Re: [libvirt PATCHv3 11/12] qemu: use the vhost-user schemas to find binary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ján,

On Thu, Jan 30, 2020 at 06:06:27PM +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.

The json file (50-qemu-virtiofsd.json) may not be located in /usr/share/qemu/vhost-user
in case qemu is built with '--with-confsuffix' option like as: '--with-confsuffix=/qemu-kvm'.
I think libvirt searches /usr/share/qemu/vhost-user because QEMU_SYSTEM_LOCATION
is hardcoded:

   #define QEMU_SYSTEM_LOCATION PREFIX "/share/qemu"

Why don't we adding such confsuffix option to libvirt and changing
QEMU_SYSTEM_LOCATION as following?

   #define QEMU_SYSTEM_LOCATION PREFIX "/share" CONFSUFFIX

Thanks,
Masa

> 
> Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
> ---
>  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   | 12 ++++++++++++
>  src/qemu/qemu_virtiofs.h   |  4 ++++
>  5 files changed, 69 insertions(+)
> 
> diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c
> index 5103d4921c..226d51a468 100644
> --- a/src/qemu/qemu_extdevice.c
> +++ b/src/qemu/qemu_extdevice.c
> @@ -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;
>  }
>  
> 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);
> +        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_vhost_user.h b/src/qemu/qemu_vhost_user.h
> index 369ba00caa..e505c8a473 100644
> --- a/src/qemu/qemu_vhost_user.h
> +++ b/src/qemu/qemu_vhost_user.h
> @@ -45,3 +45,7 @@ qemuVhostUserFetchConfigs(char ***configs,
>  int
>  qemuVhostUserFillDomainGPU(virQEMUDriverPtr driver,
>                             virDomainVideoDefPtr video);
> +
> +int
> +qemuVhostUserFillDomainFS(virQEMUDriverPtr driver,
> +                          virDomainFSDefPtr fs);
> diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c
> index 4aa8eaed2c..4ea8f23fd5 100644
> --- a/src/qemu/qemu_virtiofs.c
> +++ b/src/qemu/qemu_virtiofs.c
> @@ -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"
>  
> @@ -288,3 +289,14 @@ qemuVirtioFSStop(virQEMUDriverPtr driver,
>   cleanup:
>      virErrorRestore(&orig_err);
>  }
> +
> +
> +int
> +qemuVirtioFSPrepareDomain(virQEMUDriverPtr driver,
> +                          virDomainFSDefPtr fs)
> +{
> +    if (fs->binary)
> +        return 0;
> +
> +    return qemuVhostUserFillDomainFS(driver, fs);
> +}
> diff --git a/src/qemu/qemu_virtiofs.h b/src/qemu/qemu_virtiofs.h
> index 49db807b19..06b05510c7 100644
> --- a/src/qemu/qemu_virtiofs.h
> +++ b/src/qemu/qemu_virtiofs.h
> @@ -36,3 +36,7 @@ void
>  qemuVirtioFSStop(virQEMUDriverPtr driver,
>                   virDomainObjPtr vm,
>                   virDomainFSDefPtr fs);
> +
> +int
> +qemuVirtioFSPrepareDomain(virQEMUDriverPtr driver,
> +                          virDomainFSDefPtr fs);
> -- 
> 2.21.0
> 






[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux