From nobody Mon Apr 29 02:25:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523288764498950.6271686136292; Mon, 9 Apr 2018 08:46:04 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A3B9860B9; Mon, 9 Apr 2018 15:46:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 715A218399; Mon, 9 Apr 2018 15:46:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 336144CAA1; Mon, 9 Apr 2018 15:46:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w39Fjs21032372 for ; Mon, 9 Apr 2018 11:45:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 89F312026990; Mon, 9 Apr 2018 15:45:54 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 893D62024CA7; Mon, 9 Apr 2018 15:45:53 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 9 Apr 2018 16:45:44 +0100 Message-Id: <20180409154551.22604-2-berrange@redhat.com> In-Reply-To: <20180409154551.22604-1-berrange@redhat.com> References: <20180409154551.22604-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/8] xen: encourage use of xen:///system URI as preferred format X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 09 Apr 2018 15:46:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Historically we have used a bare xen:/// URI for connecting to the legacy Xen driver. The new libxl Xen driver follows the new practice of allowing '/system' as a path, as well as bare '/' for compat with the old Xen driver. This documents xen:///system as the preferred format for Xen, leaving xen:/// as an undocumented feature just for back-compat. Signed-off-by: Daniel P. Berrang=C3=A9 --- docs/drvxen.html.in | 14 +++++++------- docs/remote.html.in | 6 +++--- docs/uri.html.in | 16 ++++++++-------- src/libvirt.c | 8 ++++---- src/libxl/libxl_driver.c | 4 ++-- tools/libvirt-guests.sysconf | 2 +- tools/virsh.pod | 2 +- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/docs/drvxen.html.in b/docs/drvxen.html.in index b8d190c942..2e45e09527 100644 --- a/docs/drvxen.html.in +++ b/docs/drvxen.html.in @@ -43,11 +43,11 @@

=20
-xen:///                        (local access, direct)
-xen+unix:///                   (local access, via daemon)
-xen://example.com/             (remote access, TLS/x509)
-xen+tcp://example.com/         (remote access, SASl/Kerberos)
-xen+ssh://root@example.com/    (remote access, SSH tunnelled)
+xen:///system                     (local access, direct)
+xen+unix:///system                (local access, via daemon)
+xen://example.com/system          (remote access, TLS/x509)
+xen+tcp://example.com/system      (remote access, SASl/Kerberos)
+xen+ssh://root@example.com/system (remote access, SSH tunnelled)
 
=20

Import and export of libvirt domain XML configs=

@@ -76,7 +76,7 @@ xen+ssh://root@example.com/ (remote access, SSH tunnel= led) which can then be used by libvirt.

=20 -
$ virsh -c xen:/// domxml-from-native xen-xm rhel5.cfg
+    
$ virsh -c xen:///system domxml-from-native xen-xm rhel5.cfg
 <domain type=3D'xen'>
   <name>rhel5pv</name>
   <uuid>8f07fe28-753f-2729-d76d-bdbd892f949a</uuid>
@@ -122,7 +122,7 @@ xen+ssh://root@example.com/    (remote access, SSH tunn=
elled)
       format.
     

=20 -
$ virsh -c xen:/// domxml-to-native xen-xm rhel5pv.xml
+    
$ virsh -c xen:///system domxml-to-native xen-xm rhel5pv.xml
 name =3D "rhel5pv"
 uuid =3D "8f07fe28-753f-2729-d76d-bdbd892f949a"
 maxmem =3D 2500
diff --git a/docs/remote.html.in b/docs/remote.html.in
index 8c22778f53..de09975039 100644
--- a/docs/remote.html.in
+++ b/docs/remote.html.in
@@ -130,14 +130,14 @@ to distinguish this from a local URI.
 Some examples:
 

    -
  • xen+ssh://rjones@towada/
    — Connect to a +
  • xen+ssh://rjones@towada/system
    — Connec= t to a remote Xen hypervisor on host towada using ssh transport and = ssh username rjones.
  • -
  • xen://towada/
    — Connect to a +
  • xen://towada/system
    — Connect to a remote Xen hypervisor on host towada using TLS.
  • -
  • xen://towada/?no_verify=3D1
    — Connect t= o a +
  • xen://towada/system?no_verify=3D1
    — Con= nect to a remote Xen hypervisor on host towada using TLS. Do not verify the server's certificate.
  • diff --git a/docs/uri.html.in b/docs/uri.html.in index 5df73613ae..6da9eb9746 100644 --- a/docs/uri.html.in +++ b/docs/uri.html.in @@ -107,7 +107,7 @@ In virt-install use the --connect=3DURI= option: virt-install --connect=3Dtest:///default [other options]

- xen:/// URI + xen:///system URI

This section describes a feature which is new in libvirt > @@ -115,7 +115,7 @@ virt-install --connect=3Dtest:///default [oth= er options]

To access a Xen hypervisor running on the local machine -use the URI xen:///. +use the URI xen:///system.

qemu:///... QEMU and KVM URIs @@ -167,10 +167,10 @@ a NULL URI for a local connection. For example: - xen:/// + xen:///system - xen://oirase/ + xen://oirase/system Connect to the Xen hypervisor running on host oirase using TLS. @@ -187,10 +187,10 @@ a NULL URI for a local connection. For example: - xen:/// + xen:///system - xen+ssh://oirase/ + xen+ssh://oirase/system Connect to the Xen hypervisor running on host oirase by going over an ssh connection. @@ -251,7 +251,7 @@ In any case applications linked to libvirt can continue= to pass user to override the URI, either by constructing one or by allowing the user to type a URI in directly (if that is appropriate). If your application wishes to connect specifically to a Xen hypervisor, then -for future proofing it should choose a full xen= :/// URI. +for future proofing it should choose a full xen= :///system URI.

Legacy: "xen" @@ -259,7 +259,7 @@ for future proofing it should choose a full xen:/// Another legacy URI is to specify name as the string "xen". This will continue to refer to the Xen -hypervisor. However you should prefer a full x= en:/// URI in all future code. +hypervisor. However you should prefer a full x= en:///system URI in all future code.

diff --git a/src/libvirt.c b/src/libvirt.c index b7bcf80224..51acbbf83e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -954,15 +954,15 @@ virConnectOpenInternal(const char *name, goto failed; } =20 - /* Convert xen -> xen:/// for back compat */ + /* Convert xen -> xen:///system for back compat */ if (name && STRCASEEQ(name, "xen")) - name =3D "xen:///"; + name =3D "xen:///system"; =20 - /* Convert xen:// -> xen:/// because xmlParseURI cannot parse the + /* Convert xen:// -> xen:///system because xmlParseURI cannot parse the * former. This allows URIs such as xen://localhost to work. */ if (name && STREQ(name, "xen://")) - name =3D "xen:///"; + name =3D "xen:///system"; =20 /* * If no URI is passed, then check for an environment string if not diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index de70abaaae..c559bf6514 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -839,7 +839,7 @@ libxlConnectOpen(virConnectPtr conn, if (libxl_driver =3D=3D NULL) return VIR_DRV_OPEN_DECLINED; =20 - if (!(conn->uri =3D virURIParse("xen:///"))) + if (!(conn->uri =3D virURIParse("xen:///system"))) return VIR_DRV_OPEN_ERROR; } else { /* Only xen scheme */ @@ -863,7 +863,7 @@ libxlConnectOpen(virConnectPtr conn, STRNEQ(conn->uri->path, "/") && STRNEQ(conn->uri->path, "/system")) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected Xen URI path '%s', try xen:///"), + _("unexpected Xen URI path '%s', try xen:///sys= tem"), NULLSTR(conn->uri->path)); return VIR_DRV_OPEN_ERROR; } diff --git a/tools/libvirt-guests.sysconf b/tools/libvirt-guests.sysconf index 08204ca039..4e11464d2d 100644 --- a/tools/libvirt-guests.sysconf +++ b/tools/libvirt-guests.sysconf @@ -1,5 +1,5 @@ # URIs to check for running guests -# example: URIS=3D'default xen:/// vbox+tcp://host/system lxc:///' +# example: URIS=3D'default xen:///system vbox+tcp://host/system lxc:///' #URIS=3Ddefault =20 # action taken on host boot diff --git a/tools/virsh.pod b/tools/virsh.pod index 9d69a75244..4d25ac5d9b 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -254,7 +254,7 @@ common are: =20 =3Dover 4 =20 -=3Ditem xen:/// +=3Ditem xen:///system =20 this is used to connect to the local Xen hypervisor =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 02:25:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523288770014763.209297005581; Mon, 9 Apr 2018 08:46:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C6394C06A809; Mon, 9 Apr 2018 15:46:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C4A050F5E; Mon, 9 Apr 2018 15:46:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5FA0A180215F; Mon, 9 Apr 2018 15:46:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w39Fjt4W032386 for ; Mon, 9 Apr 2018 11:45:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7BEB32026990; Mon, 9 Apr 2018 15:45:55 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBB4F2024CA7; Mon, 9 Apr 2018 15:45:54 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 9 Apr 2018 16:45:45 +0100 Message-Id: <20180409154551.22604-3-berrange@redhat.com> In-Reply-To: <20180409154551.22604-1-berrange@redhat.com> References: <20180409154551.22604-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/8] lxc: allow use of lxc:///system URI as preferred format X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 09 Apr 2018 15:46:08 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Historically we have used a bare lxc:/// URI for connecting to LXC. This is different from our practice with QEMU, UML, Parallels, Libxl, BHyve and VirtualBox drivers, which all use a path of '/system' or '/session' or both. By making LXC allow '/system', we have fully standardized on the use of either '/system' or '/session' for all the stateful drivers that run inside libvirtd. Support for lxc:/// is of course maintained for back-compat. Signed-off-by: Daniel P. Berrang=C3=A9 --- docs/drvlxc.html.in | 34 +++++++++++++++++---------------= -- examples/lxcconvert/virt-lxc-convert | 2 +- src/lxc/lxc_driver.c | 7 ++++--- src/lxc/lxc_process.c | 4 ++-- tools/libvirt-guests.sysconf | 2 +- tools/virsh.pod | 2 +- tools/virt-login-shell.c | 2 +- 7 files changed, 27 insertions(+), 26 deletions(-) diff --git a/docs/drvlxc.html.in b/docs/drvlxc.html.in index 58a336ed30..44c49609d9 100644 --- a/docs/drvlxc.html.in +++ b/docs/drvlxc.html.in @@ -308,8 +308,8 @@ unit file specifies how systemd will start the libvirt = LXC container Description=3DMy little container =20 [Service] -ExecStart=3D/usr/bin/virsh -c lxc:/// start --pass-fds 3 mycontainer -ExecStop=3D/usr/bin/virsh -c lxc:/// destroy mycontainer +ExecStart=3D/usr/bin/virsh -c lxc:///system start --pass-fds 3 mycontainer +ExecStop=3D/usr/bin/virsh -c lxc:///system destroy mycontainer Type=3Doneshot RemainAfterExit=3Dyes KillMode=3Dnone @@ -621,9 +621,9 @@ The use of namespace passthrough requires libvirt >=3D = 1.2.19 As with any libvirt virtualization driver, LXC containers can be managed via a wide variety of libvirt based tools. At the lowest level the virsh command can be used to perform many -tasks, by passing the -c lxc:/// argument. As an +tasks, by passing the -c lxc:///system argument. As an alternative to repeating the URI with every command, the LIBVIRT_DEF= AULT_URI -environment variable can be set to lxc:///. The +environment variable can be set to lxc:///system. The examples that follow outline some common operations with virsh and LXC. For further details about usage of virsh consult its manual page. @@ -637,7 +637,7 @@ document and loads it into libvirt, saving the configur= ation on disk

=20
-# virsh -c lxc:/// define myguest.xml
+# virsh -c lxc:///system define myguest.xml
 
=20

Viewing container configuration

@@ -652,7 +652,7 @@ using the --inactive flag

=20
-# virsh -c lxc:/// dumpxml myguest
+# virsh -c lxc:///system dumpxml myguest
 
=20

Starting containers

@@ -663,7 +663,7 @@ container from a previously defined persistent configur= ation

=20
-# virsh -c lxc:/// start myguest
+# virsh -c lxc:///system start myguest
 
=20

@@ -673,7 +673,7 @@ by libvirt, using the virsh create command.

=20
-# virsh -c lxc:/// create myguest.xml
+# virsh -c lxc:///system create myguest.xml
 
=20 =20 @@ -689,7 +689,7 @@ to PID 1 inside the container.

=20
-# virsh -c lxc:/// shutdown myguest
+# virsh -c lxc:///system shutdown myguest
 
=20

@@ -698,7 +698,7 @@ request, it can be forcibly stopped using the vir= sh destroy

=20
-# virsh -c lxc:/// destroy myguest
+# virsh -c lxc:///system destroy myguest
 
=20 =20 @@ -714,7 +714,7 @@ to PID 1 inside the container.

=20
-# virsh -c lxc:/// reboot myguest
+# virsh -c lxc:///system reboot myguest
 
=20

Undefining (deleting) a container configuration<= /a>

@@ -726,7 +726,7 @@ running, this will turn it into a "transient" guest.

=20
-# virsh -c lxc:/// undefine myguest
+# virsh -c lxc:///system undefine myguest
 
=20

Connecting to a container console

@@ -737,7 +737,7 @@ to the text console associated with a container.

=20
-# virsh -c lxc:/// console myguest
+# virsh -c lxc:///system console myguest
 
=20

@@ -749,7 +749,7 @@ as 'console0', 'console1', 'console2', etc.

=20
-# virsh -c lxc:/// console myguest --devname console1
+# virsh -c lxc:///system console myguest --devname console1
 
=20

Running commands in a container

@@ -761,7 +761,7 @@ and then execute an arbitrary command.

=20
-# virsh -c lxc:/// lxc-enter-namespace myguest -- /bin/ls -al /dev
+# virsh -c lxc:///system lxc-enter-namespace myguest -- /bin/ls -al /dev
 
=20

Monitoring container utilization

@@ -773,7 +773,7 @@ host

=20
-# virt-top -c lxc:///
+# virt-top -c lxc:///system
 
=20

Converting LXC container configuration

@@ -784,7 +784,7 @@ most of the LXC container configuration into a domain X= ML fragment

=20
-# virsh -c lxc:/// domxml-from-native lxc-tools /var/lib/lxc/myguest/config
+# virsh -c lxc:///system domxml-from-native lxc-tools /var/lib/lxc/myguest=
/config
 
=20

diff --git a/examples/lxcconvert/virt-lxc-convert b/examples/lxcconvert/vir= t-lxc-convert index e62172eea4..5260eb708f 100644 --- a/examples/lxcconvert/virt-lxc-convert +++ b/examples/lxcconvert/virt-lxc-convert @@ -123,5 +123,5 @@ if test -z "$mem_limit"; then echo "lxc.cgroup.memory.limit_in_bytes =3D $memory" >> "$conf_new" fi =20 -virsh -c lxc:/// domxml-from-native lxc-tools $conf_new +virsh -c lxc:///system domxml-from-native lxc-tools $conf_new exit $? diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 4f600f3df7..cb481bf20a 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -164,7 +164,7 @@ static virDrvOpenStatus lxcConnectOpen(virConnectPtr co= nn, if (lxc_driver =3D=3D NULL) return VIR_DRV_OPEN_DECLINED; =20 - if (!(conn->uri =3D virURIParse("lxc:///"))) + if (!(conn->uri =3D virURIParse("lxc:///system"))) return VIR_DRV_OPEN_ERROR; } else { if (conn->uri->scheme =3D=3D NULL || @@ -177,9 +177,10 @@ static virDrvOpenStatus lxcConnectOpen(virConnectPtr c= onn, =20 /* If path isn't '/' then they typoed, tell them correct path */ if (conn->uri->path !=3D NULL && - STRNEQ(conn->uri->path, "/")) { + STRNEQ(conn->uri->path, "/") && + STRNEQ(conn->uri->path, "/system")) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected LXC URI path '%s', try lxc:///"), + _("Unexpected LXC URI path '%s', try lxc:///sys= tem"), conn->uri->path); return VIR_DRV_OPEN_ERROR; } diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 85c7bcc321..99c41014ee 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -109,7 +109,7 @@ virLXCProcessReboot(virLXCDriverPtr driver, virObjectRef(conn); autodestroy =3D true; } else { - conn =3D virConnectOpen("lxc:///"); + conn =3D virConnectOpen("lxc:///system"); /* Ignoring NULL conn which is mostly harmless here */ } =20 @@ -1629,7 +1629,7 @@ virLXCProcessAutostartAll(virLXCDriverPtr driver) * to lookup the bridge associated with a virtual * network */ - virConnectPtr conn =3D virConnectOpen("lxc:///"); + virConnectPtr conn =3D virConnectOpen("lxc:///system"); /* Ignoring NULL conn which is mostly harmless here */ =20 struct virLXCProcessAutostartData data =3D { driver, conn }; diff --git a/tools/libvirt-guests.sysconf b/tools/libvirt-guests.sysconf index 4e11464d2d..669b046507 100644 --- a/tools/libvirt-guests.sysconf +++ b/tools/libvirt-guests.sysconf @@ -1,5 +1,5 @@ # URIs to check for running guests -# example: URIS=3D'default xen:///system vbox+tcp://host/system lxc:///' +# example: URIS=3D'default xen:///system vbox+tcp://host/system lxc:///sys= tem' #URIS=3Ddefault =20 # action taken on host boot diff --git a/tools/virsh.pod b/tools/virsh.pod index 4d25ac5d9b..929958a953 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -266,7 +266,7 @@ connect locally as root to the daemon supervising QEMU = and KVM domains =20 connect locally as a normal user to his own set of QEMU and KVM domains =20 -=3Ditem lxc:/// +=3Ditem lxc:///system =20 connect to a local linux container =20 diff --git a/tools/virt-login-shell.c b/tools/virt-login-shell.c index 016e2b6d4e..b68c393026 100644 --- a/tools/virt-login-shell.c +++ b/tools/virt-login-shell.c @@ -253,7 +253,7 @@ main(int argc, char **argv) if (virConfGetValueBool(conf, "auto_shell", &autoshell) < 0) goto cleanup; =20 - conn =3D virConnectOpen("lxc:///"); + conn =3D virConnectOpen("lxc:///system"); if (!conn) goto cleanup; =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 02:25:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523288772136489.7552444307812; Mon, 9 Apr 2018 08:46:12 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AFDE8C04BE12; Mon, 9 Apr 2018 15:46:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7DE775DA63; Mon, 9 Apr 2018 15:46:10 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4394C4CAA3; Mon, 9 Apr 2018 15:46:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w39Fjuo0032398 for ; Mon, 9 Apr 2018 11:45:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9A7322024CA9; Mon, 9 Apr 2018 15:45:56 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id C03B82024CA7; Mon, 9 Apr 2018 15:45:55 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 9 Apr 2018 16:45:46 +0100 Message-Id: <20180409154551.22604-4-berrange@redhat.com> In-Reply-To: <20180409154551.22604-1-berrange@redhat.com> References: <20180409154551.22604-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/8] driver: introduce a driver method for probing default URIs X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 09 Apr 2018 15:46:11 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 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=C3=A9 --- 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 =3D "vir$name"; - } elsif ($name =3D~ /\w+(Open|Close)/) { + } elsif ($name =3D~ /\w+(Open|Close|URIProbe)/) { next; } else { die "driver $name does not have a public API"; @@ -241,12 +241,12 @@ foreach my $src (@srcs) { =20 next if $api eq "no" || $api eq "name"; =20 - die "Method $meth in $src is missing version" unless defin= ed $vers; + die "Method $meth in $src is missing version" unless defin= ed $vers || $api eq "connectURIProbe"; =20 die "Driver method for $api is NULL in $src" if $meth eq "= NULL"; =20 if (!exists($groups{$ingrp}->{apis}->{$api})) { - next if $api =3D~ /\w(Open|Close)/; + next if $api =3D~ /\w(Open|Close|URIProbe)/; =20 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; } =20 + +static int +bhyveConnectURIProbe(char **uri) +{ + if (bhyve_driver =3D=3D NULL) + return 0; + + return VIR_STRDUP(*uri, "bhyve:///system"); +} + + static virDrvOpenStatus bhyveConnectOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, @@ -189,11 +200,7 @@ bhyveConnectOpen(virConnectPtr conn, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 if (conn->uri =3D=3D NULL) { - if (bhyve_driver =3D=3D NULL) - return VIR_DRV_OPEN_DECLINED; - - if (!(conn->uri =3D 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, =20 static virHypervisorDriver bhyveHypervisorDriver =3D { .name =3D "bhyve", + .connectURIProbe =3D bhyveConnectURIProbe, .connectOpen =3D bhyveConnectOpen, /* 1.2.2 */ .connectClose =3D bhyveConnectClose, /* 1.2.2 */ .connectGetVersion =3D bhyveConnectGetVersion, /* 1.2.2 */ diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index ce0e2b2525..e71a72a441 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -25,6 +25,9 @@ # error "Don't include this file directly, only use driver.h" # endif =20 +typedef int +(*virDrvConnectURIProbe)(char **uri); + typedef virDrvOpenStatus (*virDrvConnectOpen)(virConnectPtr conn, virConnectAuthPtr auth, @@ -1300,6 +1303,7 @@ typedef virHypervisorDriver *virHypervisorDriverPtr; */ struct _virHypervisorDriver { const char *name; /* the name of the driver */ + virDrvConnectURIProbe connectURIProbe; virDrvConnectOpen connectOpen; virDrvConnectClose connectClose; virDrvConnectSupportsFeature connectSupportsFeature; diff --git a/src/libvirt.c b/src/libvirt.c index 51acbbf83e..d87efca625 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -975,6 +975,19 @@ virConnectOpenInternal(const char *name, } else { if (virConnectGetDefaultURI(conf, &uristr) < 0) goto failed; + + if (uristr =3D=3D NULL) { + VIR_DEBUG("Trying to probe for default URI"); + for (i =3D 0; i < virConnectDriverTabCount && uristr =3D=3D NU= LL; i++) { + if (virConnectDriverTab[i]->hypervisorDriver->connectURIPr= obe) { + if (virConnectDriverTab[i]->hypervisorDriver->connectU= RIProbe(&uristr) < 0) + goto failed; + VIR_DEBUG("%s driver URI probe returned '%s'", + virConnectDriverTab[i]->hypervisorDriver->na= me, + uristr ? uristr : ""); + } + } + } } =20 if (uristr) { diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index c559bf6514..d574fa446e 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -827,6 +827,16 @@ libxlStateReload(void) } =20 =20 +static int +libxlConnectURIProbe(char **uri) +{ + if (libxl_driver =3D=3D NULL) + return 0; + + return VIR_STRDUP(*uri, "xen:///system"); +} + + static virDrvOpenStatus libxlConnectOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, @@ -836,11 +846,7 @@ libxlConnectOpen(virConnectPtr conn, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 if (conn->uri =3D=3D NULL) { - if (libxl_driver =3D=3D NULL) - return VIR_DRV_OPEN_DECLINED; - - if (!(conn->uri =3D virURIParse("xen:///system"))) - return VIR_DRV_OPEN_ERROR; + return VIR_DRV_OPEN_DECLINED; } else { /* Only xen scheme */ if (conn->uri->scheme =3D=3D NULL || STRNEQ(conn->uri->scheme, "xe= n")) @@ -6466,6 +6472,7 @@ libxlConnectBaselineCPU(virConnectPtr conn, =20 static virHypervisorDriver libxlHypervisorDriver =3D { .name =3D LIBXL_DRIVER_NAME, + .connectURIProbe =3D libxlConnectURIProbe, .connectOpen =3D libxlConnectOpen, /* 0.9.0 */ .connectClose =3D libxlConnectClose, /* 0.9.0 */ .connectGetType =3D libxlConnectGetType, /* 0.9.0 */ diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index cb481bf20a..7fbeabc994 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -152,6 +152,16 @@ lxcDomObjFromDomain(virDomainPtr domain) =20 /* Functions */ =20 +static int +lxcConnectURIProbe(char **uri) +{ + if (lxc_driver =3D=3D NULL) + return 0; + + return VIR_STRDUP(*uri, "lxc:///system"); +} + + static virDrvOpenStatus lxcConnectOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UN= USED, virConfPtr conf ATTRIBUTE_UNUSED, @@ -161,11 +171,7 @@ static virDrvOpenStatus lxcConnectOpen(virConnectPtr c= onn, =20 /* Verify uri was specified */ if (conn->uri =3D=3D NULL) { - if (lxc_driver =3D=3D NULL) - return VIR_DRV_OPEN_DECLINED; - - if (!(conn->uri =3D virURIParse("lxc:///system"))) - return VIR_DRV_OPEN_ERROR; + return VIR_DRV_OPEN_DECLINED; } else { if (conn->uri->scheme =3D=3D NULL || STRNEQ(conn->uri->scheme, "lxc")) @@ -5533,6 +5539,7 @@ lxcDomainHasManagedSaveImage(virDomainPtr dom, unsign= ed int flags) /* Function Tables */ static virHypervisorDriver lxcHypervisorDriver =3D { .name =3D LXC_DRIVER_NAME, + .connectURIProbe =3D lxcConnectURIProbe, .connectOpen =3D lxcConnectOpen, /* 0.4.2 */ .connectClose =3D lxcConnectClose, /* 0.4.2 */ .connectSupportsFeature =3D lxcConnectSupportsFeature, /* 1.2.2 */ diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index f1132490e8..f30db8eec3 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1420,6 +1420,20 @@ openvzDomainSetVcpus(virDomainPtr dom, unsigned int = nvcpus) return openvzDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_AFFECT_LIVE); } =20 + +static int +openvzConnectURIProbe(char **uri) +{ + if (!virFileExists("/proc/vz")) + return 0; + + if (access("/proc/vz", W_OK) < 0) + return 0; + + return VIR_STRDUP(*uri, "openvz:///system"); +} + + static virDrvOpenStatus openvzConnectOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE= _UNUSED, virConfPtr conf ATTRIBUTE_UNUSED, @@ -1430,14 +1444,7 @@ static virDrvOpenStatus openvzConnectOpen(virConnect= Ptr conn, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 if (conn->uri =3D=3D NULL) { - if (!virFileExists("/proc/vz")) - return VIR_DRV_OPEN_DECLINED; - - if (access("/proc/vz", W_OK) < 0) - return VIR_DRV_OPEN_DECLINED; - - if (!(conn->uri =3D virURIParse("openvz:///system"))) - return VIR_DRV_OPEN_ERROR; + return VIR_DRV_OPEN_DECLINED; } else { /* If scheme isn't 'openvz', then its for another driver */ if (conn->uri->scheme =3D=3D NULL || @@ -2585,6 +2592,7 @@ openvzDomainHasManagedSaveImage(virDomainPtr dom, uns= igned int flags) =20 static virHypervisorDriver openvzHypervisorDriver =3D { .name =3D "OPENVZ", + .connectURIProbe =3D openvzConnectURIProbe, .connectOpen =3D openvzConnectOpen, /* 0.3.1 */ .connectClose =3D openvzConnectClose, /* 0.3.1 */ .connectGetType =3D openvzConnectGetType, /* 0.3.1 */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5c31dfdd58..99ec51f304 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1115,6 +1115,25 @@ qemuStateCleanup(void) } =20 =20 +static int +qemuConnectURIProbe(char **uri) +{ + virQEMUDriverConfigPtr cfg =3D NULL; + int ret =3D -1; + + if (qemu_driver =3D=3D NULL) + return 0; + + cfg =3D virQEMUDriverGetConfig(qemu_driver); + if (VIR_STRDUP(*uri, cfg->uri) < 0) + goto cleanup; + + ret =3D 0; + cleanup: + virObjectUnref(cfg); + return ret; +} + static virDrvOpenStatus qemuConnectOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_U= NUSED, virConfPtr conf ATTRIBUTE_UNUSED, @@ -1125,15 +1144,7 @@ static virDrvOpenStatus qemuConnectOpen(virConnectPt= r conn, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 if (conn->uri =3D=3D NULL) { - if (qemu_driver =3D=3D NULL) { - ret =3D VIR_DRV_OPEN_DECLINED; - goto cleanup; - } - - cfg =3D virQEMUDriverGetConfig(qemu_driver); - - if (!(conn->uri =3D virURIParse(cfg->uri))) - goto cleanup; + return VIR_DRV_OPEN_DECLINED; } else { /* If URI isn't 'qemu' its definitely not for us */ if (conn->uri->scheme =3D=3D NULL || @@ -21340,6 +21351,7 @@ qemuDomainSetLifecycleAction(virDomainPtr dom, =20 static virHypervisorDriver qemuHypervisorDriver =3D { .name =3D QEMU_DRIVER_NAME, + .connectURIProbe =3D qemuConnectURIProbe, .connectOpen =3D qemuConnectOpen, /* 0.2.0 */ .connectClose =3D qemuConnectClose, /* 0.2.0 */ .connectSupportsFeature =3D qemuConnectSupportsFeature, /* 0.5.0 */ diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index ab7fa7f273..63350908dd 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1185,6 +1185,17 @@ static void umlShutdownVMDaemon(struct uml_driver *d= river, } =20 =20 +static int umlConnectURIProbe(char **uri) +{ + if (uml_driver =3D=3D NULL) + return 0; + + return VIR_STRDUP(*uri, uml_driver->privileged ? + "uml:///system" : + "uml:///session"); +} + + static virDrvOpenStatus umlConnectOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UN= USED, virConfPtr conf ATTRIBUTE_UNUSED, @@ -1193,13 +1204,7 @@ static virDrvOpenStatus umlConnectOpen(virConnectPtr= conn, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 if (conn->uri =3D=3D NULL) { - if (uml_driver =3D=3D NULL) - return VIR_DRV_OPEN_DECLINED; - - if (!(conn->uri =3D virURIParse(uml_driver->privileged ? - "uml:///system" : - "uml:///session"))) - return VIR_DRV_OPEN_ERROR; + return VIR_DRV_OPEN_DECLINED; } else { if (conn->uri->scheme =3D=3D NULL || STRNEQ(conn->uri->scheme, "uml")) @@ -2947,6 +2952,7 @@ umlDomainHasManagedSaveImage(virDomainPtr dom, unsign= ed int flags) =20 static virHypervisorDriver umlHypervisorDriver =3D { .name =3D "UML", + .connectURIProbe =3D umlConnectURIProbe, .connectOpen =3D umlConnectOpen, /* 0.5.0 */ .connectClose =3D umlConnectClose, /* 0.5.0 */ .connectGetType =3D umlConnectGetType, /* 0.5.0 */ diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 3bcca43d32..ef71e650c6 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -499,6 +499,13 @@ vboxAttachStorageControllers(virDomainDefPtr def, } =20 =20 +static int +vboxConnectURIProbe(char **uri) +{ + return VIR_STRDUP(*uri, geteuid() ? "vbox:///session" : "vbox:///syste= m"); +} + + static virDrvOpenStatus vboxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, @@ -510,9 +517,8 @@ vboxConnectOpen(virConnectPtr conn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL && - !(conn->uri =3D virURIParse(uid ? "vbox:///session" : "vbox:///sys= tem"))) - return VIR_DRV_OPEN_ERROR; + if (conn->uri =3D=3D NULL) + return VIR_DRV_OPEN_DECLINED; =20 if (conn->uri->scheme =3D=3D NULL || STRNEQ(conn->uri->scheme, "vbox")) @@ -7980,6 +7986,7 @@ vboxDomainSendKey(virDomainPtr dom, =20 virHypervisorDriver vboxCommonDriver =3D { .name =3D "VBOX", + .connectURIProbe =3D vboxConnectURIProbe, .connectOpen =3D vboxConnectOpen, /* 0.6.3 */ .connectClose =3D vboxConnectClose, /* 0.6.3 */ .connectGetVersion =3D vboxConnectGetVersion, /* 0.6.3 */ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 02:25:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523288760829474.8838774223309; Mon, 9 Apr 2018 08:46:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5BCC785545; Mon, 9 Apr 2018 15:45:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D6A25FCB9; Mon, 9 Apr 2018 15:45:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E81E74CA9C; Mon, 9 Apr 2018 15:45:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w39FjvDG032408 for ; Mon, 9 Apr 2018 11:45:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 59868202699A; Mon, 9 Apr 2018 15:45:57 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE8DA2024CA7; Mon, 9 Apr 2018 15:45:56 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 9 Apr 2018 16:45:47 +0100 Message-Id: <20180409154551.22604-5-berrange@redhat.com> In-Reply-To: <20180409154551.22604-1-berrange@redhat.com> References: <20180409154551.22604-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/8] driver: allow drivers to indicate if they permit remote connections X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 09 Apr 2018 15:45:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Add a localOnly flag to the virConnectDriver struct which allows a driver to indicate whether it is local-only, or permits remote connections. Stateful drivers running inside libvirtd are generally local only. This allows us to remote the check for uri->server !=3D NULL from most drivers. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/bhyve/bhyve_driver.c | 4 +--- src/driver.h | 2 ++ src/interface/interface_backend_netcf.c | 5 +---- src/interface/interface_backend_udev.c | 5 +---- src/libvirt.c | 5 +++++ src/libxl/libxl_driver.c | 5 +---- src/lxc/lxc_driver.c | 5 +---- src/network/bridge_driver.c | 5 +---- src/node_device/node_device_driver.c | 4 ---- src/node_device/node_device_hal.c | 1 + src/node_device/node_device_udev.c | 1 + src/nwfilter/nwfilter_driver.c | 5 +---- src/openvz/openvz_driver.c | 5 +---- src/qemu/qemu_driver.c | 7 +------ src/secret/secret_driver.c | 5 +---- src/storage/storage_driver.c | 5 +---- src/test/test_driver.c | 5 +---- src/uml/uml_driver.c | 6 +----- src/vbox/vbox_common.c | 4 ---- src/vbox/vbox_driver.c | 8 +++++--- src/vmware/vmware_driver.c | 5 +---- src/vz/vz_driver.c | 5 +---- 22 files changed, 29 insertions(+), 73 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index a0bc400480..cc1d4ba6fb 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -205,9 +205,6 @@ bhyveConnectOpen(virConnectPtr conn, if (!conn->uri->scheme || STRNEQ(conn->uri->scheme, "bhyve")) return VIR_DRV_OPEN_DECLINED; =20 - if (conn->uri->server) - 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"), @@ -1754,6 +1751,7 @@ static virHypervisorDriver bhyveHypervisorDriver =3D { =20 =20 static virConnectDriver bhyveConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &bhyveHypervisorDriver, }; =20 diff --git a/src/driver.h b/src/driver.h index c86da85481..5fb0b523c8 100644 --- a/src/driver.h +++ b/src/driver.h @@ -79,6 +79,8 @@ typedef struct _virConnectDriver virConnectDriver; typedef virConnectDriver *virConnectDriverPtr; =20 struct _virConnectDriver { + /* Wether driver permits a server in the URI */ + bool localOnly; virHypervisorDriverPtr hypervisorDriver; virInterfaceDriverPtr interfaceDriver; virNetworkDriverPtr networkDriver; diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interf= ace_backend_netcf.c index fb75a33280..3da958980f 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -167,10 +167,6 @@ netcfConnectOpen(virConnectPtr conn, if (STRNEQ_NULLABLE(conn->uri->scheme, "interface")) return VIR_DRV_OPEN_DECLINED; =20 - /* Leave for remote driver */ - if (conn->uri->server !=3D NULL) - return VIR_DRV_OPEN_DECLINED; - if (driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("interface state driver is not active")); @@ -1224,6 +1220,7 @@ static virHypervisorDriver interfaceHypervisorDriver = =3D { =20 =20 static virConnectDriver interfaceConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &interfaceHypervisorDriver, .interfaceDriver =3D &interfaceDriver, }; diff --git a/src/interface/interface_backend_udev.c b/src/interface/interfa= ce_backend_udev.c index 47e850bc2a..2b8a9da682 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -1211,10 +1211,6 @@ udevConnectOpen(virConnectPtr conn, if (STRNEQ_NULLABLE(conn->uri->scheme, "interface")) return VIR_DRV_OPEN_DECLINED; =20 - /* Leave for remote driver */ - if (conn->uri->server !=3D NULL) - return VIR_DRV_OPEN_DECLINED; - if (driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("interface state driver is not active")); @@ -1295,6 +1291,7 @@ static virHypervisorDriver udevHypervisorDriver =3D { =20 =20 static virConnectDriver udevConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &udevHypervisorDriver, .interfaceDriver =3D &udevIfaceDriver, }; diff --git a/src/libvirt.c b/src/libvirt.c index d87efca625..2b2b3ed425 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1068,6 +1068,11 @@ virConnectOpenInternal(const char *name, VIR_DEBUG("trying driver %zu (%s) ...", i, virConnectDriverTab[i]->hypervisorDriver->name); =20 + if (virConnectDriverTab[i]->localOnly && ret->uri && ret->uri->ser= ver) { + VIR_DEBUG("Server present, skipping local only driver"); + continue; + } + ret->driver =3D virConnectDriverTab[i]->hypervisorDriver; ret->interfaceDriver =3D virConnectDriverTab[i]->interfaceDriver; ret->networkDriver =3D virConnectDriverTab[i]->networkDriver; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index d574fa446e..ce4741cf4c 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -852,10 +852,6 @@ libxlConnectOpen(virConnectPtr conn, if (conn->uri->scheme =3D=3D NULL || STRNEQ(conn->uri->scheme, "xe= n")) return VIR_DRV_OPEN_DECLINED; =20 - /* If server name is given, its for remote driver */ - if (conn->uri->server !=3D NULL) - return VIR_DRV_OPEN_DECLINED; - /* Error if xen or libxl scheme specified but driver not started. = */ if (libxl_driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -6582,6 +6578,7 @@ static virHypervisorDriver libxlHypervisorDriver =3D { }; =20 static virConnectDriver libxlConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &libxlHypervisorDriver, }; =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 7fbeabc994..7a3e720d16 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -177,10 +177,6 @@ static virDrvOpenStatus lxcConnectOpen(virConnectPtr c= onn, STRNEQ(conn->uri->scheme, "lxc")) return VIR_DRV_OPEN_DECLINED; =20 - /* Leave for remote driver */ - if (conn->uri->server !=3D NULL) - return VIR_DRV_OPEN_DECLINED; - /* If path isn't '/' then they typoed, tell them correct path */ if (conn->uri->path !=3D NULL && STRNEQ(conn->uri->path, "/") && @@ -5633,6 +5629,7 @@ static virHypervisorDriver lxcHypervisorDriver =3D { }; =20 static virConnectDriver lxcConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &lxcHypervisorDriver, }; =20 diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index d326923d81..ca48a0358c 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -886,10 +886,6 @@ networkConnectOpen(virConnectPtr conn, if (STRNEQ_NULLABLE(conn->uri->scheme, "network")) return VIR_DRV_OPEN_DECLINED; =20 - /* Leave for remote driver */ - if (conn->uri->server !=3D NULL) - return VIR_DRV_OPEN_DECLINED; - if (network_driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("network state driver is not active")); @@ -5616,6 +5612,7 @@ static virHypervisorDriver networkHypervisorDriver = =3D { =20 =20 static virConnectDriver networkConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &networkHypervisorDriver, .networkDriver =3D &networkDriver, }; diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 1347ce0c86..ad4938fcd6 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -62,10 +62,6 @@ nodeConnectOpen(virConnectPtr conn, if (STRNEQ_NULLABLE(conn->uri->scheme, "nodedev")) return VIR_DRV_OPEN_DECLINED; =20 - /* Leave for remote driver */ - if (conn->uri->server !=3D NULL) - return VIR_DRV_OPEN_DECLINED; - if (driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nodedev state driver is not active")); diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_devic= e_hal.c index 6ad56f4166..4c251da88a 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -783,6 +783,7 @@ static virHypervisorDriver halHypervisorDriver =3D { =20 =20 static virConnectDriver halConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &halHypervisorDriver, .nodeDeviceDriver =3D &halNodeDeviceDriver, }; diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index e87eb32a85..d89b5ff7cc 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1957,6 +1957,7 @@ static virHypervisorDriver udevHypervisorDriver =3D { =20 =20 static virConnectDriver udevConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &udevHypervisorDriver, .nodeDeviceDriver =3D &udevNodeDeviceDriver, }; diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 6cc7ca699a..71aca5a968 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -379,10 +379,6 @@ nwfilterConnectOpen(virConnectPtr conn, if (STRNEQ_NULLABLE(conn->uri->scheme, "nwfilter")) return VIR_DRV_OPEN_DECLINED; =20 - /* Leave for remote driver */ - if (conn->uri->server !=3D NULL) - return VIR_DRV_OPEN_DECLINED; - if (driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nwfilter state driver is not active")); @@ -712,6 +708,7 @@ static virHypervisorDriver nwfilterHypervisorDriver =3D= { =20 =20 static virConnectDriver nwfilterConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &nwfilterHypervisorDriver, .nwfilterDriver =3D &nwfilterDriver, }; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index f30db8eec3..a56476475e 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1451,10 +1451,6 @@ static virDrvOpenStatus openvzConnectOpen(virConnect= Ptr conn, STRNEQ(conn->uri->scheme, "openvz")) return VIR_DRV_OPEN_DECLINED; =20 - /* If server name is given, its for remote driver */ - if (conn->uri->server !=3D NULL) - return VIR_DRV_OPEN_DECLINED; - /* If path isn't /system, then they typoed, so tell them correct p= ath */ if (conn->uri->path =3D=3D NULL || STRNEQ(conn->uri->path, "/system")) { @@ -2659,6 +2655,7 @@ static virHypervisorDriver openvzHypervisorDriver =3D= { }; =20 static virConnectDriver openvzConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &openvzHypervisorDriver, }; =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 99ec51f304..ef890916dc 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1153,12 +1153,6 @@ static virDrvOpenStatus qemuConnectOpen(virConnectPt= r conn, goto cleanup; } =20 - /* Allow remote driver to deal with URIs with hostname server */ - if (conn->uri->server !=3D NULL) { - ret =3D VIR_DRV_OPEN_DECLINED; - goto cleanup; - } - if (qemu_driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("qemu state driver is not active")); @@ -21573,6 +21567,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { =20 =20 static virConnectDriver qemuConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &qemuHypervisorDriver, }; =20 diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index 23a3c9bdad..06d116f07f 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -532,10 +532,6 @@ secretConnectOpen(virConnectPtr conn, if (STRNEQ_NULLABLE(conn->uri->scheme, "secret")) return VIR_DRV_OPEN_DECLINED; =20 - /* Leave for remote driver */ - if (conn->uri->server !=3D NULL) - return VIR_DRV_OPEN_DECLINED; - if (driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("secret state driver is not active")); @@ -662,6 +658,7 @@ static virHypervisorDriver secretHypervisorDriver =3D { =20 =20 static virConnectDriver secretConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &secretHypervisorDriver, .secretDriver =3D &secretDriver, }; diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 173b91b61b..7eb5fad929 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -392,10 +392,6 @@ storageConnectOpen(virConnectPtr conn, if (STRNEQ_NULLABLE(conn->uri->scheme, "storage")) return VIR_DRV_OPEN_DECLINED; =20 - /* Leave for remote driver */ - if (conn->uri->server !=3D NULL) - return VIR_DRV_OPEN_DECLINED; - if (driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("storage state driver is not active")); @@ -2855,6 +2851,7 @@ static virHypervisorDriver storageHypervisorDriver = =3D { }; =20 static virConnectDriver storageConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &storageHypervisorDriver, .storageDriver =3D &storageDriver, }; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 856869c9d3..de3943406e 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1460,10 +1460,6 @@ testConnectOpen(virConnectPtr conn, if (!conn->uri->scheme || STRNEQ(conn->uri->scheme, "test")) return VIR_DRV_OPEN_DECLINED; =20 - /* Remote driver should handle these. */ - if (conn->uri->server) - return VIR_DRV_OPEN_DECLINED; - /* From this point on, the connection is for us. */ if (!conn->uri->path || conn->uri->path[0] =3D=3D '\0' @@ -7065,6 +7061,7 @@ static virNodeDeviceDriver testNodeDeviceDriver =3D { }; =20 static virConnectDriver testConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &testHypervisorDriver, .interfaceDriver =3D &testInterfaceDriver, .networkDriver =3D &testNetworkDriver, diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 63350908dd..7fae561aff 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1210,11 +1210,6 @@ static virDrvOpenStatus umlConnectOpen(virConnectPtr= conn, STRNEQ(conn->uri->scheme, "uml")) return VIR_DRV_OPEN_DECLINED; =20 - /* Allow remote driver to deal with URIs with hostname server */ - if (conn->uri->server !=3D NULL) - return VIR_DRV_OPEN_DECLINED; - - /* Check path and tell them correct path if they made a mistake */ if (uml_driver->privileged) { if (STRNEQ(conn->uri->path, "/system") && @@ -3018,6 +3013,7 @@ static virHypervisorDriver umlHypervisorDriver =3D { }; =20 static virConnectDriver umlConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D ¨HypervisorDriver, }; =20 diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index ef71e650c6..886b41b0b9 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -524,10 +524,6 @@ vboxConnectOpen(virConnectPtr conn, STRNEQ(conn->uri->scheme, "vbox")) return VIR_DRV_OPEN_DECLINED; =20 - /* Leave for remote driver */ - if (conn->uri->server !=3D NULL) - return VIR_DRV_OPEN_DECLINED; - if (conn->uri->path =3D=3D NULL || STREQ(conn->uri->path, "")) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no VirtualBox driver path specified (try vbox://= /session)")); diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c index c10c0c492b..e3880b4826 100644 --- a/src/vbox/vbox_driver.c +++ b/src/vbox/vbox_driver.c @@ -60,8 +60,7 @@ static virDrvOpenStatus dummyConnectOpen(virConnectPtr co= nn, =20 if (conn->uri =3D=3D NULL || conn->uri->scheme =3D=3D NULL || - STRNEQ(conn->uri->scheme, "vbox") || - conn->uri->server !=3D NULL) + STRNEQ(conn->uri->scheme, "vbox")) return VIR_DRV_OPEN_DECLINED; =20 if (conn->uri->path =3D=3D NULL || STREQ(conn->uri->path, "")) { @@ -95,7 +94,10 @@ static virHypervisorDriver vboxDriverDummy =3D { .connectOpen =3D dummyConnectOpen, /* 0.6.3 */ }; =20 -static virConnectDriver vboxConnectDriver; +static virConnectDriver vboxConnectDriver =3D { + .localOnly =3D true, + .hypervisorDriver =3D NULL, +}; =20 int vboxRegister(void) { diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 8b487c4a7c..435b9ee6ff 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -140,10 +140,6 @@ vmwareConnectOpen(virConnectPtr conn, STRNEQ(conn->uri->scheme, "vmwarefusion"))) return VIR_DRV_OPEN_DECLINED; =20 - /* If server name is given, its for remote driver */ - if (conn->uri->server !=3D NULL) - return VIR_DRV_OPEN_DECLINED; - /* If path isn't /session, then they typoed, so tell them correct = path */ if (conn->uri->path =3D=3D NULL || STRNEQ(conn->uri->path, "/sessi= on")) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1271,6 +1267,7 @@ static virHypervisorDriver vmwareHypervisorDriver =3D= { }; =20 static virConnectDriver vmwareConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &vmwareHypervisorDriver, }; =20 diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index a425bc8552..8842056ea4 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -374,10 +374,6 @@ vzConnectOpen(virConnectPtr conn, if (STREQ(conn->uri->scheme, "parallels") && STRNEQ(conn->driver->name= , "Parallels")) return VIR_DRV_OPEN_DECLINED; =20 - /* Remote driver should handle these. */ - if (conn->uri->server) - return VIR_DRV_OPEN_DECLINED; - /* From this point on, the connection is for us. */ if (STRNEQ_NULLABLE(conn->uri->path, "/system")) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -4143,6 +4139,7 @@ static virHypervisorDriver vzHypervisorDriver =3D { }; =20 static virConnectDriver vzConnectDriver =3D { + .localOnly =3D true, .hypervisorDriver =3D &vzHypervisorDriver, }; =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 02:25:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523288764948100.38828082311989; Mon, 9 Apr 2018 08:46:04 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0F775A72; Mon, 9 Apr 2018 15:46:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7945E183A0; Mon, 9 Apr 2018 15:46:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3A9214CAA2; Mon, 9 Apr 2018 15:46:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w39FjwBI032414 for ; Mon, 9 Apr 2018 11:45:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2B77F2024CA8; Mon, 9 Apr 2018 15:45:58 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91D9B2024CA7; Mon, 9 Apr 2018 15:45:57 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 9 Apr 2018 16:45:48 +0100 Message-Id: <20180409154551.22604-6-berrange@redhat.com> In-Reply-To: <20180409154551.22604-1-berrange@redhat.com> References: <20180409154551.22604-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/8] driver: declare supported URI schemes in virConnectDriver struct X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 09 Apr 2018 15:46:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 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=C3=A9 --- 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 =3D=3D 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 =3D { =20 static virConnectDriver bhyveConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "bhyve", NULL }, .hypervisorDriver =3D &bhyveHypervisorDriver, }; =20 diff --git a/src/driver.h b/src/driver.h index 5fb0b523c8..b071a3a782 100644 --- a/src/driver.h +++ b/src/driver.h @@ -81,6 +81,12 @@ typedef virConnectDriver *virConnectDriverPtr; struct _virConnectDriver { /* Wether driver permits a server in the URI */ bool localOnly; + /* + * NULL terminated list of supported URI schemes. + * - Single element { NULL } list indicates no supported schemes + * - NULL list indicates wildcard supportnig all schemes + */ + const char **uriSchemes; virHypervisorDriverPtr hypervisorDriver; virInterfaceDriverPtr interfaceDriver; virNetworkDriverPtr networkDriver; diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 927267f1cc..9b6944ba59 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -845,7 +845,6 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr au= th, unsigned int flags) { virDrvOpenStatus result =3D VIR_DRV_OPEN_ERROR; - char *plus; esxPrivate *priv =3D NULL; char *potentialVCenterIPAddress =3D NULL; char vCenterIPAddress[NI_MAXHOST] =3D ""; @@ -853,32 +852,9 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr a= uth, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 /* Decline if the URI is NULL or the scheme is NULL */ - if (!conn->uri || !conn->uri->scheme) + if (!conn->uri) return VIR_DRV_OPEN_DECLINED; =20 - /* Decline if the scheme is not one of {vpx|esx|gsx} */ - plus =3D strchr(conn->uri->scheme, '+'); - - if (!plus) { - if (STRCASENEQ(conn->uri->scheme, "vpx") && - STRCASENEQ(conn->uri->scheme, "esx") && - STRCASENEQ(conn->uri->scheme, "gsx")) { - return VIR_DRV_OPEN_DECLINED; - } - } else { - if (plus - conn->uri->scheme !=3D 3 || - (STRCASENEQLEN(conn->uri->scheme, "vpx", 3) && - STRCASENEQLEN(conn->uri->scheme, "esx", 3) && - STRCASENEQLEN(conn->uri->scheme, "gsx", 3))) { - return VIR_DRV_OPEN_DECLINED; - } - - virReportError(VIR_ERR_INVALID_ARG, - _("Transport '%s' in URI scheme is not supported, t= ry again " - "without the transport part"), plus + 1); - return VIR_DRV_OPEN_ERROR; - } - if (STRCASENEQ(conn->uri->scheme, "vpx") && conn->uri->path && STRNEQ(conn->uri->path, "/")) { VIR_WARN("Ignoring unexpected path '%s' for non-vpx scheme '%s'", @@ -5262,6 +5238,7 @@ static virHypervisorDriver esxHypervisorDriver =3D { =20 =20 static virConnectDriver esxConnectDriver =3D { + .uriSchemes =3D (const char *[]){ "vpx", "esx", "gsx", NULL }, .hypervisorDriver =3D &esxHypervisorDriver, .interfaceDriver =3D &esxInterfaceDriver, .networkDriver =3D &esxNetworkDriver, diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index e512b626ea..4ad8855dcc 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -122,7 +122,6 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr= auth, unsigned int flags) { virDrvOpenStatus result =3D VIR_DRV_OPEN_ERROR; - char *plus; hypervPrivate *priv =3D NULL; char *username =3D NULL; char *password =3D NULL; @@ -130,27 +129,9 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPt= r auth, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 /* Decline if the URI is NULL or the scheme is NULL */ - if (conn->uri =3D=3D NULL || conn->uri->scheme =3D=3D NULL) + if (conn->uri =3D=3D NULL) return VIR_DRV_OPEN_DECLINED; =20 - /* Decline if the scheme is not hyperv */ - plus =3D strchr(conn->uri->scheme, '+'); - - if (plus =3D=3D NULL) { - if (STRCASENEQ(conn->uri->scheme, "hyperv")) - return VIR_DRV_OPEN_DECLINED; - } else { - if (plus - conn->uri->scheme !=3D 6 || - STRCASENEQLEN(conn->uri->scheme, "hyperv", 6)) { - return VIR_DRV_OPEN_DECLINED; - } - - virReportError(VIR_ERR_INVALID_ARG, - _("Transport '%s' in URI scheme is not supported, t= ry again " - "without the transport part"), plus + 1); - return VIR_DRV_OPEN_ERROR; - } - /* Require server part */ if (conn->uri->server =3D=3D NULL) { virReportError(VIR_ERR_INVALID_ARG, "%s", @@ -1685,6 +1666,7 @@ hypervDebugHandler(const char *message, debug_level_e= level, =20 =20 static virConnectDriver hypervConnectDriver =3D { + .uriSchemes =3D (const char *[]){ "hyperv", NULL }, .hypervisorDriver =3D &hypervHypervisorDriver, }; =20 diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interf= ace_backend_netcf.c index 3da958980f..ff3443c8e6 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -164,9 +164,6 @@ netcfConnectOpen(virConnectPtr conn, /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ return VIR_DRV_OPEN_DECLINED; } else { - if (STRNEQ_NULLABLE(conn->uri->scheme, "interface")) - return VIR_DRV_OPEN_DECLINED; - if (driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("interface state driver is not active")); @@ -1221,6 +1218,7 @@ static virHypervisorDriver interfaceHypervisorDriver = =3D { =20 static virConnectDriver interfaceConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "interface", NULL }, .hypervisorDriver =3D &interfaceHypervisorDriver, .interfaceDriver =3D &interfaceDriver, }; diff --git a/src/interface/interface_backend_udev.c b/src/interface/interfa= ce_backend_udev.c index 2b8a9da682..743aafd8ba 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -1208,9 +1208,6 @@ udevConnectOpen(virConnectPtr conn, /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ return VIR_DRV_OPEN_DECLINED; } else { - if (STRNEQ_NULLABLE(conn->uri->scheme, "interface")) - return VIR_DRV_OPEN_DECLINED; - if (driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("interface state driver is not active")); @@ -1292,6 +1289,7 @@ static virHypervisorDriver udevHypervisorDriver =3D { =20 static virConnectDriver udevConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "interface", NULL }, .hypervisorDriver =3D &udevHypervisorDriver, .interfaceDriver =3D &udevIfaceDriver, }; diff --git a/src/libvirt.c b/src/libvirt.c index 2b2b3ed425..cc1387341a 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1073,6 +1073,30 @@ virConnectOpenInternal(const char *name, continue; } =20 + /* Filter drivers based on declared URI schemes */ + if (virConnectDriverTab[i]->uriSchemes && ret->uri) { + bool matchScheme =3D false; + size_t s; + if (!ret->uri->scheme) { + VIR_DEBUG("No URI scheme, skipping driver with URI whiteli= st"); + continue; + } + VIR_DEBUG("Checking for supported URI schemes"); + for (s =3D 0; virConnectDriverTab[i]->uriSchemes[s] !=3D NULL;= s++) { + if (STREQ(ret->uri->scheme, virConnectDriverTab[i]->uriSch= emes[s])) { + VIR_DEBUG("Matched URI scheme '%s'", ret->uri->scheme); + matchScheme =3D true; + break; + } + } + if (!matchScheme) { + VIR_DEBUG("No matching URI scheme"); + continue; + } + } else { + VIR_DEBUG("Matching any URI scheme for '%s'", ret->uri ? ret->= uri->scheme : ""); + } + ret->driver =3D virConnectDriverTab[i]->hypervisorDriver; ret->interfaceDriver =3D virConnectDriverTab[i]->interfaceDriver; ret->networkDriver =3D virConnectDriverTab[i]->networkDriver; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index ce4741cf4c..872790e743 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -848,10 +848,6 @@ libxlConnectOpen(virConnectPtr conn, if (conn->uri =3D=3D NULL) { return VIR_DRV_OPEN_DECLINED; } else { - /* Only xen scheme */ - if (conn->uri->scheme =3D=3D NULL || STRNEQ(conn->uri->scheme, "xe= n")) - return VIR_DRV_OPEN_DECLINED; - /* Error if xen or libxl scheme specified but driver not started. = */ if (libxl_driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -6579,6 +6575,7 @@ static virHypervisorDriver libxlHypervisorDriver =3D { =20 static virConnectDriver libxlConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "xen", NULL }, .hypervisorDriver =3D &libxlHypervisorDriver, }; =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 7a3e720d16..8b01abf75f 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -173,10 +173,6 @@ static virDrvOpenStatus lxcConnectOpen(virConnectPtr c= onn, if (conn->uri =3D=3D NULL) { return VIR_DRV_OPEN_DECLINED; } else { - if (conn->uri->scheme =3D=3D NULL || - STRNEQ(conn->uri->scheme, "lxc")) - return VIR_DRV_OPEN_DECLINED; - /* If path isn't '/' then they typoed, tell them correct path */ if (conn->uri->path !=3D NULL && STRNEQ(conn->uri->path, "/") && @@ -5630,6 +5626,7 @@ static virHypervisorDriver lxcHypervisorDriver =3D { =20 static virConnectDriver lxcConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "lxc", NULL }, .hypervisorDriver =3D &lxcHypervisorDriver, }; =20 diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index ca48a0358c..98754d4471 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -883,9 +883,6 @@ networkConnectOpen(virConnectPtr conn, /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ return VIR_DRV_OPEN_DECLINED; } else { - if (STRNEQ_NULLABLE(conn->uri->scheme, "network")) - return VIR_DRV_OPEN_DECLINED; - if (network_driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("network state driver is not active")); @@ -5613,6 +5610,7 @@ static virHypervisorDriver networkHypervisorDriver = =3D { =20 static virConnectDriver networkConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "network", NULL }, .hypervisorDriver =3D &networkHypervisorDriver, .networkDriver =3D &networkDriver, }; diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index ad4938fcd6..a3e3d76dfc 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -59,9 +59,6 @@ nodeConnectOpen(virConnectPtr conn, /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ return VIR_DRV_OPEN_DECLINED; } else { - if (STRNEQ_NULLABLE(conn->uri->scheme, "nodedev")) - return VIR_DRV_OPEN_DECLINED; - if (driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nodedev state driver is not active")); diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_devic= e_hal.c index 4c251da88a..2101101bc6 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -784,6 +784,7 @@ static virHypervisorDriver halHypervisorDriver =3D { =20 static virConnectDriver halConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "nodedev", NULL }, .hypervisorDriver =3D &halHypervisorDriver, .nodeDeviceDriver =3D &halNodeDeviceDriver, }; diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index d89b5ff7cc..de01816402 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1958,6 +1958,7 @@ static virHypervisorDriver udevHypervisorDriver =3D { =20 static virConnectDriver udevConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "nodedev", NULL }, .hypervisorDriver =3D &udevHypervisorDriver, .nodeDeviceDriver =3D &udevNodeDeviceDriver, }; diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 71aca5a968..76289265a2 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -376,9 +376,6 @@ nwfilterConnectOpen(virConnectPtr conn, /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ return VIR_DRV_OPEN_DECLINED; } else { - if (STRNEQ_NULLABLE(conn->uri->scheme, "nwfilter")) - return VIR_DRV_OPEN_DECLINED; - if (driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nwfilter state driver is not active")); @@ -709,6 +706,7 @@ static virHypervisorDriver nwfilterHypervisorDriver =3D= { =20 static virConnectDriver nwfilterConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "nwfilter", NULL }, .hypervisorDriver =3D &nwfilterHypervisorDriver, .nwfilterDriver =3D &nwfilterDriver, }; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index a56476475e..3eab3e47df 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1446,11 +1446,6 @@ static virDrvOpenStatus openvzConnectOpen(virConnect= Ptr conn, if (conn->uri =3D=3D NULL) { return VIR_DRV_OPEN_DECLINED; } else { - /* If scheme isn't 'openvz', then its for another driver */ - if (conn->uri->scheme =3D=3D NULL || - STRNEQ(conn->uri->scheme, "openvz")) - return VIR_DRV_OPEN_DECLINED; - /* If path isn't /system, then they typoed, so tell them correct p= ath */ if (conn->uri->path =3D=3D NULL || STRNEQ(conn->uri->path, "/system")) { @@ -2656,6 +2651,7 @@ static virHypervisorDriver openvzHypervisorDriver =3D= { =20 static virConnectDriver openvzConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "openvz", NULL }, .hypervisorDriver =3D &openvzHypervisorDriver, }; =20 diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index cce7448abc..ddbd9144bc 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1144,9 +1144,6 @@ phypConnectOpen(virConnectPtr conn, if (!conn || !conn->uri) return VIR_DRV_OPEN_DECLINED; =20 - if (conn->uri->scheme =3D=3D NULL || STRNEQ(conn->uri->scheme, "phyp")) - return VIR_DRV_OPEN_DECLINED; - if (conn->uri->server =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing server name in phyp:// URI")); @@ -3766,6 +3763,7 @@ static virInterfaceDriver phypInterfaceDriver =3D { }; =20 static virConnectDriver phypConnectDriver =3D { + .uriSchemes =3D (const char *[]){ "phyp", NULL }, .hypervisorDriver =3D &phypHypervisorDriver, .interfaceDriver =3D &phypInterfaceDriver, .storageDriver =3D &phypStorageDriver, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ef890916dc..8a6d3f9af0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1146,13 +1146,6 @@ static virDrvOpenStatus qemuConnectOpen(virConnectPt= r conn, if (conn->uri =3D=3D NULL) { return VIR_DRV_OPEN_DECLINED; } else { - /* If URI isn't 'qemu' its definitely not for us */ - if (conn->uri->scheme =3D=3D NULL || - STRNEQ(conn->uri->scheme, "qemu")) { - ret =3D VIR_DRV_OPEN_DECLINED; - goto cleanup; - } - if (qemu_driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("qemu state driver is not active")); @@ -21568,6 +21561,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { =20 static virConnectDriver qemuConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "qemu", NULL }, .hypervisorDriver =3D &qemuHypervisorDriver, }; =20 diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index 06d116f07f..aedfa10dcc 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -529,9 +529,6 @@ secretConnectOpen(virConnectPtr conn, /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ return VIR_DRV_OPEN_DECLINED; } else { - if (STRNEQ_NULLABLE(conn->uri->scheme, "secret")) - return VIR_DRV_OPEN_DECLINED; - if (driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("secret state driver is not active")); @@ -659,6 +656,7 @@ static virHypervisorDriver secretHypervisorDriver =3D { =20 static virConnectDriver secretConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "secret", NULL }, .hypervisorDriver =3D &secretHypervisorDriver, .secretDriver =3D &secretDriver, }; diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 7eb5fad929..1a81733842 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -389,9 +389,6 @@ storageConnectOpen(virConnectPtr conn, /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ return VIR_DRV_OPEN_DECLINED; } else { - if (STRNEQ_NULLABLE(conn->uri->scheme, "storage")) - return VIR_DRV_OPEN_DECLINED; - if (driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("storage state driver is not active")); @@ -2852,6 +2849,7 @@ static virHypervisorDriver storageHypervisorDriver = =3D { =20 static virConnectDriver storageConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "storage", NULL }, .hypervisorDriver =3D &storageHypervisorDriver, .storageDriver =3D &storageDriver, }; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index de3943406e..7f9c7f751e 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1457,9 +1457,6 @@ testConnectOpen(virConnectPtr conn, if (!conn->uri) return VIR_DRV_OPEN_DECLINED; =20 - if (!conn->uri->scheme || STRNEQ(conn->uri->scheme, "test")) - return VIR_DRV_OPEN_DECLINED; - /* From this point on, the connection is for us. */ if (!conn->uri->path || conn->uri->path[0] =3D=3D '\0' @@ -7062,6 +7059,7 @@ static virNodeDeviceDriver testNodeDeviceDriver =3D { =20 static virConnectDriver testConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "test", NULL }, .hypervisorDriver =3D &testHypervisorDriver, .interfaceDriver =3D &testInterfaceDriver, .networkDriver =3D &testNetworkDriver, diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 7fae561aff..2315cd4d15 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1206,10 +1206,6 @@ static virDrvOpenStatus umlConnectOpen(virConnectPtr= conn, if (conn->uri =3D=3D NULL) { return VIR_DRV_OPEN_DECLINED; } else { - if (conn->uri->scheme =3D=3D NULL || - STRNEQ(conn->uri->scheme, "uml")) - return VIR_DRV_OPEN_DECLINED; - /* Check path and tell them correct path if they made a mistake */ if (uml_driver->privileged) { if (STRNEQ(conn->uri->path, "/system") && @@ -3014,6 +3010,7 @@ static virHypervisorDriver umlHypervisorDriver =3D { =20 static virConnectDriver umlConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "uml", NULL }, .hypervisorDriver =3D ¨HypervisorDriver, }; =20 diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 886b41b0b9..4c4c80d45b 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -520,10 +520,6 @@ vboxConnectOpen(virConnectPtr conn, if (conn->uri =3D=3D NULL) return VIR_DRV_OPEN_DECLINED; =20 - if (conn->uri->scheme =3D=3D NULL || - STRNEQ(conn->uri->scheme, "vbox")) - return VIR_DRV_OPEN_DECLINED; - if (conn->uri->path =3D=3D NULL || STREQ(conn->uri->path, "")) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no VirtualBox driver path specified (try vbox://= /session)")); diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c index e3880b4826..395fa8e3d6 100644 --- a/src/vbox/vbox_driver.c +++ b/src/vbox/vbox_driver.c @@ -58,9 +58,7 @@ static virDrvOpenStatus dummyConnectOpen(virConnectPtr co= nn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL || - conn->uri->scheme =3D=3D NULL || - STRNEQ(conn->uri->scheme, "vbox")) + if (conn->uri =3D=3D NULL) return VIR_DRV_OPEN_DECLINED; =20 if (conn->uri->path =3D=3D NULL || STREQ(conn->uri->path, "")) { @@ -96,6 +94,7 @@ static virHypervisorDriver vboxDriverDummy =3D { =20 static virConnectDriver vboxConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "vbox", NULL }, .hypervisorDriver =3D NULL, }; =20 diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 435b9ee6ff..6118e6fa13 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -134,12 +134,6 @@ vmwareConnectOpen(virConnectPtr conn, /* @TODO accept */ return VIR_DRV_OPEN_DECLINED; } else { - if (conn->uri->scheme =3D=3D NULL || - (STRNEQ(conn->uri->scheme, "vmwareplayer") && - STRNEQ(conn->uri->scheme, "vmwarews") && - STRNEQ(conn->uri->scheme, "vmwarefusion"))) - return VIR_DRV_OPEN_DECLINED; - /* If path isn't /session, then they typoed, so tell them correct = path */ if (conn->uri->path =3D=3D NULL || STRNEQ(conn->uri->path, "/sessi= on")) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1268,6 +1262,7 @@ static virHypervisorDriver vmwareHypervisorDriver =3D= { =20 static virConnectDriver vmwareConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "vmwareplayer", "vmwarews", "vmwaref= usion", NULL }, .hypervisorDriver =3D &vmwareHypervisorDriver, }; =20 diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 8842056ea4..f3047cad6c 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -361,19 +361,6 @@ vzConnectOpen(virConnectPtr conn, if (!conn->uri) return VIR_DRV_OPEN_DECLINED; =20 - if (!conn->uri->scheme) - return VIR_DRV_OPEN_DECLINED; - - if (STRNEQ(conn->uri->scheme, "vz") && - STRNEQ(conn->uri->scheme, "parallels")) - return VIR_DRV_OPEN_DECLINED; - - if (STREQ(conn->uri->scheme, "vz") && STRNEQ(conn->driver->name, "vz")) - return VIR_DRV_OPEN_DECLINED; - - if (STREQ(conn->uri->scheme, "parallels") && STRNEQ(conn->driver->name= , "Parallels")) - return VIR_DRV_OPEN_DECLINED; - /* From this point on, the connection is for us. */ if (STRNEQ_NULLABLE(conn->uri->path, "/system")) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -4140,6 +4127,7 @@ static virHypervisorDriver vzHypervisorDriver =3D { =20 static virConnectDriver vzConnectDriver =3D { .localOnly =3D true, + .uriSchemes =3D (const char *[]){ "vz", NULL }, .hypervisorDriver =3D &vzHypervisorDriver, }; =20 @@ -4209,6 +4197,7 @@ vzRegister(void) parallelsHypervisorDriver.name =3D "Parallels"; parallelsConnectDriver =3D vzConnectDriver; parallelsConnectDriver.hypervisorDriver =3D ¶llelsHypervisorDriver; + parallelsConnectDriver.uriSchemes =3D (const char *[]){ "parallels", N= ULL }, if (virRegisterConnectDriver(¶llelsConnectDriver, true) < 0) return -1; =20 diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index fb462cd3a1..86f9e7706d 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -146,10 +146,8 @@ xenapiConnectOpen(virConnectPtr conn, virConnectAuthPt= r auth, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL || conn->uri->scheme =3D=3D NULL || - STRCASENEQ(conn->uri->scheme, "XenAPI")) { + if (conn->uri =3D=3D NULL) return VIR_DRV_OPEN_DECLINED; - } =20 if (conn->uri->server =3D=3D NULL) { xenapiSessionErrorHandler(conn, VIR_ERR_INVALID_ARG, @@ -2075,6 +2073,7 @@ static virHypervisorDriver xenapiHypervisorDriver =3D= { =20 =20 static virConnectDriver xenapiConnectDriver =3D { + .uriSchemes =3D (const char *[]){ "xenapi", NULL }, .hypervisorDriver =3D &xenapiHypervisorDriver, }; =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 02:25:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523288775927996.3909796338608; Mon, 9 Apr 2018 08:46:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 81F68C047B60; Mon, 9 Apr 2018 15:46:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B1005D9CD; Mon, 9 Apr 2018 15:46:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F1DCD4CAA7; Mon, 9 Apr 2018 15:46:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w39Fjxi5032419 for ; Mon, 9 Apr 2018 11:45:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1289F2024CA8; Mon, 9 Apr 2018 15:45:59 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D5EA2024CA7; Mon, 9 Apr 2018 15:45:58 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 9 Apr 2018 16:45:49 +0100 Message-Id: <20180409154551.22604-7-berrange@redhat.com> In-Reply-To: <20180409154551.22604-1-berrange@redhat.com> References: <20180409154551.22604-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/8] driver: ensure NULL URI isn't passed to drivers with whitelisted URIs X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 09 Apr 2018 15:46:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Ensuring that we don't call the virDrvConnectOpen method with a NULL URI means that the drivers can drop various checks for NULL URIs. These were not needed anymore since the probe functionality was split Signed-off-by: Daniel P. Berrang=C3=A9 --- src/bhyve/bhyve_driver.c | 26 +++++++---------- src/esx/esx_driver.c | 4 --- src/hyperv/hyperv_driver.c | 4 --- src/interface/interface_backend_netcf.c | 40 +++++++++++-------------- src/interface/interface_backend_udev.c | 40 +++++++++++-------------- src/libvirt.c | 6 +++- src/libxl/libxl_driver.c | 34 ++++++++++----------- src/lxc/lxc_driver.c | 33 +++++++++------------ src/network/bridge_driver.c | 40 +++++++++++-------------- src/node_device/node_device_driver.c | 40 +++++++++++-------------- src/nwfilter/nwfilter_driver.c | 26 +++++++---------- src/openvz/openvz_driver.c | 38 +++++++++++------------- src/phyp/phyp_driver.c | 3 -- src/qemu/qemu_driver.c | 52 +++++++++++++++--------------= ---- src/secret/secret_driver.c | 40 +++++++++++-------------- src/storage/storage_driver.c | 40 +++++++++++-------------- src/test/test_driver.c | 4 --- src/uml/uml_driver.c | 44 +++++++++++++--------------- src/vbox/vbox_common.c | 3 -- src/vbox/vbox_driver.c | 3 -- src/vmware/vmware_driver.c | 17 ++++------- src/vz/vz_driver.c | 3 -- src/xenapi/xenapi_driver.c | 3 -- 23 files changed, 224 insertions(+), 319 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 21754dfc10..7d6439d79d 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -199,21 +199,17 @@ bhyveConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) { - return VIR_DRV_OPEN_DECLINED; - } else { - if (STRNEQ_NULLABLE(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected bhyve URI path '%s', try bhyve://= /system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - - if (bhyve_driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("bhyve state driver is not active")); - return VIR_DRV_OPEN_ERROR; - } + if (STRNEQ_NULLABLE(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected bhyve URI path '%s', try bhyve:///sy= stem"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + + if (bhyve_driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("bhyve state driver is not active")); + return VIR_DRV_OPEN_ERROR; } =20 if (virConnectOpenEnsureACL(conn) < 0) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 9b6944ba59..335d9a970d 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -851,10 +851,6 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr a= uth, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Decline if the URI is NULL or the scheme is NULL */ - if (!conn->uri) - return VIR_DRV_OPEN_DECLINED; - if (STRCASENEQ(conn->uri->scheme, "vpx") && conn->uri->path && STRNEQ(conn->uri->path, "/")) { VIR_WARN("Ignoring unexpected path '%s' for non-vpx scheme '%s'", diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 4ad8855dcc..d02c0ac373 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -128,10 +128,6 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPt= r auth, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Decline if the URI is NULL or the scheme is NULL */ - if (conn->uri =3D=3D NULL) - return VIR_DRV_OPEN_DECLINED; - /* Require server part */ if (conn->uri->server =3D=3D NULL) { virReportError(VIR_ERR_INVALID_ARG, "%s", diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interf= ace_backend_netcf.c index ff3443c8e6..cc2402febb 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -159,31 +159,25 @@ netcfConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ - return VIR_DRV_OPEN_DECLINED; - } else { - if (driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("interface state driver is not active")); + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("interface state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected interface URI path '%s', try inte= rface:///system"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } - - if (driver->privileged) { - if (STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected interface URI path '%s', try = interface:///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected interface URI path '%s', try = interface:///session"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected interface URI path '%s', try inte= rface:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } } =20 diff --git a/src/interface/interface_backend_udev.c b/src/interface/interfa= ce_backend_udev.c index 743aafd8ba..4b975ae4b4 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -1203,31 +1203,25 @@ udevConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ - return VIR_DRV_OPEN_DECLINED; - } else { - if (driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("interface state driver is not active")); + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("interface state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected interface URI path '%s', try inte= rface:///system"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } - - if (driver->privileged) { - if (STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected interface URI path '%s', try = interface:///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected interface URI path '%s', try = interface:///session"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected interface URI path '%s', try inte= rface:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } } =20 diff --git a/src/libvirt.c b/src/libvirt.c index cc1387341a..30345af10d 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1074,9 +1074,13 @@ virConnectOpenInternal(const char *name, } =20 /* Filter drivers based on declared URI schemes */ - if (virConnectDriverTab[i]->uriSchemes && ret->uri) { + if (virConnectDriverTab[i]->uriSchemes) { bool matchScheme =3D false; size_t s; + if (!ret->uri) { + VIR_DEBUG("No URI, skipping driver with URI whitelist"); + continue; + } if (!ret->uri->scheme) { VIR_DEBUG("No URI scheme, skipping driver with URI whiteli= st"); continue; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 872790e743..45d0c99902 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -845,26 +845,22 @@ libxlConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) { - return VIR_DRV_OPEN_DECLINED; - } else { - /* Error if xen or libxl scheme specified but driver not started. = */ - if (libxl_driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("libxenlight state driver is not active")); - return VIR_DRV_OPEN_ERROR; - } + /* Error if xen or libxl scheme specified but driver not started. */ + if (libxl_driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("libxenlight state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } =20 - /* /session isn't supported in libxenlight */ - if (conn->uri->path && - STRNEQ(conn->uri->path, "") && - STRNEQ(conn->uri->path, "/") && - STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected Xen URI path '%s', try xen:///sys= tem"), - NULLSTR(conn->uri->path)); - return VIR_DRV_OPEN_ERROR; - } + /* /session isn't supported in libxenlight */ + if (conn->uri->path && + STRNEQ(conn->uri->path, "") && + STRNEQ(conn->uri->path, "/") && + STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected Xen URI path '%s', try xen:///system"= ), + NULLSTR(conn->uri->path)); + return VIR_DRV_OPEN_ERROR; } =20 if (virConnectOpenEnsureACL(conn) < 0) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 8b01abf75f..2079dd0704 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -169,26 +169,21 @@ static virDrvOpenStatus lxcConnectOpen(virConnectPtr = conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - return VIR_DRV_OPEN_DECLINED; - } else { - /* If path isn't '/' then they typoed, tell them correct path */ - if (conn->uri->path !=3D NULL && - STRNEQ(conn->uri->path, "/") && - STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected LXC URI path '%s', try lxc:///sys= tem"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + /* If path isn't '/' then they typoed, tell them correct path */ + if (conn->uri->path !=3D NULL && + STRNEQ(conn->uri->path, "/") && + STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected LXC URI path '%s', try lxc:///system"= ), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } =20 - /* URI was good, but driver isn't active */ - if (lxc_driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("lxc state driver is not active")); - return VIR_DRV_OPEN_ERROR; - } + /* URI was good, but driver isn't active */ + if (lxc_driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("lxc state driver is not active")); + return VIR_DRV_OPEN_ERROR; } =20 if (virConnectOpenEnsureACL(conn) < 0) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 98754d4471..2e9191f75d 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -878,31 +878,25 @@ networkConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ - return VIR_DRV_OPEN_DECLINED; - } else { - if (network_driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("network state driver is not active")); + if (network_driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("network state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (network_driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected network URI path '%s', try networ= k:///system"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } - - if (network_driver->privileged) { - if (STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected network URI path '%s', try ne= twork:///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected network URI path '%s', try ne= twork:///session"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected network URI path '%s', try networ= k:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } } =20 diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index a3e3d76dfc..61afa1f8eb 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -54,31 +54,25 @@ nodeConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ - return VIR_DRV_OPEN_DECLINED; - } else { - if (driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("nodedev state driver is not active")); + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("nodedev state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected nodedev URI path '%s', try nodede= v:///system"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } - - if (driver->privileged) { - if (STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected nodedev URI path '%s', try no= dedev:///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected nodedev URI path '%s', try no= dedev:///session"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected nodedev URI path '%s', try nodede= v:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } } =20 diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 76289265a2..542de03596 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -371,23 +371,17 @@ nwfilterConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ - return VIR_DRV_OPEN_DECLINED; - } else { - if (driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("nwfilter state driver is not active")); - return VIR_DRV_OPEN_ERROR; - } + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("nwfilter state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } =20 - if (STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected nwfilter URI path '%s', try nwfil= ter:///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected nwfilter URI path '%s', try nwfilter:= ///system"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } =20 if (virConnectOpenEnsureACL(conn) < 0) diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 3eab3e47df..33893ac009 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1443,29 +1443,25 @@ static virDrvOpenStatus openvzConnectOpen(virConnec= tPtr conn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) { - return VIR_DRV_OPEN_DECLINED; - } else { - /* If path isn't /system, then they typoed, so tell them correct p= ath */ - if (conn->uri->path =3D=3D NULL || - STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected OpenVZ URI path '%s', try openvz:= ///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + /* If path isn't /system, then they typoed, so tell them correct path = */ + if (conn->uri->path =3D=3D NULL || + STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected OpenVZ URI path '%s', try openvz:///s= ystem"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } =20 - if (!virFileExists("/proc/vz")) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("OpenVZ control file /proc/vz does not exist"= )); - return VIR_DRV_OPEN_ERROR; - } + if (!virFileExists("/proc/vz")) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("OpenVZ control file /proc/vz does not exist")); + return VIR_DRV_OPEN_ERROR; + } =20 - if (access("/proc/vz", W_OK) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("OpenVZ control file /proc/vz is not accessib= le")); - return VIR_DRV_OPEN_ERROR; - } + if (access("/proc/vz", W_OK) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("OpenVZ control file /proc/vz is not accessible")= ); + return VIR_DRV_OPEN_ERROR; } =20 /* We now know the URI is definitely for this driver, so beyond diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index ddbd9144bc..55d459df5c 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1141,9 +1141,6 @@ phypConnectOpen(virConnectPtr conn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (!conn || !conn->uri) - return VIR_DRV_OPEN_DECLINED; - if (conn->uri->server =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing server name in phyp:// URI")); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8a6d3f9af0..e677bf13b5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1143,38 +1143,34 @@ static virDrvOpenStatus qemuConnectOpen(virConnectP= tr conn, virDrvOpenStatus ret =3D VIR_DRV_OPEN_ERROR; virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) { - return VIR_DRV_OPEN_DECLINED; - } else { - if (qemu_driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("qemu state driver is not active")); - goto cleanup; - } + if (qemu_driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("qemu state driver is not active")); + goto cleanup; + } + + cfg =3D virQEMUDriverGetConfig(qemu_driver); + if (conn->uri->path =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no QEMU URI path given, try %s"), + cfg->uri); + goto cleanup; + } =20 - cfg =3D virQEMUDriverGetConfig(qemu_driver); - if (conn->uri->path =3D=3D NULL) { + if (virQEMUDriverIsPrivileged(qemu_driver)) { + if (STRNEQ(conn->uri->path, "/system") && + STRNEQ(conn->uri->path, "/session")) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("no QEMU URI path given, try %s"), - cfg->uri); + _("unexpected QEMU URI path '%s', try qemu:///s= ystem"), + conn->uri->path); goto cleanup; } - - if (virQEMUDriverIsPrivileged(qemu_driver)) { - if (STRNEQ(conn->uri->path, "/system") && - STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected QEMU URI path '%s', try qemu:= ///system"), - conn->uri->path); - goto cleanup; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected QEMU URI path '%s', try qemu:= ///session"), - conn->uri->path); - goto cleanup; - } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected QEMU URI path '%s', try qemu:///s= ession"), + conn->uri->path); + goto cleanup; } } =20 diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index aedfa10dcc..02fcaece35 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -524,31 +524,25 @@ secretConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ - return VIR_DRV_OPEN_DECLINED; - } else { - if (driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("secret state driver is not active")); + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("secret state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected secret URI path '%s', try secret:= ///system"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } - - if (driver->privileged) { - if (STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected secret URI path '%s', try sec= ret:///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected secret URI path '%s', try sec= ret:///session"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected secret URI path '%s', try secret:= ///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } } =20 diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 1a81733842..6104276730 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -384,31 +384,25 @@ storageConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - /* Verify uri was specified */ - if (conn->uri =3D=3D NULL) { - /* Only hypervisor drivers are permitted to auto-open on NULL uri = */ - return VIR_DRV_OPEN_DECLINED; - } else { - if (driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("storage state driver is not active")); + if (driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("storage state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + + if (driver->privileged) { + if (STRNEQ(conn->uri->path, "/system")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected storage URI path '%s', try storag= e:///system"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } - - if (driver->privileged) { - if (STRNEQ(conn->uri->path, "/system")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected storage URI path '%s', try st= orage:///system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected storage URI path '%s', try st= orage:///session"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected storage URI path '%s', try storag= e:///session"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } } =20 diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 7f9c7f751e..56d496a849 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1454,10 +1454,6 @@ testConnectOpen(virConnectPtr conn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (!conn->uri) - return VIR_DRV_OPEN_DECLINED; - - /* From this point on, the connection is for us. */ if (!conn->uri->path || conn->uri->path[0] =3D=3D '\0' || (conn->uri->path[0] =3D=3D '/' && conn->uri->path[1] =3D=3D '\0= ')) { diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 2315cd4d15..ac168ce77b 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1203,35 +1203,31 @@ static virDrvOpenStatus umlConnectOpen(virConnectPt= r conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) { - return VIR_DRV_OPEN_DECLINED; - } else { - /* Check path and tell them correct path if they made a mistake */ - if (uml_driver->privileged) { - if (STRNEQ(conn->uri->path, "/system") && - STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected UML URI path '%s', try uml://= /system"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected UML URI path '%s', try uml://= /session"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } + /* Check path and tell them correct path if they made a mistake */ + if (uml_driver->privileged) { + if (STRNEQ(conn->uri->path, "/system") && + STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected UML URI path '%s', try uml:///sys= tem"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; } - - /* URI was good, but driver isn't active */ - if (uml_driver =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("uml state driver is not active")); + } else { + if (STRNEQ(conn->uri->path, "/session")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected UML URI path '%s', try uml:///ses= sion"), + conn->uri->path); return VIR_DRV_OPEN_ERROR; } } =20 + /* URI was good, but driver isn't active */ + if (uml_driver =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("uml state driver is not active")); + return VIR_DRV_OPEN_ERROR; + } + if (virConnectOpenEnsureACL(conn) < 0) return VIR_DRV_OPEN_ERROR; =20 diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 4c4c80d45b..05cf9ad0de 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -517,9 +517,6 @@ vboxConnectOpen(virConnectPtr conn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) - return VIR_DRV_OPEN_DECLINED; - if (conn->uri->path =3D=3D NULL || STREQ(conn->uri->path, "")) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no VirtualBox driver path specified (try vbox://= /session)")); diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c index 395fa8e3d6..9e95ab01c5 100644 --- a/src/vbox/vbox_driver.c +++ b/src/vbox/vbox_driver.c @@ -58,9 +58,6 @@ static virDrvOpenStatus dummyConnectOpen(virConnectPtr co= nn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) - return VIR_DRV_OPEN_DECLINED; - if (conn->uri->path =3D=3D NULL || STREQ(conn->uri->path, "")) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no VirtualBox driver path specified (try vbox://= /session)")); diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 6118e6fa13..de3708aab3 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -130,17 +130,12 @@ vmwareConnectOpen(virConnectPtr conn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) { - /* @TODO accept */ - return VIR_DRV_OPEN_DECLINED; - } else { - /* If path isn't /session, then they typoed, so tell them correct = path */ - if (conn->uri->path =3D=3D NULL || STRNEQ(conn->uri->path, "/sessi= on")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected VMware URI path '%s', try vmwarep= layer:///session, vmwarews:///session or vmwarefusion:///session"), - NULLSTR(conn->uri->path)); - return VIR_DRV_OPEN_ERROR; - } + /* If path isn't /session, then they typoed, so tell them correct path= */ + if (conn->uri->path =3D=3D NULL || STRNEQ(conn->uri->path, "/session")= ) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected VMware URI path '%s', try vmwareplaye= r:///session, vmwarews:///session or vmwarefusion:///session"), + NULLSTR(conn->uri->path)); + return VIR_DRV_OPEN_ERROR; } =20 /* We now know the URI is definitely for this driver, so beyond diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index f3047cad6c..5867f1c911 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -358,9 +358,6 @@ vzConnectOpen(virConnectPtr conn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (!conn->uri) - return VIR_DRV_OPEN_DECLINED; - /* From this point on, the connection is for us. */ if (STRNEQ_NULLABLE(conn->uri->path, "/system")) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 86f9e7706d..42b305d316 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -146,9 +146,6 @@ xenapiConnectOpen(virConnectPtr conn, virConnectAuthPtr= auth, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri =3D=3D NULL) - return VIR_DRV_OPEN_DECLINED; - if (conn->uri->server =3D=3D NULL) { xenapiSessionErrorHandler(conn, VIR_ERR_INVALID_ARG, _("Server name not in URI")); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 02:25:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523288778906940.3416656033714; Mon, 9 Apr 2018 08:46:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A53BC9B426; Mon, 9 Apr 2018 15:46:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6594161783; Mon, 9 Apr 2018 15:46:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1A7B5180BAE6; Mon, 9 Apr 2018 15:46:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w39Fk03Q032433 for ; Mon, 9 Apr 2018 11:46:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id F12BC2024CA8; Mon, 9 Apr 2018 15:45:59 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A2A92024CA7; Mon, 9 Apr 2018 15:45:59 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 9 Apr 2018 16:45:50 +0100 Message-Id: <20180409154551.22604-8-berrange@redhat.com> In-Reply-To: <20180409154551.22604-1-berrange@redhat.com> References: <20180409154551.22604-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/8] driver: enforce a non-NULL URI scheme X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 09 Apr 2018 15:46:18 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Now that the legacy Xen driver has been dropped, we no longer need to support URIs such as "/path/to/xend/socket", and so can mandate that a URI scheme must always be present. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/libvirt.c | 15 ++++++---- src/remote/remote_driver.c | 74 ++++++++++++++++++++----------------------= ---- 2 files changed, 41 insertions(+), 48 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 30345af10d..600beaa4d5 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -905,7 +905,7 @@ virConnectGetDefaultURI(virConfPtr conf, static int virConnectCheckURIMissingSlash(const char *uristr, virURIPtr uri) { - if (!uri->scheme || !uri->path || !uri->server) + if (!uri->path || !uri->server) return 0; =20 /* To avoid false positives, only check drivers that mandate @@ -1018,6 +1018,13 @@ virConnectOpenInternal(const char *name, NULLSTR(ret->uri->user), ret->uri->port, NULLSTR(ret->uri->path)); =20 + if (ret->uri->scheme =3D=3D NULL) { + virReportError(VIR_ERR_NO_CONNECT, + _("URI '%s' does not include a driver name"), + name); + goto failed; + } + if (virConnectCheckURIMissingSlash(uristr, ret->uri) < 0) { goto failed; @@ -1038,7 +1045,7 @@ virConnectOpenInternal(const char *name, * not being able to connect to libvirtd or not being able to find * certificates. */ if (STREQ(virConnectDriverTab[i]->hypervisorDriver->name, "remote"= ) && - ret->uri !=3D NULL && ret->uri->scheme !=3D NULL && + ret->uri !=3D NULL && ( #ifndef WITH_PHYP STRCASEEQ(ret->uri->scheme, "phyp") || @@ -1081,10 +1088,6 @@ virConnectOpenInternal(const char *name, VIR_DEBUG("No URI, skipping driver with URI whitelist"); continue; } - if (!ret->uri->scheme) { - VIR_DEBUG("No URI scheme, skipping driver with URI whiteli= st"); - continue; - } VIR_DEBUG("Checking for supported URI schemes"); for (s =3D 0; virConnectDriverTab[i]->uriSchemes[s] !=3D NULL;= s++) { if (STREQ(ret->uri->scheme, virConnectDriverTab[i]->uriSch= emes[s])) { diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 901a2ebfbd..ce2ea27cd8 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -771,51 +771,41 @@ doRemoteOpen(virConnectPtr conn, * URIs we don't care about */ =20 if (conn->uri) { - if (!conn->uri->scheme) { - /* This is the ///var/lib/xen/xend-socket local path style */ - if (!conn->uri->path) - return VIR_DRV_OPEN_DECLINED; - if (conn->uri->path[0] !=3D '/') - return VIR_DRV_OPEN_DECLINED; - - transport =3D trans_unix; - } else { - transport_str =3D get_transport_from_scheme(conn->uri->scheme); + transport_str =3D get_transport_from_scheme(conn->uri->scheme); =20 - if (!transport_str) { - if (conn->uri->server) - transport =3D trans_tls; - else - transport =3D trans_unix; - } else { - if (STRCASEEQ(transport_str, "tls")) { - transport =3D trans_tls; - } else if (STRCASEEQ(transport_str, "unix")) { - if (conn->uri->server) { - virReportError(VIR_ERR_INVALID_ARG, - _("using unix socket and remote " - "server '%s' is not supported."), - conn->uri->server); - return VIR_DRV_OPEN_ERROR; - } else { - transport =3D trans_unix; - } - } else if (STRCASEEQ(transport_str, "ssh")) { - transport =3D trans_ssh; - } else if (STRCASEEQ(transport_str, "libssh2")) { - transport =3D trans_libssh2; - } else if (STRCASEEQ(transport_str, "ext")) { - transport =3D trans_ext; - } else if (STRCASEEQ(transport_str, "tcp")) { - transport =3D trans_tcp; - } else if (STRCASEEQ(transport_str, "libssh")) { - transport =3D trans_libssh; - } else { - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("remote_open: transport in URL not re= cognised " - "(should be tls|unix|ssh|ext|tcp|libs= sh2)")); + if (!transport_str) { + if (conn->uri->server) + transport =3D trans_tls; + else + transport =3D trans_unix; + } else { + if (STRCASEEQ(transport_str, "tls")) { + transport =3D trans_tls; + } else if (STRCASEEQ(transport_str, "unix")) { + if (conn->uri->server) { + virReportError(VIR_ERR_INVALID_ARG, + _("using unix socket and remote " + "server '%s' is not supported."), + conn->uri->server); return VIR_DRV_OPEN_ERROR; + } else { + transport =3D trans_unix; } + } else if (STRCASEEQ(transport_str, "ssh")) { + transport =3D trans_ssh; + } else if (STRCASEEQ(transport_str, "libssh2")) { + transport =3D trans_libssh2; + } else if (STRCASEEQ(transport_str, "ext")) { + transport =3D trans_ext; + } else if (STRCASEEQ(transport_str, "tcp")) { + transport =3D trans_tcp; + } else if (STRCASEEQ(transport_str, "libssh")) { + transport =3D trans_libssh; + } else { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("remote_open: transport in URL not recogn= ised " + "(should be tls|unix|ssh|ext|tcp|libssh2)= ")); + return VIR_DRV_OPEN_ERROR; } } } else { --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 02:25:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152328878281277.18483949555161; Mon, 9 Apr 2018 08:46:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 664EC9D427; Mon, 9 Apr 2018 15:46:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2842360930; Mon, 9 Apr 2018 15:46:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DD7F04CAAF; Mon, 9 Apr 2018 15:46:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w39Fk1wr032446 for ; Mon, 9 Apr 2018 11:46:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 03492202699A; Mon, 9 Apr 2018 15:46:01 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FEC62024CA7; Mon, 9 Apr 2018 15:46:00 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 9 Apr 2018 16:45:51 +0100 Message-Id: <20180409154551.22604-9-berrange@redhat.com> In-Reply-To: <20180409154551.22604-1-berrange@redhat.com> References: <20180409154551.22604-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 8/8] driver: ensure URI path is non-NULL to simplify drivers X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 09 Apr 2018 15:46:22 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Avoid the need for the drivers to explicitly check for a NULL path by making sure it is at least the empty string. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/bhyve/bhyve_driver.c | 2 +- src/esx/esx_driver.c | 2 +- src/libvirt.c | 8 +++++++- src/libxl/libxl_driver.c | 5 ++--- src/lxc/lxc_driver.c | 3 +-- src/openvz/openvz_driver.c | 3 +-- src/phyp/phyp_driver.c | 2 +- src/qemu/qemu_driver.c | 6 ------ src/test/test_driver.c | 5 ++--- src/vbox/vbox_common.c | 6 ------ src/vbox/vbox_driver.c | 6 ------ src/vmware/vmware_driver.c | 2 +- src/vz/vz_driver.c | 2 +- 13 files changed, 18 insertions(+), 34 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 7d6439d79d..8870756ac5 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -199,7 +199,7 @@ bhyveConnectOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (STRNEQ_NULLABLE(conn->uri->path, "/system")) { + if (STRNEQ(conn->uri->path, "/system")) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unexpected bhyve URI path '%s', try bhyve:///sy= stem"), conn->uri->path); diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 335d9a970d..c682c800ca 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -852,7 +852,7 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr au= th, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 if (STRCASENEQ(conn->uri->scheme, "vpx") && - conn->uri->path && STRNEQ(conn->uri->path, "/")) { + STRNEQ(conn->uri->path, "/")) { VIR_WARN("Ignoring unexpected path '%s' for non-vpx scheme '%s'", conn->uri->path, conn->uri->scheme); } diff --git a/src/libvirt.c b/src/libvirt.c index 600beaa4d5..0b6bd6666e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1007,6 +1007,12 @@ virConnectOpenInternal(const char *name, goto failed; } =20 + /* Avoid need for drivers to worry about NULLs, as + * no one needs to distinguish "" vs NULL */ + if (ret->uri->path =3D=3D NULL && + VIR_STRDUP(ret->uri->path, "") < 0) + goto failed; + VIR_DEBUG("Split \"%s\" to URI components:\n" " scheme %s\n" " server %s\n" @@ -1016,7 +1022,7 @@ virConnectOpenInternal(const char *name, uristr, NULLSTR(ret->uri->scheme), NULLSTR(ret->uri->server), NULLSTR(ret->uri->user), ret->uri->port, - NULLSTR(ret->uri->path)); + ret->uri->path); =20 if (ret->uri->scheme =3D=3D NULL) { virReportError(VIR_ERR_NO_CONNECT, diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 45d0c99902..8808da8db1 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -853,13 +853,12 @@ libxlConnectOpen(virConnectPtr conn, } =20 /* /session isn't supported in libxenlight */ - if (conn->uri->path && - STRNEQ(conn->uri->path, "") && + if (STRNEQ(conn->uri->path, "") && STRNEQ(conn->uri->path, "/") && STRNEQ(conn->uri->path, "/system")) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected Xen URI path '%s', try xen:///system"= ), - NULLSTR(conn->uri->path)); + conn->uri->path); return VIR_DRV_OPEN_ERROR; } =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 2079dd0704..f6041aab43 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -170,8 +170,7 @@ static virDrvOpenStatus lxcConnectOpen(virConnectPtr co= nn, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 /* If path isn't '/' then they typoed, tell them correct path */ - if (conn->uri->path !=3D NULL && - STRNEQ(conn->uri->path, "/") && + if (STRNEQ(conn->uri->path, "/") && STRNEQ(conn->uri->path, "/system")) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unexpected LXC URI path '%s', try lxc:///system"= ), diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 33893ac009..5a1446ddda 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1444,8 +1444,7 @@ static virDrvOpenStatus openvzConnectOpen(virConnectP= tr conn, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 /* If path isn't /system, then they typoed, so tell them correct path = */ - if (conn->uri->path =3D=3D NULL || - STRNEQ(conn->uri->path, "/system")) { + if (STRNEQ(conn->uri->path, "/system")) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected OpenVZ URI path '%s', try openvz:///s= ystem"), conn->uri->path); diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 55d459df5c..ed3d9feb58 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1155,7 +1155,7 @@ phypConnectOpen(virConnectPtr conn, if (VIR_ALLOC(uuid_table) < 0) goto failure; =20 - if (conn->uri->path) { + if (conn->uri->path[0] !=3D '\0') { /* need to shift one byte in order to remove the first "/" of URI = component */ if (VIR_STRDUP(managed_system, conn->uri->path + (conn->uri->path[0] =3D=3D '/')) = < 0) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e677bf13b5..97d72f6fe8 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1150,12 +1150,6 @@ static virDrvOpenStatus qemuConnectOpen(virConnectPt= r conn, } =20 cfg =3D virQEMUDriverGetConfig(qemu_driver); - if (conn->uri->path =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("no QEMU URI path given, try %s"), - cfg->uri); - goto cleanup; - } =20 if (virQEMUDriverIsPrivileged(qemu_driver)) { if (STRNEQ(conn->uri->path, "/system") && diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 56d496a849..eec7a82924 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1454,9 +1454,8 @@ testConnectOpen(virConnectPtr conn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (!conn->uri->path - || conn->uri->path[0] =3D=3D '\0' - || (conn->uri->path[0] =3D=3D '/' && conn->uri->path[1] =3D=3D '\0= ')) { + if (conn->uri->path[0] =3D=3D '\0' || + (conn->uri->path[0] =3D=3D '/' && conn->uri->path[1] =3D=3D '\0'))= { virReportError(VIR_ERR_INVALID_ARG, "%s", _("testOpen: supply a path or use test:///def= ault")); return VIR_DRV_OPEN_ERROR; diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 05cf9ad0de..ee94931918 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -517,12 +517,6 @@ vboxConnectOpen(virConnectPtr conn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri->path =3D=3D NULL || STREQ(conn->uri->path, "")) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("no VirtualBox driver path specified (try vbox://= /session)")); - return VIR_DRV_OPEN_ERROR; - } - if (uid !=3D 0) { if (STRNEQ(conn->uri->path, "/session")) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c index 9e95ab01c5..1f31fa28df 100644 --- a/src/vbox/vbox_driver.c +++ b/src/vbox/vbox_driver.c @@ -58,12 +58,6 @@ static virDrvOpenStatus dummyConnectOpen(virConnectPtr c= onn, =20 virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 - if (conn->uri->path =3D=3D NULL || STREQ(conn->uri->path, "")) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("no VirtualBox driver path specified (try vbox://= /session)")); - return VIR_DRV_OPEN_ERROR; - } - if (uid !=3D 0) { if (STRNEQ(conn->uri->path, "/session")) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index de3708aab3..c8a3151faf 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -131,7 +131,7 @@ vmwareConnectOpen(virConnectPtr conn, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 /* If path isn't /session, then they typoed, so tell them correct path= */ - if (conn->uri->path =3D=3D NULL || STRNEQ(conn->uri->path, "/session")= ) { + if (STRNEQ(conn->uri->path, "/session")) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected VMware URI path '%s', try vmwareplaye= r:///session, vmwarews:///session or vmwarefusion:///session"), NULLSTR(conn->uri->path)); diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 5867f1c911..e51d968f28 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -359,7 +359,7 @@ vzConnectOpen(virConnectPtr conn, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 /* From this point on, the connection is for us. */ - if (STRNEQ_NULLABLE(conn->uri->path, "/system")) { + if (STRNEQ(conn->uri->path, "/system")) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unexpected Virtuozzo URI path '%s', try vz:///sy= stem"), conn->uri->path); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list