]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agoconf: Add <lease/> option for <dhcp/> settings
Julio Faracco [Wed, 22 Apr 2020 20:05:57 +0000 (17:05 -0300)]
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>
5 years agodocs: drvqemu: trivial fix for qemu commands passthrough
Chen Hanxiao [Wed, 22 Apr 2020 16:02:20 +0000 (12:02 -0400)]
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>
5 years agonews: Document new Xen hypervisor features
Jim Fehlig [Tue, 21 Apr 2020 22:05:40 +0000 (16:05 -0600)]
news: Document new Xen hypervisor features

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoudevHandleOneDevice: Remove old instance of device on "move"
Michal Privoznik [Mon, 20 Apr 2020 14:12:03 +0000 (16:12 +0200)]
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>
5 years agonode_device_udev: Split udevRemoveOneDevice() into two
Michal Privoznik [Mon, 20 Apr 2020 13:59:19 +0000 (15:59 +0200)]
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>
5 years agoudevRemoveOneDevice: Unlock node device obj upon return
Michal Privoznik [Mon, 20 Apr 2020 13:40:01 +0000 (15:40 +0200)]
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>
5 years agoconf: split out virDomainFeaturesDefParse
Ján Tomko [Tue, 21 Apr 2020 16:35:59 +0000 (18:35 +0200)]
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>
5 years agoqemu-cgroup: remove unnecessary include
Marc-André Lureau [Wed, 8 Apr 2020 17:23:51 +0000 (19:23 +0200)]
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>
5 years agoqemu-dbus: register DBus bus to the VM cgroup
Marc-André Lureau [Wed, 8 Apr 2020 17:23:50 +0000 (19:23 +0200)]
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>
5 years agoqemu-dbus: remove unused variable
Marc-André Lureau [Wed, 8 Apr 2020 17:23:49 +0000 (19:23 +0200)]
qemu-dbus: remove unused variable

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu-dbus: prevent double start of the bus daemon
Marc-André Lureau [Wed, 8 Apr 2020 17:23:48 +0000 (19:23 +0200)]
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>
5 years agoslirp: add helper to VM cgroup
Marc-André Lureau [Wed, 8 Apr 2020 17:23:47 +0000 (19:23 +0200)]
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>
5 years agoslirp: leave the dbus daemon running on error
Marc-André Lureau [Wed, 8 Apr 2020 17:23:46 +0000 (19:23 +0200)]
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>
5 years agovirsh: Fix return code for dump and migrate
Andrea Bolognani [Tue, 21 Apr 2020 17:06:16 +0000 (19:06 +0200)]
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: dc0771cfa2e78ffecd7c8234538ee548748d7bef
Reported-by: Brian Rak <brak@gameservers.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: Remove stray parenthesis
Jim Fehlig [Tue, 21 Apr 2020 22:09:24 +0000 (16:09 -0600)]
docs: Remove stray parenthesis

Commit fadbaa2375 introduced a stray parenthesis in formatdomain.html.in.
Remove it.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
5 years agoCONTRIBUTING: Include information on build dependencies
Andrea Bolognani [Mon, 20 Apr 2020 10:49:09 +0000 (12:49 +0200)]
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>
5 years agotests: check conversion of passthrough hypervisor feature
Jim Fehlig [Fri, 17 Apr 2020 20:19:16 +0000 (14:19 -0600)]
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>
5 years agoxenconfig: Add support for 'passthrough' hypervisor feature
Jim Fehlig [Thu, 16 Apr 2020 14:31:48 +0000 (08:31 -0600)]
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>
5 years agolibxl: refactor cpu and hypervisor feature parser/formatter
Jim Fehlig [Thu, 16 Apr 2020 03:48:42 +0000 (21:48 -0600)]
libxl: refactor cpu and hypervisor feature parser/formatter

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolibxl: make use of passthrough hypervisor feature
Jim Fehlig [Wed, 15 Apr 2020 23:18:25 +0000 (17:18 -0600)]
libxl: make use of passthrough hypervisor feature

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: add xen hypervisor feature 'passthrough'
Jim Fehlig [Wed, 15 Apr 2020 22:34:54 +0000 (16:34 -0600)]
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>
5 years agotests: check e820_host option handling
Marek Marczykowski-Górecki [Tue, 14 Apr 2020 02:37:07 +0000 (04:37 +0200)]
tests: check e820_host option handling

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agoxenconfig: parse e820_host option
Marek Marczykowski-Górecki [Tue, 14 Apr 2020 02:37:06 +0000 (04:37 +0200)]
xenconfig: parse e820_host option

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agolibxl: make use of e820_host feature
Marek Marczykowski-Górecki [Tue, 14 Apr 2020 02:37:05 +0000 (04:37 +0200)]
libxl: make use of e820_host feature

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agoconf: add xen specific feature: e820_host
Marek Marczykowski-Górecki [Tue, 14 Apr 2020 02:37:04 +0000 (04:37 +0200)]
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>
5 years agoREADME: Add GitLab CI badge
Andrea Bolognani [Tue, 14 Apr 2020 13:19:54 +0000 (15:19 +0200)]
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>
5 years agoCONTRIBUTING: Include in release archives
Andrea Bolognani [Tue, 14 Apr 2020 11:56:36 +0000 (13:56 +0200)]
CONTRIBUTING: Include in release archives

The file, added with commit

  commit 874952f80c6d68c1a7a75e71c11a576f96f75dc2
  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>
5 years agoAvoid unnecessary error messages handling udev events
Mark Asselstine [Thu, 16 Apr 2020 15:57:46 +0000 (11:57 -0400)]
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>
5 years agonode_device_udev: handle move events
Mark Asselstine [Thu, 16 Apr 2020 15:57:45 +0000 (11:57 -0400)]
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>
5 years agodoc/python: Update to Python 3
Philipp Hahn [Mon, 20 Apr 2020 13:01:11 +0000 (15:01 +0200)]
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
5bb2a245abbde4c0a407f631660e2f2c81bc4c02

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Philipp Hahn <hahn@univention.de>
5 years agodocs: add news about virtualbox version support changes
Daniel P. Berrangé [Fri, 17 Apr 2020 11:56:25 +0000 (12:56 +0100)]
docs: add news about virtualbox version support changes

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: add support for version 6.1 SDK
Daniel P. Berrangé [Fri, 17 Apr 2020 10:57:54 +0000 (11:57 +0100)]
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>
5 years agovbox: add version 6.1 CAPI header
Daniel P. Berrangé [Fri, 17 Apr 2020 11:16:41 +0000 (12:16 +0100)]
vbox: add version 6.1 CAPI header

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: add support for version 6.0 SDK
Daniel P. Berrangé [Fri, 17 Apr 2020 10:57:54 +0000 (11:57 +0100)]
vbox: add support for version 6.0 SDK

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: add version 6.0 CAPI header
Daniel P. Berrangé [Fri, 17 Apr 2020 11:16:41 +0000 (12:16 +0100)]
vbox: add version 6.0 CAPI header

Changes in the API:

 - The CreatedSharedFolder method now accepts a target mount
   point. Since we don't request automount, we're just passing
   NULL. We could, however, use this to pass the desired
   mount target from the XML config in future.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: remove unused support for Windows MSCOM
Daniel P. Berrangé [Fri, 17 Apr 2020 11:12:09 +0000 (12:12 +0100)]
vbox: remove unused support for Windows MSCOM

Long ago we switched the vbox driver to run inside libvirtd to avoid
libvirt.so being polluted with GPLv2-only code. Since libvirtd is not
built on Windows, we disabled vbox on Windows builds. Thus the MSCOM
glue code is not required.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: remove version 5.1 CAPI header
Daniel P. Berrangé [Fri, 17 Apr 2020 11:05:36 +0000 (12:05 +0100)]
vbox: remove version 5.1 CAPI header

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: remove support for version 5.1 API
Daniel P. Berrangé [Fri, 17 Apr 2020 11:03:50 +0000 (12:03 +0100)]
vbox: remove support for version 5.1 API

This is no longer supported since 2018/04

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: remove version 5.0 CAPI header
Daniel P. Berrangé [Fri, 17 Apr 2020 11:05:36 +0000 (12:05 +0100)]
vbox: remove version 5.0 CAPI header

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovbox: remove support for version 5.0 API
Daniel P. Berrangé [Fri, 17 Apr 2020 11:03:50 +0000 (12:03 +0100)]
vbox: remove support for version 5.0 API

This is no longer supported since 2017/05

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirnetdev.c: Use g_auto*()
Michal Privoznik [Sun, 19 Apr 2020 05:24:40 +0000 (07:24 +0200)]
virnetdev.c: Use g_auto*()

While I'm at it, use more g_autofree and g_autoptr() in this
file. This also fixes a possible mem-leak in
virNetDevGetVirtualFunctions().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirNetDevSwitchdevFeature: Make failure to get 'family_id' non-fatal
Michal Privoznik [Sun, 19 Apr 2020 05:25:34 +0000 (07:25 +0200)]
virNetDevSwitchdevFeature: Make failure to get 'family_id' non-fatal

I've just got a new machine and I'm still converging on the
kernel config. Anyway, since I don't have enabled any of SRIO-V
drivers, my kernel doesn't have NET_DEVLINK enabled (i.e.
virNetDevGetFamilyId() returns 0). But this makes nodedev driver
ignore all interfaces, because when enumerating all devices via
udev, the control reaches virNetDevSwitchdevFeature() eventually
and subsequently virNetDevGetFamilyId() which 'fails'. Well, it's
not really a failure - the virNetDevSwitchdevFeature() stub
simply returns 0.

Also, move the call a few lines below, just around the place
where it's needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirNetDevGetFamilyId: Change signature
Michal Privoznik [Sun, 19 Apr 2020 06:26:04 +0000 (08:26 +0200)]
virNetDevGetFamilyId: Change signature

Introduced in v3.8.0-rc1~96, the virNetDevGetFamilyId() gets
netlink family ID for passed family name (even though it's used
only for getting "devlink" ID). Nevertheless, the function
returns 0 on an error or if no family ID was found. This makes it
harder for a caller to distinguish these two. Change the retval
so that a negative value is returned upon error, zero is no ID
found (but no error encountered) and a positive value is returned
on successful translation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: Do not include sys/wait.h on Win32
Jiri Denemark [Fri, 17 Apr 2020 18:27:00 +0000 (20:27 +0200)]
util: Do not include sys/wait.h on Win32

This fixes build on mingw broken by my previous commit 36e125296a.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu: Label restore path outside of secdriver transactions
Michal Privoznik [Fri, 3 Apr 2020 08:28:17 +0000 (10:28 +0200)]
qemu: Label restore path outside of secdriver transactions

As explained in the previous commit, we need to relabel the file
we are restoring the domain from. That is the FD that is passed
to QEMU. If the file is not under /dev then the file inside the
namespace is the very same as the one in the host. And regardless
of using transactions, the file will be relabeled. But, if the
file is under /dev then when using transactions only the copy
inside the namespace is relabeled and the one in the host is not.
But QEMU is reading from the one in the host, actually.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agosecurity: Introduce virSecurityManagerDomainSetPathLabelRO
Michal Privoznik [Fri, 3 Apr 2020 12:31:35 +0000 (14:31 +0200)]
security: Introduce virSecurityManagerDomainSetPathLabelRO

This API allows drivers to separate out handling of @stdin_path
of virSecurityManagerSetAllLabel(). The thing is, the QEMU driver
uses transactions for virSecurityManagerSetAllLabel() which
relabels devices from inside of domain's namespace. This is what
we usually want. Except when resuming domain from a file. The
file is opened before any namespace is set up and the FD is
passed to QEMU to read the migration stream from. Because of
this, the file lives outside of the namespace and if it so
happens that the file is a block device (i.e. it lives under
/dev) its copy will be created in the namespace. But the FD that
is passed to QEMU points to the original living in the host and
not in the namespace. So relabeling the file inside the namespace
helps nothing.

But if we have a separate API for relabeling the restore file
then the QEMU driver can continue calling
virSecurityManagerSetAllLabel() with transactions enabled and
call this new API without transactions.

We already have an API for relabeling a single file
(virSecurityManagerDomainSetPathLabel()) but in case of SELinux
it uses @imagelabel (which allows RW access) and we want to use
@content_context (which allows RO access).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoutil: Fix virDaemonForkIntoBackground
Jiri Denemark [Thu, 16 Apr 2020 13:11:06 +0000 (15:11 +0200)]
util: Fix virDaemonForkIntoBackground

This commit partially reverts

    commit c360ea28dc267802690e129fbad08ca2f22a44e9
    Refs: v6.2.0-rc1-1-gc360ea28dc
    Author:     Rafael Fonseca <r4f4rfs@gmail.com>
    AuthorDate: Fri Mar 27 18:40:47 2020 +0100
    Commit:     Michal Prívozník <mprivozn@redhat.com>
    CommitDate: Mon Mar 30 09:48:22 2020 +0200

    util: virdaemon: fix compilation on mingw

    The daemons are not supported on Win32 and therefore were not compiled
    in that platform. However, with the daemon code sharing, all the code in
    utils *is* compiled and it failed because `waitpid`, `fork`, and
    `setsid` are not available. So, as before, let's not build them on
    Win32 and make the code more portable by using existing vir* wrappers.

Not compiling virDaemonForkIntoBackground on Win32 is good, but the
second part of the original patch incorrectly replaced waitpid and fork
with our virProcessWait and virFork APIs. These APIs are more than just
simple wrappers and we don't want any of the extra functionality.
Especially virFork would reset any setup made before
virDaemonForkIntoBackground is called, such as logging, signal handling,
etc.

As a result of the change the additional fix in v6.2.0-67-ga87e4788d2
(util: virdaemon: fix waiting for child processes) is no longer
needed and it is effectively reverted by this commit.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: Improve zPCI section in pci-addresses.rst
Boris Fiuczynski [Fri, 17 Apr 2020 12:27:34 +0000 (14:27 +0200)]
docs: Improve zPCI section in pci-addresses.rst

Improving the zPCI example by choosing more distinct values and
adding explanation for fid.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: Update introduction in pci-addresses.rst
Andrea Bolognani [Fri, 17 Apr 2020 12:27:33 +0000 (14:27 +0200)]
docs: Update introduction in pci-addresses.rst

Changing the introduction to bring the idea of this document better across.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
5 years agodocs: Add section about code blocks to styleguide.rst
Andrea Bolognani [Thu, 16 Apr 2020 16:36:48 +0000 (18:36 +0200)]
docs: Add section about code blocks to styleguide.rst

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: fix mistaken description of the read-only socket units
Daniel P. Berrangé [Thu, 16 Apr 2020 13:18:42 +0000 (14:18 +0100)]
docs: fix mistaken description of the read-only socket units

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: remove old unused favicon file
Daniel P. Berrangé [Thu, 16 Apr 2020 11:52:13 +0000 (12:52 +0100)]
docs: remove old unused favicon file

The use of 32favicon.png was removed when the new favicons were
introduced in

  commit 40cb5581c4ace6c4a5b68990aaac4dff1b656054
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Wed Jul 26 18:22:11 2017 +0100

    docs: add full set of "favicon" files to support modern clients

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: add missing files to static asset list
Daniel P. Berrangé [Thu, 16 Apr 2020 11:49:29 +0000 (12:49 +0100)]
docs: add missing files to static asset list

The various favicon files were missing from the favicon list, so never
installed, as was an example code diagram.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: fix handling of static assets in build dir
Daniel P. Berrangé [Thu, 16 Apr 2020 11:41:52 +0000 (12:41 +0100)]
docs: fix handling of static assets in build dir

We previously added a hack to symlink CSS files from the source dir into
the build dir, to allow the website to be browsed locally. We should
have also done this for any images.

This change merges several variables into one "$(assets)" so that we
treat all static files in the root dir the same way.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobhyve: add missing param to virDomainPCIAddressBusSetModel
Daniel P. Berrangé [Thu, 16 Apr 2020 10:39:49 +0000 (10:39 +0000)]
bhyve: add missing param to virDomainPCIAddressBusSetModel

Fixes build error introduced in

  commit aa15e9259f1f246e69fb9742581ced720c88695d
  Author: Laine Stump <laine@redhat.com>
  Date:   Sun Apr 5 22:40:37 2020 -0400

    qemu/conf: set HOTPLUGGABLE connect flag during PCI address set init

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconf: Trivial comment fix
Leonid Bloch [Thu, 16 Apr 2020 11:24:54 +0000 (14:24 +0300)]
conf: Trivial comment fix

Trivial comment fix, reflecting the changes in
4ee2b31804f4d3477ee83bac28d9991afb0c3393.

Signed-off-by: Leonid Bloch <lb.workbox@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemuDomainDefPostParse: Fail if unable to fill machine type
Michal Privoznik [Thu, 16 Apr 2020 12:18:28 +0000 (14:18 +0200)]
qemuDomainDefPostParse: Fail if unable to fill machine type

Previously, we used virCapabilitiesDomainDataLookup() to fill
machine type in post parse callback if none was provided in the
domain XML. If machine type couldn't be filled in an error was
reported. After 4a4132b4625 we've changed it to
virQEMUCapsGetPreferredMachine() which returns NULL, but we no
longer report an error and proceed with the post parse callbacks
processing. This may lead to a crash because the code later on
assumes def->os.machine is not NULL.

Fixes: 4a4132b4625
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
5 years agoqemu: Revoke access to mirror on failed blockcopy
Michal Privoznik [Tue, 14 Apr 2020 09:18:02 +0000 (11:18 +0200)]
qemu: Revoke access to mirror on failed blockcopy

When preparing to do a blockcopy, the mirror image is modified so
that QEMU can access it. For instance, the mirror has seclabels
set, if it is a NVMe disk it is detached from the host and so on.
And usually, the restore is done upon successful finish of the
blockcopy operation. But, if something fails then we need to
explicitly revoke the access to the mirror image (and thus
reattach NVMe disk back to the host).

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1822538
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
5 years agodocs: Remove one example from pci-addresses.rst
Andrea Bolognani [Wed, 15 Apr 2020 17:12:46 +0000 (19:12 +0200)]
docs: Remove one example from pci-addresses.rst

The idea behind this document is to show, with actual examples,
that users should not expect PCI addresses in the domain XML and
in the guest OS to match.

The first zPCI example already serves this purpose perfectly, so
in the interest of keeping the page as brief and easy to digest
as possible the second one is removed.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
5 years agodocs: Remove MAC addresses from pci-addresses.rst
Andrea Bolognani [Wed, 15 Apr 2020 17:11:18 +0000 (19:11 +0200)]
docs: Remove MAC addresses from pci-addresses.rst

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
5 years agodocs: Move sections around in pci-addresses.rst
Andrea Bolognani [Wed, 15 Apr 2020 17:11:01 +0000 (19:11 +0200)]
docs: Move sections around in pci-addresses.rst

The section about VFIO devices is kept separate from the rest
because it's less about domain XML and guest OS disagreeing on the
PCI address of a device, and more about which of the two PCI
addresses in the domain XML is even relevant to the guest OS.

The section on zPCI addresses, on the other hand, falls squarely
in the "more complex cases" category, so it should live in the
corresponding section.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
5 years agodocs: Use consistent style in pci-addresses.rst
Andrea Bolognani [Wed, 15 Apr 2020 17:09:34 +0000 (19:09 +0200)]
docs: Use consistent style in pci-addresses.rst

Indent all code snippets by the same number of spaces, and don't
embed the :: marker in the line preceding a code block.

This commit is best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
5 years agoqemu: fix hang in p2p + xbzrle compression + parallel migration
Lin Ma [Thu, 16 Apr 2020 04:44:51 +0000 (12:44 +0800)]
qemu: fix hang in p2p + xbzrle compression + parallel migration

When we do parallel migration, The multifd-channels migration parameter
needs to be set on the destination side as well before incoming migration
URI, unless we accept the default number of connections(2).

Usually, This can be correctly handled by libvirtd. But in this case if
we use p2p + xbzrle compression without parameter '--comp-xbzrle-cache',
qemuMigrationParamsDump returns too early, The corresponding migration
parameter will not be set on the destination side, It results QEMU hangs.

Reproducer:
virsh migrate --live --p2p --comp-methods xbzrle \
--parallel --parallel-connections 3 GUEST qemu+ssh://dsthost/system

or

virsh migrate --live --p2p --compressed \
--parallel --parallel-connections 3 GUEST qemu+ssh://dsthost/system

Signed-off-by: Lin Ma <lma@suse.com>
Message-Id: <20200416044451.21134-1-lma@suse.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agogitlab: Enable improved ccache usage
Andrea Bolognani [Mon, 30 Mar 2020 16:29:06 +0000 (18:29 +0200)]
gitlab: Enable improved ccache usage

Setting CC="ccache cc" works in most cases, but sometimes it will
break the build: in particular, we have experienced issues in the
past with that approach when using cgo to build our Go bindings.

A more robust approach is to have a directory containing symlinks
from the compiler name to the ccache binary: in that case, ccache
itself will invoke the compiler, and the build system will be none
the wiser.

Since libvirt-ci commit 2563aebb6c5c, container images contain a
suitable symlink directory, so all that's needed to enable the new
approach is to add this directory to $PATH.

Since we're touching this anyway, we make a few more changes:
$CCACHE_DIR is no longer created manually, because ccache will
take care of creating it for us if it doesn't already exist; the
ccache setup is moved out of the job template and into
script_variables, removing unnecessary duplication; a limit is
set on the size of the cache (500 MB, which is twice the amount
used by a fresh build on my Fedora 31 machine).

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agogitlab: Don't define $MAKE
Andrea Bolognani [Mon, 30 Mar 2020 16:26:16 +0000 (18:26 +0200)]
gitlab: Don't define $MAKE

Since libvirt-ci commit 27cfddee8835, paths to build tools such as
ninja and make are exported in the container's environment and can
be used directly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: add zpci information to pci-addresses.rst
Cornelia Huck [Wed, 15 Apr 2020 10:51:51 +0000 (12:51 +0200)]
docs: add zpci information to pci-addresses.rst

Add some information on how pci address work on s390x.

Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: Fix word repetition in pci-addresses.rst
Andrea Bolognani [Wed, 15 Apr 2020 08:49:42 +0000 (10:49 +0200)]
docs: Fix word repetition in pci-addresses.rst

Fixes: 2923e7a3dd984c46202703d390dce3ff4ea4048c
Reported-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
5 years agoapparmor: avoid denials on libpmem initialization
Christian Ehrhardt [Wed, 8 Apr 2020 14:47:58 +0000 (16:47 +0200)]
apparmor: avoid denials on libpmem initialization

With libpmem support compiled into qemu it will trigger the following
denials on every startup.
  apparmor="DENIED" operation="open" name="/"
  apparmor="DENIED" operation="open" name="/sys/bus/nd/devices/"

This is due to [1] that tries to auto-detect if the platform supports
auto flush for all region.

Once we know all the paths that are potentially needed if this feature
is really used we can add them conditionally in virt-aa-helper and labelling
calls in case </pmem> is enabled.

But until then the change here silences the denial warnings seen above.

[1]: https://github.com/pmem/pmdk/blob/master/src/libpmem2/auto_flush_linux.c#L131

Bug: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1871354

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Jamie Strandboge <jamie@canonical.com>
5 years agodocs: Add pci-addresses.rst
Andrea Bolognani [Tue, 14 Apr 2020 17:37:09 +0000 (19:37 +0200)]
docs: Add pci-addresses.rst

This document describes the relationship between PCI addresses as
seen in the domain XML and by the guest OS, which is a topic that
people get confused by time and time again.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
5 years agobackup: Allow 'encryption' of backups and scratch images
Peter Krempa [Thu, 9 Apr 2020 13:50:40 +0000 (15:50 +0200)]
backup: Allow 'encryption' of backups and scratch images

Add the appropriate entries into the schema to allow encryption of the
backup or scratch image. Since we use blockdev internals for everything
no changes to the code are actually necessary.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: backup: Remove references to push backup to network disk
Peter Krempa [Thu, 9 Apr 2020 14:19:59 +0000 (16:19 +0200)]
docs: backup: Remove references to push backup to network disk

It was never implemented and for now I don't think there's demand to do
it. Remove the reference.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Don't format http cookies unless VIR_DOMAIN_DEF_FORMAT_SECURE is used
Peter Krempa [Tue, 14 Apr 2020 08:31:02 +0000 (10:31 +0200)]
conf: Don't format http cookies unless VIR_DOMAIN_DEF_FORMAT_SECURE is used

Starting with 3b076391befc3fe72deb0c244ac6c2b4c100b410
(v6.1.0-122-g3b076391be) we support http cookies. Since they may contain
somewhat sensitive information we should not format them into the XML
unless VIR_DOMAIN_DEF_FORMAT_SECURE is asserted.

Reported-by: Han Han <hhan@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirstoragetest: testBackingParse: Use VIR_DOMAIN_DEF_FORMAT_SECURE when formatting xml
Peter Krempa [Tue, 14 Apr 2020 08:26:24 +0000 (10:26 +0200)]
virstoragetest: testBackingParse: Use VIR_DOMAIN_DEF_FORMAT_SECURE when formatting xml

We want to format even the secure information in tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirsh: cmdUndefine: Properly extract delete-storage-volume-snapshots flag
Peter Krempa [Thu, 9 Apr 2020 13:25:35 +0000 (15:25 +0200)]
virsh: cmdUndefine: Properly extract delete-storage-volume-snapshots flag

Commit 86608f787ee added the above flag as an alias for ambiguous
'delete-snapshots' flag, but forgot to actually change the code that
extracts it, thus the new version actually doesn't work.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: backup: Fix handling of backing store for backup target images
Peter Krempa [Tue, 31 Mar 2020 13:43:46 +0000 (15:43 +0200)]
qemu: backup: Fix handling of backing store for backup target images

We always tried to install backing store for the image even if it didn't
make sense, e.g. for a full backup into a raw image. Additionally we
didn't record the backing file into the qcow2 metadata so the image
itself contained the diff of data but reading from it would be
incomplete as it depends on the backing image.

This patch fixes both issues by carefully installing the correct backing
file when appropriate and also recording it into the metadata when
creating the image.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoConvert all remaining Markdown files to reStructuredText
Andrea Bolognani [Tue, 14 Apr 2020 10:59:04 +0000 (12:59 +0200)]
Convert all remaining Markdown files to reStructuredText

We've adopted reStructuredText as the primary markup language for
our documentation and, given that both GitLab and GitHub can render
documents in this format just fine, it makes sense to get rid of
the few last remaining bits of Markdown and standardize on
reStructuredText across the board.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agolibvirt-stream: Convert to the g_autofree usage
Seeteena Thoufeek [Mon, 13 Apr 2020 12:49:26 +0000 (18:19 +0530)]
libvirt-stream: Convert to the g_autofree usage

Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agodriver: Yet 1 more g_autofree conversion change
Seeteena Thoufeek [Mon, 13 Apr 2020 12:48:57 +0000 (18:18 +0530)]
driver: Yet 1 more g_autofree conversion change

This is the last missing g_autofree conversion change in the module after
commit 1e2ae2e311c took care of the VIR_AUTOFREE conversion.

Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agotravis: Remove usage of 'sudo'
Andrea Bolognani [Fri, 10 Apr 2020 08:28:22 +0000 (10:28 +0200)]
travis: Remove usage of 'sudo'

Travis CI reports

  root: deprecated key sudo (The key `sudo` has no effect anymore.)

so let's drop it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotravis: Deduplicate build instructions
Andrea Bolognani [Fri, 10 Apr 2020 08:16:47 +0000 (10:16 +0200)]
travis: Deduplicate build instructions

All information, except for osx_image image, is identical between
the two jobs so we can avoid repeating it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoREADME-hacking: Drop from the git repository
Andrea Bolognani [Mon, 6 Apr 2020 10:02:39 +0000 (12:02 +0200)]
README-hacking: Drop from the git repository

The newly-introduced CONTRIBUTING.rst serves the same purposes and
lives in the path where most people would look for it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoCONTRIBUTING: Add entry point for new contributors
Andrea Bolognani [Mon, 6 Apr 2020 09:56:58 +0000 (11:56 +0200)]
CONTRIBUTING: Add entry point for new contributors

It's generally expected that a git repository will contain this file,
which serves as an entry point for people interested in contributing
to the project.

In our case, we have extensive documentation available on the
website which we don't want to duplicate, so let's just point people
there.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: fix iteration in virSocketAddrResolveService
Nikolay Shirokovskiy [Mon, 13 Apr 2020 13:48:43 +0000 (16:48 +0300)]
util: fix iteration in virSocketAddrResolveService

getaddrinfo returns linked list. Fix iteration accordingly.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoconf: during PCI hotplug, require that the controller support hotplug
Laine Stump [Mon, 6 Apr 2020 03:44:16 +0000 (23:44 -0400)]
conf: during PCI hotplug, require that the controller support hotplug

Before this patch we would simply rely on QEMU failing to attach the
device. Since we have a flag in the address set telling us which
controllers support hotplug, we can fail the operation sooner.

This also assures that when hotplugging with no provided PCI address,
that we skip any controllers with hotplug='off', and attempt to assign
the device to a controller that not only supports hotplug, but also
has it enabled.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: check HOTPLUGGABLE connect flag when validating a PCI address
Laine Stump [Mon, 6 Apr 2020 02:57:43 +0000 (22:57 -0400)]
conf: check HOTPLUGGABLE connect flag when validating a PCI address

The HOTPLUGGABLE flag is set for appropriates buses in a PCI address
set, and thnis patch updates virDomainPCIAddressFlagsCompatible() to
check the HOTPLUGGABLE flag when searching for a suitable bus/slot for
a device. No devices request HOTPLUGGABLE though (yet), so there is no
observable effect.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu/conf: set HOTPLUGGABLE connect flag during PCI address set init
Laine Stump [Mon, 6 Apr 2020 02:40:37 +0000 (22:40 -0400)]
qemu/conf: set HOTPLUGGABLE connect flag during PCI address set init

virDomainPCIAddressBusSetModel() is called for each PCI controller
when building an address set prior to assiging PCI addresses to
devices.

This patch adds a new argument, allowHotplug, to that function that
can be set to false if we know for certain that a particular
controller won't support hotplug

The most interesting case is in qemuDomainPCIAddressSetCreate(), where
the config of each existing controller is available while building the
address set, so we can appropriately set allowHotplug = false when the
user has "hotplug='off'" in the config of a controller that normally
would support hotplug. In all other cases, it is set to true or false
in accordance with the capability of the controller model.

So far we aren't doing anything with this bus flag in the address set.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: simplify logic when checking for AUTOASSIGN PCI addresses
Laine Stump [Sun, 5 Apr 2020 22:01:43 +0000 (18:01 -0400)]
conf: simplify logic when checking for AUTOASSIGN PCI addresses

Old behavior: If the address was manually provided by config, copy
device AUTOASSIGN flag into the bus flag, and then later on in the
function *always* check for a match of the flags (which will always
match if the address came from config, since we just copied it).

New behavior: Don't mess with the bus flags - just directly check if
the AUTOASSIGN flag matches in bus and dev, but only make the check if
the address didn't come from config (i.e. it was auto-assigned by
libvirt).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf/qemu: s/VIR_PCI_CONNECT_HOTPLUGGABLE/VIR_PCI_CONNECT_AUTOASSIGN/g
Laine Stump [Sun, 5 Apr 2020 21:16:55 +0000 (17:16 -0400)]
conf/qemu: s/VIR_PCI_CONNECT_HOTPLUGGABLE/VIR_PCI_CONNECT_AUTOASSIGN/g

When the HOTPLUGGABLE flag was originally added, it was set for all
the PCI controllers that accepted hotplugged devices, and requested
for all devices that were auto-assigned to a controller. While we're
still autoassigning to the same list of controllers, those controllers
may or may not support hotplug, so let's use the flag that fits what
we're actually doing.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: add new PCI_CONNECT flag AUTOASSIGN
Laine Stump [Mon, 23 Mar 2020 02:32:49 +0000 (22:32 -0400)]
conf: add new PCI_CONNECT flag AUTOASSIGN

This new flag will be set for any controller that we decide can have
devices assigned to it automatically during PCI device assignment. In
the past PCI_CONNECT_TYPE_HOTPLUGGABLE was used for this purpose, but
that is overloading that flag, and no longer technically correct; what
we *really* want is to auto-assign devices to any pcie-root-port or
pcie-switch-downstream-port regardless of whether or not that
controller happens to have hotplug enabled.

This patch just adds the flag, but doesn't use it at all. Note that
the numbering of all the other flags was changed in order to insert
the new flag near the beginning of the list; that doesn't cause any
problem because the connect flags aren't stored anywhere between runs
of libvirtd.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: mention hotplug='off' in news.xml
Laine Stump [Thu, 5 Mar 2020 20:17:41 +0000 (15:17 -0500)]
docs: mention hotplug='off' in news.xml

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: hook up pcie-root-port hotplug='off' option
Laine Stump [Wed, 4 Mar 2020 03:22:14 +0000 (22:22 -0500)]
qemu: hook up pcie-root-port hotplug='off' option

If a pcie-root-port or pcie-downstream-port has hotplug='off' in its
<target> subelement, and if the qemu binary supports the hotplug=false
option, then it will be added to the commandline for the pcie
controller. This controller will then not allow any hotplug/unplug of
devices while the guest is running (and the hotplug capability won't
be advertised to the guest OS, so the guest OS also won't present
unplugging of PCI devices as an option).

  <controller type='pci' model='pcie-root-port'>
    <target hotplug='off'/>
  </controller>

For any PCI controllers other than pcie-downstream-port and
pcie-root-port, of for qemu binaries that don't support the hotplug
commandline option, an error will be logged during validation.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: new attribute "hotplug" for pci controllers
Laine Stump [Tue, 3 Mar 2020 17:23:52 +0000 (12:23 -0500)]
conf: new attribute "hotplug" for pci controllers

a <controller type='pci'...> element can now have a "hotplug"
attribute in the <target> subelement. This is intended to control
whether or not the slot(s) of the controller support
hotplugging/unplugging a device:

   <controller type='pci' model='pcie-root-port'>
     <target hotplug='off'/>
   </controller>

The default value of hotplug is "on".

Since support for configuring such an option is hypervisor-dependent
(and will vary among different types of PCI controllers even on a
single hypervisor), no validation is done in this patch - that
validation will be done in the patch that wires support for the
setting into the hypervisor.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: new capabilities flag pcie-root-port.hotplug
Laine Stump [Thu, 27 Feb 2020 20:22:59 +0000 (15:22 -0500)]
qemu: new capabilities flag pcie-root-port.hotplug

This caps flag is set when the qemu binary supports the option
"hotplug" for pcie-root-port, ioh3420 (Intel pcie-root-port) and
xio3130-downstream (Intel pcie-downstream-port). If it's available,
it's possible to disable hotplugging/unplugging devices on a
particular port by adding ",hotplug=off" to the qemu device
commandline. This option first appears in qemu-5.0.0.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoformatdomain.html.in: document emulator/vcpu pin delay
Daniel Henrique Barboza [Thu, 9 Apr 2020 19:45:17 +0000 (16:45 -0300)]
formatdomain.html.in: document emulator/vcpu pin delay

In a guest with only one vcpu, when pinning the emulator in say CPU184
and the vcpu0 in CPU0 of the host, the user might expect that only
CPU0 and CPU184 of the host will be used by the guest.

The reality is that Libvirt takes some time to honor the emulator
and vcpu pinning, taking care of NUMA constraints first. This will
result in other CPUs of the host being potentially used by the
QEMU thread until the emulator/vcpu pinning is done. The user
then might be confused by the output of 'virsh cpu-stats' in this
scenario, showing around 200 microseconds of cycles being spent
in other CPUs.

Let's document this behavior, which is explained in detail in
Libvirt commit v5.0.0-199-gf136b83139, in the cputune section
of formatdomain.html.in.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoxenconfig: Add support for max_event_channels
Jim Fehlig [Tue, 7 Apr 2020 23:33:26 +0000 (17:33 -0600)]
xenconfig: Add support for max_event_channels

Add support in the domXML<->native config converter for max_event_channels.
The parser and formater functions for max_grant_frames were reworked to
also parse max_event_channels. In doing so the xenbus controller is added
earlier in the config parsing, requiring a small adjustment to one of the
existing tests. Include a new test for the event channel conversion.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolibxl: Add support for max_event_channels
Jim Fehlig [Tue, 7 Apr 2020 23:15:04 +0000 (17:15 -0600)]
libxl: Add support for max_event_channels

Add support for setting event_channels in libxl domain config object and
include a test to check that it is properly converted from XML to libxl
domain config.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconf: Add a new xenbus controller option for event channels
Jim Fehlig [Tue, 7 Apr 2020 22:37:09 +0000 (16:37 -0600)]
conf: Add a new xenbus controller option for event channels

Event channels are like PV interrupts and in conjuction with grant frames
form a data transfer mechanism for PV drivers. They are also used for
inter-processor interrupts. Guests with a large number of vcpus and/or
many PV devices many need to increase the maximum default value of 1023.
For this reason the native Xen config format supports the
'max_event_channels' setting. See xl.cfg(5) man page for more details.

Similar to the existing maxGrantFrames option, add a new xenbus controller
option 'maxEventChannels', allowing to adjust the maximum value via libvirt.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agogitdm: Add missing entries
Andrea Bolognani [Wed, 1 Apr 2020 10:14:58 +0000 (12:14 +0200)]
gitdm: Add missing entries

One new company has contributed to libvirt since the last time
the gitdm configuration was updated.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: add link to bug tracker against each download
Daniel P. Berrangé [Thu, 9 Apr 2020 13:51:59 +0000 (14:51 +0100)]
docs: add link to bug tracker against each download

Help people to see where to report bugs when they download a libvirt
release.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: update for rename of libvirt-jenkins.ci repository
Daniel P. Berrangé [Thu, 9 Apr 2020 13:47:51 +0000 (14:47 +0100)]
docs: update for rename of libvirt-jenkins.ci repository

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>