---
src/qemu/qemu_driver.c | 31 +++++++++++++++++++++++++++----
1 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f962e2c..a9f6986 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2402,10 +2402,8 @@ cleanup:
static char *
qemuDomainManagedSavePath(struct qemud_driver *driver, virDomainObjPtr vm) {
char *ret;
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(vm->def->uuid, uuidstr);
- if (virAsprintf(&ret, "%s/%s.save", driver->saveDir, uuidstr) <
0) {
+ if (virAsprintf(&ret, "%s/%s.save", driver->saveDir,
vm->def->name) < 0) {
virReportOOMError();
return(NULL);
}
@@ -4283,11 +4281,16 @@ cleanup:
return dom;
}
-static int qemudDomainUndefine(virDomainPtr dom) {
+static int qemudDomainUndefineWithFlags(virDomainPtr dom,
+ unsigned int flags)
+{
struct qemud_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
virDomainEventPtr event = NULL;
int ret = -1;
+ char *name = NULL;
+
+ virCheckFlags(VIR_DOMAIN_UNDEFINE_MANAGED_STATE, -1);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -4312,6 +4315,20 @@ static int qemudDomainUndefine(virDomainPtr dom) {
goto cleanup;
}
+ if (flags & VIR_DOMAIN_UNDEFINE_MANAGED_STATE) {
+ name = qemuDomainManagedSavePath(driver, vm);
+
+ if (name == NULL)
+ goto cleanup;
+
+ if (virFileExists(name) && (unlink(name) < 0)) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("failed on removing domain managed state "
+ "file '%s'"), name);
+ goto cleanup;
+ }
+ }
+
if (virDomainDeleteConfig(driver->configDir, driver->autostartDir, vm) < 0)
goto cleanup;
@@ -4326,6 +4343,7 @@ static int qemudDomainUndefine(virDomainPtr dom) {
ret = 0;
cleanup:
+ VIR_FREE(name);
if (vm)
virDomainObjUnlock(vm);
if (event)
@@ -4334,6 +4352,10 @@ cleanup:
return ret;
}
+static int qemudDomainUndefine(virDomainPtr dom) {
+ return qemudDomainUndefineWithFlags(dom, 0);
+}
+
static int
qemuDomainAttachDeviceDiskLive(struct qemud_driver *driver,
virDomainObjPtr vm,
@@ -8487,6 +8509,7 @@ static virDriver qemuDriver = {
.domainCreateWithFlags = qemudDomainStartWithFlags, /* 0.8.2 */
.domainDefineXML = qemudDomainDefine, /* 0.2.0 */
.domainUndefine = qemudDomainUndefine, /* 0.2.0 */
+ .domainUndefineWithFlags = qemudDomainUndefineWithFlags, /* 0.9.4 */
.domainAttachDevice = qemuDomainAttachDevice, /* 0.4.1 */
.domainAttachDeviceFlags = qemuDomainAttachDeviceFlags, /* 0.7.7 */
.domainDetachDevice = qemuDomainDetachDevice, /* 0.5.0 */
--
1.7.6