mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-31 08:55:22 +00:00
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 <mkletzan@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
f58a4dc9d5
commit
ff49d2a8c2
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -944,7 +944,6 @@ int qemuGetMemoryBackingDomainPath(qemuDomainObjPrivate *priv,
|
||||
char **path);
|
||||
|
||||
int qemuGetMemoryBackingPath(qemuDomainObjPrivate *priv,
|
||||
const virDomainDef *def,
|
||||
const char *alias,
|
||||
char **memPath);
|
||||
|
||||
|
@ -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 &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user