]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainRemoveMemoryDevice: unlink() memory backing file
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 11 Jan 2018 12:02:52 +0000 (13:02 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 2 Feb 2018 10:03:15 +0000 (11:03 +0100)
https://bugzilla.redhat.com/show_bug.cgi?id=1461214

Since fec8f9c49af we try to use predictable file names for
'memory-backend-file' objects. But that made us provide full path
to qemu when hot plugging the object while previously we provided
merely a directory. But this makes qemu behave differently. If
qemu sees a path terminated with a directory it calls mkstemp()
and unlinks the file immediately. But if it sees full path it
just calls open(path, O_CREAT ..); and never unlinks the file.
Therefore it's up to libvirt to unlink the file and not leave it
behind.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_hotplug.c
src/qemu/qemu_process.c
src/qemu/qemu_process.h

index a8979db2e8f1dd90325e52b865331072ec959d7d..53bfe47d08f0285f7f80c78474ee7140149c6223 100644 (file)
@@ -3900,6 +3900,9 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
     if (qemuDomainNamespaceTeardownMemory(vm, mem) <  0)
         VIR_WARN("Unable to remove memory device from /dev");
 
+    if (qemuProcessDestroyMemoryBackingPath(driver, vm, mem) < 0)
+        VIR_WARN("Unable to destroy memory backing path");
+
     virDomainMemoryDefFree(mem);
 
     /* fix the balloon size */
index fe12d94d37802e14b8a4007f4e0c7543651679ff..5a364730c8c1e8befc55056ba02c4b4f2ba7f2ab 100644 (file)
@@ -3494,6 +3494,32 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr driver,
 }
 
 
+int
+qemuProcessDestroyMemoryBackingPath(virQEMUDriverPtr driver,
+                                    virDomainObjPtr vm,
+                                    virDomainMemoryDefPtr mem)
+{
+    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+    char *path = NULL;
+    int ret = -1;
+
+    if (qemuGetMemoryBackingPath(vm->def, cfg, mem->info.alias, &path) < 0)
+        goto cleanup;
+
+    if (unlink(path) < 0 &&
+        errno != ENOENT) {
+        virReportSystemError(errno, _("Unable to remove %s"), path);
+        goto cleanup;
+    }
+
+    ret = 0;
+ cleanup:
+    VIR_FREE(path);
+    virObjectUnref(cfg);
+    return ret;
+}
+
+
 static int
 qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
                             virDomainGraphicsDefPtr graphics,
index b383ff309bf4d849a5ef5c57d4c5a51c3c62d31f..8d210282f88368e862ec639eef80e2e0e702bca9 100644 (file)
@@ -43,6 +43,10 @@ int qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr driver,
                                        virDomainMemoryDefPtr mem,
                                        bool build);
 
+int qemuProcessDestroyMemoryBackingPath(virQEMUDriverPtr driver,
+                                        virDomainObjPtr vm,
+                                        virDomainMemoryDefPtr mem);
+
 void qemuProcessAutostartAll(virQEMUDriverPtr driver);
 void qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver);