mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
lxc: allow use of lxc:///system URI as preferred format
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é <berrange@redhat.com>
This commit is contained in:
parent
a8ea89d258
commit
a2fd657b86
@ -308,8 +308,8 @@ unit file specifies how systemd will start the libvirt LXC container
|
|||||||
Description=My little container
|
Description=My little container
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/usr/bin/virsh -c lxc:/// start --pass-fds 3 mycontainer
|
ExecStart=/usr/bin/virsh -c lxc:///system start --pass-fds 3 mycontainer
|
||||||
ExecStop=/usr/bin/virsh -c lxc:/// destroy mycontainer
|
ExecStop=/usr/bin/virsh -c lxc:///system destroy mycontainer
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
KillMode=none
|
KillMode=none
|
||||||
@ -621,9 +621,9 @@ The use of namespace passthrough requires libvirt >= 1.2.19
|
|||||||
As with any libvirt virtualization driver, LXC containers can be
|
As with any libvirt virtualization driver, LXC containers can be
|
||||||
managed via a wide variety of libvirt based tools. At the lowest
|
managed via a wide variety of libvirt based tools. At the lowest
|
||||||
level the <code>virsh</code> command can be used to perform many
|
level the <code>virsh</code> command can be used to perform many
|
||||||
tasks, by passing the <code>-c lxc:///</code> argument. As an
|
tasks, by passing the <code>-c lxc:///system</code> argument. As an
|
||||||
alternative to repeating the URI with every command, the <code>LIBVIRT_DEFAULT_URI</code>
|
alternative to repeating the URI with every command, the <code>LIBVIRT_DEFAULT_URI</code>
|
||||||
environment variable can be set to <code>lxc:///</code>. The
|
environment variable can be set to <code>lxc:///system</code>. The
|
||||||
examples that follow outline some common operations with virsh
|
examples that follow outline some common operations with virsh
|
||||||
and LXC. For further details about usage of virsh consult its
|
and LXC. For further details about usage of virsh consult its
|
||||||
manual page.
|
manual page.
|
||||||
@ -637,7 +637,7 @@ document and loads it into libvirt, saving the configuration on disk
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
# virsh -c lxc:/// define myguest.xml
|
# virsh -c lxc:///system define myguest.xml
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a id="usageView">Viewing container configuration</a></h3>
|
<h3><a id="usageView">Viewing container configuration</a></h3>
|
||||||
@ -652,7 +652,7 @@ using the <code>--inactive</code> flag
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
# virsh -c lxc:/// dumpxml myguest
|
# virsh -c lxc:///system dumpxml myguest
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a id="usageStart">Starting containers</a></h3>
|
<h3><a id="usageStart">Starting containers</a></h3>
|
||||||
@ -663,7 +663,7 @@ container from a previously defined persistent configuration
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
# virsh -c lxc:/// start myguest
|
# virsh -c lxc:///system start myguest
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -673,7 +673,7 @@ by libvirt, using the <code>virsh create</code> command.
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
# virsh -c lxc:/// create myguest.xml
|
# virsh -c lxc:///system create myguest.xml
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
@ -689,7 +689,7 @@ to PID 1 inside the container.
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
# virsh -c lxc:/// shutdown myguest
|
# virsh -c lxc:///system shutdown myguest
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -698,7 +698,7 @@ request, it can be forcibly stopped using the <code>virsh destroy</code>
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
# virsh -c lxc:/// destroy myguest
|
# virsh -c lxc:///system destroy myguest
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
@ -714,7 +714,7 @@ to PID 1 inside the container.
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
# virsh -c lxc:/// reboot myguest
|
# virsh -c lxc:///system reboot myguest
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a id="usageDelete">Undefining (deleting) a container configuration</a></h3>
|
<h3><a id="usageDelete">Undefining (deleting) a container configuration</a></h3>
|
||||||
@ -726,7 +726,7 @@ running, this will turn it into a "transient" guest.
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
# virsh -c lxc:/// undefine myguest
|
# virsh -c lxc:///system undefine myguest
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a id="usageConnect">Connecting to a container console</a></h3>
|
<h3><a id="usageConnect">Connecting to a container console</a></h3>
|
||||||
@ -737,7 +737,7 @@ to the text console associated with a container.
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
# virsh -c lxc:/// console myguest
|
# virsh -c lxc:///system console myguest
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -749,7 +749,7 @@ as 'console0', 'console1', 'console2', etc.
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
# virsh -c lxc:/// console myguest --devname console1
|
# virsh -c lxc:///system console myguest --devname console1
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a id="usageEnter">Running commands in a container</a></h3>
|
<h3><a id="usageEnter">Running commands in a container</a></h3>
|
||||||
@ -761,7 +761,7 @@ and then execute an arbitrary command.
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
# virsh -c lxc:/// lxc-enter-namespace myguest -- /bin/ls -al /dev
|
# virsh -c lxc:///system lxc-enter-namespace myguest -- /bin/ls -al /dev
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a id="usageTop">Monitoring container utilization</a></h3>
|
<h3><a id="usageTop">Monitoring container utilization</a></h3>
|
||||||
@ -773,7 +773,7 @@ host
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
# virt-top -c lxc:///
|
# virt-top -c lxc:///system
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><a id="usageConvert">Converting LXC container configuration</a></h3>
|
<h3><a id="usageConvert">Converting LXC container configuration</a></h3>
|
||||||
@ -784,7 +784,7 @@ most of the LXC container configuration into a domain XML fragment
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
# 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
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
@ -123,5 +123,5 @@ if test -z "$mem_limit"; then
|
|||||||
echo "lxc.cgroup.memory.limit_in_bytes = $memory" >> "$conf_new"
|
echo "lxc.cgroup.memory.limit_in_bytes = $memory" >> "$conf_new"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
virsh -c lxc:/// domxml-from-native lxc-tools $conf_new
|
virsh -c lxc:///system domxml-from-native lxc-tools $conf_new
|
||||||
exit $?
|
exit $?
|
||||||
|
@ -164,7 +164,7 @@ static virDrvOpenStatus lxcConnectOpen(virConnectPtr conn,
|
|||||||
if (lxc_driver == NULL)
|
if (lxc_driver == NULL)
|
||||||
return VIR_DRV_OPEN_DECLINED;
|
return VIR_DRV_OPEN_DECLINED;
|
||||||
|
|
||||||
if (!(conn->uri = virURIParse("lxc:///")))
|
if (!(conn->uri = virURIParse("lxc:///system")))
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
} else {
|
} else {
|
||||||
if (conn->uri->scheme == NULL ||
|
if (conn->uri->scheme == NULL ||
|
||||||
@ -177,9 +177,10 @@ static virDrvOpenStatus lxcConnectOpen(virConnectPtr conn,
|
|||||||
|
|
||||||
/* If path isn't '/' then they typoed, tell them correct path */
|
/* If path isn't '/' then they typoed, tell them correct path */
|
||||||
if (conn->uri->path != NULL &&
|
if (conn->uri->path != NULL &&
|
||||||
STRNEQ(conn->uri->path, "/")) {
|
STRNEQ(conn->uri->path, "/") &&
|
||||||
|
STRNEQ(conn->uri->path, "/system")) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unexpected LXC URI path '%s', try lxc:///"),
|
_("Unexpected LXC URI path '%s', try lxc:///system"),
|
||||||
conn->uri->path);
|
conn->uri->path);
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ virLXCProcessReboot(virLXCDriverPtr driver,
|
|||||||
virObjectRef(conn);
|
virObjectRef(conn);
|
||||||
autodestroy = true;
|
autodestroy = true;
|
||||||
} else {
|
} else {
|
||||||
conn = virConnectOpen("lxc:///");
|
conn = virConnectOpen("lxc:///system");
|
||||||
/* Ignoring NULL conn which is mostly harmless here */
|
/* Ignoring NULL conn which is mostly harmless here */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1625,7 +1625,7 @@ virLXCProcessAutostartAll(virLXCDriverPtr driver)
|
|||||||
* to lookup the bridge associated with a virtual
|
* to lookup the bridge associated with a virtual
|
||||||
* network
|
* network
|
||||||
*/
|
*/
|
||||||
virConnectPtr conn = virConnectOpen("lxc:///");
|
virConnectPtr conn = virConnectOpen("lxc:///system");
|
||||||
/* Ignoring NULL conn which is mostly harmless here */
|
/* Ignoring NULL conn which is mostly harmless here */
|
||||||
|
|
||||||
struct virLXCProcessAutostartData data = { driver, conn };
|
struct virLXCProcessAutostartData data = { driver, conn };
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# URIs to check for running guests
|
# URIs to check for running guests
|
||||||
# example: URIS='default xen:///system vbox+tcp://host/system lxc:///'
|
# example: URIS='default xen:///system vbox+tcp://host/system lxc:///system'
|
||||||
#URIS=default
|
#URIS=default
|
||||||
|
|
||||||
# action taken on host boot
|
# action taken on host boot
|
||||||
|
@ -266,7 +266,7 @@ connect locally as root to the daemon supervising QEMU and KVM domains
|
|||||||
|
|
||||||
connect locally as a normal user to his own set of QEMU and KVM domains
|
connect locally as a normal user to his own set of QEMU and KVM domains
|
||||||
|
|
||||||
=item lxc:///
|
=item lxc:///system
|
||||||
|
|
||||||
connect to a local linux container
|
connect to a local linux container
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ main(int argc, char **argv)
|
|||||||
if (virConfGetValueBool(conf, "auto_shell", &autoshell) < 0)
|
if (virConfGetValueBool(conf, "auto_shell", &autoshell) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
conn = virConnectOpen("lxc:///");
|
conn = virConnectOpen("lxc:///system");
|
||||||
if (!conn)
|
if (!conn)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user