[libvirt] [PATCH] util: require command args to be non-NULL
by Daniel P. Berrangé
The virCommand APIs do not expect to be given a NULL value for an arg
name or value. Such a mistake can lead to execution of the wrong
command, as the NULL may prematurely terminate the list of args.
Detect this and report suitable error messages.
This identified a flaw in the storage test which was passing a NULL
instead of the volume path. This flaw was then validated by an incorrect
set of qemu-img args as expected data.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/util/vircommand.c | 10 ++++++++++
tests/storagevolxml2argvdata/qcow2-zerocapacity.argv | 2 +-
tests/storagevolxml2xmlin/vol-qcow2-zerocapacity.xml | 1 +
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 3559f4bafa..d965068369 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -1498,6 +1498,12 @@ virCommandAddArg(virCommandPtr cmd, const char *val)
if (!cmd || cmd->has_error)
return;
+ if (val == NULL) {
+ cmd->has_error = EINVAL;
+ abort();
+ return;
+ }
+
if (VIR_STRDUP_QUIET(arg, val) < 0) {
cmd->has_error = ENOMEM;
return;
@@ -1595,6 +1601,10 @@ virCommandAddArgFormat(virCommandPtr cmd, const char *format, ...)
void
virCommandAddArgPair(virCommandPtr cmd, const char *name, const char *val)
{
+ if (name == NULL || val == NULL) {
+ cmd->has_error = EINVAL;
+ return;
+ }
virCommandAddArgFormat(cmd, "%s=%s", name, val);
}
diff --git a/tests/storagevolxml2argvdata/qcow2-zerocapacity.argv b/tests/storagevolxml2argvdata/qcow2-zerocapacity.argv
index d83b08b342..45894931ae 100644
--- a/tests/storagevolxml2argvdata/qcow2-zerocapacity.argv
+++ b/tests/storagevolxml2argvdata/qcow2-zerocapacity.argv
@@ -1 +1 @@
-qemu-img create -f qcow2 -o compat=0.10 0K
+qemu-img create -f qcow2 -o compat=0.10 /var/lib/libvirt/images/OtherDemo.img 0K
diff --git a/tests/storagevolxml2xmlin/vol-qcow2-zerocapacity.xml b/tests/storagevolxml2xmlin/vol-qcow2-zerocapacity.xml
index 1d1e6deac0..027a73b4bf 100644
--- a/tests/storagevolxml2xmlin/vol-qcow2-zerocapacity.xml
+++ b/tests/storagevolxml2xmlin/vol-qcow2-zerocapacity.xml
@@ -1,6 +1,7 @@
<volume>
<name>OtherDemo.img</name>
<target>
+ <path>/var/lib/libvirt/images/OtherDemo.img</path>
<format type="qcow2"/>
</target>
<capacity>0</capacity>
--
2.19.2
5 years, 11 months
[libvirt] [PATCH v2] Drop UML driver
by Michal Privoznik
The driver is unmaintained, untested and severely broken for
quite some time now. Since nobody even reported any issue with it
let us drop it.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
diff to v2:
- don't drop UML from RNG schema nor config parser as suggested by Dan
configure.ac | 4 -
docs/aclpolkit.html.in | 4 -
docs/drivers.html.in | 1 -
docs/drvuml.html.in | 93 -
docs/formatcaps.html.in | 3 -
docs/formatdomain.html.in | 6 +-
docs/formatdomaincaps.html.in | 1 -
docs/formatnwfilter.html.in | 2 +-
docs/news.xml | 14 +
docs/schemas/capability.rng | 4 +-
docs/schemas/domaincommon.rng | 6 +-
include/libvirt/virterror.h | 2 +-
libvirt.spec.in | 65 +-
m4/virt-driver-uml.m4 | 54 -
mingw-libvirt.spec.in | 1 -
po/POTFILES | 2 -
src/Makefile.am | 1 -
src/README | 3 +-
src/locking/lock_driver.h | 2 +-
src/remote/Makefile.inc.am | 1 -
src/remote/libvirtd.uml.logrotate.in | 8 -
src/remote/remote_daemon.c | 4 -
src/uml/Makefile.inc.am | 48 -
src/uml/uml_conf.c | 481 -----
src/uml/uml_conf.h | 82 -
src/uml/uml_driver.c | 2835 --------------------------
src/uml/uml_driver.h | 29 -
tests/domaincapsschemadata/basic.xml | 25 -
tests/domaincapstest.c | 2 -
tests/objectlocking.ml | 3 -
tests/virdrivermoduletest.c | 3 -
tools/virsh.c | 3 -
32 files changed, 28 insertions(+), 3764 deletions(-)
delete mode 100644 docs/drvuml.html.in
delete mode 100644 m4/virt-driver-uml.m4
delete mode 100644 src/remote/libvirtd.uml.logrotate.in
delete mode 100644 src/uml/Makefile.inc.am
delete mode 100644 src/uml/uml_conf.c
delete mode 100644 src/uml/uml_conf.h
delete mode 100644 src/uml/uml_driver.c
delete mode 100644 src/uml/uml_driver.h
delete mode 100644 tests/domaincapsschemadata/basic.xml
diff --git a/configure.ac b/configure.ac
index 8c89ff365b..ac52189dff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -225,7 +225,6 @@ if test "$with_libvirtd" = "no" ; then
with_qemu=no
with_lxc=no
with_libxl=no
- with_uml=no
with_vbox=no
fi
@@ -445,7 +444,6 @@ LIBVIRT_DRIVER_ARG_VBOX
LIBVIRT_DRIVER_ARG_LXC
LIBVIRT_DRIVER_ARG_VZ
LIBVIRT_DRIVER_ARG_BHYVE
-LIBVIRT_DRIVER_ARG_UML
LIBVIRT_DRIVER_ARG_ESX
LIBVIRT_DRIVER_ARG_HYPERV
LIBVIRT_DRIVER_ARG_TEST
@@ -464,7 +462,6 @@ LIBVIRT_DRIVER_CHECK_VBOX
LIBVIRT_DRIVER_CHECK_LXC
LIBVIRT_DRIVER_CHECK_VZ
LIBVIRT_DRIVER_CHECK_BHYVE
-LIBVIRT_DRIVER_CHECK_UML
LIBVIRT_DRIVER_CHECK_ESX
LIBVIRT_DRIVER_CHECK_HYPERV
LIBVIRT_DRIVER_CHECK_TEST
@@ -947,7 +944,6 @@ AC_MSG_NOTICE([])
AC_MSG_NOTICE([Drivers])
AC_MSG_NOTICE([])
LIBVIRT_DRIVER_RESULT_QEMU
-LIBVIRT_DRIVER_RESULT_UML
LIBVIRT_DRIVER_RESULT_OPENVZ
LIBVIRT_DRIVER_RESULT_VMWARE
LIBVIRT_DRIVER_RESULT_VBOX
diff --git a/docs/aclpolkit.html.in b/docs/aclpolkit.html.in
index ac54f125da..2cf1f9b5a5 100644
--- a/docs/aclpolkit.html.in
+++ b/docs/aclpolkit.html.in
@@ -381,10 +381,6 @@
<td>storage</td>
<td>storage</td>
</tr>
- <tr>
- <td>uml</td>
- <td>UML</td>
- </tr>
<tr>
<td>vbox</td>
<td>VBOX</td>
diff --git a/docs/drivers.html.in b/docs/drivers.html.in
index c94144aa41..a66651df2f 100644
--- a/docs/drivers.html.in
+++ b/docs/drivers.html.in
@@ -29,7 +29,6 @@
<li><strong><a href="drvopenvz.html">OpenVZ</a></strong></li>
<li><strong><a href="drvqemu.html">QEMU</a></strong></li>
<li><strong><a href="drvtest.html">Test</a></strong> - Used for testing</li>
- <li><strong><a href="drvuml.html">UML</a></strong> - User Mode Linux</li>
<li><strong><a href="drvvbox.html">VirtualBox</a></strong></li>
<li><strong><a href="drvesx.html">VMware ESX</a></strong></li>
<li><strong><a href="drvvmware.html">VMware Workstation/Player</a></strong></li>
diff --git a/docs/drvuml.html.in b/docs/drvuml.html.in
deleted file mode 100644
index 0860db7dcf..0000000000
--- a/docs/drvuml.html.in
+++ /dev/null
@@ -1,93 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml">
- <body>
- <h1>User Mode Linux driver</h1>
-
- <p>
- The UML driver for libvirt allows use and management of paravirtualized
- guests built for User Mode Linux. UML requires no special support in
- the host kernel, so can be used by any user of any linux system, provided
- they have enough free RAM for their guest's needs, though there are
- certain restrictions on network connectivity unless the administrator
- has pre-created TAP devices.
- </p>
-
- <h2><a id="project">Project Links</a></h2>
-
- <ul>
- <li>
- The <a href="http://user-mode-linux.sourceforge.net/">User
- Mode Linux</a> paravirtualized kernel
- </li>
- </ul>
-
- <h2>Connections to UML driver</h2>
-
- <p>
- The libvirt UML driver follows the QEMU driver in providing two
- types of connection. There is one privileged instance per host,
- which runs as root. This is called the "system" instance, and allows
- full use of all host resources. Then, there is a per-user unprivileged
- "session", instance. This has more restricted capabilities, and may
- require the host administrator to setup certain resources ahead of
- time to allow full integration with the network. Example connection
- URIs are
- </p>
-
-<pre>
-uml:///session (local access to per-user instance)
-uml+unix:///session (local access to per-user instance)
-
-uml:///system (local access to system instance)
-uml+unix:///system (local access to system instance)
-uml://example.com/system (remote access, TLS/x509)
-uml+tcp://example.com/system (remote access, SASl/Kerberos)
-uml+ssh://root@example.com/system (remote access, SSH tunnelled)
-</pre>
-
- <h2>Example XML configuration</h2>
-
- <p>
- User mode Linux driver only supports directly kernel boot at
- this time. A future driver enhancement may allow a paravirt
- bootloader in a similar style to Xen's pygrub. For now though,
- the UML kernel must be stored on the host and referenced
- explicitly in the "os" element. Since UML is a paravirtualized
- technology, the kernel "type" is set to "uml"
- </p>
-
- <p>
- There is not yet support for networking in the driver, but
- disks can be specified in the usual libvirt manner. The main
- variation is the target device naming scheme "ubd0", and
- bus type of "uml".
- </p>
-
- <p>
- Once booted the primary console is connected to a PTY, and
- thus accessible with "virsh console" or equivalent tools
- </p>
-
-<pre>
-<domain type='uml'>
- <name>demo</name>
- <uuid>b4433fc2-a22e-ffb3-0a3d-9c173b395800</uuid>
- <memory>500000</memory>
- <currentMemory>500000</currentMemory>
- <vcpu>1</vcpu>
- <os>
- <type arch='x86_64'>uml</type>
- <kernel>/home/berrange/linux-uml-2.6.26-x86_64</kernel>
- </os>
- <devices>
- <disk type='file' device='disk'>
- <source file='/home/berrange/FedoraCore6-AMD64-root_fs'/>
- <target dev='ubd0' bus='uml'/>
- </disk>
- <console type='pty'/>
- </devices>
-</domain>
-</pre>
- </body>
-</html>
diff --git a/docs/formatcaps.html.in b/docs/formatcaps.html.in
index 86534b2ed2..2a0aa963bb 100644
--- a/docs/formatcaps.html.in
+++ b/docs/formatcaps.html.in
@@ -87,9 +87,6 @@
<dt><code>exe</code></dt>
<dd>Container based virtualization</dd>
-
- <dt><code>uml</code></dt>
- <dd>User Mode Linux</dd>
</dl>
</dd>
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 428b0e8bb5..2463261372 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -7161,9 +7161,9 @@ qemu-kvm -net nic,model=? /dev/null
Valid values for the <code>type</code> attribute are:
<code>serial</code> (described below);
<code>virtio</code> (usable whenever VirtIO support is available);
- <code>xen</code>, <code>lxc</code>, <code>uml</code> and
- <code>openvz</code> (available when the corresponding hypervisor is in
- use). <code>sclp</code> and <code>sclplm</code> (usable for s390 and
+ <code>xen</code>, <code>lxc</code> and <code>openvz</code>
+ (available when the corresponding hypervisor is in use).
+ <code>sclp</code> and <code>sclplm</code> (usable for s390 and
s390x QEMU guests) are supported for compatibility reasons but should
not be used for new guests: use the <code>sclpconsole</code> and
<code>sclplmconsole</code> target models, respectively, with the
diff --git a/docs/formatdomaincaps.html.in b/docs/formatdomaincaps.html.in
index 9920de4dac..cafd9abbdf 100644
--- a/docs/formatdomaincaps.html.in
+++ b/docs/formatdomaincaps.html.in
@@ -278,7 +278,6 @@
<value>virtio</value>
<value>xen</value>
<value>usb</value>
- <value>uml</value>
<value>sata</value>
<value>sd</value>
</enum>
diff --git a/docs/formatnwfilter.html.in b/docs/formatnwfilter.html.in
index b2282b7dee..796c16549d 100644
--- a/docs/formatnwfilter.html.in
+++ b/docs/formatnwfilter.html.in
@@ -2265,7 +2265,7 @@ echo 3 > /proc/sys/net/netfilter/nf_conntrack_icmp_timeout
to the incoming and outgoing direction. All this is related to the ftp
data traffic originating from TCP port 20 of the VM. This then leads to
the following solution
- <span class="since">(since 0.8.5 (QEMU, KVM, UML))</span>:
+ <span class="since">(since 0.8.5 (QEMU, KVM))</span>:
</p>
<pre>
<filter name='test-eth0'>
diff --git a/docs/news.xml b/docs/news.xml
index 5bdbd34a14..e9b6bb7c65 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -59,6 +59,20 @@
</description>
</change>
</section>
+ <section title="Removed features">
+ <change>
+ <summary>
+ Drop UML driver
+ </summary>
+ <description>
+ The UML driver was unmaintained and not tested for
+ quite some time now. Worse, there is a bug that causes
+ it to deadlock on some very basic operations (e.g.
+ dumping domain XML). These facts make us believe no one
+ uses it.
+ </description>
+ </change>
+ </section>
<section title="Improvements">
<change>
<summary>
diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
index fe90a2e4c6..8f3266b9f1 100644
--- a/docs/schemas/capability.rng
+++ b/docs/schemas/capability.rng
@@ -412,7 +412,7 @@
but is also used by phyp driver -->
<value>hvm</value> <!-- unmodified OS -->
<value>exe</value> <!-- For container based virt -->
- <value>uml</value> <!-- user mode linux -->
+ <value>uml</value> <!-- user mode linux; NOT USED ANYMORE -->
</choice>
</element>
</define>
@@ -484,7 +484,7 @@
<value>kqemu</value>
<value>kvm</value>
<value>xen</value>
- <value>uml</value>
+ <value>uml</value> <!-- NOT USED ANYMORE -->
<value>lxc</value>
<value>openvz</value>
<value>test</value>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 5a6c48f1aa..76b49aacc2 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -204,7 +204,7 @@
<value>kvm</value>
<value>xen</value>
<value>lxc</value>
- <value>uml</value>
+ <value>uml</value> <!-- NOT USED ANYMORE -->
<value>openvz</value>
<value>test</value>
<value>vmware</value>
@@ -1907,7 +1907,7 @@
<value>virtio</value>
<value>xen</value>
<value>usb</value>
- <value>uml</value>
+ <value>uml</value> <!-- NOT USED ANYMORE -->
<value>sata</value>
<value>sd</value>
</choice>
@@ -3725,7 +3725,7 @@
<choice>
<value>xen</value>
<value>serial</value>
- <value>uml</value>
+ <value>uml</value> <!-- NOT USED ANYMORE -->
<value>virtio</value>
<value>lxc</value>
<value>openvz</value>
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index f41afcd0a7..fbbe2d5624 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -74,7 +74,7 @@ typedef enum {
VIR_FROM_NETWORK = 19, /* Error from network config */
VIR_FROM_DOMAIN = 20, /* Error from domain config */
- VIR_FROM_UML = 21, /* Error at the UML driver */
+ VIR_FROM_UML = 21, /* Error at the UML driver; unused since 5.0.0 */
VIR_FROM_NODEDEV = 22, /* Error from node device monitor */
VIR_FROM_XEN_INOTIFY = 23, /* Error from xen inotify layer */
VIR_FROM_SECURITY = 24, /* Error from security framework */
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 71cd45c603..09472dcadc 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -20,7 +20,6 @@
# The hypervisor drivers that run in libvirtd
%define with_qemu 0%{!?_without_qemu:1}
%define with_lxc 0%{!?_without_lxc:1}
-%define with_uml 0%{!?_without_uml:1}
%define with_libxl 0%{!?_without_libxl:1}
%define with_vbox 0%{!?_without_vbox:1}
@@ -111,13 +110,12 @@
%endif
-# RHEL doesn't ship OpenVZ, VBox, UML, PowerHypervisor,
+# RHEL doesn't ship OpenVZ, VBox, PowerHypervisor,
# VMware, libxenserver (xenapi), libxenlight (Xen 4.1 and newer),
# or HyperV.
%if 0%{?rhel}
%define with_openvz 0
%define with_vbox 0
- %define with_uml 0
%define with_phyp 0
%define with_vmware 0
%define with_xenapi 0
@@ -178,7 +176,7 @@
%endif
-%if %{with_qemu} || %{with_lxc} || %{with_uml}
+%if %{with_qemu} || %{with_lxc}
# numad is used to manage the CPU and memory placement dynamically,
# it's not available on many non-x86 architectures.
%ifnarch s390 s390x %{arm} riscv64
@@ -231,9 +229,6 @@ Requires: libvirt-daemon-driver-lxc = %{version}-%{release}
%if %{with_qemu}
Requires: libvirt-daemon-driver-qemu = %{version}-%{release}
%endif
-%if %{with_uml}
-Requires: libvirt-daemon-driver-uml = %{version}-%{release}
-%endif
%if %{with_vbox}
Requires: libvirt-daemon-driver-vbox = %{version}-%{release}
%endif
@@ -743,19 +738,6 @@ the Linux kernel
%endif
-%if %{with_uml}
-%package daemon-driver-uml
-Summary: Uml driver plugin for the libvirtd daemon
-Requires: libvirt-daemon = %{version}-%{release}
-Requires: libvirt-libs = %{version}-%{release}
-
-%description daemon-driver-uml
-The UML driver plugin for the libvirtd daemon, providing
-an implementation of the hypervisor driver APIs using
-User Mode Linux
-%endif
-
-
%if %{with_vbox}
%package daemon-driver-vbox
Summary: VirtualBox driver plugin for the libvirtd daemon
@@ -843,26 +825,6 @@ capabilities of LXC
%endif
-%if %{with_uml}
-%package daemon-uml
-Summary: Server side daemon & driver required to run UML guests
-
-Requires: libvirt-daemon = %{version}-%{release}
-Requires: libvirt-daemon-driver-uml = %{version}-%{release}
-Requires: libvirt-daemon-driver-interface = %{version}-%{release}
-Requires: libvirt-daemon-driver-network = %{version}-%{release}
-Requires: libvirt-daemon-driver-nodedev = %{version}-%{release}
-Requires: libvirt-daemon-driver-nwfilter = %{version}-%{release}
-Requires: libvirt-daemon-driver-secret = %{version}-%{release}
-Requires: libvirt-daemon-driver-storage = %{version}-%{release}
-# There are no UML kernel RPMs in Fedora/RHEL to depend on.
-
-%description daemon-uml
-Server side daemon and driver required to manage the virtualization
-capabilities of UML
-%endif
-
-
%if %{with_libxl}
%package daemon-xen
Summary: Server side daemon & driver required to run XEN guests
@@ -1068,12 +1030,6 @@ exit 1
%define arg_vmware --without-vmware
%endif
-%if %{with_uml}
- %define arg_uml --with-uml
-%else
- %define arg_uml --without-uml
-%endif
-
%if %{with_storage_rbd}
%define arg_storage_rbd --with-storage-rbd
%else
@@ -1187,7 +1143,6 @@ rm -f po/stamp-po
--with-avahi \
--with-polkit \
--with-libvirtd \
- %{?arg_uml} \
%{?arg_phyp} \
%{?arg_esx} \
%{?arg_hyperv} \
@@ -1316,9 +1271,6 @@ rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/libvirtd.libxl
rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/libvirtd_libxl.aug
rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/tests/test_libvirtd_libxl.aug
%endif
-%if ! %{with_uml}
-rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/libvirtd.uml
-%endif
# Copied into libvirt-docs subpackage eventually
mv $RPM_BUILD_ROOT%{_datadir}/doc/libvirt-%{version} libvirt-docs
@@ -1725,15 +1677,6 @@ exit 0
%{_libdir}/%{name}/connection-driver/libvirt_driver_lxc.so
%endif
-%if %{with_uml}
-%files daemon-driver-uml
-%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/uml/
-%config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd.uml
-%ghost %dir %{_localstatedir}/run/libvirt/uml/
-%dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/uml/
-%{_libdir}/%{name}/connection-driver/libvirt_driver_uml.so
-%endif
-
%if %{with_libxl}
%files daemon-driver-libxl
%config(noreplace) %{_sysconfdir}/libvirt/libxl.conf
@@ -1764,10 +1707,6 @@ exit 0
%files daemon-lxc
%endif
-%if %{with_uml}
-%files daemon-uml
-%endif
-
%if %{with_libxl}
%files daemon-xen
%endif
diff --git a/m4/virt-driver-uml.m4 b/m4/virt-driver-uml.m4
deleted file mode 100644
index 9b406a5b6b..0000000000
--- a/m4/virt-driver-uml.m4
+++ /dev/null
@@ -1,54 +0,0 @@
-dnl The UML driver
-dnl
-dnl Copyright (C) 2005-2015 Red Hat, Inc.
-dnl
-dnl This library is free software; you can redistribute it and/or
-dnl modify it under the terms of the GNU Lesser General Public
-dnl License as published by the Free Software Foundation; either
-dnl version 2.1 of the License, or (at your option) any later version.
-dnl
-dnl This library is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-dnl Lesser General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU Lesser General Public
-dnl License along with this library. If not, see
-dnl <http://www.gnu.org/licenses/>.
-dnl
-
-AC_DEFUN([LIBVIRT_DRIVER_ARG_UML],[
- LIBVIRT_ARG_WITH_FEATURE([UML], [UML], [check])
-])
-
-AC_DEFUN([LIBVIRT_DRIVER_CHECK_UML],[
- if test "$with_libvirtd" = "no" || test "$with_linux" = "no"; then
- if test "$with_uml" = "yes"; then
- AC_MSG_ERROR([The UML driver cannot be enabled])
- elif test "$with_uml" = "check"; then
- with_uml="no"
- fi
- fi
-
- if test "$with_uml" = "yes" || test "$with_uml" = "check"; then
- AC_CHECK_HEADER([sys/inotify.h], [
- with_uml=yes
- ], [
- if test "$with_uml" = "check"; then
- with_uml=no
- AC_MSG_NOTICE([<sys/inotify.h> is required for the UML driver, disabling it])
- else
- AC_MSG_ERROR([The <sys/inotify.h> is required for the UML driver. Upgrade your libc6.])
- fi
- ])
- fi
-
- if test "$with_uml" = "yes" ; then
- AC_DEFINE_UNQUOTED([WITH_UML], 1, [whether UML driver is enabled])
- fi
- AM_CONDITIONAL([WITH_UML], [test "$with_uml" = "yes"])
-])
-
-AC_DEFUN([LIBVIRT_DRIVER_RESULT_UML],[
- LIBVIRT_RESULT([UML], [$with_uml])
-])
diff --git a/mingw-libvirt.spec.in b/mingw-libvirt.spec.in
index b28e40f7f7..7c7ab4146d 100644
--- a/mingw-libvirt.spec.in
+++ b/mingw-libvirt.spec.in
@@ -177,7 +177,6 @@ autoreconf -if
--without-avahi \
--without-polkit \
--without-libvirtd \
- --without-uml \
%{?_without_phyp} \
%{?_without_esx} \
%{?_without_hyperv} \
diff --git a/po/POTFILES b/po/POTFILES
index be2874487c..9dd4ee7d99 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -190,8 +190,6 @@ src/storage/storage_backend_zfs.c
src/storage/storage_driver.c
src/storage/storage_util.c
src/test/test_driver.c
-src/uml/uml_conf.c
-src/uml/uml_driver.c
src/util/iohelper.c
src/util/viralloc.c
src/util/virarptable.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 33ff280d78..e2b89e27e8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -107,7 +107,6 @@ include logging/Makefile.inc.am
include locking/Makefile.inc.am
include admin/Makefile.inc.am
include rpc/Makefile.inc.am
-include uml/Makefile.inc.am
include phyp/Makefile.inc.am
include test/Makefile.inc.am
include esx/Makefile.inc.am
diff --git a/src/README b/src/README
index bb3cddfc6e..846bf2b664 100644
--- a/src/README
+++ b/src/README
@@ -34,7 +34,6 @@ Then there are the hypervisor implementations:
* qemu/ - QEMU / KVM using qemu CLI/monitor
* remote/ - Generic libvirt native RPC client
* test/ - A "mock" driver for testing
- * uml/ - User Mode Linux
* vbox/ - Virtual Box using native API
* vmware/ - VMware Workstation and Player using the vmrun tool
* xen/ - Xen using hypercalls, XenD SEXPR & XenStore
@@ -42,7 +41,7 @@ Then there are the hypervisor implementations:
Finally some secondary drivers that are shared for several HVs.
-Currently these are used by LXC, OpenVZ, QEMU, UML and Xen drivers.
+Currently these are used by LXC, OpenVZ, QEMU and Xen drivers.
The ESX, Hyper-V, Power Hypervisor, Remote, Test & VirtualBox drivers all
implement the secondary drivers directly
diff --git a/src/locking/lock_driver.h b/src/locking/lock_driver.h
index f2d5266517..50c73a70d4 100644
--- a/src/locking/lock_driver.h
+++ b/src/locking/lock_driver.h
@@ -124,7 +124,7 @@ struct _virLockManagerParam {
* too old to support key features.
*
* NB: A plugin may be loaded multiple times, for different
- * libvirt drivers (eg QEMU, LXC, UML)
+ * libvirt drivers (eg QEMU, LXC)
*
* Returns -1 if the requested version/flags were inadequate
*/
diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am
index eb8d6feb31..d188c4e348 100644
--- a/src/remote/Makefile.inc.am
+++ b/src/remote/Makefile.inc.am
@@ -39,7 +39,6 @@ LOGROTATE_FILES_IN += \
remote/libvirtd.qemu.logrotate.in \
remote/libvirtd.lxc.logrotate.in \
remote/libvirtd.libxl.logrotate.in \
- remote/libvirtd.uml.logrotate.in \
remote/libvirtd.logrotate.in \
$(NULL)
diff --git a/src/remote/libvirtd.uml.logrotate.in b/src/remote/libvirtd.uml.logrotate.in
deleted file mode 100644
index 66a848e37e..0000000000
--- a/src/remote/libvirtd.uml.logrotate.in
+++ /dev/null
@@ -1,8 +0,0 @@
-@localstatedir(a)/log/libvirt/uml/*.log {
- weekly
- missingok
- rotate 4
- compress
- delaycompress
- copytruncate
-}
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index f0dd7597e6..3be3ad02fc 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -339,10 +339,6 @@ static int daemonInitialize(void)
if (virDriverLoadModule("lxc", "lxcRegister", false) < 0)
return -1;
#endif
-#ifdef WITH_UML
- if (virDriverLoadModule("uml", "umlRegister", false) < 0)
- return -1;
-#endif
#ifdef WITH_VBOX
if (virDriverLoadModule("vbox", "vboxRegister", false) < 0)
return -1;
diff --git a/src/uml/Makefile.inc.am b/src/uml/Makefile.inc.am
deleted file mode 100644
index 975398b928..0000000000
--- a/src/uml/Makefile.inc.am
+++ /dev/null
@@ -1,48 +0,0 @@
-UML_DRIVER_SOURCES = \
- uml/uml_conf.c \
- uml/uml_conf.h \
- uml/uml_driver.c \
- uml/uml_driver.h \
- $(NULL)
-
-DRIVER_SOURCE_FILES += $(UML_DRIVER_SOURCES)
-STATEFUL_DRIVER_SOURCE_FILES += $(UML_DRIVER_SOURCES)
-EXTRA_DIST += $(UML_DRIVER_SOURCES)
-
-if WITH_UML
-noinst_LTLIBRARIES += libvirt_driver_uml_impl.la
-libvirt_driver_uml_la_SOURCES =
-libvirt_driver_uml_la_LIBADD = \
- libvirt_driver_uml_impl.la \
- libvirt.la \
- ../gnulib/lib/libgnu.la \
- $(NULL)
-mod_LTLIBRARIES += libvirt_driver_uml.la
-libvirt_driver_uml_la_LDFLAGS = $(AM_LDFLAGS_MOD_NOUNDEF)
-
-libvirt_driver_uml_impl_la_CFLAGS = \
- -I$(srcdir)/access \
- -I$(srcdir)/conf \
- $(AM_CFLAGS) \
- $(NULL)
-libvirt_driver_uml_impl_la_LDFLAGS = $(AM_LDFLAGS)
-libvirt_driver_uml_impl_la_SOURCES = $(UML_DRIVER_SOURCES)
-
-INSTALL_DATA_DIRS += uml
-
-install-data-uml:
- $(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/uml"
- $(MKDIR_P) "$(DESTDIR)$(localstatedir)/run/libvirt/uml"
- $(MKDIR_P) "$(DESTDIR)$(localstatedir)/log/libvirt/uml"
-
-uninstall-data-uml:
- rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/uml" ||:
- rmdir "$(DESTDIR)$(localstatedir)/run/libvirt/uml" ||:
- rmdir "$(DESTDIR)$(localstatedir)/log/libvirt/uml" ||:
-
-endif WITH_UML
-
-.PHONY: \
- install-data-uml \
- uninstall-data-uml \
- $(NULL)
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
deleted file mode 100644
index 067600afba..0000000000
--- a/src/uml/uml_conf.c
+++ /dev/null
@@ -1,481 +0,0 @@
-/*
- * uml_conf.c: UML driver configuration
- *
- * Copyright (C) 2006-2014, 2016 Red Hat, Inc.
- * Copyright (C) 2006 Daniel P. Berrange
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-
-#include <config.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/wait.h>
-#include <arpa/inet.h>
-
-#include "uml_conf.h"
-#include "viruuid.h"
-#include "virbuffer.h"
-#include "virconf.h"
-#include "viralloc.h"
-#include "virlog.h"
-#include "domain_nwfilter.h"
-#include "virfile.h"
-#include "vircommand.h"
-#include "virnetdevtap.h"
-#include "virnodesuspend.h"
-#include "virstring.h"
-
-#define VIR_FROM_THIS VIR_FROM_UML
-
-VIR_LOG_INIT("uml.uml_conf");
-
-virCapsPtr umlCapsInit(void)
-{
- virCapsPtr caps;
- virCapsGuestPtr guest;
-
- if ((caps = virCapabilitiesNew(virArchFromHost(),
- false, false)) == NULL)
- goto error;
-
- /* Some machines have problematic NUMA topology causing
- * unexpected failures. We don't want to break the QEMU
- * driver in this scenario, so log errors & carry on
- */
- if (virCapabilitiesInitNUMA(caps) < 0) {
- virCapabilitiesFreeNUMAInfo(caps);
- VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities");
- }
-
- if (virCapabilitiesInitCaches(caps) < 0)
- VIR_WARN("Failed to get host CPU cache info");
-
- if (virNodeSuspendGetTargetMask(&caps->host.powerMgmt) < 0)
- VIR_WARN("Failed to get host power management capabilities");
-
- if (virGetHostUUID(caps->host.host_uuid)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("cannot get the host uuid"));
- goto error;
- }
-
- if ((guest = virCapabilitiesAddGuest(caps,
- VIR_DOMAIN_OSTYPE_UML,
- caps->host.arch,
- NULL,
- NULL,
- 0,
- NULL)) == NULL)
- goto error;
-
- if (virCapabilitiesAddGuestDomain(guest,
- VIR_DOMAIN_VIRT_UML,
- NULL,
- NULL,
- 0,
- NULL) == NULL)
- goto error;
-
- return caps;
-
- error:
- virObjectUnref(caps);
- return NULL;
-}
-
-
-static int
-umlConnectTapDevice(virDomainDefPtr vm,
- virDomainNetDefPtr net,
- const char *bridge)
-{
- bool template_ifname = false;
- int tapfd = -1;
-
- if (!net->ifname ||
- STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) ||
- strchr(net->ifname, '%')) {
- VIR_FREE(net->ifname);
- if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") < 0)
- goto error;
- /* avoid exposing vnet%d in getXMLDesc or error outputs */
- template_ifname = true;
- }
-
- if (virNetDevTapCreateInBridgePort(bridge, &net->ifname, &net->mac,
- vm->uuid, net->backend.tap, &tapfd, 1,
- virDomainNetGetActualVirtPortProfile(net),
- virDomainNetGetActualVlan(net),
- NULL, 0, NULL,
- VIR_NETDEV_TAP_CREATE_IFUP |
- VIR_NETDEV_TAP_CREATE_PERSIST) < 0) {
- if (template_ifname)
- VIR_FREE(net->ifname);
- goto error;
- }
-
- if (net->filter) {
- if (virDomainConfNWFilterInstantiate(vm->name, vm->uuid, net, false) < 0) {
- if (template_ifname)
- VIR_FREE(net->ifname);
- goto error;
- }
- }
-
- VIR_FORCE_CLOSE(tapfd);
- return 0;
-
- error:
- VIR_FORCE_CLOSE(tapfd);
- return -1;
-}
-
-static char *
-umlBuildCommandLineNet(virConnectPtr conn,
- virDomainDefPtr vm,
- virDomainNetDefPtr def,
- int idx)
-{
- virBuffer buf = VIR_BUFFER_INITIALIZER;
- char macaddr[VIR_MAC_STRING_BUFLEN];
-
- /* General format: ethNN=type,options */
-
- virBufferAsprintf(&buf, "eth%d=", idx);
-
- switch (def->type) {
- case VIR_DOMAIN_NET_TYPE_USER:
- /* ethNNN=slirp,macaddr */
- virBufferAddLit(&buf, "slirp");
- break;
-
- case VIR_DOMAIN_NET_TYPE_ETHERNET:
- /* ethNNN=tuntap,tapname,macaddr,gateway */
- virBufferAddLit(&buf, "tuntap,");
- if (def->ifname)
- virBufferAdd(&buf, def->ifname, -1);
- if (def->guestIP.nips > 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("IP address not supported for ethernet interface"));
- goto error;
- }
- break;
-
- case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("vhostuser networking type not supported"));
- goto error;
-
- case VIR_DOMAIN_NET_TYPE_SERVER:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("TCP server networking type not supported"));
- goto error;
-
- case VIR_DOMAIN_NET_TYPE_CLIENT:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("TCP client networking type not supported"));
- goto error;
-
- case VIR_DOMAIN_NET_TYPE_UDP:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("UDP networking type not supported"));
- goto error;
-
- case VIR_DOMAIN_NET_TYPE_MCAST:
- /* ethNNN=tuntap,macaddr,ipaddr,port */
- virBufferAddLit(&buf, "mcast");
- break;
-
- case VIR_DOMAIN_NET_TYPE_NETWORK:
- {
- char *bridge;
- virNetworkPtr network = virNetworkLookupByName(conn,
- def->data.network.name);
- if (!network) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Network '%s' not found"),
- def->data.network.name);
- goto error;
- }
- bridge = virNetworkGetBridgeName(network);
- virObjectUnref(network);
- if (bridge == NULL)
- goto error;
-
- if (umlConnectTapDevice(vm, def, bridge) < 0) {
- VIR_FREE(bridge);
- goto error;
- }
-
- /* ethNNN=tuntap,tapname,macaddr,gateway */
- virBufferAsprintf(&buf, "tuntap,%s", def->ifname);
- break;
- }
-
- case VIR_DOMAIN_NET_TYPE_BRIDGE:
- if (umlConnectTapDevice(vm, def,
- def->data.bridge.brname) < 0)
- goto error;
-
- /* ethNNN=tuntap,tapname,macaddr,gateway */
- virBufferAsprintf(&buf, "tuntap,%s", def->ifname);
- break;
-
- case VIR_DOMAIN_NET_TYPE_INTERNAL:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("internal networking type not supported"));
- goto error;
-
- case VIR_DOMAIN_NET_TYPE_DIRECT:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("direct networking type not supported"));
- goto error;
-
- case VIR_DOMAIN_NET_TYPE_HOSTDEV:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("hostdev networking type not supported"));
- goto error;
-
- case VIR_DOMAIN_NET_TYPE_LAST:
- break;
- }
-
- if (def->script) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("interface script execution not supported by this driver"));
- goto error;
- }
-
- virBufferAsprintf(&buf, ",%s", virMacAddrFormat(&def->mac, macaddr));
-
- if (def->type == VIR_DOMAIN_NET_TYPE_MCAST) {
- virBufferAsprintf(&buf, ",%s,%d",
- def->data.socket.address,
- def->data.socket.port);
- }
-
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
- return virBufferContentAndReset(&buf);
-
- error:
- virBufferFreeAndReset(&buf);
- return NULL;
-}
-
-static char *
-umlBuildCommandLineChr(virDomainChrDefPtr def,
- const char *dev,
- virCommandPtr cmd)
-{
- char *ret = NULL;
-
- switch (def->source->type) {
- case VIR_DOMAIN_CHR_TYPE_NULL:
- if (virAsprintf(&ret, "%s%d=null", dev, def->target.port) < 0)
- return NULL;
- break;
-
- case VIR_DOMAIN_CHR_TYPE_PTY:
- if (virAsprintf(&ret, "%s%d=pts", dev, def->target.port) < 0)
- return NULL;
- break;
-
- case VIR_DOMAIN_CHR_TYPE_DEV:
- if (virAsprintf(&ret, "%s%d=tty:%s", dev, def->target.port,
- def->source->data.file.path) < 0)
- return NULL;
- break;
-
- case VIR_DOMAIN_CHR_TYPE_STDIO:
- if (virAsprintf(&ret, "%s%d=fd:0,fd:1", dev, def->target.port) < 0)
- return NULL;
- break;
-
- case VIR_DOMAIN_CHR_TYPE_TCP:
- if (def->source->data.tcp.listen != 1) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("only TCP listen is supported for chr device"));
- return NULL;
- }
-
- if (virAsprintf(&ret, "%s%d=port:%s", dev, def->target.port,
- def->source->data.tcp.service) < 0)
- return NULL;
- break;
-
- case VIR_DOMAIN_CHR_TYPE_FILE:
- {
- int fd_out;
-
- if ((fd_out = open(def->source->data.file.path,
- O_WRONLY | O_APPEND | O_CREAT, 0660)) < 0) {
- virReportSystemError(errno,
- _("failed to open chardev file: %s"),
- def->source->data.file.path);
- return NULL;
- }
- if (virAsprintf(&ret, "%s%d=null,fd:%d", dev, def->target.port, fd_out) < 0) {
- VIR_FORCE_CLOSE(fd_out);
- return NULL;
- }
- virCommandPassFD(cmd, fd_out,
- VIR_COMMAND_PASS_FD_CLOSE_PARENT);
- }
- break;
- case VIR_DOMAIN_CHR_TYPE_PIPE:
- /* XXX could open the pipe & just pass the FDs. Be wary of
- * the effects of blocking I/O, though. */
-
- case VIR_DOMAIN_CHR_TYPE_VC:
- case VIR_DOMAIN_CHR_TYPE_UDP:
- case VIR_DOMAIN_CHR_TYPE_UNIX:
- default:
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unsupported chr device type %d"), def->source->type);
- break;
- }
-
- return ret;
-}
-
-/*
- * Null-terminate the current argument and return a pointer to the next.
- * This should follow the same rules as the Linux kernel: arguments are
- * separated by spaces; arguments can be quoted with double quotes; double
- * quotes can't be escaped.
- */
-static char *umlNextArg(char *args)
-{
- int in_quote = 0;
-
- for (; *args; args++) {
- if (*args == ' ' && !in_quote) {
- *args++ = '\0';
- break;
- }
- if (*args == '"')
- in_quote = !in_quote;
- }
-
- while (*args == ' ')
- args++;
-
- return args;
-}
-
-/*
- * Constructs a argv suitable for launching uml with config defined
- * for a given virtual machine.
- */
-virCommandPtr umlBuildCommandLine(virConnectPtr conn,
- struct uml_driver *driver,
- virDomainObjPtr vm)
-{
- size_t i, j;
- virCommandPtr cmd;
-
- cmd = virCommandNew(vm->def->os.kernel);
-
- virCommandAddEnvPassCommon(cmd);
-
- /* virCommandAddArgPair(cmd, "con0", "fd:0,fd:1"); */
- virCommandAddArgFormat(cmd, "mem=%lluK", vm->def->mem.cur_balloon);
- virCommandAddArgPair(cmd, "umid", vm->def->name);
- virCommandAddArgPair(cmd, "uml_dir", driver->monitorDir);
-
- if (vm->def->os.root)
- virCommandAddArgPair(cmd, "root", vm->def->os.root);
-
- for (i = 0; i < vm->def->ndisks; i++) {
- virDomainDiskDefPtr disk = vm->def->disks[i];
-
- if (!STRPREFIX(disk->dst, "ubd")) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unsupported disk type '%s'"), disk->dst);
- goto error;
- }
-
- virCommandAddArgPair(cmd, disk->dst, virDomainDiskGetSource(disk));
- }
-
- for (i = 0; i < vm->def->nnets; i++) {
- char *ret = umlBuildCommandLineNet(conn, vm->def, vm->def->nets[i], i);
- if (!ret)
- goto error;
- virCommandAddArg(cmd, ret);
- VIR_FREE(ret);
- }
-
- for (i = 0; i < UML_MAX_CHAR_DEVICE; i++) {
- virDomainChrDefPtr chr = NULL;
- char *ret = NULL;
- for (j = 0; j < vm->def->nconsoles; j++)
- if (vm->def->consoles[j]->target.port == i)
- chr = vm->def->consoles[j];
- if (chr)
- ret = umlBuildCommandLineChr(chr, "con", cmd);
- if (!ret)
- if (virAsprintf(&ret, "con%zu=none", i) < 0)
- goto error;
- virCommandAddArg(cmd, ret);
- VIR_FREE(ret);
- }
-
- for (i = 0; i < UML_MAX_CHAR_DEVICE; i++) {
- virDomainChrDefPtr chr = NULL;
- char *ret = NULL;
- for (j = 0; j < vm->def->nserials; j++)
- if (vm->def->serials[j]->target.port == i)
- chr = vm->def->serials[j];
- if (chr)
- ret = umlBuildCommandLineChr(chr, "ssl", cmd);
- if (!ret)
- if (virAsprintf(&ret, "ssl%zu=none", i) < 0)
- goto error;
-
- virCommandAddArg(cmd, ret);
- VIR_FREE(ret);
- }
-
- if (vm->def->os.cmdline) {
- char *args, *next_arg;
- char *cmdline;
- if (VIR_STRDUP(cmdline, vm->def->os.cmdline) < 0)
- goto error;
-
- args = cmdline;
- while (*args == ' ')
- args++;
-
- while (*args) {
- next_arg = umlNextArg(args);
- virCommandAddArg(cmd, args);
- args = next_arg;
- }
- VIR_FREE(cmdline);
- }
-
- return cmd;
-
- error:
- virCommandFree(cmd);
- return NULL;
-}
diff --git a/src/uml/uml_conf.h b/src/uml/uml_conf.h
deleted file mode 100644
index a9520a6d3e..0000000000
--- a/src/uml/uml_conf.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * uml_conf.h: VM configuration management
- *
- * Copyright (C) 2006, 2007, 2010 Red Hat, Inc.
- * Copyright (C) 2006 Daniel P. Berrange
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-
-#ifndef LIBVIRT_UML_CONF_H
-# define LIBVIRT_UML_CONF_H
-
-# include "internal.h"
-# include "libvirt_internal.h"
-# include "capabilities.h"
-# include "network_conf.h"
-# include "virdomainobjlist.h"
-# include "domain_event.h"
-# include "virerror.h"
-# include "virthread.h"
-# include "vircommand.h"
-# include "virhash.h"
-
-# define umlDebug(fmt, ...) do {} while (0)
-
-# define UML_CPUMASK_LEN CPU_SETSIZE
-
-# define UML_MAX_CHAR_DEVICE 16
-
-/* Main driver state */
-struct uml_driver {
- virMutex lock;
-
- bool privileged;
- virStateInhibitCallback inhibitCallback;
- void *inhibitOpaque;
-
- unsigned long umlVersion;
- int nextvmid;
-
- virDomainObjListPtr domains;
- size_t nactive;
-
- char *configDir;
- char *autostartDir;
- char *logDir;
- char *monitorDir;
-
- int inotifyFD;
- int inotifyWatch;
-
- virCapsPtr caps;
- virDomainXMLOptionPtr xmlopt;
-
- /* Event handling */
- virObjectEventStatePtr domainEventState;
-
- /* Mapping of 'char *uuidstr' -> virConnectPtr
- * of guests which will be automatically killed
- * when the virConnectPtr is closed*/
- virHashTablePtr autodestroy;
-};
-
-virCapsPtr umlCapsInit (void);
-
-virCommandPtr umlBuildCommandLine(virConnectPtr conn,
- struct uml_driver *driver,
- virDomainObjPtr dom);
-
-#endif /* LIBVIRT_UML_CONF_H */
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
deleted file mode 100644
index e790273717..0000000000
--- a/src/uml/uml_driver.c
+++ /dev/null
@@ -1,2835 +0,0 @@
-/*
- * uml_driver.c: core driver methods for managing UML guests
- *
- * Copyright (C) 2006-2015 Red Hat, Inc.
- * Copyright (C) 2006-2008 Daniel P. Berrange
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-
-#include <config.h>
-
-#include <sys/types.h>
-#include <sys/poll.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <sys/utsname.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <pwd.h>
-#include <sys/wait.h>
-#include <sys/ioctl.h>
-#include <sys/inotify.h>
-#include <sys/un.h>
-
-#include "uml_driver.h"
-#include "uml_conf.h"
-#include "virbuffer.h"
-#include "virhostcpu.h"
-#include "virhostmem.h"
-#include "capabilities.h"
-#include "viralloc.h"
-#include "viruuid.h"
-#include "domain_conf.h"
-#include "domain_audit.h"
-#include "datatypes.h"
-#include "virlog.h"
-#include "domain_nwfilter.h"
-#include "virfile.h"
-#include "virfdstream.h"
-#include "configmake.h"
-#include "virnetdevtap.h"
-#include "virnodesuspend.h"
-#include "virprocess.h"
-#include "viruri.h"
-#include "virstring.h"
-#include "viraccessapicheck.h"
-
-#define VIR_FROM_THIS VIR_FROM_UML
-
-VIR_LOG_INIT("uml.uml_driver");
-
-typedef struct _umlDomainObjPrivate umlDomainObjPrivate;
-typedef umlDomainObjPrivate *umlDomainObjPrivatePtr;
-struct _umlDomainObjPrivate {
- int monitor;
- int monitorWatch;
-};
-
-static int umlProcessAutoDestroyInit(struct uml_driver *driver);
-static void umlProcessAutoDestroyRun(struct uml_driver *driver,
- virConnectPtr conn);
-static void umlProcessAutoDestroyShutdown(struct uml_driver *driver);
-static int umlProcessAutoDestroyAdd(struct uml_driver *driver,
- virDomainObjPtr vm,
- virConnectPtr conn);
-static int umlProcessAutoDestroyRemove(struct uml_driver *driver,
- virDomainObjPtr vm);
-
-
-static int umlStateCleanup(void);
-
-static void *umlDomainObjPrivateAlloc(void *opaque ATTRIBUTE_UNUSED)
-{
- umlDomainObjPrivatePtr priv;
-
- if (VIR_ALLOC(priv) < 0)
- return NULL;
-
- priv->monitor = -1;
- priv->monitorWatch = -1;
-
- return priv;
-}
-
-static void umlDomainObjPrivateFree(void *data)
-{
- umlDomainObjPrivatePtr priv = data;
-
- VIR_FREE(priv);
-}
-
-
-static void umlDriverLock(struct uml_driver *driver)
-{
- virMutexLock(&driver->lock);
-}
-static void umlDriverUnlock(struct uml_driver *driver)
-{
- virMutexUnlock(&driver->lock);
-}
-
-
-static int umlOpenMonitor(struct uml_driver *driver,
- virDomainObjPtr vm);
-static int umlReadPidFile(struct uml_driver *driver,
- virDomainObjPtr vm);
-
-static int umlStartVMDaemon(virConnectPtr conn,
- struct uml_driver *driver,
- virDomainObjPtr vm,
- bool autoDestroy);
-
-static void umlShutdownVMDaemon(struct uml_driver *driver,
- virDomainObjPtr vm,
- virDomainShutoffReason reason);
-
-
-static int umlMonitorCommand(const struct uml_driver *driver,
- const virDomainObj *vm,
- const char *cmd,
- char **reply);
-
-static struct uml_driver *uml_driver;
-
-static virDomainObjPtr
-umlDomObjFromDomainLocked(struct uml_driver *driver,
- const unsigned char *uuid)
-{
- virDomainObjPtr vm;
- char uuidstr[VIR_UUID_STRING_BUFLEN];
-
- if (!(vm = virDomainObjListFindByUUID(driver->domains, uuid))) {
- virUUIDFormat(uuid, uuidstr);
-
- virReportError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching uuid '%s'"), uuidstr);
- return NULL;
- }
-
- return vm;
-}
-
-
-static virDomainObjPtr
-umlDomObjFromDomain(struct uml_driver *driver,
- const unsigned char *uuid)
-{
- virDomainObjPtr vm;
-
- umlDriverLock(driver);
- vm = umlDomObjFromDomainLocked(driver, uuid);
- umlDriverUnlock(driver);
- return vm;
-}
-
-
-struct umlAutostartData {
- struct uml_driver *driver;
- virConnectPtr conn;
-};
-
-static int
-umlAutostartDomain(virDomainObjPtr vm,
- void *opaque)
-{
- const struct umlAutostartData *data = opaque;
- int ret = 0;
- virObjectLock(vm);
- if (vm->autostart &&
- !virDomainObjIsActive(vm)) {
- virResetLastError();
- ret = umlStartVMDaemon(data->conn, data->driver, vm, false);
- virDomainAuditStart(vm, "booted", ret >= 0);
- if (ret < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to autostart VM '%s': %s"),
- vm->def->name, virGetLastErrorMessage());
- } else {
- virObjectEventPtr event =
- virDomainEventLifecycleNewFromObj(vm,
- VIR_DOMAIN_EVENT_STARTED,
- VIR_DOMAIN_EVENT_STARTED_BOOTED);
- virObjectEventStateQueue(data->driver->domainEventState, event);
- }
- }
- virObjectUnlock(vm);
- return ret;
-}
-
-static void
-umlAutostartConfigs(struct uml_driver *driver)
-{
- /* XXX: Figure out a better way todo this. The domain
- * startup code needs a connection handle in order
- * to lookup the bridge associated with a virtual
- * network
- */
- virConnectPtr conn = virConnectOpen(driver->privileged ?
- "uml:///system" :
- "uml:///session");
- /* Ignoring NULL conn which is mostly harmless here */
-
- struct umlAutostartData data = { driver, conn };
-
- umlDriverLock(driver);
- virDomainObjListForEach(driver->domains, umlAutostartDomain, &data);
- umlDriverUnlock(driver);
-
- virObjectUnref(conn);
-}
-
-
-static int
-umlIdentifyOneChrPTY(struct uml_driver *driver,
- virDomainObjPtr dom,
- virDomainChrDefPtr def,
- const char *dev)
-{
- char *cmd;
- char *res = NULL;
- int retries = 0;
- if (virAsprintf(&cmd, "config %s%d", dev, def->target.port) < 0)
- return -1;
- requery:
- if (umlMonitorCommand(driver, dom, cmd, &res) < 0)
- return -1;
-
- if (res && STRPREFIX(res, "pts:")) {
- VIR_FREE(def->source->data.file.path);
- if (VIR_STRDUP(def->source->data.file.path, res + 4) < 0) {
- VIR_FREE(res);
- VIR_FREE(cmd);
- return -1;
- }
- } else if (!res || STRPREFIX(res, "pts")) {
- /* It can take a while to startup, so retry for
- up to 5 seconds */
- /* XXX should do this in a better non-blocking
- way somehow ...perhaps register a timer */
- if (retries++ < 50) {
- VIR_FREE(res);
- usleep(1000*10);
- goto requery;
- }
- }
-
- VIR_FREE(cmd);
- VIR_FREE(res);
- return 0;
-}
-
-static int
-umlIdentifyChrPTY(struct uml_driver *driver,
- virDomainObjPtr dom)
-{
- size_t i;
-
- for (i = 0; i < dom->def->nconsoles; i++)
- if (dom->def->consoles[i]->source->type == VIR_DOMAIN_CHR_TYPE_PTY)
- if (umlIdentifyOneChrPTY(driver, dom,
- dom->def->consoles[i], "con") < 0)
- return -1;
-
- for (i = 0; i < dom->def->nserials; i++)
- if (dom->def->serials[i]->source->type == VIR_DOMAIN_CHR_TYPE_PTY &&
- umlIdentifyOneChrPTY(driver, dom,
- dom->def->serials[i], "ssl") < 0)
- return -1;
-
- return 0;
-}
-
-static void
-umlInotifyEvent(int watch,
- int fd,
- int events ATTRIBUTE_UNUSED,
- void *data)
-{
- char buf[1024];
- struct inotify_event e;
- int got;
- char *tmp, *name;
- struct uml_driver *driver = data;
- virDomainObjPtr dom;
- virObjectEventPtr event = NULL;
-
- umlDriverLock(driver);
- if (watch != driver->inotifyWatch)
- goto cleanup;
-
- reread:
- got = read(fd, buf, sizeof(buf));
- if (got == -1) {
- if (errno == EINTR)
- goto reread;
- goto cleanup;
- }
-
- tmp = buf;
- while (got) {
- if (got < sizeof(e))
- goto cleanup; /* bad */
-
- memcpy(&e, tmp, sizeof(e));
- tmp += sizeof(e);
- got -= sizeof(e);
-
- if (got < e.len)
- goto cleanup;
-
- tmp += e.len;
- got -= e.len;
-
- name = (char *)&(e.name);
-
- dom = virDomainObjListFindByName(driver->domains, name);
-
- if (!dom)
- continue;
-
- if (e.mask & IN_DELETE) {
- VIR_DEBUG("Got inotify domain shutdown '%s'", name);
- if (!virDomainObjIsActive(dom)) {
- virDomainObjEndAPI(&dom);
- continue;
- }
-
- umlShutdownVMDaemon(driver, dom, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
- virDomainAuditStop(dom, "shutdown");
- event = virDomainEventLifecycleNewFromObj(dom,
- VIR_DOMAIN_EVENT_STOPPED,
- VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);
- if (!dom->persistent)
- virDomainObjListRemove(driver->domains, dom);
- } else if (e.mask & (IN_CREATE | IN_MODIFY)) {
- VIR_DEBUG("Got inotify domain startup '%s'", name);
- if (virDomainObjIsActive(dom)) {
- virDomainObjEndAPI(&dom);
- continue;
- }
-
- if (umlReadPidFile(driver, dom) < 0) {
- virDomainObjEndAPI(&dom);
- continue;
- }
-
- dom->def->id = driver->nextvmid++;
-
- if (!driver->nactive && driver->inhibitCallback)
- driver->inhibitCallback(true, driver->inhibitOpaque);
- driver->nactive++;
-
- virDomainObjSetState(dom, VIR_DOMAIN_RUNNING,
- VIR_DOMAIN_RUNNING_BOOTED);
-
- if (umlOpenMonitor(driver, dom) < 0) {
- VIR_WARN("Could not open monitor for new domain");
- umlShutdownVMDaemon(driver, dom,
- VIR_DOMAIN_SHUTOFF_FAILED);
- virDomainAuditStop(dom, "failed");
- event = virDomainEventLifecycleNewFromObj(dom,
- VIR_DOMAIN_EVENT_STOPPED,
- VIR_DOMAIN_EVENT_STOPPED_FAILED);
- if (!dom->persistent)
- virDomainObjListRemove(driver->domains, dom);
- } else if (umlIdentifyChrPTY(driver, dom) < 0) {
- VIR_WARN("Could not identify character devices for new domain");
- umlShutdownVMDaemon(driver, dom,
- VIR_DOMAIN_SHUTOFF_FAILED);
- virDomainAuditStop(dom, "failed");
- event = virDomainEventLifecycleNewFromObj(dom,
- VIR_DOMAIN_EVENT_STOPPED,
- VIR_DOMAIN_EVENT_STOPPED_FAILED);
- if (!dom->persistent)
- virDomainObjListRemove(driver->domains, dom);
- }
- }
- virDomainObjEndAPI(&dom);
- virObjectEventStateQueue(driver->domainEventState, event);
- event = NULL;
- }
-
- cleanup:
- umlDriverUnlock(driver);
-}
-
-
-static int
-umlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
- const virDomainDef *def ATTRIBUTE_UNUSED,
- virCapsPtr caps ATTRIBUTE_UNUSED,
- unsigned int parseFlags ATTRIBUTE_UNUSED,
- void *opaque ATTRIBUTE_UNUSED,
- void *parseOpaque ATTRIBUTE_UNUSED)
-{
- if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
- dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
- dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)
- dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML;
-
- /* forbid capabilities mode hostdev in this kind of hypervisor */
- if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
- dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("hostdev mode 'capabilities' is not "
- "supported in %s"),
- virDomainVirtTypeToString(def->virtType));
- return -1;
- }
-
- return 0;
-}
-
-
-static int
-umlDomainDefPostParse(virDomainDefPtr def ATTRIBUTE_UNUSED,
- virCapsPtr caps ATTRIBUTE_UNUSED,
- unsigned int parseFlags ATTRIBUTE_UNUSED,
- void *opaque ATTRIBUTE_UNUSED,
- void *parseOpaque ATTRIBUTE_UNUSED)
-{
- return 0;
-}
-
-
-virDomainDefParserConfig umlDriverDomainDefParserConfig = {
- .devicesPostParseCallback = umlDomainDeviceDefPostParse,
- .domainPostParseCallback = umlDomainDefPostParse,
-};
-
-
-/**
- * umlStartup:
- *
- * Initialization function for the Uml daemon
- */
-static int
-umlStateInitialize(bool privileged,
- virStateInhibitCallback callback,
- void *opaque)
-{
- char *base = NULL;
- char *userdir = NULL;
-
- virDomainXMLPrivateDataCallbacks privcb = {
- .alloc = umlDomainObjPrivateAlloc,
- .free = umlDomainObjPrivateFree,
- };
-
- if (VIR_ALLOC(uml_driver) < 0)
- return -1;
-
- uml_driver->privileged = privileged;
- uml_driver->inhibitCallback = callback;
- uml_driver->inhibitOpaque = opaque;
-
- if (virMutexInit(¨_driver->lock) < 0) {
- VIR_FREE(uml_driver);
- return -1;
- }
- umlDriverLock(uml_driver);
-
- /* Don't have a dom0 so start from 1 */
- uml_driver->nextvmid = 1;
- uml_driver->inotifyWatch = -1;
-
- if (!(uml_driver->domains = virDomainObjListNew()))
- goto error;
-
- uml_driver->domainEventState = virObjectEventStateNew();
- if (!uml_driver->domainEventState)
- goto error;
-
- userdir = virGetUserDirectory();
- if (!userdir)
- goto error;
-
- if (privileged) {
- if (virAsprintf(¨_driver->logDir,
- "%s/log/libvirt/uml", LOCALSTATEDIR) == -1)
- goto out_of_memory;
-
- if (VIR_STRDUP(base, SYSCONFDIR "/libvirt") < 0)
- goto error;
-
- if (virAsprintf(¨_driver->monitorDir,
- "%s/run/libvirt/uml-guest", LOCALSTATEDIR) == -1)
- goto out_of_memory;
- } else {
- base = virGetUserConfigDirectory();
- if (!base)
- goto error;
-
- if (virAsprintf(¨_driver->logDir,
- "%s/uml/log", base) == -1)
- goto out_of_memory;
-
- if (virAsprintf(¨_driver->monitorDir,
- "%s/.uml", userdir) == -1)
- goto out_of_memory;
- }
-
- /* Configuration paths are either $XDG_CONFIG_HOME/libvirt/uml/... (session) or
- * /etc/libvirt/uml/... (system).
- */
- if (virAsprintf(¨_driver->configDir, "%s/uml", base) == -1)
- goto out_of_memory;
-
- if (virAsprintf(¨_driver->autostartDir, "%s/uml/autostart", base) == -1)
- goto out_of_memory;
-
- VIR_FREE(base);
-
- if ((uml_driver->caps = umlCapsInit()) == NULL)
- goto out_of_memory;
-
- if (!(uml_driver->xmlopt = virDomainXMLOptionNew(¨DriverDomainDefParserConfig,
- &privcb, NULL, NULL, NULL)))
- goto error;
-
- if ((uml_driver->inotifyFD = inotify_init()) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot initialize inotify"));
- goto error;
- }
-
- if (virFileMakePath(uml_driver->monitorDir) < 0) {
- virReportSystemError(errno, _("Failed to create monitor directory %s"),
- uml_driver->monitorDir);
- goto error;
- }
-
- VIR_INFO("Adding inotify watch on %s", uml_driver->monitorDir);
- if (inotify_add_watch(uml_driver->inotifyFD,
- uml_driver->monitorDir,
- IN_CREATE | IN_MODIFY | IN_DELETE) < 0) {
- virReportSystemError(errno, _("Failed to create inotify watch on %s"),
- uml_driver->monitorDir);
- goto error;
- }
-
- if ((uml_driver->inotifyWatch =
- virEventAddHandle(uml_driver->inotifyFD, POLLIN,
- umlInotifyEvent, uml_driver, NULL)) < 0)
- goto error;
-
- if (umlProcessAutoDestroyInit(uml_driver) < 0)
- goto error;
-
- if (virDomainObjListLoadAllConfigs(uml_driver->domains,
- uml_driver->configDir,
- uml_driver->autostartDir, false,
- uml_driver->caps,
- uml_driver->xmlopt,
- NULL, NULL) < 0)
- goto error;
-
- umlDriverUnlock(uml_driver);
-
- VIR_FREE(userdir);
-
- return 0;
-
- out_of_memory:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("umlStartup: out of memory"));
-
- error:
- VIR_FREE(userdir);
- VIR_FREE(base);
- umlDriverUnlock(uml_driver);
- umlStateCleanup();
- return -1;
-}
-
-/**
- * umlStateAutoStart:
- *
- * Function to autostart the Uml daemons
- */
-static void
-umlStateAutoStart(void)
-{
- if (!uml_driver)
- return;
-
- umlAutostartConfigs(uml_driver);
-}
-
-static void umlNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
-{
- struct uml_driver *driver = opaque;
-
- if (newVM) {
- virObjectEventPtr event =
- virDomainEventLifecycleNewFromObj(vm,
- VIR_DOMAIN_EVENT_DEFINED,
- VIR_DOMAIN_EVENT_DEFINED_ADDED);
- virObjectEventStateQueue(driver->domainEventState, event);
- }
-}
-
-
-/**
- * umlStateReload:
- *
- * Function to restart the Uml daemon, it will recheck the configuration
- * files and update its state and the networking
- */
-static int
-umlStateReload(void)
-{
- if (!uml_driver)
- return 0;
-
- umlDriverLock(uml_driver);
- virDomainObjListLoadAllConfigs(uml_driver->domains,
- uml_driver->configDir,
- uml_driver->autostartDir, false,
- uml_driver->caps,
- uml_driver->xmlopt,
- umlNotifyLoadDomain, uml_driver);
- umlDriverUnlock(uml_driver);
-
- return 0;
-}
-
-
-static int
-umlShutdownOneVM(virDomainObjPtr dom, void *opaque)
-{
- struct uml_driver *driver = opaque;
-
- virObjectLock(dom);
- if (virDomainObjIsActive(dom)) {
- umlShutdownVMDaemon(driver, dom, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
- virDomainAuditStop(dom, "shutdown");
- }
- virObjectUnlock(dom);
- return 0;
-}
-
-/**
- * umlStateCleanup:
- *
- * Shutdown the Uml daemon, it will stop all active domains and networks
- */
-static int
-umlStateCleanup(void)
-{
- if (!uml_driver)
- return -1;
-
- umlDriverLock(uml_driver);
- if (uml_driver->inotifyWatch != -1)
- virEventRemoveHandle(uml_driver->inotifyWatch);
- VIR_FORCE_CLOSE(uml_driver->inotifyFD);
- virObjectUnref(uml_driver->caps);
- virObjectUnref(uml_driver->xmlopt);
-
- /* shutdown active VMs
- * XXX allow them to stay around & reconnect */
- virDomainObjListForEach(uml_driver->domains, umlShutdownOneVM, uml_driver);
-
- virObjectUnref(uml_driver->domains);
-
- virObjectUnref(uml_driver->domainEventState);
-
- VIR_FREE(uml_driver->logDir);
- VIR_FREE(uml_driver->configDir);
- VIR_FREE(uml_driver->autostartDir);
- VIR_FREE(uml_driver->monitorDir);
-
- umlProcessAutoDestroyShutdown(uml_driver);
-
- umlDriverUnlock(uml_driver);
- virMutexDestroy(¨_driver->lock);
- VIR_FREE(uml_driver);
-
- return 0;
-}
-
-
-static int umlProcessAutoDestroyInit(struct uml_driver *driver)
-{
- if (!(driver->autodestroy = virHashCreate(5, NULL)))
- return -1;
-
- return 0;
-}
-
-struct umlProcessAutoDestroyData {
- struct uml_driver *driver;
- virConnectPtr conn;
-};
-
-static int umlProcessAutoDestroyDom(void *payload,
- const void *name,
- void *opaque)
-{
- struct umlProcessAutoDestroyData *data = opaque;
- virConnectPtr conn = payload;
- const char *uuidstr = name;
- unsigned char uuid[VIR_UUID_BUFLEN];
- virDomainObjPtr dom;
- virObjectEventPtr event = NULL;
-
- VIR_DEBUG("conn=%p uuidstr=%s thisconn=%p", conn, uuidstr, data->conn);
-
- if (data->conn != conn)
- return 0;
-
- if (virUUIDParse(uuidstr, uuid) < 0) {
- VIR_WARN("Failed to parse %s", uuidstr);
- return 0;
- }
-
- if (!(dom = virDomainObjListFindByUUID(data->driver->domains, uuid))) {
- VIR_DEBUG("No domain object to kill");
- return 0;
- }
-
- VIR_DEBUG("Killing domain");
- umlShutdownVMDaemon(data->driver, dom, VIR_DOMAIN_SHUTOFF_DESTROYED);
- virDomainAuditStop(dom, "destroyed");
- event = virDomainEventLifecycleNewFromObj(dom,
- VIR_DOMAIN_EVENT_STOPPED,
- VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
-
- if (!dom->persistent)
- virDomainObjListRemove(data->driver->domains, dom);
-
- virDomainObjEndAPI(&dom);
- virObjectEventStateQueue(data->driver->domainEventState, event);
- virHashRemoveEntry(data->driver->autodestroy, uuidstr);
- return 0;
-}
-
-/*
- * Precondition: driver is locked
- */
-static void umlProcessAutoDestroyRun(struct uml_driver *driver, virConnectPtr conn)
-{
- struct umlProcessAutoDestroyData data = {
- driver, conn
- };
- VIR_DEBUG("conn=%p", conn);
- virHashForEach(driver->autodestroy, umlProcessAutoDestroyDom, &data);
-}
-
-static void umlProcessAutoDestroyShutdown(struct uml_driver *driver)
-{
- virHashFree(driver->autodestroy);
-}
-
-static int umlProcessAutoDestroyAdd(struct uml_driver *driver,
- virDomainObjPtr vm,
- virConnectPtr conn)
-{
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(vm->def->uuid, uuidstr);
- VIR_DEBUG("vm=%s uuid=%s conn=%p", vm->def->name, uuidstr, conn);
- if (virHashAddEntry(driver->autodestroy, uuidstr, conn) < 0)
- return -1;
- return 0;
-}
-
-static int umlProcessAutoDestroyRemove(struct uml_driver *driver,
- virDomainObjPtr vm)
-{
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(vm->def->uuid, uuidstr);
- VIR_DEBUG("vm=%s uuid=%s", vm->def->name, uuidstr);
- if (virHashRemoveEntry(driver->autodestroy, uuidstr) < 0)
- return -1;
- return 0;
-}
-
-
-static int umlReadPidFile(struct uml_driver *driver,
- virDomainObjPtr vm)
-{
- int rc = -1;
- FILE *file;
- char *pidfile = NULL;
- int retries = 0;
-
- vm->pid = -1;
- if (virAsprintf(&pidfile, "%s/%s/pid",
- driver->monitorDir, vm->def->name) < 0)
- return -1;
-
- reopen:
- if (!(file = fopen(pidfile, "r"))) {
- if (errno == ENOENT &&
- retries++ < 50) {
- usleep(1000 * 100);
- goto reopen;
- }
- goto cleanup;
- }
-
- if (fscanf(file, "%d", &vm->pid) != 1) {
- errno = EINVAL;
- VIR_FORCE_FCLOSE(file);
- goto cleanup;
- }
-
- if (VIR_FCLOSE(file) < 0)
- goto cleanup;
-
- rc = 0;
-
- cleanup:
- if (rc != 0)
- virReportSystemError(errno,
- _("failed to read pid: %s"),
- pidfile);
- VIR_FREE(pidfile);
- return rc;
-}
-
-static int umlMonitorAddress(const struct uml_driver *driver,
- const virDomainObj *vm,
- struct sockaddr_un *addr)
-{
- char *sockname;
- int retval = 0;
-
- if (virAsprintf(&sockname, "%s/%s/mconsole",
- driver->monitorDir, vm->def->name) < 0)
- return -1;
-
- memset(addr, 0, sizeof(*addr));
- addr->sun_family = AF_UNIX;
- if (virStrcpyStatic(addr->sun_path, sockname) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unix path %s too long for destination"), sockname);
- retval = -1;
- }
- VIR_FREE(sockname);
- return retval;
-}
-
-static int umlOpenMonitor(struct uml_driver *driver,
- virDomainObjPtr vm)
-{
- struct sockaddr_un addr;
- struct stat sb;
- int retries = 0;
- umlDomainObjPrivatePtr priv = vm->privateData;
-
- if (umlMonitorAddress(driver, vm, &addr) < 0)
- return -1;
-
- VIR_DEBUG("Dest address for monitor is '%s'", addr.sun_path);
- restat:
- if (stat(addr.sun_path, &sb) < 0) {
- if (errno == ENOENT &&
- retries++ < 50) {
- usleep(1000 * 100);
- goto restat;
- }
- return -1;
- }
-
- if ((priv->monitor = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0) {
- virReportSystemError(errno,
- "%s", _("cannot open socket"));
- return -1;
- }
-
- memset(addr.sun_path, 0, sizeof(addr.sun_path));
- snprintf(addr.sun_path + 1, sizeof(addr.sun_path) - 1,
- "libvirt-uml-%u", vm->pid);
- VIR_DEBUG("Reply address for monitor is '%s'", addr.sun_path+1);
- if (bind(priv->monitor, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- virReportSystemError(errno,
- "%s", _("cannot bind socket"));
- VIR_FORCE_CLOSE(priv->monitor);
- return -1;
- }
-
- return 0;
-}
-
-
-#define MONITOR_MAGIC 0xcafebabe
-#define MONITOR_BUFLEN 512
-#define MONITOR_VERSION 2
-
-struct monitor_request {
- uint32_t magic;
- uint32_t version;
- uint32_t length;
- char data[MONITOR_BUFLEN];
-};
-
-struct monitor_response {
- uint32_t error;
- uint32_t extra;
- uint32_t length;
- char data[MONITOR_BUFLEN];
-};
-
-
-static int umlMonitorCommand(const struct uml_driver *driver,
- const virDomainObj *vm,
- const char *cmd,
- char **reply)
-{
- struct monitor_request req;
- struct monitor_response res;
- char *retdata = NULL;
- int retlen = 0, ret = 0;
- struct sockaddr_un addr;
- unsigned int addrlen;
- umlDomainObjPrivatePtr priv = vm->privateData;
-
- VIR_DEBUG("Run command '%s'", cmd);
-
- *reply = NULL;
-
- if (umlMonitorAddress(driver, vm, &addr) < 0)
- return -1;
-
- memset(&req, 0, sizeof(req));
- req.magic = MONITOR_MAGIC;
- req.version = MONITOR_VERSION;
- req.length = strlen(cmd);
- if (req.length > (MONITOR_BUFLEN-1)) {
- virReportSystemError(EINVAL,
- _("cannot send too long command %s (%d bytes)"),
- cmd, req.length);
- return -1;
- }
- if (virStrcpyStatic(req.data, cmd) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Command %s too long for destination"), cmd);
- return -1;
- }
-
- if (sendto(priv->monitor, &req, sizeof(req), 0,
- (struct sockaddr *)&addr, sizeof(addr)) != sizeof(req)) {
- virReportSystemError(errno,
- _("cannot send command %s"),
- cmd);
- return -1;
- }
-
- do {
- ssize_t nbytes;
- addrlen = sizeof(addr);
- nbytes = recvfrom(priv->monitor, &res, sizeof(res), 0,
- (struct sockaddr *)&addr, &addrlen);
- if (nbytes < 0) {
- if (errno == EAGAIN || errno == EINTR)
- continue;
- virReportSystemError(errno, _("cannot read reply %s"), cmd);
- goto error;
- }
- /* Ensure res.length is safe to read before validating its value. */
- if (nbytes < offsetof(struct monitor_request, data) ||
- nbytes < offsetof(struct monitor_request, data) + res.length) {
- virReportSystemError(0, _("incomplete reply %s"), cmd);
- goto error;
- }
-
- if (VIR_REALLOC_N(retdata, retlen + res.length) < 0)
- goto error;
- memcpy(retdata + retlen, res.data, res.length);
- retlen += res.length - 1;
- retdata[retlen] = '\0';
-
- if (res.error)
- ret = -1;
-
- } while (res.extra);
-
- VIR_DEBUG("Command reply is '%s'", NULLSTR(retdata));
-
- if (ret < 0)
- VIR_FREE(retdata);
- else
- *reply = retdata;
-
- return ret;
-
- error:
- VIR_FREE(retdata);
- return -1;
-}
-
-
-static void umlCleanupTapDevices(virDomainObjPtr vm)
-{
- size_t i;
-
- for (i = 0; i < vm->def->nnets; i++) {
- virDomainNetDefPtr def = vm->def->nets[i];
-
- if (def->type != VIR_DOMAIN_NET_TYPE_BRIDGE &&
- def->type != VIR_DOMAIN_NET_TYPE_NETWORK)
- continue;
-
- ignore_value(virNetDevTapDelete(def->ifname,
- def->backend.tap));
- }
-}
-
-static int umlStartVMDaemon(virConnectPtr conn,
- struct uml_driver *driver,
- virDomainObjPtr vm,
- bool autoDestroy)
-{
- int ret = -1;
- char *logfile;
- int logfd = -1;
- umlDomainObjPrivatePtr priv = vm->privateData;
- virCommandPtr cmd = NULL;
- size_t i;
-
- if (virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("VM is already active"));
- return -1;
- }
-
- if (!vm->def->os.kernel) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("no kernel specified"));
- return -1;
- }
- /* Make sure the binary we are about to try exec'ing exists.
- * Technically we could catch the exec() failure, but that's
- * in a sub-process so its hard to feed back a useful error
- */
- if (!virFileIsExecutable(vm->def->os.kernel)) {
- virReportSystemError(errno,
- _("Cannot find UML kernel %s"),
- vm->def->os.kernel);
- return -1;
- }
-
- if (virFileMakePath(driver->logDir) < 0) {
- virReportSystemError(errno,
- _("cannot create log directory %s"),
- driver->logDir);
- return -1;
- }
-
- if (virAsprintf(&logfile, "%s/%s.log",
- driver->logDir, vm->def->name) < 0)
- return -1;
-
- if ((logfd = open(logfile, O_CREAT | O_TRUNC | O_WRONLY,
- S_IRUSR | S_IWUSR)) < 0) {
- virReportSystemError(errno,
- _("failed to create logfile %s"),
- logfile);
- VIR_FREE(logfile);
- return -1;
- }
- VIR_FREE(logfile);
-
- if (virSetCloseExec(logfd) < 0) {
- virReportSystemError(errno, "%s",
- _("Unable to set VM logfile close-on-exec flag"));
- VIR_FORCE_CLOSE(logfd);
- return -1;
- }
-
- /* Do this upfront, so any part of the startup process can add
- * runtime state to vm->def that won't be persisted. This let's us
- * report implicit runtime defaults in the XML, like vnc listen/socket
- */
- VIR_DEBUG("Setting current domain def as transient");
- if (virDomainObjSetDefTransient(driver->caps, driver->xmlopt, vm) < 0) {
- VIR_FORCE_CLOSE(logfd);
- return -1;
- }
-
- if (!(cmd = umlBuildCommandLine(conn, driver, vm)))
- goto cleanup;
-
- for (i = 0; i < vm->def->nconsoles; i++) {
- VIR_FREE(vm->def->consoles[i]->info.alias);
- if (virAsprintf(&vm->def->consoles[i]->info.alias, "console%zu", i) < 0)
- goto cleanup;
- }
-
- virCommandWriteArgLog(cmd, logfd);
-
- priv->monitor = -1;
-
- virCommandClearCaps(cmd);
- virCommandSetOutputFD(cmd, &logfd);
- virCommandSetErrorFD(cmd, &logfd);
- virCommandDaemonize(cmd);
-
- if (virCommandRun(cmd, NULL) < 0)
- goto cleanup;
-
- if (autoDestroy &&
- umlProcessAutoDestroyAdd(driver, vm, conn) < 0)
- goto cleanup;
-
- ret = 0;
- cleanup:
- VIR_FORCE_CLOSE(logfd);
- virCommandFree(cmd);
-
- if (ret < 0) {
- virDomainConfVMNWFilterTeardown(vm);
- umlCleanupTapDevices(vm);
- virDomainObjRemoveTransientDef(vm);
- }
-
- /* NB we don't mark it running here - we do that async
- with inotify */
- /* XXX what if someone else tries to start it again
- before we get the inotification ? Sounds like
- trouble.... */
- /* XXX this is bad for events too. must fix this better */
-
- return ret;
-}
-
-static void umlShutdownVMDaemon(struct uml_driver *driver,
- virDomainObjPtr vm,
- virDomainShutoffReason reason)
-{
- int ret;
- umlDomainObjPrivatePtr priv = vm->privateData;
-
- if (!virDomainObjIsActive(vm))
- return;
-
- virProcessKill(vm->pid, SIGTERM);
-
- VIR_FORCE_CLOSE(priv->monitor);
-
- if ((ret = waitpid(vm->pid, NULL, 0)) != vm->pid) {
- VIR_WARN("Got unexpected pid %d != %d",
- ret, vm->pid);
- }
-
- vm->pid = -1;
- vm->def->id = -1;
- virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason);
-
- virDomainConfVMNWFilterTeardown(vm);
- umlCleanupTapDevices(vm);
-
- /* Stop autodestroy in case guest is restarted */
- umlProcessAutoDestroyRemove(driver, vm);
-
- virDomainObjRemoveTransientDef(vm);
-
- driver->nactive--;
- if (!driver->nactive && driver->inhibitCallback)
- driver->inhibitCallback(false, driver->inhibitOpaque);
-}
-
-
-static int umlConnectURIProbe(char **uri)
-{
- if (uml_driver == NULL)
- return 0;
-
- return VIR_STRDUP(*uri, uml_driver->privileged ?
- "uml:///system" :
- "uml:///session");
-}
-
-
-static virDrvOpenStatus umlConnectOpen(virConnectPtr conn,
- virConnectAuthPtr auth ATTRIBUTE_UNUSED,
- virConfPtr conf ATTRIBUTE_UNUSED,
- unsigned int flags)
-{
- virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
-
- /* URI was good, but driver isn't active */
- if (uml_driver == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("uml state driver is not active"));
- 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:///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;
- }
- }
-
- if (virConnectOpenEnsureACL(conn) < 0)
- return VIR_DRV_OPEN_ERROR;
-
- conn->privateData = uml_driver;
-
- return VIR_DRV_OPEN_SUCCESS;
-}
-
-static int umlConnectClose(virConnectPtr conn)
-{
- struct uml_driver *driver = conn->privateData;
-
- umlDriverLock(driver);
- umlProcessAutoDestroyRun(driver, conn);
- umlDriverUnlock(driver);
-
- conn->privateData = NULL;
-
- return 0;
-}
-
-static const char *umlConnectGetType(virConnectPtr conn) {
- if (virConnectGetTypeEnsureACL(conn) < 0)
- return NULL;
-
- return "UML";
-}
-
-
-static int umlConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED)
-{
- /* Trivially secure, since always inside the daemon */
- return 1;
-}
-
-
-static int umlConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
-{
- /* Not encrypted, but remote driver takes care of that */
- return 0;
-}
-
-
-static int umlConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
-{
- return 1;
-}
-
-
-static char *umlConnectGetCapabilities(virConnectPtr conn) {
- struct uml_driver *driver = (struct uml_driver *)conn->privateData;
- char *xml;
-
- if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
- return NULL;
-
- umlDriverLock(driver);
- xml = virCapabilitiesFormatXML(driver->caps);
- umlDriverUnlock(driver);
-
- return xml;
-}
-
-
-
-static int umlGetProcessInfo(unsigned long long *cpuTime, pid_t pid)
-{
- char *proc;
- FILE *pidinfo;
- unsigned long long usertime, systime;
-
- if (virAsprintf(&proc, "/proc/%lld/stat", (long long)pid) < 0)
- return -1;
-
- if (!(pidinfo = fopen(proc, "r"))) {
- /* VM probably shut down, so fake 0 */
- *cpuTime = 0;
- VIR_FREE(proc);
- return 0;
- }
-
- VIR_FREE(proc);
-
- if (fscanf(pidinfo, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %llu %llu", &usertime, &systime) != 2) {
- umlDebug("not enough arg");
- VIR_FORCE_FCLOSE(pidinfo);
- return -1;
- }
-
- /* We got jiffies
- * We want nanoseconds
- * _SC_CLK_TCK is jiffies per second
- * So calculate thus....
- */
- *cpuTime = 1000ull * 1000ull * 1000ull * (usertime + systime) / (unsigned long long)sysconf(_SC_CLK_TCK);
-
- umlDebug("Got %llu %llu %llu", usertime, systime, *cpuTime);
-
- VIR_FORCE_FCLOSE(pidinfo);
-
- return 0;
-}
-
-
-static virDomainPtr umlDomainLookupByID(virConnectPtr conn,
- int id)
-{
- struct uml_driver *driver = (struct uml_driver *)conn->privateData;
- virDomainObjPtr vm;
- virDomainPtr dom = NULL;
-
- umlDriverLock(driver);
- vm = virDomainObjListFindByID(driver->domains, id);
- umlDriverUnlock(driver);
-
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching id '%d'"), id);
- goto cleanup;
- }
-
- if (virDomainLookupByIDEnsureACL(conn, vm->def) < 0)
- goto cleanup;
-
- dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return dom;
-}
-
-static virDomainPtr umlDomainLookupByUUID(virConnectPtr conn,
- const unsigned char *uuid)
-{
- struct uml_driver *driver = (struct uml_driver *)conn->privateData;
- virDomainObjPtr vm;
- virDomainPtr dom = NULL;
-
- if (!(vm = umlDomObjFromDomain(driver, uuid)))
- return NULL;
-
- if (virDomainLookupByUUIDEnsureACL(conn, vm->def) < 0)
- goto cleanup;
-
- dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return dom;
-}
-
-static virDomainPtr umlDomainLookupByName(virConnectPtr conn,
- const char *name)
-{
- struct uml_driver *driver = (struct uml_driver *)conn->privateData;
- virDomainObjPtr vm;
- virDomainPtr dom = NULL;
-
- umlDriverLock(driver);
- vm = virDomainObjListFindByName(driver->domains, name);
- umlDriverUnlock(driver);
-
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching name '%s'"), name);
- goto cleanup;
- }
-
- if (virDomainLookupByNameEnsureACL(conn, vm->def) < 0)
- goto cleanup;
-
- dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return dom;
-}
-
-
-static int umlDomainIsActive(virDomainPtr dom)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr obj;
- int ret = -1;
-
- if (!(obj = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainIsActiveEnsureACL(dom->conn, obj->def) < 0)
- goto cleanup;
-
- ret = virDomainObjIsActive(obj);
-
- cleanup:
- virDomainObjEndAPI(&obj);
- return ret;
-}
-
-
-static int umlDomainIsPersistent(virDomainPtr dom)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr obj;
- int ret = -1;
-
- if (!(obj = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainIsPersistentEnsureACL(dom->conn, obj->def) < 0)
- goto cleanup;
-
- ret = obj->persistent;
-
- cleanup:
- virDomainObjEndAPI(&obj);
- return ret;
-}
-
-static int umlDomainIsUpdated(virDomainPtr dom)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr obj;
- int ret = -1;
-
- if (!(obj = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainIsUpdatedEnsureACL(dom->conn, obj->def) < 0)
- goto cleanup;
-
- ret = obj->updated;
-
- cleanup:
- virDomainObjEndAPI(&obj);
- return ret;
-}
-
-static int umlConnectGetVersion(virConnectPtr conn, unsigned long *version)
-{
- struct uml_driver *driver = conn->privateData;
- struct utsname ut;
- int ret = -1;
-
- if (virConnectGetVersionEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
-
- if (driver->umlVersion == 0) {
- uname(&ut);
-
- if (virParseVersionString(ut.release, &driver->umlVersion, true) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot parse version %s"), ut.release);
- goto cleanup;
- }
- }
-
- *version = driver->umlVersion;
- ret = 0;
-
- cleanup:
- umlDriverUnlock(driver);
- return ret;
-}
-
-
-static char *umlConnectGetHostname(virConnectPtr conn)
-{
- if (virConnectGetHostnameEnsureACL(conn) < 0)
- return NULL;
-
- return virGetHostname();
-}
-
-
-static int umlConnectListDomains(virConnectPtr conn, int *ids, int nids)
-{
- struct uml_driver *driver = conn->privateData;
- int n;
-
- if (virConnectListDomainsEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- n = virDomainObjListGetActiveIDs(driver->domains, ids, nids,
- virConnectListDomainsCheckACL, conn);
- umlDriverUnlock(driver);
-
- return n;
-}
-static int umlConnectNumOfDomains(virConnectPtr conn)
-{
- struct uml_driver *driver = conn->privateData;
- int n;
-
- if (virConnectNumOfDomainsEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- n = virDomainObjListNumOfDomains(driver->domains, true,
- virConnectNumOfDomainsCheckACL, conn);
- umlDriverUnlock(driver);
-
- return n;
-}
-static virDomainPtr umlDomainCreateXML(virConnectPtr conn, const char *xml,
- unsigned int flags)
-{
- struct uml_driver *driver = conn->privateData;
- virDomainDefPtr def;
- virDomainObjPtr vm = NULL;
- virDomainPtr dom = NULL;
- virObjectEventPtr event = NULL;
- unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
-
- virCheckFlags(VIR_DOMAIN_START_AUTODESTROY |
- VIR_DOMAIN_START_VALIDATE, NULL);
-
- if (flags & VIR_DOMAIN_START_VALIDATE)
- parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
-
- virNWFilterReadLockFilterUpdates();
- umlDriverLock(driver);
- if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
- NULL, parse_flags)))
- goto cleanup;
-
- if (virDomainCreateXMLEnsureACL(conn, def) < 0)
- goto cleanup;
-
- if (!(vm = virDomainObjListAdd(driver->domains, def,
- driver->xmlopt,
- VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
- VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
- NULL)))
- goto cleanup;
- def = NULL;
-
- if (umlStartVMDaemon(conn, driver, vm,
- (flags & VIR_DOMAIN_START_AUTODESTROY)) < 0) {
- virDomainAuditStart(vm, "booted", false);
- if (!vm->persistent)
- virDomainObjListRemove(driver->domains, vm);
- goto cleanup;
- }
- virDomainAuditStart(vm, "booted", true);
- event = virDomainEventLifecycleNewFromObj(vm,
- VIR_DOMAIN_EVENT_STARTED,
- VIR_DOMAIN_EVENT_STARTED_BOOTED);
-
- dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
-
- cleanup:
- virDomainDefFree(def);
- virDomainObjEndAPI(&vm);
- virObjectEventStateQueue(driver->domainEventState, event);
- umlDriverUnlock(driver);
- virNWFilterUnlockFilterUpdates();
- return dom;
-}
-
-
-static int umlDomainShutdownFlags(virDomainPtr dom,
- unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- char *info = NULL;
- int ret = -1;
-
- virCheckFlags(0, -1);
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
- goto cleanup;
-
-#if 0
- if (umlMonitorCommand(driver, vm, "system_powerdown", &info) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("shutdown operation failed"));
- goto cleanup;
- }
- ret = 0;
-#endif
-
- cleanup:
- VIR_FREE(info);
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-static int
-umlDomainShutdown(virDomainPtr dom)
-{
- return umlDomainShutdownFlags(dom, 0);
-}
-
-static int
-umlDomainDestroyFlags(virDomainPtr dom,
- unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- virObjectEventPtr event = NULL;
- int ret = -1;
-
- virCheckFlags(0, -1);
-
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- return -1;
-
- if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- umlShutdownVMDaemon(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED);
- virDomainAuditStop(vm, "destroyed");
- event = virDomainEventLifecycleNewFromObj(vm,
- VIR_DOMAIN_EVENT_STOPPED,
- VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
- if (!vm->persistent)
- virDomainObjListRemove(driver->domains, vm);
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- virObjectEventStateQueue(driver->domainEventState, event);
- umlDriverUnlock(driver);
- return ret;
-}
-
-
-static int umlDomainDestroy(virDomainPtr dom)
-{
- return umlDomainDestroyFlags(dom, 0);
-}
-
-
-static char *umlDomainGetOSType(virDomainPtr dom) {
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- char *type = NULL;
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return NULL;
-
- if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (VIR_STRDUP(type, virDomainOSTypeToString(vm->def->os.type)) < 0)
- goto cleanup;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return type;
-}
-
-/* Returns max memory in kb, 0 if error */
-static unsigned long long
-umlDomainGetMaxMemory(virDomainPtr dom)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- unsigned long long ret = 0;
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainGetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- ret = virDomainDefGetMemoryTotal(vm->def);
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-static int umlDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret = -1;
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainSetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (newmax < vm->def->mem.cur_balloon) {
- virReportError(VIR_ERR_INVALID_ARG, "%s",
- _("cannot set max memory lower than current memory"));
- goto cleanup;
- }
-
- virDomainDefSetMemoryTotal(vm->def, newmax);
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-static int umlDomainSetMemory(virDomainPtr dom, unsigned long newmem)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret = -1;
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainSetMemoryEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("cannot set memory of an active domain"));
- goto cleanup;
- }
-
- if (newmem > virDomainDefGetMemoryTotal(vm->def)) {
- virReportError(VIR_ERR_INVALID_ARG, "%s",
- _("cannot set memory higher than max memory"));
- goto cleanup;
- }
-
- vm->def->mem.cur_balloon = newmem;
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-static int umlDomainGetInfo(virDomainPtr dom,
- virDomainInfoPtr info)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret = -1;
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainGetInfoEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- info->state = virDomainObjGetState(vm, NULL);
-
- if (!virDomainObjIsActive(vm)) {
- info->cpuTime = 0;
- } else {
- if (umlGetProcessInfo(&(info->cpuTime), vm->pid) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("cannot read cputime for domain"));
- goto cleanup;
- }
- }
-
- info->maxMem = virDomainDefGetMemoryTotal(vm->def);
- info->memory = vm->def->mem.cur_balloon;
- info->nrVirtCpu = virDomainDefGetVcpus(vm->def);
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-
-static int
-umlDomainGetState(virDomainPtr dom,
- int *state,
- int *reason,
- unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret = -1;
-
- virCheckFlags(0, -1);
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainGetStateEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- *state = virDomainObjGetState(vm, reason);
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-
-static char *umlDomainGetXMLDesc(virDomainPtr dom,
- unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- char *ret = NULL;
-
- /* Flags checked by virDomainDefFormat */
-
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainGetXMLDescEnsureACL(dom->conn, vm->def, flags) < 0)
- goto cleanup;
-
- ret = virDomainDefFormat((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef ?
- vm->newDef : vm->def, driver->caps,
- virDomainDefFormatConvertXMLFlags(flags));
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-
-static int umlConnectListDefinedDomains(virConnectPtr conn,
- char **const names, int nnames) {
- struct uml_driver *driver = conn->privateData;
- int n;
-
- if (virConnectListDefinedDomainsEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- n = virDomainObjListGetInactiveNames(driver->domains, names, nnames,
- virConnectListDefinedDomainsCheckACL, conn);
- umlDriverUnlock(driver);
-
- return n;
-}
-
-static int umlConnectNumOfDefinedDomains(virConnectPtr conn)
-{
- struct uml_driver *driver = conn->privateData;
- int n;
-
- if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- n = virDomainObjListNumOfDomains(driver->domains, false,
- virConnectNumOfDefinedDomainsCheckACL, conn);
- umlDriverUnlock(driver);
-
- return n;
-}
-
-
-static int umlDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- virObjectEventPtr event = NULL;
- int ret = -1;
-
- virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, -1);
-
- virNWFilterReadLockFilterUpdates();
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- ret = umlStartVMDaemon(dom->conn, driver, vm,
- (flags & VIR_DOMAIN_START_AUTODESTROY));
- virDomainAuditStart(vm, "booted", ret >= 0);
- if (ret == 0)
- event = virDomainEventLifecycleNewFromObj(vm,
- VIR_DOMAIN_EVENT_STARTED,
- VIR_DOMAIN_EVENT_STARTED_BOOTED);
-
- cleanup:
- virDomainObjEndAPI(&vm);
- virObjectEventStateQueue(driver->domainEventState, event);
- umlDriverUnlock(driver);
- virNWFilterUnlockFilterUpdates();
- return ret;
-}
-
-static int umlDomainCreate(virDomainPtr dom)
-{
- return umlDomainCreateWithFlags(dom, 0);
-}
-
-static virDomainPtr
-umlDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
-{
- struct uml_driver *driver = conn->privateData;
- virDomainDefPtr def;
- virDomainObjPtr vm = NULL;
- virDomainPtr dom = NULL;
- unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
-
- virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
-
- if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
- parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
-
- umlDriverLock(driver);
- if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
- NULL, parse_flags)))
- goto cleanup;
-
- if (virXMLCheckIllegalChars("name", def->name, "\n") < 0)
- goto cleanup;
-
- if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
- goto cleanup;
-
- if (!(vm = virDomainObjListAdd(driver->domains, def,
- driver->xmlopt,
- 0, NULL)))
- goto cleanup;
- def = NULL;
- vm->persistent = 1;
-
- if (virDomainSaveConfig(driver->configDir, driver->caps,
- vm->newDef ? vm->newDef : vm->def) < 0) {
- virDomainObjListRemove(driver->domains, vm);
- goto cleanup;
- }
-
- dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
-
- cleanup:
- virDomainDefFree(def);
- virDomainObjEndAPI(&vm);
- umlDriverUnlock(driver);
- return dom;
-}
-
-static virDomainPtr
-umlDomainDefineXML(virConnectPtr conn, const char *xml)
-{
- return umlDomainDefineXMLFlags(conn, xml, 0);
-}
-
-static int umlDomainUndefineFlags(virDomainPtr dom,
- unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret = -1;
-
- virCheckFlags(0, -1);
-
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainUndefineFlagsEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (!vm->persistent) {
- virReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("cannot undefine transient domain"));
- goto cleanup;
- }
-
- if (virDomainDeleteConfig(driver->configDir, driver->autostartDir, vm) < 0)
- goto cleanup;
-
- if (virDomainObjIsActive(vm))
- vm->persistent = 0;
- else
- virDomainObjListRemove(driver->domains, vm);
-
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- umlDriverUnlock(driver);
- return ret;
-}
-
-
-static int umlDomainUndefine(virDomainPtr dom)
-{
- return umlDomainUndefineFlags(dom, 0);
-}
-
-static int umlDomainAttachUmlDisk(struct uml_driver *driver,
- virDomainObjPtr vm,
- virDomainDiskDefPtr disk)
-{
- size_t i;
- char *cmd = NULL;
- char *reply = NULL;
-
- for (i = 0; i < vm->def->ndisks; i++) {
- if (STREQ(vm->def->disks[i]->dst, disk->dst)) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("target %s already exists"), disk->dst);
- return -1;
- }
- }
-
- if (!virDomainDiskGetSource(disk)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("disk source path is missing"));
- goto error;
- }
-
- if (virAsprintf(&cmd, "config %s=%s", disk->dst,
- virDomainDiskGetSource(disk)) < 0)
- return -1;
-
- if (umlMonitorCommand(driver, vm, cmd, &reply) < 0)
- goto error;
-
- if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0)
- goto error;
-
- virDomainDiskInsertPreAlloced(vm->def, disk);
-
- VIR_FREE(reply);
- VIR_FREE(cmd);
-
- return 0;
-
- error:
-
- VIR_FREE(reply);
- VIR_FREE(cmd);
-
- return -1;
-}
-
-
-static int umlDomainAttachDevice(virDomainPtr dom, const char *xml)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- virDomainDeviceDefPtr dev = NULL;
- int ret = -1;
-
- umlDriverLock(driver);
-
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainAttachDeviceEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (!virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("cannot attach device on inactive domain"));
- goto cleanup;
- }
-
- dev = virDomainDeviceDefParse(xml, vm->def, driver->caps, driver->xmlopt,
- VIR_DOMAIN_DEF_PARSE_INACTIVE);
-
- if (dev == NULL)
- goto cleanup;
-
- if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
- if (dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_UML) {
- ret = umlDomainAttachUmlDisk(driver, vm, dev->data.disk);
- if (ret == 0)
- dev->data.disk = NULL;
- } else {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("disk bus '%s' cannot be hotplugged."),
- virDomainDiskBusTypeToString(dev->data.disk->bus));
- }
- } else {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("device type '%s' cannot be attached"),
- virDomainDeviceTypeToString(dev->type));
- goto cleanup;
- }
-
- cleanup:
-
- virDomainDeviceDefFree(dev);
- virDomainObjEndAPI(&vm);
- umlDriverUnlock(driver);
- return ret;
-}
-
-
-static int
-umlDomainAttachDeviceFlags(virDomainPtr dom,
- const char *xml,
- unsigned int flags)
-{
- virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1);
-
- if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("cannot modify the persistent configuration of a domain"));
- return -1;
- }
-
- return umlDomainAttachDevice(dom, xml);
-}
-
-
-static int umlDomainDetachUmlDisk(struct uml_driver *driver,
- virDomainObjPtr vm,
- virDomainDeviceDefPtr dev)
-{
- size_t i;
- int ret = -1;
- virDomainDiskDefPtr detach = NULL;
- char *cmd;
- char *reply;
-
- for (i = 0; i < vm->def->ndisks; i++) {
- if (STREQ(vm->def->disks[i]->dst, dev->data.disk->dst))
- break;
- }
-
- if (i == vm->def->ndisks) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("disk %s not found"), dev->data.disk->dst);
- return -1;
- }
-
- detach = vm->def->disks[i];
-
- if (virAsprintf(&cmd, "remove %s", detach->dst) < 0)
- return -1;
-
- if (umlMonitorCommand(driver, vm, cmd, &reply) < 0)
- goto cleanup;
-
- virDomainDiskRemove(vm->def, i);
-
- virDomainDiskDefFree(detach);
-
- ret = 0;
-
- VIR_FREE(reply);
-
- cleanup:
- VIR_FREE(cmd);
-
- return ret;
-}
-
-
-static int umlDomainDetachDevice(virDomainPtr dom, const char *xml)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- virDomainDeviceDefPtr dev = NULL;
- int ret = -1;
-
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainDetachDeviceEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (!virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("cannot detach device on inactive domain"));
- goto cleanup;
- }
-
- dev = virDomainDeviceDefParse(xml, vm->def, driver->caps, driver->xmlopt,
- VIR_DOMAIN_DEF_PARSE_INACTIVE |
- VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE);
- if (dev == NULL)
- goto cleanup;
-
- if (dev->type == VIR_DOMAIN_DEVICE_DISK &&
- dev->data.disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
- if (dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_UML)
- ret = umlDomainDetachUmlDisk(driver, vm, dev);
- else
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("This type of disk cannot be hot unplugged"));
- } else {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- "%s", _("This type of device cannot be hot unplugged"));
- }
-
- cleanup:
- virDomainDeviceDefFree(dev);
- virDomainObjEndAPI(&vm);
- umlDriverUnlock(driver);
- return ret;
-}
-
-
-static int
-umlDomainDetachDeviceFlags(virDomainPtr dom,
- const char *xml,
- unsigned int flags)
-{
- virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1);
-
- if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("cannot modify the persistent configuration of a domain"));
- return -1;
- }
-
- return umlDomainDetachDevice(dom, xml);
-}
-
-
-static int umlDomainGetAutostart(virDomainPtr dom,
- int *autostart)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret = -1;
-
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainGetAutostartEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- *autostart = vm->autostart;
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- umlDriverUnlock(driver);
- return ret;
-}
-
-static int umlDomainSetAutostart(virDomainPtr dom,
- int autostart)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- char *configFile = NULL, *autostartLink = NULL;
- int ret = -1;
-
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (!vm->persistent) {
- virReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("cannot set autostart for transient domain"));
- goto cleanup;
- }
-
- autostart = (autostart != 0);
-
- if (vm->autostart != autostart) {
- if ((configFile = virDomainConfigFile(driver->configDir, vm->def->name)) == NULL)
- goto cleanup;
- if ((autostartLink = virDomainConfigFile(driver->autostartDir, vm->def->name)) == NULL)
- goto cleanup;
-
- if (autostart) {
- if (virFileMakePath(driver->autostartDir) < 0) {
- virReportSystemError(errno,
- _("cannot create autostart directory %s"),
- driver->autostartDir);
- goto cleanup;
- }
-
- if (symlink(configFile, autostartLink) < 0) {
- virReportSystemError(errno,
- _("Failed to create symlink '%s to '%s'"),
- autostartLink, configFile);
- goto cleanup;
- }
- } else {
- if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) {
- virReportSystemError(errno,
- _("Failed to delete symlink '%s'"),
- autostartLink);
- goto cleanup;
- }
- }
-
- vm->autostart = autostart;
- }
- ret = 0;
-
- cleanup:
- VIR_FREE(configFile);
- VIR_FREE(autostartLink);
- virDomainObjEndAPI(&vm);
- umlDriverUnlock(driver);
- return ret;
-}
-
-
-static int
-umlDomainBlockPeek(virDomainPtr dom,
- const char *path,
- unsigned long long offset, size_t size,
- void *buffer,
- unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int fd = -1, ret = -1;
- const char *actual;
-
- virCheckFlags(0, -1);
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainBlockPeekEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (!path || path[0] == '\0') {
- virReportError(VIR_ERR_INVALID_ARG, "%s",
- _("NULL or empty path"));
- goto cleanup;
- }
-
- /* Check the path belongs to this domain. */
- if (!(actual = virDomainDiskPathByName(vm->def, path))) {
- virReportError(VIR_ERR_INVALID_ARG,
- _("invalid path '%s'"), path);
- goto cleanup;
- }
- path = actual;
-
- /* The path is correct, now try to open it and get its size. */
- fd = open(path, O_RDONLY);
- if (fd == -1) {
- virReportSystemError(errno,
- _("cannot open %s"), path);
- goto cleanup;
- }
-
- /* Seek and read. */
- /* NB. Because we configure with AC_SYS_LARGEFILE, off_t should
- * be 64 bits on all platforms.
- */
- if (lseek(fd, offset, SEEK_SET) == (off_t)-1 ||
- saferead(fd, buffer, size) == (ssize_t)-1) {
- virReportSystemError(errno,
- _("cannot read %s"), path);
- goto cleanup;
- }
-
- ret = 0;
-
- cleanup:
- VIR_FORCE_CLOSE(fd);
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-
-static int
-umlDomainOpenConsole(virDomainPtr dom,
- const char *dev_name,
- virStreamPtr st,
- unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm = NULL;
- int ret = -1;
- virDomainChrDefPtr chr = NULL;
- size_t i;
-
- virCheckFlags(0, -1);
-
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (virDomainObjCheckActive(vm) < 0)
- goto cleanup;
-
- if (dev_name) {
- for (i = 0; i < vm->def->nconsoles; i++) {
- if (vm->def->consoles[i]->info.alias &&
- STREQ(vm->def->consoles[i]->info.alias, dev_name)) {
- chr = vm->def->consoles[i];
- break;
- }
- }
- } else {
- if (vm->def->nconsoles)
- chr = vm->def->consoles[0];
- else if (vm->def->nserials)
- chr = vm->def->serials[0];
- }
-
- if (!chr) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot find console device '%s'"),
- dev_name ? dev_name : _("default"));
- goto cleanup;
- }
-
- if (chr->source->type != VIR_DOMAIN_CHR_TYPE_PTY) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("character device %s is not using a PTY"),
- dev_name ? dev_name : NULLSTR(chr->info.alias));
- goto cleanup;
- }
-
- if (virFDStreamOpenFile(st, chr->source->data.file.path,
- 0, 0, O_RDWR) < 0)
- goto cleanup;
-
- ret = 0;
- cleanup:
- virDomainObjEndAPI(&vm);
- umlDriverUnlock(driver);
- return ret;
-}
-
-
-static int
-umlConnectDomainEventRegister(virConnectPtr conn,
- virConnectDomainEventCallback callback,
- void *opaque,
- virFreeCallback freecb)
-{
- struct uml_driver *driver = conn->privateData;
- int ret = 0;
-
- if (virConnectDomainEventRegisterEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- if (virDomainEventStateRegister(conn,
- driver->domainEventState,
- callback, opaque, freecb) < 0)
- ret = -1;
- umlDriverUnlock(driver);
-
- return ret;
-}
-
-static int
-umlConnectDomainEventDeregister(virConnectPtr conn,
- virConnectDomainEventCallback callback)
-{
- struct uml_driver *driver = conn->privateData;
- int ret = 0;
-
- if (virConnectDomainEventDeregisterEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- if (virDomainEventStateDeregister(conn,
- driver->domainEventState,
- callback) < 0)
- ret = -1;
- umlDriverUnlock(driver);
-
- return ret;
-}
-
-static int
-umlConnectDomainEventRegisterAny(virConnectPtr conn,
- virDomainPtr dom,
- int eventID,
- virConnectDomainEventGenericCallback callback,
- void *opaque,
- virFreeCallback freecb)
-{
- struct uml_driver *driver = conn->privateData;
- int ret;
-
- if (virConnectDomainEventRegisterAnyEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- if (virDomainEventStateRegisterID(conn,
- driver->domainEventState,
- dom, eventID,
- callback, opaque, freecb, &ret) < 0)
- ret = -1;
- umlDriverUnlock(driver);
-
- return ret;
-}
-
-
-static int
-umlConnectDomainEventDeregisterAny(virConnectPtr conn,
- int callbackID)
-{
- struct uml_driver *driver = conn->privateData;
- int ret = 0;
-
- if (virConnectDomainEventDeregisterAnyEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- if (virObjectEventStateDeregisterID(conn,
- driver->domainEventState,
- callbackID, true) < 0)
- ret = -1;
- umlDriverUnlock(driver);
-
- return ret;
-}
-
-
-static int umlConnectListAllDomains(virConnectPtr conn,
- virDomainPtr **domains,
- unsigned int flags)
-{
- struct uml_driver *driver = conn->privateData;
- int ret = -1;
-
- virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
-
- if (virConnectListAllDomainsEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- ret = virDomainObjListExport(driver->domains, conn, domains,
- virConnectListAllDomainsCheckACL, flags);
- umlDriverUnlock(driver);
-
- return ret;
-}
-
-
-static int
-umlNodeGetInfo(virConnectPtr conn,
- virNodeInfoPtr nodeinfo)
-{
- if (virNodeGetInfoEnsureACL(conn) < 0)
- return -1;
-
- return virCapabilitiesGetNodeInfo(nodeinfo);
-}
-
-
-static int
-umlNodeGetCPUStats(virConnectPtr conn,
- int cpuNum,
- virNodeCPUStatsPtr params,
- int *nparams,
- unsigned int flags)
-{
- if (virNodeGetCPUStatsEnsureACL(conn) < 0)
- return -1;
-
- return virHostCPUGetStats(cpuNum, params, nparams, flags);
-}
-
-
-static int
-umlNodeGetMemoryStats(virConnectPtr conn,
- int cellNum,
- virNodeMemoryStatsPtr params,
- int *nparams,
- unsigned int flags)
-{
- if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
- return -1;
-
- return virHostMemGetStats(cellNum, params, nparams, flags);
-}
-
-
-static int
-umlNodeGetCellsFreeMemory(virConnectPtr conn,
- unsigned long long *freeMems,
- int startCell,
- int maxCells)
-{
- if (virNodeGetCellsFreeMemoryEnsureACL(conn) < 0)
- return -1;
-
- return virHostMemGetCellsFree(freeMems, startCell, maxCells);
-}
-
-
-static unsigned long long
-umlNodeGetFreeMemory(virConnectPtr conn)
-{
- unsigned long long freeMem;
-
- if (virNodeGetFreeMemoryEnsureACL(conn) < 0)
- return 0;
-
- if (virHostMemGetInfo(NULL, &freeMem) < 0)
- return 0;
-
- return freeMem;
-}
-
-
-static int
-umlNodeGetMemoryParameters(virConnectPtr conn,
- virTypedParameterPtr params,
- int *nparams,
- unsigned int flags)
-{
- if (virNodeGetMemoryParametersEnsureACL(conn) < 0)
- return -1;
-
- return virHostMemGetParameters(params, nparams, flags);
-}
-
-
-static int
-umlNodeSetMemoryParameters(virConnectPtr conn,
- virTypedParameterPtr params,
- int nparams,
- unsigned int flags)
-{
- if (virNodeSetMemoryParametersEnsureACL(conn) < 0)
- return -1;
-
- return virHostMemSetParameters(params, nparams, flags);
-}
-
-
-static int
-umlNodeGetCPUMap(virConnectPtr conn,
- unsigned char **cpumap,
- unsigned int *online,
- unsigned int flags)
-{
- if (virNodeGetCPUMapEnsureACL(conn) < 0)
- return -1;
-
- return virHostCPUGetMap(cpumap, online, flags);
-}
-
-
-static int
-umlNodeSuspendForDuration(virConnectPtr conn,
- unsigned int target,
- unsigned long long duration,
- unsigned int flags)
-{
- if (virNodeSuspendForDurationEnsureACL(conn) < 0)
- return -1;
-
- return virNodeSuspend(target, duration, flags);
-}
-
-
-static int
-umlNodeGetFreePages(virConnectPtr conn,
- unsigned int npages,
- unsigned int *pages,
- int startCell,
- unsigned int cellCount,
- unsigned long long *counts,
- unsigned int flags)
-{
- virCheckFlags(0, -1);
-
- if (virNodeGetFreePagesEnsureACL(conn) < 0)
- return -1;
-
- return virHostMemGetFreePages(npages, pages, startCell, cellCount, counts);
-}
-
-
-static int
-umlNodeAllocPages(virConnectPtr conn,
- unsigned int npages,
- unsigned int *pageSizes,
- unsigned long long *pageCounts,
- int startCell,
- unsigned int cellCount,
- unsigned int flags)
-{
- bool add = !(flags & VIR_NODE_ALLOC_PAGES_SET);
-
- virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1);
-
- if (virNodeAllocPagesEnsureACL(conn) < 0)
- return -1;
-
- return virHostMemAllocPages(npages, pageSizes, pageCounts,
- startCell, cellCount, add);
-}
-
-
-static int
-umlDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- int ret = -1;
- virDomainObjPtr vm;
-
- virCheckFlags(0, -1);
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainHasManagedSaveImageEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-
-static virHypervisorDriver umlHypervisorDriver = {
- .name = "UML",
- .connectURIProbe = umlConnectURIProbe,
- .connectOpen = umlConnectOpen, /* 0.5.0 */
- .connectClose = umlConnectClose, /* 0.5.0 */
- .connectGetType = umlConnectGetType, /* 0.5.0 */
- .connectGetVersion = umlConnectGetVersion, /* 0.5.0 */
- .connectGetHostname = umlConnectGetHostname, /* 0.5.0 */
- .nodeGetInfo = umlNodeGetInfo, /* 0.5.0 */
- .connectGetCapabilities = umlConnectGetCapabilities, /* 0.5.0 */
- .connectListDomains = umlConnectListDomains, /* 0.5.0 */
- .connectNumOfDomains = umlConnectNumOfDomains, /* 0.5.0 */
- .connectListAllDomains = umlConnectListAllDomains, /* 0.9.13 */
- .domainCreateXML = umlDomainCreateXML, /* 0.5.0 */
- .domainLookupByID = umlDomainLookupByID, /* 0.5.0 */
- .domainLookupByUUID = umlDomainLookupByUUID, /* 0.5.0 */
- .domainLookupByName = umlDomainLookupByName, /* 0.5.0 */
- .domainShutdown = umlDomainShutdown, /* 0.5.0 */
- .domainShutdownFlags = umlDomainShutdownFlags, /* 0.9.10 */
- .domainDestroy = umlDomainDestroy, /* 0.5.0 */
- .domainDestroyFlags = umlDomainDestroyFlags, /* 0.9.4 */
- .domainGetOSType = umlDomainGetOSType, /* 0.5.0 */
- .domainGetMaxMemory = umlDomainGetMaxMemory, /* 0.5.0 */
- .domainSetMaxMemory = umlDomainSetMaxMemory, /* 0.5.0 */
- .domainSetMemory = umlDomainSetMemory, /* 0.5.0 */
- .domainGetInfo = umlDomainGetInfo, /* 0.5.0 */
- .domainGetState = umlDomainGetState, /* 0.9.2 */
- .domainGetXMLDesc = umlDomainGetXMLDesc, /* 0.5.0 */
- .connectListDefinedDomains = umlConnectListDefinedDomains, /* 0.5.0 */
- .connectNumOfDefinedDomains = umlConnectNumOfDefinedDomains, /* 0.5.0 */
- .domainCreate = umlDomainCreate, /* 0.5.0 */
- .domainCreateWithFlags = umlDomainCreateWithFlags, /* 0.8.2 */
- .domainDefineXML = umlDomainDefineXML, /* 0.5.0 */
- .domainDefineXMLFlags = umlDomainDefineXMLFlags, /* 1.2.12 */
- .domainUndefine = umlDomainUndefine, /* 0.5.0 */
- .domainUndefineFlags = umlDomainUndefineFlags, /* 0.9.4 */
- .domainAttachDevice = umlDomainAttachDevice, /* 0.8.4 */
- .domainAttachDeviceFlags = umlDomainAttachDeviceFlags, /* 0.8.4 */
- .domainDetachDevice = umlDomainDetachDevice, /* 0.8.4 */
- .domainDetachDeviceFlags = umlDomainDetachDeviceFlags, /* 0.8.4 */
- .domainGetAutostart = umlDomainGetAutostart, /* 0.5.0 */
- .domainSetAutostart = umlDomainSetAutostart, /* 0.5.0 */
- .domainBlockPeek = umlDomainBlockPeek, /* 0.5.0 */
- .nodeGetCPUStats = umlNodeGetCPUStats, /* 0.9.3 */
- .nodeGetMemoryStats = umlNodeGetMemoryStats, /* 0.9.3 */
- .nodeGetCellsFreeMemory = umlNodeGetCellsFreeMemory, /* 0.5.0 */
- .nodeGetFreeMemory = umlNodeGetFreeMemory, /* 0.5.0 */
- .nodeGetCPUMap = umlNodeGetCPUMap, /* 1.0.0 */
- .connectDomainEventRegister = umlConnectDomainEventRegister, /* 0.9.4 */
- .connectDomainEventDeregister = umlConnectDomainEventDeregister, /* 0.9.4 */
- .connectIsEncrypted = umlConnectIsEncrypted, /* 0.7.3 */
- .connectIsSecure = umlConnectIsSecure, /* 0.7.3 */
- .domainIsActive = umlDomainIsActive, /* 0.7.3 */
- .domainIsPersistent = umlDomainIsPersistent, /* 0.7.3 */
- .domainIsUpdated = umlDomainIsUpdated, /* 0.8.6 */
- .connectDomainEventRegisterAny = umlConnectDomainEventRegisterAny, /* 0.9.4 */
- .connectDomainEventDeregisterAny = umlConnectDomainEventDeregisterAny, /* 0.9.4 */
- .domainOpenConsole = umlDomainOpenConsole, /* 0.8.6 */
- .connectIsAlive = umlConnectIsAlive, /* 0.9.8 */
- .nodeSuspendForDuration = umlNodeSuspendForDuration, /* 0.9.8 */
- .nodeGetMemoryParameters = umlNodeGetMemoryParameters, /* 0.10.2 */
- .nodeSetMemoryParameters = umlNodeSetMemoryParameters, /* 0.10.2 */
- .nodeGetFreePages = umlNodeGetFreePages, /* 1.2.6 */
- .nodeAllocPages = umlNodeAllocPages, /* 1.2.9 */
- .domainHasManagedSaveImage = umlDomainHasManagedSaveImage, /* 1.2.13 */
-};
-
-static virConnectDriver umlConnectDriver = {
- .localOnly = true,
- .uriSchemes = (const char *[]){ "uml", NULL },
- .hypervisorDriver = ¨HypervisorDriver,
-};
-
-static virStateDriver umlStateDriver = {
- .name = "UML",
- .stateInitialize = umlStateInitialize,
- .stateAutoStart = umlStateAutoStart,
- .stateCleanup = umlStateCleanup,
- .stateReload = umlStateReload,
-};
-
-int umlRegister(void)
-{
- if (virRegisterConnectDriver(¨ConnectDriver,
- true) < 0)
- return -1;
- if (virRegisterStateDriver(¨StateDriver) < 0)
- return -1;
- return 0;
-}
diff --git a/src/uml/uml_driver.h b/src/uml/uml_driver.h
deleted file mode 100644
index 3a258f6658..0000000000
--- a/src/uml/uml_driver.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * uml_driver.h: user mode Linux driver
- *
- * Copyright (C) 2006, 2007 Red Hat, Inc.
- * Copyright (C) 2006-2008 Daniel P. Berrange
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-
-#ifndef LIBVIRT_UML_DRIVER_H
-# define LIBVIRT_UML_DRIVER_H
-
-# include "internal.h"
-
-int umlRegister(void);
-
-#endif /* LIBVIRT_UML_DRIVER_H */
diff --git a/tests/domaincapsschemadata/basic.xml b/tests/domaincapsschemadata/basic.xml
deleted file mode 100644
index 7bf4e56ae0..0000000000
--- a/tests/domaincapsschemadata/basic.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<domainCapabilities>
- <path>/bin/emulatorbin</path>
- <domain>uml</domain>
- <machine>my-machine-type</machine>
- <arch>x86_64</arch>
- <iothreads supported='no'/>
- <os supported='no'/>
- <cpu>
- <mode name='host-passthrough' supported='no'/>
- <mode name='host-model' supported='no'/>
- <mode name='custom' supported='no'/>
- </cpu>
- <devices>
- <disk supported='no'/>
- <graphics supported='no'/>
- <video supported='no'/>
- <hostdev supported='no'/>
- </devices>
- <features>
- <gic supported='no'/>
- <vmcoreinfo supported='no'/>
- <genid supported='no'/>
- <sev supported='no'/>
- </features>
-</domainCapabilities>
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index ea4e57d118..7f52058bad 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -409,8 +409,6 @@ mymain(void)
ret = -1; \
} while (0)
- DO_TEST("basic", "/bin/emulatorbin", "my-machine-type",
- "x86_64", VIR_DOMAIN_VIRT_UML, CAPS_NONE);
DO_TEST("full", "/bin/emulatorbin", "my-machine-type",
"x86_64", VIR_DOMAIN_VIRT_KVM, CAPS_ALL);
diff --git a/tests/objectlocking.ml b/tests/objectlocking.ml
index 778e67cffd..6726d29e73 100644
--- a/tests/objectlocking.ml
+++ b/tests/objectlocking.ml
@@ -121,7 +121,6 @@ let driverLockMethods = [
"openvzDriverLock";
"testDriverLock";
"lxcDriverLock";
- "umlDriverLock";
"nodedevDriverLock";
"networkDriverLock";
"storageDriverLock";
@@ -136,7 +135,6 @@ let driverUnlockMethods = [
"openvzDriverUnlock";
"testDriverUnlock";
"lxcDriverUnlock";
- "umlDriverUnlock";
"nodedevDriverUnlock";
"networkDriverUnlock";
"storageDriverUnlock";
@@ -153,7 +151,6 @@ let lockableDrivers = [
"openvz_driver";
"testConnPtr";
"lxc_driver_t";
- "uml_driver";
"virStorageDriverStatePtr";
"network_driver";
"virNodeDeviceState";
diff --git a/tests/virdrivermoduletest.c b/tests/virdrivermoduletest.c
index 7e9dced87e..0d753cd0ee 100644
--- a/tests/virdrivermoduletest.c
+++ b/tests/virdrivermoduletest.c
@@ -89,9 +89,6 @@ mymain(void)
#ifdef WITH_LXC
TEST("lxc");
#endif
-#ifdef WITH_UML
- TEST("uml");
-#endif
#ifdef WITH_VBOX
TEST("vbox");
#endif
diff --git a/tools/virsh.c b/tools/virsh.c
index 09fa0f8a67..8428e539f6 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -518,9 +518,6 @@ virshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
#ifdef WITH_LXC
vshPrint(ctl, " LXC");
#endif
-#ifdef WITH_UML
- vshPrint(ctl, " UML");
-#endif
#ifdef WITH_LIBXL
vshPrint(ctl, " LibXL");
#endif
--
2.19.2
5 years, 11 months
[libvirt] [PATCH] lxc: Set max uid/gid mappings for user namespace
by Radostin Stoyanov
There is a limit on the number of lines in the /proc/<pid>/{g,u}id_map
files. In Linux 4.14 and earlier, this limit was (arbitrarily) set at
5 lines. Since Linux 4.15, which was released on 28 Jan 2018, the limit
is 340 lines.
This change is documented in user_namespaces(7).
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit...
Signed-off-by: Radostin Stoyanov <rstoyanov1(a)gmail.com>
---
src/lxc/lxc_controller.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 99360397a7..2bec8846aa 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1390,6 +1390,13 @@ virLXCControllerSetupUsernsMap(virDomainIdMapEntryPtr map,
size_t i;
int ret = -1;
+ /* The kernel supports up to 340 lines in /proc/<pid>/{g,u}id_map */
+ if (num > 340) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("Too many id mappings defined."));
+ goto cleanup;
+ }
+
for (i = 0; i < num; i++)
virBufferAsprintf(&map_value, "%u %u %u\n",
map[i].start, map[i].target, map[i].count);
--
2.19.2
5 years, 11 months
[libvirt] [PATCH] qemu: Add default address type for vhost-user interface on aarch64
by Wang Yechao
on aarch64, hotadd vhost-user interface with the follow xml file:
<interface type='vhostuser'>
<mac address='fa:16:3e:a2:e1:58'/>
<source type='unix' path='/var/run/vhu24a3f044-80' mode='server'/>
<target dev='vhu24a3f044-80'/>
<model type='virtio'/>
</interface>
will get error like that:
error: internal error: Nicdev support unavailable
Because there is no device address type specified in xml file, so
qemuDomainSupportsNicdev returns 'false' when invoked in
qemuDomainAttachNetDevice. Using pci as the default address type,
and assigns pci address later in qemuDomainEnsurePCIAddress.
Signed-off-by: Wang Yechao <wang.yechao255(a)zte.com.cn>
---
src/qemu/qemu_hotplug.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 68d021a..c1464a9 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1443,6 +1443,11 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
queueSize = net->driver.virtio.queues;
if (!queueSize)
queueSize = 1;
+
+ if (!net->info.type &&
+ vm->def->os.arch == VIR_ARCH_AARCH64)
+ net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
+
if (!qemuDomainSupportsNicdev(vm->def, net)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Nicdev support unavailable"));
--
1.8.3.1
5 years, 11 months
[libvirt] [PATCH] docs: Improve description of <hard_limit>
by Jim Fehlig
/domain/memtune/hard_limit provides a way to cap the memory a VM process
can use, including the amount of memory the process can lock. When memory
locking of a VM is requested, <hard_limit> can be used to prevent the
potential host DoS issue mentioned in /domain/memoryBacking/locked
description.
This patch improves the <hard_limit> text by clarifying it can be used
to prevent "host crashing" when VM memory is locked.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
docs/formatdomain.html.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 428b0e8bb5..07c32f9879 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1243,9 +1243,9 @@
<a href="#elementsMemoryBacking">memory backing</a> because your
workload demands it, you'll have to take into account the specifics of
your deployment and figure out a value for <code>hard_limit</code> that
- balances the risk of your guest being killed because the limit was set
- too low and the risk of your host crashing because it cannot reclaim
- the memory used by the guest due to <code>locked</code>. Good luck!</dd>
+ is large enough to support the memory requirements of your guest, but
+ small enough to protect your host against a malicious guest locking all
+ memory.</dd>
<dt><code>soft_limit</code></dt>
<dd> The optional <code>soft_limit</code> element is the memory limit to
enforce during memory contention. The units for this value are
--
2.19.1
5 years, 11 months
[libvirt] [RFC v3 1/4] nvdimm: introduce more config elements into xml for NVDIMM memory
by Luyao Zhong
1.alignsize
The 'alignsize' option allows users to specify the proper alignment.
2.pmem
The 'pmem' option allows users to specify whether the backend storage of
memory-backend-file is a real persistent memory.
3.unarmed
The 'unarmed' option allows users to mark vNVDIMM read-only.
These options can be configured respectively or simultaneously in domain
xml file, here is an example:
<devices>
...
<memory model='nvdimm' access='shared'>
<source>
<path>/dev/dax0.0</path>
<alignsize unit='MiB'>2</alignsize>
<pmem/>
</source>
<target>
<size unit='MiB'>4094</size>
<node>0</node>
<label>
<size unit='MiB'>2</size>
</label>
<unarmed/>
</target>
</memory>
...
</devices>
Signed-off-by: Luyao Zhong <luyao.zhong(a)intel.com>
---
docs/formatdomain.html.in | 80 ++++++++++++++++++----
docs/schemas/domaincommon.rng | 23 ++++++-
src/conf/domain_conf.c | 61 +++++++++++++++--
src/conf/domain_conf.h | 3 +
.../memory-hotplug-nvdimm-align.xml | 58 ++++++++++++++++
.../memory-hotplug-nvdimm-pmem.xml | 58 ++++++++++++++++
.../memory-hotplug-nvdimm-unarmed.xml | 58 ++++++++++++++++
.../memory-hotplug-nvdimm-align.xml | 1 +
.../memory-hotplug-nvdimm-pmem.xml | 1 +
.../memory-hotplug-nvdimm-unarmed.xml | 1 +
tests/qemuxml2xmltest.c | 3 +
11 files changed, 322 insertions(+), 25 deletions(-)
create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.xml
create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.xml
create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-unarmed.xml
create mode 120000 tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-align.xml
create mode 120000 tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-pmem.xml
create mode 120000 tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-unarmed.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 428b0e8..3f813f2 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -8322,6 +8322,8 @@ qemu-kvm -net nic,model=? /dev/null
<memory model='nvdimm'>
<source>
<path>/tmp/nvdimm</path>
+ <alignsize unit='KiB'>2048</alignsize>
+ <pmem/>
</source>
<target>
<size unit='KiB'>524288</size>
@@ -8329,6 +8331,7 @@ qemu-kvm -net nic,model=? /dev/null
<label>
<size unit='KiB'>128</size>
</label>
+ <unarmed/>
</target>
</memory>
</devices>
@@ -8403,10 +8406,37 @@ qemu-kvm -net nic,model=? /dev/null
</dl>
<p>
- For model <code>nvdimm</code> this element is mandatory and has a
- single child element <code>path</code> that represents a path
- in the host that backs the nvdimm module in the guest.
+ For model <code>nvdimm</code> this element is mandatory. The
+ mandatory child element <code>path</code> represents a path in
+ the host that backs the nvdimm module in the guest. If
+ <code>nvdimm</code> is provided, then the following optional
+ elements can be provided as well:
</p>
+
+ <dl>
+ <dt><code>alignsize</code></dt>
+ <dd>
+ <p>
+ This element can be used to specify a proper alignment.
+ When mmap(2) the backend files, QEMU uses the host page
+ size by default as the alignment of mapping address. However,
+ some backends may require alignments different from the page.
+ For example, mmap a real NVDIMM device maybe 2M-aligned required.
+ <span class="since">Since 4.9.0</span>
+ </p>
+ </dd>
+
+ <dt><code>pmem</code></dt>
+ <dd>
+ <p>
+ This element can be used to specify whether the backend storage
+ of memory-backend-file is a real persistent memory. If the backend
+ is a real persistence memory and <code>pmem</code> is set, QEMU
+ will guarantee the persistence of its own writes to the vNVDIMM
+ backend.<span class="since">Since 4.9.0</span>
+ </p>
+ </dd>
+ </dl>
</dd>
<dt><code>target</code></dt>
@@ -8425,19 +8455,39 @@ qemu-kvm -net nic,model=? /dev/null
NUMA nodes configured.
</p>
<p>
- For NVDIMM type devices one can optionally use
- <code>label</code> and its subelement <code>size</code>
- to configure the size of namespaces label storage
- within the NVDIMM module. The <code>size</code> element
- has usual meaning described
- <a href="#elementsMemoryAllocation">here</a>.
- For QEMU domains the following restrictions apply:
+ Besides, the following optional elements can be provided as well for
+ NVDIMM type devices:
</p>
- <ol>
- <li>the minimum label size is 128KiB,</li>
- <li>the remaining size (total-size - label-size) has to be aligned to
- 4KiB</li>
- </ol>
+
+ <dl>
+ <dt><code>label</code></dt>
+ <dd>
+ <p>
+ For NVDIMM type devices one can optionally use
+ <code>label</code> and its subelement <code>size</code>
+ to configure the size of namespaces label storage
+ within the NVDIMM module. The <code>size</code> element
+ has usual meaning described
+ <a href="#elementsMemoryAllocation">here</a>.
+ For QEMU domains the following restrictions apply:
+ </p>
+ <ol>
+ <li>the minimum label size is 128KiB,</li>
+ <li>the remaining size (total-size - label-size) will be aligned to
+ 4KiB as default.</li>
+ </ol>
+ </dd>
+
+ <dt><code>unarmed</code></dt>
+ <dd>
+ <p>
+ The <code>unarmed</code> element can be used to mark vNVDIMM read-only.
+ Currently, only real NVDIMM device backend can guarantee the guest write
+ persistence, so please set <code>unarmed</code> when using other types
+ of backends.<span class="since">Since 4.9.0</span>
+ </p>
+ </dd>
+ </dl>
</dd>
</dl>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 5a6c48f..de098a5 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5384,9 +5384,21 @@
</interleave>
</group>
<group>
- <element name="path">
- <ref name="absFilePath"/>
- </element>
+ <interleave>
+ <element name="path">
+ <ref name="absFilePath"/>
+ </element>
+ <optional>
+ <element name="alignsize">
+ <ref name="scaledInteger"/>
+ </element>
+ </optional>
+ <optional>
+ <element name="pmem">
+ <empty/>
+ </element>
+ </optional>
+ </interleave>
</group>
</choice>
</element>
@@ -5410,6 +5422,11 @@
</element>
</element>
</optional>
+ <optional>
+ <element name="unarmed">
+ <empty/>
+ </element>
+ </optional>
</interleave>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index efa0a94..e16262b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15757,6 +15757,16 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node,
_("path is required for model 'nvdimm'"));
goto cleanup;
}
+
+ if (virDomainParseMemory("./alignsize", "./alignsize/@unit", ctxt,
+ &def->alignsize, false, false) < 0)
+ goto cleanup;
+
+ if (virXPathBoolean("boolean(./pmem)", ctxt))
+ def->nvdimmPmem = true;
+ else
+ def->nvdimmPmem = false;
+
break;
case VIR_DOMAIN_MEMORY_MODEL_NONE:
@@ -15813,6 +15823,11 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node,
_("label size must be smaller than NVDIMM size"));
goto cleanup;
}
+
+ if (virXPathBoolean("boolean(./unarmed)", ctxt))
+ def->nvdimmUnarmed = true;
+ else
+ def->nvdimmUnarmed = false;
}
ret = 0;
@@ -22712,13 +22727,36 @@ virDomainMemoryDefCheckABIStability(virDomainMemoryDefPtr src,
return false;
}
- if (src->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM &&
- src->labelsize != dst->labelsize) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target NVDIMM label size '%llu' doesn't match "
- "source NVDIMM label size '%llu'"),
- src->labelsize, dst->labelsize);
- return false;
+ if (src->model == VIR_DOMAIN_MEMORY_MODEL_NVDIMM) {
+ if (src->labelsize != dst->labelsize) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Target NVDIMM label size '%llu' doesn't match "
+ "source NVDIMM label size '%llu'"),
+ src->labelsize, dst->labelsize);
+ return false;
+ }
+
+ if (src->alignsize != dst->alignsize) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Target NVDIMM alignment '%llu' doesn't match "
+ "source NVDIMM alignment '%llu'"),
+ src->alignsize, dst->alignsize);
+ return false;
+ }
+
+ if (src->nvdimmPmem != dst->nvdimmPmem) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Target NVDIMM pmem flag doesn't match "
+ "source NVDIMM pmem flag "));
+ return false;
+ }
+
+ if (src->nvdimmUnarmed != dst->nvdimmUnarmed) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Target NVDIMM unarmed flag doesn't match "
+ "source NVDIMM unarmed flag "));
+ return false;
+ }
}
return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info);
@@ -26255,6 +26293,13 @@ virDomainMemorySourceDefFormat(virBufferPtr buf,
case VIR_DOMAIN_MEMORY_MODEL_NVDIMM:
virBufferEscapeString(buf, "<path>%s</path>\n", def->nvdimmPath);
+
+ if (def->alignsize)
+ virBufferAsprintf(buf, "<alignsize unit='KiB'>%llu</alignsize>\n",
+ def->alignsize);
+
+ if (def->nvdimmPmem)
+ virBufferAddLit(buf, "<pmem/>\n");
break;
case VIR_DOMAIN_MEMORY_MODEL_NONE:
@@ -26290,6 +26335,8 @@ virDomainMemoryTargetDefFormat(virBufferPtr buf,
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</label>\n");
}
+ if (def->nvdimmUnarmed)
+ virBufferAddLit(buf, "<unarmed/>\n");
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</target>\n");
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index b24e6ec..e921f00 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2149,12 +2149,15 @@ struct _virDomainMemoryDef {
virBitmapPtr sourceNodes;
unsigned long long pagesize; /* kibibytes */
char *nvdimmPath;
+ unsigned long long alignsize; /* kibibytes; valid only for NVDIMM */
+ bool nvdimmPmem; /* valid only for NVDIMM */
/* target */
int model; /* virDomainMemoryModel */
int targetNode;
unsigned long long size; /* kibibytes */
unsigned long long labelsize; /* kibibytes; valid only for NVDIMM */
+ bool nvdimmUnarmed; /* valid only for NVDIMM */
virDomainDeviceInfo info;
};
diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.xml b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.xml
new file mode 100644
index 0000000..a8c5198
--- /dev/null
+++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.xml
@@ -0,0 +1,58 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <maxMemory slots='16' unit='KiB'>1099511627776</maxMemory>
+ <memory unit='KiB'>1267710</memory>
+ <currentMemory unit='KiB'>1267710</currentMemory>
+ <vcpu placement='static' cpuset='0-1'>2</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <idmap>
+ <uid start='0' target='1000' count='10'/>
+ <gid start='0' target='1000' count='10'/>
+ </idmap>
+ <cpu>
+ <topology sockets='2' cores='1' threads='1'/>
+ <numa>
+ <cell id='0' cpus='0-1' memory='219136' unit='KiB'/>
+ </numa>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </memballoon>
+ <memory model='nvdimm' access='private'>
+ <source>
+ <path>/tmp/nvdimm</path>
+ <alignsize unit='KiB'>2048</alignsize>
+ </source>
+ <target>
+ <size unit='KiB'>523264</size>
+ <node>0</node>
+ </target>
+ <address type='dimm' slot='0'/>
+ </memory>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.xml b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.xml
new file mode 100644
index 0000000..060d75c
--- /dev/null
+++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.xml
@@ -0,0 +1,58 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <maxMemory slots='16' unit='KiB'>1099511627776</maxMemory>
+ <memory unit='KiB'>1267710</memory>
+ <currentMemory unit='KiB'>1267710</currentMemory>
+ <vcpu placement='static' cpuset='0-1'>2</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <idmap>
+ <uid start='0' target='1000' count='10'/>
+ <gid start='0' target='1000' count='10'/>
+ </idmap>
+ <cpu>
+ <topology sockets='2' cores='1' threads='1'/>
+ <numa>
+ <cell id='0' cpus='0-1' memory='219136' unit='KiB'/>
+ </numa>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </memballoon>
+ <memory model='nvdimm' access='private'>
+ <source>
+ <path>/tmp/nvdimm</path>
+ <pmem/>
+ </source>
+ <target>
+ <size unit='KiB'>523264</size>
+ <node>0</node>
+ </target>
+ <address type='dimm' slot='0'/>
+ </memory>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-unarmed.xml b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-unarmed.xml
new file mode 100644
index 0000000..7ddbb01
--- /dev/null
+++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-unarmed.xml
@@ -0,0 +1,58 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <maxMemory slots='16' unit='KiB'>1099511627776</maxMemory>
+ <memory unit='KiB'>1267710</memory>
+ <currentMemory unit='KiB'>1267710</currentMemory>
+ <vcpu placement='static' cpuset='0-1'>2</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <idmap>
+ <uid start='0' target='1000' count='10'/>
+ <gid start='0' target='1000' count='10'/>
+ </idmap>
+ <cpu>
+ <topology sockets='2' cores='1' threads='1'/>
+ <numa>
+ <cell id='0' cpus='0-1' memory='219136' unit='KiB'/>
+ </numa>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </memballoon>
+ <memory model='nvdimm' access='private'>
+ <source>
+ <path>/tmp/nvdimm</path>
+ </source>
+ <target>
+ <size unit='KiB'>523264</size>
+ <node>0</node>
+ <unarmed/>
+ </target>
+ <address type='dimm' slot='0'/>
+ </memory>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-align.xml b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-align.xml
new file mode 120000
index 0000000..9fc6001
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-align.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/memory-hotplug-nvdimm-align.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-pmem.xml b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-pmem.xml
new file mode 120000
index 0000000..3e57c1e
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-pmem.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/memory-hotplug-nvdimm-pmem.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-unarmed.xml b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-unarmed.xml
new file mode 120000
index 0000000..1793347
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-unarmed.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/memory-hotplug-nvdimm-unarmed.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index c98b957..01e3730 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1112,6 +1112,9 @@ mymain(void)
DO_TEST("memory-hotplug-nvdimm", NONE);
DO_TEST("memory-hotplug-nvdimm-access", NONE);
DO_TEST("memory-hotplug-nvdimm-label", NONE);
+ DO_TEST("memory-hotplug-nvdimm-align", NONE);
+ DO_TEST("memory-hotplug-nvdimm-pmem", NONE);
+ DO_TEST("memory-hotplug-nvdimm-unarmed", NONE);
DO_TEST("net-udp", NONE);
DO_TEST("video-virtio-gpu-device", NONE);
--
2.7.4
5 years, 11 months
[libvirt] [PATCH] qemu: use line breaks in command line args written to log
by Daniel P. Berrangé
The QEMU command line arguments are very long and currently all written
on a single line to /var/log/libvirt/qemu/$GUEST.log. This introduces
logic to add line breaks after every env variable and "-" optional
argument, and every positional argument. This will create a clearer log
file, which will in turn present better in bug reports when people cut +
paste from the log into a bug comment.
An example log file entry now looks like this:
2018-12-14 12:57:03.677+0000: starting up libvirt version: 5.0.0, qemu version: 3.0.0qemu-3.0.0-1.fc29, kernel: 4.19.5-300.fc29.x86_64, hostname: localhost.localdomain
LC_ALL=C \
PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin \
HOME=/home/berrange \
USER=berrange \
LOGNAME=berrange \
QEMU_AUDIO_DRV=none \
/usr/bin/qemu-system-ppc64 \
-name guest=guest,debug-threads=on \
-S \
-object secret,id=masterKey0,format=raw,file=/home/berrange/.config/libvirt/qemu/lib/domain-33-guest/master-key.aes \
-machine pseries-2.10,accel=tcg,usb=off,dump-guest-core=off \
-m 1024 \
-realtime mlock=off \
-smp 1,sockets=1,cores=1,threads=1 \
-uuid c8a74977-ab18-41d0-ae3b-4041c7fffbcd \
-display none \
-no-user-config \
-nodefaults \
-chardev socket,id=charmonitor,fd=23,server,nowait \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc \
-no-shutdown \
-boot strict=on \
-device qemu-xhci,id=usb,bus=pci.0,addr=0x1 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
-msg timestamp=on
2018-12-14 12:57:03.730+0000: shutting down, reason=failed
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
docs/internals/command.html.in | 2 +-
src/bhyve/bhyve_driver.c | 4 +-
src/qemu/qemu_driver.c | 2 +-
src/qemu/qemu_interface.c | 2 +-
src/qemu/qemu_process.c | 2 +-
src/security/security_apparmor.c | 2 +-
src/util/vircommand.c | 19 ++++++++--
src/util/vircommand.h | 2 +-
src/util/virfirewall.c | 2 +-
tests/bhyvexml2argvtest.c | 4 +-
tests/commanddata/test26.log | 1 +
tests/commandtest.c | 64 +++++++++++++++++++++++++++++++-
tests/qemuxml2argvtest.c | 2 +-
tests/storagepoolxml2argvtest.c | 2 +-
tests/storagevolxml2argvtest.c | 4 +-
15 files changed, 95 insertions(+), 19 deletions(-)
create mode 100644 tests/commanddata/test26.log
diff --git a/docs/internals/command.html.in b/docs/internals/command.html.in
index 43f51a49bb..8a9061e70f 100644
--- a/docs/internals/command.html.in
+++ b/docs/internals/command.html.in
@@ -426,7 +426,7 @@ dprintf(logfd, "%s: ", timestamp);
VIR_FREE(timestamp);
virCommandWriteArgLog(cmd, logfd);
-string = virCommandToString(cmd);
+string = virCommandToString(cmd, false);
if (string)
VIR_DEBUG("about to run %s", string);
VIR_FREE(string);
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 4998100bc2..912797cfcf 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -733,14 +733,14 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn,
NULL)))
goto cleanup;
- virBufferAdd(&buf, virCommandToString(loadcmd), -1);
+ virBufferAdd(&buf, virCommandToString(loadcmd, false), -1);
virBufferAddChar(&buf, '\n');
}
if (!(cmd = virBhyveProcessBuildBhyveCmd(conn, def, true)))
goto cleanup;
- virBufferAdd(&buf, virCommandToString(cmd), -1);
+ virBufferAdd(&buf, virCommandToString(cmd, false), -1);
if (virBufferCheckError(&buf) < 0)
goto cleanup;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f9a22f8a4b..67b6f9097b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7425,7 +7425,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
VIR_QEMU_PROCESS_START_COLD)))
goto cleanup;
- ret = virCommandToString(cmd);
+ ret = virCommandToString(cmd, false);
cleanup:
virCommandFree(cmd);
diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
index cea1fd3046..ac0a17acc3 100644
--- a/src/qemu/qemu_interface.c
+++ b/src/qemu/qemu_interface.c
@@ -368,7 +368,7 @@ qemuCreateInBridgePortWithHelper(virQEMUDriverConfigPtr cfg,
char ebuf[1024];
char *errstr = NULL;
- if (!(cmdstr = virCommandToString(cmd)))
+ if (!(cmdstr = virCommandToString(cmd, false)))
goto cleanup;
virCommandAbort(cmd);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 6de510660a..8d8145d18f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4360,7 +4360,7 @@ qemuLogOperation(virDomainObjPtr vm,
goto cleanup;
if (cmd) {
- char *args = virCommandToString(cmd);
+ char *args = virCommandToString(cmd, true);
qemuDomainLogContextWrite(logCtxt, "%s\n", args);
VIR_FREE(args);
}
diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
index 0d28cae0b7..43310361ba 100644
--- a/src/security/security_apparmor.c
+++ b/src/security/security_apparmor.c
@@ -654,7 +654,7 @@ AppArmorSetSecurityChildProcessLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
if ((profile_name = get_profile_name(def)) == NULL)
goto cleanup;
- cmd_str = virCommandToString(cmd);
+ cmd_str = virCommandToString(cmd, false);
VIR_DEBUG("Changing AppArmor profile to %s on %s", profile_name, cmd_str);
virCommandSetAppArmorProfile(cmd, profile_name);
rc = 0;
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 6f106df33b..3559f4bafa 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -1950,6 +1950,7 @@ virCommandWriteArgLog(virCommandPtr cmd, int logfd)
/**
* virCommandToString:
* @cmd: the command to convert
+ * @linebreaks: true to break line after each env var or option
*
* Call after adding all arguments and environment settings, but
* before Run/RunAsync, to return a string representation of the
@@ -1959,10 +1960,11 @@ virCommandWriteArgLog(virCommandPtr cmd, int logfd)
* Caller is responsible for freeing the resulting string.
*/
char *
-virCommandToString(virCommandPtr cmd)
+virCommandToString(virCommandPtr cmd, bool linebreaks)
{
size_t i;
virBuffer buf = VIR_BUFFER_INITIALIZER;
+ bool prevopt = false;
/* Cannot assume virCommandRun will be called; so report the error
* now. If virCommandRun is called, it will report the same error. */
@@ -1991,11 +1993,22 @@ virCommandToString(virCommandPtr cmd)
virBufferAdd(&buf, cmd->env[i], eq - cmd->env[i]);
virBufferEscapeShell(&buf, eq);
virBufferAddChar(&buf, ' ');
+ if (linebreaks)
+ virBufferAddLit(&buf, "\\\n");
}
virBufferEscapeShell(&buf, cmd->args[0]);
for (i = 1; i < cmd->nargs; i++) {
virBufferAddChar(&buf, ' ');
+ if (linebreaks) {
+ /* Line break if this is a --arg or if
+ * the previous arg was a positional option
+ */
+ if (cmd->args[i][0] == '-' ||
+ !prevopt)
+ virBufferAddLit(&buf, "\\\n");
+ }
virBufferEscapeShell(&buf, cmd->args[i]);
+ prevopt = (cmd->args[i][0] == '-');
}
if (virBufferCheckError(&buf) < 0)
@@ -2438,7 +2451,7 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
goto cleanup;
}
- str = virCommandToString(cmd);
+ str = virCommandToString(cmd, false);
if (dryRunBuffer || dryRunCallback) {
dryRunStatus = 0;
if (!str) {
@@ -2579,7 +2592,7 @@ virCommandWait(virCommandPtr cmd, int *exitstatus)
if (exitstatus && (cmd->rawStatus || WIFEXITED(status))) {
*exitstatus = cmd->rawStatus ? status : WEXITSTATUS(status);
} else if (status) {
- VIR_AUTOFREE(char *) str = virCommandToString(cmd);
+ VIR_AUTOFREE(char *) str = virCommandToString(cmd, false);
VIR_AUTOFREE(char *) st = virProcessTranslateStatus(status);
bool haveErrMsg = cmd->errbuf && *cmd->errbuf && (*cmd->errbuf)[0];
diff --git a/src/util/vircommand.h b/src/util/vircommand.h
index f299acc775..dbf5041890 100644
--- a/src/util/vircommand.h
+++ b/src/util/vircommand.h
@@ -172,7 +172,7 @@ void virCommandSetPreExecHook(virCommandPtr cmd,
void virCommandWriteArgLog(virCommandPtr cmd,
int logfd);
-char *virCommandToString(virCommandPtr cmd) ATTRIBUTE_RETURN_CHECK;
+char *virCommandToString(virCommandPtr cmd, bool linebreaks) ATTRIBUTE_RETURN_CHECK;
int virCommandExec(virCommandPtr cmd, gid_t *groups, int ngroups) ATTRIBUTE_RETURN_CHECK;
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index c25d2ddfad..5a0cf95a44 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -694,7 +694,7 @@ virFirewallApplyRuleDirect(virFirewallRulePtr rule,
if (ignoreErrors) {
VIR_DEBUG("Ignoring error running command");
} else {
- VIR_AUTOFREE(char *) args = virCommandToString(cmd);
+ VIR_AUTOFREE(char *) args = virCommandToString(cmd, false);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to apply firewall rules %s: %s"),
NULLSTR(args), NULLSTR(error));
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index 6d5f19e2c6..d1b486fa64 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -68,13 +68,13 @@ static int testCompareXMLToArgvFiles(const char *xml,
goto out;
}
- if (!(actualargv = virCommandToString(cmd)))
+ if (!(actualargv = virCommandToString(cmd, false)))
goto out;
if (actualdm != NULL)
virTrimSpaces(actualdm, NULL);
- if (!(actualld = virCommandToString(ldcmd)))
+ if (!(actualld = virCommandToString(ldcmd, false)))
goto out;
if (virTestCompareToFile(actualargv, cmdline) < 0)
diff --git a/tests/commanddata/test26.log b/tests/commanddata/test26.log
new file mode 100644
index 0000000000..db0d424875
--- /dev/null
+++ b/tests/commanddata/test26.log
@@ -0,0 +1 @@
+A=B C=D E true --foo bar --oooh -f --wizz eek eek -w -z -l --mmm flash bang wallop
diff --git a/tests/commandtest.c b/tests/commandtest.c
index 4d9a468db2..816a70860f 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -630,7 +630,7 @@ static int test16(const void *unused ATTRIBUTE_UNUSED)
virCommandAddArg(cmd, "F");
virCommandAddArg(cmd, "G H");
- if ((outactual = virCommandToString(cmd)) == NULL) {
+ if ((outactual = virCommandToString(cmd, false)) == NULL) {
printf("Cannot convert to string: %s\n", virGetLastErrorMessage());
goto cleanup;
}
@@ -1135,6 +1135,67 @@ static int test25(const void *unused ATTRIBUTE_UNUSED)
}
+/*
+ * Don't run program; rather, log what would be run.
+ */
+static int test26(const void *unused ATTRIBUTE_UNUSED)
+{
+ virCommandPtr cmd = virCommandNew("true");
+ char *outactual = NULL;
+ const char *outexpect =
+ "A=B \\\n"
+ "C='D E' \\\n"
+ "true \\\n"
+ "--foo bar \\\n"
+ "--oooh \\\n"
+ "-f \\\n"
+ "--wizz 'eek eek' \\\n"
+ "-w \\\n"
+ "-z \\\n"
+ "-l \\\n"
+ "--mmm flash \\\n"
+ "bang \\\n"
+ "wallop";
+
+ int ret = -1;
+ int fd = -1;
+
+ virCommandAddEnvPair(cmd, "A", "B");
+ virCommandAddEnvPair(cmd, "C", "D E");
+ virCommandAddArgList(cmd, "--foo", "bar", "--oooh", "-f",
+ "--wizz", "eek eek", "-w", "-z", "-l",
+ "--mmm", "flash", "bang", "wallop",
+ NULL);
+
+ if ((outactual = virCommandToString(cmd, true)) == NULL) {
+ printf("Cannot convert to string: %s\n", virGetLastErrorMessage());
+ goto cleanup;
+ }
+ if ((fd = open(abs_builddir "/commandhelper.log",
+ O_CREAT | O_TRUNC | O_WRONLY, 0600)) < 0) {
+ printf("Cannot open log file: %s\n", strerror(errno));
+ goto cleanup;
+ }
+ virCommandWriteArgLog(cmd, fd);
+ if (VIR_CLOSE(fd) < 0) {
+ printf("Cannot close log file: %s\n", strerror(errno));
+ goto cleanup;
+ }
+
+ if (STRNEQ(outactual, outexpect)) {
+ virTestDifference(stderr, outexpect, outactual);
+ goto cleanup;
+ }
+
+ ret = checkoutput("test26", NULL);
+
+ cleanup:
+ virCommandFree(cmd);
+ VIR_FORCE_CLOSE(fd);
+ VIR_FREE(outactual);
+ return ret;
+}
+
static void virCommandThreadWorker(void *opaque)
{
virCommandTestDataPtr test = opaque;
@@ -1288,6 +1349,7 @@ mymain(void)
DO_TEST(test23);
DO_TEST(test24);
DO_TEST(test25);
+ DO_TEST(test26);
virMutexLock(&test->lock);
if (test->running) {
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 287e9d4ea3..5812e85436 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -620,7 +620,7 @@ testCompareXMLToArgv(const void *data)
goto cleanup;
}
- if (!(actualargv = virCommandToString(cmd)))
+ if (!(actualargv = virCommandToString(cmd, false)))
goto cleanup;
if (virTestCompareToFile(actualargv, args) < 0)
diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtest.c
index 196989cb6d..2f2d40e027 100644
--- a/tests/storagepoolxml2argvtest.c
+++ b/tests/storagepoolxml2argvtest.c
@@ -71,7 +71,7 @@ testCompareXMLToArgvFiles(bool shouldFail,
goto cleanup;
};
- if (!(actualCmdline = virCommandToString(cmd))) {
+ if (!(actualCmdline = virCommandToString(cmd, false))) {
VIR_TEST_DEBUG("pool type %d failed to get commandline\n", def->type);
goto cleanup;
}
diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c
index 105705f348..bc2da37410 100644
--- a/tests/storagevolxml2argvtest.c
+++ b/tests/storagevolxml2argvtest.c
@@ -104,14 +104,14 @@ testCompareXMLToArgvFiles(bool shouldFail,
}
if (convertStep != VIR_STORAGE_VOL_ENCRYPT_CONVERT) {
- if (!(actualCmdline = virCommandToString(cmd)))
+ if (!(actualCmdline = virCommandToString(cmd, false)))
goto cleanup;
} else {
char *createCmdline = actualCmdline;
char *cvtCmdline;
int rc;
- if (!(cvtCmdline = virCommandToString(cmd)))
+ if (!(cvtCmdline = virCommandToString(cmd, false)))
goto cleanup;
rc = virAsprintf(&actualCmdline, "%s\n%s",
--
2.19.2
5 years, 11 months
[libvirt] [PATCH] Drop UML driver
by Michal Privoznik
The driver is unmaintained, untested and severely broken for
quite some time now. Since nobody even reported any issue with it
let us drop it.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
configure.ac | 4 -
docs/aclpolkit.html.in | 4 -
docs/drivers.html.in | 1 -
docs/drvuml.html.in | 93 -
docs/formatcaps.html.in | 3 -
docs/formatdomain.html.in | 6 +-
docs/formatdomaincaps.html.in | 1 -
docs/formatnwfilter.html.in | 2 +-
docs/news.xml | 14 +
docs/schemas/capability.rng | 2 -
docs/schemas/domaincommon.rng | 3 -
include/libvirt/virterror.h | 2 +-
libvirt.spec.in | 65 +-
m4/virt-driver-uml.m4 | 54 -
mingw-libvirt.spec.in | 1 -
po/POTFILES | 2 -
src/Makefile.am | 1 -
src/README | 3 +-
src/conf/domain_conf.c | 11 +-
src/conf/domain_conf.h | 4 -
src/locking/lock_driver.h | 2 +-
src/qemu/qemu_alias.c | 1 -
src/qemu/qemu_command.c | 4 -
src/qemu/qemu_domain_address.c | 1 -
src/qemu/qemu_hotplug.c | 1 -
src/remote/Makefile.inc.am | 1 -
src/remote/libvirtd.uml.logrotate.in | 8 -
src/remote/remote_daemon.c | 4 -
src/uml/Makefile.inc.am | 48 -
src/uml/uml_conf.c | 481 -----
src/uml/uml_conf.h | 82 -
src/uml/uml_driver.c | 2835 --------------------------
src/uml/uml_driver.h | 29 -
src/vbox/vbox_common.c | 1 -
tests/domaincapsschemadata/basic.xml | 25 -
tests/domaincapsschemadata/full.xml | 1 -
tests/domaincapstest.c | 2 -
tests/objectlocking.ml | 3 -
tests/virdrivermoduletest.c | 3 -
tools/virsh.c | 3 -
40 files changed, 24 insertions(+), 3787 deletions(-)
delete mode 100644 docs/drvuml.html.in
delete mode 100644 m4/virt-driver-uml.m4
delete mode 100644 src/remote/libvirtd.uml.logrotate.in
delete mode 100644 src/uml/Makefile.inc.am
delete mode 100644 src/uml/uml_conf.c
delete mode 100644 src/uml/uml_conf.h
delete mode 100644 src/uml/uml_driver.c
delete mode 100644 src/uml/uml_driver.h
delete mode 100644 tests/domaincapsschemadata/basic.xml
diff --git a/configure.ac b/configure.ac
index 8c89ff365b..ac52189dff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -225,7 +225,6 @@ if test "$with_libvirtd" = "no" ; then
with_qemu=no
with_lxc=no
with_libxl=no
- with_uml=no
with_vbox=no
fi
@@ -445,7 +444,6 @@ LIBVIRT_DRIVER_ARG_VBOX
LIBVIRT_DRIVER_ARG_LXC
LIBVIRT_DRIVER_ARG_VZ
LIBVIRT_DRIVER_ARG_BHYVE
-LIBVIRT_DRIVER_ARG_UML
LIBVIRT_DRIVER_ARG_ESX
LIBVIRT_DRIVER_ARG_HYPERV
LIBVIRT_DRIVER_ARG_TEST
@@ -464,7 +462,6 @@ LIBVIRT_DRIVER_CHECK_VBOX
LIBVIRT_DRIVER_CHECK_LXC
LIBVIRT_DRIVER_CHECK_VZ
LIBVIRT_DRIVER_CHECK_BHYVE
-LIBVIRT_DRIVER_CHECK_UML
LIBVIRT_DRIVER_CHECK_ESX
LIBVIRT_DRIVER_CHECK_HYPERV
LIBVIRT_DRIVER_CHECK_TEST
@@ -947,7 +944,6 @@ AC_MSG_NOTICE([])
AC_MSG_NOTICE([Drivers])
AC_MSG_NOTICE([])
LIBVIRT_DRIVER_RESULT_QEMU
-LIBVIRT_DRIVER_RESULT_UML
LIBVIRT_DRIVER_RESULT_OPENVZ
LIBVIRT_DRIVER_RESULT_VMWARE
LIBVIRT_DRIVER_RESULT_VBOX
diff --git a/docs/aclpolkit.html.in b/docs/aclpolkit.html.in
index ac54f125da..2cf1f9b5a5 100644
--- a/docs/aclpolkit.html.in
+++ b/docs/aclpolkit.html.in
@@ -381,10 +381,6 @@
<td>storage</td>
<td>storage</td>
</tr>
- <tr>
- <td>uml</td>
- <td>UML</td>
- </tr>
<tr>
<td>vbox</td>
<td>VBOX</td>
diff --git a/docs/drivers.html.in b/docs/drivers.html.in
index c94144aa41..a66651df2f 100644
--- a/docs/drivers.html.in
+++ b/docs/drivers.html.in
@@ -29,7 +29,6 @@
<li><strong><a href="drvopenvz.html">OpenVZ</a></strong></li>
<li><strong><a href="drvqemu.html">QEMU</a></strong></li>
<li><strong><a href="drvtest.html">Test</a></strong> - Used for testing</li>
- <li><strong><a href="drvuml.html">UML</a></strong> - User Mode Linux</li>
<li><strong><a href="drvvbox.html">VirtualBox</a></strong></li>
<li><strong><a href="drvesx.html">VMware ESX</a></strong></li>
<li><strong><a href="drvvmware.html">VMware Workstation/Player</a></strong></li>
diff --git a/docs/drvuml.html.in b/docs/drvuml.html.in
deleted file mode 100644
index 0860db7dcf..0000000000
--- a/docs/drvuml.html.in
+++ /dev/null
@@ -1,93 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml">
- <body>
- <h1>User Mode Linux driver</h1>
-
- <p>
- The UML driver for libvirt allows use and management of paravirtualized
- guests built for User Mode Linux. UML requires no special support in
- the host kernel, so can be used by any user of any linux system, provided
- they have enough free RAM for their guest's needs, though there are
- certain restrictions on network connectivity unless the administrator
- has pre-created TAP devices.
- </p>
-
- <h2><a id="project">Project Links</a></h2>
-
- <ul>
- <li>
- The <a href="http://user-mode-linux.sourceforge.net/">User
- Mode Linux</a> paravirtualized kernel
- </li>
- </ul>
-
- <h2>Connections to UML driver</h2>
-
- <p>
- The libvirt UML driver follows the QEMU driver in providing two
- types of connection. There is one privileged instance per host,
- which runs as root. This is called the "system" instance, and allows
- full use of all host resources. Then, there is a per-user unprivileged
- "session", instance. This has more restricted capabilities, and may
- require the host administrator to setup certain resources ahead of
- time to allow full integration with the network. Example connection
- URIs are
- </p>
-
-<pre>
-uml:///session (local access to per-user instance)
-uml+unix:///session (local access to per-user instance)
-
-uml:///system (local access to system instance)
-uml+unix:///system (local access to system instance)
-uml://example.com/system (remote access, TLS/x509)
-uml+tcp://example.com/system (remote access, SASl/Kerberos)
-uml+ssh://root@example.com/system (remote access, SSH tunnelled)
-</pre>
-
- <h2>Example XML configuration</h2>
-
- <p>
- User mode Linux driver only supports directly kernel boot at
- this time. A future driver enhancement may allow a paravirt
- bootloader in a similar style to Xen's pygrub. For now though,
- the UML kernel must be stored on the host and referenced
- explicitly in the "os" element. Since UML is a paravirtualized
- technology, the kernel "type" is set to "uml"
- </p>
-
- <p>
- There is not yet support for networking in the driver, but
- disks can be specified in the usual libvirt manner. The main
- variation is the target device naming scheme "ubd0", and
- bus type of "uml".
- </p>
-
- <p>
- Once booted the primary console is connected to a PTY, and
- thus accessible with "virsh console" or equivalent tools
- </p>
-
-<pre>
-<domain type='uml'>
- <name>demo</name>
- <uuid>b4433fc2-a22e-ffb3-0a3d-9c173b395800</uuid>
- <memory>500000</memory>
- <currentMemory>500000</currentMemory>
- <vcpu>1</vcpu>
- <os>
- <type arch='x86_64'>uml</type>
- <kernel>/home/berrange/linux-uml-2.6.26-x86_64</kernel>
- </os>
- <devices>
- <disk type='file' device='disk'>
- <source file='/home/berrange/FedoraCore6-AMD64-root_fs'/>
- <target dev='ubd0' bus='uml'/>
- </disk>
- <console type='pty'/>
- </devices>
-</domain>
-</pre>
- </body>
-</html>
diff --git a/docs/formatcaps.html.in b/docs/formatcaps.html.in
index 86534b2ed2..2a0aa963bb 100644
--- a/docs/formatcaps.html.in
+++ b/docs/formatcaps.html.in
@@ -87,9 +87,6 @@
<dt><code>exe</code></dt>
<dd>Container based virtualization</dd>
-
- <dt><code>uml</code></dt>
- <dd>User Mode Linux</dd>
</dl>
</dd>
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 428b0e8bb5..2463261372 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -7161,9 +7161,9 @@ qemu-kvm -net nic,model=? /dev/null
Valid values for the <code>type</code> attribute are:
<code>serial</code> (described below);
<code>virtio</code> (usable whenever VirtIO support is available);
- <code>xen</code>, <code>lxc</code>, <code>uml</code> and
- <code>openvz</code> (available when the corresponding hypervisor is in
- use). <code>sclp</code> and <code>sclplm</code> (usable for s390 and
+ <code>xen</code>, <code>lxc</code> and <code>openvz</code>
+ (available when the corresponding hypervisor is in use).
+ <code>sclp</code> and <code>sclplm</code> (usable for s390 and
s390x QEMU guests) are supported for compatibility reasons but should
not be used for new guests: use the <code>sclpconsole</code> and
<code>sclplmconsole</code> target models, respectively, with the
diff --git a/docs/formatdomaincaps.html.in b/docs/formatdomaincaps.html.in
index 9920de4dac..cafd9abbdf 100644
--- a/docs/formatdomaincaps.html.in
+++ b/docs/formatdomaincaps.html.in
@@ -278,7 +278,6 @@
<value>virtio</value>
<value>xen</value>
<value>usb</value>
- <value>uml</value>
<value>sata</value>
<value>sd</value>
</enum>
diff --git a/docs/formatnwfilter.html.in b/docs/formatnwfilter.html.in
index b2282b7dee..796c16549d 100644
--- a/docs/formatnwfilter.html.in
+++ b/docs/formatnwfilter.html.in
@@ -2265,7 +2265,7 @@ echo 3 > /proc/sys/net/netfilter/nf_conntrack_icmp_timeout
to the incoming and outgoing direction. All this is related to the ftp
data traffic originating from TCP port 20 of the VM. This then leads to
the following solution
- <span class="since">(since 0.8.5 (QEMU, KVM, UML))</span>:
+ <span class="since">(since 0.8.5 (QEMU, KVM))</span>:
</p>
<pre>
<filter name='test-eth0'>
diff --git a/docs/news.xml b/docs/news.xml
index 5bdbd34a14..e9b6bb7c65 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -59,6 +59,20 @@
</description>
</change>
</section>
+ <section title="Removed features">
+ <change>
+ <summary>
+ Drop UML driver
+ </summary>
+ <description>
+ The UML driver was unmaintained and not tested for
+ quite some time now. Worse, there is a bug that causes
+ it to deadlock on some very basic operations (e.g.
+ dumping domain XML). These facts make us believe no one
+ uses it.
+ </description>
+ </change>
+ </section>
<section title="Improvements">
<change>
<summary>
diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
index fe90a2e4c6..74590f7a69 100644
--- a/docs/schemas/capability.rng
+++ b/docs/schemas/capability.rng
@@ -412,7 +412,6 @@
but is also used by phyp driver -->
<value>hvm</value> <!-- unmodified OS -->
<value>exe</value> <!-- For container based virt -->
- <value>uml</value> <!-- user mode linux -->
</choice>
</element>
</define>
@@ -484,7 +483,6 @@
<value>kqemu</value>
<value>kvm</value>
<value>xen</value>
- <value>uml</value>
<value>lxc</value>
<value>openvz</value>
<value>test</value>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 5a6c48f1aa..9b1a384032 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -204,7 +204,6 @@
<value>kvm</value>
<value>xen</value>
<value>lxc</value>
- <value>uml</value>
<value>openvz</value>
<value>test</value>
<value>vmware</value>
@@ -1907,7 +1906,6 @@
<value>virtio</value>
<value>xen</value>
<value>usb</value>
- <value>uml</value>
<value>sata</value>
<value>sd</value>
</choice>
@@ -3725,7 +3723,6 @@
<choice>
<value>xen</value>
<value>serial</value>
- <value>uml</value>
<value>virtio</value>
<value>lxc</value>
<value>openvz</value>
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index f41afcd0a7..fbbe2d5624 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -74,7 +74,7 @@ typedef enum {
VIR_FROM_NETWORK = 19, /* Error from network config */
VIR_FROM_DOMAIN = 20, /* Error from domain config */
- VIR_FROM_UML = 21, /* Error at the UML driver */
+ VIR_FROM_UML = 21, /* Error at the UML driver; unused since 5.0.0 */
VIR_FROM_NODEDEV = 22, /* Error from node device monitor */
VIR_FROM_XEN_INOTIFY = 23, /* Error from xen inotify layer */
VIR_FROM_SECURITY = 24, /* Error from security framework */
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 71cd45c603..09472dcadc 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -20,7 +20,6 @@
# The hypervisor drivers that run in libvirtd
%define with_qemu 0%{!?_without_qemu:1}
%define with_lxc 0%{!?_without_lxc:1}
-%define with_uml 0%{!?_without_uml:1}
%define with_libxl 0%{!?_without_libxl:1}
%define with_vbox 0%{!?_without_vbox:1}
@@ -111,13 +110,12 @@
%endif
-# RHEL doesn't ship OpenVZ, VBox, UML, PowerHypervisor,
+# RHEL doesn't ship OpenVZ, VBox, PowerHypervisor,
# VMware, libxenserver (xenapi), libxenlight (Xen 4.1 and newer),
# or HyperV.
%if 0%{?rhel}
%define with_openvz 0
%define with_vbox 0
- %define with_uml 0
%define with_phyp 0
%define with_vmware 0
%define with_xenapi 0
@@ -178,7 +176,7 @@
%endif
-%if %{with_qemu} || %{with_lxc} || %{with_uml}
+%if %{with_qemu} || %{with_lxc}
# numad is used to manage the CPU and memory placement dynamically,
# it's not available on many non-x86 architectures.
%ifnarch s390 s390x %{arm} riscv64
@@ -231,9 +229,6 @@ Requires: libvirt-daemon-driver-lxc = %{version}-%{release}
%if %{with_qemu}
Requires: libvirt-daemon-driver-qemu = %{version}-%{release}
%endif
-%if %{with_uml}
-Requires: libvirt-daemon-driver-uml = %{version}-%{release}
-%endif
%if %{with_vbox}
Requires: libvirt-daemon-driver-vbox = %{version}-%{release}
%endif
@@ -743,19 +738,6 @@ the Linux kernel
%endif
-%if %{with_uml}
-%package daemon-driver-uml
-Summary: Uml driver plugin for the libvirtd daemon
-Requires: libvirt-daemon = %{version}-%{release}
-Requires: libvirt-libs = %{version}-%{release}
-
-%description daemon-driver-uml
-The UML driver plugin for the libvirtd daemon, providing
-an implementation of the hypervisor driver APIs using
-User Mode Linux
-%endif
-
-
%if %{with_vbox}
%package daemon-driver-vbox
Summary: VirtualBox driver plugin for the libvirtd daemon
@@ -843,26 +825,6 @@ capabilities of LXC
%endif
-%if %{with_uml}
-%package daemon-uml
-Summary: Server side daemon & driver required to run UML guests
-
-Requires: libvirt-daemon = %{version}-%{release}
-Requires: libvirt-daemon-driver-uml = %{version}-%{release}
-Requires: libvirt-daemon-driver-interface = %{version}-%{release}
-Requires: libvirt-daemon-driver-network = %{version}-%{release}
-Requires: libvirt-daemon-driver-nodedev = %{version}-%{release}
-Requires: libvirt-daemon-driver-nwfilter = %{version}-%{release}
-Requires: libvirt-daemon-driver-secret = %{version}-%{release}
-Requires: libvirt-daemon-driver-storage = %{version}-%{release}
-# There are no UML kernel RPMs in Fedora/RHEL to depend on.
-
-%description daemon-uml
-Server side daemon and driver required to manage the virtualization
-capabilities of UML
-%endif
-
-
%if %{with_libxl}
%package daemon-xen
Summary: Server side daemon & driver required to run XEN guests
@@ -1068,12 +1030,6 @@ exit 1
%define arg_vmware --without-vmware
%endif
-%if %{with_uml}
- %define arg_uml --with-uml
-%else
- %define arg_uml --without-uml
-%endif
-
%if %{with_storage_rbd}
%define arg_storage_rbd --with-storage-rbd
%else
@@ -1187,7 +1143,6 @@ rm -f po/stamp-po
--with-avahi \
--with-polkit \
--with-libvirtd \
- %{?arg_uml} \
%{?arg_phyp} \
%{?arg_esx} \
%{?arg_hyperv} \
@@ -1316,9 +1271,6 @@ rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/libvirtd.libxl
rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/libvirtd_libxl.aug
rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/tests/test_libvirtd_libxl.aug
%endif
-%if ! %{with_uml}
-rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/libvirtd.uml
-%endif
# Copied into libvirt-docs subpackage eventually
mv $RPM_BUILD_ROOT%{_datadir}/doc/libvirt-%{version} libvirt-docs
@@ -1725,15 +1677,6 @@ exit 0
%{_libdir}/%{name}/connection-driver/libvirt_driver_lxc.so
%endif
-%if %{with_uml}
-%files daemon-driver-uml
-%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/uml/
-%config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd.uml
-%ghost %dir %{_localstatedir}/run/libvirt/uml/
-%dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/uml/
-%{_libdir}/%{name}/connection-driver/libvirt_driver_uml.so
-%endif
-
%if %{with_libxl}
%files daemon-driver-libxl
%config(noreplace) %{_sysconfdir}/libvirt/libxl.conf
@@ -1764,10 +1707,6 @@ exit 0
%files daemon-lxc
%endif
-%if %{with_uml}
-%files daemon-uml
-%endif
-
%if %{with_libxl}
%files daemon-xen
%endif
diff --git a/m4/virt-driver-uml.m4 b/m4/virt-driver-uml.m4
deleted file mode 100644
index 9b406a5b6b..0000000000
--- a/m4/virt-driver-uml.m4
+++ /dev/null
@@ -1,54 +0,0 @@
-dnl The UML driver
-dnl
-dnl Copyright (C) 2005-2015 Red Hat, Inc.
-dnl
-dnl This library is free software; you can redistribute it and/or
-dnl modify it under the terms of the GNU Lesser General Public
-dnl License as published by the Free Software Foundation; either
-dnl version 2.1 of the License, or (at your option) any later version.
-dnl
-dnl This library is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-dnl Lesser General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU Lesser General Public
-dnl License along with this library. If not, see
-dnl <http://www.gnu.org/licenses/>.
-dnl
-
-AC_DEFUN([LIBVIRT_DRIVER_ARG_UML],[
- LIBVIRT_ARG_WITH_FEATURE([UML], [UML], [check])
-])
-
-AC_DEFUN([LIBVIRT_DRIVER_CHECK_UML],[
- if test "$with_libvirtd" = "no" || test "$with_linux" = "no"; then
- if test "$with_uml" = "yes"; then
- AC_MSG_ERROR([The UML driver cannot be enabled])
- elif test "$with_uml" = "check"; then
- with_uml="no"
- fi
- fi
-
- if test "$with_uml" = "yes" || test "$with_uml" = "check"; then
- AC_CHECK_HEADER([sys/inotify.h], [
- with_uml=yes
- ], [
- if test "$with_uml" = "check"; then
- with_uml=no
- AC_MSG_NOTICE([<sys/inotify.h> is required for the UML driver, disabling it])
- else
- AC_MSG_ERROR([The <sys/inotify.h> is required for the UML driver. Upgrade your libc6.])
- fi
- ])
- fi
-
- if test "$with_uml" = "yes" ; then
- AC_DEFINE_UNQUOTED([WITH_UML], 1, [whether UML driver is enabled])
- fi
- AM_CONDITIONAL([WITH_UML], [test "$with_uml" = "yes"])
-])
-
-AC_DEFUN([LIBVIRT_DRIVER_RESULT_UML],[
- LIBVIRT_RESULT([UML], [$with_uml])
-])
diff --git a/mingw-libvirt.spec.in b/mingw-libvirt.spec.in
index b28e40f7f7..7c7ab4146d 100644
--- a/mingw-libvirt.spec.in
+++ b/mingw-libvirt.spec.in
@@ -177,7 +177,6 @@ autoreconf -if
--without-avahi \
--without-polkit \
--without-libvirtd \
- --without-uml \
%{?_without_phyp} \
%{?_without_esx} \
%{?_without_hyperv} \
diff --git a/po/POTFILES b/po/POTFILES
index be2874487c..9dd4ee7d99 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -190,8 +190,6 @@ src/storage/storage_backend_zfs.c
src/storage/storage_driver.c
src/storage/storage_util.c
src/test/test_driver.c
-src/uml/uml_conf.c
-src/uml/uml_driver.c
src/util/iohelper.c
src/util/viralloc.c
src/util/virarptable.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 33ff280d78..e2b89e27e8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -107,7 +107,6 @@ include logging/Makefile.inc.am
include locking/Makefile.inc.am
include admin/Makefile.inc.am
include rpc/Makefile.inc.am
-include uml/Makefile.inc.am
include phyp/Makefile.inc.am
include test/Makefile.inc.am
include esx/Makefile.inc.am
diff --git a/src/README b/src/README
index bb3cddfc6e..846bf2b664 100644
--- a/src/README
+++ b/src/README
@@ -34,7 +34,6 @@ Then there are the hypervisor implementations:
* qemu/ - QEMU / KVM using qemu CLI/monitor
* remote/ - Generic libvirt native RPC client
* test/ - A "mock" driver for testing
- * uml/ - User Mode Linux
* vbox/ - Virtual Box using native API
* vmware/ - VMware Workstation and Player using the vmrun tool
* xen/ - Xen using hypercalls, XenD SEXPR & XenStore
@@ -42,7 +41,7 @@ Then there are the hypervisor implementations:
Finally some secondary drivers that are shared for several HVs.
-Currently these are used by LXC, OpenVZ, QEMU, UML and Xen drivers.
+Currently these are used by LXC, OpenVZ, QEMU and Xen drivers.
The ESX, Hyper-V, Power Hypervisor, Remote, Test & VirtualBox drivers all
implement the secondary drivers directly
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d8dfd1656f..7a2d20730e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -108,7 +108,6 @@ VIR_ENUM_IMPL(virDomainVirt, VIR_DOMAIN_VIRT_LAST,
"kvm",
"xen",
"lxc",
- "uml",
"openvz",
"test",
"vmware",
@@ -124,7 +123,6 @@ VIR_ENUM_IMPL(virDomainOS, VIR_DOMAIN_OSTYPE_LAST,
"xen",
"linux",
"exe",
- "uml",
"xenpvh")
VIR_ENUM_IMPL(virDomainBoot, VIR_DOMAIN_BOOT_LAST,
@@ -285,7 +283,6 @@ VIR_ENUM_IMPL(virDomainDiskBus, VIR_DOMAIN_DISK_BUS_LAST,
"virtio",
"xen",
"usb",
- "uml",
"sata",
"sd")
@@ -465,7 +462,6 @@ VIR_ENUM_IMPL(virDomainChrConsoleTarget,
"none",
"serial",
"xen",
- "uml",
"virtio",
"lxc",
"openvz",
@@ -5373,7 +5369,6 @@ virDomainDiskAddressDiskBusCompatibility(virDomainDiskBus bus,
case VIR_DOMAIN_DISK_BUS_VIRTIO:
case VIR_DOMAIN_DISK_BUS_XEN:
case VIR_DOMAIN_DISK_BUS_USB:
- case VIR_DOMAIN_DISK_BUS_UML:
case VIR_DOMAIN_DISK_BUS_SD:
case VIR_DOMAIN_DISK_BUS_LAST:
return true;
@@ -9798,8 +9793,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
def->bus = VIR_DOMAIN_DISK_BUS_VIRTIO;
else if (STRPREFIX(target, "xvd"))
def->bus = VIR_DOMAIN_DISK_BUS_XEN;
- else if (STRPREFIX(target, "ubd"))
- def->bus = VIR_DOMAIN_DISK_BUS_UML;
else
def->bus = VIR_DOMAIN_DISK_BUS_IDE;
}
@@ -15067,7 +15060,6 @@ virDomainVideoDefaultType(const virDomainDef *def)
case VIR_DOMAIN_VIRT_KQEMU:
case VIR_DOMAIN_VIRT_KVM:
case VIR_DOMAIN_VIRT_LXC:
- case VIR_DOMAIN_VIRT_UML:
case VIR_DOMAIN_VIRT_OPENVZ:
case VIR_DOMAIN_VIRT_HYPERV:
case VIR_DOMAIN_VIRT_PHYP:
@@ -18819,8 +18811,7 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
if (def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
def->os.type == VIR_DOMAIN_OSTYPE_XENPVH ||
- def->os.type == VIR_DOMAIN_OSTYPE_HVM ||
- def->os.type == VIR_DOMAIN_OSTYPE_UML) {
+ def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
xmlNodePtr loader_node;
def->os.kernel = virXPathString("string(./os/kernel[1])", ctxt);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 5814997bdb..e15308dd28 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -233,7 +233,6 @@ typedef enum {
VIR_DOMAIN_VIRT_KVM,
VIR_DOMAIN_VIRT_XEN,
VIR_DOMAIN_VIRT_LXC,
- VIR_DOMAIN_VIRT_UML,
VIR_DOMAIN_VIRT_OPENVZ,
VIR_DOMAIN_VIRT_TEST,
VIR_DOMAIN_VIRT_VMWARE,
@@ -252,7 +251,6 @@ typedef enum {
VIR_DOMAIN_OSTYPE_XEN,
VIR_DOMAIN_OSTYPE_LINUX,
VIR_DOMAIN_OSTYPE_EXE,
- VIR_DOMAIN_OSTYPE_UML,
VIR_DOMAIN_OSTYPE_XENPVH,
VIR_DOMAIN_OSTYPE_LAST
@@ -479,7 +477,6 @@ typedef enum {
VIR_DOMAIN_DISK_BUS_VIRTIO,
VIR_DOMAIN_DISK_BUS_XEN,
VIR_DOMAIN_DISK_BUS_USB,
- VIR_DOMAIN_DISK_BUS_UML,
VIR_DOMAIN_DISK_BUS_SATA,
VIR_DOMAIN_DISK_BUS_SD,
@@ -1114,7 +1111,6 @@ typedef enum {
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE = 0,
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL,
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN,
- VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML,
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO,
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC,
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ,
diff --git a/src/locking/lock_driver.h b/src/locking/lock_driver.h
index f2d5266517..50c73a70d4 100644
--- a/src/locking/lock_driver.h
+++ b/src/locking/lock_driver.h
@@ -124,7 +124,7 @@ struct _virLockManagerParam {
* too old to support key features.
*
* NB: A plugin may be loaded multiple times, for different
- * libvirt drivers (eg QEMU, LXC, UML)
+ * libvirt drivers (eg QEMU, LXC)
*
* Returns -1 if the requested version/flags were inadequate
*/
diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
index 585cc972ba..45fcbf5eda 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -245,7 +245,6 @@ qemuAssignDeviceDiskAlias(virDomainDefPtr def,
break;
case VIR_DOMAIN_DISK_BUS_XEN:
- case VIR_DOMAIN_DISK_BUS_UML:
case VIR_DOMAIN_DISK_BUS_SD:
case VIR_DOMAIN_DISK_BUS_LAST:
break;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 66a4a35184..8696104949 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -78,7 +78,6 @@ VIR_ENUM_IMPL(virDomainDiskQEMUBus, VIR_DOMAIN_DISK_BUS_LAST,
"virtio",
"xen",
"usb",
- "uml",
"sata",
"sd")
@@ -1808,7 +1807,6 @@ qemuCheckIOThreads(const virDomainDef *def,
case VIR_DOMAIN_DISK_BUS_SCSI:
case VIR_DOMAIN_DISK_BUS_XEN:
case VIR_DOMAIN_DISK_BUS_USB:
- case VIR_DOMAIN_DISK_BUS_UML:
case VIR_DOMAIN_DISK_BUS_SATA:
case VIR_DOMAIN_DISK_BUS_SD:
case VIR_DOMAIN_DISK_BUS_LAST:
@@ -7254,7 +7252,6 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
case VIR_DOMAIN_VIRT_KQEMU:
case VIR_DOMAIN_VIRT_XEN:
case VIR_DOMAIN_VIRT_LXC:
- case VIR_DOMAIN_VIRT_UML:
case VIR_DOMAIN_VIRT_OPENVZ:
case VIR_DOMAIN_VIRT_TEST:
case VIR_DOMAIN_VIRT_VMWARE:
@@ -10780,7 +10777,6 @@ qemuBuildConsoleChrDeviceStr(char **deviceStr,
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE:
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN:
- case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML:
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC:
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ:
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST:
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index bd6c4031e0..684811db3a 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -730,7 +730,6 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_DISK_BUS_SCSI:
case VIR_DOMAIN_DISK_BUS_XEN:
case VIR_DOMAIN_DISK_BUS_USB:
- case VIR_DOMAIN_DISK_BUS_UML:
case VIR_DOMAIN_DISK_BUS_SATA:
case VIR_DOMAIN_DISK_BUS_SD:
case VIR_DOMAIN_DISK_BUS_LAST:
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 8da023315b..e87a89a555 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1226,7 +1226,6 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriverPtr driver,
case VIR_DOMAIN_DISK_BUS_IDE:
case VIR_DOMAIN_DISK_BUS_FDC:
case VIR_DOMAIN_DISK_BUS_XEN:
- case VIR_DOMAIN_DISK_BUS_UML:
case VIR_DOMAIN_DISK_BUS_SATA:
case VIR_DOMAIN_DISK_BUS_SD:
/* Note that SD card hotplug support should be added only once
diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am
index eb8d6feb31..d188c4e348 100644
--- a/src/remote/Makefile.inc.am
+++ b/src/remote/Makefile.inc.am
@@ -39,7 +39,6 @@ LOGROTATE_FILES_IN += \
remote/libvirtd.qemu.logrotate.in \
remote/libvirtd.lxc.logrotate.in \
remote/libvirtd.libxl.logrotate.in \
- remote/libvirtd.uml.logrotate.in \
remote/libvirtd.logrotate.in \
$(NULL)
diff --git a/src/remote/libvirtd.uml.logrotate.in b/src/remote/libvirtd.uml.logrotate.in
deleted file mode 100644
index 66a848e37e..0000000000
--- a/src/remote/libvirtd.uml.logrotate.in
+++ /dev/null
@@ -1,8 +0,0 @@
-@localstatedir(a)/log/libvirt/uml/*.log {
- weekly
- missingok
- rotate 4
- compress
- delaycompress
- copytruncate
-}
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index f0dd7597e6..3be3ad02fc 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -339,10 +339,6 @@ static int daemonInitialize(void)
if (virDriverLoadModule("lxc", "lxcRegister", false) < 0)
return -1;
#endif
-#ifdef WITH_UML
- if (virDriverLoadModule("uml", "umlRegister", false) < 0)
- return -1;
-#endif
#ifdef WITH_VBOX
if (virDriverLoadModule("vbox", "vboxRegister", false) < 0)
return -1;
diff --git a/src/uml/Makefile.inc.am b/src/uml/Makefile.inc.am
deleted file mode 100644
index 975398b928..0000000000
--- a/src/uml/Makefile.inc.am
+++ /dev/null
@@ -1,48 +0,0 @@
-UML_DRIVER_SOURCES = \
- uml/uml_conf.c \
- uml/uml_conf.h \
- uml/uml_driver.c \
- uml/uml_driver.h \
- $(NULL)
-
-DRIVER_SOURCE_FILES += $(UML_DRIVER_SOURCES)
-STATEFUL_DRIVER_SOURCE_FILES += $(UML_DRIVER_SOURCES)
-EXTRA_DIST += $(UML_DRIVER_SOURCES)
-
-if WITH_UML
-noinst_LTLIBRARIES += libvirt_driver_uml_impl.la
-libvirt_driver_uml_la_SOURCES =
-libvirt_driver_uml_la_LIBADD = \
- libvirt_driver_uml_impl.la \
- libvirt.la \
- ../gnulib/lib/libgnu.la \
- $(NULL)
-mod_LTLIBRARIES += libvirt_driver_uml.la
-libvirt_driver_uml_la_LDFLAGS = $(AM_LDFLAGS_MOD_NOUNDEF)
-
-libvirt_driver_uml_impl_la_CFLAGS = \
- -I$(srcdir)/access \
- -I$(srcdir)/conf \
- $(AM_CFLAGS) \
- $(NULL)
-libvirt_driver_uml_impl_la_LDFLAGS = $(AM_LDFLAGS)
-libvirt_driver_uml_impl_la_SOURCES = $(UML_DRIVER_SOURCES)
-
-INSTALL_DATA_DIRS += uml
-
-install-data-uml:
- $(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/uml"
- $(MKDIR_P) "$(DESTDIR)$(localstatedir)/run/libvirt/uml"
- $(MKDIR_P) "$(DESTDIR)$(localstatedir)/log/libvirt/uml"
-
-uninstall-data-uml:
- rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/uml" ||:
- rmdir "$(DESTDIR)$(localstatedir)/run/libvirt/uml" ||:
- rmdir "$(DESTDIR)$(localstatedir)/log/libvirt/uml" ||:
-
-endif WITH_UML
-
-.PHONY: \
- install-data-uml \
- uninstall-data-uml \
- $(NULL)
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
deleted file mode 100644
index 067600afba..0000000000
--- a/src/uml/uml_conf.c
+++ /dev/null
@@ -1,481 +0,0 @@
-/*
- * uml_conf.c: UML driver configuration
- *
- * Copyright (C) 2006-2014, 2016 Red Hat, Inc.
- * Copyright (C) 2006 Daniel P. Berrange
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-
-#include <config.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/wait.h>
-#include <arpa/inet.h>
-
-#include "uml_conf.h"
-#include "viruuid.h"
-#include "virbuffer.h"
-#include "virconf.h"
-#include "viralloc.h"
-#include "virlog.h"
-#include "domain_nwfilter.h"
-#include "virfile.h"
-#include "vircommand.h"
-#include "virnetdevtap.h"
-#include "virnodesuspend.h"
-#include "virstring.h"
-
-#define VIR_FROM_THIS VIR_FROM_UML
-
-VIR_LOG_INIT("uml.uml_conf");
-
-virCapsPtr umlCapsInit(void)
-{
- virCapsPtr caps;
- virCapsGuestPtr guest;
-
- if ((caps = virCapabilitiesNew(virArchFromHost(),
- false, false)) == NULL)
- goto error;
-
- /* Some machines have problematic NUMA topology causing
- * unexpected failures. We don't want to break the QEMU
- * driver in this scenario, so log errors & carry on
- */
- if (virCapabilitiesInitNUMA(caps) < 0) {
- virCapabilitiesFreeNUMAInfo(caps);
- VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities");
- }
-
- if (virCapabilitiesInitCaches(caps) < 0)
- VIR_WARN("Failed to get host CPU cache info");
-
- if (virNodeSuspendGetTargetMask(&caps->host.powerMgmt) < 0)
- VIR_WARN("Failed to get host power management capabilities");
-
- if (virGetHostUUID(caps->host.host_uuid)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("cannot get the host uuid"));
- goto error;
- }
-
- if ((guest = virCapabilitiesAddGuest(caps,
- VIR_DOMAIN_OSTYPE_UML,
- caps->host.arch,
- NULL,
- NULL,
- 0,
- NULL)) == NULL)
- goto error;
-
- if (virCapabilitiesAddGuestDomain(guest,
- VIR_DOMAIN_VIRT_UML,
- NULL,
- NULL,
- 0,
- NULL) == NULL)
- goto error;
-
- return caps;
-
- error:
- virObjectUnref(caps);
- return NULL;
-}
-
-
-static int
-umlConnectTapDevice(virDomainDefPtr vm,
- virDomainNetDefPtr net,
- const char *bridge)
-{
- bool template_ifname = false;
- int tapfd = -1;
-
- if (!net->ifname ||
- STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) ||
- strchr(net->ifname, '%')) {
- VIR_FREE(net->ifname);
- if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") < 0)
- goto error;
- /* avoid exposing vnet%d in getXMLDesc or error outputs */
- template_ifname = true;
- }
-
- if (virNetDevTapCreateInBridgePort(bridge, &net->ifname, &net->mac,
- vm->uuid, net->backend.tap, &tapfd, 1,
- virDomainNetGetActualVirtPortProfile(net),
- virDomainNetGetActualVlan(net),
- NULL, 0, NULL,
- VIR_NETDEV_TAP_CREATE_IFUP |
- VIR_NETDEV_TAP_CREATE_PERSIST) < 0) {
- if (template_ifname)
- VIR_FREE(net->ifname);
- goto error;
- }
-
- if (net->filter) {
- if (virDomainConfNWFilterInstantiate(vm->name, vm->uuid, net, false) < 0) {
- if (template_ifname)
- VIR_FREE(net->ifname);
- goto error;
- }
- }
-
- VIR_FORCE_CLOSE(tapfd);
- return 0;
-
- error:
- VIR_FORCE_CLOSE(tapfd);
- return -1;
-}
-
-static char *
-umlBuildCommandLineNet(virConnectPtr conn,
- virDomainDefPtr vm,
- virDomainNetDefPtr def,
- int idx)
-{
- virBuffer buf = VIR_BUFFER_INITIALIZER;
- char macaddr[VIR_MAC_STRING_BUFLEN];
-
- /* General format: ethNN=type,options */
-
- virBufferAsprintf(&buf, "eth%d=", idx);
-
- switch (def->type) {
- case VIR_DOMAIN_NET_TYPE_USER:
- /* ethNNN=slirp,macaddr */
- virBufferAddLit(&buf, "slirp");
- break;
-
- case VIR_DOMAIN_NET_TYPE_ETHERNET:
- /* ethNNN=tuntap,tapname,macaddr,gateway */
- virBufferAddLit(&buf, "tuntap,");
- if (def->ifname)
- virBufferAdd(&buf, def->ifname, -1);
- if (def->guestIP.nips > 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("IP address not supported for ethernet interface"));
- goto error;
- }
- break;
-
- case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("vhostuser networking type not supported"));
- goto error;
-
- case VIR_DOMAIN_NET_TYPE_SERVER:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("TCP server networking type not supported"));
- goto error;
-
- case VIR_DOMAIN_NET_TYPE_CLIENT:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("TCP client networking type not supported"));
- goto error;
-
- case VIR_DOMAIN_NET_TYPE_UDP:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("UDP networking type not supported"));
- goto error;
-
- case VIR_DOMAIN_NET_TYPE_MCAST:
- /* ethNNN=tuntap,macaddr,ipaddr,port */
- virBufferAddLit(&buf, "mcast");
- break;
-
- case VIR_DOMAIN_NET_TYPE_NETWORK:
- {
- char *bridge;
- virNetworkPtr network = virNetworkLookupByName(conn,
- def->data.network.name);
- if (!network) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Network '%s' not found"),
- def->data.network.name);
- goto error;
- }
- bridge = virNetworkGetBridgeName(network);
- virObjectUnref(network);
- if (bridge == NULL)
- goto error;
-
- if (umlConnectTapDevice(vm, def, bridge) < 0) {
- VIR_FREE(bridge);
- goto error;
- }
-
- /* ethNNN=tuntap,tapname,macaddr,gateway */
- virBufferAsprintf(&buf, "tuntap,%s", def->ifname);
- break;
- }
-
- case VIR_DOMAIN_NET_TYPE_BRIDGE:
- if (umlConnectTapDevice(vm, def,
- def->data.bridge.brname) < 0)
- goto error;
-
- /* ethNNN=tuntap,tapname,macaddr,gateway */
- virBufferAsprintf(&buf, "tuntap,%s", def->ifname);
- break;
-
- case VIR_DOMAIN_NET_TYPE_INTERNAL:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("internal networking type not supported"));
- goto error;
-
- case VIR_DOMAIN_NET_TYPE_DIRECT:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("direct networking type not supported"));
- goto error;
-
- case VIR_DOMAIN_NET_TYPE_HOSTDEV:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("hostdev networking type not supported"));
- goto error;
-
- case VIR_DOMAIN_NET_TYPE_LAST:
- break;
- }
-
- if (def->script) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("interface script execution not supported by this driver"));
- goto error;
- }
-
- virBufferAsprintf(&buf, ",%s", virMacAddrFormat(&def->mac, macaddr));
-
- if (def->type == VIR_DOMAIN_NET_TYPE_MCAST) {
- virBufferAsprintf(&buf, ",%s,%d",
- def->data.socket.address,
- def->data.socket.port);
- }
-
- if (virBufferCheckError(&buf) < 0)
- return NULL;
-
- return virBufferContentAndReset(&buf);
-
- error:
- virBufferFreeAndReset(&buf);
- return NULL;
-}
-
-static char *
-umlBuildCommandLineChr(virDomainChrDefPtr def,
- const char *dev,
- virCommandPtr cmd)
-{
- char *ret = NULL;
-
- switch (def->source->type) {
- case VIR_DOMAIN_CHR_TYPE_NULL:
- if (virAsprintf(&ret, "%s%d=null", dev, def->target.port) < 0)
- return NULL;
- break;
-
- case VIR_DOMAIN_CHR_TYPE_PTY:
- if (virAsprintf(&ret, "%s%d=pts", dev, def->target.port) < 0)
- return NULL;
- break;
-
- case VIR_DOMAIN_CHR_TYPE_DEV:
- if (virAsprintf(&ret, "%s%d=tty:%s", dev, def->target.port,
- def->source->data.file.path) < 0)
- return NULL;
- break;
-
- case VIR_DOMAIN_CHR_TYPE_STDIO:
- if (virAsprintf(&ret, "%s%d=fd:0,fd:1", dev, def->target.port) < 0)
- return NULL;
- break;
-
- case VIR_DOMAIN_CHR_TYPE_TCP:
- if (def->source->data.tcp.listen != 1) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("only TCP listen is supported for chr device"));
- return NULL;
- }
-
- if (virAsprintf(&ret, "%s%d=port:%s", dev, def->target.port,
- def->source->data.tcp.service) < 0)
- return NULL;
- break;
-
- case VIR_DOMAIN_CHR_TYPE_FILE:
- {
- int fd_out;
-
- if ((fd_out = open(def->source->data.file.path,
- O_WRONLY | O_APPEND | O_CREAT, 0660)) < 0) {
- virReportSystemError(errno,
- _("failed to open chardev file: %s"),
- def->source->data.file.path);
- return NULL;
- }
- if (virAsprintf(&ret, "%s%d=null,fd:%d", dev, def->target.port, fd_out) < 0) {
- VIR_FORCE_CLOSE(fd_out);
- return NULL;
- }
- virCommandPassFD(cmd, fd_out,
- VIR_COMMAND_PASS_FD_CLOSE_PARENT);
- }
- break;
- case VIR_DOMAIN_CHR_TYPE_PIPE:
- /* XXX could open the pipe & just pass the FDs. Be wary of
- * the effects of blocking I/O, though. */
-
- case VIR_DOMAIN_CHR_TYPE_VC:
- case VIR_DOMAIN_CHR_TYPE_UDP:
- case VIR_DOMAIN_CHR_TYPE_UNIX:
- default:
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unsupported chr device type %d"), def->source->type);
- break;
- }
-
- return ret;
-}
-
-/*
- * Null-terminate the current argument and return a pointer to the next.
- * This should follow the same rules as the Linux kernel: arguments are
- * separated by spaces; arguments can be quoted with double quotes; double
- * quotes can't be escaped.
- */
-static char *umlNextArg(char *args)
-{
- int in_quote = 0;
-
- for (; *args; args++) {
- if (*args == ' ' && !in_quote) {
- *args++ = '\0';
- break;
- }
- if (*args == '"')
- in_quote = !in_quote;
- }
-
- while (*args == ' ')
- args++;
-
- return args;
-}
-
-/*
- * Constructs a argv suitable for launching uml with config defined
- * for a given virtual machine.
- */
-virCommandPtr umlBuildCommandLine(virConnectPtr conn,
- struct uml_driver *driver,
- virDomainObjPtr vm)
-{
- size_t i, j;
- virCommandPtr cmd;
-
- cmd = virCommandNew(vm->def->os.kernel);
-
- virCommandAddEnvPassCommon(cmd);
-
- /* virCommandAddArgPair(cmd, "con0", "fd:0,fd:1"); */
- virCommandAddArgFormat(cmd, "mem=%lluK", vm->def->mem.cur_balloon);
- virCommandAddArgPair(cmd, "umid", vm->def->name);
- virCommandAddArgPair(cmd, "uml_dir", driver->monitorDir);
-
- if (vm->def->os.root)
- virCommandAddArgPair(cmd, "root", vm->def->os.root);
-
- for (i = 0; i < vm->def->ndisks; i++) {
- virDomainDiskDefPtr disk = vm->def->disks[i];
-
- if (!STRPREFIX(disk->dst, "ubd")) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unsupported disk type '%s'"), disk->dst);
- goto error;
- }
-
- virCommandAddArgPair(cmd, disk->dst, virDomainDiskGetSource(disk));
- }
-
- for (i = 0; i < vm->def->nnets; i++) {
- char *ret = umlBuildCommandLineNet(conn, vm->def, vm->def->nets[i], i);
- if (!ret)
- goto error;
- virCommandAddArg(cmd, ret);
- VIR_FREE(ret);
- }
-
- for (i = 0; i < UML_MAX_CHAR_DEVICE; i++) {
- virDomainChrDefPtr chr = NULL;
- char *ret = NULL;
- for (j = 0; j < vm->def->nconsoles; j++)
- if (vm->def->consoles[j]->target.port == i)
- chr = vm->def->consoles[j];
- if (chr)
- ret = umlBuildCommandLineChr(chr, "con", cmd);
- if (!ret)
- if (virAsprintf(&ret, "con%zu=none", i) < 0)
- goto error;
- virCommandAddArg(cmd, ret);
- VIR_FREE(ret);
- }
-
- for (i = 0; i < UML_MAX_CHAR_DEVICE; i++) {
- virDomainChrDefPtr chr = NULL;
- char *ret = NULL;
- for (j = 0; j < vm->def->nserials; j++)
- if (vm->def->serials[j]->target.port == i)
- chr = vm->def->serials[j];
- if (chr)
- ret = umlBuildCommandLineChr(chr, "ssl", cmd);
- if (!ret)
- if (virAsprintf(&ret, "ssl%zu=none", i) < 0)
- goto error;
-
- virCommandAddArg(cmd, ret);
- VIR_FREE(ret);
- }
-
- if (vm->def->os.cmdline) {
- char *args, *next_arg;
- char *cmdline;
- if (VIR_STRDUP(cmdline, vm->def->os.cmdline) < 0)
- goto error;
-
- args = cmdline;
- while (*args == ' ')
- args++;
-
- while (*args) {
- next_arg = umlNextArg(args);
- virCommandAddArg(cmd, args);
- args = next_arg;
- }
- VIR_FREE(cmdline);
- }
-
- return cmd;
-
- error:
- virCommandFree(cmd);
- return NULL;
-}
diff --git a/src/uml/uml_conf.h b/src/uml/uml_conf.h
deleted file mode 100644
index a9520a6d3e..0000000000
--- a/src/uml/uml_conf.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * uml_conf.h: VM configuration management
- *
- * Copyright (C) 2006, 2007, 2010 Red Hat, Inc.
- * Copyright (C) 2006 Daniel P. Berrange
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-
-#ifndef LIBVIRT_UML_CONF_H
-# define LIBVIRT_UML_CONF_H
-
-# include "internal.h"
-# include "libvirt_internal.h"
-# include "capabilities.h"
-# include "network_conf.h"
-# include "virdomainobjlist.h"
-# include "domain_event.h"
-# include "virerror.h"
-# include "virthread.h"
-# include "vircommand.h"
-# include "virhash.h"
-
-# define umlDebug(fmt, ...) do {} while (0)
-
-# define UML_CPUMASK_LEN CPU_SETSIZE
-
-# define UML_MAX_CHAR_DEVICE 16
-
-/* Main driver state */
-struct uml_driver {
- virMutex lock;
-
- bool privileged;
- virStateInhibitCallback inhibitCallback;
- void *inhibitOpaque;
-
- unsigned long umlVersion;
- int nextvmid;
-
- virDomainObjListPtr domains;
- size_t nactive;
-
- char *configDir;
- char *autostartDir;
- char *logDir;
- char *monitorDir;
-
- int inotifyFD;
- int inotifyWatch;
-
- virCapsPtr caps;
- virDomainXMLOptionPtr xmlopt;
-
- /* Event handling */
- virObjectEventStatePtr domainEventState;
-
- /* Mapping of 'char *uuidstr' -> virConnectPtr
- * of guests which will be automatically killed
- * when the virConnectPtr is closed*/
- virHashTablePtr autodestroy;
-};
-
-virCapsPtr umlCapsInit (void);
-
-virCommandPtr umlBuildCommandLine(virConnectPtr conn,
- struct uml_driver *driver,
- virDomainObjPtr dom);
-
-#endif /* LIBVIRT_UML_CONF_H */
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
deleted file mode 100644
index e790273717..0000000000
--- a/src/uml/uml_driver.c
+++ /dev/null
@@ -1,2835 +0,0 @@
-/*
- * uml_driver.c: core driver methods for managing UML guests
- *
- * Copyright (C) 2006-2015 Red Hat, Inc.
- * Copyright (C) 2006-2008 Daniel P. Berrange
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-
-#include <config.h>
-
-#include <sys/types.h>
-#include <sys/poll.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <sys/utsname.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <pwd.h>
-#include <sys/wait.h>
-#include <sys/ioctl.h>
-#include <sys/inotify.h>
-#include <sys/un.h>
-
-#include "uml_driver.h"
-#include "uml_conf.h"
-#include "virbuffer.h"
-#include "virhostcpu.h"
-#include "virhostmem.h"
-#include "capabilities.h"
-#include "viralloc.h"
-#include "viruuid.h"
-#include "domain_conf.h"
-#include "domain_audit.h"
-#include "datatypes.h"
-#include "virlog.h"
-#include "domain_nwfilter.h"
-#include "virfile.h"
-#include "virfdstream.h"
-#include "configmake.h"
-#include "virnetdevtap.h"
-#include "virnodesuspend.h"
-#include "virprocess.h"
-#include "viruri.h"
-#include "virstring.h"
-#include "viraccessapicheck.h"
-
-#define VIR_FROM_THIS VIR_FROM_UML
-
-VIR_LOG_INIT("uml.uml_driver");
-
-typedef struct _umlDomainObjPrivate umlDomainObjPrivate;
-typedef umlDomainObjPrivate *umlDomainObjPrivatePtr;
-struct _umlDomainObjPrivate {
- int monitor;
- int monitorWatch;
-};
-
-static int umlProcessAutoDestroyInit(struct uml_driver *driver);
-static void umlProcessAutoDestroyRun(struct uml_driver *driver,
- virConnectPtr conn);
-static void umlProcessAutoDestroyShutdown(struct uml_driver *driver);
-static int umlProcessAutoDestroyAdd(struct uml_driver *driver,
- virDomainObjPtr vm,
- virConnectPtr conn);
-static int umlProcessAutoDestroyRemove(struct uml_driver *driver,
- virDomainObjPtr vm);
-
-
-static int umlStateCleanup(void);
-
-static void *umlDomainObjPrivateAlloc(void *opaque ATTRIBUTE_UNUSED)
-{
- umlDomainObjPrivatePtr priv;
-
- if (VIR_ALLOC(priv) < 0)
- return NULL;
-
- priv->monitor = -1;
- priv->monitorWatch = -1;
-
- return priv;
-}
-
-static void umlDomainObjPrivateFree(void *data)
-{
- umlDomainObjPrivatePtr priv = data;
-
- VIR_FREE(priv);
-}
-
-
-static void umlDriverLock(struct uml_driver *driver)
-{
- virMutexLock(&driver->lock);
-}
-static void umlDriverUnlock(struct uml_driver *driver)
-{
- virMutexUnlock(&driver->lock);
-}
-
-
-static int umlOpenMonitor(struct uml_driver *driver,
- virDomainObjPtr vm);
-static int umlReadPidFile(struct uml_driver *driver,
- virDomainObjPtr vm);
-
-static int umlStartVMDaemon(virConnectPtr conn,
- struct uml_driver *driver,
- virDomainObjPtr vm,
- bool autoDestroy);
-
-static void umlShutdownVMDaemon(struct uml_driver *driver,
- virDomainObjPtr vm,
- virDomainShutoffReason reason);
-
-
-static int umlMonitorCommand(const struct uml_driver *driver,
- const virDomainObj *vm,
- const char *cmd,
- char **reply);
-
-static struct uml_driver *uml_driver;
-
-static virDomainObjPtr
-umlDomObjFromDomainLocked(struct uml_driver *driver,
- const unsigned char *uuid)
-{
- virDomainObjPtr vm;
- char uuidstr[VIR_UUID_STRING_BUFLEN];
-
- if (!(vm = virDomainObjListFindByUUID(driver->domains, uuid))) {
- virUUIDFormat(uuid, uuidstr);
-
- virReportError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching uuid '%s'"), uuidstr);
- return NULL;
- }
-
- return vm;
-}
-
-
-static virDomainObjPtr
-umlDomObjFromDomain(struct uml_driver *driver,
- const unsigned char *uuid)
-{
- virDomainObjPtr vm;
-
- umlDriverLock(driver);
- vm = umlDomObjFromDomainLocked(driver, uuid);
- umlDriverUnlock(driver);
- return vm;
-}
-
-
-struct umlAutostartData {
- struct uml_driver *driver;
- virConnectPtr conn;
-};
-
-static int
-umlAutostartDomain(virDomainObjPtr vm,
- void *opaque)
-{
- const struct umlAutostartData *data = opaque;
- int ret = 0;
- virObjectLock(vm);
- if (vm->autostart &&
- !virDomainObjIsActive(vm)) {
- virResetLastError();
- ret = umlStartVMDaemon(data->conn, data->driver, vm, false);
- virDomainAuditStart(vm, "booted", ret >= 0);
- if (ret < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to autostart VM '%s': %s"),
- vm->def->name, virGetLastErrorMessage());
- } else {
- virObjectEventPtr event =
- virDomainEventLifecycleNewFromObj(vm,
- VIR_DOMAIN_EVENT_STARTED,
- VIR_DOMAIN_EVENT_STARTED_BOOTED);
- virObjectEventStateQueue(data->driver->domainEventState, event);
- }
- }
- virObjectUnlock(vm);
- return ret;
-}
-
-static void
-umlAutostartConfigs(struct uml_driver *driver)
-{
- /* XXX: Figure out a better way todo this. The domain
- * startup code needs a connection handle in order
- * to lookup the bridge associated with a virtual
- * network
- */
- virConnectPtr conn = virConnectOpen(driver->privileged ?
- "uml:///system" :
- "uml:///session");
- /* Ignoring NULL conn which is mostly harmless here */
-
- struct umlAutostartData data = { driver, conn };
-
- umlDriverLock(driver);
- virDomainObjListForEach(driver->domains, umlAutostartDomain, &data);
- umlDriverUnlock(driver);
-
- virObjectUnref(conn);
-}
-
-
-static int
-umlIdentifyOneChrPTY(struct uml_driver *driver,
- virDomainObjPtr dom,
- virDomainChrDefPtr def,
- const char *dev)
-{
- char *cmd;
- char *res = NULL;
- int retries = 0;
- if (virAsprintf(&cmd, "config %s%d", dev, def->target.port) < 0)
- return -1;
- requery:
- if (umlMonitorCommand(driver, dom, cmd, &res) < 0)
- return -1;
-
- if (res && STRPREFIX(res, "pts:")) {
- VIR_FREE(def->source->data.file.path);
- if (VIR_STRDUP(def->source->data.file.path, res + 4) < 0) {
- VIR_FREE(res);
- VIR_FREE(cmd);
- return -1;
- }
- } else if (!res || STRPREFIX(res, "pts")) {
- /* It can take a while to startup, so retry for
- up to 5 seconds */
- /* XXX should do this in a better non-blocking
- way somehow ...perhaps register a timer */
- if (retries++ < 50) {
- VIR_FREE(res);
- usleep(1000*10);
- goto requery;
- }
- }
-
- VIR_FREE(cmd);
- VIR_FREE(res);
- return 0;
-}
-
-static int
-umlIdentifyChrPTY(struct uml_driver *driver,
- virDomainObjPtr dom)
-{
- size_t i;
-
- for (i = 0; i < dom->def->nconsoles; i++)
- if (dom->def->consoles[i]->source->type == VIR_DOMAIN_CHR_TYPE_PTY)
- if (umlIdentifyOneChrPTY(driver, dom,
- dom->def->consoles[i], "con") < 0)
- return -1;
-
- for (i = 0; i < dom->def->nserials; i++)
- if (dom->def->serials[i]->source->type == VIR_DOMAIN_CHR_TYPE_PTY &&
- umlIdentifyOneChrPTY(driver, dom,
- dom->def->serials[i], "ssl") < 0)
- return -1;
-
- return 0;
-}
-
-static void
-umlInotifyEvent(int watch,
- int fd,
- int events ATTRIBUTE_UNUSED,
- void *data)
-{
- char buf[1024];
- struct inotify_event e;
- int got;
- char *tmp, *name;
- struct uml_driver *driver = data;
- virDomainObjPtr dom;
- virObjectEventPtr event = NULL;
-
- umlDriverLock(driver);
- if (watch != driver->inotifyWatch)
- goto cleanup;
-
- reread:
- got = read(fd, buf, sizeof(buf));
- if (got == -1) {
- if (errno == EINTR)
- goto reread;
- goto cleanup;
- }
-
- tmp = buf;
- while (got) {
- if (got < sizeof(e))
- goto cleanup; /* bad */
-
- memcpy(&e, tmp, sizeof(e));
- tmp += sizeof(e);
- got -= sizeof(e);
-
- if (got < e.len)
- goto cleanup;
-
- tmp += e.len;
- got -= e.len;
-
- name = (char *)&(e.name);
-
- dom = virDomainObjListFindByName(driver->domains, name);
-
- if (!dom)
- continue;
-
- if (e.mask & IN_DELETE) {
- VIR_DEBUG("Got inotify domain shutdown '%s'", name);
- if (!virDomainObjIsActive(dom)) {
- virDomainObjEndAPI(&dom);
- continue;
- }
-
- umlShutdownVMDaemon(driver, dom, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
- virDomainAuditStop(dom, "shutdown");
- event = virDomainEventLifecycleNewFromObj(dom,
- VIR_DOMAIN_EVENT_STOPPED,
- VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);
- if (!dom->persistent)
- virDomainObjListRemove(driver->domains, dom);
- } else if (e.mask & (IN_CREATE | IN_MODIFY)) {
- VIR_DEBUG("Got inotify domain startup '%s'", name);
- if (virDomainObjIsActive(dom)) {
- virDomainObjEndAPI(&dom);
- continue;
- }
-
- if (umlReadPidFile(driver, dom) < 0) {
- virDomainObjEndAPI(&dom);
- continue;
- }
-
- dom->def->id = driver->nextvmid++;
-
- if (!driver->nactive && driver->inhibitCallback)
- driver->inhibitCallback(true, driver->inhibitOpaque);
- driver->nactive++;
-
- virDomainObjSetState(dom, VIR_DOMAIN_RUNNING,
- VIR_DOMAIN_RUNNING_BOOTED);
-
- if (umlOpenMonitor(driver, dom) < 0) {
- VIR_WARN("Could not open monitor for new domain");
- umlShutdownVMDaemon(driver, dom,
- VIR_DOMAIN_SHUTOFF_FAILED);
- virDomainAuditStop(dom, "failed");
- event = virDomainEventLifecycleNewFromObj(dom,
- VIR_DOMAIN_EVENT_STOPPED,
- VIR_DOMAIN_EVENT_STOPPED_FAILED);
- if (!dom->persistent)
- virDomainObjListRemove(driver->domains, dom);
- } else if (umlIdentifyChrPTY(driver, dom) < 0) {
- VIR_WARN("Could not identify character devices for new domain");
- umlShutdownVMDaemon(driver, dom,
- VIR_DOMAIN_SHUTOFF_FAILED);
- virDomainAuditStop(dom, "failed");
- event = virDomainEventLifecycleNewFromObj(dom,
- VIR_DOMAIN_EVENT_STOPPED,
- VIR_DOMAIN_EVENT_STOPPED_FAILED);
- if (!dom->persistent)
- virDomainObjListRemove(driver->domains, dom);
- }
- }
- virDomainObjEndAPI(&dom);
- virObjectEventStateQueue(driver->domainEventState, event);
- event = NULL;
- }
-
- cleanup:
- umlDriverUnlock(driver);
-}
-
-
-static int
-umlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
- const virDomainDef *def ATTRIBUTE_UNUSED,
- virCapsPtr caps ATTRIBUTE_UNUSED,
- unsigned int parseFlags ATTRIBUTE_UNUSED,
- void *opaque ATTRIBUTE_UNUSED,
- void *parseOpaque ATTRIBUTE_UNUSED)
-{
- if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
- dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
- dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)
- dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML;
-
- /* forbid capabilities mode hostdev in this kind of hypervisor */
- if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
- dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("hostdev mode 'capabilities' is not "
- "supported in %s"),
- virDomainVirtTypeToString(def->virtType));
- return -1;
- }
-
- return 0;
-}
-
-
-static int
-umlDomainDefPostParse(virDomainDefPtr def ATTRIBUTE_UNUSED,
- virCapsPtr caps ATTRIBUTE_UNUSED,
- unsigned int parseFlags ATTRIBUTE_UNUSED,
- void *opaque ATTRIBUTE_UNUSED,
- void *parseOpaque ATTRIBUTE_UNUSED)
-{
- return 0;
-}
-
-
-virDomainDefParserConfig umlDriverDomainDefParserConfig = {
- .devicesPostParseCallback = umlDomainDeviceDefPostParse,
- .domainPostParseCallback = umlDomainDefPostParse,
-};
-
-
-/**
- * umlStartup:
- *
- * Initialization function for the Uml daemon
- */
-static int
-umlStateInitialize(bool privileged,
- virStateInhibitCallback callback,
- void *opaque)
-{
- char *base = NULL;
- char *userdir = NULL;
-
- virDomainXMLPrivateDataCallbacks privcb = {
- .alloc = umlDomainObjPrivateAlloc,
- .free = umlDomainObjPrivateFree,
- };
-
- if (VIR_ALLOC(uml_driver) < 0)
- return -1;
-
- uml_driver->privileged = privileged;
- uml_driver->inhibitCallback = callback;
- uml_driver->inhibitOpaque = opaque;
-
- if (virMutexInit(¨_driver->lock) < 0) {
- VIR_FREE(uml_driver);
- return -1;
- }
- umlDriverLock(uml_driver);
-
- /* Don't have a dom0 so start from 1 */
- uml_driver->nextvmid = 1;
- uml_driver->inotifyWatch = -1;
-
- if (!(uml_driver->domains = virDomainObjListNew()))
- goto error;
-
- uml_driver->domainEventState = virObjectEventStateNew();
- if (!uml_driver->domainEventState)
- goto error;
-
- userdir = virGetUserDirectory();
- if (!userdir)
- goto error;
-
- if (privileged) {
- if (virAsprintf(¨_driver->logDir,
- "%s/log/libvirt/uml", LOCALSTATEDIR) == -1)
- goto out_of_memory;
-
- if (VIR_STRDUP(base, SYSCONFDIR "/libvirt") < 0)
- goto error;
-
- if (virAsprintf(¨_driver->monitorDir,
- "%s/run/libvirt/uml-guest", LOCALSTATEDIR) == -1)
- goto out_of_memory;
- } else {
- base = virGetUserConfigDirectory();
- if (!base)
- goto error;
-
- if (virAsprintf(¨_driver->logDir,
- "%s/uml/log", base) == -1)
- goto out_of_memory;
-
- if (virAsprintf(¨_driver->monitorDir,
- "%s/.uml", userdir) == -1)
- goto out_of_memory;
- }
-
- /* Configuration paths are either $XDG_CONFIG_HOME/libvirt/uml/... (session) or
- * /etc/libvirt/uml/... (system).
- */
- if (virAsprintf(¨_driver->configDir, "%s/uml", base) == -1)
- goto out_of_memory;
-
- if (virAsprintf(¨_driver->autostartDir, "%s/uml/autostart", base) == -1)
- goto out_of_memory;
-
- VIR_FREE(base);
-
- if ((uml_driver->caps = umlCapsInit()) == NULL)
- goto out_of_memory;
-
- if (!(uml_driver->xmlopt = virDomainXMLOptionNew(¨DriverDomainDefParserConfig,
- &privcb, NULL, NULL, NULL)))
- goto error;
-
- if ((uml_driver->inotifyFD = inotify_init()) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot initialize inotify"));
- goto error;
- }
-
- if (virFileMakePath(uml_driver->monitorDir) < 0) {
- virReportSystemError(errno, _("Failed to create monitor directory %s"),
- uml_driver->monitorDir);
- goto error;
- }
-
- VIR_INFO("Adding inotify watch on %s", uml_driver->monitorDir);
- if (inotify_add_watch(uml_driver->inotifyFD,
- uml_driver->monitorDir,
- IN_CREATE | IN_MODIFY | IN_DELETE) < 0) {
- virReportSystemError(errno, _("Failed to create inotify watch on %s"),
- uml_driver->monitorDir);
- goto error;
- }
-
- if ((uml_driver->inotifyWatch =
- virEventAddHandle(uml_driver->inotifyFD, POLLIN,
- umlInotifyEvent, uml_driver, NULL)) < 0)
- goto error;
-
- if (umlProcessAutoDestroyInit(uml_driver) < 0)
- goto error;
-
- if (virDomainObjListLoadAllConfigs(uml_driver->domains,
- uml_driver->configDir,
- uml_driver->autostartDir, false,
- uml_driver->caps,
- uml_driver->xmlopt,
- NULL, NULL) < 0)
- goto error;
-
- umlDriverUnlock(uml_driver);
-
- VIR_FREE(userdir);
-
- return 0;
-
- out_of_memory:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("umlStartup: out of memory"));
-
- error:
- VIR_FREE(userdir);
- VIR_FREE(base);
- umlDriverUnlock(uml_driver);
- umlStateCleanup();
- return -1;
-}
-
-/**
- * umlStateAutoStart:
- *
- * Function to autostart the Uml daemons
- */
-static void
-umlStateAutoStart(void)
-{
- if (!uml_driver)
- return;
-
- umlAutostartConfigs(uml_driver);
-}
-
-static void umlNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
-{
- struct uml_driver *driver = opaque;
-
- if (newVM) {
- virObjectEventPtr event =
- virDomainEventLifecycleNewFromObj(vm,
- VIR_DOMAIN_EVENT_DEFINED,
- VIR_DOMAIN_EVENT_DEFINED_ADDED);
- virObjectEventStateQueue(driver->domainEventState, event);
- }
-}
-
-
-/**
- * umlStateReload:
- *
- * Function to restart the Uml daemon, it will recheck the configuration
- * files and update its state and the networking
- */
-static int
-umlStateReload(void)
-{
- if (!uml_driver)
- return 0;
-
- umlDriverLock(uml_driver);
- virDomainObjListLoadAllConfigs(uml_driver->domains,
- uml_driver->configDir,
- uml_driver->autostartDir, false,
- uml_driver->caps,
- uml_driver->xmlopt,
- umlNotifyLoadDomain, uml_driver);
- umlDriverUnlock(uml_driver);
-
- return 0;
-}
-
-
-static int
-umlShutdownOneVM(virDomainObjPtr dom, void *opaque)
-{
- struct uml_driver *driver = opaque;
-
- virObjectLock(dom);
- if (virDomainObjIsActive(dom)) {
- umlShutdownVMDaemon(driver, dom, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
- virDomainAuditStop(dom, "shutdown");
- }
- virObjectUnlock(dom);
- return 0;
-}
-
-/**
- * umlStateCleanup:
- *
- * Shutdown the Uml daemon, it will stop all active domains and networks
- */
-static int
-umlStateCleanup(void)
-{
- if (!uml_driver)
- return -1;
-
- umlDriverLock(uml_driver);
- if (uml_driver->inotifyWatch != -1)
- virEventRemoveHandle(uml_driver->inotifyWatch);
- VIR_FORCE_CLOSE(uml_driver->inotifyFD);
- virObjectUnref(uml_driver->caps);
- virObjectUnref(uml_driver->xmlopt);
-
- /* shutdown active VMs
- * XXX allow them to stay around & reconnect */
- virDomainObjListForEach(uml_driver->domains, umlShutdownOneVM, uml_driver);
-
- virObjectUnref(uml_driver->domains);
-
- virObjectUnref(uml_driver->domainEventState);
-
- VIR_FREE(uml_driver->logDir);
- VIR_FREE(uml_driver->configDir);
- VIR_FREE(uml_driver->autostartDir);
- VIR_FREE(uml_driver->monitorDir);
-
- umlProcessAutoDestroyShutdown(uml_driver);
-
- umlDriverUnlock(uml_driver);
- virMutexDestroy(¨_driver->lock);
- VIR_FREE(uml_driver);
-
- return 0;
-}
-
-
-static int umlProcessAutoDestroyInit(struct uml_driver *driver)
-{
- if (!(driver->autodestroy = virHashCreate(5, NULL)))
- return -1;
-
- return 0;
-}
-
-struct umlProcessAutoDestroyData {
- struct uml_driver *driver;
- virConnectPtr conn;
-};
-
-static int umlProcessAutoDestroyDom(void *payload,
- const void *name,
- void *opaque)
-{
- struct umlProcessAutoDestroyData *data = opaque;
- virConnectPtr conn = payload;
- const char *uuidstr = name;
- unsigned char uuid[VIR_UUID_BUFLEN];
- virDomainObjPtr dom;
- virObjectEventPtr event = NULL;
-
- VIR_DEBUG("conn=%p uuidstr=%s thisconn=%p", conn, uuidstr, data->conn);
-
- if (data->conn != conn)
- return 0;
-
- if (virUUIDParse(uuidstr, uuid) < 0) {
- VIR_WARN("Failed to parse %s", uuidstr);
- return 0;
- }
-
- if (!(dom = virDomainObjListFindByUUID(data->driver->domains, uuid))) {
- VIR_DEBUG("No domain object to kill");
- return 0;
- }
-
- VIR_DEBUG("Killing domain");
- umlShutdownVMDaemon(data->driver, dom, VIR_DOMAIN_SHUTOFF_DESTROYED);
- virDomainAuditStop(dom, "destroyed");
- event = virDomainEventLifecycleNewFromObj(dom,
- VIR_DOMAIN_EVENT_STOPPED,
- VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
-
- if (!dom->persistent)
- virDomainObjListRemove(data->driver->domains, dom);
-
- virDomainObjEndAPI(&dom);
- virObjectEventStateQueue(data->driver->domainEventState, event);
- virHashRemoveEntry(data->driver->autodestroy, uuidstr);
- return 0;
-}
-
-/*
- * Precondition: driver is locked
- */
-static void umlProcessAutoDestroyRun(struct uml_driver *driver, virConnectPtr conn)
-{
- struct umlProcessAutoDestroyData data = {
- driver, conn
- };
- VIR_DEBUG("conn=%p", conn);
- virHashForEach(driver->autodestroy, umlProcessAutoDestroyDom, &data);
-}
-
-static void umlProcessAutoDestroyShutdown(struct uml_driver *driver)
-{
- virHashFree(driver->autodestroy);
-}
-
-static int umlProcessAutoDestroyAdd(struct uml_driver *driver,
- virDomainObjPtr vm,
- virConnectPtr conn)
-{
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(vm->def->uuid, uuidstr);
- VIR_DEBUG("vm=%s uuid=%s conn=%p", vm->def->name, uuidstr, conn);
- if (virHashAddEntry(driver->autodestroy, uuidstr, conn) < 0)
- return -1;
- return 0;
-}
-
-static int umlProcessAutoDestroyRemove(struct uml_driver *driver,
- virDomainObjPtr vm)
-{
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(vm->def->uuid, uuidstr);
- VIR_DEBUG("vm=%s uuid=%s", vm->def->name, uuidstr);
- if (virHashRemoveEntry(driver->autodestroy, uuidstr) < 0)
- return -1;
- return 0;
-}
-
-
-static int umlReadPidFile(struct uml_driver *driver,
- virDomainObjPtr vm)
-{
- int rc = -1;
- FILE *file;
- char *pidfile = NULL;
- int retries = 0;
-
- vm->pid = -1;
- if (virAsprintf(&pidfile, "%s/%s/pid",
- driver->monitorDir, vm->def->name) < 0)
- return -1;
-
- reopen:
- if (!(file = fopen(pidfile, "r"))) {
- if (errno == ENOENT &&
- retries++ < 50) {
- usleep(1000 * 100);
- goto reopen;
- }
- goto cleanup;
- }
-
- if (fscanf(file, "%d", &vm->pid) != 1) {
- errno = EINVAL;
- VIR_FORCE_FCLOSE(file);
- goto cleanup;
- }
-
- if (VIR_FCLOSE(file) < 0)
- goto cleanup;
-
- rc = 0;
-
- cleanup:
- if (rc != 0)
- virReportSystemError(errno,
- _("failed to read pid: %s"),
- pidfile);
- VIR_FREE(pidfile);
- return rc;
-}
-
-static int umlMonitorAddress(const struct uml_driver *driver,
- const virDomainObj *vm,
- struct sockaddr_un *addr)
-{
- char *sockname;
- int retval = 0;
-
- if (virAsprintf(&sockname, "%s/%s/mconsole",
- driver->monitorDir, vm->def->name) < 0)
- return -1;
-
- memset(addr, 0, sizeof(*addr));
- addr->sun_family = AF_UNIX;
- if (virStrcpyStatic(addr->sun_path, sockname) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unix path %s too long for destination"), sockname);
- retval = -1;
- }
- VIR_FREE(sockname);
- return retval;
-}
-
-static int umlOpenMonitor(struct uml_driver *driver,
- virDomainObjPtr vm)
-{
- struct sockaddr_un addr;
- struct stat sb;
- int retries = 0;
- umlDomainObjPrivatePtr priv = vm->privateData;
-
- if (umlMonitorAddress(driver, vm, &addr) < 0)
- return -1;
-
- VIR_DEBUG("Dest address for monitor is '%s'", addr.sun_path);
- restat:
- if (stat(addr.sun_path, &sb) < 0) {
- if (errno == ENOENT &&
- retries++ < 50) {
- usleep(1000 * 100);
- goto restat;
- }
- return -1;
- }
-
- if ((priv->monitor = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0) {
- virReportSystemError(errno,
- "%s", _("cannot open socket"));
- return -1;
- }
-
- memset(addr.sun_path, 0, sizeof(addr.sun_path));
- snprintf(addr.sun_path + 1, sizeof(addr.sun_path) - 1,
- "libvirt-uml-%u", vm->pid);
- VIR_DEBUG("Reply address for monitor is '%s'", addr.sun_path+1);
- if (bind(priv->monitor, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- virReportSystemError(errno,
- "%s", _("cannot bind socket"));
- VIR_FORCE_CLOSE(priv->monitor);
- return -1;
- }
-
- return 0;
-}
-
-
-#define MONITOR_MAGIC 0xcafebabe
-#define MONITOR_BUFLEN 512
-#define MONITOR_VERSION 2
-
-struct monitor_request {
- uint32_t magic;
- uint32_t version;
- uint32_t length;
- char data[MONITOR_BUFLEN];
-};
-
-struct monitor_response {
- uint32_t error;
- uint32_t extra;
- uint32_t length;
- char data[MONITOR_BUFLEN];
-};
-
-
-static int umlMonitorCommand(const struct uml_driver *driver,
- const virDomainObj *vm,
- const char *cmd,
- char **reply)
-{
- struct monitor_request req;
- struct monitor_response res;
- char *retdata = NULL;
- int retlen = 0, ret = 0;
- struct sockaddr_un addr;
- unsigned int addrlen;
- umlDomainObjPrivatePtr priv = vm->privateData;
-
- VIR_DEBUG("Run command '%s'", cmd);
-
- *reply = NULL;
-
- if (umlMonitorAddress(driver, vm, &addr) < 0)
- return -1;
-
- memset(&req, 0, sizeof(req));
- req.magic = MONITOR_MAGIC;
- req.version = MONITOR_VERSION;
- req.length = strlen(cmd);
- if (req.length > (MONITOR_BUFLEN-1)) {
- virReportSystemError(EINVAL,
- _("cannot send too long command %s (%d bytes)"),
- cmd, req.length);
- return -1;
- }
- if (virStrcpyStatic(req.data, cmd) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Command %s too long for destination"), cmd);
- return -1;
- }
-
- if (sendto(priv->monitor, &req, sizeof(req), 0,
- (struct sockaddr *)&addr, sizeof(addr)) != sizeof(req)) {
- virReportSystemError(errno,
- _("cannot send command %s"),
- cmd);
- return -1;
- }
-
- do {
- ssize_t nbytes;
- addrlen = sizeof(addr);
- nbytes = recvfrom(priv->monitor, &res, sizeof(res), 0,
- (struct sockaddr *)&addr, &addrlen);
- if (nbytes < 0) {
- if (errno == EAGAIN || errno == EINTR)
- continue;
- virReportSystemError(errno, _("cannot read reply %s"), cmd);
- goto error;
- }
- /* Ensure res.length is safe to read before validating its value. */
- if (nbytes < offsetof(struct monitor_request, data) ||
- nbytes < offsetof(struct monitor_request, data) + res.length) {
- virReportSystemError(0, _("incomplete reply %s"), cmd);
- goto error;
- }
-
- if (VIR_REALLOC_N(retdata, retlen + res.length) < 0)
- goto error;
- memcpy(retdata + retlen, res.data, res.length);
- retlen += res.length - 1;
- retdata[retlen] = '\0';
-
- if (res.error)
- ret = -1;
-
- } while (res.extra);
-
- VIR_DEBUG("Command reply is '%s'", NULLSTR(retdata));
-
- if (ret < 0)
- VIR_FREE(retdata);
- else
- *reply = retdata;
-
- return ret;
-
- error:
- VIR_FREE(retdata);
- return -1;
-}
-
-
-static void umlCleanupTapDevices(virDomainObjPtr vm)
-{
- size_t i;
-
- for (i = 0; i < vm->def->nnets; i++) {
- virDomainNetDefPtr def = vm->def->nets[i];
-
- if (def->type != VIR_DOMAIN_NET_TYPE_BRIDGE &&
- def->type != VIR_DOMAIN_NET_TYPE_NETWORK)
- continue;
-
- ignore_value(virNetDevTapDelete(def->ifname,
- def->backend.tap));
- }
-}
-
-static int umlStartVMDaemon(virConnectPtr conn,
- struct uml_driver *driver,
- virDomainObjPtr vm,
- bool autoDestroy)
-{
- int ret = -1;
- char *logfile;
- int logfd = -1;
- umlDomainObjPrivatePtr priv = vm->privateData;
- virCommandPtr cmd = NULL;
- size_t i;
-
- if (virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("VM is already active"));
- return -1;
- }
-
- if (!vm->def->os.kernel) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("no kernel specified"));
- return -1;
- }
- /* Make sure the binary we are about to try exec'ing exists.
- * Technically we could catch the exec() failure, but that's
- * in a sub-process so its hard to feed back a useful error
- */
- if (!virFileIsExecutable(vm->def->os.kernel)) {
- virReportSystemError(errno,
- _("Cannot find UML kernel %s"),
- vm->def->os.kernel);
- return -1;
- }
-
- if (virFileMakePath(driver->logDir) < 0) {
- virReportSystemError(errno,
- _("cannot create log directory %s"),
- driver->logDir);
- return -1;
- }
-
- if (virAsprintf(&logfile, "%s/%s.log",
- driver->logDir, vm->def->name) < 0)
- return -1;
-
- if ((logfd = open(logfile, O_CREAT | O_TRUNC | O_WRONLY,
- S_IRUSR | S_IWUSR)) < 0) {
- virReportSystemError(errno,
- _("failed to create logfile %s"),
- logfile);
- VIR_FREE(logfile);
- return -1;
- }
- VIR_FREE(logfile);
-
- if (virSetCloseExec(logfd) < 0) {
- virReportSystemError(errno, "%s",
- _("Unable to set VM logfile close-on-exec flag"));
- VIR_FORCE_CLOSE(logfd);
- return -1;
- }
-
- /* Do this upfront, so any part of the startup process can add
- * runtime state to vm->def that won't be persisted. This let's us
- * report implicit runtime defaults in the XML, like vnc listen/socket
- */
- VIR_DEBUG("Setting current domain def as transient");
- if (virDomainObjSetDefTransient(driver->caps, driver->xmlopt, vm) < 0) {
- VIR_FORCE_CLOSE(logfd);
- return -1;
- }
-
- if (!(cmd = umlBuildCommandLine(conn, driver, vm)))
- goto cleanup;
-
- for (i = 0; i < vm->def->nconsoles; i++) {
- VIR_FREE(vm->def->consoles[i]->info.alias);
- if (virAsprintf(&vm->def->consoles[i]->info.alias, "console%zu", i) < 0)
- goto cleanup;
- }
-
- virCommandWriteArgLog(cmd, logfd);
-
- priv->monitor = -1;
-
- virCommandClearCaps(cmd);
- virCommandSetOutputFD(cmd, &logfd);
- virCommandSetErrorFD(cmd, &logfd);
- virCommandDaemonize(cmd);
-
- if (virCommandRun(cmd, NULL) < 0)
- goto cleanup;
-
- if (autoDestroy &&
- umlProcessAutoDestroyAdd(driver, vm, conn) < 0)
- goto cleanup;
-
- ret = 0;
- cleanup:
- VIR_FORCE_CLOSE(logfd);
- virCommandFree(cmd);
-
- if (ret < 0) {
- virDomainConfVMNWFilterTeardown(vm);
- umlCleanupTapDevices(vm);
- virDomainObjRemoveTransientDef(vm);
- }
-
- /* NB we don't mark it running here - we do that async
- with inotify */
- /* XXX what if someone else tries to start it again
- before we get the inotification ? Sounds like
- trouble.... */
- /* XXX this is bad for events too. must fix this better */
-
- return ret;
-}
-
-static void umlShutdownVMDaemon(struct uml_driver *driver,
- virDomainObjPtr vm,
- virDomainShutoffReason reason)
-{
- int ret;
- umlDomainObjPrivatePtr priv = vm->privateData;
-
- if (!virDomainObjIsActive(vm))
- return;
-
- virProcessKill(vm->pid, SIGTERM);
-
- VIR_FORCE_CLOSE(priv->monitor);
-
- if ((ret = waitpid(vm->pid, NULL, 0)) != vm->pid) {
- VIR_WARN("Got unexpected pid %d != %d",
- ret, vm->pid);
- }
-
- vm->pid = -1;
- vm->def->id = -1;
- virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason);
-
- virDomainConfVMNWFilterTeardown(vm);
- umlCleanupTapDevices(vm);
-
- /* Stop autodestroy in case guest is restarted */
- umlProcessAutoDestroyRemove(driver, vm);
-
- virDomainObjRemoveTransientDef(vm);
-
- driver->nactive--;
- if (!driver->nactive && driver->inhibitCallback)
- driver->inhibitCallback(false, driver->inhibitOpaque);
-}
-
-
-static int umlConnectURIProbe(char **uri)
-{
- if (uml_driver == NULL)
- return 0;
-
- return VIR_STRDUP(*uri, uml_driver->privileged ?
- "uml:///system" :
- "uml:///session");
-}
-
-
-static virDrvOpenStatus umlConnectOpen(virConnectPtr conn,
- virConnectAuthPtr auth ATTRIBUTE_UNUSED,
- virConfPtr conf ATTRIBUTE_UNUSED,
- unsigned int flags)
-{
- virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
-
- /* URI was good, but driver isn't active */
- if (uml_driver == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("uml state driver is not active"));
- 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:///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;
- }
- }
-
- if (virConnectOpenEnsureACL(conn) < 0)
- return VIR_DRV_OPEN_ERROR;
-
- conn->privateData = uml_driver;
-
- return VIR_DRV_OPEN_SUCCESS;
-}
-
-static int umlConnectClose(virConnectPtr conn)
-{
- struct uml_driver *driver = conn->privateData;
-
- umlDriverLock(driver);
- umlProcessAutoDestroyRun(driver, conn);
- umlDriverUnlock(driver);
-
- conn->privateData = NULL;
-
- return 0;
-}
-
-static const char *umlConnectGetType(virConnectPtr conn) {
- if (virConnectGetTypeEnsureACL(conn) < 0)
- return NULL;
-
- return "UML";
-}
-
-
-static int umlConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED)
-{
- /* Trivially secure, since always inside the daemon */
- return 1;
-}
-
-
-static int umlConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
-{
- /* Not encrypted, but remote driver takes care of that */
- return 0;
-}
-
-
-static int umlConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
-{
- return 1;
-}
-
-
-static char *umlConnectGetCapabilities(virConnectPtr conn) {
- struct uml_driver *driver = (struct uml_driver *)conn->privateData;
- char *xml;
-
- if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
- return NULL;
-
- umlDriverLock(driver);
- xml = virCapabilitiesFormatXML(driver->caps);
- umlDriverUnlock(driver);
-
- return xml;
-}
-
-
-
-static int umlGetProcessInfo(unsigned long long *cpuTime, pid_t pid)
-{
- char *proc;
- FILE *pidinfo;
- unsigned long long usertime, systime;
-
- if (virAsprintf(&proc, "/proc/%lld/stat", (long long)pid) < 0)
- return -1;
-
- if (!(pidinfo = fopen(proc, "r"))) {
- /* VM probably shut down, so fake 0 */
- *cpuTime = 0;
- VIR_FREE(proc);
- return 0;
- }
-
- VIR_FREE(proc);
-
- if (fscanf(pidinfo, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %llu %llu", &usertime, &systime) != 2) {
- umlDebug("not enough arg");
- VIR_FORCE_FCLOSE(pidinfo);
- return -1;
- }
-
- /* We got jiffies
- * We want nanoseconds
- * _SC_CLK_TCK is jiffies per second
- * So calculate thus....
- */
- *cpuTime = 1000ull * 1000ull * 1000ull * (usertime + systime) / (unsigned long long)sysconf(_SC_CLK_TCK);
-
- umlDebug("Got %llu %llu %llu", usertime, systime, *cpuTime);
-
- VIR_FORCE_FCLOSE(pidinfo);
-
- return 0;
-}
-
-
-static virDomainPtr umlDomainLookupByID(virConnectPtr conn,
- int id)
-{
- struct uml_driver *driver = (struct uml_driver *)conn->privateData;
- virDomainObjPtr vm;
- virDomainPtr dom = NULL;
-
- umlDriverLock(driver);
- vm = virDomainObjListFindByID(driver->domains, id);
- umlDriverUnlock(driver);
-
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching id '%d'"), id);
- goto cleanup;
- }
-
- if (virDomainLookupByIDEnsureACL(conn, vm->def) < 0)
- goto cleanup;
-
- dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return dom;
-}
-
-static virDomainPtr umlDomainLookupByUUID(virConnectPtr conn,
- const unsigned char *uuid)
-{
- struct uml_driver *driver = (struct uml_driver *)conn->privateData;
- virDomainObjPtr vm;
- virDomainPtr dom = NULL;
-
- if (!(vm = umlDomObjFromDomain(driver, uuid)))
- return NULL;
-
- if (virDomainLookupByUUIDEnsureACL(conn, vm->def) < 0)
- goto cleanup;
-
- dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return dom;
-}
-
-static virDomainPtr umlDomainLookupByName(virConnectPtr conn,
- const char *name)
-{
- struct uml_driver *driver = (struct uml_driver *)conn->privateData;
- virDomainObjPtr vm;
- virDomainPtr dom = NULL;
-
- umlDriverLock(driver);
- vm = virDomainObjListFindByName(driver->domains, name);
- umlDriverUnlock(driver);
-
- if (!vm) {
- virReportError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching name '%s'"), name);
- goto cleanup;
- }
-
- if (virDomainLookupByNameEnsureACL(conn, vm->def) < 0)
- goto cleanup;
-
- dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return dom;
-}
-
-
-static int umlDomainIsActive(virDomainPtr dom)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr obj;
- int ret = -1;
-
- if (!(obj = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainIsActiveEnsureACL(dom->conn, obj->def) < 0)
- goto cleanup;
-
- ret = virDomainObjIsActive(obj);
-
- cleanup:
- virDomainObjEndAPI(&obj);
- return ret;
-}
-
-
-static int umlDomainIsPersistent(virDomainPtr dom)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr obj;
- int ret = -1;
-
- if (!(obj = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainIsPersistentEnsureACL(dom->conn, obj->def) < 0)
- goto cleanup;
-
- ret = obj->persistent;
-
- cleanup:
- virDomainObjEndAPI(&obj);
- return ret;
-}
-
-static int umlDomainIsUpdated(virDomainPtr dom)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr obj;
- int ret = -1;
-
- if (!(obj = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainIsUpdatedEnsureACL(dom->conn, obj->def) < 0)
- goto cleanup;
-
- ret = obj->updated;
-
- cleanup:
- virDomainObjEndAPI(&obj);
- return ret;
-}
-
-static int umlConnectGetVersion(virConnectPtr conn, unsigned long *version)
-{
- struct uml_driver *driver = conn->privateData;
- struct utsname ut;
- int ret = -1;
-
- if (virConnectGetVersionEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
-
- if (driver->umlVersion == 0) {
- uname(&ut);
-
- if (virParseVersionString(ut.release, &driver->umlVersion, true) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot parse version %s"), ut.release);
- goto cleanup;
- }
- }
-
- *version = driver->umlVersion;
- ret = 0;
-
- cleanup:
- umlDriverUnlock(driver);
- return ret;
-}
-
-
-static char *umlConnectGetHostname(virConnectPtr conn)
-{
- if (virConnectGetHostnameEnsureACL(conn) < 0)
- return NULL;
-
- return virGetHostname();
-}
-
-
-static int umlConnectListDomains(virConnectPtr conn, int *ids, int nids)
-{
- struct uml_driver *driver = conn->privateData;
- int n;
-
- if (virConnectListDomainsEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- n = virDomainObjListGetActiveIDs(driver->domains, ids, nids,
- virConnectListDomainsCheckACL, conn);
- umlDriverUnlock(driver);
-
- return n;
-}
-static int umlConnectNumOfDomains(virConnectPtr conn)
-{
- struct uml_driver *driver = conn->privateData;
- int n;
-
- if (virConnectNumOfDomainsEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- n = virDomainObjListNumOfDomains(driver->domains, true,
- virConnectNumOfDomainsCheckACL, conn);
- umlDriverUnlock(driver);
-
- return n;
-}
-static virDomainPtr umlDomainCreateXML(virConnectPtr conn, const char *xml,
- unsigned int flags)
-{
- struct uml_driver *driver = conn->privateData;
- virDomainDefPtr def;
- virDomainObjPtr vm = NULL;
- virDomainPtr dom = NULL;
- virObjectEventPtr event = NULL;
- unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
-
- virCheckFlags(VIR_DOMAIN_START_AUTODESTROY |
- VIR_DOMAIN_START_VALIDATE, NULL);
-
- if (flags & VIR_DOMAIN_START_VALIDATE)
- parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
-
- virNWFilterReadLockFilterUpdates();
- umlDriverLock(driver);
- if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
- NULL, parse_flags)))
- goto cleanup;
-
- if (virDomainCreateXMLEnsureACL(conn, def) < 0)
- goto cleanup;
-
- if (!(vm = virDomainObjListAdd(driver->domains, def,
- driver->xmlopt,
- VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
- VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
- NULL)))
- goto cleanup;
- def = NULL;
-
- if (umlStartVMDaemon(conn, driver, vm,
- (flags & VIR_DOMAIN_START_AUTODESTROY)) < 0) {
- virDomainAuditStart(vm, "booted", false);
- if (!vm->persistent)
- virDomainObjListRemove(driver->domains, vm);
- goto cleanup;
- }
- virDomainAuditStart(vm, "booted", true);
- event = virDomainEventLifecycleNewFromObj(vm,
- VIR_DOMAIN_EVENT_STARTED,
- VIR_DOMAIN_EVENT_STARTED_BOOTED);
-
- dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
-
- cleanup:
- virDomainDefFree(def);
- virDomainObjEndAPI(&vm);
- virObjectEventStateQueue(driver->domainEventState, event);
- umlDriverUnlock(driver);
- virNWFilterUnlockFilterUpdates();
- return dom;
-}
-
-
-static int umlDomainShutdownFlags(virDomainPtr dom,
- unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- char *info = NULL;
- int ret = -1;
-
- virCheckFlags(0, -1);
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
- goto cleanup;
-
-#if 0
- if (umlMonitorCommand(driver, vm, "system_powerdown", &info) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("shutdown operation failed"));
- goto cleanup;
- }
- ret = 0;
-#endif
-
- cleanup:
- VIR_FREE(info);
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-static int
-umlDomainShutdown(virDomainPtr dom)
-{
- return umlDomainShutdownFlags(dom, 0);
-}
-
-static int
-umlDomainDestroyFlags(virDomainPtr dom,
- unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- virObjectEventPtr event = NULL;
- int ret = -1;
-
- virCheckFlags(0, -1);
-
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- return -1;
-
- if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- umlShutdownVMDaemon(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED);
- virDomainAuditStop(vm, "destroyed");
- event = virDomainEventLifecycleNewFromObj(vm,
- VIR_DOMAIN_EVENT_STOPPED,
- VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
- if (!vm->persistent)
- virDomainObjListRemove(driver->domains, vm);
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- virObjectEventStateQueue(driver->domainEventState, event);
- umlDriverUnlock(driver);
- return ret;
-}
-
-
-static int umlDomainDestroy(virDomainPtr dom)
-{
- return umlDomainDestroyFlags(dom, 0);
-}
-
-
-static char *umlDomainGetOSType(virDomainPtr dom) {
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- char *type = NULL;
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return NULL;
-
- if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (VIR_STRDUP(type, virDomainOSTypeToString(vm->def->os.type)) < 0)
- goto cleanup;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return type;
-}
-
-/* Returns max memory in kb, 0 if error */
-static unsigned long long
-umlDomainGetMaxMemory(virDomainPtr dom)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- unsigned long long ret = 0;
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainGetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- ret = virDomainDefGetMemoryTotal(vm->def);
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-static int umlDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret = -1;
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainSetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (newmax < vm->def->mem.cur_balloon) {
- virReportError(VIR_ERR_INVALID_ARG, "%s",
- _("cannot set max memory lower than current memory"));
- goto cleanup;
- }
-
- virDomainDefSetMemoryTotal(vm->def, newmax);
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-static int umlDomainSetMemory(virDomainPtr dom, unsigned long newmem)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret = -1;
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainSetMemoryEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("cannot set memory of an active domain"));
- goto cleanup;
- }
-
- if (newmem > virDomainDefGetMemoryTotal(vm->def)) {
- virReportError(VIR_ERR_INVALID_ARG, "%s",
- _("cannot set memory higher than max memory"));
- goto cleanup;
- }
-
- vm->def->mem.cur_balloon = newmem;
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-static int umlDomainGetInfo(virDomainPtr dom,
- virDomainInfoPtr info)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret = -1;
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainGetInfoEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- info->state = virDomainObjGetState(vm, NULL);
-
- if (!virDomainObjIsActive(vm)) {
- info->cpuTime = 0;
- } else {
- if (umlGetProcessInfo(&(info->cpuTime), vm->pid) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("cannot read cputime for domain"));
- goto cleanup;
- }
- }
-
- info->maxMem = virDomainDefGetMemoryTotal(vm->def);
- info->memory = vm->def->mem.cur_balloon;
- info->nrVirtCpu = virDomainDefGetVcpus(vm->def);
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-
-static int
-umlDomainGetState(virDomainPtr dom,
- int *state,
- int *reason,
- unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret = -1;
-
- virCheckFlags(0, -1);
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainGetStateEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- *state = virDomainObjGetState(vm, reason);
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-
-static char *umlDomainGetXMLDesc(virDomainPtr dom,
- unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- char *ret = NULL;
-
- /* Flags checked by virDomainDefFormat */
-
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainGetXMLDescEnsureACL(dom->conn, vm->def, flags) < 0)
- goto cleanup;
-
- ret = virDomainDefFormat((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef ?
- vm->newDef : vm->def, driver->caps,
- virDomainDefFormatConvertXMLFlags(flags));
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-
-static int umlConnectListDefinedDomains(virConnectPtr conn,
- char **const names, int nnames) {
- struct uml_driver *driver = conn->privateData;
- int n;
-
- if (virConnectListDefinedDomainsEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- n = virDomainObjListGetInactiveNames(driver->domains, names, nnames,
- virConnectListDefinedDomainsCheckACL, conn);
- umlDriverUnlock(driver);
-
- return n;
-}
-
-static int umlConnectNumOfDefinedDomains(virConnectPtr conn)
-{
- struct uml_driver *driver = conn->privateData;
- int n;
-
- if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- n = virDomainObjListNumOfDomains(driver->domains, false,
- virConnectNumOfDefinedDomainsCheckACL, conn);
- umlDriverUnlock(driver);
-
- return n;
-}
-
-
-static int umlDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- virObjectEventPtr event = NULL;
- int ret = -1;
-
- virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, -1);
-
- virNWFilterReadLockFilterUpdates();
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- ret = umlStartVMDaemon(dom->conn, driver, vm,
- (flags & VIR_DOMAIN_START_AUTODESTROY));
- virDomainAuditStart(vm, "booted", ret >= 0);
- if (ret == 0)
- event = virDomainEventLifecycleNewFromObj(vm,
- VIR_DOMAIN_EVENT_STARTED,
- VIR_DOMAIN_EVENT_STARTED_BOOTED);
-
- cleanup:
- virDomainObjEndAPI(&vm);
- virObjectEventStateQueue(driver->domainEventState, event);
- umlDriverUnlock(driver);
- virNWFilterUnlockFilterUpdates();
- return ret;
-}
-
-static int umlDomainCreate(virDomainPtr dom)
-{
- return umlDomainCreateWithFlags(dom, 0);
-}
-
-static virDomainPtr
-umlDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
-{
- struct uml_driver *driver = conn->privateData;
- virDomainDefPtr def;
- virDomainObjPtr vm = NULL;
- virDomainPtr dom = NULL;
- unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
-
- virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
-
- if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
- parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
-
- umlDriverLock(driver);
- if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
- NULL, parse_flags)))
- goto cleanup;
-
- if (virXMLCheckIllegalChars("name", def->name, "\n") < 0)
- goto cleanup;
-
- if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
- goto cleanup;
-
- if (!(vm = virDomainObjListAdd(driver->domains, def,
- driver->xmlopt,
- 0, NULL)))
- goto cleanup;
- def = NULL;
- vm->persistent = 1;
-
- if (virDomainSaveConfig(driver->configDir, driver->caps,
- vm->newDef ? vm->newDef : vm->def) < 0) {
- virDomainObjListRemove(driver->domains, vm);
- goto cleanup;
- }
-
- dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
-
- cleanup:
- virDomainDefFree(def);
- virDomainObjEndAPI(&vm);
- umlDriverUnlock(driver);
- return dom;
-}
-
-static virDomainPtr
-umlDomainDefineXML(virConnectPtr conn, const char *xml)
-{
- return umlDomainDefineXMLFlags(conn, xml, 0);
-}
-
-static int umlDomainUndefineFlags(virDomainPtr dom,
- unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret = -1;
-
- virCheckFlags(0, -1);
-
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainUndefineFlagsEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (!vm->persistent) {
- virReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("cannot undefine transient domain"));
- goto cleanup;
- }
-
- if (virDomainDeleteConfig(driver->configDir, driver->autostartDir, vm) < 0)
- goto cleanup;
-
- if (virDomainObjIsActive(vm))
- vm->persistent = 0;
- else
- virDomainObjListRemove(driver->domains, vm);
-
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- umlDriverUnlock(driver);
- return ret;
-}
-
-
-static int umlDomainUndefine(virDomainPtr dom)
-{
- return umlDomainUndefineFlags(dom, 0);
-}
-
-static int umlDomainAttachUmlDisk(struct uml_driver *driver,
- virDomainObjPtr vm,
- virDomainDiskDefPtr disk)
-{
- size_t i;
- char *cmd = NULL;
- char *reply = NULL;
-
- for (i = 0; i < vm->def->ndisks; i++) {
- if (STREQ(vm->def->disks[i]->dst, disk->dst)) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("target %s already exists"), disk->dst);
- return -1;
- }
- }
-
- if (!virDomainDiskGetSource(disk)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("disk source path is missing"));
- goto error;
- }
-
- if (virAsprintf(&cmd, "config %s=%s", disk->dst,
- virDomainDiskGetSource(disk)) < 0)
- return -1;
-
- if (umlMonitorCommand(driver, vm, cmd, &reply) < 0)
- goto error;
-
- if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0)
- goto error;
-
- virDomainDiskInsertPreAlloced(vm->def, disk);
-
- VIR_FREE(reply);
- VIR_FREE(cmd);
-
- return 0;
-
- error:
-
- VIR_FREE(reply);
- VIR_FREE(cmd);
-
- return -1;
-}
-
-
-static int umlDomainAttachDevice(virDomainPtr dom, const char *xml)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- virDomainDeviceDefPtr dev = NULL;
- int ret = -1;
-
- umlDriverLock(driver);
-
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainAttachDeviceEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (!virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("cannot attach device on inactive domain"));
- goto cleanup;
- }
-
- dev = virDomainDeviceDefParse(xml, vm->def, driver->caps, driver->xmlopt,
- VIR_DOMAIN_DEF_PARSE_INACTIVE);
-
- if (dev == NULL)
- goto cleanup;
-
- if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
- if (dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_UML) {
- ret = umlDomainAttachUmlDisk(driver, vm, dev->data.disk);
- if (ret == 0)
- dev->data.disk = NULL;
- } else {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("disk bus '%s' cannot be hotplugged."),
- virDomainDiskBusTypeToString(dev->data.disk->bus));
- }
- } else {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("device type '%s' cannot be attached"),
- virDomainDeviceTypeToString(dev->type));
- goto cleanup;
- }
-
- cleanup:
-
- virDomainDeviceDefFree(dev);
- virDomainObjEndAPI(&vm);
- umlDriverUnlock(driver);
- return ret;
-}
-
-
-static int
-umlDomainAttachDeviceFlags(virDomainPtr dom,
- const char *xml,
- unsigned int flags)
-{
- virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1);
-
- if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("cannot modify the persistent configuration of a domain"));
- return -1;
- }
-
- return umlDomainAttachDevice(dom, xml);
-}
-
-
-static int umlDomainDetachUmlDisk(struct uml_driver *driver,
- virDomainObjPtr vm,
- virDomainDeviceDefPtr dev)
-{
- size_t i;
- int ret = -1;
- virDomainDiskDefPtr detach = NULL;
- char *cmd;
- char *reply;
-
- for (i = 0; i < vm->def->ndisks; i++) {
- if (STREQ(vm->def->disks[i]->dst, dev->data.disk->dst))
- break;
- }
-
- if (i == vm->def->ndisks) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("disk %s not found"), dev->data.disk->dst);
- return -1;
- }
-
- detach = vm->def->disks[i];
-
- if (virAsprintf(&cmd, "remove %s", detach->dst) < 0)
- return -1;
-
- if (umlMonitorCommand(driver, vm, cmd, &reply) < 0)
- goto cleanup;
-
- virDomainDiskRemove(vm->def, i);
-
- virDomainDiskDefFree(detach);
-
- ret = 0;
-
- VIR_FREE(reply);
-
- cleanup:
- VIR_FREE(cmd);
-
- return ret;
-}
-
-
-static int umlDomainDetachDevice(virDomainPtr dom, const char *xml)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- virDomainDeviceDefPtr dev = NULL;
- int ret = -1;
-
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainDetachDeviceEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (!virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("cannot detach device on inactive domain"));
- goto cleanup;
- }
-
- dev = virDomainDeviceDefParse(xml, vm->def, driver->caps, driver->xmlopt,
- VIR_DOMAIN_DEF_PARSE_INACTIVE |
- VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE);
- if (dev == NULL)
- goto cleanup;
-
- if (dev->type == VIR_DOMAIN_DEVICE_DISK &&
- dev->data.disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
- if (dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_UML)
- ret = umlDomainDetachUmlDisk(driver, vm, dev);
- else
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("This type of disk cannot be hot unplugged"));
- } else {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- "%s", _("This type of device cannot be hot unplugged"));
- }
-
- cleanup:
- virDomainDeviceDefFree(dev);
- virDomainObjEndAPI(&vm);
- umlDriverUnlock(driver);
- return ret;
-}
-
-
-static int
-umlDomainDetachDeviceFlags(virDomainPtr dom,
- const char *xml,
- unsigned int flags)
-{
- virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1);
-
- if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("cannot modify the persistent configuration of a domain"));
- return -1;
- }
-
- return umlDomainDetachDevice(dom, xml);
-}
-
-
-static int umlDomainGetAutostart(virDomainPtr dom,
- int *autostart)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret = -1;
-
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainGetAutostartEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- *autostart = vm->autostart;
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- umlDriverUnlock(driver);
- return ret;
-}
-
-static int umlDomainSetAutostart(virDomainPtr dom,
- int autostart)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- char *configFile = NULL, *autostartLink = NULL;
- int ret = -1;
-
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (!vm->persistent) {
- virReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("cannot set autostart for transient domain"));
- goto cleanup;
- }
-
- autostart = (autostart != 0);
-
- if (vm->autostart != autostart) {
- if ((configFile = virDomainConfigFile(driver->configDir, vm->def->name)) == NULL)
- goto cleanup;
- if ((autostartLink = virDomainConfigFile(driver->autostartDir, vm->def->name)) == NULL)
- goto cleanup;
-
- if (autostart) {
- if (virFileMakePath(driver->autostartDir) < 0) {
- virReportSystemError(errno,
- _("cannot create autostart directory %s"),
- driver->autostartDir);
- goto cleanup;
- }
-
- if (symlink(configFile, autostartLink) < 0) {
- virReportSystemError(errno,
- _("Failed to create symlink '%s to '%s'"),
- autostartLink, configFile);
- goto cleanup;
- }
- } else {
- if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) {
- virReportSystemError(errno,
- _("Failed to delete symlink '%s'"),
- autostartLink);
- goto cleanup;
- }
- }
-
- vm->autostart = autostart;
- }
- ret = 0;
-
- cleanup:
- VIR_FREE(configFile);
- VIR_FREE(autostartLink);
- virDomainObjEndAPI(&vm);
- umlDriverUnlock(driver);
- return ret;
-}
-
-
-static int
-umlDomainBlockPeek(virDomainPtr dom,
- const char *path,
- unsigned long long offset, size_t size,
- void *buffer,
- unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int fd = -1, ret = -1;
- const char *actual;
-
- virCheckFlags(0, -1);
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainBlockPeekEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (!path || path[0] == '\0') {
- virReportError(VIR_ERR_INVALID_ARG, "%s",
- _("NULL or empty path"));
- goto cleanup;
- }
-
- /* Check the path belongs to this domain. */
- if (!(actual = virDomainDiskPathByName(vm->def, path))) {
- virReportError(VIR_ERR_INVALID_ARG,
- _("invalid path '%s'"), path);
- goto cleanup;
- }
- path = actual;
-
- /* The path is correct, now try to open it and get its size. */
- fd = open(path, O_RDONLY);
- if (fd == -1) {
- virReportSystemError(errno,
- _("cannot open %s"), path);
- goto cleanup;
- }
-
- /* Seek and read. */
- /* NB. Because we configure with AC_SYS_LARGEFILE, off_t should
- * be 64 bits on all platforms.
- */
- if (lseek(fd, offset, SEEK_SET) == (off_t)-1 ||
- saferead(fd, buffer, size) == (ssize_t)-1) {
- virReportSystemError(errno,
- _("cannot read %s"), path);
- goto cleanup;
- }
-
- ret = 0;
-
- cleanup:
- VIR_FORCE_CLOSE(fd);
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-
-static int
-umlDomainOpenConsole(virDomainPtr dom,
- const char *dev_name,
- virStreamPtr st,
- unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm = NULL;
- int ret = -1;
- virDomainChrDefPtr chr = NULL;
- size_t i;
-
- virCheckFlags(0, -1);
-
- umlDriverLock(driver);
- if (!(vm = umlDomObjFromDomainLocked(driver, dom->uuid)))
- goto cleanup;
-
- if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (virDomainObjCheckActive(vm) < 0)
- goto cleanup;
-
- if (dev_name) {
- for (i = 0; i < vm->def->nconsoles; i++) {
- if (vm->def->consoles[i]->info.alias &&
- STREQ(vm->def->consoles[i]->info.alias, dev_name)) {
- chr = vm->def->consoles[i];
- break;
- }
- }
- } else {
- if (vm->def->nconsoles)
- chr = vm->def->consoles[0];
- else if (vm->def->nserials)
- chr = vm->def->serials[0];
- }
-
- if (!chr) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot find console device '%s'"),
- dev_name ? dev_name : _("default"));
- goto cleanup;
- }
-
- if (chr->source->type != VIR_DOMAIN_CHR_TYPE_PTY) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("character device %s is not using a PTY"),
- dev_name ? dev_name : NULLSTR(chr->info.alias));
- goto cleanup;
- }
-
- if (virFDStreamOpenFile(st, chr->source->data.file.path,
- 0, 0, O_RDWR) < 0)
- goto cleanup;
-
- ret = 0;
- cleanup:
- virDomainObjEndAPI(&vm);
- umlDriverUnlock(driver);
- return ret;
-}
-
-
-static int
-umlConnectDomainEventRegister(virConnectPtr conn,
- virConnectDomainEventCallback callback,
- void *opaque,
- virFreeCallback freecb)
-{
- struct uml_driver *driver = conn->privateData;
- int ret = 0;
-
- if (virConnectDomainEventRegisterEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- if (virDomainEventStateRegister(conn,
- driver->domainEventState,
- callback, opaque, freecb) < 0)
- ret = -1;
- umlDriverUnlock(driver);
-
- return ret;
-}
-
-static int
-umlConnectDomainEventDeregister(virConnectPtr conn,
- virConnectDomainEventCallback callback)
-{
- struct uml_driver *driver = conn->privateData;
- int ret = 0;
-
- if (virConnectDomainEventDeregisterEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- if (virDomainEventStateDeregister(conn,
- driver->domainEventState,
- callback) < 0)
- ret = -1;
- umlDriverUnlock(driver);
-
- return ret;
-}
-
-static int
-umlConnectDomainEventRegisterAny(virConnectPtr conn,
- virDomainPtr dom,
- int eventID,
- virConnectDomainEventGenericCallback callback,
- void *opaque,
- virFreeCallback freecb)
-{
- struct uml_driver *driver = conn->privateData;
- int ret;
-
- if (virConnectDomainEventRegisterAnyEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- if (virDomainEventStateRegisterID(conn,
- driver->domainEventState,
- dom, eventID,
- callback, opaque, freecb, &ret) < 0)
- ret = -1;
- umlDriverUnlock(driver);
-
- return ret;
-}
-
-
-static int
-umlConnectDomainEventDeregisterAny(virConnectPtr conn,
- int callbackID)
-{
- struct uml_driver *driver = conn->privateData;
- int ret = 0;
-
- if (virConnectDomainEventDeregisterAnyEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- if (virObjectEventStateDeregisterID(conn,
- driver->domainEventState,
- callbackID, true) < 0)
- ret = -1;
- umlDriverUnlock(driver);
-
- return ret;
-}
-
-
-static int umlConnectListAllDomains(virConnectPtr conn,
- virDomainPtr **domains,
- unsigned int flags)
-{
- struct uml_driver *driver = conn->privateData;
- int ret = -1;
-
- virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
-
- if (virConnectListAllDomainsEnsureACL(conn) < 0)
- return -1;
-
- umlDriverLock(driver);
- ret = virDomainObjListExport(driver->domains, conn, domains,
- virConnectListAllDomainsCheckACL, flags);
- umlDriverUnlock(driver);
-
- return ret;
-}
-
-
-static int
-umlNodeGetInfo(virConnectPtr conn,
- virNodeInfoPtr nodeinfo)
-{
- if (virNodeGetInfoEnsureACL(conn) < 0)
- return -1;
-
- return virCapabilitiesGetNodeInfo(nodeinfo);
-}
-
-
-static int
-umlNodeGetCPUStats(virConnectPtr conn,
- int cpuNum,
- virNodeCPUStatsPtr params,
- int *nparams,
- unsigned int flags)
-{
- if (virNodeGetCPUStatsEnsureACL(conn) < 0)
- return -1;
-
- return virHostCPUGetStats(cpuNum, params, nparams, flags);
-}
-
-
-static int
-umlNodeGetMemoryStats(virConnectPtr conn,
- int cellNum,
- virNodeMemoryStatsPtr params,
- int *nparams,
- unsigned int flags)
-{
- if (virNodeGetMemoryStatsEnsureACL(conn) < 0)
- return -1;
-
- return virHostMemGetStats(cellNum, params, nparams, flags);
-}
-
-
-static int
-umlNodeGetCellsFreeMemory(virConnectPtr conn,
- unsigned long long *freeMems,
- int startCell,
- int maxCells)
-{
- if (virNodeGetCellsFreeMemoryEnsureACL(conn) < 0)
- return -1;
-
- return virHostMemGetCellsFree(freeMems, startCell, maxCells);
-}
-
-
-static unsigned long long
-umlNodeGetFreeMemory(virConnectPtr conn)
-{
- unsigned long long freeMem;
-
- if (virNodeGetFreeMemoryEnsureACL(conn) < 0)
- return 0;
-
- if (virHostMemGetInfo(NULL, &freeMem) < 0)
- return 0;
-
- return freeMem;
-}
-
-
-static int
-umlNodeGetMemoryParameters(virConnectPtr conn,
- virTypedParameterPtr params,
- int *nparams,
- unsigned int flags)
-{
- if (virNodeGetMemoryParametersEnsureACL(conn) < 0)
- return -1;
-
- return virHostMemGetParameters(params, nparams, flags);
-}
-
-
-static int
-umlNodeSetMemoryParameters(virConnectPtr conn,
- virTypedParameterPtr params,
- int nparams,
- unsigned int flags)
-{
- if (virNodeSetMemoryParametersEnsureACL(conn) < 0)
- return -1;
-
- return virHostMemSetParameters(params, nparams, flags);
-}
-
-
-static int
-umlNodeGetCPUMap(virConnectPtr conn,
- unsigned char **cpumap,
- unsigned int *online,
- unsigned int flags)
-{
- if (virNodeGetCPUMapEnsureACL(conn) < 0)
- return -1;
-
- return virHostCPUGetMap(cpumap, online, flags);
-}
-
-
-static int
-umlNodeSuspendForDuration(virConnectPtr conn,
- unsigned int target,
- unsigned long long duration,
- unsigned int flags)
-{
- if (virNodeSuspendForDurationEnsureACL(conn) < 0)
- return -1;
-
- return virNodeSuspend(target, duration, flags);
-}
-
-
-static int
-umlNodeGetFreePages(virConnectPtr conn,
- unsigned int npages,
- unsigned int *pages,
- int startCell,
- unsigned int cellCount,
- unsigned long long *counts,
- unsigned int flags)
-{
- virCheckFlags(0, -1);
-
- if (virNodeGetFreePagesEnsureACL(conn) < 0)
- return -1;
-
- return virHostMemGetFreePages(npages, pages, startCell, cellCount, counts);
-}
-
-
-static int
-umlNodeAllocPages(virConnectPtr conn,
- unsigned int npages,
- unsigned int *pageSizes,
- unsigned long long *pageCounts,
- int startCell,
- unsigned int cellCount,
- unsigned int flags)
-{
- bool add = !(flags & VIR_NODE_ALLOC_PAGES_SET);
-
- virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1);
-
- if (virNodeAllocPagesEnsureACL(conn) < 0)
- return -1;
-
- return virHostMemAllocPages(npages, pageSizes, pageCounts,
- startCell, cellCount, add);
-}
-
-
-static int
-umlDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
-{
- struct uml_driver *driver = dom->conn->privateData;
- int ret = -1;
- virDomainObjPtr vm;
-
- virCheckFlags(0, -1);
-
- if (!(vm = umlDomObjFromDomain(driver, dom->uuid)))
- return -1;
-
- if (virDomainHasManagedSaveImageEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- ret = 0;
-
- cleanup:
- virDomainObjEndAPI(&vm);
- return ret;
-}
-
-
-static virHypervisorDriver umlHypervisorDriver = {
- .name = "UML",
- .connectURIProbe = umlConnectURIProbe,
- .connectOpen = umlConnectOpen, /* 0.5.0 */
- .connectClose = umlConnectClose, /* 0.5.0 */
- .connectGetType = umlConnectGetType, /* 0.5.0 */
- .connectGetVersion = umlConnectGetVersion, /* 0.5.0 */
- .connectGetHostname = umlConnectGetHostname, /* 0.5.0 */
- .nodeGetInfo = umlNodeGetInfo, /* 0.5.0 */
- .connectGetCapabilities = umlConnectGetCapabilities, /* 0.5.0 */
- .connectListDomains = umlConnectListDomains, /* 0.5.0 */
- .connectNumOfDomains = umlConnectNumOfDomains, /* 0.5.0 */
- .connectListAllDomains = umlConnectListAllDomains, /* 0.9.13 */
- .domainCreateXML = umlDomainCreateXML, /* 0.5.0 */
- .domainLookupByID = umlDomainLookupByID, /* 0.5.0 */
- .domainLookupByUUID = umlDomainLookupByUUID, /* 0.5.0 */
- .domainLookupByName = umlDomainLookupByName, /* 0.5.0 */
- .domainShutdown = umlDomainShutdown, /* 0.5.0 */
- .domainShutdownFlags = umlDomainShutdownFlags, /* 0.9.10 */
- .domainDestroy = umlDomainDestroy, /* 0.5.0 */
- .domainDestroyFlags = umlDomainDestroyFlags, /* 0.9.4 */
- .domainGetOSType = umlDomainGetOSType, /* 0.5.0 */
- .domainGetMaxMemory = umlDomainGetMaxMemory, /* 0.5.0 */
- .domainSetMaxMemory = umlDomainSetMaxMemory, /* 0.5.0 */
- .domainSetMemory = umlDomainSetMemory, /* 0.5.0 */
- .domainGetInfo = umlDomainGetInfo, /* 0.5.0 */
- .domainGetState = umlDomainGetState, /* 0.9.2 */
- .domainGetXMLDesc = umlDomainGetXMLDesc, /* 0.5.0 */
- .connectListDefinedDomains = umlConnectListDefinedDomains, /* 0.5.0 */
- .connectNumOfDefinedDomains = umlConnectNumOfDefinedDomains, /* 0.5.0 */
- .domainCreate = umlDomainCreate, /* 0.5.0 */
- .domainCreateWithFlags = umlDomainCreateWithFlags, /* 0.8.2 */
- .domainDefineXML = umlDomainDefineXML, /* 0.5.0 */
- .domainDefineXMLFlags = umlDomainDefineXMLFlags, /* 1.2.12 */
- .domainUndefine = umlDomainUndefine, /* 0.5.0 */
- .domainUndefineFlags = umlDomainUndefineFlags, /* 0.9.4 */
- .domainAttachDevice = umlDomainAttachDevice, /* 0.8.4 */
- .domainAttachDeviceFlags = umlDomainAttachDeviceFlags, /* 0.8.4 */
- .domainDetachDevice = umlDomainDetachDevice, /* 0.8.4 */
- .domainDetachDeviceFlags = umlDomainDetachDeviceFlags, /* 0.8.4 */
- .domainGetAutostart = umlDomainGetAutostart, /* 0.5.0 */
- .domainSetAutostart = umlDomainSetAutostart, /* 0.5.0 */
- .domainBlockPeek = umlDomainBlockPeek, /* 0.5.0 */
- .nodeGetCPUStats = umlNodeGetCPUStats, /* 0.9.3 */
- .nodeGetMemoryStats = umlNodeGetMemoryStats, /* 0.9.3 */
- .nodeGetCellsFreeMemory = umlNodeGetCellsFreeMemory, /* 0.5.0 */
- .nodeGetFreeMemory = umlNodeGetFreeMemory, /* 0.5.0 */
- .nodeGetCPUMap = umlNodeGetCPUMap, /* 1.0.0 */
- .connectDomainEventRegister = umlConnectDomainEventRegister, /* 0.9.4 */
- .connectDomainEventDeregister = umlConnectDomainEventDeregister, /* 0.9.4 */
- .connectIsEncrypted = umlConnectIsEncrypted, /* 0.7.3 */
- .connectIsSecure = umlConnectIsSecure, /* 0.7.3 */
- .domainIsActive = umlDomainIsActive, /* 0.7.3 */
- .domainIsPersistent = umlDomainIsPersistent, /* 0.7.3 */
- .domainIsUpdated = umlDomainIsUpdated, /* 0.8.6 */
- .connectDomainEventRegisterAny = umlConnectDomainEventRegisterAny, /* 0.9.4 */
- .connectDomainEventDeregisterAny = umlConnectDomainEventDeregisterAny, /* 0.9.4 */
- .domainOpenConsole = umlDomainOpenConsole, /* 0.8.6 */
- .connectIsAlive = umlConnectIsAlive, /* 0.9.8 */
- .nodeSuspendForDuration = umlNodeSuspendForDuration, /* 0.9.8 */
- .nodeGetMemoryParameters = umlNodeGetMemoryParameters, /* 0.10.2 */
- .nodeSetMemoryParameters = umlNodeSetMemoryParameters, /* 0.10.2 */
- .nodeGetFreePages = umlNodeGetFreePages, /* 1.2.6 */
- .nodeAllocPages = umlNodeAllocPages, /* 1.2.9 */
- .domainHasManagedSaveImage = umlDomainHasManagedSaveImage, /* 1.2.13 */
-};
-
-static virConnectDriver umlConnectDriver = {
- .localOnly = true,
- .uriSchemes = (const char *[]){ "uml", NULL },
- .hypervisorDriver = ¨HypervisorDriver,
-};
-
-static virStateDriver umlStateDriver = {
- .name = "UML",
- .stateInitialize = umlStateInitialize,
- .stateAutoStart = umlStateAutoStart,
- .stateCleanup = umlStateCleanup,
- .stateReload = umlStateReload,
-};
-
-int umlRegister(void)
-{
- if (virRegisterConnectDriver(¨ConnectDriver,
- true) < 0)
- return -1;
- if (virRegisterStateDriver(¨StateDriver) < 0)
- return -1;
- return 0;
-}
diff --git a/src/uml/uml_driver.h b/src/uml/uml_driver.h
deleted file mode 100644
index 3a258f6658..0000000000
--- a/src/uml/uml_driver.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * uml_driver.h: user mode Linux driver
- *
- * Copyright (C) 2006, 2007 Red Hat, Inc.
- * Copyright (C) 2006-2008 Daniel P. Berrange
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-
-#ifndef LIBVIRT_UML_DRIVER_H
-# define LIBVIRT_UML_DRIVER_H
-
-# include "internal.h"
-
-int umlRegister(void);
-
-#endif /* LIBVIRT_UML_DRIVER_H */
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 664650f217..5749e5d9cf 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -1134,7 +1134,6 @@ vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine)
case VIR_DOMAIN_DISK_BUS_VIRTIO:
case VIR_DOMAIN_DISK_BUS_XEN:
case VIR_DOMAIN_DISK_BUS_USB:
- case VIR_DOMAIN_DISK_BUS_UML:
case VIR_DOMAIN_DISK_BUS_SD:
case VIR_DOMAIN_DISK_BUS_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
diff --git a/tests/domaincapsschemadata/basic.xml b/tests/domaincapsschemadata/basic.xml
deleted file mode 100644
index 7bf4e56ae0..0000000000
--- a/tests/domaincapsschemadata/basic.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<domainCapabilities>
- <path>/bin/emulatorbin</path>
- <domain>uml</domain>
- <machine>my-machine-type</machine>
- <arch>x86_64</arch>
- <iothreads supported='no'/>
- <os supported='no'/>
- <cpu>
- <mode name='host-passthrough' supported='no'/>
- <mode name='host-model' supported='no'/>
- <mode name='custom' supported='no'/>
- </cpu>
- <devices>
- <disk supported='no'/>
- <graphics supported='no'/>
- <video supported='no'/>
- <hostdev supported='no'/>
- </devices>
- <features>
- <gic supported='no'/>
- <vmcoreinfo supported='no'/>
- <genid supported='no'/>
- <sev supported='no'/>
- </features>
-</domainCapabilities>
diff --git a/tests/domaincapsschemadata/full.xml b/tests/domaincapsschemadata/full.xml
index eafba1ae5b..c8273ad0bf 100644
--- a/tests/domaincapsschemadata/full.xml
+++ b/tests/domaincapsschemadata/full.xml
@@ -47,7 +47,6 @@
<value>virtio</value>
<value>xen</value>
<value>usb</value>
- <value>uml</value>
<value>sata</value>
<value>sd</value>
</enum>
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index ea4e57d118..7f52058bad 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -409,8 +409,6 @@ mymain(void)
ret = -1; \
} while (0)
- DO_TEST("basic", "/bin/emulatorbin", "my-machine-type",
- "x86_64", VIR_DOMAIN_VIRT_UML, CAPS_NONE);
DO_TEST("full", "/bin/emulatorbin", "my-machine-type",
"x86_64", VIR_DOMAIN_VIRT_KVM, CAPS_ALL);
diff --git a/tests/objectlocking.ml b/tests/objectlocking.ml
index 778e67cffd..6726d29e73 100644
--- a/tests/objectlocking.ml
+++ b/tests/objectlocking.ml
@@ -121,7 +121,6 @@ let driverLockMethods = [
"openvzDriverLock";
"testDriverLock";
"lxcDriverLock";
- "umlDriverLock";
"nodedevDriverLock";
"networkDriverLock";
"storageDriverLock";
@@ -136,7 +135,6 @@ let driverUnlockMethods = [
"openvzDriverUnlock";
"testDriverUnlock";
"lxcDriverUnlock";
- "umlDriverUnlock";
"nodedevDriverUnlock";
"networkDriverUnlock";
"storageDriverUnlock";
@@ -153,7 +151,6 @@ let lockableDrivers = [
"openvz_driver";
"testConnPtr";
"lxc_driver_t";
- "uml_driver";
"virStorageDriverStatePtr";
"network_driver";
"virNodeDeviceState";
diff --git a/tests/virdrivermoduletest.c b/tests/virdrivermoduletest.c
index 7e9dced87e..0d753cd0ee 100644
--- a/tests/virdrivermoduletest.c
+++ b/tests/virdrivermoduletest.c
@@ -89,9 +89,6 @@ mymain(void)
#ifdef WITH_LXC
TEST("lxc");
#endif
-#ifdef WITH_UML
- TEST("uml");
-#endif
#ifdef WITH_VBOX
TEST("vbox");
#endif
diff --git a/tools/virsh.c b/tools/virsh.c
index 09fa0f8a67..8428e539f6 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -518,9 +518,6 @@ virshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
#ifdef WITH_LXC
vshPrint(ctl, " LXC");
#endif
-#ifdef WITH_UML
- vshPrint(ctl, " UML");
-#endif
#ifdef WITH_LIBXL
vshPrint(ctl, " LibXL");
#endif
--
2.19.2
5 years, 11 months
[libvirt] [PATCH] cfg.mk: silence the group-qemu-caps command
by Daniel P. Berrangé
A missing $(AM_V_GEN) meant the raw command was printed by
mistake.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
Pushed as a trivial change
cfg.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cfg.mk b/cfg.mk
index c739edf604..4da6dc8f6e 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1149,7 +1149,7 @@ test-wrap-argv:
$(PERL) $(top_srcdir)/tests/test-wrap-argv.pl --check $$files
group-qemu-caps:
- $(PERL) $(top_srcdir)/tests/group-qemu-caps.pl --check $(top_srcdir)/
+ $(AM_V_GEN)$(PERL) $(top_srcdir)/tests/group-qemu-caps.pl --check $(top_srcdir)/
# sc_po_check can fail if generated files are not built first
sc_po_check: \
--
2.19.2
5 years, 11 months
[libvirt] [PATCH] Fix header ifdef check for config-post.h in VPATH build
by Daniel P. Berrangé
We must do a substring match, not an exact match since
there can be an arbitrary virtual path prepended.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
Pushed as a build fix
build-aux/header-ifdef.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build-aux/header-ifdef.pl b/build-aux/header-ifdef.pl
index 74b4c0246b..ccabf14055 100644
--- a/build-aux/header-ifdef.pl
+++ b/build-aux/header-ifdef.pl
@@ -85,7 +85,7 @@ while (<>) {
}
if ($mistake ||
- $ARGV eq "config-post.h" ||
+ $ARGV =~ /config-post\.h$/ ||
$ARGV =~ /vbox_(CAPI|XPCOM)/) {
$state = $STATE_EOF;
next;
--
2.19.2
5 years, 11 months