Commit Graph

43566 Commits

Author SHA1 Message Date
Peter Krempa 697e796981 qemuMonitorTestProcessCommandDefaultValidate: Partially validate 'device_add'
Use the 'allowIncomplete' argument of testQEMUSchemaValidateCommand to
validate at least properties which are already described by the schema.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-18 14:00:58 +02:00
Peter Krempa b17fd211e2 testQEMUSchemaValidateCommand: Add possibility for partial QMP validation
The QMP schema for 'device_add' is not complete yet. Allow validation of
incomplete schema so that we can enable at least some validation. Once
there's more schema in the future all present members are still
validated.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-18 14:00:58 +02:00
Peter Krempa 387c900de9 qemucapabilitiestest: Update qemu-6.2 cycle capability test data
Update to v6.1.0-1510-gc148a05721 which most notably adds the 'json-cli'
feature for 'device_add' QMP command meaning that -device accepts JSON.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-18 14:00:58 +02:00
Michal Privoznik 8fbffeae07 qemu: Decrease scope of variables in qemuConnectGetAllDomainStats()
There are two variables (@vm and @domflags) in qemuConnectGetAllDomainStats()
that are used only within the for() loop but declared for entire function.
Bring them into the loop to make it obvious they are not used outside of it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2021-10-18 12:09:39 +02:00
Michal Privoznik c2c67fe4fd objecteventtest: Don't overwrite @ret on failure
Our general pattern is to initialize @ret to -1 and set it to 0
only at the end of a function. Some functions in
objecteventtest.c do not follow this pattern.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2021-10-18 12:09:33 +02:00
Michal Privoznik 5ae12eba7f objecteventtest: Drop lifecycleEventCounter_reset()
The sole purpose of the lifecycleEventCounter_reset() function is
to zero out given lifecycleEventCounter struct. Well, we can let
the compiler zero it out when declaring a variable and just
remove the function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2021-10-18 12:09:23 +02:00
Hiroki Narukawa 91f3944935 NEWS: document bug fix about virsh domstats on qemu < 5.2.0
I think that virsh domstats problem on qemu < 5.2.0 is what users want
to find which version fixes.

Signed-off-by: Hiroki Narukawa <hnarukaw@yahoo-corp.jp>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-10-18 10:37:21 +02:00
Hiroki Narukawa fd56272203 qemu_driver: add check for qemu capabilities requirements
query-dirty-rate command is used for virsh domstats by default, but this
is available only on qemu >=5.2.0.

By this commit, qemu domain stats will check capabilities requirements before issuing actual query.

Signed-off-by: Hiroki Narukawa <hnarukaw@yahoo-corp.jp>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-10-18 10:37:19 +02:00
Hiroki Narukawa f29d7c3e69 qemu_driver: add required capabilities to qemuDomainGetStatsWorkers
One of qemuDomainGetStatsWorkers requires capabilities to run.

This commit adds capability information to qemuDomainGetStatsWorkers.

Signed-off-by: Hiroki Narukawa <hnarukaw@yahoo-corp.jp>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-10-18 10:37:17 +02:00
Hiroki Narukawa 06b45f2c5e qemu_capabilities: Add QEMU_CAPS_QUERY_DIRTY_RATE capability
query-dirty-rate command is used for virsh domstats by default, but this
is available only on qemu >=5.2.0.

In this commit, add capability flag for query-dirty-rate first.

Signed-off-by: Hiroki Narukawa <hnarukaw@yahoo-corp.jp>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-10-18 10:37:14 +02:00
Jim Fehlig 2703b0b5bf qemu: Do not report eof when processing monitor IO
There have been countless reports from users concerned about the following
error reported by libvirtd when qemu domains are shutdown

internal error: End of file from qemu monitor

While the error is harmless, users often mistaken it for real problem with
their deployments. EOF from the monitor can't be entirely ignored since
other threads may be using the monitor and must be able to detect the EOF
condition.

One potential fix is to delay reporting EOF until the monitor is used
after EOF is detected. This patch adds a 'goteof' member to the
qemuMonitor structure, which is set when EOF is detected on the monitor
socket. If another thread later tries to send data on the monitor, the
EOF error is reported.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-10-15 11:16:31 -06:00
Michal Privoznik 0a9d5f87b9 virnetsocket: Use g_auto* more
There are few functions in virnetsocket.c where an object/memory
is freed by explicit call. Use g_autoptr()/g_autofree/VIR_AUTOCLOSE
to do that automatically.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-15 16:03:47 +02:00
Michal Privoznik 44d8324f13 virnetsocket: Don't free virCommand in virNetSocketNewConnectCommand()
The aim of virNetSocketNewConnectCommand() is to execute passed
command and attach socket pair/pipe to it so that client socket
can be opened (this is used for connections with alternative
transports, e.g. ssh). The virCommand is created in a caller and
then passed to virNetSocketNewConnectCommand() where it is freed
using virCommandFree(). This approach is wrong on two levels:

1) The deallocation happens on a different level than allocation,
2) There's a WIN32 stub that just reports an error and doesn't
   free the command.

However, with g_autoptr() trickery the command can be freed in
caller.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-15 16:03:22 +02:00
Hiroki Narukawa d9afe162ab qemu_validate: Fix capability check for disk queue_size
Commit ad209e7d adds QEMU_CAPS_VIRTIO_BLK_QUEUE_SIZE capability, but
the following commit 2d6d67e1 missed to use it and uses
QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES instead.

This commit fixes the mistake.

Signed-off-by: Hiroki Narukawa <hnarukaw@yahoo-corp.jp>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-10-15 14:38:35 +02:00
Michal Privoznik 0cddf1978c qemu: capabilities: Retire QEMU_CAPS_VIRTIO_PCI_ATS
The capability reflects whether QEMU is capable of -device
virtio-*,ats=. Since the property was introduced in QEMU commit
v2.9.0-rc0~162^2~32 we can safely assume the property is always
present as the minimal version required is 2.11.0.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-15 12:49:11 +02:00
Michal Privoznik 8607dc3706 qemuxml2argvtest: Drop negative virtio-*-ats tests
There are some tests cases in qemuxml2argvtest that aim to check
whether our validator rejects <driver ats=''/> when
QEMU_CAPS_VIRTIO_PCI_ATS capability is not present.  Well, such
scenario can't happen really because the capability will always
be present.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-15 12:49:07 +02:00
Michal Privoznik 02c4c29823 qemu: capabilities: Retire QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM
The capability reflects whether QEMU is capable of -device
virtio-*,iommu_platform=. Since the property was introduced in
QEMU commit v2.9.0-rc0~162^2~37 we can safely assume the property
is always present as the minimal version required is 2.11.0.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-15 12:49:04 +02:00
Michal Privoznik 4b91b98889 qemuxml2argvtest: Drop negative virtio-*-iommu tests
There are some tests cases in qemuxml2argvtest that aim to check
whether our validator rejects <driver iommu=''/> when
QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM capability is not present.
Well, such scenario can't happen really because the capability
will always be present.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-15 12:48:59 +02:00
Michal Privoznik 01bfd5e33d test: Drop unused .args or .xml files
There are a few files containing expected output for test cases
that no longer exist. Remove them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-15 12:48:47 +02:00
Han Han d139171d80 qemu: Add support for virtio device option page-per-vq
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1925363

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-10-15 09:40:58 +02:00
Han Han 388cdd11f3 conf: Add page_per_vq for driver element
Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Gavi Teitz <gavi@nvidia.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-10-15 09:40:55 +02:00
Kristina Hanicova 61cb54e3cb qemu_migration: drop unnecessary 'migrate_speed' variable
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-10-13 12:43:54 +02:00
Kristina Hanicova 8c26fd7823 qemu_migration: set bandwidth in priv during migration
We did not set priv->migMaxBandwidth if '--bandwidth' was
specified as an option in the 'migrate' virsh command. This
caused in printing the wrong value if virsh command
'migrate-getspeed' was called during the migration. This patch
first sets the value to the given bandwidth (if one was
specified) and restores the previous value after the migration.

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

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-10-13 12:19:13 +02:00
Peter Krempa 926864ba45 qemuBuildFloppyCommandLineControllerOptionsExplicit: Generate via JSON
QEMU declares the bootindex types as:

  bootindexA=<int32>
  bootindexB=<int32>

The driveA/driveB parameters were deprecated and removed in qemu-6.0.
We'll keep them for compatibility, but they are not used with -blockdev.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 20:54:53 +02:00
Peter Krempa 245e8a12fd qemuBuildFloppyCommandLineControllerOptions: Extract formatting of implicit/explicit fdc
qemuBuildFloppyCommandLineControllerOptions was generating config for
both the implicit and explicit fdc. The explicit FDC is using '-device'
and thus will need to be converted to JSON.

Split up the lookup of the floppy drive configs from the actual command
generation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 20:54:53 +02:00
Peter Krempa 9e359909d5 qemuBuildSmartcardCommandLine: Generate via JSON
QEMU declares the props we control as:

'ccid-card-emulated'
  backend=<str>
  cert1=<str>
  cert2=<str>
  cert3=<str>
  db=<str>

'ccid-card-passthru'
  chardev=<str>          - ID of a chardev to use as a backend

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 20:54:53 +02:00
Peter Krempa cefa20b727 qemuBuildIOMMUCommandLine: Generate via JSON
QEMU declares the following types for fields we control:

  intremap=<OnOffAuto>   - on/off/auto (default: "auto")
  caching-mode=<bool>    -  (default: false)
  eim=<OnOffAuto>        - on/off/auto (default: "auto")
  device-iotlb=<bool>    -  (default: false)
  aw-bits=<uint8>        -  (default: 39)

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 20:54:53 +02:00
Peter Krempa 5d51f836b0 qemuBuildVMCoreInfoCommandLine: Generate via JSON
While this device doesn't have any properties it must be converted to
use qemuBuildDeviceCommandlineFromJSON so that we can validate it in the
future.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 20:54:53 +02:00
Peter Krempa 5e24a5021c qemuBuildTPMProxyCommandLine: Generate via JSON
All properties are strings according to QEMU.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 20:54:53 +02:00
Peter Krempa 304ffa2dff qemuBuildVMGenIDCommandLine: Generate via JSON
QEMU declares the 'guid' property as:

  guid=<str>             - UUID (aka GUID) or "auto" for random value (default) (default: "auto")

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 20:54:53 +02:00
Peter Krempa 1b61610784 qemuValidateDomainSmartcardDef: Move validation of smartcard count
Move it into the validator. Note that the placement into the device
validation part is intentional so that it also covers hotplug code
paths.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 20:54:53 +02:00
Peter Krempa b4026d9509 qemuBuildSmartcardCommandLine: Replace qemuBuildSmartcardFindCCIDController
We have a commonly used helper virDomainControllerAliasFind, which does
the same thing and also reports errors internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 20:54:53 +02:00
Peter Krempa 43d48eebf9 virDomainSmartcardDef: Declare 'type' as virDomainSmartcardType
Use 'virXMLPropEnum' to parse it and fix all switch statements which
didn't include the VIR_DOMAIN_SMARTCARD_TYPE_LAST case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 20:54:53 +02:00
Peter Krempa 3c819a6ce8 qemuValidateDomainSmartcardDef: Move chardev validation under VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH
Don't check the type twice, move the chardev validation into the
switch.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 20:54:53 +02:00
Peter Krempa d27edba370 qemuValidateDomainSmartcardDef: Unbreak error messages
https://www.libvirt.org/coding-style.html#error-message-format

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 20:54:53 +02:00
Peter Krempa 5dc34a44a4 qemuBuildDeviceCommandlineFromJSON: Remove unused keyword
Now that the code was converted to use this helper we can remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 20:54:53 +02:00
Peter Krempa 58d915b2d3 qemuBuildStorageSourceAttachPrepareDrive: Fix function comment
Remove mention of argument which no longer exists.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 20:54:53 +02:00
Praveen K Paladugu a0ec7165e3 tools: add virt-host-validate-ch for ch driver
Signed-off-by: Wei-Chen Chen <weicche@microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-10-12 17:28:35 +02:00
Peng Liang 4c0cf7c4dc spec: change the ownership of cache directory
In a50c473ad6 ("qemu: move temp file of screenshot and memorypeek to
per-domain dir") and c4f3c955d5 ("qemu: don't change ownership of
cache directory"), I move the temporary files of screenshot and
memorypeek from the cache directory to per-domain directory, and the
only user of the cache directory is the domain capabilities currently.
Since the domain capabilities are used by libvirtd, no need to set the
ownership of the cache directory to qemu_user and qemu_group.

Signed-off-by: Peng Liang <liangpeng10@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-10-12 16:54:49 +02:00
Julio Faracco 946664db75 gitdm: Add other email into Red Hat company list
Some people from Red Hat does not use 'redhat.com' domain emails.
They use personal or other domains.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-10-12 16:46:45 +02:00
Ján Tomko daa8d3220d qemu: correctly pass qemuBuildVHostUserFsDevProps
../../work/libvirt/src/qemu/qemu_hotplug.c: In function ‘qemuDomainAttachFSDevice’:
../../work/libvirt/src/qemu/qemu_hotplug.c:3458:68: error: ordered comparison of pointer with integer zero [-Werror=extra]
 3458 |     if (qemuBuildVHostUserFsDevProps(fs, vm->def, charAlias, priv) < 0)
      |                                                                    ^
cc1: all warnings being treated as errors

Fixes: b987873034
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 15:33:01 +02:00
Ján Tomko 0d2ea8873b qemu: implement virtiofs hotunplug
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-12 14:41:13 +02:00
Ján Tomko b987873034 qemu: implement virtiofs hotplug
https://bugzilla.redhat.com/show_bug.cgi?id=1897708

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-12 14:41:13 +02:00
Peter Krempa c30064a94c qemucapabilitiestest: Add test data for the qemu-6.2 development cycle
The data is based on commit v6.1.0-1313-gc09124dcb8

Notable changes:

- New machine types for the 6.2 cycle were added
- MEM_UNPLUG_ERROR event was deprecated and replaced by
  DEVICE_UNPLUG_GUEST_ERROR
- Intel SGX related commands and devices added
- 'copy-before-write' blockdev filter was added
- 'memory-backend-epc' was added
- new cpu flags

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-10-12 14:23:53 +02:00
Ján Tomko f1818032f5 qemu: Revert "qemuExtDevicesStart: pass logManager"
This reverts commit b164eac5e1

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-12 14:12:11 +02:00
Ján Tomko 7add201508 qemu: virtiofs: open a separate connection to virtlogd
Do not depend on passing a logManager. Create a new connection.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-12 14:12:11 +02:00
Ján Tomko 131361f6bc logging: define cleanup func for virLogManager
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-12 14:12:11 +02:00
Peter Krempa 3ba4d96736 qemu: command: Remove unused 'qemuBuildDeviceAddressStr'
All users were converted to the JSON counterpart.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 11:11:13 +02:00
Peter Krempa 89ba187943 qemuBuildTPMCommandLine: Generate via JSON
We control only the 'tpmdev' property of TPM devices which is a string.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 11:11:13 +02:00
Peter Krempa 173b990a82 qemuBuildHubCommandLine: Generate via JSON
The 'usb-hub' device doesn't have any special properties.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 11:11:13 +02:00