render / rpms / libvirt

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