Commit Graph

42823 Commits

Author SHA1 Message Date
Peter Krempa
f95dc8286f qemuxml2argvtest: Remove 'minimal-sandbox' case
All modern qemus support sandboxing so this is covered by other tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:59:08 +02:00
Peter Krempa
aa7d6ef97c qemuxml2argvtest: Remove 'minimal-msg-timestamp'
The feature is supported by all supported qemu versions thus covered
thoroughly by other test cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:58:46 +02:00
Peter Krempa
05fb347463 qemuxml2argvtest: Remove 'debug-threads' case
The test is now pointless since we always assume that this option is
present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:58:23 +02:00
Peter Krempa
556bfdb85d qemu: capabilities: Add alternative detection of QEMU_CAPS_NUMA
'set-numa-node' is the command which can set the equivalent parameters
to '-numa' in preconfig mode, so we can use it as witness to see that
-numa is supported.

To ensure that the old detection method is removed once we'll be bumping
qemu support add a comment with the appropriate version check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:58:11 +02:00
Peter Krempa
88f7511923 qemuMonitorSetBlockIoThrottle: Remove booleans controlling used fields
All supported QEMU versions have all the fields so we can remove the
booleans controlling which fields are used on the monitor.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:57:34 +02:00
Peter Krempa
059103869e qemuMonitorJSONSetBlockIoThrottle: Switch to standard error reporting
Use qemuMonitorJSONCheckError instead of handcrafted error reporting.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:57:22 +02:00
Peter Krempa
2d57075cb6 qemuMonitorJSONSetBlockIoThrottle: Refactor cleanup
Switch to automatic memory freeing and remove the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:57:10 +02:00
Peter Krempa
9c3fdcdfec qemu: capabilties: Retire QEMU_CAPS_DRIVE_IOTUNE_* caps
They are no longer used as we now assume that all tuning caps are
present and in case some will be removed we'll need to use different
probing methods.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:56:33 +02:00
Peter Krempa
96ecc3e208 qemu: Always assume that qemu supports drive throttling
All currently supported qemu versions support all throttling
capabilities. It is unlikely that any of the fields will be removed in
the future and if it will we will need to do specific probing which is
possible via the 'throttle' object which is the replacement for the
legacy way to configure throttling.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:56:17 +02:00
Peter Krempa
fb5a246424 qemu: capabilities: Probe QEMU_CAPS_SMP_DIES from the QMP schema
The configurability of the number of dies in a CPU can be inferred from
the presence of the 'die-id' field in 'query-hotpluggable-cpus'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:56:07 +02:00
Peter Krempa
067f44fd0b qemu: capabilities: Probe 'discard' and 'detect-zeroes' from 'blockdev-add'
Probing QEMU_CAPS_DRIVE_DISCARD and QEMU_CAPS_DRIVE_DETECT_ZEROES can be
replaced by looking into the QMP schema rather than looking at -drive
which isn't in use any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:55:56 +02:00
Peter Krempa
2a47d74758 qemu: capabilities: Rename QEMU_CAPS_CHARDEV_FD_PASS to QEMU_CAPS_CHARDEV_FD_PASS_COMMANDLINE
Make it more obvious that we care about passing FDs on the commandline
before startup of qemu, which is used to avoid startup monitor polling.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:54:46 +02:00
Peter Krempa
f64fc98506 qemu: capabilities: Probe 'reconnect', 'logfile' and 'append' from 'chardev-add'
QEMU_CAPS_CHARDEV_RECONNECT, QEMU_CAPS_CHARDEV_LOGFILE and
QEMU_CAPS_CHARDEV_FILE_APPEND can be probed from the appropriate fields
in 'chardev-add' probed via the QMP schema instead of the command line
parameters.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:37:09 +02:00
Peter Krempa
ef5f998a96 qemu: capabilities: Note that basing probing on 'query-command-line-options' should be avoided
Add a comment that will attempt to discourage adding new capabilities
based on 'query-command-line-options'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:37:09 +02:00
Peter Krempa
42e7f6a35b scripts: group-qemu-caps: Add capability name as comment to capability string
Add a cross reference of the enum value name with the string
representation. This allows a quick cross-reference of the values
without having to open the header and implementation files separately.

To achieve this the checker code at first obtains a list of the
flags and cross-references them when checking the grouping in
syntax-check, thus we are guaranteed to stay in sync.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:37:09 +02:00
Peter Krempa
0a8e44bc9f virQEMUCapsQMPSchemaQueries: Group by queried object name
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:37:09 +02:00
Peter Krempa
3cb391b39c virQEMUCapsCommandLine: Group by commandline argument name alphabetically
Further commits will be refactoring and minimizing capabilities being
parsed from 'query-command-line-options'. Group the struct driving the
detection by argument name so it's easier to spot options belonging
together.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:37:08 +02:00
Peter Krempa
c678f2d61b qemuxml2argvtest: Remove negative tests for (aes|dea)keywrap (s390) property
Upcoming commit will always add the property so the negative tests would
stop working.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 09:37:08 +02:00
Ján Tomko
5590fbf8d6 Remove redundant labels
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-17 18:27:13 +02:00
Ján Tomko
9302e249db Use g_autofree in affected functions
Add g_autofree to functions changed in previous commits doing
g_auto cleanup for libxml2-related variables, where it could
lead to removal of a label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-17 18:27:13 +02:00
Ján Tomko
2c426d2e30 Use g_auto for xmlFreeDoc everywhere
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-17 18:27:13 +02:00
Ján Tomko
5dae71ee8c Use g_auto for xmlXPathContext everywhere
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-17 18:27:13 +02:00
Ján Tomko
4a8ce37bf1 conf: refactor virNetworkLoadState
Use g_auto where possible, reducing variable scope where applicable.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-17 18:27:13 +02:00
Ján Tomko
1550892e85 conf: virCPUDefListParse: reduce scope of variables
Move 'ctxt' and 'doc' inside the loop and mark them with g_auto.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-17 18:27:13 +02:00
Pavel Hrdina
c6c3dd5971 vircgroup: fix build on non-linux systems
virCgroupGetInode needs to be in '#ifdef __linux__'.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-17 15:29:38 +02:00
Pavel Hrdina
6cbb1865d8 qemu: implement support for Fibre Channel VMID
Based on kernel commit messages the interface is

    /sys/class/fc/fc_udev_device/appid_store

where we need to write the following string "$INODE:$APPID".

$INODE is the VM root cgroup inode in hexadecimal and $APPID is user
provided string that will be attached to each FC frame for the VM
within the cgroup identified by inode and has limit 128 bytes.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-17 13:51:40 +02:00
Pavel Hrdina
38b5f4faab conf: introduce support for Fibre Channel VMID
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-17 13:50:38 +02:00
Pavel Hrdina
9ea9f7dab2 conf: refactor virDomainResourceDefFormat
Prepare the function for additional sub-elements where all of the
sub-elements are optional.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-17 12:35:45 +02:00
Pavel Hrdina
77b53057c7 conf: refactor virDomainResourceDefParse
There is no need to error out for empty <partition></partition> element
as we can just simply ignore it. This allows to simplify the function
and prepare it for new sub-elements of <resource>.

It makes the <partition> element optional so we need to reflect the
change in schema as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-17 12:35:45 +02:00
Pavel Hrdina
10c2c0b249 vircgroup: introduce virCgroupGetInode function
For new feature Fibre Channel VMID we will need to get inode of the
VM root cgroup as it is used in the new kernel API together with VMID.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-17 12:35:45 +02:00
Zhenyu Ye
f14d6ab537 security: fix use-after-free in virSecuritySELinuxReserveLabel
commit 2e668a61d5ae4("Fix error handling when adding MCS labels") uses
the 'pctx' in virReportError after it has been freed. Fix it.

Fixes: 2e668a61d5
Signed-off-by: Zhenyu Ye <yezhenyu2@huawei.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-17 12:07:36 +02:00
Michal Privoznik
32f7db0989 vmx: Support super wide SCSI bus
Since its 6.7 release, vSphere allows up to 64 units on a SCSI
bus [1]. The release version translates to virtualHW_version 13
and thus if we are dealing with sufficiently new version we can
enable the feature.

1: https://configmax.vmware.com/guest?vmwareproduct=vSphere&release=vSphere%206.7&categories=1-0

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1738392
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-16 14:22:38 +02:00
Michal Privoznik
5c254bb541 conf: Store SCSI bus length in virDomainDef
Libvirt assumes that a SCSI bus can fit up to 8 devices
(including controller itself), except for so called wide bus
which can accommodate up to 16 devices (again, including
controller). This plays important role when computing 'drive'
address in virDomainDiskDefAssignAddress(). So far, the only
driver that enables wide SCSI bus is VMX. But with newer
releases, ESX is capable of "super wide" bus (64 devices).

We can blindly bump the limit in our code because then we would
compute address that's invalid for older ESX versions that we
still want to support.

Unfortunately, I haven't found a better place where to store this
than virDomainDef.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-16 14:22:38 +02:00
Michal Privoznik
48344c640f vmx: Drop needless check in virVMXParseDisk()
After previous patch it can no longer happen that @def will be
NULL and *def won't be.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-16 14:22:38 +02:00
Michal Privoznik
d628c5ded1 vmx: Rework disk def allocation
The way we parse VMX configuration is rather unfortunate,
especially when it comes to disks. We allocate an array that can
handle all possible disks but leave the array counter (ndisks) at
zero and increase it only after successful parsing. But, we never
size the array down to release unneeded chunks of memory.

We can do better: we can use VIR_APPEND_ELEMENT() to allocate
array as needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-16 14:22:38 +02:00
Michal Privoznik
de1829059a vmx2xmltest: Add a test case
This is an attachment from the following bug:

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

Notice that .vmx file has two scsi disks, but only one is
reported in the XML. This will be fixed later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-16 14:22:38 +02:00
Michal Privoznik
5e16038284 vmx: Fill virtualHW.version to ESX version mapping
At the beginning of vmx.c we have a comment that maps
virtualHW.version field onto ESX version. However, it wasn't
updated in a while. Fill it in using the following kbase article:

  https://kb.vmware.com/s/article/1003746

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-16 14:22:38 +02:00
Ján Tomko
bd1f40fe7d tools: virsh: remove redundant labels
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-16 13:10:34 +02:00
Ján Tomko
fba265e2b2 tools: virsh: use g_autofree
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-16 13:10:34 +02:00
Ján Tomko
07b40abe0f tools: virsh: use automatic cleanup for char **
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-16 13:10:34 +02:00
Ján Tomko
851e66e05d tools: virsh: reduce variable scope to use automatic cleanup
Some variables are used in a loop and only freed in the cleanup
section because we need to be able to jump out of the loop.

Reduce their scope and free them automatically.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-16 13:10:34 +02:00
Ján Tomko
4b72960b4e tools: virsh: use automatic cleanup for vshTable
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-16 13:10:34 +02:00
Ján Tomko
5f7cdb0efc tools: virsh: use automatic cleanup for xmlDoc
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-16 13:10:34 +02:00
Ján Tomko
2a7e5240ff tools: virsh: use automatic cleanup for xmlXPathObject
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-16 13:10:34 +02:00
Ján Tomko
be72434d79 tools: virsh: use automatic cleanup for xmlXPathContext
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-16 13:10:33 +02:00
Ján Tomko
cf337df3d6 tools: virsh: use automatic cleanup for virDomainObj
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-16 13:10:33 +02:00
Ján Tomko
7c0443fb73 tools: virsh: cmdDominfo: rename 'ostype' variable
Use 'ostype' instead of generic 'str', to discourage
reuse. Also mark it as autofree.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-16 13:10:33 +02:00
Ján Tomko
65551e2239 tools: virsh: split variable declarations
One variable per line.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-16 13:10:33 +02:00
Michal Privoznik
4705edf6cc qemu: Open chardev logfile on behalf of QEMU
If the QEMU driver is configured to use the old "file" stdio
handler (meaning virtlogd is out of the picture) and a chardev
has a log file configured we rely on QEMU being able to create
the file itself. This may not be always possible (e.g. if the
logfile is set to a directory that QEMU process can't reach).
In such case we should create the file and just pass its FD to
QEMU.

We could do that unconditionally and just either pass FD from
virtlogd or the one we opened, because we bumped QEMU version
and are now requiring new enough QEMU. However, I'm keeping the
old style where logfile is appended on the cmd line for the tests
sake.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1989457
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Tested-by: Ján Tomko <jtomko@redhat.com>
2021-08-16 09:25:13 +02:00
Michal Privoznik
b5958b2863 qemuDomainOpenFile: Take @cfg instead of driver
Again, we don't need full driver, just its config.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Tested-by: Ján Tomko <jtomko@redhat.com>
2021-08-16 09:24:38 +02:00