Roberto Attias (rattias)
2010-Oct-01 15:36 UTC
[libvirt-users] how to programmatically undefine and redefine a Domain?
Hello, I'm facing some strange behavior, and I hope you can provide a clarification. Consider the following code: virDomainPtr dom = virDomainLookupByName(virt, domain_name); if (dom) { printf("domain already defined...\n"); if (virDomainUndefine(dom)) printf("...unable to undefine!!!\n"); else { printf("...undefined."); free(dom); } } dom = virDomainDefineXML(virt, SOME_XML); if (dom != NULL) { const char *name = virDomainGetName(dom); printf("NAME IS NOW: %s\n", name); } else printf("dom is NULL!\n"); When executed the first time, the code correctly defines the domain, and prints: defining domain test2-vm libvir: QEMU error : Domain not found: no domain with matching name 'test2-vm' NAME IS NOW: test2-vm If executed a second time with the same SOME_XML when the domain is already defined, it prints: defining domain test2-vm domain already defined... libvir: Domain error : invalid domain pointer in virDomainGetName undefining......undefined.NAME IS NOW: (null) Not only the name is null, but the domain can't be started. What is the correct way to undefined programmatically a domain that is already defined? Why is the second virDomainDefineXML() returining a pointer (as opposed to null), but the pointed object seem to be invalid? Thanks, Roberto -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20101001/5a126104/attachment.htm>
Possibly Parallel Threads
- undefining and redefining a Domain
- Re: [PATCH Fedora libguestfs] Don't depend on libvirt-daemon-kvm monolith.
- virt-install error: "virDomainLookupByName() failed got unknown HTTP error code 400"
- libvir: Domain Config error : internal error incorrect root element
- HWEBayes, swapping the homozygotes genotype frequencies