From: Martin Kletzander Date: Wed, 18 Sep 2024 08:46:47 +0000 (+0200) Subject: qemu: Use per-domain private memoryBackingDir for new memory backends X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=ff49d2a8c2bfc5a03147228a6b7d41c3c80e5ef9;p=libvirt.git qemu: Use per-domain private memoryBackingDir for new memory backends The function qemuGetMemoryBackingPath() does not need the @def any more and priv->memoryBackingDir can be used instead of constructing the path by calling qemuGetMemoryBackingDomainPath(). Signed-off-by: Martin Kletzander Reviewed-by: Michal Privoznik --- diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f36b02b76b..167ee8240b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3222,7 +3222,7 @@ qemuBuildMemoryBackendProps(virJSONValue **backendProps, } else { /* We can have both pagesize and mem source. If that's the case, * prefer hugepages as those are more specific. */ - if (qemuGetMemoryBackingPath(priv, def, mem->info.alias, &memPath) < 0) + if (qemuGetMemoryBackingPath(priv, mem->info.alias, &memPath) < 0) return -1; } @@ -7116,7 +7116,7 @@ qemuBuildMemPathStr(const virDomainDef *def, return -1; prealloc = true; } else if (def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) { - if (qemuGetMemoryBackingPath(priv, def, "ram", &mem_path) < 0) + if (qemuGetMemoryBackingPath(priv, "ram", &mem_path) < 0) return -1; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b05b1c9647..3e80313ab7 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1762,7 +1762,6 @@ qemuGetMemoryBackingDomainPath(qemuDomainObjPrivate *priv, /** * qemuGetMemoryBackingPath: * @priv: domain private data - * @def: domain definition * @alias: memory object alias * @memPath: constructed path * @@ -1773,12 +1772,9 @@ qemuGetMemoryBackingDomainPath(qemuDomainObjPrivate *priv, */ int qemuGetMemoryBackingPath(qemuDomainObjPrivate *priv, - const virDomainDef *def, const char *alias, char **memPath) { - g_autofree char *domainPath = NULL; - if (!alias) { /* This should never happen (TM) */ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -1786,10 +1782,8 @@ qemuGetMemoryBackingPath(qemuDomainObjPrivate *priv, return -1; } - if (qemuGetMemoryBackingDomainPath(priv, def, &domainPath) < 0) - return -1; + *memPath = g_strdup_printf("%s/%s", priv->memoryBackingDir, alias); - *memPath = g_strdup_printf("%s/%s", domainPath, alias); return 0; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 8f41c4af81..dcff4272b8 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -944,7 +944,6 @@ int qemuGetMemoryBackingDomainPath(qemuDomainObjPrivate *priv, char **path); int qemuGetMemoryBackingPath(qemuDomainObjPrivate *priv, - const virDomainDef *def, const char *alias, char **memPath); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1d3a905dd8..dd3afbeb39 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4094,12 +4094,9 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriver *driver, } if (!build || shouldBuildMB) { - g_autofree char *path = NULL; - if (qemuGetMemoryBackingDomainPath(QEMU_DOMAIN_PRIVATE(vm), vm->def, &path) < 0) - return -1; - if (qemuProcessBuildDestroyMemoryPathsImpl(driver, vm, - path, build) < 0) + QEMU_DOMAIN_PRIVATE(vm)->memoryBackingDir, + build) < 0) return -1; } @@ -4113,7 +4110,7 @@ qemuProcessDestroyMemoryBackingPath(virDomainObj *vm, { g_autofree char *path = NULL; - if (qemuGetMemoryBackingPath(QEMU_DOMAIN_PRIVATE(vm), vm->def, mem->info.alias, &path) < 0) + if (qemuGetMemoryBackingPath(QEMU_DOMAIN_PRIVATE(vm), mem->info.alias, &path) < 0) return -1; if (unlink(path) < 0 &&