On Thu, Feb 20, 2020 at 15:32:50 +0100, Ján Tomko wrote:
Look into /usr/share/qemu/vhost-user to see whether we can find
a suitable virtiofsd binary, in case the user did not provide one
in the domain XML.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/qemu/qemu_extdevice.c | 9 +++++++++
src/qemu/qemu_vhost_user.c | 40 ++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_vhost_user.h | 4 ++++
src/qemu/qemu_virtiofs.c | 11 +++++++++++
src/qemu/qemu_virtiofs.h | 4 ++++
5 files changed, 68 insertions(+)
[...]
diff --git a/src/qemu/qemu_vhost_user.c b/src/qemu/qemu_vhost_user.c
index 4c25b30664..d437fd1bd5 100644
--- a/src/qemu/qemu_vhost_user.c
+++ b/src/qemu/qemu_vhost_user.c
@@ -416,3 +416,43 @@ qemuVhostUserFillDomainGPU(virQEMUDriverPtr driver,
VIR_FREE(vus);
return ret;
}
+
+
+int
+qemuVhostUserFillDomainFS(virQEMUDriverPtr driver,
+ virDomainFSDefPtr fs)
+{
+ qemuVhostUserPtr *vus = NULL;
+ ssize_t nvus = 0;
+ ssize_t i;
+ int ret = -1;
+
+ if ((nvus = qemuVhostUserFetchParsedConfigs(driver->privileged,
+ &vus, NULL)) < 0)
+ goto end;
+
+ for (i = 0; i < nvus; i++) {
+ qemuVhostUserPtr vu = vus[i];
+
+ if (vu->type != QEMU_VHOST_USER_TYPE_FS)
+ continue;
+
+ g_free(fs->binary);
This feels weird. If the user specified a binary we shouldn't overwrite
it. Also it's dead code as you check that it's NULL in [1].
For now if we don't fill in anything else it doesn't matter, but it
might later. In such case we should probably check that the binary is
the same.
Or use this just to fill the binary but in that case the feeing is not
necessary.
+ fs->binary = g_strdup(vu->binary);
+ break;
+ }
+
+ if (i == nvus) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("Unable to find a satisfying virtiofsd"));
+ goto end;
+ }
+
+ ret = 0;
+
+ end:
+ for (i = 0; i < nvus; i++)
+ qemuVhostUserFree(vus[i]);
+ g_free(vus);
+ return ret;
+}
[...]
diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c
index 9e354a30c6..b53e5b0806 100644
--- a/src/qemu/qemu_virtiofs.c
+++ b/src/qemu/qemu_virtiofs.c
[...]
@@ -326,3 +327,13 @@ qemuVirtioFSSetupCgroup(virQEMUDriverPtr
driver,
return 0;
}
+
+int
+qemuVirtioFSPrepareDomain(virQEMUDriverPtr driver,
+ virDomainFSDefPtr fs)
+{
+ if (fs->binary)
[1]
+ return 0;
+
+ return qemuVhostUserFillDomainFS(driver, fs);
+}
Reviewed-by: Peter Krempa <pkrempa(a)redhat.com>