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

[libvirt] [PATCH 3/3] snapshot: remove snapshot metadata on transient exit



Commit 282fe1f0 documented that transient domains will auto-delete
any snapshot metadata when the last reference to the domain is
removed, and that management apps are in charge of grabbing any
snapshot metadata prior to that point.  However, this was not
actually implemented for qemu until now.

* src/qemu/qemu_driver.c (qemudDomainCreate)
(qemuDomainDestroyFlags, qemuDomainSaveInternal)
(qemudDomainCoreDump, qemuDomainRestoreFlags, qemudDomainDefine)
(qemuDomainUndefineFlags, qemuDomainMigrateConfirm3)
(qemuDomainRevertToSnapshot): Clean up snapshot metadata.
* src/qemu/qemu_migration.c (qemuMigrationPrepareAny)
(qemuMigrationPerformJob, qemuMigrationPerformPhase)
(qemuMigrationFinish): Likewise.
* src/qemu/qemu_process.c (qemuProcessHandleMonitorEOF)
(qemuProcessReconnect, qemuProcessReconnectHelper)
(qemuProcessAutoDestroyDom): Likewise.
---
 src/qemu/qemu_driver.c    |   26 ++++++++++----------------
 src/qemu/qemu_migration.c |    8 ++++----
 src/qemu/qemu_process.c   |    8 ++++----
 3 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4ff3281..0d0bea2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1318,8 +1318,7 @@ static virDomainPtr qemudDomainCreate(virConnectPtr conn, const char *xml,
                          -1, NULL, NULL, VIR_VM_OP_CREATE) < 0) {
         virDomainAuditStart(vm, "booted", false);
         if (qemuDomainObjEndJob(driver, vm) > 0)
-            virDomainRemoveInactive(&driver->domains,
-                                    vm);
+            qemuDomainRemoveInactive(driver, vm);
         vm = NULL;
         goto cleanup;
     }
@@ -1658,8 +1657,7 @@ qemuDomainDestroyFlags(virDomainPtr dom,

     if (!vm->persistent) {
         if (qemuDomainObjEndJob(driver, vm) > 0)
-            virDomainRemoveInactive(&driver->domains,
-                                    vm);
+            qemuDomainRemoveInactive(driver, vm);
         vm = NULL;
     }
     ret = 0;
@@ -2529,8 +2527,7 @@ qemuDomainSaveInternal(struct qemud_driver *driver, virDomainPtr dom,
                                      VIR_DOMAIN_EVENT_STOPPED_SAVED);
     if (!vm->persistent) {
         if (qemuDomainObjEndAsyncJob(driver, vm) > 0)
-            virDomainRemoveInactive(&driver->domains,
-                                    vm);
+            qemuDomainRemoveInactive(driver, vm);
         vm = NULL;
     }

@@ -2947,8 +2944,7 @@ endjob:
     if (qemuDomainObjEndAsyncJob(driver, vm) == 0)
         vm = NULL;
     else if ((ret == 0) && (flags & VIR_DUMP_CRASH) && !vm->persistent) {
-        virDomainRemoveInactive(&driver->domains,
-                                vm);
+        qemuDomainRemoveInactive(driver, vm);
         vm = NULL;
     }

@@ -4151,7 +4147,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
     if (qemuDomainObjEndJob(driver, vm) == 0)
         vm = NULL;
     else if (ret < 0 && !vm->persistent) {
-        virDomainRemoveInactive(&driver->domains, vm);
+        qemuDomainRemoveInactive(driver, vm);
         vm = NULL;
     }

@@ -4830,8 +4826,7 @@ static virDomainPtr qemudDomainDefine(virConnectPtr conn, const char *xml) {
     if (virDomainSaveConfig(driver->configDir,
                             vm->newDef ? vm->newDef : vm->def) < 0) {
         VIR_INFO("Defining domain '%s'", vm->def->name);
-        virDomainRemoveInactive(&driver->domains,
-                                vm);
+        qemuDomainRemoveInactive(driver, vm);
         vm = NULL;
         goto cleanup;
     }
@@ -4936,8 +4931,7 @@ qemuDomainUndefineFlags(virDomainPtr dom,
     if (virDomainObjIsActive(vm)) {
         vm->persistent = 0;
     } else {
-        virDomainRemoveInactive(&driver->domains,
-                                vm);
+        qemuDomainRemoveInactive(driver, vm);
         vm = NULL;
     }

@@ -8243,7 +8237,7 @@ qemuDomainMigrateConfirm3(virDomainPtr domain,
                (!vm->persistent || (flags & VIR_MIGRATE_UNDEFINE_SOURCE))) {
         if (flags & VIR_MIGRATE_UNDEFINE_SOURCE)
             virDomainDeleteConfig(driver->configDir, driver->autostartDir, vm);
-        virDomainRemoveInactive(&driver->domains, vm);
+        qemuDomainRemoveInactive(driver, vm);
         vm = NULL;
     }

@@ -9774,7 +9768,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
         if (qemuDomainSnapshotRevertInactive(driver, vm, snap) < 0) {
             if (!vm->persistent) {
                 if (qemuDomainObjEndJob(driver, vm) > 0)
-                    virDomainRemoveInactive(&driver->domains, vm);
+                    qemuDomainRemoveInactive(driver, vm);
                 vm = NULL;
                 goto cleanup;
             }
@@ -9797,7 +9791,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
             if (rc < 0) {
                 if (!vm->persistent) {
                     if (qemuDomainObjEndJob(driver, vm) > 0)
-                        virDomainRemoveInactive(&driver->domains, vm);
+                        qemuDomainRemoveInactive(driver, vm);
                     vm = NULL;
                     goto cleanup;
                 }
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index d9f8d93..4fd2e9f 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1127,7 +1127,7 @@ endjob:
     if (qemuMigrationJobFinish(driver, vm) == 0) {
         vm = NULL;
     } else if (!vm->persistent) {
-        virDomainRemoveInactive(&driver->domains, vm);
+        qemuDomainRemoveInactive(driver, vm);
         vm = NULL;
     }
     goto cleanup;
@@ -2272,7 +2272,7 @@ endjob:
                 (ret == 0 && (flags & VIR_MIGRATE_UNDEFINE_SOURCE)))) {
         if (flags & VIR_MIGRATE_UNDEFINE_SOURCE)
             virDomainDeleteConfig(driver->configDir, driver->autostartDir, vm);
-        virDomainRemoveInactive(&driver->domains, vm);
+        qemuDomainRemoveInactive(driver, vm);
         vm = NULL;
     }

@@ -2351,7 +2351,7 @@ endjob:
     if (refs == 0) {
         vm = NULL;
     } else if (!virDomainObjIsActive(vm) && !vm->persistent) {
-        virDomainRemoveInactive(&driver->domains, vm);
+        qemuDomainRemoveInactive(driver, vm);
         vm = NULL;
     }

@@ -2615,7 +2615,7 @@ endjob:
     if (qemuMigrationJobFinish(driver, vm) == 0) {
         vm = NULL;
     } else if (!vm->persistent && !virDomainObjIsActive(vm)) {
-        virDomainRemoveInactive(&driver->domains, vm);
+        qemuDomainRemoveInactive(driver, vm);
         vm = NULL;
     }

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 8797a56..c27a5e2 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -150,7 +150,7 @@ qemuProcessHandleMonitorEOF(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
     virDomainAuditStop(vm, auditReason);

     if (!vm->persistent)
-        virDomainRemoveInactive(&driver->domains, vm);
+        qemuDomainRemoveInactive(driver, vm);
     else
         virDomainObjUnlock(vm);

@@ -2674,7 +2674,7 @@ error:
          * user tries to start it again later */
         qemuProcessStop(driver, obj, 0, VIR_DOMAIN_SHUTOFF_FAILED);
         if (!obj->persistent)
-            virDomainRemoveInactive(&driver->domains, obj);
+            qemuDomainRemoveInactive(driver, obj);
         else
             virDomainObjUnlock(obj);
     }
@@ -2751,7 +2751,7 @@ qemuProcessReconnectHelper(void *payload,
             * Kill qemu */
             qemuProcessStop(src->driver, obj, 0, VIR_DOMAIN_SHUTOFF_FAILED);
             if (!obj->persistent)
-                virDomainRemoveInactive(&src->driver->domains, obj);
+                qemuDomainRemoveInactive(src->driver, obj);
             else
                 virDomainObjUnlock(obj);
         }
@@ -3698,7 +3698,7 @@ static void qemuProcessAutoDestroyDom(void *payload,
     if (qemuDomainObjEndJob(data->driver, dom) == 0)
         dom = NULL;
     if (dom && !dom->persistent)
-        virDomainRemoveInactive(&data->driver->domains, dom);
+        qemuDomainRemoveInactive(data->driver, dom);

 cleanup:
     if (dom)
-- 
1.7.4.4


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