I'm using Sys::Virt CPAN module to "talk" to my kvm hypervisors and manage the domains. I can do nearly everything the noramlly used bash virsh command can do, except for virsh console, which (who would guess it) opens a text console to a domain. But whatever i do with sys::virt i just get a blinking cursor and nothing happens. I also am not able to find a single example on the whole wide web... So I thought i ask you what i am missing. Here is the code i have so far - and what i have tested:
use 5.010;
use warnings;
use Sys::Virt;
use Sys::Virt::Stream;
my $data;
my $url = "someurl";
my $con = Sys::Virt->new('uri' => "qemu+tls://$url/system");
my $dom = $con->get_domain_by_name("name");
#Until here everything is just like in every other function i wrote.
my $st = $con->new_stream();
$dom->open_console($st, undef);
#I guess that i'm also fine until here - because there are no errors..
#And now i'm trying to do something with this stream object i made...
#If i would type virsh console i would get a promt to log in, so i try to fetch this promt.
#Here are two examples of how i was trying to get it:
#Result of this block: Blinking cursor - no "test"
my $rv = $st->recv($data, "1");
say "test";
say $rv;
say $data;
#Result of this block: Blinking cursor - no "test"
$st->recv_all(sub{
my ($st, $data, $nbytes) = @_;
});
say "test";
say $st;
say $data;
say $nbytes;
$st->finish();
What am I missing - or doing wrong? Any ideas?