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 <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander 2017-08-23 10:39:57 +02:00
parent 5102be52d8
commit f5ef291bdb

View File

@ -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;
}