Commit Graph

7357 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
6e9231d6c0 qemuBuildVideoCommandLine: Generate via JSON
We control the following properties of the devices in question:

'virtio-gpu'
  virgl=<bool>           - on/off (default: true)

'qxl'
  ram_size=<uint32>      -  (default: 67108864)
  vram_size=<uint64>     -  (default: 67108864)
  vram64_size_mb=<uint32> -  (default: 4294967295)
  vgamem_mb=<uint32>     -  (default: 16)
  max_outputs=<uint16>   -  (default: 0)

'vhost-user-gpu'
  max_outputs=<uint32>   -  (default: 1)
  chardev=<string>

'VGA'
  vgamem_mb=<uint32>     -  (default: 16)

'bochs-display'
  vgamem=<size>          -  (default: 16777216)

common for all devices:
  xres=<uint32>          -  (default: 0)
  yres=<uint32>          -  (default: 0)

The only noticable change is using memory size in bytes for
'bochs-display' instead of kibibytes.

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
cb1721767b qemu: monitor: Remove legacy 'device_add' infrastrcture
Remove the old-style 'device_add' helpers which parse the commandline
arguments to JSON since we now coverted all usage to use JSON directly.

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
9ac91fcceb qemuBuildChrDeviceCommandLine: Generate via JSON
Build commandlines for character devices via JSON.

For devices using 'VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL' address
type 'qemuBuildDeviceAddressProps' will now generate the address. The
only special property is 'nr'. QEMU declares it as:

  nr=<uint32>            -  (default: 4294967295)

The test fallout is caused by formatting addresses as decimal numbers
instead of hex as described in the commit which added
'qemuBuildDeviceAddressProps'.

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
3e8d38237d qemuBuildUSBControllerDevStr: Split out validation of USB controller
Move the validation code into a separate function. For now the
validation is still kept in the commandline format step as simply just
moving it to the validator causes failures in the test suite, which will
need to be investigated deeper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:05 +02:00
Peter Krempa
d8f04f1575 qemuBuildControllerPCIDevStr: Format via JSON properties
Internally format the PCI controller properties into JSON, but convert
it back to a string so that we for now change just the SCSI controller.

The change in tests is expected as the 'port' field for various PCI
controllers is expected to be a number and thus can't be represented as
a hexadecimal value in JSON.

QEMU expects the following types:

'pci-bridge'
  chassis_nr=<uint8>     -  (default: 0)

'pxb-pcie':
  bus_nr=<uint8>         -  (default: 0)

'pcie-root-port'
  port=<uint8>           -  (default: 0)
  chassis=<uint8>        -  (default: 0)
  hotplug=<bool>         -  (default: true)

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:05 +02:00
Peter Krempa
626df95907 qemuBuildControllerSCSIDevStr: Format via JSON properties
Internally format the SCSI controller properties into JSON, but convert
it back to a string so that we for now change just the SCSI controller.

The change in tests is expected as the 'reg' field for a spapr-vio
address is expected to be a number:

  $ qemu-system-ppc64 -device spapr-vscsi,help
  spapr-vscsi options:
    reg=<uint32>           -  (default: 4294967295)

The hand-rolled generator used hex representation but that will not be
possible on the monitor via JSON.

The properties of 'virtio-scsi' have following types according to QEMU:

  iothread=<link<iothread>>
  num_queues=<uint32>    -  (default: 4294967295)
  cmd_per_lun=<uint32>   -  (default: 128)
  max_sectors=<uint32>   -  (default: 65535)
  ioeventfd=<bool>       - on/off (default: true)

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:05 +02:00
Peter Krempa
e840ed6f3d qemuBuildNicDevProps: Move formatting of bootindex
Move the bootindex before the address so that the code is simpler.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:05 +02:00
Peter Krempa
dc481f11a6 qemuBuildDiskCommandLine: Generate via JSON
The types for the special fields of the 'virtio-blk-pci' according to
QEMU are:
  iothread=<link<iothread>>
  ioeventfd=<bool>       - on/off (default: true)
  event_idx=<bool>       - on/off (default: true)
  scsi=<bool>            - on/off (default: false)
  num-queues=<uint16>    -  (default: 65535)
  queue-size=<uint16>    -  (default: 256)

For all disks we also use the following properties (based on 'scsi-hd'):
  device_id=<str>
  share-rw=<bool>        -  (default: false)
  drive=<str>            - Node name or ID of a block device to use as a backend
  chardev=<str>          - ID of a chardev to use as a backend  <-  vhost-user-blk-pci
  bootindex=<int32>
  logical_block_size=<size> - A power of two between 512 B and 2 MiB (default: 0)
  physical_block_size=<size> - A power of two between 512 B and 2 MiB (default: 0)
  wwn=<uint64>           -  (default: 0)
  rotation_rate=<uint16> -  (default: 0)
  vendor=<str>
  product=<str>
  removable=<bool>       - on/off (default: false)
  write-cache=<OnOffAuto> - on/off/auto (default: "auto")
  cyls=<uint32>          -  (default: 0)
  heads=<uint32>         -  (default: 0)
  secs=<uint32>          -  (default: 0)
  bios-chs-trans=<BiosAtaTranslation> - Logical CHS translation algorithm, auto/none/lba/large/rechs (default: "auto") <- ide-hd
  serial=<str>
  werror=<BlockdevOnError> - Error handling policy, report/ignore/enospc/stop/auto (default: "auto")
  rerror=<BlockdevOnError> - Error handling policy, report/ignore/enospc/stop/auto (default: "auto")

The 'wwn' field is changed from a hex string to a number since qemu
actually treats it as a number.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:04 +02:00
Peter Krempa
9616976433 qemu: capabilities: Retire QEMU_CAPS_VIRTIO_(BLK|NET)_EVENT_IDX
Both are assumed as always present since last commit.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:04 +02:00
Peter Krempa
bc5c57ad7e qemu: capabilities: Retire QEMU_CAPS_VIRTIO_IOEVENTFD
It's not used since last commit.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:04 +02:00
Peter Krempa
6c3a85648c qemuBuildSCSIHostdevDevProps: Reorder 'drive','id' and 'bootindex' after address
Simplify the generator by shuffling around few fields.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:04 +02:00
Peter Krempa
2e4bc16370 qemuBuildPCIHostdevDevProps: Move 'failover_pair_id' property before address
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:04 +02:00
Peter Krempa
9ac81c58d3 qemuBuildHostdevMediatedDevProps: Move 'ramfb' and 'bootindex' before the address
Simplify the generator by moving few properties earlier.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:03 +02:00
Peter Krempa
c234430b73 qemuBuildMemballoonCommandLine: Reorder properties
Move the 'deflate-on-oom' and 'free-page-reporting' before the address
to simplify the genrator code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:03 +02:00
Peter Krempa
d5ae0517dc qemuBuildVirtioDevStr: Format also virtioOptions
Merge the code from qemuBuildVirtioOptionsStr so that we don't have to
call two separate functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:02 +02:00
Peter Krempa
fd2aed1ab5 qemuxml2xmltest: Remove 'panic-isa' case
The same test in regards to the 'panic' device is the 'panic-double'
case, thus panic-isa can be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:00 +02:00
Peter Krempa
bab8d47797 qemuxml2argvtest: Convert 'panic' test cases to DO_TEST_CAPS_LATEST
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:00 +02:00
Peter Krempa
3209048f36 tests: qemuxml2argv: Test also the i6300esb watchdog
Convert one of the tests to a different device.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:00 +02:00
Peter Krempa
c7d26f4742 tests: qemuxml2argv: Convert watchdog tests on x86_64 to DO_TEST_CAPS_LATEST
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:00 +02:00
Peter Krempa
4b67fe3843 virCommandGetArgList: Remove 'nargs' argument
The returned argument list is a NULL-terminated string list and the only
caller doesn't use the count. Remove the argument.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:00 +02:00
Peter Krempa
debc33ef84 qemuxml2argvtest: Refactor QAPI schema validation code
Prevent duplication of code when extending the validator for new
commands. Add a struct describing a command to validate and make the
validation loop a bit more robust to corner cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:00 +02:00
Peter Krempa
424dc5d2d2 qemu: Remove 'qemuBuildCommandLineFlags' and associated code
The -netdev formatter code switched to a real virQEMUCaps flag so we can
remove the old flags which used to enable JSON for -netdev for
validation purposes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:00 +02:00
Peter Krempa
36253a48b4 testCompareXMLToArgvValidateSchema: Base -netdev validation on JSON
Base the validation on presence of JSON as we do with other validated
commands. This will prepare the code for a refactor so that it's the
same for all validated commands.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 10:26:00 +02:00
Peter Krempa
618e8665db qemu: capabilities: Remove QEMU_CAPS_PIIX4_ACPI_HOTPLUG_BRIDGE
Commit 58ba0f6a3d added a capability which
is supported by all qemu versions we support. Remove it and the
associated dead code. Since the capability isn't present in any upstream
release we can delete it completely.

Specifically the commit itself states that it was introduced "around
(qemu) 2.1". The rest of the code handles properly that the feature is
used only on x86 with the i440fx machine so the capability is pointless.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 09:41:22 +02:00
Peter Krempa
da896d440c qemuxml2xmltest: Convert all acpi-hotplug control related tests to DO_TEST_CAPS_LATEST
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 09:41:22 +02:00
Peter Krempa
6414603105 qemuxml2argvtest: Add '-enable' variants for ACPI-hotplug related cases
We have input files for those, provide also xml2argv testing since we
have them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 09:41:22 +02:00
Peter Krempa
2d20f0bb05 qemuxml2argvtest: Use real-caps testing for 'acpi-hotplug-bridge-disable'
We can use real example configs to prove the support without the
need for using fake capabilities. Fix the recently added test cases.

The negative case for 'pc-i440fx-acpi-hotplug-bridge-disable' is removed
completely as there is no real qemu libvirt supports which wouldn't
have the capability.

The input file for the negative test on aarch64 is modified so that it's
actually a reasonably valid VM config.

Fixes: bef0f0d8be
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 09:41:22 +02:00
Peter Krempa
2017b9f0c0 qemuxml2argvtest: Use real-caps testing for 'pc-i440fx-acpi-root-hotplug-disable'
We can use two real example configs to prove the support without the
need for using fake capabilities. Fix the recently added test cases.

Fixes: 133d7983d6
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-12 09:41:22 +02:00
Ani Sinha
bef0f0d8be qemu: command: add support for acpi-bridge-hotplug feature
This change adds backend qemu command line support for new libvirt
global feature 'acpi-bridge-hotplug'. This option can be used as
following:

<feature>
  <pci>
    <acpi-bridge-hotplug state='off|on'/>
  </pci>
</feature>

The '<pci>' sub-element under '<feature>' is also newly introduced.

'acpi-bridge-hotplug' turns on the following command line option to
qemu for x86 guests:

(pc): -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=<off|on>

(q35): -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=<off|on>

This change also adds the required qemuxml2argv unit tests in order to
test correct qemu arguments. Unit tests have also been added to test
qemu capability validation checks as well as checks for using this
option with the right architecture.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-10-10 13:21:04 -04:00
Ani Sinha
7300ccc9b3 conf: introduce support for acpi-bridge-hotplug feature
This change introduces a new libvirt sub-element <pci> under
<features> that can be used to configure all pci related features.
Currently the only sub-sub element supported by this sub-element is
'acpi-bridge-hotplug' as shown below:

<features>
  <pci>
    <acpi-bridge-hotplug state='on|off'/>
  </pci>
</features>

The above option is only available for the QEMU driver, for x86 guests
only. It is a global option, affecting all PCI bridge controllers on
the guest.

The 'acpi-bridge-hotplug' option enables or disables ACPI hotplug
support for cold-plugged pci bridges. Examples of bridges include the
PCI-PCI bridge (pci-bridge controller) for pc (i440fx) machinetypes,
or PCIe-PCI bridges and pcie-root-port controllers for q35
machinetypes.

For pc machinetypes in x86, this option has been available in QEMU
since version 2.1. Please see the following changes in qemu repo:

9e047b982452c6 ("piix4: add acpi pci hotplug support")
133a2da488062e ("pc: acpi: generate AML only for PCI0 devices if PCI
               bridge hotplug is disabled")

For q35 machinetypes, this was introduced in QEMU 6.1 with the
following changes in qemu repo:

(a) c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")
(b) 17858a16950860 ("hw/acpi/ich9: Set ACPI PCI hot-plug as default on
                   Q35")

The reasons for enabling ACPI based hotplug for PCIe (q35) based
machines (as opposed to native hotplug) are outlined in (b). There are
use cases where users would still want to use native
hotplug. Therefore, this config option enables users to choose either
ACPI based hotplug or native hotplug for bridges (for example for pcie
root port controller in q35 machines).

Qemu capability validation checks have also been added along with
related unit tests to exercise the new conf option.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-10-10 13:13:45 -04:00
Ani Sinha
58ba0f6a3d qemu: capablities: detect acpi-pci-hotplug-with-bridge-support
qemu added support for i440fx specific global boolean flag

PIIX4_PM.acpi-pci-hotplug-with-bridge-support

around version 2.1. This flag is enabled by default. When disabled, it
turns off acpi pci hotplug for cold plugged pci bridges in i440fx
machine types.

Very recently, in qemu version 6.1, the same global option was also
added for q35 machine types as well.

ICH9-LPC.acpi-pci-hotplug-with-bridge-support

This option turns on or off acpi based hotplug for cold plugged pcie
bridges like pcie root ports. This flag is also enabled by
default. Please refer to the following qemu changes:

c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")
17858a16950860 ("hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35")

This patch adds the corresponding qemu capabilities in libvirt. For
i440fx, the capability is detected as
QEMU_CAPS_PIIX_ACPI_HOTPLUG_BRIDGE. For q35, the capability is
detected as QEMU_CAPS_ICH9_ACPI_HOTPLUG_BRIDGE.

Please note that the test specific qemu capabilities .replies files
has already been updated as a part of regular refreshing them when a
new qemu version is released. Hence, no updates to those files are
required.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-10-10 13:12:50 -04:00
Ján Tomko
e7801a490c qemu: do not put virtiofs socket in private data
Reconstruct the socket path from priv->libDir in every user.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-06 12:03:12 +02:00
Ján Tomko
ebdcb2a900 tests: qemuxml2argvtest: fix path to virtiofs socket
The mocked path in the test suite is not in sync with what libvirtd
generates.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-06 12:03:12 +02:00
Ján Tomko
da4efc5433 qemu: vhost-user-fs: format alias on the command line
The commit adding the vhost-user-fs device forgot to format
the device's alias on the command line.

Thankfully it was not needed yet because virtiofs migration
is not yet supported, but it will be needed in the future
to allow hot(un)plug.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-06 12:03:11 +02:00
Ani Sinha
400979fd06 qemu: capabilities: remove -en from piix4-acpi-root-hotplug-en
The capability name piix4-acpi-root-hotplug-en is not conventional and
appreared to be confusing to some. "en" suffix is also incorrect as the
capability in qemu is used to both enable and disable hotplug on the pci root
bus on the i440fx. Hence, rename it to piix4.acpi-root-pci-hotplug so that it
is clearer, less confusing and more accurate.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-10-05 00:07:23 -04:00
Ani Sinha
133d7983d6 qemu: command: add support to enable/disable hotplug on pci-root controller
This change adds qemu backend command line support for enabling or disabling
hotplug on the pci-root controller using the 'target' sub-element of the
pci-root controller as shown below:

<controller type='pci' model='pci-root'>
  <target hotplug='off'/>
</controller>

'<target hotplug='off/on'/>' is only valid for pc (i440fx-based x86)
machinetypes and turns on the following command line option that is passed
to qemu for x86 guests:

-global PIIX4_PM.acpi-root-pci-hotplug=<off/on>

Before introduction of this attribute, hotplug was always enabled for
pci-root of an i440fx-based machinetype, and since its introduction
the default setting has always been "on" for those machinetypes.

This change also adds the required qemuxml2argv unit tests in order to test
correct qemu arguments. Unit tests have also been added to test qemu capability
validation checks.

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-10-01 14:42:18 -04:00