mirror of https://gitee.com/openkylin/libvirt.git
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.
This commit is contained in:
parent
bcf974b94b
commit
e485dcc9cb
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -2671,11 +2671,12 @@ error:
|
|||
|
||||
if (virDomainObjUnref(obj) > 0) {
|
||||
/* We can't get the monitor back, so must kill the VM
|
||||
* to remove danger of it ending up running twice if
|
||||
* user tries to start it again later */
|
||||
* to remove danger of it ending up running twice if
|
||||
* 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);
|
||||
}
|
||||
|
@ -2753,7 +2754,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);
|
||||
}
|
||||
|
@ -3700,7 +3701,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)
|
||||
|
|
Loading…
Reference in New Issue