[libvirt] [PATCH 5/8] driver: declare supported URI schemes in virConnectDriver struct

Michal Privoznik mprivozn at redhat.com
Wed Apr 11 12:08:56 UTC 2018


On 04/09/2018 05:45 PM, Daniel P. Berrangé wrote:
> Declare what URI schemes a driver supports in its virConnectDriver
> struct. This allows us to skip trying to open the driver entirely
> if the URI scheme doesn't match.
> 
> Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
> ---
>  src/bhyve/bhyve_driver.c                |  4 +---
>  src/driver.h                            |  6 ++++++
>  src/esx/esx_driver.c                    | 27 ++-------------------------
>  src/hyperv/hyperv_driver.c              | 22 ++--------------------
>  src/interface/interface_backend_netcf.c |  4 +---
>  src/interface/interface_backend_udev.c  |  4 +---
>  src/libvirt.c                           | 24 ++++++++++++++++++++++++
>  src/libxl/libxl_driver.c                |  5 +----
>  src/lxc/lxc_driver.c                    |  5 +----
>  src/network/bridge_driver.c             |  4 +---
>  src/node_device/node_device_driver.c    |  3 ---
>  src/node_device/node_device_hal.c       |  1 +
>  src/node_device/node_device_udev.c      |  1 +
>  src/nwfilter/nwfilter_driver.c          |  4 +---
>  src/openvz/openvz_driver.c              |  6 +-----
>  src/phyp/phyp_driver.c                  |  4 +---
>  src/qemu/qemu_driver.c                  |  8 +-------
>  src/secret/secret_driver.c              |  4 +---
>  src/storage/storage_driver.c            |  4 +---
>  src/test/test_driver.c                  |  4 +---
>  src/uml/uml_driver.c                    |  5 +----
>  src/vbox/vbox_common.c                  |  4 ----
>  src/vbox/vbox_driver.c                  |  5 ++---
>  src/vmware/vmware_driver.c              |  7 +------
>  src/vz/vz_driver.c                      | 15 ++-------------
>  src/xenapi/xenapi_driver.c              |  5 ++---
>  26 files changed, 57 insertions(+), 128 deletions(-)
> 
> diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
> index cc1d4ba6fb..21754dfc10 100644
> --- a/src/bhyve/bhyve_driver.c
> +++ b/src/bhyve/bhyve_driver.c
> @@ -202,9 +202,6 @@ bhyveConnectOpen(virConnectPtr conn,
>       if (conn->uri == NULL) {
>           return VIR_DRV_OPEN_DECLINED;
>       } else {
> -         if (!conn->uri->scheme || STRNEQ(conn->uri->scheme, "bhyve"))
> -             return VIR_DRV_OPEN_DECLINED;
> -
>           if (STRNEQ_NULLABLE(conn->uri->path, "/system")) {
>              virReportError(VIR_ERR_INTERNAL_ERROR,
>                             _("Unexpected bhyve URI path '%s', try bhyve:///system"),
> @@ -1752,6 +1749,7 @@ static virHypervisorDriver bhyveHypervisorDriver = {
>  
>  static virConnectDriver bhyveConnectDriver = {
>      .localOnly = true,
> +    .uriSchemes = (const char *[]){ "bhyve", NULL },

Frankly, I don't like this typecast. But at the same time, I'm unable to
come up with something better. Apart from some VIR_URI_SCHEMES() macro
that would hide typecast in its internals.

Michal




More information about the libvir-list mailing list