[libvirt] [PATCH 3/8] driver: introduce a driver method for probing default URIs

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


On 04/09/2018 05:45 PM, Daniel P. Berrangé wrote:
> Currently the virDrvConnectOpen method is supposed to handle both
> opening an explicit URI and auto-probing a driver if no URI is
> given. Introduce a dedicated virDrvConnectURIProbe method to enable the
> probing functionality to be split from the driver opening functionality.
> 
> It is still possible for NULL to be passed to the virDrvConnectOpen
> method after this change, because the remote driver needs special
> handling to enable probing of the URI against a remote libvirtd daemon.
> 
> Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
> ---
>  docs/hvsupport.pl          |  6 +++---
>  src/bhyve/bhyve_driver.c   | 18 +++++++++++++-----
>  src/driver-hypervisor.h    |  4 ++++
>  src/libvirt.c              | 13 +++++++++++++
>  src/libxl/libxl_driver.c   | 17 ++++++++++++-----
>  src/lxc/lxc_driver.c       | 17 ++++++++++++-----
>  src/openvz/openvz_driver.c | 24 ++++++++++++++++--------
>  src/qemu/qemu_driver.c     | 30 +++++++++++++++++++++---------
>  src/uml/uml_driver.c       | 20 +++++++++++++-------
>  src/vbox/vbox_common.c     | 13 ++++++++++---
>  10 files changed, 117 insertions(+), 45 deletions(-)
> 
> diff --git a/docs/hvsupport.pl b/docs/hvsupport.pl
> index fc6eb1f152..a2b980c502 100755
> --- a/docs/hvsupport.pl
> +++ b/docs/hvsupport.pl
> @@ -184,7 +184,7 @@ foreach my $drivertable (@drivertable) {
>                  my $api;
>                  if (exists $apis{"vir$name"}) {
>                      $api = "vir$name";
> -                } elsif ($name =~ /\w+(Open|Close)/) {
> +                } elsif ($name =~ /\w+(Open|Close|URIProbe)/) {
>                      next;
>                  } else {
>                      die "driver $name does not have a public API";
> @@ -241,12 +241,12 @@ foreach my $src (@srcs) {
>  
>                  next if $api eq "no" || $api eq "name";
>  
> -                die "Method $meth in $src is missing version" unless defined $vers;
> +                die "Method $meth in $src is missing version" unless defined $vers || $api eq "connectURIProbe";
>  
>                  die "Driver method for $api is NULL in $src" if $meth eq "NULL";
>  
>                  if (!exists($groups{$ingrp}->{apis}->{$api})) {
> -                    next if $api =~ /\w(Open|Close)/;
> +                    next if $api =~ /\w(Open|Close|URIProbe)/;
>  
>                      die "Found unexpected method $api in $ingrp\n";
>                  }
> diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
> index 849d3abcd3..a0bc400480 100644
> --- a/src/bhyve/bhyve_driver.c
> +++ b/src/bhyve/bhyve_driver.c
> @@ -180,6 +180,17 @@ bhyveDomObjFromDomain(virDomainPtr domain)
>      return vm;
>  }
>  
> +
> +static int
> +bhyveConnectURIProbe(char **uri)
> +{
> +    if (bhyve_driver == NULL)
> +        return 0;
> +
> +    return VIR_STRDUP(*uri, "bhyve:///system");
> +}

make check fails because it thinks this function (and others) is missing
ACL check.

> +
> +
>  static virDrvOpenStatus
>  bhyveConnectOpen(virConnectPtr conn,
>                   virConnectAuthPtr auth ATTRIBUTE_UNUSED,
> @@ -189,11 +200,7 @@ bhyveConnectOpen(virConnectPtr conn,
>       virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
>  
>       if (conn->uri == NULL) {
> -         if (bhyve_driver == NULL)
> -             return VIR_DRV_OPEN_DECLINED;
> -
> -         if (!(conn->uri = virURIParse("bhyve:///system")))
> -             return VIR_DRV_OPEN_ERROR;
> +         return VIR_DRV_OPEN_DECLINED;
>       } else {
>           if (!conn->uri->scheme || STRNEQ(conn->uri->scheme, "bhyve"))
>               return VIR_DRV_OPEN_DECLINED;
> @@ -1689,6 +1696,7 @@ bhyveConnectGetDomainCapabilities(virConnectPtr conn,
>  
>  static virHypervisorDriver bhyveHypervisorDriver = {
>      .name = "bhyve",
> +    .connectURIProbe = bhyveConnectURIProbe,

s,$, /* 4.3.0 */

Michal




More information about the libvir-list mailing list