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>
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
tmp++;
}
+ cleanup:
+ VIR_FREE(domname);
return path;
}