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

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@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

On Tue, Dec 11, 2012 at 12:46:55PM +0000, Rawat, Vishwanath wrote:
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@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.
This is showing that libvirt failed to connect to the remote host. This is not likely to be related to the Perl bindings. You should check the same conection using virsh. eg virsh -c qemu+ssh://root@10.238.132.125/system?no_verify=1 uri
Can't call method "list_domains" on an undefined value at KVM.pl line 21.
This error is because you failed to connect, but your script ignored the error and carried on running, instead of exiting.
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";
You need to exit at this point, since you have no valid connection
}
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"; }
Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

Hi Daniel, It means that libvirt (and other related) libs should be installed on both client and server? Client is the machine from where connection is made(using $uri) to Remote machine(server). Regards, Rawat -----Original Message----- From: Daniel P. Berrange [mailto:berrange@redhat.com] Sent: Tuesday, December 11, 2012 9:29 PM To: Rawat, Vishwanath Cc: libvirt-users@redhat.com Subject: Re: [libvirt-users] Need help regarding perl sys::virt On Tue, Dec 11, 2012 at 12:46:55PM +0000, Rawat, Vishwanath wrote:
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@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.
This is showing that libvirt failed to connect to the remote host. This is not likely to be related to the Perl bindings. You should check the same conection using virsh. eg virsh -c qemu+ssh://root@10.238.132.125/system?no_verify=1 uri
Can't call method "list_domains" on an undefined value at KVM.pl line 21.
This error is because you failed to connect, but your script ignored the error and carried on running, instead of exiting.
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";
You need to exit at this point, since you have no valid connection
}
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"; }
Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 12/18/2012 03:43 AM, Rawat, Vishwanath wrote: [Please don't top-post on technical lists]
Hi Daniel,
I'm not Daniel; but one of the joys of open source development is that by posting to a public list, you can get answers from anyone.
It means that libvirt (and other related) libs should be installed on both client and server? Client is the machine from where connection is made(using $uri) to Remote machine(server).
libvirt.so must be installed on the client machine, and both libvirt.so and libvirtd must be installed on the server machine. If you use Fedora, this would be done by installing libvirt-client on the client, and libvirt-daemon-kvm (and all packages it depends on) on the server. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Daniel, Could you please help me with the question below. Please let me know if question is not clear. Regards, Rawat -----Original Message----- From: Rawat, Vishwanath Sent: Tuesday, December 18, 2012 4:14 PM To: 'Daniel P. Berrange' Cc: libvirt-users@redhat.com Subject: RE: [libvirt-users] Need help regarding perl sys::virt Hi Daniel, It means that libvirt (and other related) libs should be installed on both client and server? Client is the machine from where connection is made(using $uri) to Remote machine(server). Regards, Rawat -----Original Message----- From: Daniel P. Berrange [mailto:berrange@redhat.com] Sent: Tuesday, December 11, 2012 9:29 PM To: Rawat, Vishwanath Cc: libvirt-users@redhat.com Subject: Re: [libvirt-users] Need help regarding perl sys::virt On Tue, Dec 11, 2012 at 12:46:55PM +0000, Rawat, Vishwanath wrote:
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@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.
This is showing that libvirt failed to connect to the remote host. This is not likely to be related to the Perl bindings. You should check the same conection using virsh. eg virsh -c qemu+ssh://root@10.238.132.125/system?no_verify=1 uri
Can't call method "list_domains" on an undefined value at KVM.pl line 21.
This error is because you failed to connect, but your script ignored the error and carried on running, instead of exiting.
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";
You need to exit at this point, since you have no valid connection
}
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"; }
Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Rawat, Vishwanath