render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
d76c62
From f15a4eb66ecbfb80340bbab65150b22ab3a313fe Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <f15a4eb66ecbfb80340bbab65150b22ab3a313fe@dist-git>
d76c62
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
d76c62
Date: Wed, 4 Mar 2020 12:42:48 +0100
d76c62
Subject: [PATCH] qemu: use the vhost-user schemas to find binary
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
Look into /usr/share/qemu/vhost-user to see whether we can find
d76c62
a suitable virtiofsd binary, in case the user did not provide one
d76c62
in the domain XML.
d76c62
d76c62
Signed-off-by: Ján Tomko <jtomko@redhat.com>
d76c62
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
d76c62
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Tested-by: Andrea Bolognani <abologna@redhat.com>
d76c62
(cherry picked from commit 071a1ab92fbbd58f68fb4929d004d6155759067e)
d76c62
Signed-off-by: Ján Tomko <jtomko@redhat.com>
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1694166
d76c62
Message-Id: <e422c33d2c825f91b90eb10ef1530406a3492e0e.1583322091.git.jtomko@redhat.com>
d76c62
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
d76c62
---
d76c62
 src/qemu/qemu_extdevice.c  |  9 +++++++++
d76c62
 src/qemu/qemu_vhost_user.c | 39 ++++++++++++++++++++++++++++++++++++++
d76c62
 src/qemu/qemu_vhost_user.h |  4 ++++
d76c62
 src/qemu/qemu_virtiofs.c   | 11 +++++++++++
d76c62
 src/qemu/qemu_virtiofs.h   |  4 ++++
d76c62
 5 files changed, 67 insertions(+)
d76c62
d76c62
diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c
d76c62
index f66bafb62f..07b9117f57 100644
d76c62
--- a/src/qemu/qemu_extdevice.c
d76c62
+++ b/src/qemu/qemu_extdevice.c
d76c62
@@ -105,6 +105,15 @@ qemuExtDevicesPrepareDomain(virQEMUDriverPtr driver,
d76c62
         }
d76c62
     }
d76c62
 
d76c62
+    for (i = 0; i < vm->def->nfss; i++) {
d76c62
+        virDomainFSDefPtr fs = vm->def->fss[i];
d76c62
+
d76c62
+        if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) {
d76c62
+            if (qemuVirtioFSPrepareDomain(driver, fs) < 0)
d76c62
+                return -1;
d76c62
+        }
d76c62
+    }
d76c62
+
d76c62
     return ret;
d76c62
 }
d76c62
 
d76c62
diff --git a/src/qemu/qemu_vhost_user.c b/src/qemu/qemu_vhost_user.c
d76c62
index 4c25b30664..a3d5ac0fc7 100644
d76c62
--- a/src/qemu/qemu_vhost_user.c
d76c62
+++ b/src/qemu/qemu_vhost_user.c
d76c62
@@ -416,3 +416,42 @@ qemuVhostUserFillDomainGPU(virQEMUDriverPtr driver,
d76c62
     VIR_FREE(vus);
d76c62
     return ret;
d76c62
 }
d76c62
+
d76c62
+
d76c62
+int
d76c62
+qemuVhostUserFillDomainFS(virQEMUDriverPtr driver,
d76c62
+                          virDomainFSDefPtr fs)
d76c62
+{
d76c62
+    qemuVhostUserPtr *vus = NULL;
d76c62
+    ssize_t nvus = 0;
d76c62
+    ssize_t i;
d76c62
+    int ret = -1;
d76c62
+
d76c62
+    if ((nvus = qemuVhostUserFetchParsedConfigs(driver->privileged,
d76c62
+                                                &vus, NULL)) < 0)
d76c62
+        goto end;
d76c62
+
d76c62
+    for (i = 0; i < nvus; i++) {
d76c62
+        qemuVhostUserPtr vu = vus[i];
d76c62
+
d76c62
+        if (vu->type != QEMU_VHOST_USER_TYPE_FS)
d76c62
+            continue;
d76c62
+
d76c62
+        fs->binary = g_strdup(vu->binary);
d76c62
+        break;
d76c62
+    }
d76c62
+
d76c62
+    if (i == nvus) {
d76c62
+        virReportError(VIR_ERR_OPERATION_FAILED, "%s",
d76c62
+                       _("Unable to find a satisfying virtiofsd"));
d76c62
+        goto end;
d76c62
+    }
d76c62
+
d76c62
+    ret = 0;
d76c62
+
d76c62
+ end:
d76c62
+    for (i = 0; i < nvus; i++)
d76c62
+        qemuVhostUserFree(vus[i]);
d76c62
+    g_free(vus);
d76c62
+    return ret;
d76c62
+}
d76c62
diff --git a/src/qemu/qemu_vhost_user.h b/src/qemu/qemu_vhost_user.h
d76c62
index 369ba00caa..e505c8a473 100644
d76c62
--- a/src/qemu/qemu_vhost_user.h
d76c62
+++ b/src/qemu/qemu_vhost_user.h
d76c62
@@ -45,3 +45,7 @@ qemuVhostUserFetchConfigs(char ***configs,
d76c62
 int
d76c62
 qemuVhostUserFillDomainGPU(virQEMUDriverPtr driver,
d76c62
                            virDomainVideoDefPtr video);
d76c62
+
d76c62
+int
d76c62
+qemuVhostUserFillDomainFS(virQEMUDriverPtr driver,
d76c62
+                          virDomainFSDefPtr fs);
d76c62
diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c
d76c62
index 194855ece8..d579ce1d33 100644
d76c62
--- a/src/qemu/qemu_virtiofs.c
d76c62
+++ b/src/qemu/qemu_virtiofs.c
d76c62
@@ -28,6 +28,7 @@
d76c62
 #include "qemu_conf.h"
d76c62
 #include "qemu_extdevice.h"
d76c62
 #include "qemu_security.h"
d76c62
+#include "qemu_vhost_user.h"
d76c62
 #include "qemu_virtiofs.h"
d76c62
 #include "virpidfile.h"
d76c62
 #include "virqemu.h"
d76c62
@@ -325,3 +326,13 @@ qemuVirtioFSSetupCgroup(virDomainObjPtr vm,
d76c62
 
d76c62
     return 0;
d76c62
 }
d76c62
+
d76c62
+int
d76c62
+qemuVirtioFSPrepareDomain(virQEMUDriverPtr driver,
d76c62
+                          virDomainFSDefPtr fs)
d76c62
+{
d76c62
+    if (fs->binary)
d76c62
+        return 0;
d76c62
+
d76c62
+    return qemuVhostUserFillDomainFS(driver, fs);
d76c62
+}
d76c62
diff --git a/src/qemu/qemu_virtiofs.h b/src/qemu/qemu_virtiofs.h
d76c62
index 1db59917c6..7de4ea6190 100644
d76c62
--- a/src/qemu/qemu_virtiofs.h
d76c62
+++ b/src/qemu/qemu_virtiofs.h
d76c62
@@ -40,3 +40,7 @@ int
d76c62
 qemuVirtioFSSetupCgroup(virDomainObjPtr vm,
d76c62
                         virDomainFSDefPtr fs,
d76c62
                         virCgroupPtr cgroup);
d76c62
+
d76c62
+int
d76c62
+qemuVirtioFSPrepareDomain(virQEMUDriverPtr driver,
d76c62
+                          virDomainFSDefPtr fs);
d76c62
-- 
d76c62
2.25.1
d76c62