[PATCH 4/8] qemu: Allow to undefine a running domain

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

 



---
 src/qemu/qemu_driver.c |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 421a98e..81be950 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4720,12 +4720,6 @@ qemuDomainUndefineFlags(virDomainPtr dom,
         goto cleanup;
     }
 
-    if (virDomainObjIsActive(vm)) {
-        qemuReportError(VIR_ERR_OPERATION_INVALID,
-                        "%s", _("cannot delete active domain"));
-        goto cleanup;
-    }
-
     if (!vm->persistent) {
         qemuReportError(VIR_ERR_OPERATION_INVALID,
                         "%s", _("cannot undefine transient domain"));
@@ -4760,9 +4754,19 @@ qemuDomainUndefineFlags(virDomainPtr dom,
                                      VIR_DOMAIN_EVENT_UNDEFINED_REMOVED);
 
     VIR_INFO("Undefining domain '%s'", vm->def->name);
-    virDomainRemoveInactive(&driver->domains,
-                            vm);
-    vm = NULL;
+
+    /* If the domain is active, keep it running but set it as transient.
+     * domainDestroy and domainShutdown will take care of remove the
+     * domain obj from the hash table.
+     */
+    if (virDomainObjIsActive(vm)) {
+        vm->persistent = 0;
+    } else {
+        virDomainRemoveInactive(&driver->domains,
+                                vm);
+        vm = NULL;
+    }
+
     ret = 0;
 
 cleanup:
-- 
1.7.6

--
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]