Commit Graph

42211 Commits

Author SHA1 Message Date
Peter Krempa
c63a3ba258 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>
2021-05-24 20:38:08 +02:00
Peter Krempa
0ad33f48c5 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>
2021-05-24 20:38:08 +02:00
Peter Krempa
02f843e70a 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>
2021-05-24 20:38:08 +02:00
Peter Krempa
7c67afce65 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>
2021-05-24 20:38:08 +02:00
Peter Krempa
3df66f27a6 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>
2021-05-24 20:38:08 +02:00
Peter Krempa
8878b94abc 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>
2021-05-24 20:38:08 +02:00
Peter Krempa
4130cc1f7b 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>
2021-05-24 20:38:08 +02:00
Peter Krempa
2976b6aaeb 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>
2021-05-24 20:38:07 +02:00
Masayoshi Mizuma
b4d87669ba 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>
2021-05-24 20:38:07 +02:00
Peter Krempa
b7583a5ba3 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>
2021-05-24 20:38:07 +02:00
Peter Krempa
f9e8857eec 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>
2021-05-24 20:38:07 +02:00
Peter Krempa
2ec54727f7 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>
2021-05-24 20:38:07 +02:00
Peter Krempa
18f976abe2 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>
2021-05-24 20:38:07 +02:00
Peter Krempa
983bad4771 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>
2021-05-24 20:38:07 +02:00
Peter Krempa
06e9b0c28d 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>
2021-05-24 20:38:07 +02:00
Peter Krempa
81db8b6d89 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>
2021-05-24 20:38:07 +02:00
Peter Krempa
92a3eddd03 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>
2021-05-24 20:26:20 +02:00
Peter Krempa
bbd55e9284 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>
2021-05-24 20:26:20 +02:00
Peter Krempa
fac773fab9 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>
2021-05-24 20:26:20 +02:00
Michal Privoznik
4b3dc045b9 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>
2021-05-24 19:57:45 +02:00
Michal Privoznik
773118632e 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>
2021-05-24 14:49:28 +02:00
Michal Privoznik
ccb8acc966 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>
2021-05-24 14:49:28 +02:00
Michal Privoznik
fe25224fda 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>
2021-05-24 14:49:28 +02:00
Pavel Hrdina
8b118c909a 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>
2021-05-24 14:31:42 +02:00
Han Han
6ff937747c 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>
2021-05-24 12:47:15 +02:00
Olaf Hering
d8c468d58c 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>
2021-05-21 10:59:47 -06:00
Olaf Hering
2b51050b10 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>
2021-05-21 10:58:53 -06:00
Olaf Hering
2d0decccba 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>
2021-05-21 10:57:36 -06:00
Kristina Hanicova
7ab1ba112f 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>
2021-05-21 12:46:31 -04:00
Kristina Hanicova
b6b6725c95 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>
2021-05-21 14:38:09 +02:00
Kristina Hanicova
bcdaa91a27 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>
2021-05-21 14:36:57 +02:00
Kristina Hanicova
483e943884 qemu: Build command line for object input-linux
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/142

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
2021-05-21 14:29:09 +02:00
Kristina Hanicova
cff0444e51 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>
2021-05-21 14:29:09 +02:00
Kristina Hanicova
3bfbc3c0ef qemu_capabilities: Add QEMU_CAPS_INPUT_LINUX
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-05-21 14:29:09 +02:00
Pavel Hrdina
93344aed27 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>
2021-05-21 14:00:55 +02:00
Pavel Hrdina
3e1d2c93a3 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>
2021-05-21 14:00:43 +02:00
Kristina Hanicova
19967f64f4 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>
2021-05-21 08:51:11 +02:00
Ján Tomko
015fe0439f 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>
2021-05-20 16:27:21 +02:00
Michal Privoznik
7166b1ec7e NEWS: Document new memory dump format
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-05-20 16:24:11 +02:00
Michal Privoznik
3de70da32d 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>
2021-05-20 16:24:06 +02:00
Michal Privoznik
c2707c7e3c 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>
2021-05-20 16:23:32 +02:00
Michal Privoznik
8e75ecefd7 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>
2021-05-20 16:21:03 +02:00
Michal Privoznik
9d4cd1d1cd virNodeDevCapMdevParseXML: Use virXMLPropEnum() for ./start/@type
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-05-20 16:08:02 +02:00
Peter Krempa
7eb281f91c 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: 42a5585499
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2021-05-20 12:17:09 +02:00
Tim Wiederhake
3d5591aede 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>
2021-05-20 11:52:46 +02:00
Tim Wiederhake
99037fb2b9 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>
2021-05-20 11:52:44 +02:00
Tim Wiederhake
058d4ed47e virStorageAdapterFCHost: Change type of "type" to virStorageAdapterType
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-05-20 11:52:41 +02:00
Tim Wiederhake
8e2d030e26 virStorageAdapterParseXML: Use g_autofree
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-05-20 11:52:38 +02:00
Tim Wiederhake
b127e50290 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>
2021-05-20 11:52:35 +02:00
Tim Wiederhake
5ad6db604a virDomainAudioDefParseXML: Don't ignore return value of virDomainAudio*Parse()
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-05-20 11:52:32 +02:00