[v2,12/16] qemu: prepare domain for vhost-user GPU

Message ID b4868db7321107858bb2e0b4fe2d96889123ac4a.1566576129.git.crobinso@redhat.com
State Accepted
Commit 638f066b7342d6b285444612058e552b0edc4af8
Headers show
Series
  • Add vhost-user-gpu support
Related show

Commit Message

Cole Robinson Aug. 23, 2019, 4:21 p.m.
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Call qemuExtVhostUserGPUPrepareDomain() to fill the domain with the
location of the vhost-user binary to start.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
---
 src/qemu/qemu_extdevice.c | 29 +++++++++++++++++++++++++++++
 src/qemu/qemu_extdevice.h |  5 +++++
 src/qemu/qemu_process.c   |  4 ++++
 3 files changed, 38 insertions(+)

Patch

diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c
index dc032aa60c..5c55aba006 100644
--- a/src/qemu/qemu_extdevice.c
+++ b/src/qemu/qemu_extdevice.c
@@ -21,6 +21,7 @@ 
 #include <config.h>
 
 #include "qemu_extdevice.h"
+#include "qemu_vhost_user_gpu.h"
 #include "qemu_domain.h"
 #include "qemu_tpm.h"
 
@@ -92,6 +93,34 @@  qemuExtDevicesInitPaths(virQEMUDriverPtr driver,
 }
 
 
+/*
+ * qemuExtDevicesPrepareDomain:
+ *
+ * @driver: QEMU driver
+ * @vm: domain
+ *
+ * Code that modifies live XML of a domain which is about to start.
+ */
+int
+qemuExtDevicesPrepareDomain(virQEMUDriverPtr driver,
+                            virDomainObjPtr vm)
+{
+    int ret = 0;
+    size_t i;
+
+    for (i = 0; i < vm->def->nvideos; i++) {
+        virDomainVideoDefPtr video = vm->def->videos[i];
+
+        if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO && video->vhostuser) {
+            if ((ret = qemuExtVhostUserGPUPrepareDomain(driver, video) < 0))
+                break;
+        }
+    }
+
+    return ret;
+}
+
+
 /*
  * qemuExtDevicesPrepareHost:
  *
diff --git a/src/qemu/qemu_extdevice.h b/src/qemu/qemu_extdevice.h
index 039b3e60dd..2412244d60 100644
--- a/src/qemu/qemu_extdevice.h
+++ b/src/qemu/qemu_extdevice.h
@@ -29,6 +29,11 @@  int qemuExtDeviceLogCommand(qemuDomainLogContextPtr logCtxt,
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
     ATTRIBUTE_RETURN_CHECK;
 
+int qemuExtDevicesPrepareDomain(virQEMUDriverPtr driver,
+                                virDomainObjPtr vm)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
+    ATTRIBUTE_RETURN_CHECK;
+
 int qemuExtDevicesPrepareHost(virQEMUDriverPtr driver,
                               virDomainDefPtr def)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c439f17011..ed767b0807 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6358,6 +6358,10 @@  qemuProcessPrepareDomain(virQEMUDriverPtr driver,
     if (qemuFirmwareFillDomain(driver, vm, flags) < 0)
         goto cleanup;
 
+    VIR_DEBUG("Preparing external devices");
+    if (qemuExtDevicesPrepareDomain(driver, vm) < 0)
+        goto cleanup;
+
     for (i = 0; i < vm->def->nchannels; i++) {
         if (qemuDomainPrepareChannel(vm->def->channels[i],
                                      priv->channelTargetDir) < 0)