|
|
404507 |
From 9c5a70bc8c9332de2e769226efe81cb95b1ce2a4 Mon Sep 17 00:00:00 2001
|
|
|
404507 |
Message-Id: <9c5a70bc8c9332de2e769226efe81cb95b1ce2a4@dist-git>
|
|
|
404507 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
404507 |
Date: Fri, 2 Feb 2018 11:12:36 +0100
|
|
|
404507 |
Subject: [PATCH] qemuDomainRemoveMemoryDevice: unlink() memory backing file
|
|
|
404507 |
|
|
|
404507 |
https://bugzilla.redhat.com/show_bug.cgi?id=1461214
|
|
|
404507 |
|
|
|
404507 |
Since fec8f9c49af we try to use predictable file names for
|
|
|
404507 |
'memory-backend-file' objects. But that made us provide full path
|
|
|
404507 |
to qemu when hot plugging the object while previously we provided
|
|
|
404507 |
merely a directory. But this makes qemu behave differently. If
|
|
|
404507 |
qemu sees a path terminated with a directory it calls mkstemp()
|
|
|
404507 |
and unlinks the file immediately. But if it sees full path it
|
|
|
404507 |
just calls open(path, O_CREAT ..); and never unlinks the file.
|
|
|
404507 |
Therefore it's up to libvirt to unlink the file and not leave it
|
|
|
404507 |
behind.
|
|
|
404507 |
|
|
|
404507 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
404507 |
(cherry picked from commit 4d83a6722f5b9c10ee85d5a5ffee364ac0e7b8af)
|
|
|
404507 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
404507 |
---
|
|
|
404507 |
src/qemu/qemu_hotplug.c | 3 +++
|
|
|
404507 |
src/qemu/qemu_process.c | 26 ++++++++++++++++++++++++++
|
|
|
404507 |
src/qemu/qemu_process.h | 4 ++++
|
|
|
404507 |
3 files changed, 33 insertions(+)
|
|
|
404507 |
|
|
|
404507 |
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
|
|
404507 |
index f1056627f2..831e014d9c 100644
|
|
|
404507 |
--- a/src/qemu/qemu_hotplug.c
|
|
|
404507 |
+++ b/src/qemu/qemu_hotplug.c
|
|
|
404507 |
@@ -3803,6 +3803,9 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
|
|
|
404507 |
if (qemuDomainNamespaceTeardownMemory(driver, vm, mem) < 0)
|
|
|
404507 |
VIR_WARN("Unable to remove memory device from /dev");
|
|
|
404507 |
|
|
|
404507 |
+ if (qemuProcessDestroyMemoryBackingPath(driver, vm, mem) < 0)
|
|
|
404507 |
+ VIR_WARN("Unable to destroy memory backing path");
|
|
|
404507 |
+
|
|
|
404507 |
virDomainMemoryDefFree(mem);
|
|
|
404507 |
|
|
|
404507 |
/* fix the balloon size */
|
|
|
404507 |
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
|
|
404507 |
index caf967dac5..3853112924 100644
|
|
|
404507 |
--- a/src/qemu/qemu_process.c
|
|
|
404507 |
+++ b/src/qemu/qemu_process.c
|
|
|
404507 |
@@ -3491,6 +3491,32 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr driver,
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
|
|
|
404507 |
+int
|
|
|
404507 |
+qemuProcessDestroyMemoryBackingPath(virQEMUDriverPtr driver,
|
|
|
404507 |
+ virDomainObjPtr vm,
|
|
|
404507 |
+ virDomainMemoryDefPtr mem)
|
|
|
404507 |
+{
|
|
|
404507 |
+ virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
|
|
404507 |
+ char *path = NULL;
|
|
|
404507 |
+ int ret = -1;
|
|
|
404507 |
+
|
|
|
404507 |
+ if (qemuGetMemoryBackingPath(vm->def, cfg, mem->info.alias, &path) < 0)
|
|
|
404507 |
+ goto cleanup;
|
|
|
404507 |
+
|
|
|
404507 |
+ if (unlink(path) < 0 &&
|
|
|
404507 |
+ errno != ENOENT) {
|
|
|
404507 |
+ virReportSystemError(errno, _("Unable to remove %s"), path);
|
|
|
404507 |
+ goto cleanup;
|
|
|
404507 |
+ }
|
|
|
404507 |
+
|
|
|
404507 |
+ ret = 0;
|
|
|
404507 |
+ cleanup:
|
|
|
404507 |
+ VIR_FREE(path);
|
|
|
404507 |
+ virObjectUnref(cfg);
|
|
|
404507 |
+ return ret;
|
|
|
404507 |
+}
|
|
|
404507 |
+
|
|
|
404507 |
+
|
|
|
404507 |
static int
|
|
|
404507 |
qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
|
|
|
404507 |
virDomainGraphicsDefPtr graphics,
|
|
|
404507 |
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
|
|
|
404507 |
index b383ff309b..8d210282f8 100644
|
|
|
404507 |
--- a/src/qemu/qemu_process.h
|
|
|
404507 |
+++ b/src/qemu/qemu_process.h
|
|
|
404507 |
@@ -43,6 +43,10 @@ int qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr driver,
|
|
|
404507 |
virDomainMemoryDefPtr mem,
|
|
|
404507 |
bool build);
|
|
|
404507 |
|
|
|
404507 |
+int qemuProcessDestroyMemoryBackingPath(virQEMUDriverPtr driver,
|
|
|
404507 |
+ virDomainObjPtr vm,
|
|
|
404507 |
+ virDomainMemoryDefPtr mem);
|
|
|
404507 |
+
|
|
|
404507 |
void qemuProcessAutostartAll(virQEMUDriverPtr driver);
|
|
|
404507 |
void qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver);
|
|
|
404507 |
|
|
|
404507 |
--
|
|
|
404507 |
2.16.1
|
|
|
404507 |
|