我正在使用 Sys::Virt CPAN 模块与我的 kvm 管理程序“对话”并管理域。我可以做几乎所有常规使用的 bash virsh 命令可以做的事情,除了 virsh 控制台,它(谁会猜到)打开一个域的文本控制台。但是无论我用 sys::virt 做什么,我都会得到一个闪烁的光标,什么也没有发生。我也无法在整个万维网上找到一个例子......所以我想我问你我错过了什么。这是我到目前为止的代码 - 以及我测试过的代码:
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();
我错过了什么 - 或做错了什么?有任何想法吗?