]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
3 years agokbase: debuglogs: Extract client library logging setup
Peter Krempa [Mon, 17 Jan 2022 12:59:58 +0000 (13:59 +0100)]
kbase: debuglogs: Extract client library logging setup

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
3 years agokbase: debuglogs: Add a section describing log outputs and filters
Peter Krempa [Mon, 17 Jan 2022 12:45:02 +0000 (13:45 +0100)]
kbase: debuglogs: Add a section describing log outputs and filters

Outline what the given settings influence.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
3 years agokbase: debuglogs: Section off the settings for legacy libvirt
Peter Krempa [Mon, 17 Jan 2022 11:15:17 +0000 (12:15 +0100)]
kbase: debuglogs: Section off the settings for legacy libvirt

Move out the settings required to pre libvirt-4.4.0 deployments into a
separate section so that the main point is not cluttered by now mostly
irrelevant settings.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
3 years agokbase: debuglogs: Un-nest section on enabling debug logs
Peter Krempa [Mon, 17 Jan 2022 10:55:40 +0000 (11:55 +0100)]
kbase: debuglogs: Un-nest section on enabling debug logs

Enabling the logs is the focus of this article. Decouple it from the
first section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
3 years agokbase: debuglogs: Use common heading hierarchy
Peter Krempa [Mon, 17 Jan 2022 10:04:15 +0000 (11:04 +0100)]
kbase: debuglogs: Use common heading hierarchy

Use the heading hierarchy as generated by pandoc which we use in most
of the converted XML format docs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
3 years agospec: Run pre/post-install stuff on 'daemon-driver-storage-core'
Peter Krempa [Wed, 19 Jan 2022 12:41:28 +0000 (13:41 +0100)]
spec: Run pre/post-install stuff on 'daemon-driver-storage-core'

'daemon-driver-storage' is just a meta-package, the actual daemon is in
the 'daemon-driver-storage-core' package, so without installing the meta
package the storage daemon is not being enabled.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2025644
Fixes: 50eae3f8859, b8ef6255444
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoremote: systemd: Remove unix sockets from filesystem when disabling a '.socket' unit
Peter Krempa [Tue, 18 Jan 2022 14:00:21 +0000 (15:00 +0100)]
remote: systemd: Remove unix sockets from filesystem when disabling a '.socket' unit

The existence of the unix socket path is used by the remote driver to
determine whether modular daemons are in use, so if the socket file
stays behind and the user decided to switch from modular to monolithic
daemon which was socket activated, the remote driver will insist on
picking '/var/run/libvirt/virtqemud-sock', even when it's no longer in
use:

 # systemctl start libvirtd.service
 # virsh list
  Id   Name   State
 --------------------

 # systemctl stop libvirtd.service
 Warning: Stopping libvirtd.service, but it can still be activated by:
   libvirtd.socket
   libvirtd-ro.socket
   libvirtd-admin.socket
 # systemctl start virtqemud.socket
 # virsh list
  Id   Name   State
 --------------------

 # systemctl stop virtqemud.socket
 # systemctl start libvirtd.service
 # virsh list
 error: failed to connect to the hypervisor
 error: Failed to connect socket to '/var/run/libvirt/virtqemud-sock': Connection refused

 # virsh -c 'qemu:///system?socket=/var/run/libvirt/libvirt-sock' list
  Id   Name   State
 --------------------

Fix this by instructing systemd to delete the socket file when
deactivating the unit file for the socket.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
3 years agoqemuValidateDomainDeviceDefVideo: Reject non-default video head count for devices...
Peter Krempa [Tue, 18 Jan 2022 15:59:35 +0000 (16:59 +0100)]
qemuValidateDomainDeviceDefVideo: Reject non-default video head count for devices not supporting it

Only QXL and virtio-vga actually propagate the 'heads' attribute as
'max_outputs' to the commandline of qemu. Reject the setting when
non-default value is used for any other video type.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2036300
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuValidateDomainDeviceDefVideo: Refactor condition checking for qxl and virtio-vga
Peter Krempa [Tue, 18 Jan 2022 15:58:35 +0000 (16:58 +0100)]
qemuValidateDomainDeviceDefVideo: Refactor condition checking for qxl and virtio-vga

Subsequent patch will use the same condition so move the primary device
check into a nested condition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildDeviceVideoCmd: Simplify formatting of 'max_outputs' property
Peter Krempa [Tue, 18 Jan 2022 15:31:28 +0000 (16:31 +0100)]
qemuBuildDeviceVideoCmd: Simplify formatting of 'max_outputs' property

Since there's no capability to check now, we can simply move the
formatting of 'max_outputs' earlier.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: capabilities: Retire QEMU_CAPS_QXL_MAX_OUTPUTS and QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS
Peter Krempa [Tue, 18 Jan 2022 15:22:33 +0000 (16:22 +0100)]
qemu: capabilities: Retire QEMU_CAPS_QXL_MAX_OUTPUTS and QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS

Both are supported by qemu-2.11 and later, so we don't have to check for
them explicitly.

Note that QXL is supported only on x86_64, thus on other arches only the
capability for 'virtio-gpu' is removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildDeviceVideoCmd: Always assume support for 'max_outputs' property
Peter Krempa [Tue, 18 Jan 2022 15:19:03 +0000 (16:19 +0100)]
qemuBuildDeviceVideoCmd: Always assume support for 'max_outputs' property

Both the QXL video device and 'virtio' video device support
'max_outputs' in all qemu versions libvirt supports. This means we no
longer have to check the QEMU_CAPS_QXL_MAX_OUTPUTS and
QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainDeviceInfoParseXML: Reject '0' value for ACPI index
Peter Krempa [Tue, 18 Jan 2022 14:43:42 +0000 (15:43 +0100)]
virDomainDeviceInfoParseXML: Reject '0' value for ACPI index

Value of '0' is treated equivalently to when it's not provided by the
user. Reject an explicit '0' provided by the user as it would get
ignored.

In this rare case we can make the XML parser more strict, as libvirt
would never format the '<acpi/>' element if the index is '0' thus there
are no libvirt-generated XMLs we'd not load back, as of such this is
identical to rejecting it in the validation phase.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2037146
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirsh-network: Don't check for virshXXXTypeFromString() >= VIR_XXX_LAST
Michal Privoznik [Mon, 10 Jan 2022 11:59:29 +0000 (12:59 +0100)]
virsh-network: Don't check for virshXXXTypeFromString() >= VIR_XXX_LAST

They way our VIR_ENUM_IMPL() and virXXXTypeFromString() work is
that for any string that's not recognized a negative one is
returned. And, since VIR_XXX_LAST is passed to VIR_ENUM_IMPL() we
can be sure that all enum members are covered. Therefore, there
is no way that virXXXTypeFromString() can return a value that's
bigger or equal to VIR_XXX_LAST.

I've noticed two places where such comparison was made, both in
cmdNetworkUpdate(). Drop them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirsh: Introduce net-update --section completer
Michal Privoznik [Mon, 10 Jan 2022 11:44:23 +0000 (12:44 +0100)]
virsh: Introduce net-update --section completer

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: Introduce net-update --command completer
Michal Privoznik [Mon, 10 Jan 2022 11:41:03 +0000 (12:41 +0100)]
virsh: Introduce net-update --command completer

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoutil: set facility when opening syslog channel
Daniel P. Berrangé [Tue, 18 Jan 2022 16:48:00 +0000 (16:48 +0000)]
util: set facility when opening syslog channel

We're currently passing '0' which leaves the syslog facility
unset. Since we're passing an explicit facility for syslog
when using journald, it makes sense to be explicit when
using  syslog directly too.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoutil: fix syslog facility value
Daniel P. Berrangé [Tue, 18 Jan 2022 16:45:35 +0000 (16:45 +0000)]
util: fix syslog facility value

We set SYSLOG_PRIORITY when sending to journald to avoid our
messages getting tagged with the default facility which is
used for the kernel.

Unfortunately:

  commit fd00f0e6c75b00c3d97be8670afcd9094b823855
  Author: Guido Günther <agx@sigxcpu.org>
  Date:   Mon Sep 21 20:06:55 2015 +0200

    Use daemon log facility for journald

used the LOG_nnn constants from the syslog header without realizing
that these values have a bit-shift applied. While Linux defines a
LOG_FAC() macros to undo the bit-shift this doesn't appear to be
standardized. So the safe thing is to just use the raw value since
these values are fixed by RFC 5424.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agodocs: coding-style: One variable declaration per line
Tim Wiederhake [Thu, 13 Jan 2022 16:53:25 +0000 (17:53 +0100)]
docs: coding-style: One variable declaration per line

This was not mentioned before.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agodocs: coding-style: Clarify on virXXXPtr types
Tim Wiederhake [Tue, 11 Jan 2022 16:10:43 +0000 (17:10 +0100)]
docs: coding-style: Clarify on virXXXPtr types

This partially reverts commit 9ccbed6afb.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agomanpages: libvirt-guests: Fix typos
Tim Wiederhake [Wed, 19 Jan 2022 10:08:13 +0000 (11:08 +0100)]
manpages: libvirt-guests: Fix typos

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
3 years agoqemu: simplify qemuProcessSetupRawIO
Ján Tomko [Thu, 13 Jan 2022 17:26:14 +0000 (18:26 +0100)]
qemu: simplify qemuProcessSetupRawIO

Remove the now unused 'driver' parameter, as well as the pointless
if (ret == 0) comparison which is always true after removing the
cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoutil: remove {Get,Set}UnprivSGIO
Ján Tomko [Thu, 13 Jan 2022 17:22:43 +0000 (18:22 +0100)]
util: remove {Get,Set}UnprivSGIO

These are no longer used.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoutil: remove virGetDeviceID
Ján Tomko [Thu, 13 Jan 2022 17:20:37 +0000 (18:20 +0100)]
util: remove virGetDeviceID

It was only used to construct the hash key for the (now removed)
shared devices in the qemu driver.

Remove it and its mocking.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoqemu: remove sharedDevices hash table
Ján Tomko [Thu, 13 Jan 2022 17:08:11 +0000 (18:08 +0100)]
qemu: remove sharedDevices hash table

Its only use was to check conflicts of the sgio attributes between
devices shared with other domains.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoqemu: remove all use of SGIO
Ján Tomko [Thu, 13 Jan 2022 16:47:03 +0000 (17:47 +0100)]
qemu: remove all use of SGIO

Now that the 'unfiltered' attribute is rejected by the validator,
remove all the code that deals with the feature.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoconf: reject unfiltered sgio on validation
Ján Tomko [Thu, 13 Jan 2022 13:04:49 +0000 (14:04 +0100)]
conf: reject unfiltered sgio on validation

No kernels supported by upstream libvirt have the feature.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoutil: remove virGetUnprivSGIOSysfsPath
Ján Tomko [Thu, 13 Jan 2022 12:09:31 +0000 (13:09 +0100)]
util: remove virGetUnprivSGIOSysfsPath

unpriv_sgio was a downstream-only feature in RHEL 6-8.
The libvirt support was merged upstream by mistake.

Remove the function that constructs the sysfs path and assume it
does not exist in all the callers.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoqemu: remove support for transitional virtio-input-host
Ján Tomko [Tue, 18 Jan 2022 15:01:04 +0000 (16:01 +0100)]
qemu: remove support for transitional virtio-input-host

virtio-input is virtio-1.0 only and these models have been only present
in one upstream QEMU release, then removed by:

      commit d923e30578a65392e50e530e3a29b2edf5c51c5b
          virtio-input-host-pci: cleanup types

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoqemu: remove support for transitional virtio-input-host
Ján Tomko [Tue, 18 Jan 2022 17:03:55 +0000 (18:03 +0100)]
qemu: remove support for transitional virtio-input-host

This device was virtio 1.0-only so adding the (non-)transitional model
did not make sense and it was only present in QEMU 4.0.

Report a validation error for both of the users that will ever hit this
code path.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoqemu: capabilities: do not check for transitional input host
Ján Tomko [Tue, 18 Jan 2022 14:25:50 +0000 (15:25 +0100)]
qemu: capabilities: do not check for transitional input host

The (non-)transitional version of this device was only present in
one upstream QEMU release (4.0), then removed by:

  commit d923e30578a65392e50e530e3a29b2edf5c51c5b
      virtio-input-host-pci: cleanup types

Remove them from probing as well, since they are unlikely to be found.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoutil: openvswitch: do not reuse cmd in InterfaceClearTxQos
Ján Tomko [Mon, 17 Jan 2022 16:33:39 +0000 (17:33 +0100)]
util: openvswitch: do not reuse cmd in InterfaceClearTxQos

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: openvswitch: do not reuse cmd in InterfaceSetTxQos
Ján Tomko [Mon, 17 Jan 2022 16:28:44 +0000 (17:28 +0100)]
util: openvswitch: do not reuse cmd in InterfaceSetTxQos

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: openvswitch: split out virNetDevOpenvswitchInterfaceSetRxQos
Ján Tomko [Mon, 17 Jan 2022 16:20:42 +0000 (17:20 +0100)]
util: openvswitch: split out virNetDevOpenvswitchInterfaceSetRxQos

The virNetDevOpenvswitchInterfaceSetQos function is uneven
because setting the Rx Qos is open-coded, while clearing it
is sepearated in another function.

Separate the setting too.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: openvswitch: split out virNetDevOpenvswitchInterfaceSetTxQos
Ján Tomko [Mon, 17 Jan 2022 16:13:12 +0000 (17:13 +0100)]
util: openvswitch: split out virNetDevOpenvswitchInterfaceSetTxQos

The virNetDevOpenvswitchInterfaceSetQos function is uneven
because setting the Tx Qos is open-coded, while clearing it
is sepearated in another function.

Separate the setting too.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: openvswitch: unexport InterfaceClear{Rx,Tx}Qos
Ján Tomko [Mon, 17 Jan 2022 15:39:20 +0000 (16:39 +0100)]
util: openvswitch: unexport InterfaceClear{Rx,Tx}Qos

This also removes the indentation error.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: openvswitch: move InterfaceClear{Rx,Tx}Qos
Ján Tomko [Mon, 17 Jan 2022 15:37:50 +0000 (16:37 +0100)]
util: openvswitch: move InterfaceClear{Rx,Tx}Qos

These functions are called by virNetDevOpenvswitchInterfaceSetQos
as well as virNetDevOpenvswitchInterfaceClearQos.

Move them above both fuctions.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: Stop storing dnsmasq version
Andrea Bolognani [Mon, 17 Jan 2022 16:31:52 +0000 (17:31 +0100)]
util: Stop storing dnsmasq version

We don't do anything with it after checking that it satisfies our
requirements and don't provide a way for users of the module to
access it, so carrying it around is pointless.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agospec: Drop BuildRequires on dnsmasq
Andrea Bolognani [Mon, 17 Jan 2022 16:27:52 +0000 (17:27 +0100)]
spec: Drop BuildRequires on dnsmasq

It's been an optional build time dependency for a long time, so
if Meson couldn't find it the only consequence was that libvirt
would look for it at runtime instead, which is what we are doing
for most of our non-library dependencies anyway.

Since 5c98d1cee0be we've stopped even looking for it at build
time, so there's no point in having it installed in the build
environment.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirdnsmasq: Join dnsmasqCapsNewEmpty() and dnsmasqCapsNewFromBinary()
Michal Privoznik [Wed, 12 Jan 2022 04:58:39 +0000 (05:58 +0100)]
virdnsmasq: Join dnsmasqCapsNewEmpty() and dnsmasqCapsNewFromBinary()

After previous cleanups, there's just one caller of
dnsmasqCapsNewEmpty() and it is dnsmasqCapsNewFromBinary().
And the former is pretty short. Therefore, it is not necessary
for the code to live in two separate functions. Dissolve the
former in the latter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirdnsmasq: Drop dnsmasqCapsNewFromBuffer()
Michal Privoznik [Wed, 12 Jan 2022 04:56:42 +0000 (05:56 +0100)]
virdnsmasq: Drop dnsmasqCapsNewFromBuffer()

The function is no longer used. Remove it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agonetworkxml2conftest: Check if capabilities were created successfully
Michal Privoznik [Mon, 17 Jan 2022 12:14:45 +0000 (13:14 +0100)]
networkxml2conftest: Check if capabilities were created successfully

Now that looking up dnsmasq is handled/mocked we can start
checking whether dnsmasq capabilities were built successfully and
error out if that wasn't the case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agonetworkxml2conftest: Use dnsmasqCapsNewFromBinary() to construct caps
Michal Privoznik [Wed, 12 Jan 2022 04:42:41 +0000 (05:42 +0100)]
networkxml2conftest: Use dnsmasqCapsNewFromBinary() to construct caps

DISCLAIMER: dnsmasq capabilities are empty as of v8.0.0-rc1~145.

In a real environment the dnsmasq capabilities are constructed
using dnsmasqCapsNewFromBinary(). We also have
dnsmasqCapsNewFromBuffer() to bypass checks that real code is
doing and just get capabilities object. The latter is used from
test suite.

However, with a little bit of mocking we can test the real life
code. All that's needed is to simulate dnsmasq's output for
--version and --help and mock a stat() that's done in
dnsmasqCapsRefreshInternal().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirdnsmasq: Require non NULL @caps in dnsmasqCapsGetBinaryPath()
Michal Privoznik [Mon, 10 Jan 2022 15:25:18 +0000 (16:25 +0100)]
virdnsmasq: Require non NULL @caps in dnsmasqCapsGetBinaryPath()

First observation: There is no way that caps->binaryPath can be
NULL. Second observation: There is no caller that passes NULL.
Let's drop the ternary operator and access @caps directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirdnsmasq: Lookup DNSMASQ in PATH
Michal Privoznik [Mon, 10 Jan 2022 15:19:31 +0000 (16:19 +0100)]
virdnsmasq: Lookup DNSMASQ in PATH

While it's true that our virCommand subsystem is happy with
non-absolute paths, the dnsmasq capability code is not. It stores
the path to dnsmasq within and makes it accessible via
dnsmasqCapsGetBinaryPath(). While strictly speaking no caller
necessarily needs canonicalized path, let's find dnsmasq once and
cache the result.

Therefore, when constructing the capabilities structure look up
the binary path. If DNSMASQ already contains an absolute path
then virFindFileInPath() will simply return a copy.

With this code in place, the virFileIsExecutable() check can be
removed from dnsmasqCapsRefreshInternal() because
virFindFileInPath() already made sure the binary is executable.

But introducing virFindFileInPath() means we have to mock it in
test suite because dnsmasqCaps are created in
networkxml2conftest.

Moreover, we don't need to check for dnsmasq in configure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirdnsmasq: Don't run 'dnsmasq --help'
Michal Privoznik [Mon, 17 Jan 2022 12:22:09 +0000 (13:22 +0100)]
virdnsmasq: Don't run 'dnsmasq --help'

We don't query any capabilities of dnsmasq. We are only
interested in dnsmasq's version (obtained via 'dnsmasq
--version'). Therefore, there's no point in running 'dnsmasq
--help'. Its output is not processed even.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirdnsmasq: Drop !caps check from dnsmasqCapsRefreshInternal()
Michal Privoznik [Mon, 17 Jan 2022 12:20:50 +0000 (13:20 +0100)]
virdnsmasq: Drop !caps check from dnsmasqCapsRefreshInternal()

There is no way that the dnsmasqCapsRefreshInternal() function
can be called with @caps == NULL. Therefore, drop the if() that
checks for that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirdnsmasq: Drop noRefresh member from from struct _dnsmasqCaps
Michal Privoznik [Mon, 17 Jan 2022 12:20:32 +0000 (13:20 +0100)]
virdnsmasq: Drop noRefresh member from from struct _dnsmasqCaps

The noRefresh member of _dnsmasqCaps struct is set only after it
was checked for and is never checked again. This is needless and
the member can be removed. There is no way that
dnsmasqCapsRefreshInternal() can be called after
dnsmasqCapsSetFromBuffer().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirdnsmasq: Drop mtime member from struct _dnsmasqCaps
Michal Privoznik [Mon, 17 Jan 2022 12:19:26 +0000 (13:19 +0100)]
virdnsmasq: Drop mtime member from struct _dnsmasqCaps

The _dnsmasqCaps struct has @mtime member which holds the mtime
of the dnsmasq binary. The idea was that capabilities don't need
to be queried if mtime hasn't changed since the last time.
However, the code that would try to query capabilities again was
removed and now we are left with code that stores mtime but has
no use for it.

Remove the member and code that uses it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirdnsmasq: Drop @force argument of dnsmasqCapsRefreshInternal()
Michal Privoznik [Mon, 17 Jan 2022 12:17:42 +0000 (13:17 +0100)]
virdnsmasq: Drop @force argument of dnsmasqCapsRefreshInternal()

This argument is not used really as the only caller passes true
and dnsmasqCapsRefreshInternal() only checks for false value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agolib: Prefer g_autoptr(dnsmasqCaps) instead of explicit unref
Michal Privoznik [Tue, 11 Jan 2022 15:51:32 +0000 (16:51 +0100)]
lib: Prefer g_autoptr(dnsmasqCaps) instead of explicit unref

The dnsmasqCaps type has its own cleanup function defined and
ready to use via g_autoptr(). Use automatic cleanup instead of
an explicit one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirdnsmasq: Drop @binaryPath argument from dnsmasqCapsNewEmpty()
Michal Privoznik [Mon, 10 Jan 2022 15:15:29 +0000 (16:15 +0100)]
virdnsmasq: Drop @binaryPath argument from dnsmasqCapsNewEmpty()

Both callers of dnsmasqCapsNewEmpty() pass DNSMASQ as an argument
which is then fed to a ternary operator which looks like this
(after substitution).

  DNSMASQ ? DNSMASQ : DNSMASQ

While I like tautologies, the code can be simplified by dropping
the argument.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoqemuDomainPinIOThread: Update live definition after process pinning
Peter Krempa [Tue, 18 Jan 2022 09:08:03 +0000 (10:08 +0100)]
qemuDomainPinIOThread: Update live definition after process pinning

Otherwise we'll keep using the new pinning value even if it can't be
applied to the thread.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2040555
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agoqemuDomainPinIOThread: Copy the cpu bitmap instead of re-parsing it
Peter Krempa [Tue, 18 Jan 2022 09:06:38 +0000 (10:06 +0100)]
qemuDomainPinIOThread: Copy the cpu bitmap instead of re-parsing it

The bitmap recorded in the live/persistent definition was re-parsed two
more times. We can copy it which is cheaper and less verbose.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agoqemu: Log which API is trying to acquire a job
Jiri Denemark [Tue, 11 Jan 2022 09:28:43 +0000 (10:28 +0100)]
qemu: Log which API is trying to acquire a job

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoNEWS: mention removal of sysconfig
Olaf Hering [Wed, 12 Jan 2022 10:45:09 +0000 (11:45 +0100)]
NEWS: mention removal of sysconfig

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agoremove sysconfig files
Olaf Hering [Wed, 12 Jan 2022 10:45:08 +0000 (11:45 +0100)]
remove sysconfig files

sysconfig files are owned by the admin of the host. They have the
liberty to put anything they want into these files. This makes it
difficult to provide different built-in defaults.

Remove the sysconfig file and place the current desired default into
the service file.

Local customizations can now go either into /etc/sysconfig/name
or /etc/systemd/system/name.service.d/my-knobs.conf

Attempt to handle upgrades in libvirt.spec.
Dirty files which are marked as %config will be renamed to file.rpmsave.
To restore them automatically, move stale .rpmsave files away, and
catch any new rpmsave files in %posttrans.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agodocs: domain: document legacy audio for qemu
Olaf Hering [Wed, 12 Jan 2022 12:42:00 +0000 (13:42 +0100)]
docs: domain: document legacy audio for qemu

Adding a blurb like this was forgotten in 2009.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agodocs: Add man page for libvirt-guests
Jim Fehlig [Fri, 7 Jan 2022 21:35:10 +0000 (14:35 -0700)]
docs: Add man page for libvirt-guests

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agobuild: Only install libvirt-guests when building libvirtd
Jim Fehlig [Mon, 10 Jan 2022 18:42:58 +0000 (11:42 -0700)]
build: Only install libvirt-guests when building libvirtd

libvirt-guests was already moved to the libvirt daemon package in commit
d800c50349. It only needs to be installed when building libvirtd.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agotestutils: Terminate usage string with a new line
Michal Privoznik [Mon, 17 Jan 2022 15:46:46 +0000 (16:46 +0100)]
testutils: Terminate usage string with a new line

If a test binary is executed with an argument then usage
information is printed out (that no arguments are accepted and
what environment variables affect execution). The string is
printed onto stderr but it is not terminated with a newline
character producing not so nice output.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoexamples: drop some conditionals checks from macros
Daniel P. Berrangé [Fri, 14 Jan 2022 10:34:43 +0000 (10:34 +0000)]
examples: drop some conditionals checks from macros

We no longer need to worry about GCC version older than 7.4.0. The other
remaining conditionals checks were also overkill for the example code.
In the unlikely event that someone tries to re-use the code in a
scenario where further conditions apply they can figure out.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoconfigure: bump min required CLang to 6.0 / XCode 10.0
Daniel P. Berrangé [Wed, 12 Jan 2022 16:51:33 +0000 (16:51 +0000)]
configure: bump min required CLang to 6.0 / XCode 10.0

Several distros have been dropped since the last time we bumped the
minimum required CLang version.

Per repology, currently shipping versions are:

             RHEL-8: 10.0.1
      Debian Buster: 7.0.1
 openSUSE Leap 15.2: 9.0.1
   Ubuntu LTS 18.04: 6.0.0
   Ubuntu LTS 20.04: 10.0.0
         FreeBSD 12: 8.0.1
          Fedora 33: 11.0.0
          Fedora 34: 11.1.0

With this list Ubuntu LTS 18.04 is the constraint at 6.0.0

An LLVM version of 6.0.0 corresponds to macOS XCode version of 10.0
which dates from Sept 2018.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoconfigure: bump min required GCC to 7.4.0
Daniel P. Berrangé [Wed, 12 Jan 2022 16:47:17 +0000 (16:47 +0000)]
configure: bump min required GCC to 7.4.0

Several distros have been dropped since the last time we bumped the
minimum required GCC version.

Per repology, currently shipping versions are:

                 RHEL-8: 8.3.1
          Debian Buster: 8.3.0
     openSUSE Leap 15.2: 7.5.0
       Ubuntu LTS 18.04: 7.5.0
       Ubuntu LTS 20.04: 9.3.0
                FreeBSD: 10.3.0
              Fedora 33: 9.2.0
              Fedora 34: 11.0.1
                OpenBSD: 8.4.0
         macOS HomeBrew: 11.1.0

With this list Ubuntu LTS 18.04 / openSUSE Leap 15.2 are the
constraint at 7.5.0.

When QEMU bumped GCC to 7.5.0, however, it was reported that
this is a problem for NetBSD which still ships 7.4.0.

NetBSD is not an officially targetted platform for libvirt.
Given that QEMU saw complaints about this and the feature
difference between GCC 7.4.0 and 7.5.0 is minor, I'm being
friendly and sticking 7.4.0.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agodocs: coding-style: Remove "no_memory" as acceptable goto target
Tim Wiederhake [Thu, 13 Jan 2022 16:13:58 +0000 (17:13 +0100)]
docs: coding-style: Remove "no_memory" as acceptable goto target

There are no instances of that label left.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agodocs: coding-style: Rewrite section on shortening comparisons
Tim Wiederhake [Thu, 13 Jan 2022 16:01:52 +0000 (17:01 +0100)]
docs: coding-style: Rewrite section on shortening comparisons

The code style showed `bool hasFoos; if (hasFoos == true)` as a
good example in one place, only to warn against comparisons with
`true` a couple of paragraphs further down.

Merge this advice on comparing with `true` into the "Conditional
expressions" section and split the example up for readability.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: Remove needless labels
Michal Privoznik [Fri, 14 Jan 2022 13:05:52 +0000 (14:05 +0100)]
virsh: Remove needless labels

There are few places where a cleanup label contains nothing but a
return statement. Drop such labels and return directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolibxl: Remove needless labels
Michal Privoznik [Fri, 14 Jan 2022 12:49:54 +0000 (13:49 +0100)]
libxl: Remove needless labels

After previous cleanups some labels are needless: they contain
nothing but a return statement. Drop such labels and return
directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoxen_xl.c: Use g_autoptr() for virCPUDef
Michal Privoznik [Fri, 14 Jan 2022 08:37:29 +0000 (09:37 +0100)]
xen_xl.c: Use g_autoptr() for virCPUDef

In xenParseXLVnuma() the @cpu variable is freed explicitly.
However, when switched to g_autoptr(virCPUDef) the explicit call
can be removed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoxen_xl.c: Use g_autofree more
Michal Privoznik [Fri, 14 Jan 2022 08:37:26 +0000 (09:37 +0100)]
xen_xl.c: Use g_autofree more

There are few places inside src/libxl/xen_xl.c that can benefit
from g_autofree. Let them use automatic memory freeing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolibxl: Allocate @libxldisk in xenParseXLDisk() on stack
Michal Privoznik [Fri, 14 Jan 2022 08:51:39 +0000 (09:51 +0100)]
libxl: Allocate @libxldisk in xenParseXLDisk() on stack

In xenParseXLDisk() the @libxldisk variable (which is type of
libxl_device_disk) is allocated on heap. But this is not
necessary as nothing in the function needs that approach.

Allocate the variable on the stack and drop corresponding
VIR_FREE() call.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolibxl: Don't use a static buffer in xenParseXLVnuma()
Michal Privoznik [Fri, 14 Jan 2022 08:36:21 +0000 (09:36 +0100)]
libxl: Don't use a static buffer in xenParseXLVnuma()

The xenParseXLVnuma() function is responsible for parsing 'vnuma'
part of XL config and setting corresponding values in
virDomainDef. While doing so it uses a static buffer which is set
to data we are interested in and then parsing the buffer further
(e.g. string to integer conversion, bitmap parsing, and so on).
Well, the data we are interested in are already in a string
(@data) which can be used directly rendering this intermediary
buffer needless.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirconf: Make virConfSetValue() clear consumed pointer
Michal Privoznik [Fri, 14 Jan 2022 09:11:42 +0000 (10:11 +0100)]
virconf: Make virConfSetValue() clear consumed pointer

The way that virConfSetValue() works (and the way it is even
documented) is that the @value pointer is always consumed.
However, since the first order pointer is passed it leaves
callers in a pickle situation - they always have to set pointer
to NULL after calling virConfSetValue() to avoid touching it.

Let's switch @value to a double pointer and clear it inside the
function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agosrc: Declare and use g_autoptr(virConfValue)
Michal Privoznik [Fri, 14 Jan 2022 09:28:52 +0000 (10:28 +0100)]
src: Declare and use g_autoptr(virConfValue)

This commit declares g_autoptr() function for virConfValue type.
At the same time, it switches variable declarations to use it.
Also, in a few places we might have freed a variable twice, for
instance in xenFormatXLDomainNamespaceData(). This is because
virConfSetValue() consumes passed pointer (@value) even in case
of failure and thus any code that uses virConfSetValue() must
refrain from touching @value and it must not call
virConfFreeValue().

This semantic is not obvious and will be addressed in one of
future commits.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoxen_xl: Check for virConfSetValue() retval
Michal Privoznik [Fri, 14 Jan 2022 09:36:42 +0000 (10:36 +0100)]
xen_xl: Check for virConfSetValue() retval

There's one case where the return value of virConfSetValue() is
not checked for and it's in xenFormatXLInputDevs() function.
Let's fix that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirconf: Report an error in when virConfSetValue() fails
Michal Privoznik [Fri, 14 Jan 2022 09:35:17 +0000 (10:35 +0100)]
virconf: Report an error in when virConfSetValue() fails

Callers of virConfSetValue() don't report any error, they just
pass the error blindly. Therefore, report an error when
virConfSetValue() is about to fail.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agostorage_file: Declare virStorageSourceParseRBDColonString only in one header
Michal Privoznik [Fri, 7 Jan 2022 13:10:03 +0000 (14:10 +0100)]
storage_file: Declare virStorageSourceParseRBDColonString only in one header

The virStorageSourceParseRBDColonString() function is declared in
src/storage_file/storage_source.h and
src/storage_file/storage_source_backingstore.h but implemented
only in the .c that corresponds to the latter header file.
Therefore, drop declaration from storage_source.h as the function
is not implemented in its corresponding .c file.

Leftover from: 2d29a3a9d86b5f95a859888283e6caa98593b1d2
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: capabilities: Re-enable JSON syntax for -device
Peter Krempa [Thu, 13 Jan 2022 15:59:56 +0000 (16:59 +0100)]
qemu: capabilities: Re-enable JSON syntax for -device

Now that qemu fixed device unplug when JSON syntax is used with -device
we can re-enable the feature.

Since the old capability string representation is condemned by
suggesting filtering it as a workaround we must introduce a new string.
To achieve this the original capability position is renamed to
X_QEMU_CAPS_DEVICE_JSON_BROKEN_HOTPLUG and a new position with the
original name QEMU_CAPS_DEVICE_JSON is introduced to prevent us having
to change the rest of the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agotests: qemucapabilities: Add test data for the qemu-7.0 development cycle
Peter Krempa [Thu, 13 Jan 2022 14:50:10 +0000 (15:50 +0100)]
tests: qemucapabilities: Add test data for the qemu-7.0 development cycle

Update to commit v6.2.0-874-g1cd2ad11d3

Notable changes are:
- added flag noting that use of JSON syntax for -device was fixed
- 'dbus' backend for graphics and character devices added
- virtio-mem added 'node' property
- 'clusters' added to CPU topology
- 'open-timeout' property for NBD protocol backend
- 'wheel-left' and 'wheel-right' event types for 'input-send-event'
- increased default resolution to '1280x800' on 'virtio-gpu'
- SGX property 'section-size' changed to 'sections' incompatibly
  (unused luckily)

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2(argv|xml)data: x86-kvm-32-on-64: Add machine type
Peter Krempa [Thu, 13 Jan 2022 15:14:42 +0000 (16:14 +0100)]
qemuxml2(argv|xml)data: x86-kvm-32-on-64: Add machine type

The machine type doesn't change the test result and prevents tests being
changed every time we are about to update real capabilities to a new
qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agotests: Report expected monitor command for simulated commands
Michal Privoznik [Tue, 30 Nov 2021 17:16:32 +0000 (18:16 +0100)]
tests: Report expected monitor command for simulated commands

There are two tests currently that simulate QMP talk:
qemucapabilitiestest and qemuhotplugtest. In both cases they
check whether currently executed command is the one for which
reply was provided. If not an error message is reported. However,
the error message contains only the actual command and not the
expected one. This makes it harder to navigate through .replies
files.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Fri, 14 Jan 2022 22:16:33 +0000 (23:16 +0100)]
Translated using Weblate (Swedish)

Currently translated at 30.5% (3191 of 10455 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
3 years agoqemu: split handling of distinct firmware enum conversions
Daniel P. Berrangé [Mon, 10 Jan 2022 18:03:42 +0000 (13:03 -0500)]
qemu: split handling of distinct firmware enum conversions

The qemuFirmwareOSInterfaceTypeFromOsDefFirmware method
was added to convert from virDomainOsDefFirmware to the
qemuFirmwareOSInterface enum.

It was later also used to convert from virDomainLoader
to qemuFirmwareOSInterface in:

  commit 8e1804f9f66f13ca1412d22bf1a957b6d55a2365
  Author: Michal Prívozník <mprivozn@redhat.com>
  Date:   Tue Dec 17 17:45:50 2019 +0100

    qemu_firmware: Try to autofill for old style UEFI specification

This caused compile errors with clang due to passing a
mis-matched enum type. These were later silenced by
stripping the enum types:

  commit 8fcee47807d29008632a7ad918cbe93ac0a20597
  Author: Michal Prívozník <mprivozn@redhat.com>
  Date:   Wed Jan 8 09:42:47 2020 +0100

    qemu_firmware: Accept int in qemuFirmwareOSInterfaceTypeFromOsDefFirmware()

This is still rather confusing to humans reading the
code. It is clearer to just define a separate helper
method for the virDomainLoader type conversion.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agodocs: use virYesNo definition in more schemas
Daniel P. Berrangé [Mon, 10 Jan 2022 11:08:01 +0000 (11:08 +0000)]
docs: use virYesNo definition in more schemas

A few places are still using an expend yes/no choice instead of the
common virYesNo definition.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agodocs: split example for <os> schema
Daniel P. Berrangé [Mon, 10 Jan 2022 10:49:19 +0000 (10:49 +0000)]
docs: split example for <os> schema

The docs illustration for the <os> schema contains a mixture of
incompatible configuration options. This is rather confusing and
misleading to users. Splitting the illustration into four separate
examples clarifies the situation.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agomeson: Detect rst2html5 and rst2man only when needed
Ivan Teterevkov [Thu, 13 Jan 2022 08:40:56 +0000 (08:40 +0000)]
meson: Detect rst2html5 and rst2man only when needed

Detect these commands in docs/meson.build, i.e. only when
users enable documentation.

Signed-off-by: Ivan Teterevkov <ivan.teterevkov@nutanix.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agovirDomainSnapshotRedefinePrep: Don't do partial redefine
Peter Krempa [Wed, 12 Jan 2022 16:00:22 +0000 (17:00 +0100)]
virDomainSnapshotRedefinePrep: Don't do partial redefine

'virDomainSnapshotRedefinePrep' does everything needed for a redefine
when the snapshot exists but not when we are defining metadata for a new
snapshot. This gives us weird semantics.

Extract the code for replacing the definition of an existing snapshot
into a new helper 'virDomainSnapshotReplaceDef' and refactor all
callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainSnapshotAssignDef: Clear second argument when it is consumed
Peter Krempa [Wed, 12 Jan 2022 14:52:04 +0000 (15:52 +0100)]
virDomainSnapshotAssignDef: Clear second argument when it is consumed

Rather than callers second-guessing when the snapshot definition is
assigned turn it into a double pointer and clear it on success.

Fix callers to work with the new semantics.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainSnapshotLoad: Refactor handling of snapshot definition object
Peter Krempa [Wed, 12 Jan 2022 15:40:03 +0000 (16:40 +0100)]
qemuDomainSnapshotLoad: Refactor handling of snapshot definition object

Move the variable holding the snapshot definition into the loop and use
automatic clearing for it. Adjust the code for parity.

Note that the clearing of 'snapdef' on success of
'virDomainSnapshotAssignDef' will be refactored in upcoming patches.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuSnapshotCreate: Standardize handling of the reference on @snapdef
Peter Krempa [Wed, 12 Jan 2022 15:35:01 +0000 (16:35 +0100)]
qemuSnapshotCreate: Standardize handling of the reference on @snapdef

As with qemuSnapshotRedefine, make an extra reference in a temporary
autocleaned variable and use that instead of refing the definition after
it's stolen.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuSnapshotCreate: Use 'snapdef' instead of 'def'
Peter Krempa [Wed, 12 Jan 2022 15:12:27 +0000 (16:12 +0100)]
qemuSnapshotCreate: Use 'snapdef' instead of 'def'

'def' is commonly used for domain definition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agotestDomainSnapshotCreateXML: Extract snapshot redefinition code
Peter Krempa [Wed, 12 Jan 2022 14:40:55 +0000 (15:40 +0100)]
testDomainSnapshotCreateXML: Extract snapshot redefinition code

The test driver code was copied from qemu but wasn't refactored
recently. Split out the redefinition code similarly to what qemu driver
did.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainSnapshotRedefineValidate: Don't modify the snapshot definition
Peter Krempa [Wed, 12 Jan 2022 14:08:25 +0000 (15:08 +0100)]
virDomainSnapshotRedefineValidate: Don't modify the snapshot definition

It is not expected that a function with 'Validate' in the name actually
modifies the validated object, even worse when it even modifies another
object and the ultimatively worst bit is that it doesn't undo the mess
if the validation fails midway.

Move the stealing of the domain definition from the definition of a
snapshot being redefined into the caller along with the call to
virDomainSnapshotAlignDisks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainSnapshotRedefinePrep: Use 'snapdef' for snapshot definition object
Peter Krempa [Wed, 12 Jan 2022 13:56:04 +0000 (14:56 +0100)]
virDomainSnapshotRedefinePrep: Use 'snapdef' for snapshot definition object

We use this variable name to distinguish it from the domain definition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainSnapshotRedefineValidate: Unexport
Peter Krempa [Wed, 12 Jan 2022 13:28:21 +0000 (14:28 +0100)]
virDomainSnapshotRedefineValidate: Unexport

The function isn't used outside of src/conf/snapshot_conf.c as of
57d252c74

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainSnapshotAlignDisks: Allow alternate domain definition when redefining
Peter Krempa [Wed, 12 Jan 2022 13:20:04 +0000 (14:20 +0100)]
virDomainSnapshotAlignDisks: Allow alternate domain definition when redefining

Due to historical reasons we allow users to redefine an existing
snapshot without providing the domain definition which would correspond
to it. In such case we'd use the domain definition from the snapshot
that is being redefined.

To prevent callers from doing complex moving of the domain definition
object back and forth between the snapshot definitions we can add an
argument to virDomainSnapshotAlignDisks which will allow us to pass in
the alternate definition if the one from the snapshot is missing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainSnapshotAlignDisks: Move 'require_match' selection logic inside
Peter Krempa [Wed, 12 Jan 2022 12:49:44 +0000 (13:49 +0100)]
virDomainSnapshotAlignDisks: Move 'require_match' selection logic inside

'require_match' set to true is only needed for internal snapshots taken
by hypervisors (qemu) which don't have a way to control which disks take
part in the snapshot (savevm).

To de-clutter callers we can change the argument to mean 'this code path
requires uniform snapshot for internal snapshots'.

Change the argument and fix the callers. For now all callers pass 'true'
but any new hypervisor or even usage in qemu is not going to share the
limitation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainSnapshotAlignDisks: Convert @default_snapshot to virDomainSnapshotLocation
Peter Krempa [Wed, 12 Jan 2022 11:52:16 +0000 (12:52 +0100)]
virDomainSnapshotAlignDisks: Convert @default_snapshot to virDomainSnapshotLocation

Use the appropriate type for the variable and fix all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainSnapshotAlignDisks: Improve function comment
Peter Krempa [Wed, 12 Jan 2022 11:46:19 +0000 (12:46 +0100)]
virDomainSnapshotAlignDisks: Improve function comment

Add description of arguments, reword the description for clarity, and
fix improper argument names mentioned in the existing description.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainSnapshotRedefineValidate: Fix validation of VIR_DOMAIN_SNAPSHOT_CREATE_DISK_...
Peter Krempa [Wed, 12 Jan 2022 10:02:49 +0000 (11:02 +0100)]
virDomainSnapshotRedefineValidate: Fix validation of VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY flag

External snapshot with memory is created without using the
VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY flag, but rather with properly
configuring the XML. When redefining the code should be checking the
same thing as by definition an external snapshot with memory is not a
disk-only snapshot.

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