Commit Graph

43161 Commits

Author SHA1 Message Date
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
Michal Privoznik
e0dcdaefe2 qemuDomainOpenFile: Take virDomainDef instead of virDomainObj
The function doesn't really need domain object, but domain
definition from which it takes seclabels.

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:05 +02:00
Michal Privoznik
34ce7e7e96 virDomainDefGetSecurityLabelDef: Fix const correctness
The function doesn't write to domain definition really so make
@def argument as const. This allows us to call it from functions
where the domain definition is already const.

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:21:10 +02:00
Olaf Hering
42158b8936 libxl: remove conditionals from discard configuration
LIBXL_HAVE_LIBXL_DEVICE_DISK_DISCARD_ENABLE exists since Xen 4.5.0

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2021-08-13 08:44:01 -06:00
Ján Tomko
69e810945e util: xml: clean up unnecessary ret variables
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-12 15:47:36 +02:00
Ján Tomko
441d2f4e23 util: xml: use g_auto for xmlXPathObject
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-12 15:47:36 +02:00
Ján Tomko
8f6657aea9 util: define cleanup func for xmlXPathObject
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-08-12 15:47:36 +02:00
Kristina Hanicova
68d386913f conf: replace validation with variables passed to virXMLParse()
virXMLParse() now allows validating xml against schema directly,
eliminating the need to do it individually in each function.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-08-12 13:12:29 +02:00
Kristina Hanicova
6106327b23 domain_conf: Remove redundant variable
xmlDocPtr is no longer needed, because validation against schema
was moved to another function.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-08-12 13:12:29 +02:00
Kristina Hanicova
e6c730c865 domain_conf: replace validation with variables passed to virXMLParse()
virXMLParse() now allows to validate xml against schema directly,
eliminating the need to do it individually.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-08-12 13:12:29 +02:00
Kristina Hanicova
323a1318a3 util: add xml validation against schema in virXMLParseHelper()
We need this in order to validate XML against schema at one
place, rather than have the same code for validation in different
functions.
I will add '--validate' option to more virsh commands soon and
this makes it easier as virXMLParse() is called in every one I
plan to change.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-08-12 13:12:29 +02:00
Kristina Hanicova
f43c27960e src: add 'schema' and 'validate' variable to virXMLParseHelper()
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-08-12 13:12:29 +02:00
Ján Tomko
4de7ccc4d8 vsh: steal pointer in vshEditWriteToTempFile
Fixes: 13896b5ad1
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-08-12 11:45:21 +02:00