]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
3 years agoqemuDomainAttachDeviceDiskLiveInternal: Absorb qemuDomainAttachSCSIDisk
Peter Krempa [Tue, 18 May 2021 13:10:22 +0000 (15:10 +0200)]
qemuDomainAttachDeviceDiskLiveInternal: Absorb qemuDomainAttachSCSIDisk

Move the validation of the SCSI device address and the attachment of the
controller into qemuDomainAttachDeviceDiskLiveInternal as there's no
specific need for a special helper.

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 agoqemuDomainAttachDeviceDiskLiveInternal: Absorb qemuDomainAttachVirtioDiskDevice
Peter Krempa [Tue, 18 May 2021 13:10:22 +0000 (15:10 +0200)]
qemuDomainAttachDeviceDiskLiveInternal: Absorb qemuDomainAttachVirtioDiskDevice

Move the specific device setup and address reservation code into the
main hotplug helper as it's just one extra function call.

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 agoqemuDomainAttachDeviceDiskLiveInternal: Absorb qemuDomainAttachUSBMassStorageDevice
Peter Krempa [Tue, 18 May 2021 13:10:22 +0000 (15:10 +0200)]
qemuDomainAttachDeviceDiskLiveInternal: Absorb qemuDomainAttachUSBMassStorageDevice

Move the specific device setup and address reservation code into the
main hotplug helper as it's just one extra function call.

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 agoqemuDomainRemoveDiskDevice: Move 'copy-on-read' handling to qemuBlockStorageSourceCha...
Peter Krempa [Fri, 7 May 2021 12:54:31 +0000 (14:54 +0200)]
qemuDomainRemoveDiskDevice: Move 'copy-on-read' handling to qemuBlockStorageSourceChainData

Unify the handling of the copy-on-read filter by changing the handling
to use qemuBlockStorageSourceChainData.

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 agoqemuDomainAttachDiskGeneric: Move 'copy-on-read' handling to qemuBlockStorageSourceCh...
Peter Krempa [Fri, 7 May 2021 12:50:23 +0000 (14:50 +0200)]
qemuDomainAttachDiskGeneric: Move 'copy-on-read' handling to qemuBlockStorageSourceChainData

Fill in the required fields in qemuBlockStorageSourceChainData to handle
the hotplug so that we can simplify the cleanup code.

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 agoqemuBlockStorageSourceChainData: Add handling of 'copy-on-read' filter layer
Peter Krempa [Fri, 7 May 2021 12:48:02 +0000 (14:48 +0200)]
qemuBlockStorageSourceChainData: Add handling of 'copy-on-read' filter layer

qemuBlockStorageSourceChainData encapsulates the backend of the disk for
startup and hotplug operations. Add the handling for the copy-on-read
filter so that the hotplug code doesn't need to have separate cleanup.

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 agoconf: remove virDomainDiskInsertPreAlloced
Peter Krempa [Tue, 18 May 2021 14:02:18 +0000 (16:02 +0200)]
conf: remove virDomainDiskInsertPreAlloced

Replace the last use of the function by virDomainDiskInsert and remove
the unused helper.

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 agoReplace virDomainDiskInsertPreAlloced by virDomainDiskInsert
Peter Krempa [Tue, 18 May 2021 14:00:48 +0000 (16:00 +0200)]
Replace virDomainDiskInsertPreAlloced by virDomainDiskInsert

Pre-extending the disk array size is pointless nowadays since we've
switched to memory APIs which don't return failure.

Switch all uses of reallocation of the array followed by
'virDomainDiskInsertPreAlloced' with direct virDomainDiskInsert.

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: Move iothread and s390 address validation for disk devices into the validator
Peter Krempa [Fri, 30 Apr 2021 14:19:15 +0000 (16:19 +0200)]
qemu: Move iothread and s390 address validation for disk devices into the validator

The "machine-loadparm-multiple-disks-nets-s390" case now requires the
QEMU_CAPS_CCW feature to pass validation.

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 agoqemuxml2argvtest: Remove pointless tests for keywrapping on s390
Peter Krempa [Fri, 30 Apr 2021 14:29:45 +0000 (16:29 +0200)]
qemuxml2argvtest: Remove pointless tests for keywrapping on s390

There were two negative tests for the keywrapping feature on s390 when
the feature flag was missing. For now both shared the error message thus
worked fine, but with the upcoming patch to move some disk validation
code from the command line formatter to validation code will change the
error message in case the disk capabilities are missing.

Drop the test cases which don't provide any capability and keep those
that have the disk capabilities present as they are sufficient to prove
the feature.

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: Move bootindex usage logic into qemuBuildDiskDeviceStr
Peter Krempa [Fri, 30 Apr 2021 14:09:09 +0000 (16:09 +0200)]
qemu: Move bootindex usage logic into qemuBuildDiskDeviceStr

We can skip the formatting of the bootindex for floppies directly at the
place where it's being formatted.

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: Move 'bootindex' handling for disks out of command line formatter
Peter Krempa [Fri, 30 Apr 2021 06:58:45 +0000 (08:58 +0200)]
qemu: Move 'bootindex' handling for disks out of command line formatter

The logic assigning the bootindices from the legacy boot order
configuration was spread through the command line formatters for the
disk device and for the floppy controller.

This patch adds 'effectiveBootindex' property to the disk private data
which holds the calculated boot index and moves the logic of determining
the boot index into 'qemuProcessPrepareDomainDiskBootorder' called from
'qemuProcessPrepareDomainStorage'.

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_snapshot: Add the guest name to the transient disk path
Masayoshi Mizuma [Thu, 25 Mar 2021 00:54:11 +0000 (20:54 -0400)]
qemu_snapshot: Add the guest name to the transient disk path

Later patches will implement sharing of the backing file, so we'll need
to be able to discriminate the overlays per VM.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
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: snapshot: move transient snapshot code to qemu_process
Peter Krempa [Tue, 27 Apr 2021 18:31:11 +0000 (20:31 +0200)]
qemu: snapshot: move transient snapshot code to qemu_process

The code deals with the startup of the VM and just uses the snapshot
code to achieve the desired outcome.

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 agoqemuSnapshotDiskCreate: Use 'cfg' from the qemuSnapshotDiskContext
Peter Krempa [Wed, 28 Apr 2021 12:19:36 +0000 (14:19 +0200)]
qemuSnapshotDiskCreate: Use 'cfg' from the qemuSnapshotDiskContext

We store the virQEMUDriverConfig object in the context.

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 agoqemuSnapshotDiskPrepareOne: Use data from qemuSnapshotDiskContext
Peter Krempa [Wed, 28 Apr 2021 12:16:37 +0000 (14:16 +0200)]
qemuSnapshotDiskPrepareOne: Use data from qemuSnapshotDiskContext

Remove all the arguments which are present in qemuSnapshotDiskContext.

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 agoqemuSnapshotDiskContext: Store virQEMUDriverConfig in the struct
Peter Krempa [Wed, 28 Apr 2021 12:12:39 +0000 (14:12 +0200)]
qemuSnapshotDiskContext: Store virQEMUDriverConfig in the struct

The config is used both with the preparation and execution functions, so
we can store it in the context to simplify other helpers.

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 agoqemuSnapshotDiskPrepareOne: Pass in qemuSnapshotDiskContext
Peter Krempa [Wed, 28 Apr 2021 11:57:57 +0000 (13:57 +0200)]
qemuSnapshotDiskPrepareOne: Pass in qemuSnapshotDiskContext

Rather than filling various parts of the context from arguments pass in
the whole context.

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: process: Setup transient disks only when starting a fresh VM
Peter Krempa [Wed, 28 Apr 2021 09:03:19 +0000 (11:03 +0200)]
qemu: process: Setup transient disks only when starting a fresh VM

Creating the overlay for the disk is needed when starting a new VM only.
Additionally for now migration with transient disks is forbidden
anyways.

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: snapshot: Extract setup of snapshot disk definition for transient disks
Peter Krempa [Wed, 28 Apr 2021 08:17:18 +0000 (10:17 +0200)]
qemu: snapshot: Extract setup of snapshot disk definition for transient disks

The code will be later reused when adding support for sharing the
backing image of the snapshot.

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 agoRemove static analysis assertions
Peter Krempa [Wed, 19 May 2021 14:58:29 +0000 (16:58 +0200)]
Remove static analysis assertions

None of them are currently needed to pass our upstream CI, most were
either for ancient clang versions or coverity for silencing false
positives.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoDrop magic comments for coverity
Peter Krempa [Wed, 19 May 2021 14:45:11 +0000 (16:45 +0200)]
Drop magic comments for coverity

They were added mostly randomly and we don't really want to keep working
around of false positives.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoschema: Allow '0' offset for a <slice> of <disk>
Peter Krempa [Fri, 21 May 2021 12:53:43 +0000 (14:53 +0200)]
schema: Allow '0' offset for a <slice> of <disk>

Using slice to cut off the end of the image is a perfectly vaid
configuration. Use 'unsignedInt' instead of 'positiveInteger' for the
'offset' attribute in the XML schema and modify one test case to cover
this use case.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1960993
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agoconf: Deduplicate NUMA distance code
Michal Privoznik [Mon, 3 May 2021 09:04:45 +0000 (11:04 +0200)]
conf: Deduplicate NUMA distance code

After previous patches we have two structures:
virCapsHostNUMACellDistance and virNumaDistance which express the
same thing. And have the exact same members (modulo their names).
Drop the former in favor of the latter.

This change means that distances with value of 0 are no longer
printed out into capabilities XML, because domain XML code allows
partial distance specification and thus threats value of 0 as
unspecified by user (see virDomainNumaGetNodeDistance() which
returns the default LOCAL/REMOTE distance for value of 0).

Also, from ACPI 6.1 specification, section 5.2.17 System Locality
Distance Information Table (SLIT):

  Distance values of 0-9 are reserved and have no meaning.

Thus we shouldn't be ever reporting 0 in neither domain nor
capabilities XML.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agonuma_conf: Expose virNumaDistance formatter
Michal Privoznik [Fri, 14 May 2021 13:25:47 +0000 (15:25 +0200)]
numa_conf: Expose virNumaDistance formatter

Expose virNumaDistance XML formatter so that it can be re-used by
other parts of the code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agonuma_conf: Rename virDomainNumaDistance to virNumaDistance
Michal Privoznik [Mon, 17 May 2021 07:15:24 +0000 (09:15 +0200)]
numa_conf: Rename virDomainNumaDistance to virNumaDistance

There's nothing domain specific about NUMA distances. Rename the
virDomainNumaDistance structure to just virNumaDistance.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agocapabilities: Rename siblings to distances
Michal Privoznik [Mon, 3 May 2021 10:06:42 +0000 (12:06 +0200)]
capabilities: Rename siblings to distances

The virCapsHostNUMACellSiblingInfo structure really represents
distance to other NUMA node. Rename the structure and variables
of that type to make it more obvious.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoRevert "qemuDomainSetNumaParamsLive: set nodeset for root cgroup"
Pavel Hrdina [Fri, 21 May 2021 13:26:59 +0000 (15:26 +0200)]
Revert "qemuDomainSetNumaParamsLive: set nodeset for root cgroup"

This reverts commit <1b22dd6dd44202094e0f78f887cbe790c00e9ebc>.

First of all, the reverted commit is incomplete. It only sets
cpuset.mems in the VM root cgroup when the API is used but there is no
code that would do the same when the VM is started.

Libvirt never places any process into the VM root cgroup directly. All
the supporting processes like slirp-helper or dbus-daemon are placed
into the emulator sub-cgroup and all the QEMU threads are distributed
between emulator, vcpu* and iothread* sub-cgroups. The scenario
described in the reverted commit can happen only if someone manually
adds any process there which we should not care about.

If we would like to set the limit in the VM root cgroup we need to
introduce better logic:

    - set both (old and new) numa group in the VM root cgroup
    - change the numa group in all sub-cgroups to new value
    - finally set only the new value in the VM root cgroup

The simplest fix now is to revert the commit.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agokbase: Fix broken link of migration doc
Han Han [Mon, 24 May 2021 10:30:20 +0000 (18:30 +0800)]
kbase: Fix broken link of migration doc

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
3 years agolibxl: remove libxl_domain_build_info_init from libxlMakeDomBuildInfo
Olaf Hering [Thu, 20 May 2021 11:26:20 +0000 (13:26 +0200)]
libxl: remove libxl_domain_build_info_init from libxlMakeDomBuildInfo

The used libxl_domain_build_info, which is contained in
libxl_domain_config, is owned and already initialized by the caller.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
3 years agolibxl: remove libxl_domain_create_info_init from libxlMakeDomCreateInfo
Olaf Hering [Thu, 20 May 2021 10:58:35 +0000 (12:58 +0200)]
libxl: remove libxl_domain_create_info_init from libxlMakeDomCreateInfo

The passed libxl_domain_create_info is owned, and already initialized,
by the caller.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
3 years agolibxl: adjust handling of libxl_device_disk objects
Olaf Hering [Thu, 20 May 2021 10:17:20 +0000 (12:17 +0200)]
libxl: adjust handling of libxl_device_disk objects

libxl objects are supposed to be initialized and disposed.
Correct the usage of libxl_device_disk objects which are allocated on
the stack. Initialize each one prior usage, and dispose them once done.

Adjust libxlMakeDisk to use an already initialized object, it is owned
by the caller.

Adjust libxlMakeDiskList to initialize the list of objects, before they
are filled by libxlMakeDisk. In case of error, the objects are disposed
by libxl_domain_config_dispose.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
3 years agoconf: Report alias name of the detached device in error
Kristina Hanicova [Thu, 20 May 2021 14:13:34 +0000 (16:13 +0200)]
conf: Report alias name of the detached device in error

This is v2 from:
https://listman.redhat.com/archives/libvir-list/2021-May/msg00481.html

I have reworked the code a bit to have only one error report
instead of multiple ones with different combinations of possible
matching items. Suggested by Laine.

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

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agoqemu: Return -EINVAL to keep qemuDomainOpenFile() consistent
Kristina Hanicova [Fri, 21 May 2021 11:41:30 +0000 (13:41 +0200)]
qemu: Return -EINVAL to keep qemuDomainOpenFile() consistent

The description of the function says that the return value is a
file descriptor on success and negative errno on failure which is
not true. If the 'if' case with check on security labels fails,
the return value is -1 not -errno. The solution is to return
'-EINVAL' instead.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: Use qemuDomainOpenFile() in qemuPrepareNVRAM()
Kristina Hanicova [Fri, 21 May 2021 11:41:29 +0000 (13:41 +0200)]
qemu: Use qemuDomainOpenFile() in qemuPrepareNVRAM()

Previously, nvram file was created with user/group owner as
'root', rather than specifications defined in libvirtd.conf. The
solution is to call qemuDomainOpenFile(), which creates file with
defined permissions and qemuSecurityDomainSetPathLabel() to set
security label for created nvram file.

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

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: Build command line for object input-linux
Kristina Hanicova [Fri, 21 May 2021 11:01:08 +0000 (13:01 +0200)]
qemu: Build command line for object input-linux

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/142

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
3 years agoconf: Parse/format XML input type 'evdev'
Kristina Hanicova [Fri, 21 May 2021 11:01:07 +0000 (13:01 +0200)]
conf: Parse/format XML input type 'evdev'

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_capabilities: Add QEMU_CAPS_INPUT_LINUX
Kristina Hanicova [Fri, 21 May 2021 11:01:06 +0000 (13:01 +0200)]
qemu_capabilities: Add QEMU_CAPS_INPUT_LINUX

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agostorage_file: add support to probe cluster_size from QCOW2 images
Pavel Hrdina [Wed, 12 May 2021 15:44:19 +0000 (17:44 +0200)]
storage_file: add support to probe cluster_size from QCOW2 images

From QEMU docs/interop/qcow2.txt :

   Byte  20 - 23:   cluster_bits
                    Number of bits that are used for addressing an offset
                    within a cluster (1 << cluster_bits is the cluster size).

With this patch libvirt will be able to report the current cluster_size
for all existing storage volumes managed by storage driver.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agostorage: add support for QCOW2 cluster_size option
Pavel Hrdina [Wed, 12 May 2021 15:43:36 +0000 (17:43 +0200)]
storage: add support for QCOW2 cluster_size option

The default value hard-coded in QEMU (64KiB) is not always the ideal.
Having a possibility to set the cluster_size by user may in specific
use-cases improve performance for QCOW2 images.

QEMU internally has some limits, the value has to be between 512B and
2048KiB and must by power of two, except when the image has Extended L2
Entries the minimal value has to be 16KiB.

Since qemu-img ensures the value is correct and the limit is not always
the same libvirt will not duplicate any of these checks as the error
message from qemu-img is good enough:

    Cluster size must be a power of two between 512 and 2048k

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/154

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: Add check for needed paths for memory devices
Kristina Hanicova [Thu, 20 May 2021 14:29:05 +0000 (16:29 +0200)]
qemu: Add check for needed paths for memory devices

When building a commandline for a DIMM memory device with
non-default access mode, the qemuBuildMemoryBackendProps() will
tell QEMU to allocate memory from per-domain memory backing dir.
But later, when preparing the host, the
qemuProcessNeedMemoryBackingPath() does not check for memory
devices at all resulting in per-domain memory backing dir not
being created which upsets QEMU.

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

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: fs: do not try to fill binary path if we have a socket
Ján Tomko [Thu, 20 May 2021 09:01:15 +0000 (11:01 +0200)]
qemu: fs: do not try to fill binary path if we have a socket

We do not need to look for a suitable binary in the vhost-user
description files, if we aren't the ones starting it.
Otherwise startup will fail with:

error: Failed to start domain 'vm1'
error: operation failed: Unable to find a satisfying virtiofsd

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoNEWS: Document new memory dump format
Michal Privoznik [Thu, 20 May 2021 13:00:39 +0000 (15:00 +0200)]
NEWS: Document new memory dump format

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agovirsh: Expose new win-dmp dump format
Michal Privoznik [Thu, 20 May 2021 12:32:21 +0000 (14:32 +0200)]
virsh: Expose new win-dmp dump format

In previous commit the virDomainCoreDumpWithFormat() API gained
new format. Expose it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agolib: Add win-dmp crashdump format
Michal Privoznik [Thu, 20 May 2021 12:32:11 +0000 (14:32 +0200)]
lib: Add win-dmp crashdump format

QEMU gained support for 'win-dmp' format in it's release of 3.0,
but libvirt doesn't implement it yet. Fortunately, there not much
needed: new value to virDomainCoreDumpFormat public enum, which
unfortunately means that QEMU driver has to be updated in the
same commit, because of VIR_ENUM_IMPL().

Luckily, we don't need any extra QEMU capability - the code
already checks supported formats via
'query-dump-guest-memory-capability' just before issuing
'dump-guest-memory'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoinclude: Fix copy-paste error in comment to virDomainCoreDumpFormat enum
Michal Privoznik [Thu, 20 May 2021 12:20:15 +0000 (14:20 +0200)]
include: Fix copy-paste error in comment to virDomainCoreDumpFormat enum

The comment to virDomainCoreDumpFormat enum says that new values
can be introduced in the future "as new events are added". Well,
it should have been "formats" instead of "events", obviously.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agovirNodeDevCapMdevParseXML: Use virXMLPropEnum() for ./start/@type
Michal Privoznik [Thu, 20 May 2021 10:51:57 +0000 (12:51 +0200)]
virNodeDevCapMdevParseXML: Use virXMLPropEnum() for ./start/@type

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoconf: node_device: Fix build with clang
Peter Krempa [Thu, 20 May 2021 10:17:09 +0000 (12:17 +0200)]
conf: node_device: Fix build with clang

Clang complains:

  ../libvirt/src/conf/node_device_conf.c:1945:74: error: result of comparison of unsigned enum expression < 0 is always false [-Werror,-Wtautological-unsigned-enum-zero-compare]
        if ((mdev->start = virNodeDevMdevStartTypeFromString(starttype)) < 0) {

Fixes: 42a55854993
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
3 years agovirDomainDeviceSpaprVioAddressParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 19 May 2021 14:10:12 +0000 (16:10 +0200)]
virDomainDeviceSpaprVioAddressParseXML: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`ULLONG_MAX + value + 1`) for attribute `reg`. Allowing negative
numbers to be interpreted this way makes no sense for this attribute, as it
refers to a 32 bit address space.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirStorageAdapterParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 19 May 2021 14:10:11 +0000 (16:10 +0200)]
virStorageAdapterParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirStorageAdapterFCHost: Change type of "type" to virStorageAdapterType
Tim Wiederhake [Wed, 19 May 2021 14:10:10 +0000 (16:10 +0200)]
virStorageAdapterFCHost: Change type of "type" to virStorageAdapterType

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirStorageAdapterParseXML: Use g_autofree
Tim Wiederhake [Wed, 19 May 2021 14:10:09 +0000 (16:10 +0200)]
virStorageAdapterParseXML: Use g_autofree

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirDomainIOMMUDefParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 19 May 2021 14:10:08 +0000 (16:10 +0200)]
virDomainIOMMUDefParseXML: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `aw_bits`. Allowing negative
numbers to be interpreted this way makes no sense for this attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirDomainAudioDefParseXML: Don't ignore return value of virDomainAudio*Parse()
Tim Wiederhake [Wed, 19 May 2021 14:10:07 +0000 (16:10 +0200)]
virDomainAudioDefParseXML: Don't ignore return value of virDomainAudio*Parse()

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirDomainAudioDefParseXML: Use virXMLProp*
Tim Wiederhake [Wed, 19 May 2021 14:10:06 +0000 (16:10 +0200)]
virDomainAudioDefParseXML: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `id`. Allowing negative
numbers to be interpreted this way makes no sense for this attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirDomainAudioDef: Change type of "sdl.driver" to virDomainAudioSDLDriver
Tim Wiederhake [Wed, 19 May 2021 14:10:05 +0000 (16:10 +0200)]
virDomainAudioDef: Change type of "sdl.driver" to virDomainAudioSDLDriver

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirDomainAudioDef: Change type of "type" to virDomainAudioType
Tim Wiederhake [Wed, 19 May 2021 14:10:04 +0000 (16:10 +0200)]
virDomainAudioDef: Change type of "type" to virDomainAudioType

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirDomainAudioPulseAudioParse: Use virXMLProp*
Tim Wiederhake [Wed, 19 May 2021 14:10:03 +0000 (16:10 +0200)]
virDomainAudioPulseAudioParse: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `latency`. Allowing negative
numbers to be interpreted this way makes no sense for this attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirnetdevopenvswitch: Remove redundant declaration
Peng Liang [Thu, 20 May 2021 06:46:06 +0000 (14:46 +0800)]
virnetdevopenvswitch: Remove redundant declaration

virNetDevOpenvswitchInterfaceGetMaster is declared twice in
src/util/virnetdevopenvswitch.h.  Remove the last one.

Signed-off-by: Peng Liang <liangpeng10@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agotests: nodedevxml2xmltest: test more mdev files
Jonathon Jongsma [Fri, 14 May 2021 21:29:00 +0000 (16:29 -0500)]
tests: nodedevxml2xmltest: test more mdev files

Add the rest of the mdev xml files to the xml2xml test, and include 2
new test cases: one that explicitly specifies 'manual' start, and one
that explicitly specifies 'auto' start.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agonodedev: support auto-start property for mdevs
Boris Fiuczynski [Fri, 14 May 2021 21:28:59 +0000 (16:28 -0500)]
nodedev: support auto-start property for mdevs

This adds a new element to the mdev capabilities xml schema that
represents the start policy for a defined mediated device. The actual
auto-start functionality is handled behind the scenes by mdevctl, but it
wasn't yet hooked up in libvirt.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agotest: move nodedev xml2xml output to a separate dir
Jonathon Jongsma [Fri, 14 May 2021 21:28:58 +0000 (16:28 -0500)]
test: move nodedev xml2xml output to a separate dir

Currently, we're loading and parsing the xml from the input file, and
then formatting it and then comparing it directly back to the input
file. This works for now, but is severely limiting as it relies on the
input file being fully-specified and in the exact order as the output
xml format.

If optional elements are ommitted in the input XML, the output xml
may include default values for the ommitted elements and thus the output
will not match the input.

In order to allow more flexibility in testing, save the expected output
to a seprate 'out' directory similar to what most of the other xml2xml
tests are already doing.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agolibxl: remove libxl_domain_config_init from libxlBuildDomainConfig
Olaf Hering [Wed, 19 May 2021 08:40:00 +0000 (10:40 +0200)]
libxl: remove libxl_domain_config_init from libxlBuildDomainConfig

The passed libxl_domain_config is owned, and already initialized, by the
caller.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
3 years agovirsh-domain: Fix @ret handling in cmdSetmem and cmdSetmaxmem
Michal Privoznik [Wed, 19 May 2021 09:58:21 +0000 (11:58 +0200)]
virsh-domain: Fix @ret handling in cmdSetmem and cmdSetmaxmem

These functions initialize @ret to true and only after something
fails either they call cleanup code (which consists only from
virshDomainFree()) and return false, or they set ret = false and
carry on (when the failure occurred close to cleanup code).

Switch them to the usual pattern in which ret is initialized to
failure, goto cleanup is used and ret is set to true only after
everything succeeded.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agovirsh: Fix logic wrt to --current flag in cmdSetmem
Michal Privoznik [Tue, 18 May 2021 12:24:01 +0000 (14:24 +0200)]
virsh: Fix logic wrt to --current flag in cmdSetmem

In my commit of v7.1.0-rc1~376 I've simplified the logic of
handling @flags. My assumption back then was that calling
virDomainSetMemory() is equivalent to
virDomainSetMemoryFlags(flags = 0). But that is not the case,
because it is equivalent to virDomainSetMemoryFlags(flags =
VIR_DOMAIN_AFFECT_LIVE). Fix the condition that calls the old
API.

Fixes: b5e267e8c59a257652f88d034cb1e0ce1ed4b58a
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1961118
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agodocs: nodedev: document mdev uuid property
Jonathon Jongsma [Fri, 14 May 2021 21:29:01 +0000 (16:29 -0500)]
docs: nodedev: document mdev uuid property

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agotests: Add capabilities for QEMU 6.0.0 on s390x
Shalini Chellathurai Saroja [Tue, 18 May 2021 08:40:20 +0000 (10:40 +0200)]
tests: Add capabilities for QEMU 6.0.0 on s390x

Introduce replies and xml files for QEMU 6.0.0 on s390x.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agotests: qemucapabilities: Add test-data for the qemu-6.1 cycle
Peter Krempa [Mon, 17 May 2021 08:28:04 +0000 (10:28 +0200)]
tests: qemucapabilities: Add test-data for the qemu-6.1 cycle

Add test data based on qemu commit v6.0.0-540-g6005ee07c3.

Notable changes are the removal of 'sheepdog' disk storage protocol.

Additionally the cpu model reported when probing seems to have changed
from:

"model-id": "AMD Ryzen 9 3900X 12-Core Processor            "

to:

"model-id": "QEMU TCG CPU version 2.5+"

despite building on the same machine. This probably also results in the
2 test changes in the CPU definition which popped up in this update.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agoqemuxml2argvtest: Limit 'disk-network-sheepdog' testcase to qemu-6.0.0
Peter Krempa [Mon, 17 May 2021 08:38:25 +0000 (10:38 +0200)]
qemuxml2argvtest: Limit 'disk-network-sheepdog' testcase to qemu-6.0.0

QEMU is dropping sheepdog support in 6.1 so we need to limit the test
case to the latest version supporting sheepdog as it won't be described
by the QMP schema any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agoqemublocktest: Drop 'network-sheepdog-qcow2' image creation test case
Peter Krempa [Mon, 17 May 2021 08:33:34 +0000 (10:33 +0200)]
qemublocktest: Drop 'network-sheepdog-qcow2' image creation test case

QEMU dropped sheepdog support for the 6.1 release. Since we use schema
validation in the image creation it would create test failures.

In this instance we just drop the test altogether as adding versioned
capabilities would be a bit too overkill for this scenario.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agotestQemuInfoSetArgs: Strip default machine alias only for 'latest' test cases
Peter Krempa [Mon, 17 May 2021 08:51:15 +0000 (10:51 +0200)]
testQemuInfoSetArgs: Strip default machine alias only for 'latest' test cases

For the real-capabilities test cases testing 'latest' capabilities we
strip off the alias from 'pc' to the appropriate versioned machine type
to prevent update to all tests when bumping qemu capabilities.

Recenly we also started caching the capabilities to prevent re-parsing
the XML all the time. The commit adding the caching kept the alias
stripping prior to cache insertion, thus the cache contains the stripped
alias.

This leads to problem when a test case is added where the 'latest'
equals to the selected version.

Move the machine alias stripping after we create a local copy thus
stripping it only for 'latest' tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agolibxl: fix refcounting in libxlDomainChangeEjectableMedia
Olaf Hering [Tue, 18 May 2021 19:26:31 +0000 (21:26 +0200)]
libxl: fix refcounting in libxlDomainChangeEjectableMedia

The initial variant of libxlDomainChangeEjectableMedia could just leave
the function earlier. With refcounting this does not work anymore.

Fixes commit a5bf06ba34dbb226ac1b2fb63f5026c5d493bc65

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
3 years agovirNodeDevCapPCIDevIommuGroupParseXML: Use virXMLProp*
Tim Wiederhake [Tue, 18 May 2021 15:04:51 +0000 (17:04 +0200)]
virNodeDevCapPCIDevIommuGroupParseXML: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `number`. Allowing negative
numbers to be interpreted this way makes no sense for this attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agovirDomainAudioOSSParse: Use virXMLProp*
Tim Wiederhake [Tue, 18 May 2021 15:04:50 +0000 (17:04 +0200)]
virDomainAudioOSSParse: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `bufferCount`. Allowing negative
numbers to be interpreted this way makes no sense for this attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agovirDomainAudioCoreAudioParse: Use virXMLProp*
Tim Wiederhake [Tue, 18 May 2021 15:04:49 +0000 (17:04 +0200)]
virDomainAudioCoreAudioParse: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `bufferCount`. Allowing negative
numbers to be interpreted this way makes no sense for this attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agovirDomainChrDefParseTargetXML: Use virXMLProp*
Tim Wiederhake [Tue, 18 May 2021 15:04:48 +0000 (17:04 +0200)]
virDomainChrDefParseTargetXML: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `port`. Allowing negative
numbers to be interpreted this way makes no sense for this attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agovirDomainChrSourceReconnectDefParseXML: Use virXMLProp*
Tim Wiederhake [Tue, 18 May 2021 15:04:47 +0000 (17:04 +0200)]
virDomainChrSourceReconnectDefParseXML: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `timeout`. Allowing negative
numbers to be interpreted this way makes no sense for this attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agovirDomainDiskDefGeometryParse: Use virXMLProp*
Tim Wiederhake [Tue, 18 May 2021 15:04:46 +0000 (17:04 +0200)]
virDomainDiskDefGeometryParse: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attributes `cyls`, `heads` and `secs`.
Allowing negative numbers to be interpreted this way makes no sense for
these attributes.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agovirDomainDiskDef: Change type of geometry.trans to virDomainDiskGeometryTrans
Tim Wiederhake [Tue, 18 May 2021 15:04:45 +0000 (17:04 +0200)]
virDomainDiskDef: Change type of geometry.trans to virDomainDiskGeometryTrans

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agovirDomainDeviceUSBMasterParseXML: Use virXMLProp*
Tim Wiederhake [Tue, 18 May 2021 15:04:44 +0000 (17:04 +0200)]
virDomainDeviceUSBMasterParseXML: Use virXMLProp*

This strictens the parser to disallow negative values (interpreted as
`UINT_MAX + value + 1`) for attribute `startport`. Allowing negative
numbers to be interpreted this way makes no sense for this attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agovirDomainHostdevSubsysUSBDefParseXML: Use virXMLProp*
Tim Wiederhake [Tue, 18 May 2021 15:04:43 +0000 (17:04 +0200)]
virDomainHostdevSubsysUSBDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agovirDomainHostdevDef: Change type of startupPolicy to virDomainStartupPolicy
Tim Wiederhake [Tue, 18 May 2021 15:04:42 +0000 (17:04 +0200)]
virDomainHostdevDef: Change type of startupPolicy to virDomainStartupPolicy

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agolibxl: set vcpu affinity during domain creation
Olaf Hering [Wed, 5 May 2021 14:06:32 +0000 (16:06 +0200)]
libxl: set vcpu affinity during domain creation

Since Xen 4.5 libxl allows to set affinities during domain creation.
This enables Xen to allocate the domain memory on NUMA systems close to
the specified pcpus.

Libvirt can now handle <domain/cputune/vcpupin> in domU.xml correctly.

Without this change, Xen will create the domU and assign NUMA memory and
vcpu affinities on its own. Later libvirt will adjust the affinity,
which may move the vcpus away from the assigned NUMA node.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
3 years agoqemu_process: Drop needless check in qemuProcessNeedMemoryBackingPath()
Michal Privoznik [Fri, 5 Feb 2021 12:54:26 +0000 (13:54 +0100)]
qemu_process: Drop needless check in qemuProcessNeedMemoryBackingPath()

The aim of this function is to return whether domain definition
and/or memory device that user intents to hotplug needs a private
path inside cfg->memoryBackingDir. The rule for the memory device
that's being hotplug includes checking whether corresponding
guest NUMA node needs memoryBackingDir. Well, while the rationale
behind makes sense it is not necessary to check for that really -
just a few lines above every guest NUMA node was checked exactly
for that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu_process: Deduplicate code in qemuProcessNeedHugepagesPath()
Michal Privoznik [Fri, 5 Feb 2021 12:34:35 +0000 (13:34 +0100)]
qemu_process: Deduplicate code in qemuProcessNeedHugepagesPath()

The aim of qemuProcessNeedHugepagesPath() is to return whether
guest needs private path inside HugeTLBFS mounts (deducted from
domain definition @def) or whether the memory device that user is
hotplugging in needs the private path (deducted from the @mem
argument). The actual creation of the path is done in the only
caller qemuProcessBuildDestroyMemoryPaths().

The rule for the first case (@def) and the second case (@mem) is
the same (domain has a DIMM device that has HP requested) and is
written twice. Move the logic into a function to deduplicate the
code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agodomaincapsdata: Drop expected outputs for old QEMUs
Michal Privoznik [Tue, 18 May 2021 12:59:55 +0000 (14:59 +0200)]
domaincapsdata: Drop expected outputs for old QEMUs

The minimal version of QEMU is 2.11.0 which means we can drop
test cases for older versions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu_capabilities: Update QEMU_MIN_* macros
Michal Privoznik [Tue, 18 May 2021 13:10:17 +0000 (15:10 +0200)]
qemu_capabilities: Update QEMU_MIN_* macros

As of b4cbdbe90bbf85eaf687f532d5a52a11e664b781 (and friends) the
minimal QEMU version required is 2.11.0. Let's update our
QEMU_MIN_* macros to reflect that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agotests: libxl: Mock xs_open and xs_close
Jim Fehlig [Mon, 17 May 2021 17:52:25 +0000 (11:52 -0600)]
tests: libxl: Mock xs_open and xs_close

The Xen-related unit tests are failing against the recently released
Xen 4.15. Xen commit 90c9f9f4dd changed the implementation of
libxl_ctx_alloc to use xs_open instead of xs_daemon_open. libvirt has
already mocked xs_daemon-{open,close} and others to allow using libxl
in confined build environments. This patch adds xs_{open,close} to the
list of functions mocked in libxlmock.c

https://github.com/xen-project/xen/commit/90c9f9f4ddd55e11be0506bff10c6237507c6e0d

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agomeson: Add yajl kludge
Andrea Bolognani [Fri, 14 May 2021 09:03:42 +0000 (11:03 +0200)]
meson: Add yajl kludge

If this looks familiar, that's because it's literally *the
same code* that we used to work around *the same issue* in
readline before 1635dca26f61def3fbf56c70fbbfe514f2b50987 :)

Note that the issue only really affects people building from
source on Apple Silicon: on Intel, Homebrew installs header
files under directories that are part of the default search
path, which explains why our CI pipeline never ran into it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Tested-by: Roman Bolshakov <r.bolshakov@yadro.com>
3 years agoqemu: capabilities: fill in domcaps <filesystem>
Kristina Hanicova [Tue, 18 May 2021 12:50:51 +0000 (14:50 +0200)]
qemu: capabilities: fill in domcaps <filesystem>

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoconf: domcaps: Report device <filesystem>
Kristina Hanicova [Wed, 12 May 2021 17:12:55 +0000 (19:12 +0200)]
conf: domcaps: Report device <filesystem>

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemusecuritytest: Honour EXIT_AM_SKIP
Michal Privoznik [Mon, 17 May 2021 19:34:55 +0000 (21:34 +0200)]
qemusecuritytest: Honour EXIT_AM_SKIP

There is a case where qemusecuritytest is skipped - on MacOS and
MinGW. In such case, EXIT_AM_SKIP should be returned.  However,
my recent patch of 5d99b157bc completely missed that and made the
test return EXIT_FAILURE even though the test exited early
without performing any test case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agotests: Replace deprecated ASN1 code
Luke Yue [Tue, 18 May 2021 01:19:26 +0000 (09:19 +0800)]
tests: Replace deprecated ASN1 code

This fixes compiler warnings when building with libtasn1 4.17.0.

Signed-off-by: Luke Yue <lukedyue@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoviridentity: Fix ref/unref imbalance in VIR_IDENTITY_AUTORESTORE
Michal Privoznik [Mon, 17 May 2021 16:01:11 +0000 (18:01 +0200)]
viridentity: Fix ref/unref imbalance in VIR_IDENTITY_AUTORESTORE

The basic use case of VIR_IDENTITY_AUTORESTORE() is in
conjunction with virIdentityElevateCurrent(). What happens is
that virIdentityElevateCurrent() gets current identity (which
increases the refcounter of thread local virIdentity object) and
returns a pointer to it. Later, when the variable goes out of
scope the virIdentityRestoreHelper() is called which calls
virIdentitySetCurrent() over the old identity. But this means
that the refcounter is increased again.

Therefore, we have to explicitly decrease the refcounter by
calling g_object_unref().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agovirCapabilitiesHostNUMAFormat: Bring variables into loops
Michal Privoznik [Fri, 14 May 2021 15:26:32 +0000 (17:26 +0200)]
virCapabilitiesHostNUMAFormat: Bring variables into loops

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirnumamock: Allow CPU-less NUMA nodes
Michal Privoznik [Mon, 17 May 2021 10:40:00 +0000 (12:40 +0200)]
virnumamock: Allow CPU-less NUMA nodes

The original virNumaGetNodeCPUs() returns an empty virBitmap if
given NUMA node has no CPUs. But that's not how our mock behaves
- it looks under $fakesysfs/node/node$N/cpulist only to find an
empty file which is then passed to virBitmapParseUnlimited()
which threats such input as error.

Fortunately, we don't have any fake sysfs data where this path is
hit, but we might soon.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirnuma: Export virNumaGetMaxCPUs properly
Michal Privoznik [Mon, 17 May 2021 10:43:35 +0000 (12:43 +0200)]
virnuma: Export virNumaGetMaxCPUs properly

This function will be used in virnumamock, shortly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agonuma_conf: Use virXMLFormatElement() in virDomainNumaDefFormatXML
Michal Privoznik [Mon, 3 May 2021 11:25:47 +0000 (13:25 +0200)]
numa_conf: Use virXMLFormatElement() in virDomainNumaDefFormatXML

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agodriver: Don't leak saved error in virGetConnectGeneric()
Michal Privoznik [Mon, 17 May 2021 12:48:36 +0000 (14:48 +0200)]
driver: Don't leak saved error in virGetConnectGeneric()

Recently, a new code was added to virGetConnectGeneric() that
saves the original error into a variable so that it's not lost in
virConnectClose() called under the 'error' label.

However, the error saving code uses virSaveLastError() +
virSetError() combo which leaks the memory allocated for the
error copy. Using virErrorPreserveLast() + virErrorRestore() does
the same job without the memleak.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agotestutils: Document and enforce @func callback retvals for virTestMain()
Michal Privoznik [Sun, 16 May 2021 16:20:56 +0000 (18:20 +0200)]
testutils: Document and enforce @func callback retvals for virTestMain()

When a test has a wrapper over main() (e.g. because it's
preloading some mock libraries). the main() is renamed to
something else (usually mymain()), and main() is generated by
calling one of VIR_TEST_MAIN() or VIR_TEST_MAIN_PRELOAD() macros.

This has a neat side effect - if mymain() returns an error a
short summary is printed, e.g.:

  Some tests failed. Run them using:
  VIR_TEST_DEBUG=1 VIR_TEST_RANGE=5-6 ./virtest

However, this detection only works if EXIT_FAILURE is returned by
mymain(). Document and enforce this limitation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>