[libvirt-users] Need help regarding perl sys::virt

Rawat, Vishwanath Vishwanath.Rawat at netapp.com
Tue Dec 11 12:46:55 UTC 2012


Hi,
                I wanted to use perl Sys::Virt (which uses libvirt) to remotely connect KVM hypervisor. As a start I tried following simple script(KVM.pl) but I am getting following error.
First it will ask for authentication which I am providing to it manually then it fails. Do I need to do some configuration on KVM hypervisor before executing this script? Any help is appreciated.

bash-3.2$ perl KVM.pl
root at 10.238.132.125's password:
Unable to open connection to qemu+ssh://root@10.238.132.125/system?no_verify=1: End of file while reading data: Warning: Perm: Input/output error8.132.125' (RSA) to the list of known hosts.
Can't call method "list_domains" on an undefined value at KVM.pl line 21.
bash-3.2$

bash-3.2$ cat KVM.pl

use strict;
use warnings;
use Sys::Virt;
use Data::Dump qw(dump);

my $user = "root";
my $host = <some_host>;

my $uri = "qemu+ssh://root\@$host/system?no_verify=1";

my $vmm;
eval {
  $vmm = Sys::Virt->new(uri => $uri, readonly => 1);
};
if ($@) {
    print "Unable to open connection to $uri: " . $@->message . "\n";
}

for my $dom ($vmm->list_domains, $vmm->list_defined_domains) {
  ## see perldoc Sys::Virt::Domain
  print "name: ", $dom->get_name, "\n";
  print "uuid: ", $dom->get_uuid_string(), "\n";
  ## $dom->get_info returns a hash reference
  dump $dom->get_info;
  print "\n";
}

Regards,
Rawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20121211/d16f6e2b/attachment.htm>


More information about the libvirt-users mailing list