]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
4 years agoconf: Introduce <metadata_cache> subelement of <disk><driver>
Peter Krempa [Wed, 6 Jan 2021 17:20:22 +0000 (18:20 +0100)]
conf: Introduce <metadata_cache> subelement of <disk><driver>

In certain specific cases it might be beneficial to be able to control
the metadata caching of storage image format drivers of a hypervisor.

Introduce XML machinery to set the maximum size of the metadata cache
which will be used by qemu's qcow2 driver.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainSnapshotDiskDefFormat: Use virXMLFormatElement
Peter Krempa [Thu, 7 Jan 2021 14:03:57 +0000 (15:03 +0100)]
virDomainSnapshotDiskDefFormat: Use virXMLFormatElement

Refactor the code to use modern XML formatting approach.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDomainDiskDefFormatDriver: Rename 'driverBuf' to 'attrBuf'
Peter Krempa [Wed, 6 Jan 2021 21:34:57 +0000 (22:34 +0100)]
virDomainDiskDefFormatDriver: Rename 'driverBuf' to 'attrBuf'

Unify the code with other places using virXMLFormatElement.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: Add tests for NFS disk protocol
Ryan Gahagan [Wed, 6 Jan 2021 21:32:32 +0000 (15:32 -0600)]
tests: Add tests for NFS disk protocol

Signed-off-by: Ryan Gahagan <rgahagan@cs.utexas.edu>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil: virstoragefile: Add 'json:' pseudo-protocol parser for 'nfs' protocol
Ryan Gahagan [Wed, 6 Jan 2021 21:32:31 +0000 (15:32 -0600)]
util: virstoragefile: Add 'json:' pseudo-protocol parser for 'nfs' protocol

Enable parsing of backing store strings containing the native 'nfs'
protocol specification.

Signed-off-by: Ryan Gahagan <rgahagan@cs.utexas.edu>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: block: Add support for VIR_STORAGE_NET_PROTOCOL_NFS
Ryan Gahagan [Wed, 6 Jan 2021 21:32:30 +0000 (15:32 -0600)]
qemu: block: Add support for VIR_STORAGE_NET_PROTOCOL_NFS

Implement support for the 'nfs' native protocol driver in the qemu
driver.

QEMU accepts numeric UID/GID for 'nfs' protocol file driver thus libvirt
needs to perform the lookup prior to passing it to qemu.

Signed-off-by: Ryan Gahagan <rgahagan@cs.utexas.edu>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Add XML format/parse methods for VIR_STORAGE_NET_PROTOCOL_NFS
Ryan Gahagan [Wed, 6 Jan 2021 21:32:29 +0000 (15:32 -0600)]
conf: Add XML format/parse methods for VIR_STORAGE_NET_PROTOCOL_NFS

Signed-off-by: Ryan Gahagan <rgahagan@cs.utexas.edu>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agodocs: add rng schema and formatdomain docs for NFS
Ryan Gahagan [Wed, 6 Jan 2021 21:32:28 +0000 (15:32 -0600)]
docs: add rng schema and formatdomain docs for NFS

Add documentation and schema for the new disk transport protocol.

Signed-off-by: Ryan Gahagan <rgahagan@cs.utexas.edu>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil: Add fields for VIR_STORAGE_NET_PROTOCOL_NFS to virStorageSource
Ryan Gahagan [Wed, 6 Jan 2021 21:32:27 +0000 (15:32 -0600)]
util: Add fields for VIR_STORAGE_NET_PROTOCOL_NFS to virStorageSource

'nfs_user'/'nfs_group' represents the XML configuration.

'nfs_uid'/'nfs_gid' is internal store when libvirt looks up the user's
uid/gid in the system.

Signed-off-by: Ryan Gahagan <rgahagan@cs.utexas.edu>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Add VIR_STORAGE_NET_PROTOCOL_NFS disk protocol type
Ryan Gahagan [Wed, 6 Jan 2021 21:32:26 +0000 (15:32 -0600)]
conf: Add VIR_STORAGE_NET_PROTOCOL_NFS disk protocol type

Signed-off-by: Ryan Gahagan <rgahagan@cs.utexas.edu>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agostorage: volStorageBackendRBDRefreshVolInfo: refactor
Yi Li [Fri, 8 Jan 2021 06:44:31 +0000 (14:44 +0800)]
storage: volStorageBackendRBDRefreshVolInfo: refactor

use the ret variable for return value

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agostorageBackendCreatePloop: Refactor cleanup
Yi Li [Fri, 8 Jan 2021 06:14:22 +0000 (14:14 +0800)]
storageBackendCreatePloop: Refactor cleanup

Get rid of the 'cleanup' label and 'created' variable.

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoFix MinGW pipeline after 49cb59778a4e6c2d04bb9383a9d97fbbc83f9fce
Erik Skultety [Fri, 8 Jan 2021 10:33:44 +0000 (11:33 +0100)]
Fix MinGW pipeline after 49cb59778a4e6c2d04bb9383a9d97fbbc83f9fce

Broken build job: https://gitlab.com/libvirt/libvirt/-/jobs/951162206

Signed-off-by: Erik Skultety <eskultet@redhat.com>
4 years agocpu-gather: Rename the script as cpu-data.py
Jiri Denemark [Thu, 7 Jan 2021 17:48:41 +0000 (18:48 +0100)]
cpu-gather: Rename the script as cpu-data.py

It is now doing way more than gathering the CPU data from a host as the
other scripts were merged in it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocpu_map: Suggest better command for updating test data files
Jiri Denemark [Thu, 7 Jan 2021 18:48:51 +0000 (19:48 +0100)]
cpu_map: Suggest better command for updating test data files

cpu-cpuid.py was merged into cpu-gather.py and the script can handle
multiple files so there's no need for a loop around it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agocpu-gather: Remove redundant "processor" from CPU data file names
Jiri Denemark [Thu, 7 Jan 2021 17:47:27 +0000 (18:47 +0100)]
cpu-gather: Remove redundant "processor" from CPU data file names

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoschema: secret: Relax requirements for usage name
Peter Krempa [Wed, 6 Jan 2021 16:19:03 +0000 (17:19 +0100)]
schema: secret: Relax requirements for usage name

There's plenty of existing documentation [1] which shows as example a
name which contains a space and a dot ('client.admin secret') as ceph
usage name.

Use a more relaxed type in the RNG schema since the usage name is
actually just a string used to look up the secret.

[1]:
https://docs.ceph.com/en/latest/rbd/libvirt/#configuring-the-vm
https://documentation.suse.com/ses/6/html/ses-all/cha-ceph-libvirt.html#ceph-libvirt-cfg-vm
Libvirt docs were correct though:
https://libvirt.org/formatsecret.html#CephUsageType

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoschema: Add define for object names
Peter Krempa [Wed, 6 Jan 2021 15:51:21 +0000 (16:51 +0100)]
schema: Add define for object names

Objects such as domain, pool, etc re-define the regex for the format.
Add more generic types for objects with/without a slash which we'll be
able to reuse also for other objects.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoschema: Remove workaround for bug in libxml2 2.7.6
Peter Krempa [Wed, 6 Jan 2021 10:27:50 +0000 (11:27 +0100)]
schema: Remove workaround for bug in libxml2 2.7.6

New libxml2 handles '\n' properly so the literal newline is not
necessary, because 2.9.1 is the minimum version we support.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoschema: domaincommon: Remove pointless 'choice' from 'inituser'/'initgroup'
Peter Krempa [Wed, 6 Jan 2021 16:12:03 +0000 (17:12 +0100)]
schema: domaincommon: Remove pointless 'choice' from 'inituser'/'initgroup'

'genericName' allows arbitrary numeric strings so using an explicit
'unsignedInt' choice is pointless. The elements take an username or a
uid which is prefixed by '+', both of which are covered by
'genericName'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirSecretLookupParseSecret: Use g_steal_pointer
Peter Krempa [Wed, 6 Jan 2021 14:59:59 +0000 (15:59 +0100)]
virSecretLookupParseSecret: Use g_steal_pointer

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agosecretXMLParseNode: Clean up freeing of memory
Peter Krempa [Wed, 6 Jan 2021 14:52:06 +0000 (15:52 +0100)]
secretXMLParseNode: Clean up freeing of memory

Use one variable per extracted property instead of reusing strings and
drop needless VIR_FREE calls.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirSecretDefParseUsage: Use g_autofree for type_str
Peter Krempa [Wed, 6 Jan 2021 14:51:26 +0000 (15:51 +0100)]
virSecretDefParseUsage: Use g_autofree for type_str

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuDomainSetBlockIoTune: Skip monitor call for empty cdrom
Peter Krempa [Thu, 7 Jan 2021 09:19:22 +0000 (10:19 +0100)]
qemuDomainSetBlockIoTune: Skip monitor call for empty cdrom

Similarly to startup of the VM qemu doesn't like setting throttling for
an empty drive. Just skip it since we do the correct thing once new
media is inserted.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/117
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Tested-by: Han Han <hhan@redhat.com>
4 years agoqemuDomainSetBlockIoTune: Remove old uninformative comment
Peter Krempa [Thu, 7 Jan 2021 09:15:51 +0000 (10:15 +0100)]
qemuDomainSetBlockIoTune: Remove old uninformative comment

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotestCompareXMLToArgvValidateSchema: Populate autoNodeset
Peter Krempa [Mon, 30 Nov 2020 17:48:53 +0000 (18:48 +0100)]
testCompareXMLToArgvValidateSchema: Populate autoNodeset

We create a new 'vm' so we must also fake the nodeset.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuBuildChrChardevStr: Rename 'flags' to 'cdevflags'
Peter Krempa [Mon, 30 Nov 2020 13:14:22 +0000 (14:14 +0100)]
qemuBuildChrChardevStr: Rename 'flags' to 'cdevflags'

The monitor code uses 'flags' for the flags of the monitor builder,
while in this function it's a different set of flags. All callers pass a
variable named 'cdevflags', so rename the argument to suit.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: qemuxml2argv: Don't check whether -netdev was QAPIfied repeatedly
Peter Krempa [Mon, 30 Nov 2020 13:01:05 +0000 (14:01 +0100)]
tests: qemuxml2argv: Don't check whether -netdev was QAPIfied repeatedly

Check once before looping through the args.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: json: Replace virJSONValueObjectSteal by virJSONValueObjectRemoveKey
Peter Krempa [Mon, 30 Nov 2020 13:59:38 +0000 (14:59 +0100)]
util: json: Replace virJSONValueObjectSteal by virJSONValueObjectRemoveKey

virJSONValueObjectRemoveKey can be used as direct replacement. Fix the
one caller and remove the duplicate function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorAddObject: Refactor cleanup
Peter Krempa [Mon, 30 Nov 2020 15:23:55 +0000 (16:23 +0100)]
qemuMonitorAddObject: Refactor cleanup

Remove freeing/clearing of @props as the function doesn't guarantee that
it happens on success, rename the variable hodling copy of the alias and
use g_autofree to automatically free it and remove the cleanup label as
well as 'ret' variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorAddObject: Fix semantics of @alias
Peter Krempa [Mon, 30 Nov 2020 15:21:18 +0000 (16:21 +0100)]
qemuMonitorAddObject: Fix semantics of @alias

The callers of qemuMonitorAddObject rely on the fact that @alias is
filled only when the object is added successfully. This is documented
but the code didn't behave like that.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorJSONMakeCommandInternal: Clear @arguments when stolen
Peter Krempa [Mon, 30 Nov 2020 14:34:56 +0000 (15:34 +0100)]
qemuMonitorJSONMakeCommandInternal: Clear @arguments when stolen

All callers of qemuMonitorJSONMakeCommandInternal will benefit from
making @arguments a double pointer and passing it to
virJSONValueObjectCreate directly which will clear it if it steals the
value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorJSONAddObject: Take double pointer for @props
Peter Krempa [Mon, 30 Nov 2020 14:32:14 +0000 (15:32 +0100)]
qemuMonitorJSONAddObject: Take double pointer for @props

Prepare for a refactor of qemuMonitorJSONMakeCommandInternal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotestQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities: refactor cleanup
Peter Krempa [Mon, 30 Nov 2020 14:29:49 +0000 (15:29 +0100)]
testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities: refactor cleanup

Use automatic memory freeing to remove the 'cleanup:' label and 'ret'
variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorJSONSetMigrationCapabilities: Refactor cleanup
Peter Krempa [Mon, 30 Nov 2020 14:27:44 +0000 (15:27 +0100)]
qemuMonitorJSONSetMigrationCapabilities: Refactor cleanup

Use automatic memory freeing and remove the 'cleanup' label and 'ret'
variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorSetMigrationCapabilities: Take double pointer for @caps
Peter Krempa [Mon, 30 Nov 2020 14:17:34 +0000 (15:17 +0100)]
qemuMonitorSetMigrationCapabilities: Take double pointer for @caps

This allows simplification of the callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMonitorJSONSetMigrationParams: Take double pointer for @params
Peter Krempa [Mon, 30 Nov 2020 14:17:34 +0000 (15:17 +0100)]
qemuMonitorJSONSetMigrationParams: Take double pointer for @params

This allows simplification of the caller as well as will enable a later
refactor of qemuMonitorJSONMakeCommandInternal.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohostdev: mdev: Lookup mdevs by sysfs path rather than mdev struct
Erik Skultety [Thu, 7 Jan 2021 15:53:21 +0000 (16:53 +0100)]
hostdev: mdev: Lookup mdevs by sysfs path rather than mdev struct

The lookup didn't do anything apart from comparing the sysfs paths
anyway since that's what makes each mdev unique.
The most ridiculous usage of the old logic was in
virHostdevReAttachMediatedDevices where in order to drop an mdev
hostdev from the list of active devices we first had to create a new
mdev and use it in the lookup call. Why couldn't we have used the
hostdev directly? Because the hostdev and mdev structures are
incompatible.

The way mdevs are currently removed is via a write to a specific sysfs
attribute. If you do it while the machine which has the mdev assigned
is running, the write call may block (with a new enough kernel, with
older kernels it would return a write error!) until the device
is no longer in use which is when the QEMU process exits.

The interesting part here comes afterwards when we're cleaning up and
call virHostdevReAttachMediatedDevices. The domain doesn't exist
anymore, so the list of active hostdevs needs to be updated and the
respective hostdevs removed from the list, but remember we had to
create an mdev object in the memory in order to find it in the list
first which will fail because the write to sysfs had already removed
the mdev instance from the host system.
And so the next time you try to start the same domain you'll get:

"Requested operation is not valid: mediated device <path> is in use by
driver QEMU, domain <name>"

Fixes: https://gitlab.com/libvirt/libvirt/-/issues/119
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agohostdev: Update mdev pointer reference after checking device type
Erik Skultety [Thu, 7 Jan 2021 15:48:40 +0000 (16:48 +0100)]
hostdev: Update mdev pointer reference after checking device type

We set the pointer to some garbage packed structure data without
knowing whether we were actually handling the type of device we
expected to be handling. On its own, this was harmless, because we'd
never use the pointer as we'd skip the device if it were not the
expected type. However, it's better to make the logic even more
explicit - we first check the device and only when we're sure we have
the expected type we then update the pointer shortcut.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: validate pcie_cap_pos != 0 in virDeviceHasPCIExpressLink()
Laine Stump [Wed, 6 Jan 2021 20:42:47 +0000 (15:42 -0500)]
util: validate pcie_cap_pos != 0 in virDeviceHasPCIExpressLink()

virDeviceHasPCIExpressLink() wasn't checking that pcie_cap_pos was
valid before attempting to use it, which could lead to reading the
byte at offset 0 + PCI_CAP_ID_EXP instead of [valid offset] +
PCI_CAP_ID_EXP. In particular, this could happen for "integrated" PCI
devices (those that are on the PCIe root complex). If it happened that
the byte from the wrong address had the "right" bit set, then it would
lead to us innappropriately believing that Express Link info was
available when it wasn't, and the node device driver would then log an
error like this:

  virPCIDeviceGetLinkCapSta:2754 :
  internal error: pci device 0000:00:18.0 is not a PCI-Express device

during a libvirtd restart. (this didn't ever occur until after
virPCIDeviceIsPCIExpress() was made more intelligent in commit
c00b6b1ae, which hasn't yet been in any official release)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agolxc: eliminate leaked and dangling pointers in virLXCProcessSetupInterfaceTap
Laine Stump [Wed, 6 Jan 2021 18:44:40 +0000 (13:44 -0500)]
lxc: eliminate leaked and dangling pointers in virLXCProcessSetupInterfaceTap

The two scenarios were found by Coverity after a seemingly-unrelated
change to virLXCProcessSetupInterfaceTap() (in commit ecfc2d5f43), and
explained by John Ferlan here:

https://www.redhat.com/archives/libvir-list/2020-December/msg00810.html

To re-explain:

a) On entry to virLXCProcessSetupInterfaceTap() if net->ifname != NULL
   then a copy of net->ifname is made into parentVeth, and a reference
   to *that* pointer is sent down to virNetDevVethCreate().

b) If parentVeth (aka net->ifname) is a template name (e.g. "blah%d"),
   then virNetDevVethCreate() calls virNetDevGenerateName(), and if
   virNetDevGenerateName() successfully generates a usable name
   (e.g. "blah27") then it will free the original template string
   (which is pointed to by net->ifname and by parentVeth), then
   replace the pointer in parentVeth with a pointer to the new
   string. Note that net->ifname still points to the now-freed
   template string.

c) returning back up to virLXCProcessSetupInterfaceTap(), we check if
   net->ifname == NULL - it *isn't* (still contains stale pointer to
   template string), so we don't replace it with the pointer to the new
   string that is in parentVeth.

d) Result: the new string is leaked once we return from
   virLXCProcessSetupInterfaceTap(), while there is a dangling pointer
   to the old string in net->ifname.

There is also a leak if there is a failure somewhere between steps (b)
and (c) above - the failure cleanup in virNetDevVethCreate() will only
free the newly-generated parentVeth string if the original pointer was
NULL (narrator: "It wasn't."). But it's a new string allocated by
virNetDevGenerateName(), not the original string from net->ifname, so
it really does need to be freed.

The solution is to make a copy of the entire original string into a
g_autofree pointer, then iff everything is successful we g_free() the
original net->ifname and replace it by stealing the string returned by
virNetDevVethCreate().

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agolxc: remove unnecessary call to virNetDevReserveName()
Laine Stump [Mon, 21 Dec 2020 01:35:02 +0000 (20:35 -0500)]
lxc: remove unnecessary call to virNetDevReserveName()

In all cases *except* when parsing status XML as libvirt is being
restarted, the XML parser will delete any manually specified interface
name (aka "<target dev='blah'/>" aka net->ifname) that could have been
generated by virNetDevGenerateName(). This means that during the setup
when a domain is being started (e.g. during
virLXCProcessSetupInterfaceTap()) it is pointless to call
virNetDevReserveName() with any setting of net->ifname that has come
from the XML parser - it is guaranteed to not fit the pattern of any
auto-generated name, and so the call is just a NOP anyway.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu_map: Define and enable Snowridge model
Tim Wiederhake [Wed, 6 Jan 2021 10:05:11 +0000 (11:05 +0100)]
cpu_map: Define and enable Snowridge model

Due to missing pdpe1gb support in the host CPU data, the CPU is still
incorrectly detected as Westmere-IBRS for host capabilities because we
don't have the option to disable features included in the base model
there.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu_map: Add support for split-lock-detect CPU feature
Tim Wiederhake [Wed, 6 Jan 2021 10:05:09 +0000 (11:05 +0100)]
cpu_map: Add support for split-lock-detect CPU feature

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu_map: Add support for core-capability CPU feature
Tim Wiederhake [Wed, 6 Jan 2021 10:05:07 +0000 (11:05 +0100)]
cpu_map: Add support for core-capability CPU feature

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu_map: Add support for fsrm CPU feature
Tim Wiederhake [Wed, 6 Jan 2021 10:05:06 +0000 (11:05 +0100)]
cpu_map: Add support for fsrm CPU feature

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocputestdata: Add test data for Snowridge
Tim Wiederhake [Wed, 6 Jan 2021 10:05:05 +0000 (11:05 +0100)]
cputestdata: Add test data for Snowridge

It's obvious the CPU model detection provides strange results, which
will be fixed by adding a new Snowridge CPU model few patches later.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agonetwork: Introduce mutex for bridge name generation
Michal Privoznik [Thu, 7 Jan 2021 14:51:02 +0000 (15:51 +0100)]
network: Introduce mutex for bridge name generation

When defining/creating a network the bridge name may be filled in
automatically by libvirt (if none provided in the input XML or
the one provided is a pattern, e.g. "virbr%d"). During the
bridge name generation process a candidate name is generated
which is then checked with the rest of already defined/running
networks for collisions.

Problem is, that there is no mutex guarding this critical section
and thus if two threads line up so that they both generate the
same candidate they won't find any collision and the same name is
then stored.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/78
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agoqemuMonitorFdsetsFree: Don't leak @set->fds
Michal Privoznik [Thu, 7 Jan 2021 13:22:17 +0000 (14:22 +0100)]
qemuMonitorFdsetsFree: Don't leak @set->fds

The @fds member of qemuMonitorFdsetInfo struct is an array and as
such, it's allocated in qemuMonitorJSONQueryFdsetsParse() but not
freed in qemuMonitorFdsetsFree().

Fixes: b8998cc670f7b1b11a83276050e49dce7efba333
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agorpm: Simplify expression of supported platforms
Neal Gompa [Thu, 7 Jan 2021 14:58:08 +0000 (09:58 -0500)]
rpm: Simplify expression of supported platforms

Stanzas like "0%{?fedora} && 0%{?fedora} >= %{min_fedora}" contain
redundant definitions, as "0%{?fedora} >= %{min_fedora}" implies that
"%fedora" is defined and has a value. Thus, we can simplify this.

Signed-off-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu-gather: Merge cpu-cpuid.py
Tim Wiederhake [Mon, 4 Jan 2021 11:30:19 +0000 (12:30 +0100)]
cpu-gather: Merge cpu-cpuid.py

Old usage:
  cpu-cpuid.py diff FILE...
New usage:
  cpu-gather.py diff FILE...

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu-gather: Factor out call to cpu-cpuid.py
Tim Wiederhake [Mon, 4 Jan 2021 11:30:18 +0000 (12:30 +0100)]
cpu-gather: Factor out call to cpu-cpuid.py

This is a preparatory step to merge cpu-cpuid.py.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu-gather: Use actions instead of flags for action argument
Tim Wiederhake [Mon, 4 Jan 2021 11:30:17 +0000 (12:30 +0100)]
cpu-gather: Use actions instead of flags for action argument

This allows for the functionality of cpu-cpuid.py script to be
integrated more naturally in a later patch.

Changes the way this script should be called:
  cpu-gather.py                   -> cpu-gather.py
  cpu-gather.py --gather          -> cpu-gather.py gather
  cpu-gather.py --parse           -> cpu-gather.py parse
  cpu-gather.py --gather --parse  -> cpu-gather.py full

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu-cpuid: Deduplicate register list
Tim Wiederhake [Mon, 4 Jan 2021 11:30:16 +0000 (12:30 +0100)]
cpu-cpuid: Deduplicate register list

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu-cpuid: Merge checkFeature functions
Tim Wiederhake [Mon, 4 Jan 2021 11:30:15 +0000 (12:30 +0100)]
cpu-cpuid: Merge checkFeature functions

Prepare to deduplicate the list of relevant registers for cpuid and
msr information.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu-cpuid: Merge addFeature functions
Tim Wiederhake [Mon, 4 Jan 2021 11:30:14 +0000 (12:30 +0100)]
cpu-cpuid: Merge addFeature functions

Prepare to deduplicate the list of relevant registers for cpuid and
msr information.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu-cpuid: Remove xmltodict usage in parseCPU
Tim Wiederhake [Mon, 4 Jan 2021 11:30:13 +0000 (12:30 +0100)]
cpu-cpuid: Remove xmltodict usage in parseCPU

'xmltodict' is a Python module that is not installed by default.
Replace it, so the dependencies of cpu-gather.py do not change
when both scripts are merged.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu-cpuid: Remove xmltodict usage in parseMap
Tim Wiederhake [Mon, 4 Jan 2021 11:30:12 +0000 (12:30 +0100)]
cpu-cpuid: Remove xmltodict usage in parseMap

'xmltodict' is a Python module that is not installed by default.
Replace it, so the dependencies of cpu-gather.py do not change
when both scripts are merged.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agocpu-cpuid: Use argparse to parse arguments
Tim Wiederhake [Mon, 4 Jan 2021 11:30:11 +0000 (12:30 +0100)]
cpu-cpuid: Use argparse to parse arguments

Using 'argparse' for argument handling simplifies merging this script
with cpu-gather.py in a later patch.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agosrc: fix resource leak introduced in d4439a6b8
Nikolay Shirokovskiy [Thu, 7 Jan 2021 13:09:19 +0000 (16:09 +0300)]
src: fix resource leak introduced in d4439a6b8

@tmp that was copied just above is leaked on plain return.
The issue is found by Coverity.

Patch that inroduced a leak:
d4439a6b8 : src: adopt to VIR_DRV_SUPPORTS_FEATURE return -1

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: build fix for 910b94df
Nick Shyrokovskiy [Wed, 6 Jan 2021 15:40:51 +0000 (18:40 +0300)]
qemu: build fix for 910b94df

Fixes compiler error:

src/qemu/qemu_migration.c:4814:20: error: ‘dstOffline’ may be used
    uninitialized in this function [-Werror=maybe-uninitialized]
    4814 |     if (offline && !dstOffline) {

The commit that introduced the error:
910b94df: qemu: adopt to VIR_DRV_SUPPORTS_FEATURE return -1

Signed-off-by: Nick Shyrokovskiy <nshyrokovskiy@gmail.com>
4 years agoqemuDomainChangeNet: Check changed virtio network driver options
Tim Wiederhake [Wed, 6 Jan 2021 11:12:40 +0000 (12:12 +0100)]
qemuDomainChangeNet: Check changed virtio network driver options

Changes to a virtio network device such as
  <interface type="network">
    <model type="virtio"/>
    <driver iommu="on" ats="on"/> <!-- this line added -->
    ...
  </interface>
were quietly dismissed by `virsh update-device ... --live`.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agosrc: don't hide error in VIR_DRV_SUPPORTS_FEATURE
Nikolay Shirokovskiy [Fri, 18 Dec 2020 06:40:04 +0000 (09:40 +0300)]
src: don't hide error in VIR_DRV_SUPPORTS_FEATURE

Otherwise we can get misleading error messages. One example is when connection
is broken we got "this function is not supported by the connection driver:
virDomainMigrate3" from virDomainMigrate3.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: adopt to VIR_DRV_SUPPORTS_FEATURE return -1
Nikolay Shirokovskiy [Thu, 17 Dec 2020 12:28:25 +0000 (15:28 +0300)]
qemu: adopt to VIR_DRV_SUPPORTS_FEATURE return -1

Otherwise in some places we can mistakenly report 'unsupported' error instead
of root cause. So let's handle root cause explicitly from the macro.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolibxl: adopt to VIR_DRV_SUPPORTS_FEATURE return -1
Nikolay Shirokovskiy [Thu, 17 Dec 2020 12:27:41 +0000 (15:27 +0300)]
libxl: adopt to VIR_DRV_SUPPORTS_FEATURE return -1

Otherwise in some places we can mistakenly report 'unsupported' error instead
of root cause. So let's handle root cause explicitly from the macro.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agosrc: adopt to VIR_DRV_SUPPORTS_FEATURE return -1
Nikolay Shirokovskiy [Thu, 17 Dec 2020 12:20:57 +0000 (15:20 +0300)]
src: adopt to VIR_DRV_SUPPORTS_FEATURE return -1

Otherwise in some places we can mistakenly report 'unsupported' error instead
of root cause. So let's handle root cause explicitly from the macro.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoschemas: Allow direct children of <filesystem/> to be interleaved
Michal Privoznik [Wed, 6 Jan 2021 11:52:13 +0000 (12:52 +0100)]
schemas: Allow direct children of <filesystem/> to be interleaved

Now that individual child elements allow their children to be
interleaved, let's allow direct children of <filesystem/> to be
interleaved too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoschemas: Allow interleaving of fsBinary children
Michal Privoznik [Wed, 6 Jan 2021 11:43:05 +0000 (12:43 +0100)]
schemas: Allow interleaving of fsBinary children

The <binary/> element of <filesystem/> can have children elements
(<cache/> and <lock/>). Allow them to be interleaved.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoschemas: Allow fsDriver to be interleaved
Michal Privoznik [Wed, 6 Jan 2021 11:41:40 +0000 (12:41 +0100)]
schemas: Allow fsDriver to be interleaved

Our <filesystem/> element can have <driver/> child element. But
with the way our schema is written it can't be interleaved and
has to go first.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Restore default root qdisc when QoS is cleared out
Michal Privoznik [Fri, 4 Dec 2020 11:50:58 +0000 (12:50 +0100)]
qemu: Restore default root qdisc when QoS is cleared out

When an interface has some bandwidth limitation set (it's root
qdisc is htb in that case) but this gets cleared out via public
API call (virDomainSetInterfaceParameters() or
virDomainUpdateDeviceFlags()) then virNetDevBandwidthSet() clears
out whatever qdiscs were set on the interface and kernel places
the default qdisc at the root. What we need to do next is to
replace the root qdisc with the one we want.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1329644
Fixes: 0b66196d86ea375234cb0ee99289c486f9921820
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: Set default qdisc before setting bandwidth
Michal Privoznik [Fri, 4 Dec 2020 12:02:53 +0000 (13:02 +0100)]
qemu: Set default qdisc before setting bandwidth

While the code that's setting default qdisc is clever enough to
not overwrite any bandwidth (potentially) set by
virNetDevBandwidthSet() (and thus the root qdisc htb is not
replaced with noqueue), it does print a debug message when that's
the case. It's needless. We can set the root qdisc beforehand and
let virNetDevBandwidthSet() overwrite it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu_process: Release domain seclabel later in qemuProcessStop()
Michal Privoznik [Wed, 9 Dec 2020 10:06:29 +0000 (11:06 +0100)]
qemu_process: Release domain seclabel later in qemuProcessStop()

Some secdrivers (typically SELinux driver) generate unique
dynamic seclabel for each domain (unless a static one is
requested in domain XML). This is achieved by calling
qemuSecurityGenLabel() from qemuProcessPrepareDomain() which
allocates unique seclabel and stores it in domain def->seclabels.
The counterpart is qemuSecurityReleaseLabel() which releases the
label and removes it from def->seclabels. Problem is, that with
current code the qemuProcessStop() may still want to use the
seclabel after it was released, e.g. when it wants to restore the
label of a disk mirror.

What is happening now, is that in qemuProcessStop() the
qemuSecurityReleaseLabel() is called, which removes the SELinux
seclabel from def->seclabels, yada yada yada and eventually
qemuSecurityRestoreImageLabel() is called. This bubbles down to
virSecuritySELinuxRestoreImageLabelSingle() which find no SELinux
seclabel (using virDomainDefGetSecurityLabelDef()) and this
returns early doing nothing.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1751664
Fixes: 8fa0374c5b8e834fcbdeae674cc6cc9e6bf9019f
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirstoragefile: move virStorageFileIsClusterFS into virfile
Pavel Hrdina [Mon, 7 Dec 2020 11:04:41 +0000 (12:04 +0100)]
virstoragefile: move virStorageFileIsClusterFS into virfile

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirstoragefile: move virStorageFileResize into virfile
Pavel Hrdina [Mon, 7 Dec 2020 11:04:04 +0000 (12:04 +0100)]
virstoragefile: move virStorageFileResize into virfile

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirfile: refactor virFileNBDDeviceAssociate
Pavel Hrdina [Wed, 6 Jan 2021 12:02:38 +0000 (13:02 +0100)]
virfile: refactor virFileNBDDeviceAssociate

The only reason why virstoragefile.h needs to be included in virfile.h
is that virFileNBDDeviceAssociate() takes virStorageFileFormat argument.
The function doesn't need the enum value as it converts the value to
string and uses only that.

Change the argument to string which will allow us to remove that
include.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agosrc: add missing headers to various files
Pavel Hrdina [Wed, 6 Jan 2021 11:56:11 +0000 (12:56 +0100)]
src: add missing headers to various files

All these headers are indirectly included provided by virfile.h having
virstoragefile.h which will be removed in the following patch.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil: move virStorageFileCheckCompat into conf
Pavel Hrdina [Mon, 7 Dec 2020 12:34:18 +0000 (13:34 +0100)]
util: move virStorageFileCheckCompat into conf

It is not used anywhere else.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil: move virStorageFileGetLVMKey to locking
Pavel Hrdina [Fri, 4 Dec 2020 05:52:18 +0000 (06:52 +0100)]
util: move virStorageFileGetLVMKey to locking

The function doesn't take virStorageSource as argument and has nothing
in common with virStorageSource or storage file.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil: move virQEMUBuildQemuImgKeySecretOpts into storage
Pavel Hrdina [Tue, 1 Dec 2020 15:30:21 +0000 (16:30 +0100)]
util: move virQEMUBuildQemuImgKeySecretOpts into storage

Function virQEMUBuildQemuImgKeySecretOpts is not used anywhere else
so there is no need to have it in util.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirstoragefile: remove unused virStorageFileChainCheckBroken
Pavel Hrdina [Mon, 7 Dec 2020 11:02:14 +0000 (12:02 +0100)]
virstoragefile: remove unused virStorageFileChainCheckBroken

The last usage outside of tests was removed by commit
<780f8c94ca8b3dee7eb59c1bfbc32f672f965df8>.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoutil: remove unused virStorageGenerateQcowPassphrase
Pavel Hrdina [Tue, 1 Dec 2020 15:36:44 +0000 (16:36 +0100)]
util: remove unused virStorageGenerateQcowPassphrase

The last user was removed by commit
<40f0e0348dfc84f28a500e262c4953b0d3b44fa0>.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoschema: Fix TPM version rules
Michal Privoznik [Wed, 6 Jan 2021 10:50:56 +0000 (11:50 +0100)]
schema: Fix TPM version rules

According to our parser (virDomainTPMDefParseXML()) the version
is an optional attribute and independent of TPM backend type.
Therefore, it's not a choice group, which is what our RNG schema
suggests.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agomanpage: virsh: Drop note that 'domrename' doesn't work with snapshots/checkpoints
Peter Krempa [Wed, 6 Jan 2021 09:56:12 +0000 (10:56 +0100)]
manpage: virsh: Drop note that 'domrename' doesn't work with snapshots/checkpoints

As of commits 3b1244bffdb and 4770a96c662 renaming of the domain works
also with checkpoints and snapshots. Update the docs.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Han Han <hhan@redhat.com>
4 years agoconf: Add support for keeping TPM emulator state
Eiichi Tsukata [Mon, 4 Jan 2021 02:31:59 +0000 (02:31 +0000)]
conf: Add support for keeping TPM emulator state

Currently, swtpm TPM state file is removed when a transient domain is
powered off or undefined. When we store TPM state on a shared storage
such as NFS and use transient domain, TPM states should be kept as it is.

Add per-TPM emulator option `persistent_sate` for keeping TPM state.
This option only works for the emulator type backend and looks as follows:

  <tpm model='tpm-tis'>
    <backend type='emulator' persistent_state='yes'/>
  </tpm>

Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: The TSC tolerance interval should be closed
Jiri Denemark [Tue, 5 Jan 2021 22:53:25 +0000 (23:53 +0100)]
qemu: The TSC tolerance interval should be closed

The kernel refuses to set guest TSC frequency less than a minimum
frequency or greater than maximum frequency (both computed based on the
host TSC frequency). When writing the libvirt code with a reversed logic
(return success when the requested frequency falls within the tolerance
interval) I forgot to include the boundaries.

Fixes: d8e5b4560006590668d4669f54a46b08ec14c1a2
https://bugzilla.redhat.com/show_bug.cgi?id=1839095

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: backup: Properly delete temporary bitmap after push-mode incremental backup
Peter Krempa [Tue, 5 Jan 2021 14:43:21 +0000 (15:43 +0100)]
qemu: backup: Properly delete temporary bitmap after push-mode incremental backup

Refactor in 0316c28a453ac used incorrect source variable to initialize
the variable which holds the name of the bitmap which needs to be
deleted after the backup job finishes. This resulted into deleting the
source bitmap of the backup rather than the temporary one.

Use 'dd->incrementalBitmap' which holds the temporary bitmap name
instead of 'dd->backupdisk->incremental' which holds the name of the
source bitmap which is used by the backup.

Fixes: 0316c28a453ac15f58c61f30359f66ab9a649884
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1908647
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirsh-domain: Add quotes around '%s' formatting domain name
Peter Krempa [Tue, 5 Jan 2021 12:02:34 +0000 (13:02 +0100)]
virsh-domain: Add quotes around '%s' formatting domain name

Domain name can contain spaces in which case it's not immediately clear
from virsh messages where the boundary of the name is. Enclose all %s
formatters in apostrophes as delimiters.

Done via the following vim regex:

 %s/omain %s/omain '%s'/g

This patch changes:

 $ virsh undefine --snapshots-metadata 'OWASP Broken Web Apps VM v1.2'
 Domain OWASP Broken Web Apps VM v1.2 has been undefined

to:

 $ virsh undefine --snapshots-metadata 'OWASP Broken Web Apps VM v1.2'
 Domain 'OWASP Broken Web Apps VM v1.2' has been undefined

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Properly handle setting of <iotune> for empty cdrom
Peter Krempa [Tue, 5 Jan 2021 11:06:32 +0000 (12:06 +0100)]
qemu: Properly handle setting of <iotune> for empty cdrom

When starting a VM with an empty cdrom which has <iotune> configured the
startup fails as qemu is not happy about setting tuning for an empty
drive:

 error: internal error: unable to execute 'block_set_io_throttle', unexpected error: 'Device has no medium'

Resolve this by skipping the setting of throttling for empty drives and
updating the throttling when new medium is inserted into the drive.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/111
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovmx: Treat missing cdrom-image as empty drive
Martin Kletzander [Mon, 21 Dec 2020 15:34:32 +0000 (16:34 +0100)]
vmx: Treat missing cdrom-image as empty drive

This is perfectly valid in VMWare and the VM just boots with an empty drive.  We
used to just skip the whole drive before, but since we changed how we parse
empty cdrom drives this results in an error.  Make it behave more closer to
VMWare.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agoesx: Handle missing images in esxParseVMXFileName
Martin Kletzander [Tue, 5 Jan 2021 12:58:53 +0000 (13:58 +0100)]
esx: Handle missing images in esxParseVMXFileName

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agotests: Test vmx files with missing images
Martin Kletzander [Tue, 5 Jan 2021 13:19:34 +0000 (14:19 +0100)]
tests: Test vmx files with missing images

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agovmx: Allow missing cdrom image file in virVMXParseFileName
Martin Kletzander [Mon, 21 Dec 2020 15:51:31 +0000 (16:51 +0100)]
vmx: Allow missing cdrom image file in virVMXParseFileName

This will be used later.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agotests: Allow testing for parse failures in vmx2xmltest
Martin Kletzander [Tue, 5 Jan 2021 13:19:21 +0000 (14:19 +0100)]
tests: Allow testing for parse failures in vmx2xmltest

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agovmx: Make virVMXParseFileName return an integer
Martin Kletzander [Mon, 21 Dec 2020 13:48:49 +0000 (14:48 +0100)]
vmx: Make virVMXParseFileName return an integer

And return the actual extracted value in a parameter.  This way we can later
return success even without any extracted value.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agotests: Use g_autofree in testParseVMXFileName
Martin Kletzander [Mon, 21 Dec 2020 15:56:25 +0000 (16:56 +0100)]
tests: Use g_autofree in testParseVMXFileName

There's only one variable to clean-up, others are just tokens inside that
variable, but it is nicer anyway.  Positive returns have not been converted
because the function will change soon and it would not make much sense.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agoesx: Unindent unnecessary conditional branch
Martin Kletzander [Mon, 21 Dec 2020 13:38:30 +0000 (14:38 +0100)]
esx: Unindent unnecessary conditional branch

The positive branch can just return and the huge negative part does not need to
be indented an extra level.  Best viewed with `-w`.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
4 years agorpm: fix ownership of the swtpm log directory
Daniel P. Berrangé [Mon, 4 Jan 2021 18:03:55 +0000 (18:03 +0000)]
rpm: fix ownership of the swtpm log directory

As soon as a guest using a <tpm> device is launched, libvirt will change
the ownership to 'tss' user and group, with mode 0730, which will cause
RPM verify to then fail.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agorpm: ensure swtpm tools are installed with QEMU
Daniel P. Berrangé [Mon, 4 Jan 2021 18:03:24 +0000 (18:03 +0000)]
rpm: ensure swtpm tools are installed with QEMU

These are needed for the <tpm> devices to be usable.

Reviewed-by: Laine Stump <laine@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agostorage_util: Rework storageBackendCreateRaw() slightly
Yi Li [Tue, 5 Jan 2021 14:43:32 +0000 (22:43 +0800)]
storage_util: Rework storageBackendCreateRaw() slightly

Remove @ret and @created variables which are not needed really.

Signed-off-by: Yi Li <yili@winhong.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirStorageBackendCopyToFD: remove unused return variable
Yi Li [Tue, 5 Jan 2021 14:43:31 +0000 (22:43 +0800)]
virStorageBackendCopyToFD: remove unused return variable

None of the callers care about errno really. The errno will be
reported by virReportSystemError().

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>