src: fix generation of default resource partition

Now that resource structure can have appid as well we need to adapt code
that creates default resource partition if not provided by user.
Otherwise starting a VM with appid defined would fail with following
error:

    error: unsupported configuration: Resource partition '(null)' must start with '/'

Fixes: 38b5f4faab
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Pavel Hrdina 2021-08-25 13:01:52 +02:00
parent cb6c650064
commit 3796e8e1ff
2 changed files with 8 additions and 14 deletions

View File

@ -1258,13 +1258,11 @@ int virLXCProcessStart(virConnectPtr conn,
return -1;
}
if (!vm->def->resource) {
virDomainResourceDef *res = g_new0(virDomainResourceDef, 1);
if (!vm->def->resource)
vm->def->resource = g_new0(virDomainResourceDef, 1);
res->partition = g_strdup("/machine");
vm->def->resource = res;
}
if (!vm->def->resource->partition)
vm->def->resource->partition = g_strdup("/machine");
logfile = g_strdup_printf("%s/%s.log", cfg->logDir, vm->def->name);

View File

@ -949,15 +949,11 @@ qemuInitCgroup(virDomainObj *vm,
virCgroupFree(priv->cgroup);
priv->cgroup = NULL;
if (!vm->def->resource) {
virDomainResourceDef *res;
if (!vm->def->resource)
vm->def->resource = g_new0(virDomainResourceDef, 1);
res = g_new0(virDomainResourceDef, 1);
res->partition = g_strdup("/machine");
vm->def->resource = res;
}
if (!vm->def->resource->partition)
vm->def->resource->partition = g_strdup("/machine");
if (!g_path_is_absolute(vm->def->resource->partition)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,