From: Marc-André Lureau <marcandre.lur...@redhat.com> Each vhost-user-gpu needs its own helper gpu process. Start/stop them, and apply the emulator cgroup controller.
Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- src/qemu/qemu_extdevice.c | 47 ++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c index d982922470..8ec703a9b0 100644 --- a/src/qemu/qemu_extdevice.c +++ b/src/qemu/qemu_extdevice.c @@ -25,6 +25,7 @@ #include "qemu_extdevice.h" #include "qemu_domain.h" #include "qemu_tpm.h" +#include "qemu_vhost_user_gpu.h" #include "viralloc.h" #include "virlog.h" @@ -132,11 +133,21 @@ qemuExtDevicesStart(virQEMUDriverPtr driver, virDomainDefPtr def, qemuDomainLogContextPtr logCtxt) { - int ret = 0; + int i, ret = 0; if (qemuExtDevicesInitPaths(driver, def) < 0) return -1; + for (i = 0; i < def->nvideos; i++) { + virDomainVideoDefPtr video = def->videos[i]; + + if (video->type == VIR_DOMAIN_VIDEO_TYPE_VHOST_USER) { + ret = qemuExtVhostUserGPUStart(driver, def, video, logCtxt); + if (ret < 0) + return ret; + } + } + if (def->tpm) ret = qemuExtTPMStart(driver, def, logCtxt); @@ -148,9 +159,19 @@ void qemuExtDevicesStop(virQEMUDriverPtr driver, virDomainDefPtr def) { + int i; + if (qemuExtDevicesInitPaths(driver, def) < 0) return; + for (i = 0; i < def->nvideos; i++) { + virDomainVideoDefPtr video = def->videos[i]; + + if (video->type == VIR_DOMAIN_VIDEO_TYPE_VHOST_USER) { + qemuExtVhostUserGPUStop(driver, def, video); + } + } + if (def->tpm) qemuExtTPMStop(driver, def); } @@ -159,6 +180,13 @@ qemuExtDevicesStop(virQEMUDriverPtr driver, bool qemuExtDevicesHasDevice(virDomainDefPtr def) { + int i; + + for (i = 0; i < def->nvideos; i++) { + if (def->videos[i]->type == VIR_DOMAIN_VIDEO_TYPE_VHOST_USER) + return true; + } + if (def->tpm && def->tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR) return true; @@ -171,10 +199,19 @@ qemuExtDevicesSetupCgroup(virQEMUDriverPtr driver, virDomainDefPtr def, virCgroupPtr cgroup) { - int ret = 0; + int i; - if (def->tpm) - ret = qemuExtTPMSetupCgroup(driver, def, cgroup); + for (i = 0; i < def->nvideos; i++) { + virDomainVideoDefPtr video = def->videos[i]; - return ret; + if (video->type == VIR_DOMAIN_VIDEO_TYPE_VHOST_USER && + qemuExtVhostUserGPUSetupCgroup(driver, def, video, cgroup) < 0) + return -1; + } + + if (def->tpm && + qemuExtTPMSetupCgroup(driver, def, cgroup) < 0) + return -1; + + return 0; } -- 2.18.0.129.ge3331758f1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list