[libvirt] [PATCH] NOT only vz!: add func to set shared drivers after libvirtd init

Dmitry Guryanov dguryanov at virtuozzo.com
Fri Nov 13 10:41:30 UTC 2015


On Thu, 2015-10-22 at 11:13 +0300, Mikhail Feoktistov wrote:
> Built-in drivers in libvirt are initialized before libvirtd initialization.
> Libvirt loads shared drivers on libvirtd initialization step.
> For built-in drivers we can't set shared drivers, because they are not
> initialized yet.
> This patch adds function to set shared drivers after libvirtd init.

I'm OK with this solution, since it'll allow us to use shared driver if we use
connection to libvirtd. At this point only network driver is used, but I hope we
will work with storage driver too. So ACK from me.

This patch is needed to use virt-manager to manage our containers remotely.

> ---
>  daemon/libvirtd.c        |  4 ++++
>  src/libvirt.c            | 41 +++++++++++++++++++++++++++++++++++++++++
>  src/libvirt_internal.h   |  1 +
>  src/libvirt_private.syms |  1 +
>  4 files changed, 47 insertions(+)
> 
> diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
> index 250094b..aac1826 100644
> --- a/daemon/libvirtd.c
> +++ b/daemon/libvirtd.c
> @@ -431,6 +431,10 @@ static void daemonInitialize(void)
>      bhyveRegister();
>  # endif
>  #endif
> +# ifdef WITH_VZ
> +    virAssignSharedDrivers("vz");
> +    virAssignSharedDrivers("Parallels");
> +# endif
>  }
>  
>  
> diff --git a/src/libvirt.c b/src/libvirt.c
> index 2602dde..4c4b7bd 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -1433,3 +1433,44 @@ virTypedParameterValidateSet(virConnectPtr conn,
>      }
>      return 0;
>  }
> +
> +/**
> + * virAssignSharedDrivers:
> + * @name: name of connection driver
> + *
> + * This function fills in any empty pointers for shared drivers
> + * in connect driver structure
> + *
> + * Returns 0 in case of success, -1 in case of error
> +*/
> +int
> +virAssignSharedDrivers(const char *name)
> +{
> +    size_t i;
> +
> +    if (name == NULL) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("Driver name must be specified"));
> +        return -1;
> +    }
> +
> +    for (i = 0; i < virConnectDriverTabCount; i++) {
> +        if (STREQ(virConnectDriverTab[i]->hypervisorDriver->name, name)) {
> +            if (virConnectDriverTab[i]->interfaceDriver == NULL)
> +                virConnectDriverTab[i]->interfaceDriver =
> virSharedInterfaceDriver;
> +            if (virConnectDriverTab[i]->networkDriver == NULL)
> +                virConnectDriverTab[i]->networkDriver =
> virSharedNetworkDriver;
> +            if (virConnectDriverTab[i]->nodeDeviceDriver == NULL)
> +                virConnectDriverTab[i]->nodeDeviceDriver =
> virSharedNodeDeviceDriver;
> +            if (virConnectDriverTab[i]->nwfilterDriver == NULL)
> +                virConnectDriverTab[i]->nwfilterDriver =
> virSharedNWFilterDriver;
> +            if (virConnectDriverTab[i]->secretDriver == NULL)
> +                virConnectDriverTab[i]->secretDriver = virSharedSecretDriver;
> +            if (virConnectDriverTab[i]->storageDriver == NULL)
> +                virConnectDriverTab[i]->storageDriver =
> virSharedStorageDriver;
> +            break;
> +       }
> +    }
> +
> +    return 0;
> +}
> diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
> index 1313b58..2a7227b 100644
> --- a/src/libvirt_internal.h
> +++ b/src/libvirt_internal.h
> @@ -289,4 +289,5 @@ virTypedParameterValidateSet(virConnectPtr conn,
>                               virTypedParameterPtr params,
>                               int nparams);
>  
> +int virAssignSharedDrivers(const char *name);
>  #endif
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index be6ee19..340555a 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -943,6 +943,7 @@ virFDStreamSetInternalCloseCb;
>  
>  
>  # libvirt_internal.h
> +virAssignSharedDrivers;
>  virConnectSupportsFeature;
>  virDomainMigrateBegin3;
>  virDomainMigrateBegin3Params;
-- 
Dmitry Guryanov




More information about the libvir-list mailing list