]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agobuild: drop the pthread gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 17:19:18 +0000 (18:19 +0100)]
build: drop the pthread gnulib module

This was fixing a problem with old versions of mingw which had a
pthread.h that polluted the namespace with random symbols. This is no
longer relevant on our mingw platform targets.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the perror gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 17:15:55 +0000 (18:15 +0100)]
build: drop the perror gnulib module

This fixes a problem on mingw where it doesn't know how to report
certain errnos defined by POSIX, but not used on Windows. These are
not a real problem for libvirt.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the gitlog-to-changelog gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 17:14:06 +0000 (18:14 +0100)]
build: drop the gitlog-to-changelog gnulib module

The use of this script was discontinued when we stopped providing a full
ChangeLog in the dist with:

  commit ce97c33a795dec053f1e85c65ecd924b8c6ec4ba
  Author: Andrea Bolognani <abologna@redhat.com>
  Date:   Mon Apr 1 17:33:03 2019 +0200

    maint: Stop generating ChangeLog from git

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the stdarg gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 17:02:43 +0000 (18:02 +0100)]
build: drop the stdarg gnulib module

gnulib fixes a portability problem on AIX which is a platform we have
never targetted.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoRevert "build: use autobuild module to make build logs nicer"
Daniel P. Berrangé [Wed, 2 Oct 2019 15:34:10 +0000 (16:34 +0100)]
Revert "build: use autobuild module to make build logs nicer"

This reverts commit 83aca30f1e8be524780a60b9dd8a14ec5f9de878.

While the motivation of the original commit is fine, we are intending to
drop autoconf in favour of meson, and similarly wish to drop use of
gnulib. Removing this feature is part of that conversion work.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: drop the stpcpy gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 15:14:45 +0000 (16:14 +0100)]
util: drop the stpcpy gnulib module

stpcpy returns a pointer to the end of the string just copied
which in theory makes it easier to then copy another string
after it. We only use stpcpy in one place though and that
is trivially rewritten to avoid stpcpy with no loss in code
clarity or efficiency.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the mktempd gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 11:09:08 +0000 (12:09 +0100)]
build: drop the mktempd gnulib module

The mktempd module in gnulib provides an equivalent to 'mktemp -d' on
platforms which lack this shell command. All platforms on which libvirt
runs the affected tests have 'mktemp -d' support, so the gnulib module
is not required.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the inet_pton gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 11:04:07 +0000 (12:04 +0100)]
build: drop the inet_pton gnulib module

All use of this function was purged a long time ago in favour
of getaddrinfo

  commit a8ae7d19f4ace62ff3f364c628cbc16baa9b080c
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Thu Oct 21 11:13:05 2010 +0100

    Remove all use of inet_pton and inet_ntop

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the getopt-posix gnulib module
Daniel P. Berrangé [Wed, 2 Oct 2019 10:42:07 +0000 (11:42 +0100)]
build: drop the getopt-posix gnulib module

The getopt-posix module fixes a problem with optind being incorrectly
set after a failed option parse. It was also previously used to allow
the bhyve driver to access a private internal reentrant getopt impl.
None of this matters to libvirt code any more.

This partially reverts

  commit b436a8ae5ccb04f8cf893d882d52ab5efc713307
  Author: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
  Date:   Thu Jun 9 00:50:35 2016 +0000

    gnulib: add getopt module

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobhyve: stop using private gnulib _getopt_internal_r func
Daniel P. Berrangé [Thu, 3 Oct 2019 13:35:44 +0000 (14:35 +0100)]
bhyve: stop using private gnulib _getopt_internal_r func

The _getopt_internal_r func is not intended for public use, it is an
internal function shared between the gnulib getopt and argp modules.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: capabilities: Fill in bochs-display info
Fabiano Fidêncio [Thu, 3 Oct 2019 13:28:40 +0000 (15:28 +0200)]
qemu: capabilities: Fill in bochs-display info

086c19d69 added bochs-display capability but didn't fill in the info for
domain capabilities.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_driver: hook up query-cpu-model-comparison
Collin Walling [Thu, 19 Sep 2019 20:25:05 +0000 (16:25 -0400)]
qemu_driver: hook up query-cpu-model-comparison

This command is hooked into the virsh hypervisor-cpu-compare command.
As such, the CPU model XML provided to the command will be compared
to the hypervisor CPU contained in the QEMU capabilities file for the
appropriate QEMU binary (for s390x, this CPU definition can be observed
via virsh domcapabilities).

QMP will report that the XML CPU is either identical to, a subset of,
or incompatible with the hypervisor CPU. s390 can also report that
the XML CPU is a "superset" of the hypervisor CPU. This response is
presented as incompatible, as this CPU model would not be able to run
on the hypervisor.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Message-Id: <1568924706-2311-15-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agocpu_conf: xml to cpu definition parse helper
Collin Walling [Thu, 19 Sep 2019 20:25:04 +0000 (16:25 -0400)]
cpu_conf: xml to cpu definition parse helper

Implement an XML to virCPUDefPtr helper that handles the ctxt
prerequisite for virCPUDefParseXML.

This does not alter any functionality.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
Message-Id: <1568924706-2311-14-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_capabilities: introduce QEMU_CAPS_QUERY_CPU_MODEL_COMPARISON
Collin Walling [Thu, 19 Sep 2019 20:25:03 +0000 (16:25 -0400)]
qemu_capabilities: introduce QEMU_CAPS_QUERY_CPU_MODEL_COMPARISON

This capability enables comparison of CPU models via QMP.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Message-Id: <1568924706-2311-13-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: implement query-cpu-model-comparison
Collin Walling [Thu, 19 Sep 2019 20:25:02 +0000 (16:25 -0400)]
qemu_monitor: implement query-cpu-model-comparison

Interfaces with QEMU to compare CPU models. The command takes two CPU
models, A and B, that are given a model name and an optional list of
CPU features. Through the query-cpu-model-comparison command issued
via QMP, a result is produced that contains the comparison evaluation
string (identical, superset, subset, incompatible).

The list of properties (aka CPU features) that is returned from the QMP
response is ignored.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
Message-Id: <1568924706-2311-12-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_driver: expand cpu features after baseline
Collin Walling [Wed, 2 Oct 2019 11:48:17 +0000 (13:48 +0200)]
qemu_driver: expand cpu features after baseline

Perform a full CPU model expansion on the result of the baselined
model name when the features flag is present.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Message-Id: <1568924706-2311-11-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_driver: hook up query-cpu-model-baseline
Collin Walling [Thu, 19 Sep 2019 20:25:00 +0000 (16:25 -0400)]
qemu_driver: hook up query-cpu-model-baseline

This command is hooked into the virsh hypervisor-cpu-baseline command.
The CPU models provided in the XML sent to the command will be baselined
via the query-cpu-model-baseline QMP command. The resulting CPU model
will be reported.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
Message-Id: <1568924706-2311-10-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_capabilities: introduce QEMU_CAPS_QUERY_CPU_MODEL_BASELINE
Collin Walling [Thu, 19 Sep 2019 20:24:59 +0000 (16:24 -0400)]
qemu_capabilities: introduce QEMU_CAPS_QUERY_CPU_MODEL_BASELINE

This capability enables baselining of CPU models via QMP.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Message-Id: <1568924706-2311-9-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: implement query-cpu-model-baseline
Collin Walling [Thu, 19 Sep 2019 20:24:58 +0000 (16:24 -0400)]
qemu_monitor: implement query-cpu-model-baseline

Interfaces with QEMU to baseline CPU models. The command takes two
CPU models, A and B, that are given a model name and an optional list
of CPU features. Through the query-cpu-model-baseline command issued
via QMP, a result is produced that contains a new baselined CPU model
that is guaranteed to run on both A and B.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielh413@gmail.com>
Message-Id: <1568924706-2311-8-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: make qemuMonitorJSONParseCPUModelData command-agnostic
Collin Walling [Thu, 19 Sep 2019 20:24:57 +0000 (16:24 -0400)]
qemu_monitor: make qemuMonitorJSONParseCPUModelData command-agnostic

Modify the error messages in qemuMonitorJSONParseCPUModelData to print
the command name provided to the function.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Message-Id: <1568924706-2311-7-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: allow cpu props to be optional
Collin Walling [Thu, 19 Sep 2019 20:24:56 +0000 (16:24 -0400)]
qemu_monitor: allow cpu props to be optional

Some older s390 CPU models (e.g. z900) will not report props as a
response from query-cpu-model-expansion. As such, we should make the
props field optional when parsing the return data from the QMP response.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Message-Id: <1568924706-2311-6-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: add features to CPU model for QMP command
Collin Walling [Thu, 19 Sep 2019 20:24:55 +0000 (16:24 -0400)]
qemu_monitor: add features to CPU model for QMP command

query-cpu-model-baseline/comparison will accept a list of features
as part of the command. Since CPUs may be defined with CPU feature
policies, let's parse it to the appropriate boolean that the QMP
command expects.

A feature that is set to required, force, or if it is a hypervisor
CPU feature (-1), then set the property value to true. Otherwise
(optional, disabled) set the value to false.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Message-Id: <1568924706-2311-5-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: use cpu def instead of char for expansion
Collin Walling [Thu, 19 Sep 2019 20:24:54 +0000 (16:24 -0400)]
qemu_monitor: use cpu def instead of char for expansion

When expanding a CPU model via query-cpu-model-expansion, any features
that were a part of the original model are discarded. For exmaple,
when expanding modelA with features f1, f2, a full expansion may reveal
feature f3, but the expanded model will not include f1 or f2.

Let's pass a virCPUDefPtr to the expansion function in preparation for
taking features into consideration.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Message-Id: <1568924706-2311-4-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: expansion cleanups
Collin Walling [Thu, 19 Sep 2019 20:24:53 +0000 (16:24 -0400)]
qemu_monitor: expansion cleanups

With refactoring most of the expansion function, let's take care of
some additional cleanups.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Message-Id: <1568924706-2311-3-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoqemu_monitor: refactor cpu model expansion
Collin Walling [Thu, 19 Sep 2019 20:24:52 +0000 (16:24 -0400)]
qemu_monitor: refactor cpu model expansion

Refactor some code in qemuMonitorJSONGetCPUModelExpansion to be later
used for the comparison and baseline functions.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <1568924706-2311-2-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agomaint: Post-release version bump to 5.9.0
Peter Krempa [Mon, 7 Oct 2019 06:00:47 +0000 (08:00 +0200)]
maint: Post-release version bump to 5.9.0

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
5 years agoRelease of libvirt-5.8.0
Daniel Veillard [Sat, 5 Oct 2019 07:45:29 +0000 (09:45 +0200)]
Release of libvirt-5.8.0

* docs/news.xml: updated for the release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
5 years agoremove a now redundant call to virDiskNameToIndex()
Pavel Mores [Mon, 30 Sep 2019 13:41:01 +0000 (15:41 +0200)]
remove a now redundant call to virDiskNameToIndex()

Parseability of disk name is now checked in qemuDomainDeviceDefValidateDisk().

Signed-off-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Refuse partitions in disk targets
Pavel Mores [Mon, 30 Sep 2019 13:41:00 +0000 (15:41 +0200)]
qemu: Refuse partitions in disk targets

The way in which the qemu driver generates aliases for disks involves
ignoring the partition number part of a target dev name.  This means that
all partitions of a block device and the device itself all end up with the
same alias.  If multiple such disks are specified in XML, the resulting
name clash makes qemu invocation fail.

Since attaching partitions to qemu VMs doesn't seem to make much sense
anyway, disallow partitions in target specifications altogether.

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

Signed-off-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoremote: don't pull anonymous enums into rpc protocol structs
Daniel P. Berrangé [Tue, 17 Sep 2019 11:24:25 +0000 (12:24 +0100)]
remote: don't pull anonymous enums into rpc protocol structs

The VIR_TYPED_PARAM_* enum fields are defined in libvirt-common.h, not
in the remote protcol, so shouldn't be part of the protocol structs
output check. This avoids similar problems hitting when we add use of
glib, which has other such anonymous enums.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: attempt to document the general libvirt dev strategy
Daniel P. Berrangé [Thu, 19 Sep 2019 11:48:15 +0000 (12:48 +0100)]
docs: attempt to document the general libvirt dev strategy

There are various ideas / plans floating around for future libvirt work,
some of which is actively in progress. Historically we've never captured
this kind of information anywhere, except in mailing list discussions.
In particular guidelines in hacking.html.in don't appear until a policy
is actively applied.

This patch attempts to fill the documentation gap, by creating a new
"strategy" page which outlines the general vision for some notable
future changes. The key thing to note is that none of the stuff on this
page is guaranteed, plans may change as new information arises. IOW this
is a "best guess" as to the desired future.

This doc has focused on three areas, related to the topic of language
usage / consolidation

 - Use of non-C languages for the library, daemons or helper tools
 - Replacement of autotools with meson
 - Use of RST and Sphinx for documentation (website + man pages)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: fix escaping of shell path for netcat binary
Daniel P. Berrangé [Thu, 19 Sep 2019 11:47:54 +0000 (12:47 +0100)]
rpc: fix escaping of shell path for netcat binary

Consider having a nc binary in the path with a space in its name,
for example '/tmp/fo o/nc'

This results in libvirt running SSH with the following arg value

  "'if ''/tmp/fo o/nc'' -q 2>&1 | grep \"requires
    an argument\" >/dev/null 2>&1; then ARG=-q0;
    else ARG=;fi;''/tmp/fo o/nc'' $ARG -U
    /var/run/libvirt/libvirt-sock'"

The use of the single quote escaping was introduced by

  commit 6ac6238de33fc74e7545b245ae273d1bfd658808
  Author: Guido Günther <agx@sigxcpu.org>
  Date:   Thu Oct 13 21:49:01 2011 +0200

    Use virBufferEscapeShell in virNetSocketNewConnectSSH

    to escape the netcat command since it's passed to the shell. Adjust
    expected test case output accordingly.

While the intention of this change was good, the result is broken as it
is still underquoted.

On the SSH server side, SSH itself runs the command via the shell.
Our command is then invoking the shell again. Thus we see

$ virsh -c qemu+ssh://root@domokun/system?netcat=%2Ftmp%2Ffo%20o%2Fnc list
error: failed to connect to the hypervisor
error: End of file while reading data: sh: /tmp/fo: No such file or directory: Input/output error

With the second level of escaping added we can now successfully use a nc
binary with a space in the path.

The original test case added was misleading as it illustrated using a
binary path of 'nc -4' which is not a path, it is a command with a
separate argument, which is getting interpreted as a path.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoadmin: fix memory leak of typed parameters getting client info
Daniel P. Berrangé [Mon, 30 Sep 2019 15:56:33 +0000 (16:56 +0100)]
admin: fix memory leak of typed parameters getting client info

In the error code path, the temporary parameters are not freed.

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu_capabilities: Put only unique FW images into domcaps
Michal Privoznik [Thu, 12 Sep 2019 11:07:31 +0000 (13:07 +0200)]
qemu_capabilities: Put only unique FW images into domcaps

In the domain capabilities XML there are FW image paths printed.
There are two sources for the image paths (in order of
preference):

  1) firmware descriptor files - as returned by
  qemuFirmwareGetSupported()

  2) a compile time list of FW:NRAM pairs which can be overridden
  in qemu.conf

If either of those contains a duplicate FW image path (which is
a valid use case) it is printed twice in the capabilities XML.
While it's technically not a bug, it doesn't look good.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: checkpoint: Don't update current checkpoint until we are done
Peter Krempa [Mon, 30 Sep 2019 14:37:48 +0000 (16:37 +0200)]
qemu: checkpoint: Don't update current checkpoint until we are done

Similarly to the snapshot code there's no reason to modify current
checkpoint until we are done creating the new one.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: snapshot: Don't update current snapshot until we're done
Peter Krempa [Mon, 30 Sep 2019 14:22:08 +0000 (16:22 +0200)]
qemu: snapshot: Don't update current snapshot until we're done

Since commit f105627992e we store whether a snapshot is current globally
rather than locally in the snapshot object.

This means that we don't have to unset the current snapshot prior to
taking/reverting the snapshot and we can do it only when everything is
done successfully.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoclarify the xml example for NVDIMM more clealy
Luyao Zhong [Mon, 23 Sep 2019 10:06:22 +0000 (18:06 +0800)]
clarify the xml example for NVDIMM more clealy

The NVDIMM backend file can be a normal file or a real device file,
Current xml example and explainations may mislead users. So add more
info about the NVDIMM related elements and update the xml examples.

Signed-off-by: Luyao Zhong <luyao.zhong@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosecurity: AppArmor profile fixes for swtpm
Chris Coulson [Tue, 24 Sep 2019 19:25:14 +0000 (20:25 +0100)]
security: AppArmor profile fixes for swtpm

The AppArmor profile generated by virt-aa-helper is too strict for swtpm.
This change contains 2 small fixes:
- Relax append access to swtpm's log file to permit write access instead.
Append access is insufficient because the log is opened with O_CREAT.
- Permit swtpm to acquire a lock on its lock file.

Signed-off-by: Chris Coulson <chris.coulson@canonical.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: sanity check vhost user FD before passing to QEMU
Daniel P. Berrangé [Mon, 30 Sep 2019 11:39:17 +0000 (12:39 +0100)]
qemu: sanity check vhost user FD before passing to QEMU

Ensure that the FD we're passing to QEMU is actually open, so we get a
sane error message upfront instead of telling QEMU to use a closed FD.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: ensure vhostuser FD is initialized to -1
Daniel P. Berrangé [Fri, 27 Sep 2019 16:34:44 +0000 (17:34 +0100)]
qemu: ensure vhostuser FD is initialized to -1

The video private data was not initializing the vhostuser FD
causing us to attempt to close FD 0 many times over.

Fixes

  commit ca60ecfa8cc1bd85baf7137dd1864d5f00f019f0
  Author: Marc-André Lureau <marcandre.lureau@redhat.com>
  Date:   Mon Sep 23 14:44:36 2019 +0400

      qemu: add qemuDomainVideoPrivate

Since the test suite does not invoke qemuExtDevicesStart(), no
vhost_user_fd will be present when generating test XML. To deal
with this we can must a fake FD number. While the current XML
is using FD == 0, we pick a very interesting number that's unlikely
to be a real FD, so that we're more likely to see any mistakes
closing the invalid FD.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: monitor: unexport qemuMonitorJSONTransactionAdd
Peter Krempa [Thu, 26 Sep 2019 14:37:44 +0000 (16:37 +0200)]
qemu: monitor: unexport qemuMonitorJSONTransactionAdd

Now it's not used outside of qemu_monitor_json.c.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: Replace open-coded transaction action generators
Peter Krempa [Thu, 26 Sep 2019 14:36:15 +0000 (16:36 +0200)]
qemu: checkpoint: Replace open-coded transaction action generators

Use the generators provided by the monitor code instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: block: Replace snapshot transaction action generator
Peter Krempa [Thu, 26 Sep 2019 14:33:43 +0000 (16:33 +0200)]
qemu: block: Replace snapshot transaction action generator

Use the new generator residing in the monitor code rather than directly
using qemuMonitorJSONTransactionAdd.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agotests: qemumonitor: Add testing for the 'transaction' command and generators
Peter Krempa [Thu, 26 Sep 2019 14:12:20 +0000 (16:12 +0200)]
tests: qemumonitor: Add testing for the 'transaction' command and generators

Validate all the commands against the schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: monitor: Add transaction generators for snapshot APIs
Peter Krempa [Thu, 26 Sep 2019 14:03:46 +0000 (16:03 +0200)]
qemu: monitor: Add transaction generators for snapshot APIs

Unify with other code that generates parameters for the 'transaction'
command.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: monitor: Add transaction generators for dirty bitmap APIs
Peter Krempa [Thu, 26 Sep 2019 13:53:39 +0000 (15:53 +0200)]
qemu: monitor: Add transaction generators for dirty bitmap APIs

Rather than generating the transaction contents in random places add a
unified set of APIs to generate the contents for a 'transaction' for the
dirty bitmap APIs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: domain: Base block job interlocking on QEMU_CAPS_INCREMENTAL_BACKUP
Peter Krempa [Thu, 26 Sep 2019 12:08:11 +0000 (14:08 +0200)]
qemu: domain: Base block job interlocking on QEMU_CAPS_INCREMENTAL_BACKUP

The QEMU_CAPS_INCREMENTAL_BACKUP will be enabled once all bits of the
incremental backup feature work as expected which means also properly
interacting with blockjobs and snapshots.

Thus we can allow blockjobs and snapshots if QEMU_CAPS_INCREMENTAL_BACKUP
is present even when checkpoints exist.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: Aggregate interlocking of blockjobs by checkpoints in one place
Peter Krempa [Thu, 26 Sep 2019 11:54:15 +0000 (13:54 +0200)]
qemu: Aggregate interlocking of blockjobs by checkpoints in one place

Rather than having to fix 5 places once we support the combination, add
a function called by all the blockjob/snapshot APIs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: Forbid creating checkpoints until we support backups
Peter Krempa [Thu, 26 Sep 2019 11:25:40 +0000 (13:25 +0200)]
qemu: checkpoint: Forbid creating checkpoints until we support backups

Checkpoints by themselves are not very useful for anything else than
testing the few bitmap interactions that are currently implemented.

It's very unlikely that anybody used this feature and thus we can
disable it until we have a more complete implementation ready.

Additionally the code for deleting checkpoints has many broken failure
scenarios which should be fixed first. This will require support of
deleting a bitmap in a qemu 'transaction' which was not released yet.

Curious users obviously can use the qemu namespace in the XML to enable
this for experiments:

  <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
    ...
    <qemu:capabilities>
      <qemu:add capability='incremental-backup'/>
    </qemu:capabilities>
  </domain>

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: caps: Add capability for incremental backup support
Peter Krempa [Thu, 26 Sep 2019 11:01:30 +0000 (13:01 +0200)]
qemu: caps: Add capability for incremental backup support

Add a new all-covering capability which will be used to interlock
incremental backup support until all bits are ready.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: Don't repeat virDomainObjEndAPI in qemuDomainBlockPull
Peter Krempa [Thu, 26 Sep 2019 11:50:16 +0000 (13:50 +0200)]
qemu: Don't repeat virDomainObjEndAPI in qemuDomainBlockPull

Add a 'cleanup' label and use jumps as we do in other places.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: Remove open-ended TODOs
Peter Krempa [Thu, 26 Sep 2019 11:21:00 +0000 (13:21 +0200)]
qemu: checkpoint: Remove open-ended TODOs

Once somebody is motivated enough to add the support for the quiesce
flag or offline checkpoint deletion they are welcome to do so but we
don't need to have a reminder.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: Refactor cleanup in qemuCheckpointCreateXML
Peter Krempa [Thu, 26 Sep 2019 11:19:40 +0000 (13:19 +0200)]
qemu: checkpoint: Refactor cleanup in qemuCheckpointCreateXML

Use VIR_AUTO* helpers and get rid of the 'cleanup' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: driver: Don't pull in qemu_monitor_json.h directly
Peter Krempa [Fri, 20 Sep 2019 11:49:55 +0000 (13:49 +0200)]
qemu: driver: Don't pull in qemu_monitor_json.h directly

There's nothing that uses it directly now. Also not allowing direct use
will promote our layering.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: domain: Move checkpoint related code to qemu_checkpoint.c
Peter Krempa [Fri, 20 Sep 2019 11:47:04 +0000 (13:47 +0200)]
qemu: domain: Move checkpoint related code to qemu_checkpoint.c

Finish the refactor by moving and renaming functions from qemu_domain.c

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: driver: Move checkpoint-related code to qemu_checkpoint.c
Peter Krempa [Thu, 19 Sep 2019 14:49:21 +0000 (16:49 +0200)]
qemu: driver: Move checkpoint-related code to qemu_checkpoint.c

Move all extensive functions to a new file so that we don't just pile
everything in the common files. This obviously isn't possible with
straight code movement as we still need stubs in qemu_driver.c

Additionally some functions e.g. for looking up a checkpoint by name
were so short that moving the impl didn't make sense.

Note that in the move the new file also doesn't use
virQEMUMomentReparent but rather an stripped down copy. As I plan to
split out snapshot code into a separate file the unification doesn't
make sense any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoqemu: checkpoint: Do ACL check prior to snapshot interlocking
Peter Krempa [Fri, 27 Sep 2019 08:00:39 +0000 (10:00 +0200)]
qemu: checkpoint: Do ACL check prior to snapshot interlocking

The interlocking with snapshots is executed prior to the ACL check so if
a VM has snapshots invoking the checkpoint API may leak it's existance.

Introduced with the qemuDomainCheckpointCreateXML API implementation in
commit 5f4e0796503.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agotools: fix regression passing command with virt-login-shell
Daniel P. Berrangé [Fri, 27 Sep 2019 16:18:24 +0000 (17:18 +0100)]
tools: fix regression passing command with virt-login-shell

It is documented that a command to run inside the container can be
passed with the -c arg.

  virt-login-shell -c "ls -l /"

This fixes

  commit 4feeb2d986b98013ebfb1d41ab6b9007b6cce6e2
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Thu Aug 1 10:58:31 2019 +0100

    tools: split virt-login-shell into two binaries

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: fix systemd IP socket activation with virtproxyd
Daniel P. Berrangé [Fri, 20 Sep 2019 15:18:41 +0000 (16:18 +0100)]
remote: fix systemd IP socket activation with virtproxyd

We recently forbid the use of --listen with socket activation:

  commit 3a6a725b8f575890ee6c151ad1f46ea0ceea1f3b
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Thu Aug 22 14:52:16 2019 +0100

      remote: forbid the --listen arg when systemd socket activation

In this change we forgot that virtproxyd doesn't have a --listen
parameter, and instead behaves as if it was always present. Thus
when systemd socket activation is present, we must disable this
built-in default

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotools: Record NSS dependency on symbols file
Michal Privoznik [Tue, 16 Jul 2019 10:06:20 +0000 (12:06 +0200)]
tools: Record NSS dependency on symbols file

If a symbol file for either of NSS modules is changed then
subsequent 'make' doesn't regenerate the library, because there
is no implicit dependency between the library and symbols file.
Put an explicit dependency into the Makefile then. Unfortunately,
setting _DEPENDENCIES makes us lose automake's generated
dependencies (see src/Makefile.am:592 for details). But
fortunately, the only dependency we had was _LIBADD variable.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agolibvirt_nss.h: Separate function declarations with an empty line
Michal Privoznik [Tue, 16 Jul 2019 10:05:27 +0000 (12:05 +0200)]
libvirt_nss.h: Separate function declarations with an empty line

I find it more readable that way.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agonss: Don't leak @addr in gethostbyname4()
Michal Privoznik [Sat, 28 Sep 2019 18:42:29 +0000 (20:42 +0200)]
nss: Don't leak @addr in gethostbyname4()

Similarly to gethostbyname3(), the @addr must be freed on return
from the function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agonss: Drop needless free() in gethostbyname3()
Michal Privoznik [Sat, 28 Sep 2019 19:24:53 +0000 (21:24 +0200)]
nss: Drop needless free() in gethostbyname3()

The findLease() function allocates @addr array iff no error
occurred and at least one satisfactory record was found.
Therefore, there is no need to call free() if findLease() failed,
or did not find any records as addr == NULL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agonss: Compare addresses iff their family matches
Michal Privoznik [Sat, 28 Sep 2019 18:46:08 +0000 (20:46 +0200)]
nss: Compare addresses iff their family matches

When parsing leases file, appendAddr() is called to append parsed
tuple (address, expiry time, family) into an array. Whilst doing
so, the array is searched for possible duplicate. This is done by
comparing each item of the array by passed @family: if @family is
AF_INET then the item is viewed as IPv4 address. Similarly, if
@family is AF_INET6 then the item is viewed as IPv6 address. This
is not exactly right - the array can contain addresses of both
families and thus the address family of each item of the array
must be considered.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovircgroup: Add some VIR_DEBUG statements
Cole Robinson [Thu, 26 Sep 2019 19:25:52 +0000 (15:25 -0400)]
vircgroup: Add some VIR_DEBUG statements

These helped with debugging
https://bugzilla.redhat.com/show_bug.cgi?id=1612383

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agovircgroupv2: Fix VM startup when legacy cgroups are defined
Cole Robinson [Thu, 26 Sep 2019 19:00:55 +0000 (15:00 -0400)]
vircgroupv2: Fix VM startup when legacy cgroups are defined

On Fedora 31, starting a 'mock' build alters /proc/$pid/cgroup,
probably due to usage of systemd-nspawn.

Before:
$ cat /proc/self/cgroup
0::/user.slice/user-1000.slice/...

After:
$ cat /proc/self/cgroup
1:name=systemd:/
0::/user.slice/user-1000.slice/...

The cgroupv2 code mishandles that first line in the second case, which
causes VM startup to fail with: Unable to read from
'/sys/fs/cgroup/machine/cgroup.controllers': No such file or directory

The kernel docs[1] say that the cgroupv2 path will always start with
'0::', which in the code here controllers="". Only set the v2 placement
path when we see that cgroup file entry.

[1] https://www.kernel.org/doc/html/v5.3/admin-guide/cgroup-v2.html#processes

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

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: driver: Remove misplaced qemuDomainObjEndJob in qemuDomainCheckpointGetXMLDesc
Peter Krempa [Fri, 20 Sep 2019 07:08:05 +0000 (09:08 +0200)]
qemu: driver: Remove misplaced qemuDomainObjEndJob in qemuDomainCheckpointGetXMLDesc

The code that gets the job to refresh disk sizes was not merged yet so
remove this artifact.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agoconf: Drop pointless 'domain' argument from virDomainSnapshotRedefinePrep
Peter Krempa [Fri, 20 Sep 2019 10:25:51 +0000 (12:25 +0200)]
conf: Drop pointless 'domain' argument from virDomainSnapshotRedefinePrep

'vm' is passed in which contains the definition which contains the UUID
so we don't need another parameter for this.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: Drop pointless 'domain' argument from virDomainCheckpointRedefinePrep
Peter Krempa [Fri, 20 Sep 2019 10:25:51 +0000 (12:25 +0200)]
conf: Drop pointless 'domain' argument from virDomainCheckpointRedefinePrep

'vm' is passed in which contains the definition which contains the UUID
so we don't need another parameter for this.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Move, rename and export qemuDomObjFromDomain
Peter Krempa [Fri, 20 Sep 2019 09:03:08 +0000 (11:03 +0200)]
qemu: Move, rename and export qemuDomObjFromDomain

Move it to qemu_domain.c and rename it to qemuDomainObjFromDomain. This
will allow reusing it after splitting out checkpoint code from
qemu_driver.c.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodocs: document that C & Python are the preferred languages
Daniel P. Berrangé [Thu, 5 Sep 2019 11:41:30 +0000 (12:41 +0100)]
docs: document that C & Python are the preferred languages

Blacklist Perl and Shell code in favour of Python for
sake of readability and portability.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu_monitor: s/size_t/ULL/ in qemuMonitorSave{Virtual,Physical}Memory
Michal Privoznik [Fri, 27 Sep 2019 11:29:53 +0000 (13:29 +0200)]
qemu_monitor: s/size_t/ULL/ in qemuMonitorSave{Virtual,Physical}Memory

As it turns out, on my 32bit ARM machine size_t is not the same
size as ULL. However, @length argument for both functions is type
of size_t but it's treated as ULL - for instance when passed to
qemuMonitorJSONMakeCommand(). The problem is that because of
"U:size" the virJSONValueObjectAddVArgs() expects an ULL argument
but on the stack there are size_t and char * arguments (which
coincidentally add up to size of ULL). So the created command has
only two arguments "val" and incorrect "size" and no "path" which
is required.

I've tried to find other occurrences of this pattern but at the
rest of places where size_t is used it tracks size of an array so
that's safe.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
5 years agorpm: stop compressing the ChangeLog file
Daniel P. Berrangé [Fri, 20 Sep 2019 12:21:31 +0000 (13:21 +0100)]
rpm: stop compressing the ChangeLog file

We stopped generating a giant ChangeLog file in

  commit ce97c33a795dec053f1e85c65ecd924b8c6ec4ba
  Author: Andrea Bolognani <abologna@redhat.com>
  Date:   Mon Apr 1 17:33:03 2019 +0200

      maint: Stop generating ChangeLog from git

so there is no reason to compress it anymore.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: Simplify argument list of qemuDomainBlockPullCommon
Peter Krempa [Thu, 26 Sep 2019 11:47:54 +0000 (13:47 +0200)]
qemu: Simplify argument list of qemuDomainBlockPullCommon

Drop the 'driver' argument since it can be extracted from private data
to shorten the argument list.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
5 years agotests: qemucapabilities: Update caps of qemu-4.1 to released version
Peter Krempa [Fri, 27 Sep 2019 05:27:57 +0000 (07:27 +0200)]
tests: qemucapabilities: Update caps of qemu-4.1 to released version

Now that qemu 4.1 was released we can update the capabilities to the
final form.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agotests: add qemu capabilities data for qemu 4.2
Peter Krempa [Tue, 17 Sep 2019 14:49:03 +0000 (16:49 +0200)]
tests: add qemu capabilities data for qemu 4.2

Add capabilities test data for upcoming qemu 4.2.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agoconf: refresh network ports missing from network driver on restart
Laine Stump [Fri, 20 Sep 2019 22:15:19 +0000 (18:15 -0400)]
conf: refresh network ports missing from network driver on restart

Before the refactoring that properly separated the network driver from
the hypervisor driver and forced all interaction to go through public
APIs, all network usage counters were zeroed when the network driver
was initialized, and the network driver's now-deprecated
"semi-private" API networkNotifyActualDevice() was called for every
interface of every domain as each hypervisor "reconnected" its domains
during a libvirtd restart, and this would refresh the usage count for
each network.

Post-driver-split, during libvirtd restart/reconnection of the running
domains, the function virDomainNetNotifyActualDevice() is called by
each hypervisor driver for every interface of every domain restart,
and this function has code to re-register interfaces, but it only
calls into the network driver to re-register those ports that don't
already have a valid portid (ie. one that is not simply all 0),
assuming that those with valid portids are already known (and counted)
by the network driver.

commit 7ab9bdd47 recently modified the network driver so that, in most
cases, it properly resyncs each network's connection count during
libvirtd (or maybe virtnetworkd) restart by iterating through the
network's port list. This doesn't account for the case where a network
is destroyed and restarted while there are running domains that have
active ports on the network. In that case, the entire port list and
connection count for that network is lost, and now even a restart of
libvirtd/virtnetworkd/virtqemud, which in the past would resync the
connection count, doesn't help (the network driver thinks there are no
active ports, while the hypervisor driver knows about all the active
ports, but mistakenly believes that the network driver also knows).

The solution to this is to not just bypass valid portids during the
call to virDomainNetworkNotifyActualDevice(). Instead, we query the
network driver about the portid that was preserved in the domain
status, and if it is not registered, we register it.

(NB: while it would technically be correct to just generate a new
portid for these cases, it makes for less churn in portids (and thus
may make troubleshooting simpler) if we make the small fix to
virDomainNetDefActualToNetworkPort() that preserves existing valid
portids rather than unconditionally generating a new one.)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: take advantage of VIR_AUTOPTR for virNetworkPortDefPtr
Laine Stump [Mon, 23 Sep 2019 01:03:51 +0000 (21:03 -0400)]
conf: take advantage of VIR_AUTOPTR for virNetworkPortDefPtr

define a VIR_DEFINE_AUTOPTR_FUNC() to autofree virNetworkPortDefs, and
convert all uses of virNetworkPortDefPtr that are appropriate to use
it.

This coincidentally fixes multiple potential memory leaks (in failure
cases) in networkPortCreateXML()

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovbox_driver.c: use virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:46 +0000 (11:56 -0300)]
vbox_driver.c: use virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovbox_common.c: use virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:45 +0000 (11:56 -0300)]
vbox_common.c: use virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu_driver.c: use virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:44 +0000 (11:56 -0300)]
qemu_driver.c: use virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agodriver.c: change URI validation to handle QEMU and vbox case
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:43 +0000 (11:56 -0300)]
driver.c: change URI validation to handle QEMU and vbox case

The existing QEMU and vbox URI path validation consider
that a privileged user can use both a "/system" and a
"/session" URI. This differs from all the other drivers
that forbids the root user to use "/session" URI.

Let's update virConnectValidateURIPath() to handle these
cases as exceptions, using the already existent 'entityName'
value to handle "QEMU" and "vbox" differently. This allows
us to use the validateURI function in these cases without
changing the existing behavior of other drivers.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agostorage_driver.c: use virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:42 +0000 (11:56 -0300)]
storage_driver.c: use virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agosecret_driver.c: use virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:41 +0000 (11:56 -0300)]
secret_driver.c: use virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agonode_device_driver.c: use virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:40 +0000 (11:56 -0300)]
node_device_driver.c: use virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agobridge_driver.c: virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:39 +0000 (11:56 -0300)]
bridge_driver.c: virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agointerface_backend_udev.c: use virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:38 +0000 (11:56 -0300)]
interface_backend_udev.c: use virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agointerface_backend_netcf.c: use virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:37 +0000 (11:56 -0300)]
interface_backend_netcf.c: use virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agosrc/driver.c: add virConnectValidateURIPath()
Daniel Henrique Barboza [Thu, 26 Sep 2019 14:56:36 +0000 (11:56 -0300)]
src/driver.c: add virConnectValidateURIPath()

The code to validate the URI path is repeated across several
files. This patch creates a common validation code to be
used across all of them.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Suggested-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoconf: utility function to update entry in def->nets array
Laine Stump [Wed, 25 Sep 2019 16:42:51 +0000 (12:42 -0400)]
conf: utility function to update entry in def->nets array

A virDomainNetDef object in a domain's nets array might contain a
virDomainHostdevDef, and when this is the case, the domain's hostdevs
array will also have a pointer to this embedded hostdev (this is done
so that internal functions that need to perform some operation on all
hostdevs won't leave out the type='hostdev' network interfaces).

When a network device was updated with virDomainUpdateDeviceFlags(),
we were replacing the entry in the nets array (and free'ing the
original) but forgetting about the pointer in the hostdevs array
(which would then point to the now-free'd hostdev contained in the old
net object.) This often resulted in a libvirtd crash.

The solution is to add a function, virDomainNetUpdate(), called by
qemuDomainUpdateDeviceConfig(), that updates the hostdevs array
appropriately along with the nets array.

Resolves: https://bugzilla.redhat.com/1558934

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodomain_conf: Unref video private data in virDomainVideoDefClear()
Michal Privoznik [Thu, 26 Sep 2019 14:17:49 +0000 (16:17 +0200)]
domain_conf: Unref video private data in virDomainVideoDefClear()

The private data for video definition is created in
virDomainVideoDefNew() and we attempt to free it in
virDomainVideoDefFree(). This seems to work, except
the free function calls clear function which zeroes
out the whole structure and thus virObjectUnref()
which is called on private data does nothing.

2,568 bytes in 107 blocks are definitely lost in loss record 207 of 213
   at 0x4A35476: calloc (vg_replace_malloc.c:752)
   by 0x50A6048: virAllocVar (viralloc.c:346)
   by 0x513CC5A: virObjectNew (virobject.c:243)
   by 0x4DC1DEE: qemuDomainVideoPrivateNew (qemu_domain.c:1337)
   by 0x51A6BD6: virDomainVideoDefNew (domain_conf.c:2831)
   by 0x51B9F06: virDomainVideoDefParseXML (domain_conf.c:15541)
   by 0x51CB761: virDomainDefParseXML (domain_conf.c:21158)
   by 0x51C5973: virDomainDefParseNode (domain_conf.c:21708)
   by 0x51C583A: virDomainDefParse (domain_conf.c:21663)
   by 0x51C58AE: virDomainDefParseFile (domain_conf.c:21688)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agospec: Drop unittest overrides
Cole Robinson [Tue, 24 Sep 2019 17:21:13 +0000 (13:21 -0400)]
spec: Drop unittest overrides

nodinfotest.c doesn't exist anymore

seclabeltest.c has changed substantially since this behavior was
added to the spec, and in my testing doesn't have any problems
running in mock

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu: driver: Remove unused cleanup labels in stats gathering functions
Peter Krempa [Thu, 19 Sep 2019 09:32:09 +0000 (11:32 +0200)]
qemu: driver: Remove unused cleanup labels in stats gathering functions

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsBlockExportFro...
Peter Krempa [Thu, 19 Sep 2019 09:01:48 +0000 (11:01 +0200)]
qemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsBlockExportFrontend

The macro now became unused so it was deleted.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsBlockExportBac...
Peter Krempa [Thu, 19 Sep 2019 09:01:48 +0000 (11:01 +0200)]
qemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsBlockExportBackendStorage

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsOneBlock
Peter Krempa [Thu, 19 Sep 2019 09:01:48 +0000 (11:01 +0200)]
qemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsOneBlock

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsOneBlockFallback
Peter Krempa [Thu, 19 Sep 2019 09:01:48 +0000 (11:01 +0200)]
qemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsOneBlockFallback

The open-coded version does not take much more space and additionally we
get rid of the hidden goto.

This also requires us to remove the 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: Use virTypedParamList in the bulk stats gathering functions
Peter Krempa [Thu, 19 Sep 2019 08:36:28 +0000 (10:36 +0200)]
qemu: Use virTypedParamList in the bulk stats gathering functions

The bulk stats functions are specific as they pass around the list into
many sub-functions and also a substantial amount of the entries uses
formatted names for indexing purposes. This makes them ideal to be
converted to the new virTypedParamList helpers.

Unfortunately given how the functions are used this requires a big-bang
rewrite of all of the calls to add entries to the parameter list.

Given that a substantial simplification is achieved as well as a pretty
significant change to the original code is required some macros which
were used only sporadically were replaced by inline calls rather than
tweaking the macros first and deleting them later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Remove QEMU_ADD_BLOCK_PARAM_LL macro
Peter Krempa [Thu, 15 Aug 2019 09:38:08 +0000 (11:38 +0200)]
qemu: driver: Remove QEMU_ADD_BLOCK_PARAM_LL macro

Use QEMU_ADD_BLOCK_PARAM_ULL instead since all parameters are now
unsigned.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: driver: Don't return anything from qemuDomainBlockStatsGatherTotals
Peter Krempa [Mon, 16 Sep 2019 16:58:25 +0000 (18:58 +0200)]
qemu: driver: Don't return anything from qemuDomainBlockStatsGatherTotals

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>