From: Michael Galaxy <mgalaxy(a)akamai.com>
Signed-off-by: Michael Galaxy <mgalaxy(a)akamai.com>
---
src/qemu/qemu_driver.c | 31 +++++++++++++++++-----------
src/qemu/qemu_hotplug.c | 6 +++---
src/qemu/qemu_process.c | 45 ++++++++++++++++++++++++-----------------
src/qemu/qemu_process.h | 13 ++++++------
4 files changed, 54 insertions(+), 41 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 448e6b1591..98742f83c8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -653,11 +653,14 @@ qemuStateInitialize(bool privileged,
cfg->nvramDir);
goto error;
}
- if (g_mkdir_with_parents(cfg->memoryBackingDir, 0777) < 0) {
- virReportSystemError(errno, _("Failed to create memory backing dir
%1$s"),
- cfg->memoryBackingDir);
- goto error;
+ for (i = 0; i < cfg->nb_memoryBackingDirs; i++) {
+ if (g_mkdir_with_parents(cfg->memoryBackingDirs[i], 0777) < 0) {
+ virReportSystemError(errno, _("Failed to create memory backing dir # %1$lu @ %2$s,
total: %3$lu"),
+ i, cfg->memoryBackingDirs[i], cfg->nb_memoryBackingDirs);
+ goto error;
+ }
}
+
if (g_mkdir_with_parents(cfg->slirpStateDir, 0777) < 0) {
virReportSystemError(errno, _("Failed to create slirp state dir
%1$s"),
cfg->slirpStateDir);
@@ -802,13 +805,15 @@ qemuStateInitialize(bool privileged,
(int)cfg->group);
goto error;
}
- if (chown(cfg->memoryBackingDir, cfg->user, cfg->group) < 0) {
- virReportSystemError(errno,
+ for (i = 0; i < cfg->nb_memoryBackingDirs; i++) {
+ if (chown(cfg->memoryBackingDirs[i], cfg->user, cfg->group) < 0)
{
+ virReportSystemError(errno,
_("unable to set ownership of '%1$s' to
%2$d:%3$d"),
- cfg->memoryBackingDir, (int)cfg->user,
+ cfg->memoryBackingDirs[i], (int)cfg->user,
(int)cfg->group);
- goto error;
- }
+ goto error;
+ }
+ }
if (chown(cfg->slirpStateDir, cfg->user, cfg->group) < 0) {
virReportSystemError(errno,
_("unable to set ownership of '%1$s' to
%2$d:%3$d"),
@@ -855,10 +860,12 @@ qemuStateInitialize(bool privileged,
goto error;
}
- if (privileged &&
- virFileUpdatePerm(cfg->memoryBackingDir,
+ for (i = 0; i < cfg->nb_memoryBackingDirs; i++) {
+ if (privileged &&
+ virFileUpdatePerm(cfg->memoryBackingDirs[i],
0, S_IXGRP | S_IXOTH) < 0)
- goto error;
+ goto error;
+ }
/* Get all the running persistent or transient configs first */
if (virDomainObjListLoadAllConfigs(qemu_driver->domains,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 31b00e05ca..c3d636d167 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2289,7 +2289,7 @@ qemuDomainAttachMemory(virQEMUDriver *driver,
priv, vm->def, mem, true, false, NULL) < 0)
goto cleanup;
- if (qemuProcessBuildDestroyMemoryPaths(driver, vm, mem, true) < 0)
+ if (qemuProcessBuildDestroyMemoryPaths(vm, mem, true) < 0)
goto cleanup;
if (qemuDomainNamespaceSetupMemory(vm, mem, &teardowndevice) < 0)
@@ -2364,7 +2364,7 @@ qemuDomainAttachMemory(virQEMUDriver *driver,
qemuDomainObjExitMonitor(vm);
if (objAdded && mem)
- ignore_value(qemuProcessDestroyMemoryBackingPath(driver, vm, mem));
+ ignore_value(qemuProcessDestroyMemoryBackingPath(vm->def, priv, mem));
virErrorRestore(&orig_err);
if (!mem)
@@ -4640,7 +4640,7 @@ qemuDomainRemoveMemoryDevice(virQEMUDriver *driver,
if (qemuDomainNamespaceTeardownMemory(vm, mem) < 0)
VIR_WARN("Unable to remove memory device from /dev");
- if (qemuProcessDestroyMemoryBackingPath(driver, vm, mem) < 0)
+ if (qemuProcessDestroyMemoryBackingPath(vm->def, priv, mem) < 0)
VIR_WARN("Unable to destroy memory backing path");
qemuDomainReleaseMemoryDeviceSlot(vm, mem);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c1115b440f..48681ef97f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4002,12 +4002,12 @@ qemuProcessBuildDestroyMemoryPathsImpl(virQEMUDriver *driver,
int
-qemuProcessBuildDestroyMemoryPaths(virQEMUDriver *driver,
- virDomainObj *vm,
+qemuProcessBuildDestroyMemoryPaths(virDomainObj *vm,
virDomainMemoryDef *mem,
bool build)
{
-
+ qemuDomainObjPrivate *priv = vm->privateData;
+ virQEMUDriver *driver = priv->driver;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
size_t i;
bool shouldBuildHP = false;
@@ -4037,13 +4037,15 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriver *driver,
}
if (!build || shouldBuildMB) {
- g_autofree char *path = NULL;
- if (qemuGetMemoryBackingDomainPath(driver, vm->def, &path) < 0)
- return -1;
+ for (i = 0; i < cfg->nb_memoryBackingDirs; i++) {
+ g_autofree char *path = NULL;
+ if (qemuGetMemoryBackingDomainPath(vm->def, vm->privateData, i, &path) <
0)
+ return -1;
- if (qemuProcessBuildDestroyMemoryPathsImpl(driver, vm,
- path, build) < 0)
- return -1;
+ if (qemuProcessBuildDestroyMemoryPathsImpl(driver, vm,
+ path, build) < 0)
+ return -1;
+ }
}
return 0;
@@ -4051,19 +4053,24 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriver *driver,
int
-qemuProcessDestroyMemoryBackingPath(virQEMUDriver *driver,
- virDomainObj *vm,
+qemuProcessDestroyMemoryBackingPath(virDomainDef *def,
+ qemuDomainObjPrivate *priv,
virDomainMemoryDef *mem)
{
+ virQEMUDriver *driver = priv->driver;
g_autofree char *path = NULL;
+ g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
- if (qemuGetMemoryBackingPath(driver, vm->def, mem->info.alias, &path) <
0)
- return -1;
+ for (size_t i = 0; i < cfg->nb_memoryBackingDirs; i++) {
+ virDomainXMLPrivateDataCallbacks *privateData = (virDomainXMLPrivateDataCallbacks *)
priv;
+ if (qemuGetMemoryBackingPath(def, privateData, i, mem->info.alias, &path)
< 0)
+ return -1;
- if (unlink(path) < 0 &&
- errno != ENOENT) {
- virReportSystemError(errno, _("Unable to remove %1$s"), path);
- return -1;
+ if (unlink(path) < 0 &&
+ errno != ENOENT) {
+ virReportSystemError(errno, _("Unable to remove %1$s"), path);
+ return -1;
+ }
}
return 0;
@@ -7225,7 +7232,7 @@ qemuProcessPrepareHost(virQEMUDriver *driver,
if (qemuProcessPrepareHostBackendChardev(vm) < 0)
return -1;
- if (qemuProcessBuildDestroyMemoryPaths(driver, vm, NULL, true) < 0)
+ if (qemuProcessBuildDestroyMemoryPaths(vm, NULL, true) < 0)
return -1;
/* Ensure no historical cgroup for this VM is lying around bogus
@@ -8438,7 +8445,7 @@ void qemuProcessStop(virQEMUDriver *driver,
goto endjob;
}
- qemuProcessBuildDestroyMemoryPaths(driver, vm, NULL, false);
+ qemuProcessBuildDestroyMemoryPaths(vm, NULL, false);
if (!!g_atomic_int_dec_and_test(&driver->nactive) &&
driver->inhibitCallback)
driver->inhibitCallback(false, driver->inhibitOpaque);
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index c1ea949215..2993ef518a 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -38,14 +38,13 @@ int qemuProcessStopCPUs(virQEMUDriver *driver,
virDomainPausedReason reason,
virDomainAsyncJob asyncJob);
-int qemuProcessBuildDestroyMemoryPaths(virQEMUDriver *driver,
- virDomainObj *vm,
- virDomainMemoryDef *mem,
- bool build);
+int qemuProcessBuildDestroyMemoryPaths(virDomainObj *vm,
+ virDomainMemoryDef *mem,
+ bool build);
-int qemuProcessDestroyMemoryBackingPath(virQEMUDriver *driver,
- virDomainObj *vm,
- virDomainMemoryDef *mem);
+int qemuProcessDestroyMemoryBackingPath(virDomainDef *def,
+ qemuDomainObjPrivate *priv,
+ virDomainMemoryDef *mem);
void qemuProcessReconnectAll(virQEMUDriver *driver);
--
2.25.1