[libvirt] [PATCH 1/5] qemuDomainCreateXML: Don't remove persistent domains on error

Michal Privoznik mprivozn at redhat.com
Tue Sep 22 15:28:53 UTC 2015


https://bugzilla.redhat.com/show_bug.cgi?id=871452

Okay, so we allow users to 'virsh create' an already existing
domain, providing completely different XML than the one stored in
Libvirt. Well, as long as name and UUID matches. However, the
code that handles errors unconditionally removes the domain that
failed to start even though the domain might have been
persistent. Fortunately, the domain is removed just from the
internal list of domains and the config file is kept around.

Steps to reproduce:

1) virsh dumpxml $dom > /tmp/dom.xml
2) change XML so that it is still parse-able but won't boot, e.g.
change guest agent path to /foo/bar
3) virsh create /tmp/dom.xml
4) virsh dumpxml $dom
5) Observe "No such domain" error

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/qemu/qemu_driver.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2387cf3..30d2d98 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1752,7 +1752,8 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
     def = NULL;
 
     if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) {
-        qemuDomainRemoveInactive(driver, vm);
+        if (!vm->persistent)
+            qemuDomainRemoveInactive(driver, vm);
         goto cleanup;
     }
 
@@ -1762,7 +1763,8 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
                          start_flags) < 0) {
         virDomainAuditStart(vm, "booted", false);
         qemuDomainObjEndJob(driver, vm);
-        qemuDomainRemoveInactive(driver, vm);
+        if (!vm->persistent)
+            qemuDomainRemoveInactive(driver, vm);
         goto cleanup;
     }
 
-- 
2.4.9




More information about the libvir-list mailing list