[PATCH v2 4/4] virDomainRestore: Don't keep transient domains around

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

 



So while working on my previous patches, I've noticed that
virDomainRestore implementation in qemu and test drivers has the
same problem as I am fixing.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 4 ++--
 src/test/test_driver.c | 7 ++++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3532973..562a0b6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6828,8 +6828,6 @@ qemuDomainRestoreFlags(virConnectPtr conn,
         VIR_WARN("Failed to close %s", path);
 
     qemuDomainObjEndJob(driver, vm);
-    if (ret < 0)
-        qemuDomainRemoveInactive(driver, vm);
 
  cleanup:
     virDomainDefFree(def);
@@ -6837,6 +6835,8 @@ qemuDomainRestoreFlags(virConnectPtr conn,
     VIR_FREE(xml);
     VIR_FREE(xmlout);
     virFileWrapperFdFree(wrapperFd);
+    if (vm && ret < 0)
+        qemuDomainRemoveInactive(driver, vm);
     virDomainObjEndAPI(&vm);
     virNWFilterUnlockFilterUpdates();
     return ret;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 01ab1e3..9ccd567 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2132,8 +2132,13 @@ testDomainRestoreFlags(virConnectPtr conn,
         goto cleanup;
     def = NULL;
 
-    if (testDomainStartState(privconn, dom, VIR_DOMAIN_RUNNING_RESTORED) < 0)
+    if (testDomainStartState(privconn, dom, VIR_DOMAIN_RUNNING_RESTORED) < 0) {
+        if (!dom->persistent) {
+            virDomainObjListRemove(privconn->domains, dom);
+            dom = NULL;
+        }
         goto cleanup;
+    }
 
     event = virDomainEventLifecycleNewFromObj(dom,
                                      VIR_DOMAIN_EVENT_STARTED,
-- 
2.4.9

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]