From f5ef291bdb2c7616f342efc20e2322e48c038eca Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Wed, 23 Aug 2017 10:39:57 +0200 Subject: [PATCH] qemu: Use short domain name in qemuDomainGetPreservedMountPath Otherwise longer domain names might generate paths that are too long to be created. This follows what other parts of the code do as well. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1453194 Signed-off-by: Martin Kletzander --- src/qemu/qemu_domain.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 05bf1c7d02..77ae450b76 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7827,14 +7827,18 @@ qemuDomainGetPreservedMountPath(virQEMUDriverConfigPtr cfg, char *path = NULL; char *tmp; const char *suffix = mountpoint + strlen(DEVPREFIX); + char *domname = virDomainObjGetShortName(vm->def); size_t off; + if (!domname) + return NULL; + if (STREQ(mountpoint, "/dev")) suffix = "dev"; if (virAsprintf(&path, "%s/%s.%s", - cfg->stateDir, vm->def->name, suffix) < 0) - return NULL; + cfg->stateDir, domname, suffix) < 0) + goto cleanup; /* Now consider that @mountpoint is "/dev/blah/blah2". * @suffix then points to "blah/blah2". However, caller @@ -7850,6 +7854,8 @@ qemuDomainGetPreservedMountPath(virQEMUDriverConfigPtr cfg, tmp++; } + cleanup: + VIR_FREE(domname); return path; }