Commit Graph

37186 Commits

Author SHA1 Message Date
Peter Krempa
b8c02497b3 mock: qemuDomainGetUnplugTimeout: Decrease timeout
We always queue the DEVICE_DELETED events before successful return from
the command so that tests are reliable. This means we can decrease the
unplug timeout as it's guaranteed to be executed in correct order.

According to my testing it shaves off ~450ms of test run:

real	0m0.721s

vs.

real	0m0.259s

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 15:57:36 +02:00
Peter Krempa
f1ac096ea6 mock:qemuDomainGetUnplugTimeout: Remove unused attribute for '@vm'
'@vm' is used to use a different timeout for ppc64 guests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 15:57:36 +02:00
Peter Krempa
2ab8dba58c qemuDomainGetUnplugTimeout: Add G_GNUC_NO_INLINE
The function is mocked in qemuhotplugmock.so. Recent clang versions
decided to inline it so the mock stopped working resulting in
qemuhotplugtest wasting 15 seconds waiting for timeouts.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 15:57:36 +02:00
Peter Krempa
6ed1219244 qemucapstest: Refresh data for qemu 5.0 on x86_64
Bump to v5.0.0-rc3-8-g3119154db0 and make sure that 'liburing' is picked
up by qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-23 15:56:32 +02:00
Peter Krempa
d9792233ec qemuDomainSaveImageOpen: Refactor handling of errors
Return error codes directly and fix weird reporting of errors via
temporary variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-23 15:36:53 +02:00
Peter Krempa
9219424f56 qemuDomainSaveImageOpen: Use 'g_new0' instead of VIR_ALLOC(_N)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-23 15:36:53 +02:00
Peter Krempa
db907a4d9c qemuDomainSaveImageOpen: Automatically close 'fd' if unneeded
Use VIR_AUTOCLOSE to declare it and remove all internal closing of the
filedescriptor. This will allow getting rid of 'error' completely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-23 15:36:53 +02:00
Peter Krempa
3850add603 qemuDomainSaveImageOpen: Use g_autoptr for 'def'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-23 15:36:48 +02:00
Peter Krempa
92b9657986 virQEMUSaveData: Register autoclear function and use it in qemuDomainSaveImageOpen
In an attempt to simplify qemuDomainSaveImageOpen we need to add
automatic pointer clearing for virQEMUSaveData.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-23 15:36:48 +02:00
Peter Krempa
f76a571820 qemu: fix domain start with corrupted save file
Commit 21ad56e932 introduced a regression where a VM with a corrupted
save image file would fail to start on the first attempt. This was
caused by returning a wrong return code as 'fd' was abused to also hold
the return code.

Since it's easy to miss this nuance, introduce a 'ret' variable for the
return code and return it' value in the error section.

https://bugzilla.redhat.com/show_bug.cgi?id=1791522

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
2020-04-23 15:35:39 +02:00
Ján Tomko
d016a64de2 util: remove virRun
Everything is using virCommand now.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 12:49:30 +02:00
Ján Tomko
7e5580a2a0 util: remove references to virRun/virExec
virCommand is now used everywhere.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Suggested-by: Sebastian Mitterle <smitterl@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 12:49:30 +02:00
Ján Tomko
36f09bd3c3 Remove all usage of virRun
Catch the individual usage not removed in previous commits.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 12:49:30 +02:00
Ján Tomko
e0bc87cab8 vmware: use virCommand instead of virRun
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 12:49:30 +02:00
Ján Tomko
5c911bcd2b openvz: switch from virRun to virCommand
Construct the command in multiple steps instead of using a sentinel
in the args array.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 12:49:30 +02:00
Michal Privoznik
8589ecc69f networkxml2xmltest: Complete renaming of @actual
In 97a0aa2467 the @actual variable was renamed to @confactual.
However, the commit missed non-Linux case resulting in a broken
build.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 12:38:01 +02:00
Julio Faracco
7e5a40fd0f tests: Add tests for <lease/> to cover dnsmasq settings
New tests are required to cover some new XML syntax entry for
<lease/> option. This includes schema testing and other features
like unit attribute and lease value. This commit includes hostsfile
checks adding new files for each test case that is manipulating <host/>
tag.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 10:59:33 +02:00
Julio Faracco
97a0aa2467 conf: Add <lease/> option for <dhcp/> settings
If an user is trying to configure a dhcp neetwork settings, it is not
possible to change the leasetime of a range or a host entry. This is
available using dnsmasq extra options, but they are associated with
dhcp-range or dhcp-hosts fields. This patch implements a leasetime for
range and hosts tags. They can be defined under that settings:

    <dhcp>
      <range ...>
        <lease/>
      </range>
      <host ...>
        <lease/>
      </host>
    </dhcp>

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=913446

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-23 10:59:23 +02:00
Chen Hanxiao
5670fb5794 docs: drvqemu: trivial fix for qemu commands passthrough
element <qemu:commandline> should be the child of <domain>

Signed-off-by: Chen Hanxiao <chen_han_xiao@126.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2020-04-22 18:56:47 +02:00
Jim Fehlig
468c981130 news: Document new Xen hypervisor features
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2020-04-22 10:35:06 -06:00
Michal Privoznik
9a13704818 udevHandleOneDevice: Remove old instance of device on "move"
When a device is "move"-d (this basically means it was renamed),
we add the new device onto our list but keep the old there too.
Fortunately, udev sets this DEVPATH_OLD property which points to
the old device path. We can use it to remove the old instance.

To test this try renaming an interface, for instance:

  # ip link set tunl0 name tunl1
  # ip link set tunl1 name tunl0

One problem with udev is that it sends old ifname in INTERFACE
property, which creates a problem for us, the property is where
we get the ifname from and use it then to query all kind of info
about the interface. Well, if it is non-existent then we can't
query anything. This happens if ifname rename is suppressed
(net.ifnames=0 on kernel cmd line for instance). Fortunately, we
can use "kernel" source for udev events which has always the
fresh info.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-04-22 12:51:15 +02:00
Michal Privoznik
bfa8cf4b29 node_device_udev: Split udevRemoveOneDevice() into two
Move internals of udevRemoveOneDevice() into a separate function
which accepts sysfs path as an argument and actually removes the
device from the internal list. It will be reused later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2020-04-22 12:51:15 +02:00
Michal Privoznik
4c1033a151 udevRemoveOneDevice: Unlock node device obj upon return
When removing a node device object from the internal list the
udevRemoveOneDevice() function does plain unref over the object.
This is not sufficient. If there is another thread that's waiting
for the object lock it will wait forever.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-22 12:51:15 +02:00
Ján Tomko
c740ae69c3 conf: split out virDomainFeaturesDefParse
The virDomainDefParseXML function has grown so large it broke the build:
../../src/conf/domain_conf.c:20362:1: error: stack frame size of 4168 bytes
in function 'virDomainDefParseXML' [-Werror,-Wframe-larger-than=]

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-04-22 10:46:37 +02:00
Marc-André Lureau
090a1770a1 qemu-cgroup: remove unnecessary include
The file doesn't use virSystemd functions directly.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-22 09:58:10 +02:00
Marc-André Lureau
8e1ac0d384 qemu-dbus: register DBus bus to the VM cgroup
External devices are started before cgroup is created. Add the DBus
daemon to the VM cgroup with the rest of the external devices.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-22 09:58:10 +02:00
Marc-André Lureau
5f56cb8bc8 qemu-dbus: remove unused variable
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-22 09:58:10 +02:00
Marc-André Lureau
a86094d694 qemu-dbus: prevent double start of the bus daemon
Allow calling qemuDBusStart() multiple times (as may be done by
qemu-slirp already).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-22 09:58:10 +02:00
Marc-André Lureau
8cb44c01a8 slirp: add helper to VM cgroup
The slirp helper process should be associated with the VM cgroup, like
other helpers.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-22 09:58:10 +02:00
Marc-André Lureau
be6f94277e slirp: leave the dbus daemon running on error
Don't stop the DBus daemon if a slirp helper failed to start, as it
may be shared with other helpers.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-22 09:58:10 +02:00
Andrea Bolognani
fbc4e81a36 virsh: Fix return code for dump and migrate
When the job monitoring logic was refactored, these two commands
were not converted properly and the result is that a successful
dump or migration (char '0') would be reported as a failed one
(int 48) instead.

Fixes: dc0771cfa2
Reported-by: Brian Rak <brak@gameservers.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-22 09:30:56 +02:00
Jim Fehlig
9ced95a49c docs: Remove stray parenthesis
Commit fadbaa2375 introduced a stray parenthesis in formatdomain.html.in.
Remove it.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2020-04-21 16:09:24 -06:00
Andrea Bolognani
94cb908f90 CONTRIBUTING: Include information on build dependencies
libvirt depends on a ton of packages, so trying to install them
all by using the classic approach of repeatedly running configure
and reacting to each failure by installing the corresponding
missing package will inevitably lead to frustration.

Luckily there's an easy solution to get most dependencies
installed in one fell swoop, and we just need to document it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2020-04-21 19:25:38 +02:00
Jim Fehlig
bed3252536 tests: check conversion of passthrough hypervisor feature
Add a new test to check the 'mode' attribute of the passthrough element
and augment an existing, related test to check enablement of the
passthrough element only.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-21 09:22:14 -06:00
Jim Fehlig
b523e22521 xenconfig: Add support for 'passthrough' hypervisor feature
Add support for xl.cfg(5) 'passthrough' option in the domXML-to-xenconfig
configuration converter.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-21 09:21:42 -06:00
Jim Fehlig
9cb8bc6ff1 libxl: refactor cpu and hypervisor feature parser/formatter
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-21 09:20:58 -06:00
Jim Fehlig
9529e0077a libxl: make use of passthrough hypervisor feature
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-21 09:20:07 -06:00
Jim Fehlig
fadbaa2375 conf: add xen hypervisor feature 'passthrough'
'passthrough' is Xen-Specific guest configuration option new to Xen 4.13
that enables IOMMU mappings for a guest and hence whether it supports PCI
passthrough. The default is disabled. See the xl.cfg(5) man page and
xen.git commit babde47a3fe for more details.

The default state of disabled prevents hotlugging PCI devices. However,
if the guest configuration contains a PCI passthrough device at time of
creation, libxl will automatically enable 'passthrough' and subsequent
hotplugging of PCI devices will also be possible. It is not possible to
unconditionally enable 'passthrough' since it would introduce a migration
incompatibility due to guest ABI change. Instead, introduce another Xen
hypervisor feature that can be used to enable guest PCI passthrough

  <features>
    <xen>
      <passthrough state='on'/>
    </xen>
  </features>

To allow finer control over how IOMMU maps to guest P2M table, the
passthrough element also supports a 'mode' attribute with values
restricted to snyc_pt and share_pt, similar to xl.cfg(5) 'passthrough'
setting .

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-21 09:18:58 -06:00
Marek Marczykowski-Górecki
34077c1b8b tests: check e820_host option handling
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2020-04-21 09:06:09 -06:00
Marek Marczykowski-Górecki
f3ef7dafc8 xenconfig: parse e820_host option
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2020-04-21 09:06:09 -06:00
Marek Marczykowski-Górecki
5749395bfd libxl: make use of e820_host feature
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2020-04-21 09:06:09 -06:00
Marek Marczykowski-Górecki
b7d6648d43 conf: add xen specific feature: e820_host
e820_host is a Xen-specific option, only available for PV domains, that
provides the domain a virtual e820 memory map based on the host one. It
is enabled with a new Xen hypervisor feature, e.g.

  <features>
    <xen>
      <e820_host state='on'/>
    </xen>
  </features>

e820_host is required when using PCI passthrough and is generally
considered safe for any PV kernel. e820_host is silently ignored if set
in HVM domain configuration. See xl.cfg(5) man page in the Xen
documentation for more details.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2020-04-21 09:01:55 -06:00
Andrea Bolognani
de011c60a1 README: Add GitLab CI badge
We've moved most of our CI jobs to GitLab, so we should display
the corresponding badge prominently.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-20 18:02:07 +02:00
Andrea Bolognani
c7aad5de46 CONTRIBUTING: Include in release archives
The file, added with commit

  commit 874952f80c
  Author: Andrea Bolognani <abologna@redhat.com>
  Date:   Mon Apr 6 11:56:58 2020 +0200

    CONTRIBUTING: Add entry point for new contributors

should be included in release archives.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-20 18:01:55 +02:00
Mark Asselstine
72d99b094b Avoid unnecessary error messages handling udev events
The udev monitor thread "udevEventHandleThread()" will lag the
actual/real view of devices in sysfs as it serially processes udev
monitor events. So for instance if you were to run the following cmd
to create a new veth pair and rename one of the veth endpoints

you might see the following monitor events and real world that looks like

                                     time
			              |    create v0 sysfs entry
wake udevEventHandleThread            |    create v1 sysfs entry
udev_monitor_receive_device(v1-add)   |    move v0 sysfs to v2
udevHandleOneDevice(v1)               |
udev_monitor_receive_device(v0-add)   |
udevHandleOneDevice(v0)               | <--- error msgs in virNetDevGetLinkInfo()
udev_monitor_receive_device(v2-move)  |      as v0 no longer exists
udevHandleOneDevice(v2)               |
                                     \/

As you can see the changes in sysfs can take place well before we get
to act on the events in the udevEventHandleThread(), so by the time we
get around to processing the v0 add event, the sysfs entry has been
moved to v2.

To work around this we check if the sysfs entry is valid before
attempting to read it and don't bother trying to read link info if
not. This is safe since we will never read sysfs entries earlier than
it existing, ie. if the entry is not there it has either been removed
in the time since we enumerated the device or something bigger is
busted, in either case, no sysfs entry, no link info. In the case
described above we will eventually get the link info as we work
through the queue of monitor events and get to the 'move' event.

https://bugzilla.redhat.com/show_bug.cgi?id=1557902

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-20 15:25:52 +02:00
Mark Asselstine
abbd3a3184 node_device_udev: handle move events
It is possible and common to rename some devices, this is especially
true for ethernet devices such as veth pairs.

In the udevEventHandleThread() we will be notified of this change but
currently we only process "add", "change" and "remove"
events. Renaming a device such as above results in a "move" event, not
a "remove" followed by and "add" or vise versa. This change will add
the new/destination device to our records but unfortunately there is
no usable mechanism to identify the old/source device to remove it
from the records. So this is admittedly only a partial fix.

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-04-20 15:25:52 +02:00
Philipp Hahn
a7f0a3a272 doc/python: Update to Python 3
Convert the simple example to Python 3 syntax:
- print() is a function
- do not use bare except
- libvirt.open*() does not return None but raises an exception

The referenced source for the example was removed with
5bb2a245ab

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-04-20 14:06:25 +01:00
Daniel P. Berrangé
67edcb32a3 docs: add news about virtualbox version support changes
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-20 11:34:59 +01:00
Daniel P. Berrangé
622c5e4099 vbox: add support for version 6.1 SDK
Changes in the API:

 - APIs related to the graphics adapter are no longer on the
   IMachine interface, but on a IGraphicsAdapter interface
 - The LaunchVMProcess method takes a list of env variables
   instead of a single variable containing a concatenated
   list. Since we only ever pass a single env variable, we
   can simply stuff it straight into a list.
 - The DHCP server start method no longer needs the network
   name

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-20 11:34:59 +01:00
Daniel P. Berrangé
a030a78c69 vbox: add version 6.1 CAPI header
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-04-20 11:34:59 +01:00