From: Marc-André Lureau <marcandre.lureau(a)redhat.com>
External devices are started before cgroup is created. Add the DBus
daemon to the VM cgroup with the rest of the external devices.
Signed-off-by: Marc-André Lureau <marcandre.lureau(a)redhat.com>
---
src/qemu/qemu_dbus.c | 24 ++++++++++++++++++++++++
src/qemu/qemu_dbus.h | 3 +++
src/qemu/qemu_extdevice.c | 4 ++++
3 files changed, 31 insertions(+)
diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c
index 02dc3ebf07..53f6c45986 100644
--- a/src/qemu/qemu_dbus.c
+++ b/src/qemu/qemu_dbus.c
@@ -156,6 +156,30 @@ qemuDBusStop(virQEMUDriverPtr driver,
}
+int
+qemuDBusSetupCgroup(virQEMUDriverPtr driver,
+ virDomainObjPtr vm)
+{
+ g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ g_autofree char *shortName = NULL;
+ g_autofree char *pidfile = NULL;
+ pid_t cpid = -1;
+
+ if (!priv->dbusDaemonRunning)
+ return 0;
+
+ if (!(shortName = virDomainDefGetShortName(vm->def)))
+ return -1;
+ pidfile = qemuDBusCreatePidFilename(cfg, shortName);
+ if (virPidFileReadPath(pidfile, &cpid) < 0) {
+ VIR_WARN("Unable to get DBus PID");
+ return -1;
+ }
+
+ return virCgroupAddProcess(priv->cgroup, cpid);
+}
+
int
qemuDBusStart(virQEMUDriverPtr driver,
virDomainObjPtr vm)
diff --git a/src/qemu/qemu_dbus.h b/src/qemu/qemu_dbus.h
index a96f19ac0d..474eb1058b 100644
--- a/src/qemu/qemu_dbus.h
+++ b/src/qemu/qemu_dbus.h
@@ -35,3 +35,6 @@ void qemuDBusStop(virQEMUDriverPtr driver,
int qemuDBusVMStateAdd(virDomainObjPtr vm, const char *id);
void qemuDBusVMStateRemove(virDomainObjPtr vm, const char *id);
+
+int qemuDBusSetupCgroup(virQEMUDriverPtr driver,
+ virDomainObjPtr vm);
diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c
index dae3524307..2096272761 100644
--- a/src/qemu/qemu_extdevice.c
+++ b/src/qemu/qemu_extdevice.c
@@ -23,6 +23,7 @@
#include "qemu_command.h"
#include "qemu_extdevice.h"
#include "qemu_vhost_user_gpu.h"
+#include "qemu_dbus.h"
#include "qemu_domain.h"
#include "qemu_tpm.h"
#include "qemu_slirp.h"
@@ -276,6 +277,9 @@ qemuExtDevicesSetupCgroup(virQEMUDriverPtr driver,
virDomainDefPtr def = vm->def;
size_t i;
+ if (qemuDBusSetupCgroup(driver, vm) < 0)
+ return -1;
+
for (i = 0; i < def->nvideos; i++) {
virDomainVideoDefPtr video = def->videos[i];
--
2.26.0.106.g9fadedd637