]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: start/stop the vhost-user-gpu external device
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 23 Sep 2019 10:44:41 +0000 (14:44 +0400)
committerCole Robinson <crobinso@redhat.com>
Tue, 24 Sep 2019 17:19:09 +0000 (13:19 -0400)
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.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
src/qemu/qemu_extdevice.c

index 7855fa677081d70aecff61a214c0fd1e74661961..abcaa9fca22adb76845c870ca0e1183b7d2772b5 100644 (file)
@@ -162,6 +162,16 @@ qemuExtDevicesStart(virQEMUDriverPtr driver,
     if (qemuExtDevicesInitPaths(driver, vm->def) < 0)
         return -1;
 
+    for (i = 0; i < vm->def->nvideos; i++) {
+        virDomainVideoDefPtr video = vm->def->videos[i];
+
+        if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
+            ret = qemuExtVhostUserGPUStart(driver, vm, video);
+            if (ret < 0)
+                return ret;
+        }
+    }
+
     if (vm->def->tpm)
         ret = qemuExtTPMStart(driver, vm, incomingMigration);
 
@@ -185,10 +195,17 @@ qemuExtDevicesStop(virQEMUDriverPtr driver,
     virDomainDefPtr def = vm->def;
     size_t i;
 
-    if (qemuExtDevicesInitPaths(driver, vm->def) < 0)
+    if (qemuExtDevicesInitPaths(driver, def) < 0)
         return;
 
-    if (vm->def->tpm)
+    for (i = 0; i < def->nvideos; i++) {
+        virDomainVideoDefPtr video = def->videos[i];
+
+        if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER)
+            qemuExtVhostUserGPUStop(driver, vm, video);
+    }
+
+    if (def->tpm)
         qemuExtTPMStop(driver, vm);
 
     for (i = 0; i < def->nnets; i++) {
@@ -204,6 +221,13 @@ qemuExtDevicesStop(virQEMUDriverPtr driver,
 bool
 qemuExtDevicesHasDevice(virDomainDefPtr def)
 {
+    size_t i;
+
+    for (i = 0; i < def->nvideos; i++) {
+        if (def->videos[i]->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER)
+            return true;
+    }
+
     if (def->tpm && def->tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR)
         return true;
 
@@ -216,10 +240,19 @@ qemuExtDevicesSetupCgroup(virQEMUDriverPtr driver,
                           virDomainDefPtr def,
                           virCgroupPtr cgroup)
 {
-    int ret = 0;
+    size_t 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->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER &&
+            qemuExtVhostUserGPUSetupCgroup(driver, def, video, cgroup) < 0)
+            return -1;
+    }
+
+    if (def->tpm &&
+        qemuExtTPMSetupCgroup(driver, def, cgroup) < 0)
+        return -1;
+
+    return 0;
 }