Re: Need help regarding perl sys::virt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

_______________________________________________
libvirt-users mailing list
libvirt-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvirt-users


[Index of Archives]     [Virt Tools]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux