qemu: use the vhost-user schemas to find binary

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@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Ján Tomko 2020-01-28 15:38:52 +01:00
parent 9de5d69c21
commit 071a1ab92f
5 changed files with 67 additions and 0 deletions

View File

@ -105,6 +105,15 @@ qemuExtDevicesPrepareDomain(virQEMUDriverPtr driver,
}
}
for (i = 0; i < vm->def->nfss; i++) {
virDomainFSDefPtr fs = vm->def->fss[i];
if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) {
if (qemuVirtioFSPrepareDomain(driver, fs) < 0)
return -1;
}
}
return ret;
}

View File

@ -417,3 +417,42 @@ 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;
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;
}

View File

@ -45,3 +45,7 @@ qemuVhostUserFetchConfigs(char ***configs,
int
qemuVhostUserFillDomainGPU(virQEMUDriverPtr driver,
virDomainVideoDefPtr video);
int
qemuVhostUserFillDomainFS(virQEMUDriverPtr driver,
virDomainFSDefPtr fs);

View File

@ -28,6 +28,7 @@
#include "qemu_conf.h"
#include "qemu_extdevice.h"
#include "qemu_security.h"
#include "qemu_vhost_user.h"
#include "qemu_virtiofs.h"
#include "virpidfile.h"
#include "virqemu.h"
@ -325,3 +326,13 @@ qemuVirtioFSSetupCgroup(virDomainObjPtr vm,
return 0;
}
int
qemuVirtioFSPrepareDomain(virQEMUDriverPtr driver,
virDomainFSDefPtr fs)
{
if (fs->binary)
return 0;
return qemuVhostUserFillDomainFS(driver, fs);
}

View File

@ -40,3 +40,7 @@ int
qemuVirtioFSSetupCgroup(virDomainObjPtr vm,
virDomainFSDefPtr fs,
virCgroupPtr cgroup);
int
qemuVirtioFSPrepareDomain(virQEMUDriverPtr driver,
virDomainFSDefPtr fs);