2010/10/13 Matthias Bolte <[email protected]>:
> 2010/10/12 Matthias Bolte <[email protected]>:
>> 2010/10/12 Ravi Pawar <[email protected]>:
>>> hi,
>>>
>>> i am trying to undefine a domain by using dm.undefine();
>>> and then trying to create one with same name is giving me error saying
>>> 'Domain not found: no domain with matching uuid
>>> 'aeae9d4e-17cb-b661-a612-88ac677c28c1'
>>>
>>> i have attached my test program which reproduces the issue.
>>>
>>> please let me know where i am going wrong?
>>>
>>> configuration: libvirt : 0.6.3
>>> Java Bindings: 0.4.2
>>
>> I didn't look into this problem in detail, but I think you need to
>> call free on the Domain object after you undefined it.
>>
>> dm.undefine();
>> dm.free();
>> dm = null;
>>
>> Matthias
>>
>
> Okay, calling free doesn't help. I tested it with libvirt 0.6.3 and
> libvirt-java 0.4.6 and can reproduce your problem.
>
> This problem is fixed in libvirt 0.8.2. I didn't track it down to the
> actual commit.
>
> So in order to fix your problem you'll have to update libvirt to 0.8.2
> or identify the commit between 0.8.1 and 0.8.2 that fixes your problem
> and backport it to 0.6.3.
>
> Matthias
>
I found the commit (30ec755ecb3350116d2851afa0de02e77dbe2c51) that
avoids the problem in your original test code. I say 'avoid' instead
of 'fix' because the actual fix is to call free on the domain objects
after undefining them as I initially suggested. But when I tested this
I did it wrong and jumped to false conclusions.
Just to say it once again: Adding free calls solve this problem for me
with libvirt 0.6.3.
I attached a modified version of your test code that works for me.
Matthias
import org.libvirt.Connect;
import org.libvirt.Domain;
import org.libvirt.LibvirtException;
public class TestRedef {
/**
* @param args
*/
public static void main(String[] args) {
Connect conn = null;
int flags = 0;
try {
conn = new Connect("qemu:///system", false);
String dumpxml = "<domain type='kvm'>"+
"<name>tt2</name>"+
"<memory>524288</memory>"+
"<currentMemory>524288</currentMemory>"+
"<vcpu>1</vcpu>"+
"<os>"+
" <type arch='x86_64'>hvm</type>"+
" <boot dev='hd'/>"+
"</os>"+
"<features>"+
" <acpi/>"+
" <apic/>"+
" <pae/>"+
"</features>"+
"<clock offset='utc'/>"+
"<on_poweroff>destroy</on_poweroff>"+
"<on_reboot>restart</on_reboot>"+
"<on_crash>restart</on_crash>"+
"<devices>"+
" <disk type='file' device='disk'>"+
" <driver name='qemu' cache='none'/>"+
" <source file='/var/lib/libvirt/images/tt.img'/>"+
" <target dev='hda' bus='ide'/>"+
" </disk>"+
" <interface type='network'>"+
" <mac address='54:52:00:02:02:2c'/>"+
" <source network='default'/>"+
" </interface>"+
" <serial type='pty'>"+
" <target port='0'/>"+
" </serial>"+
" <console type='pty'>"+
" <target port='0'/>"+
" </console>"+
" <input type='mouse' bus='ps2'/>"+
" <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/>"+
"</devices>"+
"</domain>";
Domain dm = null;
System.out.println("lookup of tt2...");
try {
dm = conn.domainLookupByName("tt2");
} catch (LibvirtException e) {
// TODO: handle exception
}
System.out.println("lookup of tt2... done");
if (dm != null) {
System.out.println("undefine tt2...");
dm.undefine();
dm.free();
System.out.println("undefine tt2... done");
}
System.out.println("first define/undefine tt2...");
Domain dm1 = conn.domainDefineXML(dumpxml);
System.out.println("first define/undefine tt2... defined");
dm1.undefine();
dm1.free();
System.out.println("first define/undefine tt2... undefined");
System.out.println("second define/undefine tt2...");
Domain dm2 = conn.domainDefineXML(dumpxml);
System.out.println("second define/undefine tt2... defined");
dm2.undefine();
dm2.free();
System.out.println("second define/undefine tt2... undefined");
} catch (LibvirtException e) {
System.out.println("exception caught:" + e);
System.out.println(e.getError());
return;
}
}
}
_______________________________________________
libvirt-users mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvirt-users