]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agovirpcimock: Mock the SRIOV Virtual functions
Shivaprasad G Bhat [Thu, 29 Aug 2019 19:18:59 +0000 (16:18 -0300)]
virpcimock: Mock the SRIOV Virtual functions

The softlink to physfn is the way to know if the device is
VF or not. So, the patch softlinks 'physfn' to the parent function.
The multifunction PCI devices dont have 'physfn' softlinks.

The patch adds few Virtual functions to the mock environment and
changes the existing VFIO test xmls using the VFs to use the newly
added VFs for their use case.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirpcimock.c: mock /dev/vfio
Daniel Henrique Barboza [Thu, 29 Aug 2019 19:18:58 +0000 (16:18 -0300)]
virpcimock.c: mock /dev/vfio

This patch adds mock of the /dev/vfio path, needed for proper
implementation of the support for multifunction/multiple devices
per iommu groups.

To do that, the existing bind and unbind operations were adapted
to operate with the mocked filesystem as well.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Adjust max memlock on mdev hotplug
Eric Farman [Tue, 3 Sep 2019 20:09:48 +0000 (22:09 +0200)]
qemu: Adjust max memlock on mdev hotplug

When starting a domain, we use the presence of a vfio-pci or
mdev hostdev to determine if the memlock maximum needs to be
increased.  But if we hotplug either of these devices, only the
vfio-pci path gets that love.  This means that attaching a, say,
vfio-ccw device will appear to succeed but the device may be
unusable as the guest may see I/O errors on long CCW chains.
The host, meanwhile, would be flooded with these messages:

  vfio_pin_page_external: Task qemu-system-s39 (11584) RLIMIT_MEMLOCK (65536) exceeded

Let's adjust the maximum memlock value in the mdev hotplug path,
so that the domain has the same value as if it were started with
one or more mdev devices in its configuration.

Signed-off-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agoqemu: Reset the maximum locked memory on hotplug fail
Eric Farman [Tue, 3 Sep 2019 20:09:47 +0000 (22:09 +0200)]
qemu: Reset the maximum locked memory on hotplug fail

If attaching a PCI hostdev fails, there are several things that
need to be un-done as part of the cleanup.  One thing that is
not done is re-calculating/re-setting the maximum amount of locked
memory for the domain, since we may have changed that.

Let's fix that, just to ensure everything is back the way it was.

Signed-off-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agoqemu: Refactor the max memlock routine
Eric Farman [Tue, 3 Sep 2019 20:09:46 +0000 (22:09 +0200)]
qemu: Refactor the max memlock routine

Let's pull this hunk out into a function, so it can be reused
in another codepath that needs to do the same thing.

Signed-off-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agovirhostdev: Don't unref @pcidevs twice
Michal Privoznik [Mon, 9 Sep 2019 14:20:07 +0000 (16:20 +0200)]
virhostdev: Don't unref @pcidevs twice

In f08e6883cb4 I've made @pcidevs in
virHostdevReAttachPCIDevices() to be automatically unrefed using
VIR_AUTOUNREF() but I forgot to remove the line that explicitly
unrefs the object at the end of the function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: remove devhelp API docs
Daniel P. Berrangé [Thu, 5 Sep 2019 12:07:59 +0000 (13:07 +0100)]
docs: remove devhelp API docs

We currently generate two completely separate API references for the
libvirt public API. One at 'docs/html/' and one at 'docs/devhelp/'.
Both are published on the website, but we only link to content in
the 'docs/html/' pages.

Both are installed in the libvirt-docs sub-RPM, with a full copy
of the website including 'docs/html/' in /usr/share/docs/libvirt-docs,
while the 'docs/devhelp/' content goes to /usr/share/gtk-doc/. The
latter was broken for years until:

  commit ca6f602546cb28658db05f29bc840e04d22d0947
  Author: Andrea Bolognani <abologna@redhat.com>
  Date:   Fri May 10 14:54:52 2019 +0200

    docs: Introduce $(devhelphtml_generated)

    Our XSLT magic generates one Devhelp-compatible HTML file
    per documentation module, but so far we have only shipped
    and installed documentation for virterror.

    Now that we have $(modules), however, we can generate the
    list of files the same way we do for regular documentation
    and make sure we always ship and install everything.

That this bug went unnoticed for so long is a sign of how few
people are using the devhelp docs. The only commits to the devhelp
code since it was first introduced have been fixing various build
problems that hit.

The only obvious difference between the two sets of docs is the CSS
styling in use. Overall devhelp does not look compelling enough to
justify having two duplicated sets of API docs. Eliminating it will
reduce the amount of XSL code we are carrying in the tree which is
an attractive benefit.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu_conf.c: introduce qemuAddRemoveSharedDeviceInternal
Daniel Henrique Barboza [Tue, 3 Sep 2019 23:06:07 +0000 (20:06 -0300)]
qemu_conf.c: introduce qemuAddRemoveSharedDeviceInternal

After the previous commits, qemuAddSharedDevice() and
qemuRemoveSharedDevice() are now the same code with a different
flag to call the internal functions.

This patch aggregates the common code into a new function called
qemuAddRemoveSharedDeviceInternal() to further reduce
code repetition. Both qemuAddSharedDevice() and
qemuRemoveSharedDevice() are kept since they are public
functions used elsewhere.

No functional change was made.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agoqemu_conf.c: introduce qemuAddRemoveSharedDiskInternal
Daniel Henrique Barboza [Tue, 3 Sep 2019 23:06:06 +0000 (20:06 -0300)]
qemu_conf.c: introduce qemuAddRemoveSharedDiskInternal

Following the same idea of avoid code repetition from the
previous patch, this commit introduces a new function that
aggregates the functions of qemuAddSharedDisk() and
qemuRemoveSharedDisk() into a single place, using a flag to
switch between add/remove operations.

Both qemuAddSharedDisk() and qemuRemoveSharedDisk() are
public, so keep them around to avoid changing other files
due to an internal qemu_conf.c refactory.

No functional change was made.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agoqemu_conf.c: introduce qemuAddRemoveSharedHostdevInternal
Daniel Henrique Barboza [Tue, 3 Sep 2019 23:06:05 +0000 (20:06 -0300)]
qemu_conf.c: introduce qemuAddRemoveSharedHostdevInternal

qemuAddSharedHostdev() has a code similar to
qemuRemoveSharedHostdev(), with exception of one line that
defines the operation (add or remove).

This patch introduces a new function that aggregates the common
code, using a flag to switch between the operations, avoiding
code repetition.

No functional change was made.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agoqemu: update threading info about domain object refs
Jonathon Jongsma [Wed, 4 Sep 2019 17:23:30 +0000 (12:23 -0500)]
qemu: update threading info about domain object refs

Since commit fd9ef3b31e, virDomainFindByUUIDRef() no longer exists and
all virDomainObjListFindBy*() functions now increment the reference
count.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agoremote: fix UNIX socket path being incorrectly built for libvirtd
eater [Fri, 6 Sep 2019 21:36:17 +0000 (23:36 +0200)]
remote: fix UNIX socket path being incorrectly built for libvirtd

As a result of changes in

      commit d5f0c1b6dd51f0fbab2f8a25733c55d8be6b937b
      Author: Daniel P. Berrangé <berrange@redhat.com>
      Date:   Thu Jul 18 12:30:22 2019 +0100

        remote: stop trying to print help as giant blocks of text

The socket path built would be libvirt//var/run/libvirt-sock
instead of /var/run/libvirt/libvirt-sock. Fortunately this only
affects users who have set the 'unix_sock_dir' config parameter
in /etc/libvirt/libvirtd.conf, which is pretty rare/unusual.

Signed-off-by: eater <=@eater.me>
Exception made for the psuedonym above since patch is considered
trivial & thus non-copyrightable material.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolib: Grab write lock when modifying list of domains
Michal Privoznik [Fri, 6 Sep 2019 11:59:59 +0000 (13:59 +0200)]
lib: Grab write lock when modifying list of domains

In some places where virDomainObjListForEach() is called the
passed callback calls virDomainObjListRemoveLocked(). Well, this
is unsafe, because the former only grabs a read lock but the
latter modifies the list.
I've identified the following unsafe calls:

- qemuProcessReconnectAll()
- libxlReconnectDomains()

The rest seem to be safe.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirdomainobjlist: Document virDomainObjListForEach()
Michal Privoznik [Fri, 6 Sep 2019 11:50:39 +0000 (13:50 +0200)]
virdomainobjlist: Document virDomainObjListForEach()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirsh: Fix help for net-port-delete
Jonathon Jongsma [Tue, 3 Sep 2019 16:47:29 +0000 (11:47 -0500)]
virsh: Fix help for net-port-delete

Apparently a copy/paste error. The net-port-delete help string was in
fact from net-port-dumpxml.

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

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agoqemu_slirp: Drop unused variable in qemuSlirpStart()
Michal Privoznik [Fri, 6 Sep 2019 12:14:21 +0000 (14:14 +0200)]
qemu_slirp: Drop unused variable in qemuSlirpStart()

The @cmdstr variable is not used really.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolibxl: Fix libxlDomainPMSuspendForDuration domain active check
Marek Marczykowski-Górecki [Fri, 6 Sep 2019 14:12:55 +0000 (16:12 +0200)]
libxl: Fix libxlDomainPMSuspendForDuration domain active check

virDomainObjCheckActive() returns -1 if domain is not active, not 0.

Fixes cb50436c6f "libxl: implement virDomainPM* functions"
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
5 years agoutil: Set backing file name for LOOP_GET_STATUS64 queries.
Julio Faracco [Mon, 2 Sep 2019 17:00:27 +0000 (14:00 -0300)]
util: Set backing file name for LOOP_GET_STATUS64 queries.

This is an issue for LXC loop devices when you are trying to get loop
devices info using `ioctl`. Modern apps uses `/sys/dev/block` to grab
information about devices, but if you use the method mention you won't
be able to retrive the associated file with that loop device. See
example below from cryptsetup sources:

    static char *_ioctl_backing_file(const char *loop)
    {
        struct loop_info64 lo64 = {0};
        int loop_fd;

        loop_fd = open(loop, O_RDONLY);
        if (loop_fd < 0)
            return NULL;

        if (ioctl(loop_fd, LOOP_GET_STATUS64, &lo64) < 0) {
            close(loop_fd);
            return NULL;
        }

        lo64.lo_file_name[LO_NAME_SIZE-2] = '*';
        lo64.lo_file_name[LO_NAME_SIZE-1] = 0;

        close(loop_fd);
        return strdup((char*)lo64.lo_file_name);
    }

It will return an empty string because lo_file_name was not set.
Function `virFileLoopDeviceOpenSearch()` is using `ioctl` to query data,
but it is not checking `lo_file_name` field.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
5 years agotests: add slirp-helper qemuxml2argv test
Marc-André Lureau [Thu, 8 Aug 2019 14:55:14 +0000 (18:55 +0400)]
tests: add slirp-helper qemuxml2argv test

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 agoqemu-hotplug: handle hotplugging of slirp-helper
Marc-André Lureau [Thu, 8 Aug 2019 14:55:13 +0000 (18:55 +0400)]
qemu-hotplug: handle hotplugging of slirp-helper

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 agoqemu-process: prepare slirp-helper
Marc-André Lureau [Thu, 8 Aug 2019 14:55:12 +0000 (18:55 +0400)]
qemu-process: prepare slirp-helper

When the network interface is of "user" type, and QEMU has the "-net
socket,fd=" datagram support, call qemuInterfacePrepareSlirp() to
probe and associate a slirp-helper with the interface.

The usage of automated slirp-helper can be prevented with
disableSlirp (in particular when resuming a
VM that didn't start with slirp-helper before).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu-command: use -net socket, fd= with slirp-helper
Marc-André Lureau [Thu, 8 Aug 2019 14:55:11 +0000 (18:55 +0400)]
qemu-command: use -net socket, fd= with slirp-helper

If a slirp-helper is associated with a network interface (after
probing & preparing succesfully), pass the socket fd to QEMU and use
"-net socket,fd=".

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 agoqemu-extdevice: prepare, start and stop slirp-helper
Marc-André Lureau [Thu, 8 Aug 2019 14:55:10 +0000 (18:55 +0400)]
qemu-extdevice: prepare, start and stop slirp-helper

If a slirp-helper is associated with a network interface,
prepare/start/stop the process via qemu-extdevice.

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 agoqemu-migration: prevent migration if slirp cannot be migrated
Marc-André Lureau [Thu, 8 Aug 2019 14:55:09 +0000 (18:55 +0400)]
qemu-migration: prevent migration if slirp cannot be migrated

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu-migration: prevent migration if dbus-vmstate is required
Marc-André Lureau [Thu, 8 Aug 2019 14:55:08 +0000 (18:55 +0400)]
qemu-migration: prevent migration if dbus-vmstate is required

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: add a flag to the cookie to prevent slirp-helper setup
Marc-André Lureau [Thu, 8 Aug 2019 14:55:07 +0000 (18:55 +0400)]
qemu: add a flag to the cookie to prevent slirp-helper setup

For VM started and migrated/saved without slirp-helpers, let's prevent
the automatic setup (as it would fail to migrate otherwise).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu-domain: save and restore slirp state
Marc-André Lureau [Thu, 8 Aug 2019 14:55:06 +0000 (18:55 +0400)]
qemu-domain: save and restore slirp state

Save & restore the slirp helper PID associated with a network
interface & the probed features.

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 agoqemu: add slirp helper unit
Marc-André Lureau [Thu, 8 Aug 2019 14:55:05 +0000 (18:55 +0400)]
qemu: add slirp helper unit

The unit provides the functions associated with a slirp-helper:
- probing / checking capabilities
- opening the socketpair
- starting / stoping the helper
- registering for dbus-vmstate migration

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 agoqemu-conf: add slirp state dir
Marc-André Lureau [Thu, 8 Aug 2019 14:55:04 +0000 (18:55 +0400)]
qemu-conf: add slirp state dir

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 agoqemu-conf: add configurable slirp-helper location
Marc-André Lureau [Thu, 8 Aug 2019 14:55:03 +0000 (18:55 +0400)]
qemu-conf: add configurable slirp-helper location

A slirp helper is a process that provides user-mode networking through
a unix domain socket. It is expected to follow the following
specification:
https://gitlab.freedesktop.org/slirp/libslirp-rs/blob/master/src/bin/README.rst

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: add qemuDomainNetworkPrivate
Marc-André Lureau [Thu, 8 Aug 2019 14:55:02 +0000 (18:55 +0400)]
qemu: add qemuDomainNetworkPrivate

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 agodomain-conf: add network def private data
Marc-André Lureau [Thu, 8 Aug 2019 14:55:01 +0000 (18:55 +0400)]
domain-conf: add network def private data

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 agoqemu: add dbus-vmstate
Marc-André Lureau [Thu, 8 Aug 2019 14:55:00 +0000 (18:55 +0400)]
qemu: add dbus-vmstate

Add dbusVMStates to keep a list of dbus-vmstate objects needed for
migration. They are populated on the command line during start or
qemuDBusVMStateAdd/Remove() will hotplug them as needed.

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 agoqemu-security: add qemuSecurityCommandRun()
Marc-André Lureau [Thu, 8 Aug 2019 14:54:59 +0000 (18:54 +0400)]
qemu-security: add qemuSecurityCommandRun()

Add a generic way to run a command through the security management.

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 agoqemu: reset VM id after external devices stop
Marc-André Lureau [Thu, 8 Aug 2019 14:54:58 +0000 (18:54 +0400)]
qemu: reset VM id after external devices stop

pid filenames (from swtpm and other helpers from this series) are
based on VM shortname, which is derived from VM id. If the id is reset
to early, the state filenames will not be found.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: add dbus-vmstate capability
Marc-André Lureau [Thu, 8 Aug 2019 14:54:57 +0000 (18:54 +0400)]
qemu: add dbus-vmstate capability

This object is being proposed to qemu upstream "Add dbus-vmstate
object". It handles data migration of external processes.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: add socket datagram capability
Marc-André Lureau [Thu, 8 Aug 2019 14:54:56 +0000 (18:54 +0400)]
qemu: add socket datagram capability

Datagram socket is available since qemu 4.0, commit
fdec16e3c2a614e2861f3086b05d444b5d8c3406 ("net/socket: learn to talk
with a unix dgram socket").

Required for slirp-helper communication.

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 agoqemu: replace logCtxt with qemuDomainLogAppendMessage()
Marc-André Lureau [Thu, 8 Aug 2019 14:54:55 +0000 (18:54 +0400)]
qemu: replace logCtxt with qemuDomainLogAppendMessage()

Once QEMU is started, the qemuDomainLogContext is owned by it, and can
no longer be used from libvirt. Instead, use
qemuDomainLogAppendMessage() which will redirect the log.

This is not strictly necessary for swtpm, but the following patches
are going to reuse qemuExtDeviceLogCommand().

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 agodbus: correctly build reply message
Marc-André Lureau [Thu, 8 Aug 2019 14:54:54 +0000 (18:54 +0400)]
dbus: correctly build reply message

dbus_message_new() does not construct correct replies by itself, it is
recommended to use dbus_message_new_method_return() instead.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: fix xml2xml tpm-emulator.xml test
Marc-André Lureau [Thu, 8 Aug 2019 14:54:53 +0000 (18:54 +0400)]
tests: fix xml2xml tpm-emulator.xml test

It is failing, because it ends up being parsed with version='default'
and expects '1.2' instead.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoAdd .editorconfig
Marc-André Lureau [Thu, 8 Aug 2019 14:54:52 +0000 (18:54 +0400)]
Add .editorconfig

Consistent code style across editors.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: qapi: Limit traversal depth for QAPI schema queries
Peter Krempa [Mon, 12 Aug 2019 16:31:44 +0000 (18:31 +0200)]
qemu: qapi: Limit traversal depth for QAPI schema queries

Implicitly the query depth is limited by the length of the QAPI schema
query, but 'alternate' and 'array' QAPI meta-types don't consume a part
of the query string thus a loop on such types would get our traversal
code stuck in an infinite loop. Prevent this from happening by limiting
the nesting depth to 1000.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: maintain user alias for video type 'none'
Jonathon Jongsma [Thu, 5 Sep 2019 16:17:38 +0000 (11:17 -0500)]
qemu: maintain user alias for video type 'none'

After parsing a video device with a model type of
VIR_DOMAIN_VIDEO_TYPE_NONE, all device info is cleared (see
virDomainDefPostParseVideo()) in order to avoid formatting any
auto-generated values for the XML. Subsequently, however, an alias is
generated for the video device (e.g. 'video0'), which results in an
alias property being formatted in the XML output anyway. This creates
confusion if the user has explicitly provided an alias for the video
device since the alias will change.

To avoid this, don't clear the user-defined alias for video devices of
type "none".

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

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovircgroupv2: fix setting cpu.max period
Pavel Hrdina [Thu, 5 Sep 2019 09:22:11 +0000 (11:22 +0200)]
vircgroupv2: fix setting cpu.max period

When we set cpu.max period we need to parse the cpu.max file first as
it contains both quota and period values separated by space.  When only
a single number is written to that file it will set quota.  However,
in order to change period we need to write both values.

The code was prepared for that but mistakenly used new line to end the
string with the first value.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoqemu: migration: Switch to blockdev mode for non-shared storage migration
Peter Krempa [Wed, 4 Sep 2019 11:20:41 +0000 (13:20 +0200)]
qemu: migration: Switch to blockdev mode for non-shared storage migration

When blockdev is used we always should use the blockdev mode for
non-shared storage migration.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: migration: Refactor cleanup in qemuMigrationSrcNBDStorageCopy
Peter Krempa [Wed, 4 Sep 2019 10:23:16 +0000 (12:23 +0200)]
qemu: migration: Refactor cleanup in qemuMigrationSrcNBDStorageCopy

Use VIR_AUTOUNREF and remove the cleanup label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: migration: Refactor cleanup in qemuMigrationSrcNBDStorageCopyDriveMirror
Peter Krempa [Wed, 4 Sep 2019 10:23:16 +0000 (12:23 +0200)]
qemu: migration: Refactor cleanup in qemuMigrationSrcNBDStorageCopyDriveMirror

Use VIR_AUTOFREE and remove the cleanup label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: migration: Refactor cleanup in qemuMigrationSrcNBDStorageCopyBlockdev
Peter Krempa [Wed, 4 Sep 2019 10:23:16 +0000 (12:23 +0200)]
qemu: migration: Refactor cleanup in qemuMigrationSrcNBDStorageCopyBlockdev

Remove the cleanup label as it's empty.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: Defer support checks for external active snapshots to blockdev code or qemu
Peter Krempa [Tue, 13 Aug 2019 11:37:17 +0000 (13:37 +0200)]
qemu: Defer support checks for external active snapshots to blockdev code or qemu

Remove libvirt's support check for the target of an external snapshot to
the blockdev code or qemu. This will potentially require a more complex
cleanup but removes a level of hardcoded feature checks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Add -blockdev support for external snapshots
Peter Krempa [Mon, 17 Dec 2018 17:31:29 +0000 (18:31 +0100)]
qemu: Add -blockdev support for external snapshots

Use the code for creating or attaching new storage source in the
snapshot code and switch to 'blockdev-snapshot' for creating the
snapshot itself.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: snapshot: Skip overlay file creation/interogation if unsupported
Peter Krempa [Tue, 13 Aug 2019 10:23:00 +0000 (12:23 +0200)]
qemu: snapshot: Skip overlay file creation/interogation if unsupported

With blockdev we'll be able to support protocols which are not supported
by the storage backends in libvirt. This means that we have to be able
to skip the creation and relative storage path reading if it's not
supported. This will make it impossible to use relative backing for
network protocols but that would be almost insane anyways.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Merge use of 'reuse' flag in qemuDomainSnapshotDiskPrepareOne
Peter Krempa [Tue, 13 Aug 2019 10:28:00 +0000 (12:28 +0200)]
qemu: Merge use of 'reuse' flag in qemuDomainSnapshotDiskPrepareOne

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Disband qemuDomainSnapshotCreateSingleDiskActive
Peter Krempa [Mon, 12 Aug 2019 13:11:36 +0000 (15:11 +0200)]
qemu: Disband qemuDomainSnapshotCreateSingleDiskActive

After we always assume support for the 'transaction' command
(c358adc57113b) and follow-up cleanups
qemuDomainSnapshotCreateSingleDiskActive lost its value. Move the code
into appropriate helpers and remove the function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: snapshot: Rename external disk snapshot handling functions
Peter Krempa [Wed, 28 Aug 2019 15:20:36 +0000 (17:20 +0200)]
qemu: snapshot: Rename external disk snapshot handling functions

Fix and unify the naming of external snapshot preparation functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: snapshot: Move error preservation to qemuDomainSnapshotDiskDataCleanup
Peter Krempa [Wed, 28 Aug 2019 07:33:27 +0000 (09:33 +0200)]
qemu: snapshot: Move error preservation to qemuDomainSnapshotDiskDataCleanup

Make qemuDomainSnapshotDiskDataCleanup cleanup section friendly by
moving the error preservation code inside it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: snapshot: Save status and config XMLs only on success
Peter Krempa [Wed, 28 Aug 2019 07:31:28 +0000 (09:31 +0200)]
qemu: snapshot: Save status and config XMLs only on success

We changed to always saving the status and config XMLs to simplify
code. After a few more refactors it's now possible to move it to the
appropriate place and save the XMLs only on success again.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: snapshot: Fix image lock handling when taking a snapshot
Peter Krempa [Wed, 28 Aug 2019 07:30:33 +0000 (09:30 +0200)]
qemu: snapshot: Fix image lock handling when taking a snapshot

When we take a snapshot we must properly remove our locking
infrastructure locks. This was broken by commit 3817fa10c4ad9 which
attempted to properly track the readonly state for the image as the
locking code was executed after this change. Since we forced the image
which was locked as read-write to read-only prior to unlocking it the
write lock was not dropped.

Fix it by moving the locking code prior to modifying the readonly flag.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Fix shallow non-reuse block copy
Peter Krempa [Tue, 3 Sep 2019 12:26:20 +0000 (14:26 +0200)]
qemu: driver: Fix shallow non-reuse block copy

The code preparing data for creating/attaching the target image of block
copy didn't use the correct reference to the existing backing chain in
case when the copy should inherit it. This meant that qemu actually
opened a second copy of the chain and operated on that.

This would de-sync qemu from libvirt's view of node names. Luckily this
is only hypothetical at this point since it happens only when -blockdev
is enabled.

Fix it by passing 'mirrorBacking' which has the proper data as the
backing store when calling
qemuBuildStorageSourceChainAttachPrepareBlockdevTop.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Explicitly pass backing store to qemuBuildStorageSourceChainAttachPrepareBlockd...
Peter Krempa [Tue, 3 Sep 2019 12:22:41 +0000 (14:22 +0200)]
qemu: Explicitly pass backing store to qemuBuildStorageSourceChainAttachPrepareBlockdevTop

In some cases we'll need to pass in a backing store which is not
recorded as the backing store of @src. Export backingStore as variable
and fix all callers to pass in the backing store. No semantic changes
for now.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: block: explicitly pass backing store to qemuBlockStorageSourceAttachPrepareBlockdev
Peter Krempa [Tue, 3 Sep 2019 11:58:34 +0000 (13:58 +0200)]
qemu: block: explicitly pass backing store to qemuBlockStorageSourceAttachPrepareBlockdev

Pass backing store as an argument rather than extracting it locally and
fix the callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: command: Refactor qemuBuildStorageSourceChainAttachPrepareBlockdevInternal
Peter Krempa [Tue, 3 Sep 2019 11:43:57 +0000 (13:43 +0200)]
qemu: command: Refactor qemuBuildStorageSourceChainAttachPrepareBlockdevInternal

Extract the loop and supporting infrastructure to the caller as only one
of the two callers actually cares about looping and rename the helper to
qemuBuildStorageSourceChainAttachPrepareBlockdevOne.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: block: Explicitly specify backingStore when creating format layer props
Peter Krempa [Tue, 3 Sep 2019 11:27:52 +0000 (13:27 +0200)]
qemu: block: Explicitly specify backingStore when creating format layer props

Pass in backing store explicitly to qemuBlockStorageSourceGetBlockdevProps
and fix the callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: block: Unify conditions to format backing store of format node definition
Peter Krempa [Tue, 3 Sep 2019 11:16:39 +0000 (13:16 +0200)]
qemu: block: Unify conditions to format backing store of format node definition

Move all bits of the formatting of the 'backing' attribute to a single
condition and make it use a single extracted copy of the backing store.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Prevent storage causing too much nested XML
Peter Krempa [Wed, 4 Sep 2019 14:58:08 +0000 (16:58 +0200)]
qemu: Prevent storage causing too much nested XML

Since libvirt stores the backing chain into the XML in a nested way it
is the prime possibility to hit libxml2's parsing limit of 256 layers.

Introduce code which will crawl the backing chain and verify that it's
not too deep. The maximum nesting is set to 200 layers so that there's
still some space left for additional properties or nesting into snapshot
XMLs.

The check is applied to all disk use cases (starting, hotplug, media
change) as well as block copy which changes image and snapshots.

We simply report an error and refuse the operation.

Without this check a restart of libvirtd would result in the status XML
failing to be parsed and thus losing the VM.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: domain: Refactor cleanup in qemuDomainDetermineDiskChain
Peter Krempa [Wed, 4 Sep 2019 13:18:37 +0000 (15:18 +0200)]
qemu: domain: Refactor cleanup in qemuDomainDetermineDiskChain

Use VIR_AUTOUNREF and get rid of the cleanup label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: hotplug: Setup disk throttling with blockdev
Peter Krempa [Thu, 5 Sep 2019 13:09:50 +0000 (15:09 +0200)]
qemu: hotplug: Setup disk throttling with blockdev

With blockdev we must issue the block_set_io_throttle QMP command to
setup disk throttling as we currently can't do it with the 'throttle'
layer.

Unfortunately there's nothing we can do if it fails.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: hotplug: Use VIR_AUTOFREE in qemuDomainAttachDiskGeneric
Peter Krempa [Thu, 5 Sep 2019 12:48:20 +0000 (14:48 +0200)]
qemu: hotplug: Use VIR_AUTOFREE in qemuDomainAttachDiskGeneric

Get rid of the last manually freed var.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: hotplug: Simplify cleanup in qemuDomainChangeMediaLegacy
Peter Krempa [Thu, 5 Sep 2019 12:47:10 +0000 (14:47 +0200)]
qemu: hotplug: Simplify cleanup in qemuDomainChangeMediaLegacy

Switch to using VIR_AUTOFREE and remove the cleanup label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Fix qemuDomainObjTaint with virtlogd
Jiri Denemark [Thu, 5 Sep 2019 13:35:35 +0000 (15:35 +0200)]
qemu: Fix qemuDomainObjTaint with virtlogd

When virtlogd is used to capture QEMU's stdout, qemuDomainObjTaint would
always fail to write the message to the log file when QEMU is already
running (i.e., outside qemuProcessLaunch). This can happen during device
hotplug or by sending a custom QEMU guest agent command:

    warning : qemuDomainObjTaint:8757 : Domain id=9 name='blaf'
        uuid=9cfa4e37-2930-405b-bcb4-faac1829dad8 is tainted:
        custom-ga-command
    error : virLogHandlerDomainOpenLogFile:388 : Cannot open log file:
        '/var/log/libvirt/qemu/blaf.log': Device or resource busy
    error : virNetClientProgramDispatchError:172 : Cannot open log file:
        '/var/log/libvirt/qemu/blaf.log': Device or resource busy

The fix is easy, we just need to use the right API for appending a
message to QEMU log file instead of creating a new log context.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: domain: Fix tpm <encryption> comment
Cole Robinson [Wed, 4 Sep 2019 17:32:31 +0000 (13:32 -0400)]
conf: domain: Fix tpm <encryption> comment

The attribute is named 'secret', not 'uuid'

Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agonews: rewording wrt NSS, virt-login-shell & split daemons
Daniel P. Berrangé [Tue, 3 Sep 2019 15:12:03 +0000 (16:12 +0100)]
news: rewording wrt NSS, virt-login-shell & split daemons

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: monitor: Fix formatting of 'offset' in qemuMonitorJSONSaveMemory
Peter Krempa [Fri, 30 Aug 2019 14:37:46 +0000 (16:37 +0200)]
qemu: monitor: Fix formatting of 'offset' in qemuMonitorJSONSaveMemory

The offset is unsigned long long thus 'U' must be used.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemublock: Use bigger numbers as dummy capacity/physical
Peter Krempa [Fri, 30 Aug 2019 14:36:15 +0000 (16:36 +0200)]
tests: qemublock: Use bigger numbers as dummy capacity/physical

Actually test that the full range is available.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: block: Use correct type when creating image size JSON entries
Peter Krempa [Fri, 30 Aug 2019 14:33:48 +0000 (16:33 +0200)]
qemu: block: Use correct type when creating image size JSON entries

The 'u' modifier creates an unsigned int JSON attribute but the disk size
and capacity fields are unsigned long long. If the size of the created
image would be more than 4GiB we'd overflow and create sub-4G image.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agonews: Mention removal of xenapi driver
Jim Fehlig [Tue, 3 Sep 2019 04:46:00 +0000 (22:46 -0600)]
news: Mention removal of xenapi driver

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoxenapi: remove driver
Jim Fehlig [Tue, 3 Sep 2019 04:24:00 +0000 (22:24 -0600)]
xenapi: remove driver

The xenapi driver has not seen any development since its initial
contribution 9 years ago. There have been no bug reports, no patches,
and no queries about the driver on the developer or user mailing lists.
Remove the driver from the libvirt sources.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agomaint: Post-release version bump to 5.8.0
Jim Fehlig [Tue, 3 Sep 2019 21:19:22 +0000 (15:19 -0600)]
maint: Post-release version bump to 5.8.0

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
5 years agoRelease of libvirt 5.7.0
Daniel Veillard [Tue, 3 Sep 2019 15:19:02 +0000 (17:19 +0200)]
Release of libvirt 5.7.0

* docs/news.xml: updated for release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
5 years agonews: document new libxml version requirement
Daniel P. Berrangé [Tue, 3 Sep 2019 12:24:27 +0000 (13:24 +0100)]
news: document new libxml version requirement

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: domain: Fix potential NULL deref when parsing job private data
Peter Krempa [Mon, 2 Sep 2019 14:11:46 +0000 (16:11 +0200)]
qemu: domain: Fix potential NULL deref when parsing job private data

A specially crafted XML which would reference a non-existing disk but
request the mirror to be registered with the blockjob could potentially
make the parser dereference NULL. Fix it by moving the code slightly and
just treat it as a wrong job XML. Found by Coverity.

Reported-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
5 years agonews: Update for 5.7.0 release
Michal Privoznik [Tue, 3 Sep 2019 12:09:06 +0000 (14:09 +0200)]
news: Update for 5.7.0 release

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agonews: Rename --precopy-bandwidth migration option
Jiri Denemark [Mon, 2 Sep 2019 15:00:32 +0000 (17:00 +0200)]
news: Rename --precopy-bandwidth migration option

The (pre-copy) bandwidth was historically the only bandwidth we
supported and thus it is called just "bandwidth" in all other places.
E.g., virsh migrate-setspeed or in the migration typed parameter name.
Let's make the new option for virsh migrate consistent.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirsh: Rename --precopy-bandwidth migration option
Jiri Denemark [Mon, 2 Sep 2019 15:00:32 +0000 (17:00 +0200)]
virsh: Rename --precopy-bandwidth migration option

The (pre-copy) bandwidth was historically the only bandwidth we
supported and thus it is called just "bandwidth" in all other places.
E.g., virsh migrate-setspeed or in the migration typed parameter name.
Let's make the new option for virsh migrate consistent.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu_blockjob: Remove secdriver metadata more frequently
Michal Privoznik [Fri, 30 Aug 2019 12:34:12 +0000 (14:34 +0200)]
qemu_blockjob: Remove secdriver metadata more frequently

If a block job reaches failed/cancelled state, or is completed
without pivot then we must remove security driver metadata
associated to the backing chain so that we don't leave any
metadata behind.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu_blockjob: Print image path on failed security metadata move too
Michal Privoznik [Fri, 30 Aug 2019 13:07:48 +0000 (15:07 +0200)]
qemu_blockjob: Print image path on failed security metadata move too

When a block job is completed, the security image metadata are
moved to the new image. If this fails an warning is printed, but
the message contains only domain name and lacks image paths. Put
them both into the warning message.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu_blockjob: Move active commit failed state handling into a function
Michal Privoznik [Fri, 30 Aug 2019 12:21:24 +0000 (14:21 +0200)]
qemu_blockjob: Move active commit failed state handling into a function

Currently, there are only a few lines of code so a separate
function was not necessary, but this will change. So instead of
putting all the new code under 'case
QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT' create a separate function.
Just like every other case has one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoselinux: Do not report an error when not returning -1
Martin Kletzander [Thu, 29 Aug 2019 15:32:03 +0000 (17:32 +0200)]
selinux: Do not report an error when not returning -1

I guess the reason for that was the automatic interpretation/stringification of
setfilecon_errno, but the code was not nice to read and it was a bit confusing.
Also, the logs and error states get cleaner this way.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
5 years agoqemu: Validate arg in qemuAgentErrorComandUnsupported()
Jonathon Jongsma [Fri, 30 Aug 2019 16:09:09 +0000 (11:09 -0500)]
qemu: Validate arg in qemuAgentErrorComandUnsupported()

Coverity noted that 'reply' can be NULL after calling
qemuAgentCommand().  Avoid dereferencing reply in
qemuAgentErrorComandUnsupported() in that case.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agovircgroupv2: fix abort in VIR_AUTOFREE
Pavel Hrdina [Fri, 30 Aug 2019 14:15:15 +0000 (16:15 +0200)]
vircgroupv2: fix abort in VIR_AUTOFREE

Introduced by commit <c854e0bd33c7a5afb04a36465bf04f861b2efef5> that
tried to fix an issue where we would fail to parse values from files.

We cannot change the original pointer that is going to be used by
VIR_AUTOFREE.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu_conf.c: removing unused virQEMUDriverConfigPtr variable
Daniel Henrique Barboza [Fri, 30 Aug 2019 10:03:55 +0000 (07:03 -0300)]
qemu_conf.c: removing unused virQEMUDriverConfigPtr variable

'virQEMUDriverConfigPtr cfg' is declared, initiated, but never
used in virQEMUDriverCreateCapabilities().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Christophe de Dinechin <dinechin@redhat.com>
5 years agosecurity_selinux: Play nicely with network FS that only emulates SELinux
Michal Privoznik [Thu, 22 Aug 2019 14:34:02 +0000 (16:34 +0200)]
security_selinux: Play nicely with network FS that only emulates SELinux

There are some network file systems that do support XATTRs (e.g.
gluster via FUSE). And they appear to support SELinux too.
However, not really. Problem is, that it is impossible to change
SELinux label of a file stored there, and yet we claim success
(rightfully - hypervisor succeeds in opening the file). But this
creates a problem for us - from XATTR bookkeeping POV, we haven't
changed the label and thus if we remembered any label, we must
roll back and remove it.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
5 years agosecurity_selinux: Drop virSecuritySELinuxSetFileconHelper
Michal Privoznik [Thu, 22 Aug 2019 08:25:24 +0000 (10:25 +0200)]
security_selinux: Drop virSecuritySELinuxSetFileconHelper

This function is no longer needed because after previous commits
it's just an alias to virSecuritySELinuxSetFilecon.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
5 years agosecurity_selinux: Drop @optional from _virSecuritySELinuxContextItem
Michal Privoznik [Thu, 22 Aug 2019 08:21:11 +0000 (10:21 +0200)]
security_selinux: Drop @optional from _virSecuritySELinuxContextItem

Now, that we don't need to remember if setting context is
'optional' (the argument only made
virSecuritySELinuxSetFileconImpl() return a different success
code), we can drop it from the _virSecuritySELinuxContextItem
structure as we don't need to remember it in transactions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
5 years agosecurity_selinux: Drop virSecuritySELinuxSetFileconOptional()
Michal Privoznik [Thu, 22 Aug 2019 08:14:05 +0000 (10:14 +0200)]
security_selinux: Drop virSecuritySELinuxSetFileconOptional()

There is no real difference between
virSecuritySELinuxSetFilecon() and
virSecuritySELinuxSetFileconOptional(). Drop the latter in favour
of the former.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
5 years agovirSecuritySELinuxSetFileconImpl: Drop @optional argument
Michal Privoznik [Wed, 21 Aug 2019 15:50:55 +0000 (17:50 +0200)]
virSecuritySELinuxSetFileconImpl: Drop @optional argument

The only thing that the @optional argument does is that it makes
the function return 1 instead of 0 if setting SELinux context
failed in a non-critical fashion. Drop the argument then and
return 1 in that case. This enables caller to learn if SELinux
context was set or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
5 years agoqemu: command: Use all vCPU properties when creating args for vCPU hotplug
Peter Krempa [Thu, 29 Aug 2019 13:15:23 +0000 (15:15 +0200)]
qemu: command: Use all vCPU properties when creating args for vCPU hotplug

As qemu documents we should use everything in the 'props' sub-object of
the data returned by query-hotpluggable-cpus. Until now we only used
everything we recognized, but that may break in cases when qemu
introduces new fields.

This change requires a fix to the test data as some fields were
reordered.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: Extract and store vCPU properties as qemu returned them
Peter Krempa [Thu, 29 Aug 2019 12:47:10 +0000 (14:47 +0200)]
qemu: Extract and store vCPU properties as qemu returned them

In addition to the data that libvirt needs and extracts internally,
copy and store the whole 'props' JSON sub-object of the data returned by
query-hotpluggable-cpus for future use.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: agent: fix potential leak in qemuAgentGetFSInfo()
Jonathon Jongsma [Thu, 29 Aug 2019 13:56:29 +0000 (08:56 -0500)]
qemu: agent: fix potential leak in qemuAgentGetFSInfo()

On error paths, info_ret could potentially leak. Make sure it's freed.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agosecurity_util: verify xattrs only if ref is present
Nikolay Shirokovskiy [Wed, 28 Aug 2019 10:21:02 +0000 (13:21 +0300)]
security_util: verify xattrs only if ref is present

After 7cfb7aab573 commit starting a domain pullutes logs with
warnings like [1]. The reason is resource files do not
have timestamp before starting a domain and after destroying
domain the timestamp is cleared. Let's check the timestamp
only if attribute with refcounter is found.

[1] warning : virSecurityValidateTimestamp:198 : Invalid XATTR timestamp detected on \
    /some/path secdriver=dac

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: add SVGs for sticker logos
Daniel P. Berrangé [Wed, 21 Feb 2018 13:25:32 +0000 (13:25 +0000)]
docs: add SVGs for sticker logos

Use the templates at https://github.com/terinjokes/StickerConstructorSpec
to provide square and hexagon logos for libvirt, suitable for printing
as stickers.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>