Since commit 9dca74ee6f54, the function can take driver and a vm, no need to overcomplicate.
Signed-off-by: Martin Kletzander <mklet...@redhat.com> --- src/qemu/qemu_domain.c | 30 ++++++++++++++++++------------ src/qemu/qemu_domain.h | 9 +++------ src/qemu/qemu_process.c | 7 +------ 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 403f01e75e46..6102f7983f58 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -536,23 +536,29 @@ qemuDomainSetPrivatePathsOld(virQEMUDriverPtr driver, * can change it later on whenever we feel like so. */ int -qemuDomainSetPrivatePaths(char **domainLibDir, char **domainChannelTargetDir, - const char *confLibDir, const char *confChannelDir, - const char *domainName, int domainId) +qemuDomainSetPrivatePaths(virQEMUDriverPtr driver, + virDomainObjPtr vm) { + virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + qemuDomainObjPrivatePtr priv = vm->privateData; const int dommaxlen = 20; + int ret = -1; - if (!*domainLibDir && - virAsprintf(domainLibDir, "%s/domain-%d-%.*s", - confLibDir, domainId, dommaxlen, domainName) < 0) - return -1; + if (!priv->libDir && + virAsprintf(&priv->libDir, "%s/domain-%d-%.*s", + cfg->libDir, vm->def->id, dommaxlen, vm->def->name) < 0) + goto cleanup; - if (!*domainChannelTargetDir && - virAsprintf(domainChannelTargetDir, "%s/domain-%d-%.*s", - confChannelDir, domainId, dommaxlen, domainName) < 0) - return -1; + if (!priv->channelTargetDir && + virAsprintf(&priv->channelTargetDir, "%s/domain-%d-%.*s", + cfg->channelTargetDir, vm->def->id, + dommaxlen, vm->def->name) < 0) + goto cleanup; - return 0; + ret = 0; + cleanup: + virObjectUnref(cfg); + return ret; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 02c6012c9c87..918a77dabd29 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -551,12 +551,9 @@ bool qemuDomainSupportsNetdev(virDomainDefPtr def, int qemuDomainNetVLAN(virDomainNetDefPtr def); -int qemuDomainSetPrivatePaths(char **domainLibDir, - char **domainChannelTargetDir, - const char *confLibDir, - const char *confChannelDir, - const char *domainName, - int domainId); +int qemuDomainSetPrivatePaths(virQEMUDriverPtr driver, + virDomainObjPtr vm); + virDomainDiskDefPtr qemuDomainDiskByName(virDomainDefPtr def, const char *name); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index ea8b3efe02c4..02c13bcfbb38 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4610,12 +4610,7 @@ qemuProcessInit(virQEMUDriverPtr driver, goto stop; } - if (qemuDomainSetPrivatePaths(&priv->libDir, - &priv->channelTargetDir, - cfg->libDir, - cfg->channelTargetDir, - vm->def->name, - vm->def->id) < 0) + if (qemuDomainSetPrivatePaths(driver, vm) < 0) goto cleanup; ret = 0; -- 2.8.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list