In near future we will need more than just a plain VIR_STRDUP(). Better implement that in a separate function and in qemuBuildMemoryBackendStr() which is complicated enough already. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_conf.c | 18 ++++++++++++++++++ src/qemu/qemu_conf.h | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b1cfafa79..82d2fb2a3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3439,7 +3439,7 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps, } else { /* We can have both pagesize and mem source. If that's the case, * prefer hugepages as those are more specific. */ - if (VIR_STRDUP(memPath, cfg->memoryBackingDir) < 0) + if (qemuGetMemoryBackingPath(cfg, &memPath) < 0) goto cleanup; } diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index bf6b334f4..23dcc25e1 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1748,3 +1748,21 @@ qemuGetDomainHupageMemPath(const virDomainDef *def, return 0; } + + +/** + * qemuGetMemoryBackingPath: + * @cfg: the driver config + * @memPath: constructed path + * + * Constructs path to memory backing dir and stores it at @memPath. + * + * Returns: 0 on success, + * -1 otherwise (with error reported). + */ +int +qemuGetMemoryBackingPath(virQEMUDriverConfigPtr cfg, + char **memPath) +{ + return VIR_STRDUP(*memPath, cfg->memoryBackingDir); +} diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 13b6f818a..9d6866816 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -363,4 +363,7 @@ int qemuGetDomainHupageMemPath(const virDomainDef *def, virQEMUDriverConfigPtr cfg, unsigned long long pagesize, char **memPath); + +int qemuGetMemoryBackingPath(virQEMUDriverConfigPtr cfg, + char **memPath); #endif /* __QEMUD_CONF_H */ -- 2.13.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list