From nobody Wed May 14 11:30:06 2025 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