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

Re: [libvirt] [PATCH 3/5] interface: always build all available backends



On 10/06/2012 01:20 PM, Doug Goldstein wrote:
> Always build all available backends to avoid bit-rot. At run time we
> select the correct backend and load it by attempting netcf first and
> then udev.
> ---
>  src/Makefile.am                         |    6 ++--
>  src/interface/interface_backend_netcf.c |    2 +-
>  src/interface/interface_backend_udev.c  |    6 +++-
>  src/interface/interface_driver.c        |   37 +++++++++++++++++++++++++++++++
>  src/interface/interface_driver.h        |    3 ++
>  5 files changed, 48 insertions(+), 6 deletions(-)
>  create mode 100644 src/interface/interface_driver.c
> 
> diff --git a/src/Makefile.am b/src/Makefile.am

> +++ b/src/interface/interface_backend_udev.c
> @@ -503,9 +503,11 @@ static virInterfaceDriver udevIfaceDriver = {
>  };
>  
>  int
> -interfaceRegister(void) {
> -    if (virRegisterInterfaceDriver(&udevIfaceDriver) < 0)
> +udevIfaceRegister(void) {
> +    if (virRegisterInterfaceDriver(&udevIfaceDriver) < 0) {
>          virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>                         _("failed to register udev interface driver"));
> +        return -1;

Oops, this line should be squashed into 1/5.

> +int
> +interfaceRegister(void) {
> +#ifdef WITH_NETCF
> +    /* Attempt to load the netcf based backend first */
> +    if (netcfIfaceRegister() == 0)
> +        return 0;
> +#endif /* WITH_NETCF */
> +#if HAVE_UDEV
> +    /* If there's no netcf or it failed to load, register the udev backend */
> +    if (udevIfaceRegister() == 0)
> +        return 0;
> +#endif /* HAVE_UDEV */
> +    return -1;

If neither backend is available, this fails without a good error
message.  Then again, if neither backend is available, we don't compile
this file.  So no real loss.

> +}
> diff --git a/src/interface/interface_driver.h b/src/interface/interface_driver.h
> index 67b6218..80ada5c 100644
> --- a/src/interface/interface_driver.h
> +++ b/src/interface/interface_driver.h
> @@ -26,4 +26,7 @@
>  
>  int interfaceRegister(void);
>  
> +int netcfIfaceRegister(void);
> +int udevIfaceRegister(void);

I guess it doesn't hurt to unconditionally declare these, even though
they are only conditionally compiled.

ACK and pushed.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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