eyekona has asked for the wisdom of the Perl Monks concerning the following question:
Hi everybody,
Thanks to your help in my former question, i've gotten really far in my project and there is just one feature missing atm. But this feature really makes trouble. But maybe i'm just to stupid to read the description of this Cpan module.
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 what i was trying: #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();
I made tcpdump yesterday to check if and what happens. And after my "recv" request the vm-server is sending something - 5-6 Packages but as they are encrypted I can't read anything but it seems as if it sends some data for me to receive. But how can I check what this data is, if I just get blinking cursor? And in which format is this data - what do I receive? How do i deal with it?
UPDATE:
Ok at last I found out what I am doing wrong, I just used the default stream. With a stream properly defined I can send and receive text.
my $st=$con->new_stream(Sys::Virt::Stream::NONBLOCK); $dom->open_console($st, undef, 0);
When a stream is correctly defined and the program is not just taking the default - which evidently does not work - everything works just fine - very slow but fine.
Just in case someone has the same problem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CPAN Module Sys::Virt and virsh console
by daxim (Curate) on Sep 19, 2013 at 15:40 UTC | |
by eyekona (Acolyte) on Sep 20, 2013 at 07:14 UTC | |
by Anonymous Monk on Sep 20, 2013 at 08:44 UTC | |
by eyekona (Acolyte) on Sep 20, 2013 at 09:14 UTC |