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

Re: [libvirt] question about libvirt-tck/libivrt-perl



On Mon, Apr 12, 2010 at 03:41:44PM +0200, Gerhard Stenzel wrote:
> Hi, I have a small libvirt-TCK script, which fails in a for me
> unexpected way:
> ##########################################################
> use strict;
> use warnings;
> 
> use Term::ReadKey;
> 
> use Test::More tests => 4;
> 
> use Sys::Virt::TCK;
> 
> my $tck = Sys::Virt::TCK->new();
> my $conn = eval { $tck->setup(); };
> BAIL_OUT "failed to setup test harness: $@" if $@;
> END { $tck->cleanup if $tck; }
> 
> # first domain
> my $xml = $tck->generic_domain("tck")->as_xml;
> my $dom;
> ok_domain(sub { $dom = $conn->create_domain($xml) }, "defined domain
> config");
> my $uuid = $dom->get_uuid_string();
> diag $uuid;
> $xml = $dom->get_xml_description;
> 
> diag "Starting inactive domain config";
> ok($dom->get_id() > 0, "running domain has an ID > 0");
> $dom->destroy;
> 
> # new domain
> my $newxml = $tck->generic_domain("tck")->as_xml;
> 
> my $newdom;
> ok_domain(sub { $newdom = $conn->create_domain($newxml) }, "defined
> domain config");
> my $newuuid = $newdom->get_uuid_string();
> diag $newuuid;
> $newxml = $newdom->get_xml_description();
> 
> ok($newdom->get_id() > 0, "running domain has an ID > 0");
> $newdom->destroy;
> ##########################################################
> 
> scripts/network/001-prepare-image.t .. 
> 1..4
> ok 1 - defined domain config
> # 4317db52-00bb-3cac-5639-91cdce05a717
> # Starting inactive domain config
> ok 2 - running domain has an ID > 0
> ok 3 - defined domain config
> # 4317db52-00bb-3cac-5639-91cdce05a717
> libvirt error code: 42, message: Domain not found: no domain with
> matching uuid '4317db52-00bb-3cac-5639-91cdce05a717'
> 
> ##########################################################
> If I change
> my $newxml = $tck->generic_domain("tck")->as_xml;
> to 
> my $newxml = $tck->generic_domain("tck2")->as_xml;
> the script works as expected.
> 
> I am wondering if this is a problem in the libvirt-perl wrapper or
> working as designed and my expectation is simply wrong? 

It is a subtle issue crossing several layers. libvirt internally caches
virDomainPtr instances based on name. You created a object in the perl
layer '$dom' with the name, and then you create a new instance with the
same name, but assign to a diferent perl object '$newdom'. This means
that the old virDomainPtr associated with $dom still exists. If you
explicitly set '$dom = undef' before creating the second domain you
should release the old handle & make it all work as expected

Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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