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: 38b5f4faabccf681439d99e5394954c6ef7a5a40
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/lxc/lxc_process.c | 10 ++++------
src/qemu/qemu_cgroup.c | 12 ++++--------
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index cfa009f14e..d262128a50 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -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);
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 42dba1750d..6d4a82b3cd 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -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,
--
2.31.1