[PATCH 000/103] qemu: Type-aware generation of properties for -device (part 1)

This series converts our generation of -device to JSON. This allows to use proper types when talking on QMP which will become mandatory in qemu soon (for now we coverted _everything_ to strings) and also use JSON on the commandline which will be the only "stable" interface. Part 1 consists of cleanups and conversion of all devices which can be hotplugged and most others. There are few other missing along with preparation for schema validation which will come in part 2. The patches can be fetched at: git fetch https://gitlab.com/pipo.sk/libvirt.git jsonify-refactors-2 Peter Krempa (103): virJSONValueObjectAddVArgs: Add 'k' convertor for formatting non-negative integers virJSONValueObjectAddVArgs: Add check for presence of the ':' separator virJSONValueObjectAddVArgs: Add new convertors for allocated strings qemuBuildMemoryCellBackendStr: Return JSON props instead of a buffer qemuBuildInputDevStr: Don't mix generators for -object and -device qemuBuildObjectCommandlineFromJSON: Format directly into the virCommand qemu: capabilities: Rename QEMU_CAPS_OBJECT_QAPIFIED to QEMU_CAPS_OBJECT_JSON qemu: capabilities: Introduce QEMU_CAPS_NETDEV_JSON qemuBuildObjectCommandlineFromJSON: Remove checks for 'type' and 'alias' testCompareXMLToArgvValidateSchema: Base -netdev validation on JSON qemu: command: Format netdev as JSON when QEMU_CAPS_NETDEV_JSON is present virQEMUBuildNetdevCommandlineFromJSON: Remove unused formatter qemu: Remove 'qemuBuildCommandLineFlags' and associated code virQEMUBuildDriveCommandlineFromJSON: Open-code in callers qemuxml2argvtest: Refactor QAPI schema validation code virCommandGetArgList: Remove 'nargs' argument qemu: capabilities: Introduce QEMU_CAPS_CHARDEV_JSON qemu: capabilities: Introduce QEMU_CAPS_DEVICE_JSON tests: qemuxml2argv: Convert watchdog tests on x86_64 to DO_TEST_CAPS_LATEST tests: qemuxml2argv: Test also the i6300esb watchdog qemuxml2argvtest: Convert 'panic' test cases to DO_TEST_CAPS_LATEST qemuxml2xmltest: Remove 'panic-isa' case qemu: Move watchdog model validation into the validation code qemuDomainHotplugAddVcpu: Refactor cleanup qemu: Rename 'qemuMonitorAddDeviceArgs' to 'qemuMonitorAddDeviceProps' qemuMonitorJSONAddDeviceProps: Refactor cleanup virQEMUBuildCommandLineJSONIterate: Simplify logic virQEMUBuildCommandLineJSONRecurse: Error out when array conversion function is not provided qemuBlockStorageSourceAttachRollback: Sanitize warning messages qemuBuildDeviceAddressSt: Split out formatting of PCI address qemuBuildDeviceAddressPCIStr: Make error messages easier to find qemuBuildDeviceAddressPCIStr: Extract PCI bus name lookup qemu: command: Introduce JSON equivalent of qemuBuildDeviceAddressStr qemuBuildVirtioDevStr: Don't return early qemuBuildVirtioDevStr: Extract code for determining device model qemuBuildVirtioDevGetConfig: Split out per device type code qemuDeviceVideoGetModel: Clarify 'virtio' argument qemuDeviceVideoGetModel: Move to the beginning qemuBuildVirtioDevGetConfig: Split up formatting of bus suffix qemuBuildVirtioDevGetConfigDev: Provide more information qemuBuildVirtioDevStr: Remove 'baseName' argument qemuBuildVirtioDevStr: Format also virtioOptions qemuBuildVirtioOptionsStr: Remove empty function qemuBuildDeviceVideoStr: Properly format virtio options for 'virtio-vga' conf: Introduce 'effectiveBootIndex' into 'virDomainDeviceInfo' qemu: process: Make qemuProcessPrepareDomainDiskBootorder more universal qemu: Use 'effectiveBootIndex' to handle <os><boot dev='network'> qemu: Clean up after old-style passing of 'bootIndex' to network devices virDomainDeviceGetInfo: Make argument const qemuValidateDomainDeviceDef: Optimize virDomainDeviceInfo validation qemuValidateDomainDeviceDef: Avoid unneded variable and 'break' statements qemu: validate: Move validation of device rom qemu: command: Introduce JSON variant of qemuBuildVirtioDevStr qemu: command: Introduce helper for building JSON props of -device into commandline qemu: command: Introduce JSON variant of qemuBuildRomProps qemuBuildPanicCommandLine: Generate via JSON qemuBuildWatchdogCommandLine: Generate via JSON qemuBuildMemoryDeviceCommandLine: Generate via JSON qemuBuildShmemCommandLine: Generate via JSON qemuBuildMemballoonCommandLine: Generate via JSON qemuBuildMemballoonCommandLine: Reorder properties qemuBuildRNGCommandLine: Generate via JSON qemuBuildHostdevCommandLine: Build mediated device commandline via JSON qemuBuildHostdevMediatedDevProps: Move 'ramfb' and 'bootindex' before the address qemuBuildHostdevMediatedDevProps: Format USB host devices via JSON qemuBuildRedirdevCommandLine: Generate via JSON qemuBuildInputCommandLine: Generate via JSON qemuCommandAddExtDevice: Generate via JSON qemuBuildHostdevCommandLine: Format PCI host devices via JSON qemuBuildPCIHostdevDevProps: Move 'failover_pair_id' property before address qemuBuildDeviceAddressProps: Format also 'drive' addresses qemu: validate: Move disk address validation code qemuBuildHostdevSCSICommandLine: Generate via JSON qemuBuildSCSIHostdevDevProps: Reorder 'drive','id' and 'bootindex' after address qemuBuildIoEventFdStr: Always assume support for QEMU_CAPS_VIRTIO_IOEVENTFD qemu: capabilities: Retire QEMU_CAPS_VIRTIO_IOEVENTFD qemu: Always assume presence of QEMU_CAPS_VIRTIO_(BLK|NET)_EVENT_IDX qemu: capabilities: Retire QEMU_CAPS_VIRTIO_(BLK|NET)_EVENT_IDX qemuBuildDiskFrontendAttributeErrorPolicy: Extract logic qemuBuildDiskCommandLine: Generate via JSON qemuBuildInterfaceCommandLine: Generate via JSON qemuBuildNicDevProps: Move formatting of bootindex qemu: command: Remove unused qemuBuildRomStr qemuBuildControllerDevStr: Split out formatting of SCSI controller qemuBuildControllerDevStr: Split out formatting of PCI controller qemuBuildControllerSCSIDevStr: Format via JSON properties qemuBuildControllerPCIDevStr: Format via JSON properties qemuBuildUSBControllerDevStr: Split out validation of USB controller qemuBuildUSBControllerDevStr: Format via JSON properties. qemuBuildControllersByTypeCommandLine: Generate via JSON qemuBuildChrDeviceCommandLine: Generate via JSON qemuBuildHostdevCommandLine: Generate via JSON qemuBuildVsockCommandLine: Generate via JSON qemu: monitor: Remove legacy 'device_add' infrastrcture qemuBuildVHostUserFsCommandLine: Generate via JSON qemuBuildFSDevCommandLine: Generate via JSON qemuBuildVideoCommandLine: Generate via JSON qemu: Command remove unused 'qemuBuildVirtioDevStr' qemuBuildSoundCommandLine: Generate via JSON qemuBuildSoundCommandLine: Generate codecs via JSON qemuBuildHubCommandLine: Generate via JSON qemuBuildTPMCommandLine: Generate via JSON qemu: command: Remove unused 'qemuBuildDeviceAddressStr' src/conf/device_conf.h | 7 + src/conf/domain_conf.c | 8 +- src/conf/domain_conf.h | 2 +- src/libvirt_private.syms | 3 +- src/qemu/qemu_block.c | 6 +- src/qemu/qemu_capabilities.c | 20 +- src/qemu/qemu_capabilities.h | 13 +- src/qemu/qemu_command.c | 3981 +++++++++-------- src/qemu/qemu_command.h | 151 +- src/qemu/qemu_domain.h | 4 - src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_hotplug.c | 235 +- src/qemu/qemu_monitor.c | 49 +- src/qemu/qemu_monitor.h | 11 +- src/qemu/qemu_monitor_json.c | 175 +- src/qemu/qemu_monitor_json.h | 6 +- src/qemu/qemu_process.c | 61 +- src/qemu/qemu_process.h | 3 +- src/qemu/qemu_validate.c | 367 +- src/util/vircommand.c | 4 +- src/util/vircommand.h | 2 +- src/util/virjson.c | 93 +- src/util/virqemu.c | 71 +- src/util/virqemu.h | 10 +- .../caps_2.11.0.s390x.xml | 3 - .../caps_2.11.0.x86_64.xml | 3 - .../caps_2.12.0.aarch64.xml | 3 - .../caps_2.12.0.ppc64.xml | 3 - .../caps_2.12.0.s390x.xml | 3 - .../caps_2.12.0.x86_64.xml | 3 - .../qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 3 - .../qemucapabilitiesdata/caps_3.0.0.s390x.xml | 3 - .../caps_3.0.0.x86_64.xml | 3 - .../qemucapabilitiesdata/caps_3.1.0.ppc64.xml | 3 - .../caps_3.1.0.x86_64.xml | 3 - .../caps_4.0.0.aarch64.xml | 3 - .../qemucapabilitiesdata/caps_4.0.0.ppc64.xml | 3 - .../caps_4.0.0.riscv32.xml | 3 - .../caps_4.0.0.riscv64.xml | 3 - .../qemucapabilitiesdata/caps_4.0.0.s390x.xml | 3 - .../caps_4.0.0.x86_64.xml | 3 - .../caps_4.1.0.x86_64.xml | 3 - .../caps_4.2.0.aarch64.xml | 3 - .../qemucapabilitiesdata/caps_4.2.0.ppc64.xml | 3 - .../qemucapabilitiesdata/caps_4.2.0.s390x.xml | 3 - .../caps_4.2.0.x86_64.xml | 3 - .../caps_5.0.0.aarch64.xml | 3 - .../qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 3 - .../caps_5.0.0.riscv64.xml | 3 - .../caps_5.0.0.x86_64.xml | 3 - .../caps_5.1.0.x86_64.xml | 3 - .../caps_5.2.0.aarch64.xml | 3 - .../qemucapabilitiesdata/caps_5.2.0.ppc64.xml | 3 - .../caps_5.2.0.riscv64.xml | 3 - .../qemucapabilitiesdata/caps_5.2.0.s390x.xml | 3 - .../caps_5.2.0.x86_64.xml | 3 - .../caps_6.0.0.aarch64.xml | 3 - .../qemucapabilitiesdata/caps_6.0.0.s390x.xml | 3 - .../caps_6.0.0.x86_64.xml | 3 - .../caps_6.1.0.x86_64.xml | 3 - tests/qemumonitorjsontest.c | 2 - ...fault-cpu-kvm-virt-4.2.aarch64-latest.args | 4 +- ...fault-cpu-tcg-virt-4.2.aarch64-latest.args | 4 +- .../qemuxml2argvdata/aarch64-pci-serial.args | 2 +- .../aarch64-traditional-pci.args | 4 +- .../aarch64-video-default.args | 2 +- .../aarch64-video-virtio-gpu-pci.args | 6 +- .../aarch64-virt-2.6-virtio-pci-default.args | 2 +- .../aarch64-virt-graphics.aarch64-latest.args | 16 +- .../aarch64-virt-headless.aarch64-latest.args | 14 +- .../aarch64-virtio-pci-default.args | 12 +- tests/qemuxml2argvdata/autoindex.args | 22 +- .../qemuxml2argvdata/balloon-ccw-deflate.args | 2 +- .../balloon-device-deflate-off.args | 2 +- .../balloon-device-deflate.args | 2 +- tests/qemuxml2argvdata/bios-nvram-secure.args | 2 +- tests/qemuxml2argvdata/boot-complex.args | 2 +- tests/qemuxml2argvdata/boot-order.args | 2 +- tests/qemuxml2argvdata/controller-order.args | 2 +- tests/qemuxml2argvdata/cpu-host-model.args | 2 +- .../cpu-host-model.x86_64-2.11.0.args | 6 +- .../cpu-host-model.x86_64-2.12.0.args | 6 +- .../cpu-host-model.x86_64-3.0.0.args | 6 +- .../cpu-host-model.x86_64-3.1.0.args | 6 +- .../cpu-host-model.x86_64-4.0.0.args | 6 +- .../cpu-host-model.x86_64-4.1.0.args | 6 +- .../cpu-host-model.x86_64-4.2.0.args | 6 +- .../cpu-host-model.x86_64-5.0.0.args | 6 +- .../cpu-host-model.x86_64-5.1.0.args | 6 +- .../cpu-host-model.x86_64-5.2.0.args | 6 +- .../cpu-host-model.x86_64-6.0.0.args | 6 +- .../cpu-host-model.x86_64-6.1.0.args | 6 +- .../cpu-host-model.x86_64-latest.args | 6 +- ...ult-video-type-aarch64.aarch64-latest.args | 4 +- ...ult-video-type-riscv64.riscv64-latest.args | 4 +- .../disk-floppy-q35-2_11.x86_64-2.12.0.args | 4 +- .../disk-floppy-q35-2_11.x86_64-latest.args | 4 +- .../disk-floppy-q35-2_9.x86_64-2.12.0.args | 4 +- .../disk-floppy-q35-2_9.x86_64-latest.args | 4 +- .../disk-ide-wwn.x86_64-latest.args | 2 +- .../disk-scsi-disk-wwn.x86_64-latest.args | 4 +- .../disk-scsi.x86_64-latest.args | 4 +- ...tdev-mdev-display-ramfb.x86_64-latest.args | 2 +- .../hostdev-scsi-lsi.x86_64-4.1.0.args | 12 +- .../hostdev-scsi-lsi.x86_64-latest.args | 12 +- .../hostdev-scsi-vhost-scsi-pcie.args | 4 +- ...hostdev-scsi-virtio-scsi.x86_64-4.1.0.args | 14 +- ...ostdev-scsi-virtio-scsi.x86_64-latest.args | 14 +- ...ubsys-mdev-vfio-ccw-boot.s390x-latest.args | 2 +- .../mach-virt-serial-pci.args | 2 +- .../mach-virt-serial-usb.args | 4 +- ...ine-loadparm-multiple-disks-nets-s390.args | 2 +- .../machine-loadparm-net-s390.args | 2 +- tests/qemuxml2argvdata/machine-smm-opt.args | 2 +- tests/qemuxml2argvdata/name-escape.args | 2 +- .../net-virtio-teaming-hostdev.args | 4 +- .../qemuxml2argvdata/net-virtio-teaming.args | 4 +- .../os-firmware-bios.x86_64-latest.args | 2 +- ...re-efi-no-enrolled-keys.x86_64-latest.args | 4 +- ...os-firmware-efi-secboot.x86_64-latest.args | 2 +- .../os-firmware-efi.x86_64-latest.args | 2 +- ...e.args => panic-double.x86_64-latest.args} | 16 +- tests/qemuxml2argvdata/panic-isa.xml | 33 - tests/qemuxml2argvdata/panic-no-address.args | 33 - .../panic-no-address.x86_64-latest.args | 37 + tests/qemuxml2argvdata/panic.args | 33 - .../qemuxml2argvdata/panic.x86_64-latest.args | 37 + tests/qemuxml2argvdata/pcie-expander-bus.args | 66 +- .../pcie-root-port-model-generic.args | 6 +- .../pcie-root-port-model-ioh3420.args | 4 +- ...cie-root-port-nohotplug.x86_64-latest.args | 14 +- tests/qemuxml2argvdata/pcie-root-port.args | 4 +- .../pcie-switch-downstream-port.args | 16 +- .../pcie-switch-upstream-port.args | 4 +- ...ault-cpu-kvm-pseries-2.7.ppc64-latest.args | 2 +- ...ault-cpu-kvm-pseries-3.1.ppc64-latest.args | 2 +- ...ault-cpu-kvm-pseries-4.2.ppc64-latest.args | 2 +- ...ault-cpu-tcg-pseries-2.7.ppc64-latest.args | 2 +- ...ault-cpu-tcg-pseries-3.1.ppc64-latest.args | 2 +- ...ault-cpu-tcg-pseries-4.2.ppc64-latest.args | 2 +- .../ppc64-pseries-graphics.ppc64-latest.args | 2 +- .../ppc64-pseries-headless.ppc64-latest.args | 2 +- .../ppc64-tpmproxy-with-tpm.ppc64-latest.args | 2 +- tests/qemuxml2argvdata/pseries-basic.args | 2 +- .../pseries-cpu-compat-power9.args | 2 +- .../qemuxml2argvdata/pseries-cpu-compat.args | 2 +- tests/qemuxml2argvdata/pseries-cpu-exact.args | 2 +- tests/qemuxml2argvdata/pseries-cpu-le.args | 2 +- .../pseries-panic-missing.args | 2 +- .../pseries-panic-no-address.args | 2 +- .../pseries-serial-native.args | 2 +- .../qemuxml2argvdata/pseries-usb-default.args | 2 +- tests/qemuxml2argvdata/pseries-usb-kbd.args | 2 +- tests/qemuxml2argvdata/pseries-usb-multi.args | 2 +- .../pseries-vio-user-assigned.args | 8 +- tests/qemuxml2argvdata/pseries-vio.args | 8 +- .../q35-default-devices-only.args | 6 +- tests/qemuxml2argvdata/q35-multifunction.args | 36 +- .../q35-pci-force-address.args | 2 +- tests/qemuxml2argvdata/q35-pcie-autoadd.args | 28 +- tests/qemuxml2argvdata/q35-pcie.args | 26 +- .../q35-pm-disable-fallback.args | 2 +- tests/qemuxml2argvdata/q35-pm-disable.args | 2 +- .../q35-virt-manager-basic.args | 12 +- tests/qemuxml2argvdata/q35-virtio-pci.args | 26 +- .../riscv64-virt-graphics.riscv64-latest.args | 16 +- .../riscv64-virt-headless.riscv64-latest.args | 14 +- .../qemuxml2argvdata/s390-panic-missing.args | 2 +- .../serial-dev-chardev-iobase.args | 2 +- .../tpm-emulator-spapr.ppc64-latest.args | 10 +- .../tseg-explicit-size.x86_64-latest.args | 6 +- ...sb-controller-explicit-unavailable-q35.err | 2 +- .../usb-controller-qemu-xhci-unavailable.err | 2 +- ...vhost-user-fs-hugepages.x86_64-latest.args | 8 +- .../vhost-vsock-ccw-iommu.s390x-latest.args | 2 +- ...eo-bochs-display-device.x86_64-latest.args | 2 +- .../virtio-non-transitional.x86_64-3.1.0.args | 22 +- ...virtio-non-transitional.x86_64-latest.args | 22 +- ...-options-controller-ats.x86_64-latest.args | 4 +- ...ptions-controller-iommu.x86_64-latest.args | 4 +- ...tions-controller-packed.x86_64-latest.args | 4 +- .../virtio-options-fs-ats.x86_64-latest.args | 4 +- ...virtio-options-fs-iommu.x86_64-latest.args | 4 +- ...irtio-options-fs-packed.x86_64-latest.args | 4 +- ...irtio-options-input-ats.x86_64-latest.args | 4 +- ...tio-options-input-iommu.x86_64-latest.args | 4 +- ...io-options-input-packed.x86_64-latest.args | 4 +- ...-options-memballoon-ats.x86_64-latest.args | 2 +- ...loon-freepage-reporting.x86_64-latest.args | 2 +- ...ptions-memballoon-iommu.x86_64-latest.args | 2 +- ...tions-memballoon-packed.x86_64-latest.args | 2 +- .../virtio-options-net-ats.x86_64-latest.args | 4 +- ...irtio-options-net-iommu.x86_64-latest.args | 4 +- ...rtio-options-net-packed.x86_64-latest.args | 4 +- .../virtio-options-rng-ats.x86_64-latest.args | 4 +- ...irtio-options-rng-iommu.x86_64-latest.args | 4 +- ...rtio-options-rng-packed.x86_64-latest.args | 4 +- ...irtio-options-video-ats.x86_64-latest.args | 4 +- ...tio-options-video-iommu.x86_64-latest.args | 4 +- ...io-options-video-packed.x86_64-latest.args | 4 +- .../virtio-options.x86_64-latest.args | 22 +- .../virtio-transitional.x86_64-3.1.0.args | 4 +- .../virtio-transitional.x86_64-latest.args | 4 +- tests/qemuxml2argvdata/watchdog-device.args | 34 - .../watchdog-device.x86_64-latest.args | 38 + tests/qemuxml2argvdata/watchdog-device.xml | 2 +- tests/qemuxml2argvdata/watchdog-dump.args | 34 - .../watchdog-dump.x86_64-latest.args | 38 + .../qemuxml2argvdata/watchdog-injectnmi.args | 34 - .../watchdog-injectnmi.x86_64-latest.args | 38 + tests/qemuxml2argvdata/watchdog.args | 33 - .../watchdog.x86_64-latest.args | 37 + ...default-cpu-kvm-q35-4.2.x86_64-latest.args | 8 +- ...default-cpu-tcg-q35-4.2.x86_64-latest.args | 8 +- .../x86_64-q35-graphics.x86_64-latest.args | 14 +- .../x86_64-q35-headless.x86_64-latest.args | 14 +- tests/qemuxml2argvtest.c | 155 +- tests/qemuxml2xmltest.c | 1 - 218 files changed, 3425 insertions(+), 3484 deletions(-) rename tests/qemuxml2argvdata/{panic-double.args => panic-double.x86_64-latest.args} (52%) delete mode 100644 tests/qemuxml2argvdata/panic-isa.xml delete mode 100644 tests/qemuxml2argvdata/panic-no-address.args create mode 100644 tests/qemuxml2argvdata/panic-no-address.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/panic.args create mode 100644 tests/qemuxml2argvdata/panic.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/watchdog-device.args create mode 100644 tests/qemuxml2argvdata/watchdog-device.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/watchdog-dump.args create mode 100644 tests/qemuxml2argvdata/watchdog-dump.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/watchdog-injectnmi.args create mode 100644 tests/qemuxml2argvdata/watchdog-injectnmi.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/watchdog.args create mode 100644 tests/qemuxml2argvdata/watchdog.x86_64-latest.args -- 2.31.1

In many cases we use a signed value, but use the sign to note that it was not assigned. For converting to JSON objects it will be handy to have possibility to do this automatically. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virjson.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index 9adcea4fff..70ea71b505 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -115,6 +115,7 @@ virJSONValueGetType(const virJSONValue *value) * * i: signed integer value * j: signed integer value, error if negative + * k: signed integer value, omitted if negative * z: signed integer value, omitted if zero * y: signed integer value, omitted if zero, error if negative * @@ -189,6 +190,7 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, case 'z': case 'y': + case 'k': case 'j': case 'i': { int val = va_arg(args, int); @@ -200,7 +202,10 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, return -1; } - if (!val && (type == 'z' || type == 'y')) + if (val == 0 && (type == 'z' || type == 'y')) + continue; + + if (val < 0 && type == 'k') continue; rc = virJSONValueObjectAppendNumberInt(obj, key, val); -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
In many cases we use a signed value, but use the sign to note that it was not assigned. For converting to JSON objects it will be handy to have possibility to do this automatically.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virjson.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/util/virjson.c b/src/util/virjson.c index 9adcea4fff..70ea71b505 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -115,6 +115,7 @@ virJSONValueGetType(const virJSONValue *value) * * i: signed integer value * j: signed integer value, error if negative + * k: signed integer value, omitted if negative * z: signed integer value, omitted if zero * y: signed integer value, omitted if zero, error if negative * @@ -189,6 +190,7 @@ virJSONValueObjectAddVArgs(virJSONValue *obj,
case 'z': case 'y': + case 'k': case 'j': case 'i': { int val = va_arg(args, int); @@ -200,7 +202,10 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, return -1; }
- if (!val && (type == 'z' || type == 'y')) + if (val == 0 && (type == 'z' || type == 'y')) + continue; +
Please split out this cosmetic style change.
+ if (val < 0 && type == 'k') continue;
k. I mean Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

On Thu, Oct 7, 2021 at 6:43 PM Ján Tomko <jtomko@redhat.com> wrote:
On a Thursday in 2021, Peter Krempa wrote:
In many cases we use a signed value, but use the sign to note that it was not assigned. For converting to JSON objects it will be handy to have possibility to do this automatically.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virjson.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/util/virjson.c b/src/util/virjson.c index 9adcea4fff..70ea71b505 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -115,6 +115,7 @@ virJSONValueGetType(const virJSONValue *value) * * i: signed integer value * j: signed integer value, error if negative + * k: signed integer value, omitted if negative * z: signed integer value, omitted if zero * y: signed integer value, omitted if zero, error if negative * @@ -189,6 +190,7 @@ virJSONValueObjectAddVArgs(virJSONValue *obj,
case 'z': case 'y': + case 'k': case 'j': case 'i': { int val = va_arg(args, int); @@ -200,7 +202,10 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, return -1; }
- if (!val && (type == 'z' || type == 'y')) + if (val == 0 && (type == 'z' || type == 'y')) + continue; +
Please split out this cosmetic style change.
Please don't.
+ if (val < 0 && type == 'k')
continue;
k.
I mean Reviewed-by: Ján Tomko <jtomko@redhat.com>
Jano
Kristina

On a Friday in 2021, Kristina Hanicova wrote:
On Thu, Oct 7, 2021 at 6:43 PM Ján Tomko <jtomko@redhat.com> wrote:
On a Thursday in 2021, Peter Krempa wrote:
In many cases we use a signed value, but use the sign to note that it was not assigned. For converting to JSON objects it will be handy to have possibility to do this automatically.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virjson.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/util/virjson.c b/src/util/virjson.c index 9adcea4fff..70ea71b505 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -115,6 +115,7 @@ virJSONValueGetType(const virJSONValue *value) * * i: signed integer value * j: signed integer value, error if negative + * k: signed integer value, omitted if negative * z: signed integer value, omitted if zero * y: signed integer value, omitted if zero, error if negative * @@ -189,6 +190,7 @@ virJSONValueObjectAddVArgs(virJSONValue *obj,
case 'z': case 'y': + case 'k': case 'j': case 'i': { int val = va_arg(args, int); @@ -200,7 +202,10 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, return -1; }
- if (!val && (type == 'z' || type == 'y')) + if (val == 0 && (type == 'z' || type == 'y')) + continue; +
Please split out this cosmetic style change.
Please don't.
Why not? It is unrelated to the goal of introducing the 'k' parser and having it here distracts from that goal. Writing a new commit might cost a few seconds of the author's time, but it will save time for the readers of such commit. And you can expect a commit to be read more times (even by the author a few years into the future, after they long forgot about writing it), while it is only written once. There might be some projects (I think linux kernel does this) that do not accept commits with purely whitespace/style changes, but we do allow them in libvirt and I'm much happier to review them, since they make the actual functional changes more obvious. (And they make the review of a 100-patch series possible). I like this blog post danpb wrote on the topic: https://www.berrange.com/posts/2012/06/27/thoughts-on-improving-openstack-gi... Jano

On Fri, Oct 08, 2021 at 13:20:54 +0200, Ján Tomko wrote:
On a Friday in 2021, Kristina Hanicova wrote:
On Thu, Oct 7, 2021 at 6:43 PM Ján Tomko <jtomko@redhat.com> wrote:
On a Thursday in 2021, Peter Krempa wrote:
In many cases we use a signed value, but use the sign to note that it was not assigned. For converting to JSON objects it will be handy to have possibility to do this automatically.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virjson.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/util/virjson.c b/src/util/virjson.c index 9adcea4fff..70ea71b505 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -115,6 +115,7 @@ virJSONValueGetType(const virJSONValue *value) * * i: signed integer value * j: signed integer value, error if negative + * k: signed integer value, omitted if negative * z: signed integer value, omitted if zero * y: signed integer value, omitted if zero, error if negative * @@ -189,6 +190,7 @@ virJSONValueObjectAddVArgs(virJSONValue *obj,
case 'z': case 'y': + case 'k': case 'j': case 'i': { int val = va_arg(args, int); @@ -200,7 +202,10 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, return -1; }
- if (!val && (type == 'z' || type == 'y')) + if (val == 0 && (type == 'z' || type == 'y')) + continue; +
Please split out this cosmetic style change.
Please don't.
Why not?
It is unrelated to the goal of introducing the 'k' parser and having it here distracts from that goal.
Writing a new commit might cost a few seconds of the author's time, but it will save time for the readers of such commit. And you can expect a commit to be read more times (even by the author a few years into the future, after they long forgot about writing it), while it is only written once.
There might be some projects (I think linux kernel does this) that do not accept commits with purely whitespace/style changes, but we do allow them in libvirt and I'm much happier to review them, since they make the actual functional changes more obvious. (And they make the review of a 100-patch series possible).
I like this blog post danpb wrote on the topic: https://www.berrange.com/posts/2012/06/27/thoughts-on-improving-openstack-gi...
I'd argue that it might be relevant to have it in the same commit as it makes it more obvious that 'val' is a number and not a flag, especially once I'm adding aonther check, but at the same time we already have this inconsistency few lines above, so I'll remove the cosmetic change for now.

Enforce that the ':' separator between the key and value is always present. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virjson.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index 70ea71b505..d7e72af8f9 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -161,9 +161,9 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, while ((key = va_arg(args, char *)) != NULL) { - if (strlen(key) < 3) { + if (strlen(key) < 3 || key[1] != ':') { virReportError(VIR_ERR_INTERNAL_ERROR, - _("argument key '%s' is too short, missing type prefix"), + _("argument key '%s' is too short or malformed"), key); return -1; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Enforce that the ':' separator between the key and value is always present.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virjson.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The 'f' and 'F' convertors add a string value to the JSON value object and free the passed pointer. This is helpful in case we need to e.g. add single use formatted values: virJSONValueObjectAdd(props, "f:test1", g_strdup_printf("%s-test1", blah), "F:test2", virGetStringAndReportErrorOnNull(), NULL); With 'F' if the passed string is NULL no additional error is reported so the error is passed through. To prevent leaking the strings on reasonable failures we add an 'err' variable which skips the implementation of the conversions, but keeps iterating through the arguments. On hard programming errors (bad key format) the string is leaked but that should not be a problem in practice. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virjson.c | 82 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 14 deletions(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index d7e72af8f9..4d9cd5629a 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -112,6 +112,8 @@ virJSONValueGetType(const virJSONValue *value) * Explanation of type codes: * s: string value, must be non-null * S: string value, omitted if null + * f: string value, passed pointer is freed, error reported if NULL + * F: string value, passed pointer is freed, no error reported if NULL * * i: signed integer value * j: signed integer value, error if negative @@ -155,6 +157,7 @@ int virJSONValueObjectAddVArgs(virJSONValue *obj, va_list args) { + bool err = false; char type; char *key; int rc; @@ -173,17 +176,30 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, /* This doesn't support maps, but no command uses those. */ switch (type) { + case 'f': + case 'F': case 'S': case 's': { char *val = va_arg(args, char *); + g_autofree char *valf = NULL; + + if (type == 'f' || type == 'F') + valf = val; + + if (err) + continue; + if (!val) { if (type == 'S') continue; - virReportError(VIR_ERR_INTERNAL_ERROR, - _("argument key '%s' must not have null value"), - key); - return -1; + if (type != 'F') { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("argument key '%s' must not have null value"), + key); + } + err = true; + continue; } rc = virJSONValueObjectAppendString(obj, key, val); } break; @@ -195,11 +211,15 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, case 'i': { int val = va_arg(args, int); + if (err) + continue; + if (val < 0 && (type == 'j' || type == 'y')) { virReportError(VIR_ERR_INTERNAL_ERROR, _("argument key '%s' must not be negative"), key); - return -1; + err = true; + continue; } if (val == 0 && (type == 'z' || type == 'y')) @@ -215,6 +235,9 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, case 'u': { unsigned int val = va_arg(args, unsigned int); + if (err) + continue; + if (!val && type == 'p') continue; @@ -227,11 +250,15 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, case 'I': { long long val = va_arg(args, long long); + if (err) + continue; + if (val < 0 && (type == 'J' || type == 'Y')) { virReportError(VIR_ERR_INTERNAL_ERROR, _("argument key '%s' must not be negative"), key); - return -1; + err = true; + continue; } if (!val && (type == 'Z' || type == 'Y')) @@ -249,6 +276,9 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, */ long long val = va_arg(args, long long); + if (err) + continue; + if (!val && type == 'P') continue; @@ -257,6 +287,10 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, case 'd': { double val = va_arg(args, double); + + if (err) + continue; + rc = virJSONValueObjectAppendNumberDouble(obj, key, val); } break; @@ -265,6 +299,9 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, case 'b': { int val = va_arg(args, int); + if (err) + continue; + if (!val && type == 'B') continue; @@ -282,6 +319,9 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, } break; case 'n': { + if (err) + continue; + rc = virJSONValueObjectAppendNull(obj, key); } break; @@ -289,6 +329,9 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, case 'a': { virJSONValue **val = va_arg(args, virJSONValue **); + if (err) + continue; + if (!(*val)) { if (type == 'A') continue; @@ -296,7 +339,8 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, virReportError(VIR_ERR_INTERNAL_ERROR, _("argument key '%s' must not have null value"), key); - return -1; + err = true; + continue; } rc = virJSONValueObjectAppend(obj, key, val); @@ -308,6 +352,9 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, g_autoptr(virJSONValue) jsonMap = virJSONValueNewArray(); ssize_t pos = -1; + if (err) + continue; + if (!map) { if (type == 'M') continue; @@ -315,18 +362,20 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, virReportError(VIR_ERR_INTERNAL_ERROR, _("argument key '%s' must not have null value"), key); - return -1; + err = true; + continue; } while ((pos = virBitmapNextSetBit(map, pos)) > -1) { g_autoptr(virJSONValue) newelem = virJSONValueNewNumberLong(pos); - if (virJSONValueArrayAppend(jsonMap, &newelem) < 0) - return -1; + if (virJSONValueArrayAppend(jsonMap, &newelem) < 0) { + err = true; + continue; + } } - if ((rc = virJSONValueObjectAppend(obj, key, &jsonMap)) < 0) - return -1; + rc = virJSONValueObjectAppend(obj, key, &jsonMap); } break; default: @@ -335,10 +384,15 @@ virJSONValueObjectAddVArgs(virJSONValue *obj, return -1; } - if (rc < 0) - return -1; + if (rc < 0) { + err = true; + continue; + } } + if (err) + return -1; + /* verify that we added at least one key-value pair */ if (virJSONValueObjectKeysNumber(obj) == 0) return 0; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The 'f' and 'F' convertors add a string value to the JSON value object and free the passed pointer. This is helpful in case we need to e.g. add single use formatted values:
I'm not a fan of conditionally freeing the passed pointer based on some value. Especially now that we have g_auto, it should be easy enough to take care of in the caller.
virJSONValueObjectAdd(props, "f:test1", g_strdup_printf("%s-test1", blah), "F:test2", virGetStringAndReportErrorOnNull(), NULL);
With 'F' if the passed string is NULL no additional error is reported so the error is passed through.
To prevent leaking the strings on reasonable failures we add an 'err' variable which skips the implementation of the conversions, but keeps iterating through the arguments.
On hard programming errors (bad key format) the string is leaked but that should not be a problem in practice.
This sentence does not help sell it either :) Jano
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virjson.c | 82 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 14 deletions(-)

Rename the function to 'qemuBuildMemoryCellBackendProps' and return the properties before conversion to commandline arguments. This requires changes in the caller. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 28bca1519c..dcd6a6e75d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3188,15 +3188,13 @@ qemuBuildMemoryBackendProps(virJSONValue **backendProps, static int -qemuBuildMemoryCellBackendStr(virDomainDef *def, - virQEMUDriverConfig *cfg, - size_t cell, - qemuDomainObjPrivate *priv, - virBuffer *buf) +qemuBuildMemoryCellBackendProps(virDomainDef *def, + virQEMUDriverConfig *cfg, + size_t cell, + qemuDomainObjPrivate *priv, + virJSONValue **props) { - g_autoptr(virJSONValue) props = NULL; g_autofree char *alias = NULL; - int rc; virDomainMemoryDef mem = { 0 }; unsigned long long memsize = virDomainNumaGetNodeMemorySize(def->numa, cell); @@ -3207,14 +3205,7 @@ qemuBuildMemoryCellBackendStr(virDomainDef *def, mem.targetNode = cell; mem.info.alias = alias; - if ((rc = qemuBuildMemoryBackendProps(&props, alias, cfg, - priv, def, &mem, false, false)) < 0) - return -1; - - if (qemuBuildObjectCommandlineFromJSON(buf, props, priv->qemuCaps) < 0) - return -1; - - return rc; + return qemuBuildMemoryBackendProps(props, alias, cfg, priv, def, &mem, false, false); } @@ -7388,7 +7379,7 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg, size_t i, j; virQEMUCaps *qemuCaps = priv->qemuCaps; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - virBuffer *nodeBackends = NULL; + virJSONValue **nodeBackends = NULL; bool needBackend = false; bool hmat = false; int ret = -1; @@ -7408,7 +7399,7 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg, hmat = true; } - nodeBackends = g_new0(virBuffer, ncells); + nodeBackends = g_new0(virJSONValue *, ncells); /* using of -numa memdev= cannot be combined with -numa mem=, thus we * need to check which approach to use */ @@ -7418,8 +7409,8 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg, int rc; for (i = 0; i < ncells; i++) { - if ((rc = qemuBuildMemoryCellBackendStr(def, cfg, i, priv, - &nodeBackends[i])) < 0) + if ((rc = qemuBuildMemoryCellBackendProps(def, cfg, i, priv, + &nodeBackends[i])) < 0) goto cleanup; if (rc == 0) @@ -7448,8 +7439,14 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg, ssize_t initiator = virDomainNumaGetNodeInitiator(def->numa, i); if (needBackend) { + g_auto(virBuffer) objbuf = VIR_BUFFER_INITIALIZER; + + if (qemuBuildObjectCommandlineFromJSON(&objbuf, nodeBackends[i], + priv->qemuCaps) < 0) + goto cleanup; + virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &nodeBackends[i]); + virCommandAddArgBuffer(cmd, &objbuf); } virCommandAddArg(cmd, "-numa"); @@ -7507,7 +7504,7 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg, cleanup: if (nodeBackends) { for (i = 0; i < ncells; i++) - virBufferFreeAndReset(&nodeBackends[i]); + virJSONValueFree(nodeBackends[i]); VIR_FREE(nodeBackends); } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Rename the function to 'qemuBuildMemoryCellBackendProps' and return the properties before conversion to commandline arguments. This requires changes in the caller.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Input devices of VIR_DOMAIN_INPUT_TYPE_EVDEV type are instantiated via an '-object' rather than a '-device'. Mixing them in one function is a bad idea as the caller then needs to use the string correctly which is not the case in 'qemuDomainAttachInputDevice'. Generate a JSON object for '-object' explicitly. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 43 ++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index dcd6a6e75d..a4d439a0ec 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3887,12 +3887,10 @@ qemuBuildUSBInputDevStr(const virDomainDef *def, } -static char * -qemuBuildObjectInputDevStr(virDomainInputDef *dev, - virQEMUCaps *qemuCaps) +static virJSONValue * +qemuBuildInputEvdevProps(virDomainInputDef *dev) { g_autoptr(virJSONValue) props = NULL; - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; if (qemuMonitorCreateObjectProps(&props, "input-linux", dev->info.alias, "s:evdev", dev->source.evdev, @@ -3908,10 +3906,7 @@ qemuBuildObjectInputDevStr(virDomainInputDef *dev, virDomainInputSourceGrabToggleTypeToString(dev->source.grabToggle), NULL); - if (qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps) < 0) - return NULL; - - return virBufferContentAndReset(&buf); + return g_steal_pointer(&props); } @@ -3931,10 +3926,6 @@ qemuBuildInputDevStr(char **devstr, if (!(*devstr = qemuBuildVirtioInputDevStr(def, input, qemuCaps))) return -1; break; - case VIR_DOMAIN_INPUT_BUS_NONE: - if (!(*devstr = qemuBuildObjectInputDevStr(input, qemuCaps))) - return -1; - break; } return 0; } @@ -3949,20 +3940,32 @@ qemuBuildInputCommandLine(virCommand *cmd, for (i = 0; i < def->ninputs; i++) { virDomainInputDef *input = def->inputs[i]; - g_autofree char *devstr = NULL; if (qemuCommandAddExtDevice(cmd, &input->info) < 0) return -1; - if (qemuBuildInputDevStr(&devstr, def, input, qemuCaps) < 0) - return -1; + if (input->type == VIR_DOMAIN_INPUT_TYPE_EVDEV) { + g_autoptr(virJSONValue) props = NULL; + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - if (devstr) { - if (input->type == VIR_DOMAIN_INPUT_TYPE_EVDEV) - virCommandAddArg(cmd, "-object"); - else + if (!(props = qemuBuildInputEvdevProps(input))) + return -1; + + if (qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps) < 0) + return -1; + + virCommandAddArg(cmd, "-object"); + virCommandAddArgBuffer(cmd, &buf); + } else { + g_autofree char *devstr = NULL; + + if (qemuBuildInputDevStr(&devstr, def, input, qemuCaps) < 0) + return -1; + + if (devstr) { virCommandAddArg(cmd, "-device"); - virCommandAddArg(cmd, devstr); + virCommandAddArg(cmd, devstr); + } } } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Input devices of VIR_DOMAIN_INPUT_TYPE_EVDEV type are instantiated via an '-object' rather than a '-device'. Mixing them in one function is a bad idea as the caller then needs to use the string correctly which is not the case in 'qemuDomainAttachInputDevice'.
Generate a JSON object for '-object' explicitly.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 43 ++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 20 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

All callers basically end up dumping the buffer into a string and then adding '-object' 'props' arguments to virCommand. Simplify all callers by doing this in the function itself. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 119 +++++++++++----------------------------- 1 file changed, 32 insertions(+), 87 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a4d439a0ec..ae8234f88f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -156,10 +156,11 @@ VIR_ENUM_IMPL(qemuAudioDriver, static int -qemuBuildObjectCommandlineFromJSON(virBuffer *buf, +qemuBuildObjectCommandlineFromJSON(virCommand *cmd, virJSONValue *props, virQEMUCaps *qemuCaps) { + g_autofree char *arg = NULL; const char *type = virJSONValueObjectGetString(props, "qom-type"); const char *alias = virJSONValueObjectGetString(props, "id"); @@ -171,13 +172,22 @@ qemuBuildObjectCommandlineFromJSON(virBuffer *buf, } if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_QAPIFIED)) { - return virJSONValueToBuffer(props, buf, false); + if (!(arg = virJSONValueToString(props, false))) + return -1; } else { - virBufferAsprintf(buf, "%s,", type); + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - return virQEMUBuildCommandLineJSON(props, buf, "qom-type", - virQEMUBuildCommandLineJSONArrayBitmap); + virBufferAsprintf(&buf, "%s,", type); + + if (virQEMUBuildCommandLineJSON(props, &buf, "qom-type", + virQEMUBuildCommandLineJSONArrayBitmap) < 0) + return -1; + + arg = virBufferContentAndReset(&buf); } + + virCommandAddArgList(cmd, "-object", arg, NULL); + return 0; } @@ -197,7 +207,6 @@ qemuBuildMasterKeyCommandLine(virCommand *cmd, { g_autofree char *alias = NULL; g_autofree char *path = NULL; - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_autoptr(virJSONValue) props = NULL; if (!(alias = qemuDomainGetMasterKeyAlias())) @@ -217,12 +226,9 @@ qemuBuildMasterKeyCommandLine(virCommand *cmd, NULL) < 0) return -1; - if (qemuBuildObjectCommandlineFromJSON(&buf, props, priv->qemuCaps) < 0) + if (qemuBuildObjectCommandlineFromJSON(cmd, props, priv->qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &buf); - return 0; } @@ -732,18 +738,14 @@ qemuBuildObjectSecretCommandLine(virCommand *cmd, qemuDomainSecretInfo *secinfo, virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_autoptr(virJSONValue) props = NULL; if (qemuBuildSecretInfoProps(secinfo, &props) < 0) return -1; - if (qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps) < 0) + if (qemuBuildObjectCommandlineFromJSON(cmd, props, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &buf); - return 0; } @@ -803,19 +805,15 @@ qemuBuildTLSx509CommandLine(virCommand *cmd, const char *alias, virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_autoptr(virJSONValue) props = NULL; if (qemuBuildTLSx509BackendProps(tlspath, isListen, verifypeer, alias, certEncSecretAlias, &props) < 0) return -1; - if (qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps) < 0) + if (qemuBuildObjectCommandlineFromJSON(cmd, props, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &buf); - return 0; } @@ -1852,17 +1850,12 @@ qemuBuildObjectCommandline(virCommand *cmd, virJSONValue *objProps, virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - if (!objProps) return 0; - if (qemuBuildObjectCommandlineFromJSON(&buf, objProps, qemuCaps) < 0) + if (qemuBuildObjectCommandlineFromJSON(cmd, objProps, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &buf); - return 0; } @@ -3210,7 +3203,7 @@ qemuBuildMemoryCellBackendProps(virDomainDef *def, static int -qemuBuildMemoryDimmBackendStr(virBuffer *buf, +qemuBuildMemoryDimmBackendStr(virCommand *cmd, virDomainMemoryDef *mem, virDomainDef *def, virQEMUDriverConfig *cfg, @@ -3231,7 +3224,7 @@ qemuBuildMemoryDimmBackendStr(virBuffer *buf, priv, def, mem, true, false) < 0) return -1; - if (qemuBuildObjectCommandlineFromJSON(buf, props, priv->qemuCaps) < 0) + if (qemuBuildObjectCommandlineFromJSON(cmd, props, priv->qemuCaps) < 0) return -1; return 0; @@ -3946,16 +3939,12 @@ qemuBuildInputCommandLine(virCommand *cmd, if (input->type == VIR_DOMAIN_INPUT_TYPE_EVDEV) { g_autoptr(virJSONValue) props = NULL; - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; if (!(props = qemuBuildInputEvdevProps(input))) return -1; - if (qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps) < 0) + if (qemuBuildObjectCommandlineFromJSON(cmd, props, qemuCaps) < 0) return -1; - - virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &buf); } else { g_autofree char *devstr = NULL; @@ -5523,11 +5512,9 @@ qemuBuildRNGCommandLine(virLogManager *logManager, for (i = 0; i < def->nrngs; i++) { g_autoptr(virJSONValue) props = NULL; - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; virDomainRNGDef *rng = def->rngs[i]; g_autofree char *chardev = NULL; g_autofree char *devstr = NULL; - int rc; if (!rng->info.alias) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -5547,14 +5534,9 @@ qemuBuildRNGCommandLine(virLogManager *logManager, if (qemuBuildRNGBackendProps(rng, &props) < 0) return -1; - rc = qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps); - - if (rc < 0) + if (qemuBuildObjectCommandlineFromJSON(cmd, props, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &buf); - /* add the device */ if (qemuCommandAddExtDevice(cmd, &rng->info) < 0) return -1; @@ -7109,7 +7091,6 @@ qemuBuildMemCommandLineMemoryDefaultBackend(virCommand *cmd, { g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(priv->driver); g_autoptr(virJSONValue) props = NULL; - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; virDomainMemoryDef mem = { 0 }; mem.size = virDomainDefGetMemoryInitial(def); @@ -7120,11 +7101,9 @@ qemuBuildMemCommandLineMemoryDefaultBackend(virCommand *cmd, priv, def, &mem, false, true) < 0) return -1; - if (qemuBuildObjectCommandlineFromJSON(&buf, props, priv->qemuCaps) < 0) + if (qemuBuildObjectCommandlineFromJSON(cmd, props, priv->qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &buf); return 0; } @@ -7203,17 +7182,13 @@ qemuBuildIOThreadCommandLine(virCommand *cmd, for (i = 0; i < def->niothreadids; i++) { g_autoptr(virJSONValue) props = NULL; - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_autofree char *alias = g_strdup_printf("iothread%u", def->iothreadids[i]->iothread_id); if (qemuMonitorCreateObjectProps(&props, "iothread", alias, NULL) < 0) return -1; - if (qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps) < 0) + if (qemuBuildObjectCommandlineFromJSON(cmd, props, qemuCaps) < 0) return -1; - - virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &buf); } return 0; @@ -7442,14 +7417,9 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg, ssize_t initiator = virDomainNumaGetNodeInitiator(def->numa, i); if (needBackend) { - g_auto(virBuffer) objbuf = VIR_BUFFER_INITIALIZER; - - if (qemuBuildObjectCommandlineFromJSON(&objbuf, nodeBackends[i], + if (qemuBuildObjectCommandlineFromJSON(cmd, nodeBackends[i], priv->qemuCaps) < 0) goto cleanup; - - virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &objbuf); } virCommandAddArg(cmd, "-numa"); @@ -7527,15 +7497,11 @@ qemuBuildMemoryDeviceCommandLine(virCommand *cmd, /* memory hotplug requires NUMA to be enabled - we already checked * that memory devices are present only when NUMA is */ for (i = 0; i < def->nmems; i++) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; char *dimmStr; - if (qemuBuildMemoryDimmBackendStr(&buf, def->mems[i], def, cfg, priv) < 0) + if (qemuBuildMemoryDimmBackendStr(cmd, def->mems[i], def, cfg, priv) < 0) return -1; - virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &buf); - if (!(dimmStr = qemuBuildMemoryDeviceStr(def, def->mems[i], priv->qemuCaps))) return -1; @@ -9044,10 +9010,8 @@ qemuBuildShmemCommandLine(virLogManager *logManager, bool chardevStdioLogd) { g_autoptr(virJSONValue) memProps = NULL; - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_autofree char *devstr = NULL; g_autofree char *chardev = NULL; - int rc; unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT | QEMU_BUILD_CHARDEV_UNIX_FD_PASS; if (chardevStdioLogd) @@ -9088,14 +9052,9 @@ qemuBuildShmemCommandLine(virLogManager *logManager, if (!(memProps = qemuBuildShmemBackendMemProps(shmem))) return -1; - rc = qemuBuildObjectCommandlineFromJSON(&buf, memProps, qemuCaps); - - if (rc < 0) + if (qemuBuildObjectCommandlineFromJSON(cmd, memProps, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &buf); - G_GNUC_FALLTHROUGH; case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL: devstr = qemuBuildShmemDevStr(def, shmem, qemuCaps); @@ -9816,7 +9775,6 @@ qemuBuildSEVCommandLine(virDomainObj *vm, virCommand *cmd, virDomainSEVDef *sev) { g_autoptr(virJSONValue) props = NULL; - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; qemuDomainObjPrivate *priv = vm->privateData; g_autofree char *dhpath = NULL; g_autofree char *sessionpath = NULL; @@ -9839,11 +9797,9 @@ qemuBuildSEVCommandLine(virDomainObj *vm, virCommand *cmd, NULL) < 0) return -1; - if (qemuBuildObjectCommandlineFromJSON(&buf, props, priv->qemuCaps) < 0) + if (qemuBuildObjectCommandlineFromJSON(cmd, props, priv->qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &buf); return 0; } @@ -9852,18 +9808,15 @@ static int qemuBuildPVCommandLine(virDomainObj *vm, virCommand *cmd) { g_autoptr(virJSONValue) props = NULL; - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; qemuDomainObjPrivate *priv = vm->privateData; if (qemuMonitorCreateObjectProps(&props, "s390-pv-guest", "lsec0", NULL) < 0) return -1; - if (qemuBuildObjectCommandlineFromJSON(&buf, props, priv->qemuCaps) < 0) + if (qemuBuildObjectCommandlineFromJSON(cmd, props, priv->qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &buf); return 0; } @@ -9993,7 +9946,6 @@ qemuBuildManagedPRCommandLine(virCommand *cmd, const virDomainDef *def, qemuDomainObjPrivate *priv) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_autoptr(virJSONValue) props = NULL; if (!virDomainDefHasManagedPR(def)) @@ -10002,12 +9954,9 @@ qemuBuildManagedPRCommandLine(virCommand *cmd, if (!(props = qemuBuildPRManagedManagerInfoProps(priv))) return -1; - if (qemuBuildObjectCommandlineFromJSON(&buf, props, priv->qemuCaps) < 0) + if (qemuBuildObjectCommandlineFromJSON(cmd, props, priv->qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &buf); - return 0; } @@ -10076,7 +10025,6 @@ qemuBuildDBusVMStateCommandLine(virCommand *cmd, virQEMUDriver *driver, virDomainObj *vm) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_autoptr(virJSONValue) props = NULL; qemuDomainObjPrivate *priv = QEMU_DOMAIN_PRIVATE(vm); @@ -10091,12 +10039,9 @@ qemuBuildDBusVMStateCommandLine(virCommand *cmd, if (!(props = qemuBuildDBusVMStateInfoProps(driver, vm))) return -1; - if (qemuBuildObjectCommandlineFromJSON(&buf, props, priv->qemuCaps) < 0) + if (qemuBuildObjectCommandlineFromJSON(cmd, props, priv->qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-object"); - virCommandAddArgBuffer(cmd, &buf); - priv->dbusVMState = true; return 0; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
All callers basically end up dumping the buffer into a string and then adding '-object' 'props' arguments to virCommand. Simplify all callers by doing this in the function itself.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 119 +++++++++++----------------------------- 1 file changed, 32 insertions(+), 87 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Unify it with the upcoming capabilities for -netdev and -device. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_capabilities.c | 6 +++--- src/qemu/qemu_capabilities.h | 2 +- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_monitor.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 82687dbf39..02f297d14f 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -623,7 +623,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "vnc-power-control", /* QEMU_CAPS_VNC_POWER_CONTROL */ "audiodev", /* QEMU_CAPS_AUDIODEV */ "blockdev-backup", /* QEMU_CAPS_BLOCKDEV_BACKUP */ - "object.qapified", /* QEMU_CAPS_OBJECT_QAPIFIED */ + "object.qapified", /* QEMU_CAPS_OBJECT_JSON */ "rotation-rate", /* QEMU_CAPS_ROTATION_RATE */ /* 400 */ @@ -1580,7 +1580,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = { { "nbd-server-start/arg-type/tls-creds", QEMU_CAPS_NBD_TLS }, { "nbd-server-add/arg-type/bitmap", QEMU_CAPS_NBD_BITMAP }, { "netdev_add/arg-type/+vhost-vdpa", QEMU_CAPS_NETDEV_VHOST_VDPA }, - { "object-add/arg-type/qom-type/^secret", QEMU_CAPS_OBJECT_QAPIFIED }, + { "object-add/arg-type/qom-type/^secret", QEMU_CAPS_OBJECT_JSON }, { "query-display-options/ret-type/+egl-headless/rendernode", QEMU_CAPS_EGL_HEADLESS_RENDERNODE }, { "query-display-options/ret-type/+sdl", QEMU_CAPS_SDL }, { "query-display-options/ret-type/+egl-headless", QEMU_CAPS_EGL_HEADLESS }, @@ -5089,7 +5089,7 @@ virQEMUCapsInitProcessCapsInterlock(virQEMUCaps *qemuCaps) * method which doesn't show up in query-command-line-options. As we'll use * it only for development and testing purposes we can base the capability * on a not entirely related witness. */ - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_QAPIFIED)) + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_JSON)) virQEMUCapsSet(qemuCaps, QEMU_CAPS_COMPAT_DEPRECATED); } diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 2bbfc15dc4..00ea71633a 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -603,7 +603,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_VNC_POWER_CONTROL, /* -vnc power-control option */ QEMU_CAPS_AUDIODEV, /* -audiodev instead of QEMU_AUDIO_DRV */ QEMU_CAPS_BLOCKDEV_BACKUP, /* qemu supports the blockdev-backup job */ - QEMU_CAPS_OBJECT_QAPIFIED, /* parameters for object-add are formally described */ + QEMU_CAPS_OBJECT_JSON, /* parameters for object-add are formally described */ QEMU_CAPS_ROTATION_RATE, /* scsi-disk / ide-drive rotation-rate prop */ /* 400 */ diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ae8234f88f..1a946d895d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -171,7 +171,7 @@ qemuBuildObjectCommandlineFromJSON(virCommand *cmd, return -1; } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_QAPIFIED)) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_JSON)) { if (!(arg = virJSONValueToString(props, false))) return -1; } else { diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 5fc23f13d3..068b7ff997 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -700,7 +700,7 @@ qemuMonitorOpenInternal(virDomainObj *vm, mon->callbackOpaque = opaque; if (priv) - mon->objectAddNoWrap = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_QAPIFIED); + mon->objectAddNoWrap = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_JSON); if (virSetCloseExec(mon->fd) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Unify it with the upcoming capabilities for -netdev and -device.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_capabilities.c | 6 +++--- src/qemu/qemu_capabilities.h | 2 +- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_monitor.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Introduce a capability that will be asserted once '-netdev' will accept JSON. For now it will be dormant (only used by tests). Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_capabilities.c | 1 + src/qemu/qemu_capabilities.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 02f297d14f..b0542ff19c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -644,6 +644,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "virtio-mem-pci", /* QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI */ "memory-backend-file.reserve", /* QEMU_CAPS_MEMORY_BACKEND_RESERVE */ "piix4.acpi-root-pci-hotplug", /* QEMU_CAPS_PIIX4_ACPI_ROOT_PCI_HOTPLUG */ + "netdev.json", /* QEMU_CAPS_NETDEV_JSON */ ); diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 00ea71633a..2945054079 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -624,6 +624,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI, /* -device virtio-mem-pci */ QEMU_CAPS_MEMORY_BACKEND_RESERVE, /* -object memory-backend-*.reserve= */ QEMU_CAPS_PIIX4_ACPI_ROOT_PCI_HOTPLUG, /* -M pc PIIX4_PM.acpi-root-pci-hotplug */ + QEMU_CAPS_NETDEV_JSON, /* -netdev accepts JSON */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Introduce a capability that will be asserted once '-netdev' will accept JSON. For now it will be dormant (only used by tests).
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_capabilities.c | 1 + src/qemu/qemu_capabilities.h | 1 + 2 files changed, 2 insertions(+)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

We validate the generated props agains the QMP schema which makes sure that the objects are generated properly. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1a946d895d..f82768d5b1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -161,20 +161,12 @@ qemuBuildObjectCommandlineFromJSON(virCommand *cmd, virQEMUCaps *qemuCaps) { g_autofree char *arg = NULL; - const char *type = virJSONValueObjectGetString(props, "qom-type"); - const char *alias = virJSONValueObjectGetString(props, "id"); - - if (!type || !alias) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing 'type'(%s) or 'alias'(%s) field of QOM 'object'"), - NULLSTR(type), NULLSTR(alias)); - return -1; - } if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_JSON)) { if (!(arg = virJSONValueToString(props, false))) return -1; } else { + const char *type = virJSONValueObjectGetString(props, "qom-type"); g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; virBufferAsprintf(&buf, "%s,", type); -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
We validate the generated props agains the QMP schema which makes sure
*against
that the objects are generated properly.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

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> --- tests/qemuxml2argvtest.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 7df3946751..2190e03d18 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -503,7 +503,6 @@ testCompareXMLToArgvValidateSchema(virQEMUDriver *drv, GHashTable *schema = NULL; g_autoptr(virCommand) cmd = NULL; unsigned int parseFlags = info->parseFlags; - bool netdevQAPIfied = false; /* comment out with line comment to enable schema checking for non _CAPS tests if (!info->schemafile) @@ -546,8 +545,6 @@ testCompareXMLToArgvValidateSchema(virQEMUDriver *drv, if (virCommandGetArgList(cmd, &args, &nargs) < 0) return -1; - netdevQAPIfied = !virQEMUQAPISchemaPathExists("netdev_add/arg-type/type/!string", schema); - for (i = 0; i < nargs; i++) { g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER; g_autoptr(virJSONValue) jsonargs = NULL; @@ -565,7 +562,7 @@ testCompareXMLToArgvValidateSchema(virQEMUDriver *drv, i++; } else if (STREQ(args[i], "-netdev")) { - if (!netdevQAPIfied) { + if (*args[i + 1] != '{') { i++; continue; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
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> --- tests/qemuxml2argvtest.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Base the JSON output on a regular capability flag rather than purely internal flag. This will prepare for the time when QEMU will accept JSON argumets for -netdev. For now the capability is not set (thus we for now don't have QMP schema validation) but that will be addressed later. To achieve this 'qemuBuildNetdevCommandlineFromJSON' is introduced and all callers of 'virQEMUBuildNetdevCommandlineFromJSON' are refactored to use the new helper. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/libvirt_private.syms | 1 + src/qemu/qemu_command.c | 55 ++++++++++++++++++++++++++-------------- src/util/virqemu.c | 2 +- src/util/virqemu.h | 4 +++ 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fd0eea0777..a58f2e4552 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3118,6 +3118,7 @@ virQEMUBuildBufferEscapeComma; virQEMUBuildCommandLineJSON; virQEMUBuildCommandLineJSONArrayBitmap; virQEMUBuildCommandLineJSONArrayNumbered; +virQEMUBuildCommandLineJSONArrayObjectsStr; virQEMUBuildDriveCommandlineFromJSON; virQEMUBuildNetdevCommandlineFromJSON; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f82768d5b1..3c5aa94f11 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -183,6 +183,34 @@ qemuBuildObjectCommandlineFromJSON(virCommand *cmd, } +static int +qemuBuildNetdevCommandlineFromJSON(virCommand *cmd, + virJSONValue *props, + virQEMUCaps *qemuCaps) +{ + g_autofree char *arg = NULL; + + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NETDEV_JSON)) { + if (!(arg = virJSONValueToString(props, false))) + return -1; + } else { + const char *type = virJSONValueObjectGetString(props, "type"); + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + + virBufferAsprintf(&buf, "%s,", type); + + if (virQEMUBuildCommandLineJSON(props, &buf, "type", + virQEMUBuildCommandLineJSONArrayObjectsStr) < 0) + return -1; + + arg = virBufferContentAndReset(&buf); + } + + virCommandAddArgList(cmd, "-netdev", arg, NULL); + return 0; +} + + /** * qemuBuildMasterKeyCommandLine: * @cmd: the command to modify @@ -8383,13 +8411,11 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, virNetDevVPortProfileOp vmop, bool standalone, size_t *nnicindexes, - int **nicindexes, - unsigned int flags) + int **nicindexes) { virDomainDef *def = vm->def; int ret = -1; g_autofree char *nic = NULL; - g_autofree char *host = NULL; g_autofree char *chardev = NULL; int *tapfd = NULL; size_t tapfdSize = 0; @@ -8643,12 +8669,9 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, slirpfdName, vdpafdName))) goto cleanup; - if (!(host = virQEMUBuildNetdevCommandlineFromJSON(hostnetprops, - (flags & QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON)))) + if (qemuBuildNetdevCommandlineFromJSON(cmd, hostnetprops, qemuCaps) < 0) goto cleanup; - virCommandAddArgList(cmd, "-netdev", host, NULL); - /* Possible combinations: * * Old way: -netdev type=tap,id=netdev1 \ @@ -8721,8 +8744,7 @@ qemuBuildNetCommandLine(virQEMUDriver *driver, bool standalone, size_t *nnicindexes, int **nicindexes, - unsigned int *bootHostdevNet, - unsigned int flags) + unsigned int *bootHostdevNet) { size_t i; int last_good_net = -1; @@ -8746,7 +8768,7 @@ qemuBuildNetCommandLine(virQEMUDriver *driver, if (qemuBuildInterfaceCommandLine(driver, vm, logManager, secManager, cmd, net, qemuCaps, bootNet, vmop, standalone, nnicindexes, - nicindexes, flags) < 0) + nicindexes) < 0) goto error; last_good_net = i; @@ -9270,8 +9292,7 @@ qemuBuildChannelsCommandLine(virLogManager *logManager, virQEMUDriverConfig *cfg, const virDomainDef *def, virQEMUCaps *qemuCaps, - bool chardevStdioLogd, - unsigned int flags) + bool chardevStdioLogd) { size_t i; unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT | @@ -9283,7 +9304,6 @@ qemuBuildChannelsCommandLine(virLogManager *logManager, virDomainChrDef *channel = def->channels[i]; g_autofree char *chardevstr = NULL; g_autoptr(virJSONValue) netdevprops = NULL; - g_autofree char *netdevstr = NULL; if (!(chardevstr = qemuBuildChrChardevStr(logManager, secManager, cmd, cfg, def, @@ -9300,11 +9320,8 @@ qemuBuildChannelsCommandLine(virLogManager *logManager, if (!(netdevprops = qemuBuildChannelGuestfwdNetdevProps(channel))) return -1; - if (!(netdevstr = virQEMUBuildNetdevCommandlineFromJSON(netdevprops, - (flags & QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON)))) + if (qemuBuildNetdevCommandlineFromJSON(cmd, netdevprops, qemuCaps) < 0) return -1; - - virCommandAddArgList(cmd, "-netdev", netdevstr, NULL); break; case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: @@ -10452,7 +10469,7 @@ qemuBuildCommandLine(virQEMUDriver *driver, if (qemuBuildNetCommandLine(driver, vm, logManager, secManager, cmd, qemuCaps, vmop, standalone, - nnicindexes, nicindexes, &bootHostdevNet, flags) < 0) + nnicindexes, nicindexes, &bootHostdevNet) < 0) return NULL; if (qemuBuildSmartcardCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps, @@ -10468,7 +10485,7 @@ qemuBuildCommandLine(virQEMUDriver *driver, return NULL; if (qemuBuildChannelsCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps, - chardevStdioLogd, flags) < 0) + chardevStdioLogd) < 0) return NULL; if (qemuBuildConsoleCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps, diff --git a/src/util/virqemu.c b/src/util/virqemu.c index 644a1615dc..ff6e13b963 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -127,7 +127,7 @@ virQEMUBuildCommandLineJSONArrayNumbered(const char *key, * * guestfwd=tcp:10.0.2.1:4600-chardev:charchannel0,guestfwd=... */ -static int +int virQEMUBuildCommandLineJSONArrayObjectsStr(const char *key, virJSONValue *array, virBuffer *buf, diff --git a/src/util/virqemu.h b/src/util/virqemu.h index 70668faf47..b1fc3c8323 100644 --- a/src/util/virqemu.h +++ b/src/util/virqemu.h @@ -30,6 +30,10 @@ typedef int (*virQEMUBuildCommandLineJSONArrayFormatFunc)(const char *key, virJSONValue *array, virBuffer *buf, const char *skipKey); +int virQEMUBuildCommandLineJSONArrayObjectsStr(const char *key, + virJSONValue *array, + virBuffer *buf, + const char *skipKey); int virQEMUBuildCommandLineJSONArrayBitmap(const char *key, virJSONValue *array, virBuffer *buf, -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Base the JSON output on a regular capability flag rather than purely internal flag. This will prepare for the time when QEMU will accept JSON argumets for -netdev.
For now the capability is not set (thus we for now don't have QMP schema validation) but that will be addressed later.
To achieve this 'qemuBuildNetdevCommandlineFromJSON' is introduced and all callers of 'virQEMUBuildNetdevCommandlineFromJSON' are refactored to use the new helper.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/libvirt_private.syms | 1 + src/qemu/qemu_command.c | 55 ++++++++++++++++++++++++++-------------- src/util/virqemu.c | 2 +- src/util/virqemu.h | 4 +++ 4 files changed, 42 insertions(+), 20 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Now that everything was replaced by the new code we can remove this function. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/libvirt_private.syms | 1 - src/util/virqemu.c | 30 ------------------------------ src/util/virqemu.h | 4 ---- 3 files changed, 35 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a58f2e4552..cffd3d638c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3120,7 +3120,6 @@ virQEMUBuildCommandLineJSONArrayBitmap; virQEMUBuildCommandLineJSONArrayNumbered; virQEMUBuildCommandLineJSONArrayObjectsStr; virQEMUBuildDriveCommandlineFromJSON; -virQEMUBuildNetdevCommandlineFromJSON; # util/virrandom.h diff --git a/src/util/virqemu.c b/src/util/virqemu.c index ff6e13b963..8119643431 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -283,36 +283,6 @@ virQEMUBuildCommandLineJSON(virJSONValue *value, } -/** - * virQEMUBuildNetdevCommandlineFromJSON: - * @props: JSON properties describing a netdev - * @rawjson: don't transform to commandline args, but just stringify json - * - * Converts @props into arguments for -netdev including all the quirks and - * differences between the monitor and command line syntax. - * - * @rawjson is meant for testing of the schema in the xml2argvtest - */ -char * -virQEMUBuildNetdevCommandlineFromJSON(virJSONValue *props, - bool rawjson) -{ - const char *type = virJSONValueObjectGetString(props, "type"); - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - - if (rawjson) - return virJSONValueToString(props, false); - - virBufferAsprintf(&buf, "%s,", type); - - if (virQEMUBuildCommandLineJSON(props, &buf, "type", - virQEMUBuildCommandLineJSONArrayObjectsStr) < 0) - return NULL; - - return virBufferContentAndReset(&buf); -} - - char * virQEMUBuildDriveCommandlineFromJSON(virJSONValue *srcdef) { diff --git a/src/util/virqemu.h b/src/util/virqemu.h index b1fc3c8323..5098ed7653 100644 --- a/src/util/virqemu.h +++ b/src/util/virqemu.h @@ -48,10 +48,6 @@ int virQEMUBuildCommandLineJSON(virJSONValue *value, const char *skipKey, virQEMUBuildCommandLineJSONArrayFormatFunc array); -char * -virQEMUBuildNetdevCommandlineFromJSON(virJSONValue *props, - bool rawjson); - char *virQEMUBuildDriveCommandlineFromJSON(virJSONValue *src); void virQEMUBuildBufferEscapeComma(virBuffer *buf, const char *str); -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Now that everything was replaced by the new code we can remove this function.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/libvirt_private.syms | 1 - src/util/virqemu.c | 30 ------------------------------ src/util/virqemu.h | 4 ---- 3 files changed, 35 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

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> --- src/qemu/qemu_command.h | 4 ---- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_process.c | 10 ++-------- src/qemu/qemu_process.h | 3 +-- tests/qemuxml2argvtest.c | 11 ++++------- 5 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 6b8f90f737..00efcfd5fd 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -43,10 +43,6 @@ VIR_ENUM_DECL(qemuVideo); VIR_ENUM_DECL(qemuSoundCodec); -typedef enum { - QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON = 1 << 0, -} qemuBuildCommandLineFlags; - virCommand *qemuBuildCommandLine(virQEMUDriver *driver, virLogManager *logManager, virSecurityManager *secManager, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 760d30a867..e0a3b4d978 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6423,7 +6423,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn, goto cleanup; if (!(cmd = qemuProcessCreatePretendCmdBuild(driver, vm, NULL, - qemuCheckFips(vm), true, false))) + qemuCheckFips(vm), true))) goto cleanup; ret = virCommandToString(cmd, false); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1d0165af6d..9faaeeadba 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7756,14 +7756,8 @@ qemuProcessCreatePretendCmdBuild(virQEMUDriver *driver, virDomainObj *vm, const char *migrateURI, bool enableFips, - bool standalone, - bool jsonPropsValidation) + bool standalone) { - unsigned int buildflags = 0; - - if (jsonPropsValidation) - buildflags = QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON; - VIR_DEBUG("Building emulator command line"); return qemuBuildCommandLine(driver, NULL, @@ -7776,7 +7770,7 @@ qemuProcessCreatePretendCmdBuild(virQEMUDriver *driver, enableFips, NULL, NULL, - buildflags); + 0); } diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index f9fa140e6d..c0f1c85aab 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -105,8 +105,7 @@ virCommand *qemuProcessCreatePretendCmdBuild(virQEMUDriver *driver, virDomainObj *vm, const char *migrateURI, bool enableFips, - bool standalone, - bool jsonPropsValidation); + bool standalone); int qemuProcessInit(virQEMUDriver *driver, virDomainObj *vm, diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 2190e03d18..7c6e3d3dd7 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -386,8 +386,7 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, virDomainObj *vm, const char *migrateURI, struct testQemuInfo *info, - unsigned int flags, - bool jsonPropsValidation) + unsigned int flags) { qemuDomainObjPrivate *priv = vm->privateData; bool enableFips = !!(flags & FLAG_FIPS_HOST); @@ -484,8 +483,7 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, enableFips = false; return qemuProcessCreatePretendCmdBuild(drv, vm, migrateURI, - enableFips, false, - jsonPropsValidation); + enableFips, false); } @@ -538,8 +536,7 @@ testCompareXMLToArgvValidateSchema(virQEMUDriver *drv, if (virBitmapParse("0-3", &priv->autoNodeset, 4) < 0) return -1; - if (!(cmd = testCompareXMLToArgvCreateArgs(drv, vm, migrateURI, info, flags, - true))) + if (!(cmd = testCompareXMLToArgvCreateArgs(drv, vm, migrateURI, info, flags))) return -1; if (virCommandGetArgList(cmd, &args, &nargs) < 0) @@ -743,7 +740,7 @@ testCompareXMLToArgv(const void *data) virResetLastError(); if (!(cmd = testCompareXMLToArgvCreateArgs(&driver, vm, migrateURI, info, - flags, false))) { + flags))) { err = virGetLastError(); if (!err) { VIR_TEST_DEBUG("no error was reported for expected failure"); -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
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> --- src/qemu/qemu_command.h | 4 ---- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_process.c | 10 ++-------- src/qemu/qemu_process.h | 3 +-- tests/qemuxml2argvtest.c | 11 ++++------- 5 files changed, 8 insertions(+), 22 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Optimize the number of string copies by using the virBuffers in the callers directly. Simplest way to achieve this is to just open code the one function call 'virQEMUBuildDriveCommandlineFromJSON' was wrapping in the two callers. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/libvirt_private.syms | 1 - src/qemu/qemu_command.c | 13 +++++++------ src/util/virqemu.c | 13 ------------- src/util/virqemu.h | 2 -- 4 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index cffd3d638c..516b3692b2 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3119,7 +3119,6 @@ virQEMUBuildCommandLineJSON; virQEMUBuildCommandLineJSONArrayBitmap; virQEMUBuildCommandLineJSONArrayNumbered; virQEMUBuildCommandLineJSONArrayObjectsStr; -virQEMUBuildDriveCommandlineFromJSON; # util/virrandom.h diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3c5aa94f11..19b1119e4a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1252,10 +1252,9 @@ qemuBuildDriveSourceStr(virDomainDiskDef *disk, if (qemuBuildDriveSourcePR(buf, disk) < 0) return -1; } else { - if (!(source = virQEMUBuildDriveCommandlineFromJSON(srcprops))) + if (virQEMUBuildCommandLineJSON(srcprops, buf, NULL, + virQEMUBuildCommandLineJSONArrayNumbered) < 0) return -1; - - virBufferAdd(buf, source, -1); } virBufferAddLit(buf, ","); @@ -4533,16 +4532,18 @@ static char * qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDef *dev) { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - g_autofree char *netsource = NULL; g_autoptr(virJSONValue) srcprops = NULL; virDomainHostdevSubsysSCSI *scsisrc = &dev->source.subsys.u.scsi; virDomainHostdevSubsysSCSIiSCSI *iscsisrc = &scsisrc->u.iscsi; if (!(srcprops = qemuDiskSourceGetProps(iscsisrc->src))) return NULL; - if (!(netsource = virQEMUBuildDriveCommandlineFromJSON(srcprops))) + + if (virQEMUBuildCommandLineJSON(srcprops, &buf, NULL, + virQEMUBuildCommandLineJSONArrayNumbered) < 0) return NULL; - virBufferAsprintf(&buf, "%s,if=none,format=raw", netsource); + + virBufferAddLit(&buf, ",if=none,format=raw"); return virBufferContentAndReset(&buf); } diff --git a/src/util/virqemu.c b/src/util/virqemu.c index 8119643431..e31451dff4 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -283,19 +283,6 @@ virQEMUBuildCommandLineJSON(virJSONValue *value, } -char * -virQEMUBuildDriveCommandlineFromJSON(virJSONValue *srcdef) -{ - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - - if (virQEMUBuildCommandLineJSON(srcdef, &buf, NULL, - virQEMUBuildCommandLineJSONArrayNumbered) < 0) - return NULL; - - return virBufferContentAndReset(&buf); -} - - /** * virQEMUBuildBufferEscapeComma: * @buf: buffer to append the escaped string diff --git a/src/util/virqemu.h b/src/util/virqemu.h index 5098ed7653..472f24de53 100644 --- a/src/util/virqemu.h +++ b/src/util/virqemu.h @@ -48,6 +48,4 @@ int virQEMUBuildCommandLineJSON(virJSONValue *value, const char *skipKey, virQEMUBuildCommandLineJSONArrayFormatFunc array); -char *virQEMUBuildDriveCommandlineFromJSON(virJSONValue *src); - void virQEMUBuildBufferEscapeComma(virBuffer *buf, const char *str); -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Optimize the number of string copies by using the virBuffers in the callers directly. Simplest way to achieve this is to just open code the one function call 'virQEMUBuildDriveCommandlineFromJSON' was wrapping in the two callers.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/libvirt_private.syms | 1 - src/qemu/qemu_command.c | 13 +++++++------ src/util/virqemu.c | 13 ------------- src/util/virqemu.h | 2 -- 4 files changed, 7 insertions(+), 22 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

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> --- tests/qemuxml2argvtest.c | 120 +++++++++++++++++++++------------------ 1 file changed, 66 insertions(+), 54 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 7c6e3d3dd7..b5fab1178c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -487,6 +487,70 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, } +struct testValidateSchemaCommandData { + const char *name; + const char *schema; +}; + + +static const struct testValidateSchemaCommandData commands[] = { + { "-blockdev", "blockdev-add" }, + { "-netdev", "netdev_add" }, + { "-object", "object-add" }, +}; + +static int +testCompareXMLToArgvValidateSchemaCommand(GStrv args, + GHashTable *schema) +{ + GStrv arg; + + for (arg = args; *arg; arg++) { + const char *curcommand = *arg; + const char *curargs = *(arg + 1); + size_t i; + + for (i = 0; i < G_N_ELEMENTS(commands); i++) { + const struct testValidateSchemaCommandData *command = commands + i; + g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) jsonargs = NULL; + + if (STRNEQ(curcommand, command->name)) + continue; + + if (!curargs) { + VIR_TEST_VERBOSE("expected arguments for command '%s'", + command->name); + return -1; + } + + if (*curargs != '{') { + /* skip the current validation */ + VIR_TEST_DEBUG("skipping validation of '%s': argument is not JSON", + command->name); + arg++; + break; + } + + if (!(jsonargs = virJSONValueFromString(curargs))) + return -1; + + if (testQEMUSchemaValidateCommand(command->schema, jsonargs, + schema, false, false, &debug) < 0) { + VIR_TEST_VERBOSE("failed to validate '%s %s' against QAPI schema: %s", + command->name, curargs, virBufferCurrentContent(&debug)); + return -1; + } + + /* don't check the argument twice */ + arg++; + } + } + + return 0; +} + + static int testCompareXMLToArgvValidateSchema(virQEMUDriver *drv, const char *migrateURI, @@ -497,7 +561,6 @@ testCompareXMLToArgvValidateSchema(virQEMUDriver *drv, g_autoptr(virDomainObj) vm = NULL; qemuDomainObjPrivate *priv = NULL; size_t nargs = 0; - size_t i; GHashTable *schema = NULL; g_autoptr(virCommand) cmd = NULL; unsigned int parseFlags = info->parseFlags; @@ -542,59 +605,8 @@ testCompareXMLToArgvValidateSchema(virQEMUDriver *drv, if (virCommandGetArgList(cmd, &args, &nargs) < 0) return -1; - for (i = 0; i < nargs; i++) { - g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER; - g_autoptr(virJSONValue) jsonargs = NULL; - - if (STREQ(args[i], "-blockdev")) { - if (!(jsonargs = virJSONValueFromString(args[i + 1]))) - return -1; - - if (testQEMUSchemaValidateCommand("blockdev-add", jsonargs, - schema, false, false, &debug) < 0) { - VIR_TEST_VERBOSE("failed to validate -blockdev '%s' against QAPI schema: %s", - args[i + 1], virBufferCurrentContent(&debug)); - return -1; - } - - i++; - } else if (STREQ(args[i], "-netdev")) { - if (*args[i + 1] != '{') { - i++; - continue; - } - - if (!(jsonargs = virJSONValueFromString(args[i + 1]))) - return -1; - - if (testQEMUSchemaValidateCommand("netdev_add", jsonargs, - schema, false, false, &debug) < 0) { - VIR_TEST_VERBOSE("failed to validate -netdev '%s' against QAPI schema: %s", - args[i + 1], virBufferCurrentContent(&debug)); - return -1; - } - - i++; - } else if (STREQ(args[i], "-object")) { - - if (*args[i + 1] != '{') { - i++; - continue; - } - - if (!(jsonargs = virJSONValueFromString(args[i + 1]))) - return -1; - - if (testQEMUSchemaValidateCommand("object-add", jsonargs, - schema, false, false, &debug) < 0) { - VIR_TEST_VERBOSE("failed to validate -object '%s' against QAPI schema: %s", - args[i + 1], virBufferCurrentContent(&debug)); - return -1; - } - - i++; - } - } + if (testCompareXMLToArgvValidateSchemaCommand(args, schema) < 0) + return -1; return 0; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
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> --- tests/qemuxml2argvtest.c | 120 +++++++++++++++++++++------------------ 1 file changed, 66 insertions(+), 54 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

On a Thursday in 2021, Peter Krempa wrote:
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> --- tests/qemuxml2argvtest.c | 120 +++++++++++++++++++++------------------ 1 file changed, 66 insertions(+), 54 deletions(-)
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 7c6e3d3dd7..b5fab1178c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c
[..]
+ + if (!(jsonargs = virJSONValueFromString(curargs))) + return -1; + + if (testQEMUSchemaValidateCommand(command->schema, jsonargs, + schema, false, false, &debug) < 0) { + VIR_TEST_VERBOSE("failed to validate '%s %s' against QAPI schema: %s", + command->name, curargs, virBufferCurrentContent(&debug)); + return -1; + } + + /* don't check the argument twice */
// this is bridge
+ arg++; + } + } + + return 0;
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

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> --- src/util/vircommand.c | 4 +--- src/util/vircommand.h | 2 +- tests/qemuxml2argvtest.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 8e372c3152..fead373729 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -2164,8 +2164,7 @@ virCommandToString(virCommand *cmd, int virCommandGetArgList(virCommand *cmd, - char ***args, - size_t *nargs) + char ***args) { size_t i; @@ -2175,7 +2174,6 @@ virCommandGetArgList(virCommand *cmd, } *args = g_new0(char *, cmd->nargs); - *nargs = cmd->nargs - 1; for (i = 1; i < cmd->nargs; i++) (*args)[i - 1] = g_strdup(cmd->args[i]); diff --git a/src/util/vircommand.h b/src/util/vircommand.h index fb6c3b5d12..600806a987 100644 --- a/src/util/vircommand.h +++ b/src/util/vircommand.h @@ -178,7 +178,7 @@ int virCommandToStringBuf(virCommand *cmd, bool linebreaks, bool stripCommandPath); -int virCommandGetArgList(virCommand *cmd, char ***args, size_t *nargs); +int virCommandGetArgList(virCommand *cmd, char ***args); int virCommandExec(virCommand *cmd, gid_t *groups, int ngroups) G_GNUC_WARN_UNUSED_RESULT; diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index b5fab1178c..330804f446 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -560,7 +560,6 @@ testCompareXMLToArgvValidateSchema(virQEMUDriver *drv, g_auto(GStrv) args = NULL; g_autoptr(virDomainObj) vm = NULL; qemuDomainObjPrivate *priv = NULL; - size_t nargs = 0; GHashTable *schema = NULL; g_autoptr(virCommand) cmd = NULL; unsigned int parseFlags = info->parseFlags; @@ -602,7 +601,7 @@ testCompareXMLToArgvValidateSchema(virQEMUDriver *drv, if (!(cmd = testCompareXMLToArgvCreateArgs(drv, vm, migrateURI, info, flags))) return -1; - if (virCommandGetArgList(cmd, &args, &nargs) < 0) + if (virCommandGetArgList(cmd, &args) < 0) return -1; if (testCompareXMLToArgvValidateSchemaCommand(args, schema) < 0) -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
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> --- src/util/vircommand.c | 4 +--- src/util/vircommand.h | 2 +- tests/qemuxml2argvtest.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The flag will be used to switch use of JSON arguments for -chardev once qemu will support it. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_capabilities.c | 1 + src/qemu/qemu_capabilities.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b0542ff19c..02fdeea595 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -645,6 +645,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "memory-backend-file.reserve", /* QEMU_CAPS_MEMORY_BACKEND_RESERVE */ "piix4.acpi-root-pci-hotplug", /* QEMU_CAPS_PIIX4_ACPI_ROOT_PCI_HOTPLUG */ "netdev.json", /* QEMU_CAPS_NETDEV_JSON */ + "chardev.json", /* QEMU_CAPS_CHARDEV_JSON */ ); diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 2945054079..37ce0a1d54 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -625,6 +625,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_MEMORY_BACKEND_RESERVE, /* -object memory-backend-*.reserve= */ QEMU_CAPS_PIIX4_ACPI_ROOT_PCI_HOTPLUG, /* -M pc PIIX4_PM.acpi-root-pci-hotplug */ QEMU_CAPS_NETDEV_JSON, /* -netdev accepts JSON */ + QEMU_CAPS_CHARDEV_JSON, /* -chardev accepts JSON */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The flag will be used to switch use of JSON arguments for -chardev once qemu will support it.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_capabilities.c | 1 + src/qemu/qemu_capabilities.h | 1 + 2 files changed, 2 insertions(+)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The flag will be used to switch use of JSON arguments for -device once qemu will support it. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_capabilities.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 02fdeea595..4bed967782 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -646,6 +646,9 @@ VIR_ENUM_IMPL(virQEMUCaps, "piix4.acpi-root-pci-hotplug", /* QEMU_CAPS_PIIX4_ACPI_ROOT_PCI_HOTPLUG */ "netdev.json", /* QEMU_CAPS_NETDEV_JSON */ "chardev.json", /* QEMU_CAPS_CHARDEV_JSON */ + + /* 415 */ + "device.json", /* QEMU_CAPS_DEVICE_JSON */ ); diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 37ce0a1d54..16a36da63d 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -627,6 +627,9 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_NETDEV_JSON, /* -netdev accepts JSON */ QEMU_CAPS_CHARDEV_JSON, /* -chardev accepts JSON */ + /* 415 */ + QEMU_CAPS_DEVICE_JSON, /* -device accepts JSON */ + QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The flag will be used to switch use of JSON arguments for -device once qemu will support it.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_capabilities.h | 3 +++ 2 files changed, 6 insertions(+)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/qemuxml2argvdata/watchdog-device.args | 34 ----------------- .../watchdog-device.x86_64-latest.args | 38 +++++++++++++++++++ tests/qemuxml2argvdata/watchdog-dump.args | 34 ----------------- .../watchdog-dump.x86_64-latest.args | 38 +++++++++++++++++++ .../qemuxml2argvdata/watchdog-injectnmi.args | 34 ----------------- .../watchdog-injectnmi.x86_64-latest.args | 38 +++++++++++++++++++ tests/qemuxml2argvdata/watchdog.args | 33 ---------------- .../watchdog.x86_64-latest.args | 37 ++++++++++++++++++ tests/qemuxml2argvtest.c | 8 ++-- 9 files changed, 155 insertions(+), 139 deletions(-) delete mode 100644 tests/qemuxml2argvdata/watchdog-device.args create mode 100644 tests/qemuxml2argvdata/watchdog-device.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/watchdog-dump.args create mode 100644 tests/qemuxml2argvdata/watchdog-dump.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/watchdog-injectnmi.args create mode 100644 tests/qemuxml2argvdata/watchdog-injectnmi.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/watchdog.args create mode 100644 tests/qemuxml2argvdata/watchdog.x86_64-latest.args diff --git a/tests/qemuxml2argvdata/watchdog-device.args b/tests/qemuxml2argvdata/watchdog-device.args deleted file mode 100644 index 0ba147c1f9..0000000000 --- a/tests/qemuxml2argvdata/watchdog-device.args +++ /dev/null @@ -1,34 +0,0 @@ -LC_ALL=C \ -PATH=/bin \ -HOME=/tmp/lib/domain--1-QEMUGuest1 \ -USER=test \ -LOGNAME=test \ -XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ -XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ -XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -QEMU_AUDIO_DRV=none \ -/usr/bin/qemu-system-i386 \ --name guest=QEMUGuest1,debug-threads=on \ --S \ --object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ --machine pc,accel=tcg,usb=off,dump-guest-core=off \ --m 214 \ --realtime mlock=off \ --smp 1,sockets=1,cores=1,threads=1 \ --uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --display none \ --no-user-config \ --nodefaults \ --chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server=on,wait=off \ --mon chardev=charmonitor,id=monitor,mode=control \ --rtc base=utc \ --no-shutdown \ --no-acpi \ --boot strict=on \ --usb \ --drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ --device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ --device ib700,id=watchdog0 \ --watchdog-action poweroff \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ --msg timestamp=on diff --git a/tests/qemuxml2argvdata/watchdog-device.x86_64-latest.args b/tests/qemuxml2argvdata/watchdog-device.x86_64-latest.args new file mode 100644 index 0000000000..0da2413005 --- /dev/null +++ b/tests/qemuxml2argvdata/watchdog-device.x86_64-latest.args @@ -0,0 +1,38 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-i386 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \ +-cpu qemu64 \ +-m 214 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ +-device ide-hd,bus=ide.0,unit=0,drive=libvirt-1-format,id=ide0-0-0,bootindex=1 \ +-audiodev id=audio1,driver=none \ +-device ib700,id=watchdog0 \ +-watchdog-action poweroff \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/watchdog-dump.args b/tests/qemuxml2argvdata/watchdog-dump.args deleted file mode 100644 index b0f1d69473..0000000000 --- a/tests/qemuxml2argvdata/watchdog-dump.args +++ /dev/null @@ -1,34 +0,0 @@ -LC_ALL=C \ -PATH=/bin \ -HOME=/tmp/lib/domain--1-QEMUGuest1 \ -USER=test \ -LOGNAME=test \ -XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ -XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ -XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -QEMU_AUDIO_DRV=none \ -/usr/bin/qemu-system-i386 \ --name guest=QEMUGuest1,debug-threads=on \ --S \ --object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ --machine pc,accel=tcg,usb=off,dump-guest-core=off \ --m 214 \ --realtime mlock=off \ --smp 1,sockets=1,cores=1,threads=1 \ --uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --display none \ --no-user-config \ --nodefaults \ --chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server=on,wait=off \ --mon chardev=charmonitor,id=monitor,mode=control \ --rtc base=utc \ --no-shutdown \ --no-acpi \ --boot strict=on \ --usb \ --drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ --device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ --device ib700,id=watchdog0 \ --watchdog-action pause \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ --msg timestamp=on diff --git a/tests/qemuxml2argvdata/watchdog-dump.x86_64-latest.args b/tests/qemuxml2argvdata/watchdog-dump.x86_64-latest.args new file mode 100644 index 0000000000..439998dcd8 --- /dev/null +++ b/tests/qemuxml2argvdata/watchdog-dump.x86_64-latest.args @@ -0,0 +1,38 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-i386 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \ +-cpu qemu64 \ +-m 214 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ +-device ide-hd,bus=ide.0,unit=0,drive=libvirt-1-format,id=ide0-0-0,bootindex=1 \ +-audiodev id=audio1,driver=none \ +-device ib700,id=watchdog0 \ +-watchdog-action pause \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/watchdog-injectnmi.args b/tests/qemuxml2argvdata/watchdog-injectnmi.args deleted file mode 100644 index 1dac7dc738..0000000000 --- a/tests/qemuxml2argvdata/watchdog-injectnmi.args +++ /dev/null @@ -1,34 +0,0 @@ -LC_ALL=C \ -PATH=/bin \ -HOME=/tmp/lib/domain--1-QEMUGuest1 \ -USER=test \ -LOGNAME=test \ -XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ -XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ -XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -QEMU_AUDIO_DRV=none \ -/usr/bin/qemu-system-i386 \ --name guest=QEMUGuest1,debug-threads=on \ --S \ --object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ --machine pc,accel=tcg,usb=off,dump-guest-core=off \ --m 214 \ --realtime mlock=off \ --smp 1,sockets=1,cores=1,threads=1 \ --uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --display none \ --no-user-config \ --nodefaults \ --chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server=on,wait=off \ --mon chardev=charmonitor,id=monitor,mode=control \ --rtc base=utc \ --no-shutdown \ --no-acpi \ --boot strict=on \ --usb \ --drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ --device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ --device ib700,id=watchdog0 \ --watchdog-action inject-nmi \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ --msg timestamp=on diff --git a/tests/qemuxml2argvdata/watchdog-injectnmi.x86_64-latest.args b/tests/qemuxml2argvdata/watchdog-injectnmi.x86_64-latest.args new file mode 100644 index 0000000000..371e4c0162 --- /dev/null +++ b/tests/qemuxml2argvdata/watchdog-injectnmi.x86_64-latest.args @@ -0,0 +1,38 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-i386 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \ +-cpu qemu64 \ +-m 214 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ +-device ide-hd,bus=ide.0,unit=0,drive=libvirt-1-format,id=ide0-0-0,bootindex=1 \ +-audiodev id=audio1,driver=none \ +-device ib700,id=watchdog0 \ +-watchdog-action inject-nmi \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/watchdog.args b/tests/qemuxml2argvdata/watchdog.args deleted file mode 100644 index 3e17fcb42c..0000000000 --- a/tests/qemuxml2argvdata/watchdog.args +++ /dev/null @@ -1,33 +0,0 @@ -LC_ALL=C \ -PATH=/bin \ -HOME=/tmp/lib/domain--1-QEMUGuest1 \ -USER=test \ -LOGNAME=test \ -XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ -XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ -XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -QEMU_AUDIO_DRV=none \ -/usr/bin/qemu-system-i386 \ --name guest=QEMUGuest1,debug-threads=on \ --S \ --object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ --machine pc,accel=tcg,usb=off,dump-guest-core=off \ --m 214 \ --realtime mlock=off \ --smp 1,sockets=1,cores=1,threads=1 \ --uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --display none \ --no-user-config \ --nodefaults \ --chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server=on,wait=off \ --mon chardev=charmonitor,id=monitor,mode=control \ --rtc base=utc \ --no-shutdown \ --no-acpi \ --boot strict=on \ --usb \ --drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ --device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ --device ib700,id=watchdog0 \ --watchdog-action poweroff \ --msg timestamp=on diff --git a/tests/qemuxml2argvdata/watchdog.x86_64-latest.args b/tests/qemuxml2argvdata/watchdog.x86_64-latest.args new file mode 100644 index 0000000000..76a845c60f --- /dev/null +++ b/tests/qemuxml2argvdata/watchdog.x86_64-latest.args @@ -0,0 +1,37 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-i386 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \ +-cpu qemu64 \ +-m 214 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ +-device ide-hd,bus=ide.0,unit=0,drive=libvirt-1-format,id=ide0-0-0,bootindex=1 \ +-audiodev id=audio1,driver=none \ +-device ib700,id=watchdog0 \ +-watchdog-action poweroff \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 330804f446..433677e69e 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1827,10 +1827,10 @@ mymain(void) DO_TEST_PARSE_ERROR_NOCAPS("smbios-uuid-match"); DO_TEST_NOCAPS("smbios-type-fwcfg"); - DO_TEST_NOCAPS("watchdog"); - DO_TEST_NOCAPS("watchdog-device"); - DO_TEST_NOCAPS("watchdog-dump"); - DO_TEST_NOCAPS("watchdog-injectnmi"); + DO_TEST_CAPS_LATEST("watchdog"); + DO_TEST_CAPS_LATEST("watchdog-device"); + DO_TEST_CAPS_LATEST("watchdog-dump"); + DO_TEST_CAPS_LATEST("watchdog-injectnmi"); DO_TEST_CAPS_ARCH_LATEST("watchdog-diag288", "s390x"); DO_TEST_NOCAPS("balloon-device"); DO_TEST("balloon-device-deflate", -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/qemuxml2argvdata/watchdog-device.args | 34 ----------------- .../watchdog-device.x86_64-latest.args | 38 +++++++++++++++++++ tests/qemuxml2argvdata/watchdog-dump.args | 34 ----------------- .../watchdog-dump.x86_64-latest.args | 38 +++++++++++++++++++ .../qemuxml2argvdata/watchdog-injectnmi.args | 34 ----------------- .../watchdog-injectnmi.x86_64-latest.args | 38 +++++++++++++++++++ tests/qemuxml2argvdata/watchdog.args | 33 ---------------- .../watchdog.x86_64-latest.args | 37 ++++++++++++++++++ tests/qemuxml2argvtest.c | 8 ++-- 9 files changed, 155 insertions(+), 139 deletions(-) delete mode 100644 tests/qemuxml2argvdata/watchdog-device.args create mode 100644 tests/qemuxml2argvdata/watchdog-device.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/watchdog-dump.args create mode 100644 tests/qemuxml2argvdata/watchdog-dump.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/watchdog-injectnmi.args create mode 100644 tests/qemuxml2argvdata/watchdog-injectnmi.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/watchdog.args create mode 100644 tests/qemuxml2argvdata/watchdog.x86_64-latest.args
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Convert one of the tests to a different device. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/qemuxml2argvdata/watchdog-device.x86_64-latest.args | 2 +- tests/qemuxml2argvdata/watchdog-device.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qemuxml2argvdata/watchdog-device.x86_64-latest.args b/tests/qemuxml2argvdata/watchdog-device.x86_64-latest.args index 0da2413005..78ac8227c3 100644 --- a/tests/qemuxml2argvdata/watchdog-device.x86_64-latest.args +++ b/tests/qemuxml2argvdata/watchdog-device.x86_64-latest.args @@ -31,7 +31,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ -device ide-hd,bus=ide.0,unit=0,drive=libvirt-1-format,id=ide0-0-0,bootindex=1 \ -audiodev id=audio1,driver=none \ --device ib700,id=watchdog0 \ +-device i6300esb,id=watchdog0,bus=pci.0,addr=0x3 \ -watchdog-action poweroff \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/watchdog-device.xml b/tests/qemuxml2argvdata/watchdog-device.xml index a65caf5be4..490f11a5b5 100644 --- a/tests/qemuxml2argvdata/watchdog-device.xml +++ b/tests/qemuxml2argvdata/watchdog-device.xml @@ -18,7 +18,7 @@ <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='hda' bus='ide'/> </disk> - <watchdog model='ib700' action='poweroff'/> + <watchdog model='i6300esb' action='poweroff'/> <memballoon model='virtio'/> </devices> </domain> -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Convert one of the tests to a different device.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/qemuxml2argvdata/watchdog-device.x86_64-latest.args | 2 +- tests/qemuxml2argvdata/watchdog-device.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- ...e.args => panic-double.x86_64-latest.args} | 16 ++++---- tests/qemuxml2argvdata/panic-no-address.args | 33 ----------------- .../panic-no-address.x86_64-latest.args | 37 +++++++++++++++++++ tests/qemuxml2argvdata/panic.args | 33 ----------------- .../qemuxml2argvdata/panic.x86_64-latest.args | 37 +++++++++++++++++++ tests/qemuxml2argvtest.c | 10 ++--- 6 files changed, 86 insertions(+), 80 deletions(-) rename tests/qemuxml2argvdata/{panic-double.args => panic-double.x86_64-latest.args} (52%) delete mode 100644 tests/qemuxml2argvdata/panic-no-address.args create mode 100644 tests/qemuxml2argvdata/panic-no-address.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/panic.args create mode 100644 tests/qemuxml2argvdata/panic.x86_64-latest.args diff --git a/tests/qemuxml2argvdata/panic-double.args b/tests/qemuxml2argvdata/panic-double.x86_64-latest.args similarity index 52% rename from tests/qemuxml2argvdata/panic-double.args rename to tests/qemuxml2argvdata/panic-double.x86_64-latest.args index 9457d267d7..960339c1b2 100644 --- a/tests/qemuxml2argvdata/panic-double.args +++ b/tests/qemuxml2argvdata/panic-double.x86_64-latest.args @@ -6,25 +6,27 @@ LOGNAME=test \ XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -QEMU_AUDIO_DRV=none \ /usr/bin/qemu-system-i386 \ -name guest=QEMUGuest1,debug-threads=on \ -S \ --object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ --machine pc,accel=tcg,usb=off,dump-guest-core=off \ --cpu qemu32,hv-crash \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \ +-cpu qemu64,hv-crash \ -m 214 \ --realtime mlock=off \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \ +-overcommit mem-lock=off \ -smp 6,sockets=6,cores=1,threads=1 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ -display none \ -no-user-config \ -nodefaults \ --chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server=on,wait=off \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ -mon chardev=charmonitor,id=monitor,mode=control \ -rtc base=utc \ -no-shutdown \ -boot strict=on \ --usb \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-audiodev id=audio1,driver=none \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -device pvpanic,ioport=1285 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/panic-no-address.args b/tests/qemuxml2argvdata/panic-no-address.args deleted file mode 100644 index ed8df3d22a..0000000000 --- a/tests/qemuxml2argvdata/panic-no-address.args +++ /dev/null @@ -1,33 +0,0 @@ -LC_ALL=C \ -PATH=/bin \ -HOME=/tmp/lib/domain--1-QEMUGuest1 \ -USER=test \ -LOGNAME=test \ -XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ -XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ -XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -QEMU_AUDIO_DRV=none \ -/usr/bin/qemu-system-i386 \ --name guest=QEMUGuest1,debug-threads=on \ --S \ --object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ --machine pc,accel=tcg,usb=off,dump-guest-core=off \ --m 214 \ --realtime mlock=off \ --smp 1,sockets=1,cores=1,threads=1 \ --uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --display none \ --no-user-config \ --nodefaults \ --chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server=on,wait=off \ --mon chardev=charmonitor,id=monitor,mode=control \ --rtc base=utc \ --no-shutdown \ --no-acpi \ --boot strict=on \ --usb \ --drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ --device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ --device pvpanic \ --msg timestamp=on diff --git a/tests/qemuxml2argvdata/panic-no-address.x86_64-latest.args b/tests/qemuxml2argvdata/panic-no-address.x86_64-latest.args new file mode 100644 index 0000000000..7949091e87 --- /dev/null +++ b/tests/qemuxml2argvdata/panic-no-address.x86_64-latest.args @@ -0,0 +1,37 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-i386 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \ +-cpu qemu64 \ +-m 214 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ +-device ide-hd,bus=ide.0,unit=0,drive=libvirt-1-format,id=ide0-0-0,bootindex=1 \ +-audiodev id=audio1,driver=none \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ +-device pvpanic \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/panic.args b/tests/qemuxml2argvdata/panic.args deleted file mode 100644 index 83b7d30820..0000000000 --- a/tests/qemuxml2argvdata/panic.args +++ /dev/null @@ -1,33 +0,0 @@ -LC_ALL=C \ -PATH=/bin \ -HOME=/tmp/lib/domain--1-QEMUGuest1 \ -USER=test \ -LOGNAME=test \ -XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ -XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ -XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -QEMU_AUDIO_DRV=none \ -/usr/bin/qemu-system-i386 \ --name guest=QEMUGuest1,debug-threads=on \ --S \ --object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ --machine pc,accel=tcg,usb=off,dump-guest-core=off \ --m 214 \ --realtime mlock=off \ --smp 1,sockets=1,cores=1,threads=1 \ --uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --display none \ --no-user-config \ --nodefaults \ --chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server=on,wait=off \ --mon chardev=charmonitor,id=monitor,mode=control \ --rtc base=utc \ --no-shutdown \ --no-acpi \ --boot strict=on \ --usb \ --drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ --device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ --device pvpanic,ioport=1285 \ --msg timestamp=on diff --git a/tests/qemuxml2argvdata/panic.x86_64-latest.args b/tests/qemuxml2argvdata/panic.x86_64-latest.args new file mode 100644 index 0000000000..35e387696e --- /dev/null +++ b/tests/qemuxml2argvdata/panic.x86_64-latest.args @@ -0,0 +1,37 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-i386 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \ +-cpu qemu64 \ +-m 214 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ +-device ide-hd,bus=ide.0,unit=0,drive=libvirt-1-format,id=ide0-0-0,bootindex=1 \ +-audiodev id=audio1,driver=none \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ +-device pvpanic,ioport=1285 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 433677e69e..3b3596068e 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3013,13 +3013,9 @@ mymain(void) DO_TEST("kvm-pit-delay", QEMU_CAPS_KVM_PIT_TICK_POLICY); DO_TEST("kvm-pit-discard", QEMU_CAPS_KVM_PIT_TICK_POLICY); - DO_TEST("panic", - QEMU_CAPS_DEVICE_PANIC); - DO_TEST("panic-double", - QEMU_CAPS_DEVICE_PANIC); - - DO_TEST("panic-no-address", - QEMU_CAPS_DEVICE_PANIC); + DO_TEST_CAPS_LATEST("panic"); + DO_TEST_CAPS_LATEST("panic-double"); + DO_TEST_CAPS_LATEST("panic-no-address"); DO_TEST_CAPS_ARCH_VER_FULL("fips-enabled", "x86_64", "5.1.0", ARG_FLAGS, FLAG_FIPS_HOST); DO_TEST_CAPS_ARCH_LATEST_FULL("fips-enabled", "x86_64", ARG_FLAGS, FLAG_FIPS_HOST); -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- ...e.args => panic-double.x86_64-latest.args} | 16 ++++---- tests/qemuxml2argvdata/panic-no-address.args | 33 ----------------- .../panic-no-address.x86_64-latest.args | 37 +++++++++++++++++++ tests/qemuxml2argvdata/panic.args | 33 ----------------- .../qemuxml2argvdata/panic.x86_64-latest.args | 37 +++++++++++++++++++ tests/qemuxml2argvtest.c | 10 ++--- 6 files changed, 86 insertions(+), 80 deletions(-) rename tests/qemuxml2argvdata/{panic-double.args => panic-double.x86_64-latest.args} (52%) delete mode 100644 tests/qemuxml2argvdata/panic-no-address.args create mode 100644 tests/qemuxml2argvdata/panic-no-address.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/panic.args create mode 100644 tests/qemuxml2argvdata/panic.x86_64-latest.args
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

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> --- tests/qemuxml2argvdata/panic-isa.xml | 33 ---------------------------- tests/qemuxml2xmltest.c | 1 - 2 files changed, 34 deletions(-) delete mode 100644 tests/qemuxml2argvdata/panic-isa.xml diff --git a/tests/qemuxml2argvdata/panic-isa.xml b/tests/qemuxml2argvdata/panic-isa.xml deleted file mode 100644 index 34e8bd7a01..0000000000 --- a/tests/qemuxml2argvdata/panic-isa.xml +++ /dev/null @@ -1,33 +0,0 @@ -<domain type='qemu'> - <name>QEMUGuest1</name> - <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> - <memory unit='KiB'>219136</memory> - <currentMemory unit='KiB'>219136</currentMemory> - <vcpu placement='static'>1</vcpu> - <os> - <type arch='i686' machine='pc'>hvm</type> - <boot dev='hd'/> - </os> - <clock offset='utc'/> - <on_poweroff>destroy</on_poweroff> - <on_reboot>restart</on_reboot> - <on_crash>destroy</on_crash> - <devices> - <emulator>/usr/bin/qemu-system-i386</emulator> - <disk type='block' device='disk'> - <source dev='/dev/HostVG/QEMUGuest1'/> - <target dev='hda' bus='ide'/> - <address type='drive' controller='0' bus='0' target='0' unit='0'/> - </disk> - <controller type='usb' index='0'/> - <controller type='fdc' index='0'/> - <controller type='ide' index='0'/> - <controller type='pci' index='0' model='pci-root'/> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> - <memballoon model='virtio'/> - <panic model='isa'> - <address type='isa' iobase='0x505'/> - </panic> - </devices> -</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 69363ef85c..8bc4b9ff19 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1069,7 +1069,6 @@ mymain(void) QEMU_CAPS_Q35_PCI_HOLE64_SIZE); DO_TEST("panic", QEMU_CAPS_DEVICE_PANIC); - DO_TEST("panic-isa", QEMU_CAPS_DEVICE_PANIC); DO_TEST("panic-pseries", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE); DO_TEST("panic-double", QEMU_CAPS_DEVICE_PANIC); -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
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> --- tests/qemuxml2argvdata/panic-isa.xml | 33 ---------------------------- tests/qemuxml2xmltest.c | 1 - 2 files changed, 34 deletions(-) delete mode 100644 tests/qemuxml2argvdata/panic-isa.xml
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Report the error from 'qemuValidateDomainWatchdogDef' rather than 'qemuBuildWatchdogDevStr'. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 10 +++------- src/qemu/qemu_validate.c | 4 +++- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 19b1119e4a..bd34c6b48e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3688,14 +3688,10 @@ qemuBuildWatchdogDevStr(const virDomainDef *def, { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - const char *model = virDomainWatchdogModelTypeToString(dev->model); - if (!model) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing watchdog model")); - return NULL; - } + virBufferAsprintf(&buf, "%s,id=%s", + virDomainWatchdogModelTypeToString(dev->model), + dev->info.alias); - virBufferAsprintf(&buf, "%s,id=%s", model, dev->info.alias); if (qemuBuildDeviceAddressStr(&buf, def, &dev->info) < 0) return NULL; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index c84508cb64..8a779f24c7 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2102,7 +2102,9 @@ qemuValidateDomainWatchdogDef(const virDomainWatchdogDef *dev, break; case VIR_DOMAIN_WATCHDOG_MODEL_LAST: - break; + default: + virReportEnumRangeError(virDomainWatchdogModel, dev->model); + return -1; } return 0; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Report the error from 'qemuValidateDomainWatchdogDef' rather than 'qemuBuildWatchdogDevStr'.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 10 +++------- src/qemu/qemu_validate.c | 4 +++- 2 files changed, 6 insertions(+), 8 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Use g_autoptr for 'vcpuprops' and remove the 'cleanup' label and 'ret' varlaible which is no longer needed. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_hotplug.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 22239b2689..5d4c8bf839 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6282,12 +6282,11 @@ qemuDomainHotplugAddVcpu(virQEMUDriver *driver, virDomainObj *vm, unsigned int vcpu) { - virJSONValue *vcpuprops = NULL; + g_autoptr(virJSONValue) vcpuprops = NULL; virDomainVcpuDef *vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu); qemuDomainVcpuPrivate *vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpuinfo); unsigned int nvcpus = vcpupriv->vcpus; bool newhotplug = qemuDomainSupportsNewVcpuHotplug(vm); - int ret = -1; int rc; int oldvcpus = virDomainDefGetVcpus(vm->def); size_t i; @@ -6296,7 +6295,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriver *driver, vcpupriv->alias = g_strdup_printf("vcpu%u", vcpu); if (!(vcpuprops = qemuBuildHotpluggableCPUProps(vcpuinfo))) - goto cleanup; + return -1; } qemuDomainObjEnterMonitor(driver, vm); @@ -6309,19 +6308,19 @@ qemuDomainHotplugAddVcpu(virQEMUDriver *driver, } if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + return -1; virDomainAuditVcpu(vm, oldvcpus, oldvcpus + nvcpus, "update", rc == 0); if (rc < 0) - goto cleanup; + return -1; /* start outputting of the new XML element to allow keeping unpluggability */ if (newhotplug) vm->def->individualvcpus = true; if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE, false) < 0) - goto cleanup; + return -1; /* validation requires us to set the expected state prior to calling it */ for (i = vcpu; i < vcpu + nvcpus; i++) { @@ -6332,22 +6331,18 @@ qemuDomainHotplugAddVcpu(virQEMUDriver *driver, if (vcpupriv->tid > 0 && qemuProcessSetupVcpu(vm, i) < 0) - goto cleanup; + return -1; } if (qemuDomainValidateVcpuInfo(vm) < 0) - goto cleanup; + return -1; qemuDomainVcpuPersistOrder(vm->def); if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) - goto cleanup; - - ret = 0; + return -1; - cleanup: - virJSONValueFree(vcpuprops); - return ret; + return 0; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Use g_autoptr for 'vcpuprops' and remove the 'cleanup' label and 'ret' varlaible which is no longer needed.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_hotplug.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

We commonly use 'props' for the JSON object describing something. Rename the monitor device addition code. Additionally the common approach is to clear the pointer if it was consumed so the arguments are adjusted to do so. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_hotplug.c | 3 +-- src/qemu/qemu_monitor.c | 13 +++++++------ src/qemu/qemu_monitor.h | 4 ++-- src/qemu/qemu_monitor_json.c | 13 ++++++------- src/qemu/qemu_monitor_json.h | 4 ++-- src/qemu/qemu_process.c | 3 +-- 6 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 5d4c8bf839..1c310249e2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6301,8 +6301,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); if (newhotplug) { - rc = qemuMonitorAddDeviceArgs(qemuDomainGetMonitor(vm), vcpuprops); - vcpuprops = NULL; + rc = qemuMonitorAddDeviceProps(qemuDomainGetMonitor(vm), &vcpuprops); } else { rc = qemuMonitorSetCPU(qemuDomainGetMonitor(vm), vcpu, true); } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 068b7ff997..fe65d46ae9 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2893,20 +2893,21 @@ qemuMonitorAddDevice(qemuMonitor *mon, /** - * qemuMonitorAddDeviceArgs: + * qemuMonitorAddDeviceProps: * @mon: monitor object - * @args: arguments for device add, consumed on success or failure + * @props: JSON object describing the device to add, the object is consumed + * and cleared. * - * Adds a device described by @args. Requires JSON monitor. + * Adds a device described by @props. * Returns 0 on success -1 on error. */ int -qemuMonitorAddDeviceArgs(qemuMonitor *mon, - virJSONValue *args) +qemuMonitorAddDeviceProps(qemuMonitor *mon, + virJSONValue **props) { QEMU_CHECK_MONITOR(mon); - return qemuMonitorJSONAddDeviceArgs(mon, args); + return qemuMonitorJSONAddDeviceProps(mon, props); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 648fe293ed..5edf6a161b 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1028,8 +1028,8 @@ int qemuMonitorAttachPCIDiskController(qemuMonitor *mon, const char *bus, virPCIDeviceAddress *guestAddr); -int qemuMonitorAddDeviceArgs(qemuMonitor *mon, - virJSONValue *args); +int qemuMonitorAddDeviceProps(qemuMonitor *mon, + virJSONValue **props); int qemuMonitorAddDevice(qemuMonitor *mon, const char *devicestr); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 1b98baa4c7..e5c71f58c2 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4554,8 +4554,8 @@ int qemuMonitorJSONDelDevice(qemuMonitor *mon, int -qemuMonitorJSONAddDeviceArgs(qemuMonitor *mon, - virJSONValue *args) +qemuMonitorJSONAddDeviceProps(qemuMonitor *mon, + virJSONValue **props) { int ret = -1; virJSONValue *cmd = NULL; @@ -4564,7 +4564,7 @@ qemuMonitorJSONAddDeviceArgs(qemuMonitor *mon, if (!(cmd = qemuMonitorJSONMakeCommand("device_add", NULL))) goto cleanup; - if (virJSONValueObjectAppend(cmd, "arguments", &args) < 0) + if (virJSONValueObjectAppend(cmd, "arguments", props) < 0) goto cleanup; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) @@ -4575,7 +4575,6 @@ qemuMonitorJSONAddDeviceArgs(qemuMonitor *mon, ret = 0; cleanup: - virJSONValueFree(args); virJSONValueFree(cmd); virJSONValueFree(reply); return ret; @@ -4586,12 +4585,12 @@ int qemuMonitorJSONAddDevice(qemuMonitor *mon, const char *devicestr) { - virJSONValue *args; + g_autoptr(virJSONValue) props = NULL; - if (!(args = qemuMonitorJSONKeywordStringToJSON(devicestr, "driver"))) + if (!(props = qemuMonitorJSONKeywordStringToJSON(devicestr, "driver"))) return -1; - return qemuMonitorJSONAddDeviceArgs(mon, args); + return qemuMonitorJSONAddDeviceProps(mon, &props); } diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 0289f8c3bf..8dc2350642 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -235,8 +235,8 @@ int qemuMonitorJSONAttachPCIDiskController(qemuMonitor *mon, const char *bus, virPCIDeviceAddress *guestAddr); -int qemuMonitorJSONAddDeviceArgs(qemuMonitor *mon, - virJSONValue *args); +int qemuMonitorJSONAddDeviceProps(qemuMonitor *mon, + virJSONValue **props); int qemuMonitorJSONAddDevice(qemuMonitor *mon, const char *devicestr); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9faaeeadba..09a2ff8ef2 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6085,8 +6085,7 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) goto cleanup; - rc = qemuMonitorAddDeviceArgs(qemuDomainGetMonitor(vm), vcpuprops); - vcpuprops = NULL; + rc = qemuMonitorAddDeviceProps(qemuDomainGetMonitor(vm), &vcpuprops); if (qemuDomainObjExitMonitor(driver, vm) < 0) goto cleanup; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
We commonly use 'props' for the JSON object describing something. Rename the monitor device addition code.
Additionally the common approach is to clear the pointer if it was consumed so the arguments are adjusted to do so.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_hotplug.c | 3 +-- src/qemu/qemu_monitor.c | 13 +++++++------ src/qemu/qemu_monitor.h | 4 ++-- src/qemu/qemu_monitor_json.c | 13 ++++++------- src/qemu/qemu_monitor_json.h | 4 ++-- src/qemu/qemu_process.c | 3 +-- 6 files changed, 19 insertions(+), 21 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Use automatic memory freeing and remove 'ret' variable and 'cleanup' label. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_monitor_json.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e5c71f58c2..f831cfeeb5 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4557,27 +4557,22 @@ int qemuMonitorJSONAddDeviceProps(qemuMonitor *mon, virJSONValue **props) { - int ret = -1; - virJSONValue *cmd = NULL; - virJSONValue *reply = NULL; + g_autoptr(virJSONValue) cmd = NULL; + g_autoptr(virJSONValue) reply = NULL; if (!(cmd = qemuMonitorJSONMakeCommand("device_add", NULL))) - goto cleanup; + return -1; if (virJSONValueObjectAppend(cmd, "arguments", props) < 0) - goto cleanup; + return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return -1; if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; - ret = 0; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return 0; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Use automatic memory freeing and remove 'ret' variable and 'cleanup' label.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_monitor_json.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

With automatic memory freeing we can simplify the function to avoid two almost-identical calls to virQEMUBuildCommandLineJSONRecurse. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virqemu.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/util/virqemu.c b/src/util/virqemu.c index e31451dff4..3e9311e3c7 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -158,23 +158,17 @@ virQEMUBuildCommandLineJSONIterate(const char *key, void *opaque) { struct virQEMUCommandLineJSONIteratorData *data = opaque; + g_autofree char *tmpkey = NULL; if (STREQ_NULLABLE(key, data->skipKey)) return 0; - if (data->prefix) { - g_autofree char *tmpkey = NULL; + if (data->prefix) + key = tmpkey = g_strdup_printf("%s.%s", data->prefix, key); - tmpkey = g_strdup_printf("%s.%s", data->prefix, key); - - return virQEMUBuildCommandLineJSONRecurse(tmpkey, value, data->buf, - data->skipKey, - data->arrayFunc, false); - } else { - return virQEMUBuildCommandLineJSONRecurse(key, value, data->buf, - data->skipKey, - data->arrayFunc, false); - } + return virQEMUBuildCommandLineJSONRecurse(key, value, data->buf, + data->skipKey, + data->arrayFunc, false); } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
With automatic memory freeing we can simplify the function to avoid two almost-identical calls to virQEMUBuildCommandLineJSONRecurse.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virqemu.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

For conversion of '-device' we'll try to avoid usage of arrays if possible, so for now if the array coversion function is not provided the convertor will error out. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virqemu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util/virqemu.c b/src/util/virqemu.c index 3e9311e3c7..aef6006dd7 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -219,7 +219,13 @@ virQEMUBuildCommandLineJSONRecurse(const char *key, return -1; } - if (!arrayFunc || arrayFunc(key, value, buf, skipKey) < 0) { + if (!arrayFunc) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("JSON array -> commandline conversion function not provided")); + return -1; + } + + if (arrayFunc(key, value, buf, skipKey) < 0) { /* fallback, treat the array as a non-bitmap, adding the key * for each member */ for (i = 0; i < virJSONValueArraySize(value); i++) { -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
For conversion of '-device' we'll try to avoid usage of arrays if possible, so for now if the array coversion function is not provided the convertor will error out.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virqemu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Mention the QMP command 'device_add' rather than 'qemuMonitorAddDevice' and remove the weird formatting. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_block.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 393d3f44d7..b6d6d95692 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1817,15 +1817,15 @@ qemuBlockStorageSourceAttachRollback(qemuMonitor *mon, if (data->chardevAdded) { if (qemuMonitorDetachCharDev(mon, data->chardevAlias) < 0) { - VIR_WARN("Unable to remove chardev %s after failed " "qemuMonitorAddDevice", + VIR_WARN("Unable to remove chardev %s after failed 'device_add'", data->chardevAlias); } } if (data->driveAdded) { if (qemuMonitorDriveDel(mon, data->driveAlias) < 0) - VIR_WARN("Unable to remove drive %s (%s) after failed " - "qemuMonitorAddDevice", data->driveAlias, data->driveCmd); + VIR_WARN("Unable to remove drive %s (%s) after failed 'device_add'", + data->driveAlias, data->driveCmd); } if (data->formatAttached) -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Mention the QMP command 'device_add' rather than 'qemuMonitorAddDevice' and remove the weird formatting.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_block.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The PCI address case grew massive over time. Split it out into a new function qemuBuildDeviceAddressPCIStr. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 147 ++++++++++++++++++++++------------------ 1 file changed, 82 insertions(+), 65 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index bd34c6b48e..aeb04207b2 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -321,87 +321,104 @@ qemuVirCommandGetDevSet(virCommand *cmd, int fd) static int -qemuBuildDeviceAddressStr(virBuffer *buf, - const virDomainDef *domainDef, - virDomainDeviceInfo *info) +qemuBuildDeviceAddressPCIStr(virBuffer *buf, + const virDomainDef *domainDef, + virDomainDeviceInfo *info) { g_autofree char *devStr = NULL; const char *contAlias = NULL; bool contIsPHB = false; int contTargetIndex = 0; + size_t i; - switch ((virDomainDeviceAddressType)info->type) { - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: { - size_t i; + if (!(devStr = virPCIDeviceAddressAsString(&info->addr.pci))) + return -1; - if (!(devStr = virPCIDeviceAddressAsString(&info->addr.pci))) - return -1; - for (i = 0; i < domainDef->ncontrollers; i++) { - virDomainControllerDef *cont = domainDef->controllers[i]; + for (i = 0; i < domainDef->ncontrollers; i++) { + virDomainControllerDef *cont = domainDef->controllers[i]; - if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI && - cont->idx == info->addr.pci.bus) { - contAlias = cont->info.alias; - contIsPHB = virDomainControllerIsPSeriesPHB(cont); - contTargetIndex = cont->opts.pciopts.targetIndex; + if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI && + cont->idx == info->addr.pci.bus) { + contAlias = cont->info.alias; + contIsPHB = virDomainControllerIsPSeriesPHB(cont); + contTargetIndex = cont->opts.pciopts.targetIndex; - if (!contAlias) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Device alias was not set for PCI " - "controller with index %u required " - "for device at address %s"), - info->addr.pci.bus, devStr); - return -1; - } + if (!contAlias) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Device alias was not set for PCI " + "controller with index %u required " + "for device at address %s"), + info->addr.pci.bus, devStr); + return -1; + } - if (virDomainDeviceAliasIsUserAlias(contAlias)) { - /* When domain has builtin pci-root controller we don't put it - * onto cmd line. Therefore we can't set its alias. In that - * case, use the default one. */ - if (!qemuDomainIsPSeries(domainDef) && - cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) { - if (virQEMUCapsHasPCIMultiBus(domainDef)) - contAlias = "pci.0"; - else - contAlias = "pci"; - } else if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) { - contAlias = "pcie.0"; - } + if (virDomainDeviceAliasIsUserAlias(contAlias)) { + /* When domain has builtin pci-root controller we don't put it + * onto cmd line. Therefore we can't set its alias. In that + * case, use the default one. */ + if (!qemuDomainIsPSeries(domainDef) && + cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) { + if (virQEMUCapsHasPCIMultiBus(domainDef)) + contAlias = "pci.0"; + else + contAlias = "pci"; + } else if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) { + contAlias = "pcie.0"; } - break; } + break; } - if (!contAlias) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not find PCI " - "controller with index %u required " - "for device at address %s"), - info->addr.pci.bus, devStr); - return -1; - } + } - if (contIsPHB && contTargetIndex > 0) { - /* The PCI bus created by a spapr-pci-host-bridge device with - * alias 'x' will be called 'x.0' rather than 'x'; however, - * this does not apply to the implicit PHB in a pSeries guest, - * which always has the hardcoded name 'pci.0' */ - virBufferAsprintf(buf, ",bus=%s.0", contAlias); - } else { - /* For all other controllers, the bus name matches the alias - * of the corresponding controller */ - virBufferAsprintf(buf, ",bus=%s", contAlias); - } + if (!contAlias) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not find PCI " + "controller with index %u required " + "for device at address %s"), + info->addr.pci.bus, devStr); + return -1; + } - if (info->addr.pci.multi == VIR_TRISTATE_SWITCH_ON) - virBufferAddLit(buf, ",multifunction=on"); - else if (info->addr.pci.multi == VIR_TRISTATE_SWITCH_OFF) - virBufferAddLit(buf, ",multifunction=off"); - virBufferAsprintf(buf, ",addr=0x%x", info->addr.pci.slot); - if (info->addr.pci.function != 0) - virBufferAsprintf(buf, ".0x%x", info->addr.pci.function); - if (info->acpiIndex != 0) - virBufferAsprintf(buf, ",acpi-index=%u", info->acpiIndex); + if (contIsPHB && contTargetIndex > 0) { + /* The PCI bus created by a spapr-pci-host-bridge device with + * alias 'x' will be called 'x.0' rather than 'x'; however, + * this does not apply to the implicit PHB in a pSeries guest, + * which always has the hardcoded name 'pci.0' */ + virBufferAsprintf(buf, ",bus=%s.0", contAlias); + } else { + /* For all other controllers, the bus name matches the alias + * of the corresponding controller */ + virBufferAsprintf(buf, ",bus=%s", contAlias); } + + if (info->addr.pci.multi == VIR_TRISTATE_SWITCH_ON) + virBufferAddLit(buf, ",multifunction=on"); + else if (info->addr.pci.multi == VIR_TRISTATE_SWITCH_OFF) + virBufferAddLit(buf, ",multifunction=off"); + + virBufferAsprintf(buf, ",addr=0x%x", info->addr.pci.slot); + + if (info->addr.pci.function != 0) + virBufferAsprintf(buf, ".0x%x", info->addr.pci.function); + + if (info->acpiIndex != 0) + virBufferAsprintf(buf, ",acpi-index=%u", info->acpiIndex); + + return 0; +} + + +static int +qemuBuildDeviceAddressStr(virBuffer *buf, + const virDomainDef *domainDef, + virDomainDeviceInfo *info) +{ + const char *contAlias = NULL; + + switch ((virDomainDeviceAddressType)info->type) { + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: + if (qemuBuildDeviceAddressPCIStr(buf, domainDef, info) < 0) + return -1; break; case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: -- 2.31.1

s/St/Str/ in the commit summary On a Thursday in 2021, Peter Krempa wrote:
The PCI address case grew massive over time. Split it out into a new function qemuBuildDeviceAddressPCIStr.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 147 ++++++++++++++++++++++------------------ 1 file changed, 82 insertions(+), 65 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Per coding guidelines error messages should not be broken into lines and variables should be separated by apostrophes. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index aeb04207b2..ee7a9f3060 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -345,9 +345,7 @@ qemuBuildDeviceAddressPCIStr(virBuffer *buf, if (!contAlias) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Device alias was not set for PCI " - "controller with index %u required " - "for device at address %s"), + _("Device alias was not set for PCI controller with index '%u' required for device at address '%s'"), info->addr.pci.bus, devStr); return -1; } @@ -372,9 +370,7 @@ qemuBuildDeviceAddressPCIStr(virBuffer *buf, if (!contAlias) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not find PCI " - "controller with index %u required " - "for device at address %s"), + _("Could not find PCI controller with index '%u' required for device at address '%s'"), info->addr.pci.bus, devStr); return -1; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Per coding guidelines error messages should not be broken into lines and variables should be separated by apostrophes.
https://libvirt.org/coding-style.html#error-message-format
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Split up the bus lookup into a function called 'qemuBuildDeviceAddressPCIGetBus'. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 48 +++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ee7a9f3060..56acd9a109 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -320,10 +320,9 @@ qemuVirCommandGetDevSet(virCommand *cmd, int fd) } -static int -qemuBuildDeviceAddressPCIStr(virBuffer *buf, - const virDomainDef *domainDef, - virDomainDeviceInfo *info) +static char * +qemuBuildDeviceAddressPCIGetBus(const virDomainDef *domainDef, + virDomainDeviceInfo *info) { g_autofree char *devStr = NULL; const char *contAlias = NULL; @@ -332,7 +331,7 @@ qemuBuildDeviceAddressPCIStr(virBuffer *buf, size_t i; if (!(devStr = virPCIDeviceAddressAsString(&info->addr.pci))) - return -1; + return NULL; for (i = 0; i < domainDef->ncontrollers; i++) { virDomainControllerDef *cont = domainDef->controllers[i]; @@ -347,7 +346,7 @@ qemuBuildDeviceAddressPCIStr(virBuffer *buf, virReportError(VIR_ERR_INTERNAL_ERROR, _("Device alias was not set for PCI controller with index '%u' required for device at address '%s'"), info->addr.pci.bus, devStr); - return -1; + return NULL; } if (virDomainDeviceAliasIsUserAlias(contAlias)) { @@ -372,20 +371,33 @@ qemuBuildDeviceAddressPCIStr(virBuffer *buf, virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not find PCI controller with index '%u' required for device at address '%s'"), info->addr.pci.bus, devStr); - return -1; + return NULL; } - if (contIsPHB && contTargetIndex > 0) { - /* The PCI bus created by a spapr-pci-host-bridge device with - * alias 'x' will be called 'x.0' rather than 'x'; however, - * this does not apply to the implicit PHB in a pSeries guest, - * which always has the hardcoded name 'pci.0' */ - virBufferAsprintf(buf, ",bus=%s.0", contAlias); - } else { - /* For all other controllers, the bus name matches the alias - * of the corresponding controller */ - virBufferAsprintf(buf, ",bus=%s", contAlias); - } + /* The PCI bus created by a spapr-pci-host-bridge device with + * alias 'x' will be called 'x.0' rather than 'x'; however, + * this does not apply to the implicit PHB in a pSeries guest, + * which always has the hardcoded name 'pci.0' */ + if (contIsPHB && contTargetIndex > 0) + return g_strdup_printf("%s.0", contAlias); + + /* For all other controllers, the bus name matches the alias + * of the corresponding controller */ + return g_strdup(contAlias); +} + + +static int +qemuBuildDeviceAddressPCIStr(virBuffer *buf, + const virDomainDef *domainDef, + virDomainDeviceInfo *info) +{ + g_autofree char *bus = NULL; + + if (!(bus = qemuBuildDeviceAddressPCIGetBus(domainDef, info))) + return -1; + + virBufferStrcat(buf, ",bus=", bus, NULL); if (info->addr.pci.multi == VIR_TRISTATE_SWITCH_ON) virBufferAddLit(buf, ",multifunction=on"); -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Split up the bus lookup into a function called 'qemuBuildDeviceAddressPCIGetBus'.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 48 +++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 18 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Upcoming patches will start converting the formatting of arguments for -device from a string to JSON so that we can keep proper types around when using it via QMP. This means we will need an equivalet for the device address builder function. 'qemuBuildDeviceAddressProps' provides equal functionality, but the output differs for fields where a number is expected, where we've previously formatted a hex value but now end up with a decimal value per JSON standard. For given address types I've selected an example device and used '-device $DEV,help' to obtain the current types recognized by qemu: Note that 'bus' is not shown below, but it's already a string so we can keep using it as a string. VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI (virtio-balloon-pci) acpi-index=<uint32> - (default: 0) addr=<int32> - Slot and optional function number, example: 06.0 or 06 (default: -1) multifunction=<bool> - on/off (default: false) Note that 'addr' is here defined as 'int32' but in fact internally in qemu is an alternate type between a number and a string so we can keep using strings here. VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB (usb-tablet) port=<str> VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO (spapr-vty) reg=<uint32> - (default: 4294967295) VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW (virtio-blk-cww) devno=<str> - Identifier of an I/O device in the channel subsystem, example: fe.1.23ab VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA (isa-serial) iobase=<uint32> - (default: 4294967295) irq=<uint32> - (default: 4294967295) VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM (pc-dimm) slot=<int32> - (default: -1) addr=<uint64> - (default: 0) Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 101 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 56acd9a109..565b1970dc 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -416,7 +416,7 @@ qemuBuildDeviceAddressPCIStr(virBuffer *buf, } -static int +static int G_GNUC_UNUSED qemuBuildDeviceAddressStr(virBuffer *buf, const virDomainDef *domainDef, virDomainDeviceInfo *info) @@ -484,6 +484,105 @@ qemuBuildDeviceAddressStr(virBuffer *buf, } +static int G_GNUC_UNUSED +qemuBuildDeviceAddressProps(virJSONValue *props, + const virDomainDef *domainDef, + virDomainDeviceInfo *info) +{ + switch ((virDomainDeviceAddressType) info->type) { + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: { + g_autofree char *pciaddr = NULL; + + if (info->addr.pci.function != 0) + pciaddr = g_strdup_printf("0x%x.0x%x", info->addr.pci.slot, info->addr.pci.function); + else + pciaddr = g_strdup_printf("0x%x", info->addr.pci.slot); + + if (virJSONValueObjectAdd(props, + "F:bus", qemuBuildDeviceAddressPCIGetBus(domainDef, info), + "T:multifunction", info->addr.pci.multi, + "s:addr", pciaddr, + "p:acpi-index", info->acpiIndex, + NULL) < 0) + return -1; + + return 0; + } + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: { + const char *contAlias = NULL; + g_auto(virBuffer) port = VIR_BUFFER_INITIALIZER; + + if (!(contAlias = virDomainControllerAliasFind(domainDef, + VIR_DOMAIN_CONTROLLER_TYPE_USB, + info->addr.usb.bus))) + return -1; + + virDomainUSBAddressPortFormatBuf(&port, info->addr.usb.port); + + if (virJSONValueObjectAdd(props, + "f:bus", g_strdup_printf("%s.0", contAlias), + "S:port", virBufferCurrentContent(&port), + NULL) < 0) + return -1; + + return 0; + } + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO: + if (info->addr.spaprvio.has_reg) { + if (virJSONValueObjectAdd(props, + "P:reg", info->addr.spaprvio.reg, + NULL) < 0) + return -1; + } + return 0; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: { + g_autofree char *devno = g_strdup_printf("%x.%x.%04x", + info->addr.ccw.cssid, + info->addr.ccw.ssid, + info->addr.ccw.devno); + + if (virJSONValueObjectAdd(props, "s:devno", devno, NULL) < 0) + return -1; + + return 0; + } + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA: + if (virJSONValueObjectAdd(props, + "u:iobase", info->addr.isa.iobase, + "p:irq", info->addr.isa.irq, + NULL) < 0) + return -1; + + return 0; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM: + if (virJSONValueObjectAdd(props, + "u:slot", info->addr.dimm.slot, + "P:addr", info->addr.dimm.base, + NULL) < 0) + return -1; + + return 0; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST: + default: + return 0; + } +} + + /** * qemuBuildVirtioDevStr * @buf: virBuffer * to append the built string -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Upcoming patches will start converting the formatting of arguments for -device from a string to JSON so that we can keep proper types around when using it via QMP.
This means we will need an equivalet for the device address builder
*equivalent
function. 'qemuBuildDeviceAddressProps' provides equal functionality, but the output differs for fields where a number is expected, where we've previously formatted a hex value but now end up with a decimal value per JSON standard.
For given address types I've selected an example device and used '-device $DEV,help' to obtain the current types recognized by qemu:
Note that 'bus' is not shown below, but it's already a string so we can keep using it as a string.
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI (virtio-balloon-pci) acpi-index=<uint32> - (default: 0) addr=<int32> - Slot and optional function number, example: 06.0 or 06 (default: -1) multifunction=<bool> - on/off (default: false)
Note that 'addr' is here defined as 'int32' but in fact internally in qemu is an alternate type between a number and a string so we can keep using strings here.
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB (usb-tablet) port=<str>
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO (spapr-vty) reg=<uint32> - (default: 4294967295)
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW (virtio-blk-cww) devno=<str> - Identifier of an I/O device in the channel subsystem, example: fe.1.23ab
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA (isa-serial) iobase=<uint32> - (default: 4294967295) irq=<uint32> - (default: 4294967295)
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM (pc-dimm) slot=<int32> - (default: -1) addr=<uint64> - (default: 0)
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 101 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 56acd9a109..565b1970dc 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -416,7 +416,7 @@ qemuBuildDeviceAddressPCIStr(virBuffer *buf, }
-static int +static int G_GNUC_UNUSED qemuBuildDeviceAddressStr(virBuffer *buf, const virDomainDef *domainDef, virDomainDeviceInfo *info) @@ -484,6 +484,105 @@ qemuBuildDeviceAddressStr(virBuffer *buf, }
+static int G_GNUC_UNUSED +qemuBuildDeviceAddressProps(virJSONValue *props, + const virDomainDef *domainDef, + virDomainDeviceInfo *info) +{ + switch ((virDomainDeviceAddressType) info->type) { + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: { + g_autofree char *pciaddr = NULL; + + if (info->addr.pci.function != 0) + pciaddr = g_strdup_printf("0x%x.0x%x", info->addr.pci.slot, info->addr.pci.function); + else + pciaddr = g_strdup_printf("0x%x", info->addr.pci.slot); + + if (virJSONValueObjectAdd(props, + "F:bus", qemuBuildDeviceAddressPCIGetBus(domainDef, info),
Without the '[fF]' patch, this only needs one autofree'd variable.
+ "T:multifunction", info->addr.pci.multi, + "s:addr", pciaddr, + "p:acpi-index", info->acpiIndex, + NULL) < 0) + return -1; + + return 0; + } + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: { + const char *contAlias = NULL; + g_auto(virBuffer) port = VIR_BUFFER_INITIALIZER; + + if (!(contAlias = virDomainControllerAliasFind(domainDef, + VIR_DOMAIN_CONTROLLER_TYPE_USB, + info->addr.usb.bus))) + return -1; + + virDomainUSBAddressPortFormatBuf(&port, info->addr.usb.port); + + if (virJSONValueObjectAdd(props, + "f:bus", g_strdup_printf("%s.0", contAlias),
Here too.
+ "S:port", virBufferCurrentContent(&port), + NULL) < 0) + return -1;
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

To simplify upcoming refactors change the logic such that we don't return early for device types which can't be transitional. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 90 ++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 565b1970dc..5104af3731 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -608,7 +608,8 @@ qemuBuildVirtioDevStr(virBuffer *buf, const char *implName = NULL; virDomainDeviceDef device = { .type = devtype }; virDomainDeviceInfo *info; - bool has_tmodel, has_ntmodel; + bool has_tmodel = false; + bool has_ntmodel = false; virDomainDeviceSetData(&device, devdata); info = virDomainDeviceGetInfo(&device); @@ -660,10 +661,10 @@ qemuBuildVirtioDevStr(virBuffer *buf, break; case VIR_DOMAIN_DEVICE_HOSTDEV: - if (device.data.hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) - return 0; - has_tmodel = device.data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL; - has_ntmodel = device.data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL; + if (device.data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) { + has_tmodel = device.data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL; + has_ntmodel = device.data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL; + } break; case VIR_DOMAIN_DEVICE_RNG: @@ -687,10 +688,10 @@ qemuBuildVirtioDevStr(virBuffer *buf, break; case VIR_DOMAIN_DEVICE_INPUT: - if (device.data.input->type != VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) - return 0; - has_tmodel = device.data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel = device.data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL; + if (device.data.input->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) { + has_tmodel = device.data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device.data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL; + } break; case VIR_DOMAIN_DEVICE_CONTROLLER: @@ -700,8 +701,6 @@ qemuBuildVirtioDevStr(virBuffer *buf, } else if (device.data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { has_tmodel = device.data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL; has_ntmodel = device.data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL; - } else { - return 0; } break; @@ -724,44 +723,45 @@ qemuBuildVirtioDevStr(virBuffer *buf, case VIR_DOMAIN_DEVICE_AUDIO: case VIR_DOMAIN_DEVICE_LAST: default: - return 0; - } - - if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && - (has_tmodel || has_ntmodel)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("virtio (non-)transitional models are not " - "supported for address type=%s"), - virDomainDeviceAddressTypeToString(info->type)); - return -1; + break; } - if (has_tmodel) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) { - virBufferAddLit(buf, "-transitional"); - } else if (virQEMUCapsGet(qemuCaps, - QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { - virBufferAddLit(buf, ",disable-legacy=off,disable-modern=off"); - } - /* No error if -transitional is not supported: our address - * allocation will force the device into plain PCI bus, which - * is functionally identical to standard 'virtio-XXX' behavior - */ - } else if (has_ntmodel) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) { - virBufferAddLit(buf, "-non-transitional"); - } else if (virQEMUCapsGet(qemuCaps, - QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { - /* Even if the QEMU binary doesn't support the non-transitional - * device, we can still make it work by manually disabling legacy - * VirtIO and enabling modern VirtIO */ - virBufferAddLit(buf, ",disable-legacy=on,disable-modern=off"); - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("virtio non-transitional model not supported " - "for this qemu")); + if (has_tmodel || has_ntmodel) { + if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("virtio (non-)transitional models are not " + "supported for address type=%s"), + virDomainDeviceAddressTypeToString(info->type)); return -1; } + + if (has_tmodel) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) { + virBufferAddLit(buf, "-transitional"); + } else if (virQEMUCapsGet(qemuCaps, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + virBufferAddLit(buf, ",disable-legacy=off,disable-modern=off"); + } + /* No error if -transitional is not supported: our address + * allocation will force the device into plain PCI bus, which + * is functionally identical to standard 'virtio-XXX' behavior + */ + } else if (has_ntmodel) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) { + virBufferAddLit(buf, "-non-transitional"); + } else if (virQEMUCapsGet(qemuCaps, + QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + /* Even if the QEMU binary doesn't support the non-transitional + * device, we can still make it work by manually disabling legacy + * VirtIO and enabling modern VirtIO */ + virBufferAddLit(buf, ",disable-legacy=on,disable-modern=off"); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio non-transitional model not supported " + "for this qemu")); + return -1; + } + } } return 0; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
To simplify upcoming refactors change the logic such that we don't return early for device types which can't be transitional.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 90 ++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 45 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Extract the code into 'qemuBuildVirtioDevGetConfig' so that we can later reuse it when converting individual device code into the more modern JSON approach as the extracted code will be necessary either way. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 157 ++++++++++++++++++++++++---------------- 1 file changed, 96 insertions(+), 61 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5104af3731..3bf514c817 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -583,36 +583,22 @@ qemuBuildDeviceAddressProps(virJSONValue *props, } -/** - * qemuBuildVirtioDevStr - * @buf: virBuffer * to append the built string - * @baseName: qemu virtio device basename string. Ex: virtio-rng for <rng> - * @qemuCaps: virQEMUCapPtr - * @devtype: virDomainDeviceType of the device. Ex: VIR_DOMAIN_DEVICE_TYPE_RNG - * @devdata: *Def * of the device definition - * - * Build the qemu virtio -device name from the passed parameters. Currently - * this is mostly about attaching the correct string prefix to @baseName for - * the passed @type. So for @baseName "virtio-rng" and devdata->info.type - * VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI, generate "virtio-rng-pci" - * - * Returns: -1 on failure, 0 on success - */ static int -qemuBuildVirtioDevStr(virBuffer *buf, - const char *baseName, - virQEMUCaps *qemuCaps, - virDomainDeviceType devtype, - void *devdata) +qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, + const char *baseName, + virQEMUCaps *qemuCaps, + char **devtype, + virTristateSwitch *disableLegacy, + virTristateSwitch *disableModern) { + virDomainDeviceInfo *info = virDomainDeviceGetInfo(device); + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; const char *implName = NULL; - virDomainDeviceDef device = { .type = devtype }; - virDomainDeviceInfo *info; bool has_tmodel = false; bool has_ntmodel = false; - virDomainDeviceSetData(&device, devdata); - info = virDomainDeviceGetInfo(&device); + *disableLegacy = VIR_TRISTATE_SWITCH_ABSENT; + *disableModern = VIR_TRISTATE_SWITCH_ABSENT; switch ((virDomainDeviceAddressType) info->type) { case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: @@ -647,60 +633,60 @@ qemuBuildVirtioDevStr(virBuffer *buf, return -1; } - virBufferAsprintf(buf, "%s-%s", baseName, implName); + virBufferAsprintf(&buf, "%s-%s", baseName, implName); - switch (devtype) { + switch ((virDomainDeviceType) device->type) { case VIR_DOMAIN_DEVICE_DISK: - has_tmodel = device.data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel = device.data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL; + has_tmodel = device->data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device->data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_NET: - has_tmodel = device.data.net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel = device.data.net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_NON_TRANSITIONAL; + has_tmodel = device->data.net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device->data.net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_HOSTDEV: - if (device.data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) { - has_tmodel = device.data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL; - has_ntmodel = device.data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL; + if (device->data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) { + has_tmodel = device->data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL; + has_ntmodel = device->data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL; } break; case VIR_DOMAIN_DEVICE_RNG: - has_tmodel = device.data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel = device.data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL; + has_tmodel = device->data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device->data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_FS: - has_tmodel = device.data.fs->model == VIR_DOMAIN_FS_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel = device.data.fs->model == VIR_DOMAIN_FS_MODEL_VIRTIO_NON_TRANSITIONAL; + has_tmodel = device->data.fs->model == VIR_DOMAIN_FS_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device->data.fs->model == VIR_DOMAIN_FS_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_MEMBALLOON: - has_tmodel = device.data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel = device.data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL; + has_tmodel = device->data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device->data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_VSOCK: - has_tmodel = device.data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel = device.data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL; + has_tmodel = device->data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device->data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_INPUT: - if (device.data.input->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) { - has_tmodel = device.data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel = device.data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL; + if (device->data.input->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) { + has_tmodel = device->data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device->data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL; } break; case VIR_DOMAIN_DEVICE_CONTROLLER: - if (device.data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) { - has_tmodel = device.data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_TRANSITIONAL; - has_ntmodel = device.data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_NON_TRANSITIONAL; - } else if (device.data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { - has_tmodel = device.data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL; - has_ntmodel = device.data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL; + if (device->data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) { + has_tmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_TRANSITIONAL; + has_ntmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_NON_TRANSITIONAL; + } else if (device->data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { + has_tmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL; + has_ntmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL; } break; @@ -732,15 +718,14 @@ qemuBuildVirtioDevStr(virBuffer *buf, _("virtio (non-)transitional models are not " "supported for address type=%s"), virDomainDeviceAddressTypeToString(info->type)); - return -1; } if (has_tmodel) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) { - virBufferAddLit(buf, "-transitional"); - } else if (virQEMUCapsGet(qemuCaps, - QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { - virBufferAddLit(buf, ",disable-legacy=off,disable-modern=off"); + virBufferAddLit(&buf, "-transitional"); + } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + *disableLegacy = VIR_TRISTATE_SWITCH_OFF; + *disableModern = VIR_TRISTATE_SWITCH_OFF; } /* No error if -transitional is not supported: our address * allocation will force the device into plain PCI bus, which @@ -748,22 +733,72 @@ qemuBuildVirtioDevStr(virBuffer *buf, */ } else if (has_ntmodel) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) { - virBufferAddLit(buf, "-non-transitional"); - } else if (virQEMUCapsGet(qemuCaps, - QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + virBufferAddLit(&buf, "-non-transitional"); + } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { /* Even if the QEMU binary doesn't support the non-transitional * device, we can still make it work by manually disabling legacy * VirtIO and enabling modern VirtIO */ - virBufferAddLit(buf, ",disable-legacy=on,disable-modern=off"); + *disableLegacy = VIR_TRISTATE_SWITCH_ON; + *disableModern = VIR_TRISTATE_SWITCH_OFF; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("virtio non-transitional model not supported " - "for this qemu")); + _("virtio non-transitional model not supported for this qemu")); return -1; } } } + *devtype = virBufferContentAndReset(&buf); + + return 0; +} + + +/** + * qemuBuildVirtioDevStr + * @buf: virBuffer * to append the built string + * @baseName: qemu virtio device basename string. Ex: virtio-rng for <rng> + * @qemuCaps: virQEMUCapPtr + * @devtype: virDomainDeviceType of the device. Ex: VIR_DOMAIN_DEVICE_TYPE_RNG + * @devdata: *Def * of the device definition + * + * Build the qemu virtio -device name from the passed parameters. Currently + * this is mostly about attaching the correct string prefix to @baseName for + * the passed @type. So for @baseName "virtio-rng" and devdata->info.type + * VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI, generate "virtio-rng-pci" + * + * Returns: -1 on failure, 0 on success + */ +static int +qemuBuildVirtioDevStr(virBuffer *buf, + const char *baseName, + virQEMUCaps *qemuCaps, + virDomainDeviceType devtype, + void *devdata) +{ + virDomainDeviceDef device = { .type = devtype }; + g_autofree char *model = NULL; + virTristateSwitch disableLegacy = VIR_TRISTATE_SWITCH_ABSENT; + virTristateSwitch disableModern = VIR_TRISTATE_SWITCH_ABSENT; + + virDomainDeviceSetData(&device, devdata); + + if (qemuBuildVirtioDevGetConfig(&device, baseName, qemuCaps, &model, + &disableLegacy, &disableModern) < 0) + return -1; + + virBufferAdd(buf, model, -1); + + if (disableLegacy != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(buf, ",disable-legacy=%s", + virTristateSwitchTypeToString(disableLegacy)); + } + + if (disableModern != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(buf, ",disable-modern=%s", + virTristateSwitchTypeToString(disableModern)); + } + return 0; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Extract the code into 'qemuBuildVirtioDevGetConfig' so that we can later reuse it when converting individual device code into the more modern JSON approach as the extracted code will be necessary either way.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 157 ++++++++++++++++++++++++---------------- 1 file changed, 96 insertions(+), 61 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Split out the function a bit more to separate the per-device code. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 151 +++++++++++++++++++++------------------- 1 file changed, 80 insertions(+), 71 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3bf514c817..f185e3a53c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -583,110 +583,63 @@ qemuBuildDeviceAddressProps(virJSONValue *props, } -static int -qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, - const char *baseName, - virQEMUCaps *qemuCaps, - char **devtype, - virTristateSwitch *disableLegacy, - virTristateSwitch *disableModern) +static void +qemuBuildVirtioDevGetConfigDev(virDomainDeviceDef *device, + bool *has_tmodel, + bool *has_ntmodel) { - virDomainDeviceInfo *info = virDomainDeviceGetInfo(device); - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - const char *implName = NULL; - bool has_tmodel = false; - bool has_ntmodel = false; - - *disableLegacy = VIR_TRISTATE_SWITCH_ABSENT; - *disableModern = VIR_TRISTATE_SWITCH_ABSENT; - - switch ((virDomainDeviceAddressType) info->type) { - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: - implName = "pci"; - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: - implName = "device"; - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: - implName = "ccw"; - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected address type for '%s'"), baseName); - return -1; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST: - default: - virReportEnumRangeError(virDomainDeviceAddressType, info->type); - return -1; - } - - virBufferAsprintf(&buf, "%s-%s", baseName, implName); - switch ((virDomainDeviceType) device->type) { case VIR_DOMAIN_DEVICE_DISK: - has_tmodel = device->data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel = device->data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL; + *has_tmodel = device->data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL; + *has_ntmodel = device->data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_NET: - has_tmodel = device->data.net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel = device->data.net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_NON_TRANSITIONAL; + *has_tmodel = device->data.net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_TRANSITIONAL; + *has_ntmodel = device->data.net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_HOSTDEV: if (device->data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) { - has_tmodel = device->data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL; - has_ntmodel = device->data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL; + *has_tmodel = device->data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL; + *has_ntmodel = device->data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL; } break; case VIR_DOMAIN_DEVICE_RNG: - has_tmodel = device->data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel = device->data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL; + *has_tmodel = device->data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL; + *has_ntmodel = device->data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_FS: - has_tmodel = device->data.fs->model == VIR_DOMAIN_FS_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel = device->data.fs->model == VIR_DOMAIN_FS_MODEL_VIRTIO_NON_TRANSITIONAL; + *has_tmodel = device->data.fs->model == VIR_DOMAIN_FS_MODEL_VIRTIO_TRANSITIONAL; + *has_ntmodel = device->data.fs->model == VIR_DOMAIN_FS_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_MEMBALLOON: - has_tmodel = device->data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel = device->data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL; + *has_tmodel = device->data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL; + *has_ntmodel = device->data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_VSOCK: - has_tmodel = device->data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel = device->data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL; + *has_tmodel = device->data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL; + *has_ntmodel = device->data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_INPUT: if (device->data.input->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) { - has_tmodel = device->data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL; - has_ntmodel = device->data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL; + *has_tmodel = device->data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL; + *has_ntmodel = device->data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL; } break; case VIR_DOMAIN_DEVICE_CONTROLLER: if (device->data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) { - has_tmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_TRANSITIONAL; - has_ntmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_NON_TRANSITIONAL; + *has_tmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_TRANSITIONAL; + *has_ntmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_NON_TRANSITIONAL; } else if (device->data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { - has_tmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL; - has_ntmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL; + *has_tmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL; + *has_ntmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL; } break; @@ -711,6 +664,62 @@ qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, default: break; } +} + + +static int +qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, + const char *baseName, + virQEMUCaps *qemuCaps, + char **devtype, + virTristateSwitch *disableLegacy, + virTristateSwitch *disableModern) +{ + virDomainDeviceInfo *info = virDomainDeviceGetInfo(device); + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + const char *implName = NULL; + bool has_tmodel = false; + bool has_ntmodel = false; + + *disableLegacy = VIR_TRISTATE_SWITCH_ABSENT; + *disableModern = VIR_TRISTATE_SWITCH_ABSENT; + + switch ((virDomainDeviceAddressType) info->type) { + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: + implName = "pci"; + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: + implName = "device"; + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: + implName = "ccw"; + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected address type for '%s'"), baseName); + return -1; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST: + default: + virReportEnumRangeError(virDomainDeviceAddressType, info->type); + return -1; + } + + virBufferAsprintf(&buf, "%s-%s", baseName, implName); + + qemuBuildVirtioDevGetConfigDev(device, &has_tmodel, &has_ntmodel); if (has_tmodel || has_ntmodel) { if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Split out the function a bit more to separate the per-device code.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 151 +++++++++++++++++++++------------------- 1 file changed, 80 insertions(+), 71 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The 'virito' argument was misleadingly implying that it's true for all virtio devices, but that's not the case. 'virtio-vga(-gl)' is a virtio device but doesn't accept the usual bus-dependant suffix. Add a comment for 'qemuDeviceVideoGetModel' and another boolean 'virtioBusSuffix' which carries the above meaning so that the 'virtio' argument can be fixed (it will be used later). Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f185e3a53c..3c468ab0a4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4291,16 +4291,28 @@ qemuBuildSoundCommandLine(virCommand *cmd, } +/** + * qemuDeviceVideoGetModel: + * @qemuCaps: qemu capabilities + * @video: video device definition + * @virtio: the returned video device is a 'virtio' device + * @virtioBusSuffix: the returned device needs to get the bus-suffix + * + * Returns the model fo the device for @video and @qemuCaps. @virtio and + * @virtioBusSuffix are filled with the corresponding flags. + */ static const char * qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, const virDomainVideoDef *video, - bool *virtio) + bool *virtio, + bool *virtioBusSuffix) { const char *model = NULL; bool primaryVga = false; virTristateSwitch accel3d = VIR_TRISTATE_SWITCH_ABSENT; *virtio = false; + *virtioBusSuffix = false; if (video->accel) accel3d = video->accel->accel3d; @@ -4318,6 +4330,7 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, } else { model = "vhost-user-gpu"; *virtio = true; + *virtioBusSuffix = true; } } else { if (primaryVga) { @@ -4340,6 +4353,9 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, model = "virtio-vga-gl"; else model = "virtio-vga"; + + *virtio = true; + *virtioBusSuffix = false; break; case VIR_DOMAIN_VIDEO_TYPE_BOCHS: model = "bochs-display"; @@ -4367,7 +4383,9 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, model = "virtio-gpu-gl"; else model = "virtio-gpu"; + *virtio = true; + *virtioBusSuffix = true; break; case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: case VIR_DOMAIN_VIDEO_TYPE_VGA: @@ -4406,14 +4424,15 @@ qemuBuildDeviceVideoStr(const virDomainDef *def, const char *model = NULL; virTristateSwitch accel3d = VIR_TRISTATE_SWITCH_ABSENT; bool virtio = false; + bool virtioBusSuffix = false; if (video->accel) accel3d = video->accel->accel3d; - if (!(model = qemuDeviceVideoGetModel(qemuCaps, video, &virtio))) + if (!(model = qemuDeviceVideoGetModel(qemuCaps, video, &virtio, &virtioBusSuffix))) return NULL; - if (virtio) { + if (virtioBusSuffix) { if (qemuBuildVirtioDevStr(&buf, model, qemuCaps, VIR_DOMAIN_DEVICE_VIDEO, video) < 0) { return NULL; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The 'virito' argument was misleadingly implying that it's true for all
*virtio
virtio devices, but that's not the case. 'virtio-vga(-gl)' is a virtio device but doesn't accept the usual bus-dependant suffix.
Add a comment for 'qemuDeviceVideoGetModel' and another boolean 'virtioBusSuffix' which carries the above meaning so that the 'virtio' argument can be fixed (it will be used later).
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The function is static and will be needed in the virtio device config helper. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 248 ++++++++++++++++++++-------------------- 1 file changed, 124 insertions(+), 124 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3c468ab0a4..e86c3bda22 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -583,6 +583,130 @@ qemuBuildDeviceAddressProps(virJSONValue *props, } +/** + * qemuDeviceVideoGetModel: + * @qemuCaps: qemu capabilities + * @video: video device definition + * @virtio: the returned video device is a 'virtio' device + * @virtioBusSuffix: the returned device needs to get the bus-suffix + * + * Returns the model fo the device for @video and @qemuCaps. @virtio and + * @virtioBusSuffix are filled with the corresponding flags. + */ +static const char * +qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, + const virDomainVideoDef *video, + bool *virtio, + bool *virtioBusSuffix) +{ + const char *model = NULL; + bool primaryVga = false; + virTristateSwitch accel3d = VIR_TRISTATE_SWITCH_ABSENT; + + *virtio = false; + *virtioBusSuffix = false; + + if (video->accel) + accel3d = video->accel->accel3d; + + if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps)) + primaryVga = true; + + /* We try to chose the best model for primary video device by preferring + * model with VGA compatibility mode. For some video devices on some + * architectures there might not be such model so fallback to one + * without VGA compatibility mode. */ + if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) { + if (primaryVga) { + model = "vhost-user-vga"; + } else { + model = "vhost-user-gpu"; + *virtio = true; + *virtioBusSuffix = true; + } + } else { + if (primaryVga) { + switch ((virDomainVideoType) video->type) { + case VIR_DOMAIN_VIDEO_TYPE_VGA: + model = "VGA"; + break; + case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: + model = "cirrus-vga"; + break; + case VIR_DOMAIN_VIDEO_TYPE_VMVGA: + model = "vmware-svga"; + break; + case VIR_DOMAIN_VIDEO_TYPE_QXL: + model = "qxl-vga"; + break; + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_VGA_GL) && + accel3d == VIR_TRISTATE_SWITCH_ON) + model = "virtio-vga-gl"; + else + model = "virtio-vga"; + + *virtio = true; + *virtioBusSuffix = false; + break; + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + model = "bochs-display"; + break; + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: + model = "ramfb"; + break; + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: + case VIR_DOMAIN_VIDEO_TYPE_XEN: + case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_LAST: + break; + } + } else { + switch ((virDomainVideoType) video->type) { + case VIR_DOMAIN_VIDEO_TYPE_QXL: + model = "qxl"; + break; + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_GL_PCI) && + accel3d == VIR_TRISTATE_SWITCH_ON) + model = "virtio-gpu-gl"; + else + model = "virtio-gpu"; + + *virtio = true; + *virtioBusSuffix = true; + break; + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: + case VIR_DOMAIN_VIDEO_TYPE_VGA: + case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: + case VIR_DOMAIN_VIDEO_TYPE_VMVGA: + case VIR_DOMAIN_VIDEO_TYPE_XEN: + case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: + case VIR_DOMAIN_VIDEO_TYPE_LAST: + break; + } + } + } + + if (!model || STREQ(model, "")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid model for video type '%s'"), + virDomainVideoTypeToString(video->type)); + return NULL; + } + + return model; +} + + static void qemuBuildVirtioDevGetConfigDev(virDomainDeviceDef *device, bool *has_tmodel, @@ -4291,130 +4415,6 @@ qemuBuildSoundCommandLine(virCommand *cmd, } -/** - * qemuDeviceVideoGetModel: - * @qemuCaps: qemu capabilities - * @video: video device definition - * @virtio: the returned video device is a 'virtio' device - * @virtioBusSuffix: the returned device needs to get the bus-suffix - * - * Returns the model fo the device for @video and @qemuCaps. @virtio and - * @virtioBusSuffix are filled with the corresponding flags. - */ -static const char * -qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, - const virDomainVideoDef *video, - bool *virtio, - bool *virtioBusSuffix) -{ - const char *model = NULL; - bool primaryVga = false; - virTristateSwitch accel3d = VIR_TRISTATE_SWITCH_ABSENT; - - *virtio = false; - *virtioBusSuffix = false; - - if (video->accel) - accel3d = video->accel->accel3d; - - if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps)) - primaryVga = true; - - /* We try to chose the best model for primary video device by preferring - * model with VGA compatibility mode. For some video devices on some - * architectures there might not be such model so fallback to one - * without VGA compatibility mode. */ - if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) { - if (primaryVga) { - model = "vhost-user-vga"; - } else { - model = "vhost-user-gpu"; - *virtio = true; - *virtioBusSuffix = true; - } - } else { - if (primaryVga) { - switch ((virDomainVideoType) video->type) { - case VIR_DOMAIN_VIDEO_TYPE_VGA: - model = "VGA"; - break; - case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: - model = "cirrus-vga"; - break; - case VIR_DOMAIN_VIDEO_TYPE_VMVGA: - model = "vmware-svga"; - break; - case VIR_DOMAIN_VIDEO_TYPE_QXL: - model = "qxl-vga"; - break; - case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_VGA_GL) && - accel3d == VIR_TRISTATE_SWITCH_ON) - model = "virtio-vga-gl"; - else - model = "virtio-vga"; - - *virtio = true; - *virtioBusSuffix = false; - break; - case VIR_DOMAIN_VIDEO_TYPE_BOCHS: - model = "bochs-display"; - break; - case VIR_DOMAIN_VIDEO_TYPE_RAMFB: - model = "ramfb"; - break; - case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: - case VIR_DOMAIN_VIDEO_TYPE_XEN: - case VIR_DOMAIN_VIDEO_TYPE_VBOX: - case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: - case VIR_DOMAIN_VIDEO_TYPE_GOP: - case VIR_DOMAIN_VIDEO_TYPE_NONE: - case VIR_DOMAIN_VIDEO_TYPE_LAST: - break; - } - } else { - switch ((virDomainVideoType) video->type) { - case VIR_DOMAIN_VIDEO_TYPE_QXL: - model = "qxl"; - break; - case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_GL_PCI) && - accel3d == VIR_TRISTATE_SWITCH_ON) - model = "virtio-gpu-gl"; - else - model = "virtio-gpu"; - - *virtio = true; - *virtioBusSuffix = true; - break; - case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: - case VIR_DOMAIN_VIDEO_TYPE_VGA: - case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: - case VIR_DOMAIN_VIDEO_TYPE_VMVGA: - case VIR_DOMAIN_VIDEO_TYPE_XEN: - case VIR_DOMAIN_VIDEO_TYPE_VBOX: - case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: - case VIR_DOMAIN_VIDEO_TYPE_GOP: - case VIR_DOMAIN_VIDEO_TYPE_NONE: - case VIR_DOMAIN_VIDEO_TYPE_BOCHS: - case VIR_DOMAIN_VIDEO_TYPE_RAMFB: - case VIR_DOMAIN_VIDEO_TYPE_LAST: - break; - } - } - } - - if (!model || STREQ(model, "")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid model for video type '%s'"), - virDomainVideoTypeToString(video->type)); - return NULL; - } - - return model; -} - - static char * qemuBuildDeviceVideoStr(const virDomainDef *def, virDomainVideoDef *video, -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The function is static and will be needed in the virtio device config helper.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 248 ++++++++++++++++++++-------------------- 1 file changed, 124 insertions(+), 124 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Add the bus suffix in a separate call. This will make it more obvious what's happening in the next commit. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e86c3bda22..b1ee5c6cb8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -808,6 +808,10 @@ qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, *disableLegacy = VIR_TRISTATE_SWITCH_ABSENT; *disableModern = VIR_TRISTATE_SWITCH_ABSENT; + qemuBuildVirtioDevGetConfigDev(device, &has_tmodel, &has_ntmodel); + + virBufferAdd(&buf, baseName, -1); + switch ((virDomainDeviceAddressType) info->type) { case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: implName = "pci"; @@ -841,9 +845,7 @@ qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, return -1; } - virBufferAsprintf(&buf, "%s-%s", baseName, implName); - - qemuBuildVirtioDevGetConfigDev(device, &has_tmodel, &has_ntmodel); + virBufferAsprintf(&buf, "-%s", implName); if (has_tmodel || has_ntmodel) { if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Add the bus suffix in a separate call. This will make it more obvious what's happening in the next commit.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Since we already have code for per-device behaviour we can also populate the device name and extract virtioOptions in the switch statement so that callers don't have to pass it in. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 107 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 99 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b1ee5c6cb8..8753ae5891 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -709,67 +709,147 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, static void qemuBuildVirtioDevGetConfigDev(virDomainDeviceDef *device, + virQEMUCaps *qemuCaps, + const char **baseName, + virDomainVirtioOptions **virtioOptions, bool *has_tmodel, - bool *has_ntmodel) + bool *has_ntmodel, + bool *useBusSuffix) { switch ((virDomainDeviceType) device->type) { case VIR_DOMAIN_DEVICE_DISK: + if (virStorageSourceGetActualType(device->data.disk->src) == VIR_STORAGE_TYPE_VHOST_USER) + *baseName = "vhost-user-blk"; + else + *baseName = "virtio-blk"; + + *virtioOptions = device->data.disk->virtio; *has_tmodel = device->data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL; *has_ntmodel = device->data.disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_NET: + *baseName = "virtio-net"; + *virtioOptions = device->data.net->virtio; *has_tmodel = device->data.net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_TRANSITIONAL; *has_ntmodel = device->data.net->model == VIR_DOMAIN_NET_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_HOSTDEV: if (device->data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) { + *baseName = "vhost-scsi"; *has_tmodel = device->data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_TRANSITIONAL; *has_ntmodel = device->data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL; } break; case VIR_DOMAIN_DEVICE_RNG: + *baseName = "virtio-rng"; + *virtioOptions = device->data.rng->virtio; *has_tmodel = device->data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL; *has_ntmodel = device->data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_FS: + switch ((virDomainFSDriverType) device->data.fs->fsdriver) { + case VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT: + case VIR_DOMAIN_FS_DRIVER_TYPE_PATH: + case VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE: + *baseName = "virtio-9p"; + break; + + case VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS: + *baseName = "vhost-user-fs"; + break; + + case VIR_DOMAIN_FS_DRIVER_TYPE_LOOP: + case VIR_DOMAIN_FS_DRIVER_TYPE_NBD: + case VIR_DOMAIN_FS_DRIVER_TYPE_PLOOP: + case VIR_DOMAIN_FS_DRIVER_TYPE_LAST: + break; + + } + *virtioOptions = device->data.fs->virtio; *has_tmodel = device->data.fs->model == VIR_DOMAIN_FS_MODEL_VIRTIO_TRANSITIONAL; *has_ntmodel = device->data.fs->model == VIR_DOMAIN_FS_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_MEMBALLOON: + *baseName = "virtio-balloon"; + *virtioOptions = device->data.memballoon->virtio; *has_tmodel = device->data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_TRANSITIONAL; *has_ntmodel = device->data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_VSOCK: + *baseName = "vhost-vsock"; + *virtioOptions = device->data.vsock->virtio; *has_tmodel = device->data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL; *has_ntmodel = device->data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL; break; case VIR_DOMAIN_DEVICE_INPUT: - if (device->data.input->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) { + *virtioOptions = device->data.input->virtio; + + switch ((virDomainInputType) device->data.input->type) { + case VIR_DOMAIN_INPUT_TYPE_MOUSE: + *baseName = "virtio-mouse"; + break; + + case VIR_DOMAIN_INPUT_TYPE_TABLET: + *baseName = "virtio-tablet"; + break; + + case VIR_DOMAIN_INPUT_TYPE_KBD: + *baseName = "virtio-keyboard"; + break; + + case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH: + *baseName = "virtio-input-host"; *has_tmodel = device->data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL; *has_ntmodel = device->data.input->model == VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL; + break; + + case VIR_DOMAIN_INPUT_TYPE_EVDEV: + case VIR_DOMAIN_INPUT_TYPE_LAST: + default: + break; } break; case VIR_DOMAIN_DEVICE_CONTROLLER: if (device->data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) { + *baseName = "virtio-serial"; + *virtioOptions = device->data.controller->virtio; *has_tmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_TRANSITIONAL; *has_ntmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_VIRTIO_SERIAL_VIRTIO_NON_TRANSITIONAL; } else if (device->data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { + *baseName = "virtio-scsi"; + *virtioOptions = device->data.controller->virtio; *has_tmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL; *has_ntmodel = device->data.controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL; } break; + case VIR_DOMAIN_DEVICE_VIDEO: { + bool virtio; + bool virtioBusSuffix; + + if (!(*baseName = qemuDeviceVideoGetModel(qemuCaps, + device->data.video, + &virtio, + &virtioBusSuffix))) + return; + + if (!virtioBusSuffix) + *useBusSuffix = false; + + *virtioOptions = device->data.video->virtio; + } + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_SOUND: - case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_WATCHDOG: case VIR_DOMAIN_DEVICE_GRAPHICS: case VIR_DOMAIN_DEVICE_HUB: @@ -793,7 +873,6 @@ qemuBuildVirtioDevGetConfigDev(virDomainDeviceDef *device, static int qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, - const char *baseName, virQEMUCaps *qemuCaps, char **devtype, virTristateSwitch *disableLegacy, @@ -801,14 +880,25 @@ qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, { virDomainDeviceInfo *info = virDomainDeviceGetInfo(device); g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + const char *baseName = NULL; const char *implName = NULL; bool has_tmodel = false; bool has_ntmodel = false; + bool useBusSuffix = true; + virDomainVirtioOptions *virtioOptions; *disableLegacy = VIR_TRISTATE_SWITCH_ABSENT; *disableModern = VIR_TRISTATE_SWITCH_ABSENT; - qemuBuildVirtioDevGetConfigDev(device, &has_tmodel, &has_ntmodel); + qemuBuildVirtioDevGetConfigDev(device, qemuCaps, &baseName, + &virtioOptions, &has_tmodel, + &has_ntmodel, &useBusSuffix); + + if (!baseName) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("unknown base name while formatting virtio device")); + return -1; + } virBufferAdd(&buf, baseName, -1); @@ -845,7 +935,8 @@ qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, return -1; } - virBufferAsprintf(&buf, "-%s", implName); + if (useBusSuffix) + virBufferAsprintf(&buf, "-%s", implName); if (has_tmodel || has_ntmodel) { if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { @@ -906,7 +997,7 @@ qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, */ static int qemuBuildVirtioDevStr(virBuffer *buf, - const char *baseName, + const char *baseName G_GNUC_UNUSED, virQEMUCaps *qemuCaps, virDomainDeviceType devtype, void *devdata) @@ -918,7 +1009,7 @@ qemuBuildVirtioDevStr(virBuffer *buf, virDomainDeviceSetData(&device, devdata); - if (qemuBuildVirtioDevGetConfig(&device, baseName, qemuCaps, &model, + if (qemuBuildVirtioDevGetConfig(&device, qemuCaps, &model, &disableLegacy, &disableModern) < 0) return -1; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Since we already have code for per-device behaviour we can also populate the device name and extract virtioOptions in the switch statement so that callers don't have to pass it in.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 107 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 99 insertions(+), 8 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The code doesn't need the name as it determines it internally. Remove the argument and fix all callers. In certain cases it lead to simplification of the logic. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 62 +++++++++-------------------------------- 1 file changed, 13 insertions(+), 49 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8753ae5891..de7278bcdd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -983,7 +983,6 @@ qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, /** * qemuBuildVirtioDevStr * @buf: virBuffer * to append the built string - * @baseName: qemu virtio device basename string. Ex: virtio-rng for <rng> * @qemuCaps: virQEMUCapPtr * @devtype: virDomainDeviceType of the device. Ex: VIR_DOMAIN_DEVICE_TYPE_RNG * @devdata: *Def * of the device definition @@ -997,7 +996,6 @@ qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, */ static int qemuBuildVirtioDevStr(virBuffer *buf, - const char *baseName G_GNUC_UNUSED, virQEMUCaps *qemuCaps, virDomainDeviceType devtype, void *devdata) @@ -1995,17 +1993,8 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, break; case VIR_DOMAIN_DISK_BUS_VIRTIO: - if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_VHOST_USER) { - if (qemuBuildVirtioDevStr(&opt, "vhost-user-blk", qemuCaps, - VIR_DOMAIN_DEVICE_DISK, disk) < 0) { - return NULL; - } - } else { - if (qemuBuildVirtioDevStr(&opt, "virtio-blk", qemuCaps, - VIR_DOMAIN_DEVICE_DISK, disk) < 0) { - return NULL; - } - } + if (qemuBuildVirtioDevStr(&opt, qemuCaps, VIR_DOMAIN_DEVICE_DISK, disk) < 0) + return NULL; if (disk->iothread) virBufferAsprintf(&opt, ",iothread=iothread%u", disk->iothread); @@ -2454,8 +2443,7 @@ qemuBuildVHostUserFsDevStr(virDomainFSDef *fs, { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - if (qemuBuildVirtioDevStr(&buf, "vhost-user-fs", priv->qemuCaps, - VIR_DOMAIN_DEVICE_FS, fs) < 0) + if (qemuBuildVirtioDevStr(&buf, priv->qemuCaps, VIR_DOMAIN_DEVICE_FS, fs) < 0) return NULL; virBufferAsprintf(&buf, ",id=%s", fs->info.alias); @@ -2560,8 +2548,7 @@ qemuBuildFSDevStr(const virDomainDef *def, { g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER; - if (qemuBuildVirtioDevStr(&opt, "virtio-9p", qemuCaps, - VIR_DOMAIN_DEVICE_FS, fs) < 0) + if (qemuBuildVirtioDevStr(&opt, qemuCaps, VIR_DOMAIN_DEVICE_FS, fs) < 0) return NULL; virBufferAsprintf(&opt, ",id=%s", fs->info.alias); @@ -2791,8 +2778,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: - if (qemuBuildVirtioDevStr(&buf, "virtio-scsi", qemuCaps, - VIR_DOMAIN_DEVICE_CONTROLLER, def) < 0) { + if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_CONTROLLER, def) < 0) { return -1; } @@ -2842,8 +2828,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, break; case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: - if (qemuBuildVirtioDevStr(&buf, "virtio-serial", qemuCaps, - VIR_DOMAIN_DEVICE_CONTROLLER, def) < 0) { + if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_CONTROLLER, def) < 0) { return -1; } @@ -3737,8 +3722,7 @@ qemuBuildNicDevStr(virDomainDef *def, char macaddr[VIR_MAC_STRING_BUFLEN]; if (virDomainNetIsVirtioModel(net)) { - if (qemuBuildVirtioDevStr(&buf, "virtio-net", qemuCaps, - VIR_DOMAIN_DEVICE_NET, net) < 0) { + if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_NET, net) < 0) { return NULL; } @@ -4137,7 +4121,7 @@ qemuBuildMemballoonCommandLine(virCommand *cmd, if (!virDomainDefHasMemballoon(def)) return 0; - if (qemuBuildVirtioDevStr(&buf, "virtio-balloon", qemuCaps, + if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_MEMBALLOON, def->memballoon) < 0) { return -1; @@ -4209,26 +4193,10 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def, switch ((virDomainInputType)dev->type) { case VIR_DOMAIN_INPUT_TYPE_MOUSE: - if (qemuBuildVirtioDevStr(&buf, "virtio-mouse", qemuCaps, - VIR_DOMAIN_DEVICE_INPUT, dev) < 0) { - return NULL; - } - break; case VIR_DOMAIN_INPUT_TYPE_TABLET: - if (qemuBuildVirtioDevStr(&buf, "virtio-tablet", qemuCaps, - VIR_DOMAIN_DEVICE_INPUT, dev) < 0) { - return NULL; - } - break; case VIR_DOMAIN_INPUT_TYPE_KBD: - if (qemuBuildVirtioDevStr(&buf, "virtio-keyboard", qemuCaps, - VIR_DOMAIN_DEVICE_INPUT, dev) < 0) { - return NULL; - } - break; case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH: - if (qemuBuildVirtioDevStr(&buf, "virtio-input-host", qemuCaps, - VIR_DOMAIN_DEVICE_INPUT, dev) < 0) { + if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_INPUT, dev) < 0) { return NULL; } break; @@ -4526,8 +4494,7 @@ qemuBuildDeviceVideoStr(const virDomainDef *def, return NULL; if (virtioBusSuffix) { - if (qemuBuildVirtioDevStr(&buf, model, qemuCaps, - VIR_DOMAIN_DEVICE_VIDEO, video) < 0) { + if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_VIDEO, video) < 0) { return NULL; } } else { @@ -4833,8 +4800,7 @@ qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def, g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; virDomainHostdevSubsysSCSIVHost *hostsrc = &dev->source.subsys.u.scsi_host; - if (qemuBuildVirtioDevStr(&buf, "vhost-scsi", qemuCaps, - VIR_DOMAIN_DEVICE_HOSTDEV, dev) < 0) { + if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_HOSTDEV, dev) < 0) { return NULL; } @@ -5771,8 +5737,7 @@ qemuBuildRNGDevStr(const virDomainDef *def, { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - if (qemuBuildVirtioDevStr(&buf, "virtio-rng", qemuCaps, - VIR_DOMAIN_DEVICE_RNG, dev) < 0) { + if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_RNG, dev) < 0) { return NULL; } @@ -10456,8 +10421,7 @@ qemuBuildVsockDevStr(virDomainDef *def, qemuDomainVsockPrivate *priv = (qemuDomainVsockPrivate *)vsock->privateData; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - if (qemuBuildVirtioDevStr(&buf, "vhost-vsock", qemuCaps, - VIR_DOMAIN_DEVICE_VSOCK, vsock) < 0) { + if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_VSOCK, vsock) < 0) { return NULL; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The code doesn't need the name as it determines it internally. Remove the argument and fix all callers. In certain cases it lead to
s/lead/led/ Lead and lead compounds can cause cancer, reproductive harm or birth defects in the state of California.
simplification of the logic.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 62 +++++++++-------------------------------- 1 file changed, 13 insertions(+), 49 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Merge the code from qemuBuildVirtioOptionsStr so that we don't have to call two separate functions. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 39 ++++++++++--------- .../vhost-vsock-ccw-iommu.s390x-latest.args | 2 +- ...-options-controller-ats.x86_64-latest.args | 4 +- ...ptions-controller-iommu.x86_64-latest.args | 4 +- ...tions-controller-packed.x86_64-latest.args | 4 +- .../virtio-options-fs-ats.x86_64-latest.args | 4 +- ...virtio-options-fs-iommu.x86_64-latest.args | 4 +- ...irtio-options-fs-packed.x86_64-latest.args | 4 +- ...irtio-options-input-ats.x86_64-latest.args | 4 +- ...tio-options-input-iommu.x86_64-latest.args | 4 +- ...io-options-input-packed.x86_64-latest.args | 4 +- ...-options-memballoon-ats.x86_64-latest.args | 2 +- ...ptions-memballoon-iommu.x86_64-latest.args | 2 +- ...tions-memballoon-packed.x86_64-latest.args | 2 +- .../virtio-options-net-ats.x86_64-latest.args | 4 +- ...irtio-options-net-iommu.x86_64-latest.args | 4 +- ...rtio-options-net-packed.x86_64-latest.args | 4 +- .../virtio-options-rng-ats.x86_64-latest.args | 4 +- ...irtio-options-rng-iommu.x86_64-latest.args | 4 +- ...rtio-options-rng-packed.x86_64-latest.args | 4 +- ...irtio-options-video-ats.x86_64-latest.args | 4 +- ...tio-options-video-iommu.x86_64-latest.args | 4 +- ...io-options-video-packed.x86_64-latest.args | 4 +- .../virtio-options.x86_64-latest.args | 22 +++++------ 24 files changed, 72 insertions(+), 69 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index de7278bcdd..60404b6dd8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -875,6 +875,7 @@ static int qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, virQEMUCaps *qemuCaps, char **devtype, + virDomainVirtioOptions **virtioOptions, virTristateSwitch *disableLegacy, virTristateSwitch *disableModern) { @@ -885,13 +886,12 @@ qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, bool has_tmodel = false; bool has_ntmodel = false; bool useBusSuffix = true; - virDomainVirtioOptions *virtioOptions; *disableLegacy = VIR_TRISTATE_SWITCH_ABSENT; *disableModern = VIR_TRISTATE_SWITCH_ABSENT; qemuBuildVirtioDevGetConfigDev(device, qemuCaps, &baseName, - &virtioOptions, &has_tmodel, + virtioOptions, &has_tmodel, &has_ntmodel, &useBusSuffix); if (!baseName) { @@ -1004,10 +1004,11 @@ qemuBuildVirtioDevStr(virBuffer *buf, g_autofree char *model = NULL; virTristateSwitch disableLegacy = VIR_TRISTATE_SWITCH_ABSENT; virTristateSwitch disableModern = VIR_TRISTATE_SWITCH_ABSENT; + virDomainVirtioOptions *virtioOptions = NULL; virDomainDeviceSetData(&device, devdata); - if (qemuBuildVirtioDevGetConfig(&device, qemuCaps, &model, + if (qemuBuildVirtioDevGetConfig(&device, qemuCaps, &model, &virtioOptions, &disableLegacy, &disableModern) < 0) return -1; @@ -1023,28 +1024,30 @@ qemuBuildVirtioDevStr(virBuffer *buf, virTristateSwitchTypeToString(disableModern)); } + if (virtioOptions) { + if (virtioOptions->iommu != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(buf, ",iommu_platform=%s", + virTristateSwitchTypeToString(virtioOptions->iommu)); + } + if (virtioOptions->ats != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(buf, ",ats=%s", + virTristateSwitchTypeToString(virtioOptions->ats)); + } + if (virtioOptions->packed != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(buf, ",packed=%s", + virTristateSwitchTypeToString(virtioOptions->packed)); + } + } + return 0; } static void -qemuBuildVirtioOptionsStr(virBuffer *buf, - virDomainVirtioOptions *virtio) +qemuBuildVirtioOptionsStr(virBuffer *buf G_GNUC_UNUSED, + virDomainVirtioOptions *virtio G_GNUC_UNUSED) { if (!virtio) return; - - if (virtio->iommu != VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAsprintf(buf, ",iommu_platform=%s", - virTristateSwitchTypeToString(virtio->iommu)); - } - if (virtio->ats != VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAsprintf(buf, ",ats=%s", - virTristateSwitchTypeToString(virtio->ats)); - } - if (virtio->packed != VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAsprintf(buf, ",packed=%s", - virTristateSwitchTypeToString(virtio->packed)); - } } static int diff --git a/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args b/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args index 7b6ae2c0e4..84baab8570 100644 --- a/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args +++ b/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args @@ -31,5 +31,5 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -audiodev id=audio1,driver=none \ -device virtio-balloon-ccw,id=balloon0,devno=fe.0.0001 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ --device vhost-vsock-ccw,id=vsock0,guest-cid=4,vhostfd=6789,iommu_platform=on,devno=fe.0.0002 \ +-device vhost-vsock-ccw,iommu_platform=on,id=vsock0,guest-cid=4,vhostfd=6789,devno=fe.0.0002 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-options-controller-ats.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-controller-ats.x86_64-latest.args index b6599e614c..5ac1467fae 100644 --- a/tests/qemuxml2argvdata/virtio-options-controller-ats.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-controller-ats.x86_64-latest.args @@ -29,8 +29,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -device virtio-scsi-pci,ats=on,id=scsi0,bus=pci.0,addr=0x2 \ -device virtio-scsi-pci,ats=off,id=scsi1,bus=pci.0,addr=0x3 \ --device virtio-serial-pci,id=virtio-serial0,ats=on,bus=pci.0,addr=0x4 \ --device virtio-serial-pci,id=virtio-serial1,ats=off,bus=pci.0,addr=0x5 \ +-device virtio-serial-pci,ats=on,id=virtio-serial0,bus=pci.0,addr=0x4 \ +-device virtio-serial-pci,ats=off,id=virtio-serial1,bus=pci.0,addr=0x5 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/virtio-options-controller-iommu.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-controller-iommu.x86_64-latest.args index c8b52d0103..3b48553883 100644 --- a/tests/qemuxml2argvdata/virtio-options-controller-iommu.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-controller-iommu.x86_64-latest.args @@ -29,8 +29,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -device virtio-scsi-pci,iommu_platform=on,id=scsi0,bus=pci.0,addr=0x2 \ -device virtio-scsi-pci,iommu_platform=off,id=scsi1,bus=pci.0,addr=0x3 \ --device virtio-serial-pci,id=virtio-serial0,iommu_platform=on,bus=pci.0,addr=0x4 \ --device virtio-serial-pci,id=virtio-serial1,iommu_platform=off,bus=pci.0,addr=0x5 \ +-device virtio-serial-pci,iommu_platform=on,id=virtio-serial0,bus=pci.0,addr=0x4 \ +-device virtio-serial-pci,iommu_platform=off,id=virtio-serial1,bus=pci.0,addr=0x5 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/virtio-options-controller-packed.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-controller-packed.x86_64-latest.args index 80422a9512..19a318c4fb 100644 --- a/tests/qemuxml2argvdata/virtio-options-controller-packed.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-controller-packed.x86_64-latest.args @@ -29,8 +29,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -device virtio-scsi-pci,packed=on,id=scsi0,bus=pci.0,addr=0x2 \ -device virtio-scsi-pci,packed=off,id=scsi1,bus=pci.0,addr=0x3 \ --device virtio-serial-pci,id=virtio-serial0,packed=on,bus=pci.0,addr=0x4 \ --device virtio-serial-pci,id=virtio-serial1,packed=off,bus=pci.0,addr=0x5 \ +-device virtio-serial-pci,packed=on,id=virtio-serial0,bus=pci.0,addr=0x4 \ +-device virtio-serial-pci,packed=off,id=virtio-serial1,bus=pci.0,addr=0x5 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/virtio-options-fs-ats.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-fs-ats.x86_64-latest.args index 35af0024a7..6956c7bdc6 100644 --- a/tests/qemuxml2argvdata/virtio-options-fs-ats.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-fs-ats.x86_64-latest.args @@ -28,9 +28,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ --device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,ats=on,bus=pci.0,addr=0x2 \ +-device virtio-9p-pci,ats=on,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.0,addr=0x2 \ -fsdev local,security_model=passthrough,id=fsdev-fs1,path=/export/fs2 \ --device virtio-9p-pci,id=fs1,fsdev=fsdev-fs1,mount_tag=fs2,ats=off,bus=pci.0,addr=0x3 \ +-device virtio-9p-pci,ats=off,id=fs1,fsdev=fsdev-fs1,mount_tag=fs2,bus=pci.0,addr=0x3 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/virtio-options-fs-iommu.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-fs-iommu.x86_64-latest.args index a7e60e9ffa..d964d11f8a 100644 --- a/tests/qemuxml2argvdata/virtio-options-fs-iommu.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-fs-iommu.x86_64-latest.args @@ -28,9 +28,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ --device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,iommu_platform=on,bus=pci.0,addr=0x2 \ +-device virtio-9p-pci,iommu_platform=on,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.0,addr=0x2 \ -fsdev local,security_model=passthrough,id=fsdev-fs1,path=/export/fs2 \ --device virtio-9p-pci,id=fs1,fsdev=fsdev-fs1,mount_tag=fs2,iommu_platform=off,bus=pci.0,addr=0x3 \ +-device virtio-9p-pci,iommu_platform=off,id=fs1,fsdev=fsdev-fs1,mount_tag=fs2,bus=pci.0,addr=0x3 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/virtio-options-fs-packed.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-fs-packed.x86_64-latest.args index 3a27a6d0ca..5eac96bead 100644 --- a/tests/qemuxml2argvdata/virtio-options-fs-packed.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-fs-packed.x86_64-latest.args @@ -28,9 +28,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ --device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,packed=on,bus=pci.0,addr=0x2 \ +-device virtio-9p-pci,packed=on,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.0,addr=0x2 \ -fsdev local,security_model=passthrough,id=fsdev-fs1,path=/export/fs2 \ --device virtio-9p-pci,id=fs1,fsdev=fsdev-fs1,mount_tag=fs2,packed=off,bus=pci.0,addr=0x3 \ +-device virtio-9p-pci,packed=off,id=fs1,fsdev=fsdev-fs1,mount_tag=fs2,bus=pci.0,addr=0x3 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/virtio-options-input-ats.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-input-ats.x86_64-latest.args index b4f9b34472..5997192c91 100644 --- a/tests/qemuxml2argvdata/virtio-options-input-ats.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-input-ats.x86_64-latest.args @@ -27,8 +27,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-acpi \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ --device virtio-mouse-pci,id=input0,bus=pci.0,addr=0x2,ats=on \ --device virtio-keyboard-pci,id=input1,bus=pci.0,addr=0x3,ats=off \ +-device virtio-mouse-pci,ats=on,id=input0,bus=pci.0,addr=0x2 \ +-device virtio-keyboard-pci,ats=off,id=input1,bus=pci.0,addr=0x3 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/virtio-options-input-iommu.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-input-iommu.x86_64-latest.args index 7e4c8a9474..a956781626 100644 --- a/tests/qemuxml2argvdata/virtio-options-input-iommu.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-input-iommu.x86_64-latest.args @@ -27,8 +27,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-acpi \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ --device virtio-mouse-pci,id=input0,bus=pci.0,addr=0x2,iommu_platform=on \ --device virtio-keyboard-pci,id=input1,bus=pci.0,addr=0x3,iommu_platform=off \ +-device virtio-mouse-pci,iommu_platform=on,id=input0,bus=pci.0,addr=0x2 \ +-device virtio-keyboard-pci,iommu_platform=off,id=input1,bus=pci.0,addr=0x3 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/virtio-options-input-packed.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-input-packed.x86_64-latest.args index 34705667aa..8a1be03de2 100644 --- a/tests/qemuxml2argvdata/virtio-options-input-packed.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-input-packed.x86_64-latest.args @@ -27,8 +27,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-acpi \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ --device virtio-mouse-pci,id=input0,bus=pci.0,addr=0x2,packed=on \ --device virtio-keyboard-pci,id=input1,bus=pci.0,addr=0x3,packed=off \ +-device virtio-mouse-pci,packed=on,id=input0,bus=pci.0,addr=0x2 \ +-device virtio-keyboard-pci,packed=off,id=input1,bus=pci.0,addr=0x3 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/virtio-options-memballoon-ats.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-memballoon-ats.x86_64-latest.args index 08bca52dc4..184b84ea39 100644 --- a/tests/qemuxml2argvdata/virtio-options-memballoon-ats.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-memballoon-ats.x86_64-latest.args @@ -28,6 +28,6 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -audiodev id=audio1,driver=none \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2,ats=on \ +-device virtio-balloon-pci,ats=on,id=balloon0,bus=pci.0,addr=0x2 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-options-memballoon-iommu.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-memballoon-iommu.x86_64-latest.args index 21fc2f6f8a..2b08aeee01 100644 --- a/tests/qemuxml2argvdata/virtio-options-memballoon-iommu.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-memballoon-iommu.x86_64-latest.args @@ -28,6 +28,6 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -audiodev id=audio1,driver=none \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2,iommu_platform=on \ +-device virtio-balloon-pci,iommu_platform=on,id=balloon0,bus=pci.0,addr=0x2 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-options-memballoon-packed.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-memballoon-packed.x86_64-latest.args index 4d54b6a68d..865e81eb21 100644 --- a/tests/qemuxml2argvdata/virtio-options-memballoon-packed.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-memballoon-packed.x86_64-latest.args @@ -28,6 +28,6 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -audiodev id=audio1,driver=none \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2,packed=on \ +-device virtio-balloon-pci,packed=on,id=balloon0,bus=pci.0,addr=0x2 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-options-net-ats.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-net-ats.x86_64-latest.args index 87a05d8b79..8ec2387405 100644 --- a/tests/qemuxml2argvdata/virtio-options-net-ats.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-net-ats.x86_64-latest.args @@ -28,9 +28,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -netdev user,id=hostnet0 \ --device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:56:58:5a:5c,bus=pci.0,addr=0x2,ats=on \ +-device virtio-net-pci,ats=on,netdev=hostnet0,id=net0,mac=52:54:56:58:5a:5c,bus=pci.0,addr=0x2 \ -netdev user,id=hostnet1 \ --device virtio-net-pci,netdev=hostnet1,id=net1,mac=62:64:66:68:6a:6c,bus=pci.0,addr=0x3,ats=off \ +-device virtio-net-pci,ats=off,netdev=hostnet1,id=net1,mac=62:64:66:68:6a:6c,bus=pci.0,addr=0x3 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/virtio-options-net-iommu.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-net-iommu.x86_64-latest.args index dcd62e69a1..76a7944029 100644 --- a/tests/qemuxml2argvdata/virtio-options-net-iommu.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-net-iommu.x86_64-latest.args @@ -28,9 +28,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -netdev user,id=hostnet0 \ --device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:56:58:5a:5c,bus=pci.0,addr=0x2,iommu_platform=on \ +-device virtio-net-pci,iommu_platform=on,netdev=hostnet0,id=net0,mac=52:54:56:58:5a:5c,bus=pci.0,addr=0x2 \ -netdev user,id=hostnet1 \ --device virtio-net-pci,netdev=hostnet1,id=net1,mac=62:64:66:68:6a:6c,bus=pci.0,addr=0x3,iommu_platform=off \ +-device virtio-net-pci,iommu_platform=off,netdev=hostnet1,id=net1,mac=62:64:66:68:6a:6c,bus=pci.0,addr=0x3 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/virtio-options-net-packed.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-net-packed.x86_64-latest.args index 7f6d04708e..b8d7a971fa 100644 --- a/tests/qemuxml2argvdata/virtio-options-net-packed.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-net-packed.x86_64-latest.args @@ -28,9 +28,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -netdev user,id=hostnet0 \ --device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:56:58:5a:5c,bus=pci.0,addr=0x2,packed=on \ +-device virtio-net-pci,packed=on,netdev=hostnet0,id=net0,mac=52:54:56:58:5a:5c,bus=pci.0,addr=0x2 \ -netdev user,id=hostnet1 \ --device virtio-net-pci,netdev=hostnet1,id=net1,mac=62:64:66:68:6a:6c,bus=pci.0,addr=0x3,packed=off \ +-device virtio-net-pci,packed=off,netdev=hostnet1,id=net1,mac=62:64:66:68:6a:6c,bus=pci.0,addr=0x3 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/virtio-options-rng-ats.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-rng-ats.x86_64-latest.args index a6318c1a3c..936da98242 100644 --- a/tests/qemuxml2argvdata/virtio-options-rng-ats.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-rng-ats.x86_64-latest.args @@ -30,8 +30,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -object '{"qom-type":"rng-random","id":"objrng0","filename":"/dev/random"}' \ --device virtio-rng-pci,rng=objrng0,id=rng0,ats=on,bus=pci.0,addr=0x2 \ +-device virtio-rng-pci,ats=on,rng=objrng0,id=rng0,bus=pci.0,addr=0x2 \ -object '{"qom-type":"rng-random","id":"objrng1","filename":"/dev/random"}' \ --device virtio-rng-pci,rng=objrng1,id=rng1,ats=off,bus=pci.0,addr=0x3 \ +-device virtio-rng-pci,ats=off,rng=objrng1,id=rng1,bus=pci.0,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-options-rng-iommu.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-rng-iommu.x86_64-latest.args index 176f4231e0..ff52853bee 100644 --- a/tests/qemuxml2argvdata/virtio-options-rng-iommu.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-rng-iommu.x86_64-latest.args @@ -30,8 +30,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -object '{"qom-type":"rng-random","id":"objrng0","filename":"/dev/random"}' \ --device virtio-rng-pci,rng=objrng0,id=rng0,iommu_platform=on,bus=pci.0,addr=0x2 \ +-device virtio-rng-pci,iommu_platform=on,rng=objrng0,id=rng0,bus=pci.0,addr=0x2 \ -object '{"qom-type":"rng-random","id":"objrng1","filename":"/dev/random"}' \ --device virtio-rng-pci,rng=objrng1,id=rng1,iommu_platform=off,bus=pci.0,addr=0x3 \ +-device virtio-rng-pci,iommu_platform=off,rng=objrng1,id=rng1,bus=pci.0,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-options-rng-packed.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-rng-packed.x86_64-latest.args index 667a577161..4c1a727ff8 100644 --- a/tests/qemuxml2argvdata/virtio-options-rng-packed.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-rng-packed.x86_64-latest.args @@ -30,8 +30,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -object '{"qom-type":"rng-random","id":"objrng0","filename":"/dev/random"}' \ --device virtio-rng-pci,rng=objrng0,id=rng0,packed=on,bus=pci.0,addr=0x2 \ +-device virtio-rng-pci,packed=on,rng=objrng0,id=rng0,bus=pci.0,addr=0x2 \ -object '{"qom-type":"rng-random","id":"objrng1","filename":"/dev/random"}' \ --device virtio-rng-pci,rng=objrng1,id=rng1,packed=off,bus=pci.0,addr=0x3 \ +-device virtio-rng-pci,packed=off,rng=objrng1,id=rng1,bus=pci.0,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-options-video-ats.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-video-ats.x86_64-latest.args index bbef4b29e9..b2a944bb34 100644 --- a/tests/qemuxml2argvdata/virtio-options-video-ats.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-video-ats.x86_64-latest.args @@ -30,8 +30,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -audiodev id=audio1,driver=none \ -chardev socket,id=chr-vu-video0,fd=1729 \ -chardev socket,id=chr-vu-video1,fd=1729 \ --device vhost-user-vga,id=video0,max_outputs=1,chardev=chr-vu-video0,bus=pci.0,addr=0x2,ats=on \ --device vhost-user-gpu-pci,id=video1,max_outputs=1,chardev=chr-vu-video1,bus=pci.0,addr=0x3,ats=off \ +-device vhost-user-vga,id=video0,max_outputs=1,chardev=chr-vu-video0,bus=pci.0,addr=0x2 \ +-device vhost-user-gpu-pci,ats=off,id=video1,max_outputs=1,chardev=chr-vu-video1,bus=pci.0,addr=0x3 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-options-video-iommu.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-video-iommu.x86_64-latest.args index c5b2f48aee..23808318cc 100644 --- a/tests/qemuxml2argvdata/virtio-options-video-iommu.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-video-iommu.x86_64-latest.args @@ -30,8 +30,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -audiodev id=audio1,driver=none \ -chardev socket,id=chr-vu-video0,fd=1729 \ -chardev socket,id=chr-vu-video1,fd=1729 \ --device vhost-user-vga,id=video0,max_outputs=1,chardev=chr-vu-video0,bus=pci.0,addr=0x2,iommu_platform=on \ --device vhost-user-gpu-pci,id=video1,max_outputs=1,chardev=chr-vu-video1,bus=pci.0,addr=0x3,iommu_platform=off \ +-device vhost-user-vga,id=video0,max_outputs=1,chardev=chr-vu-video0,bus=pci.0,addr=0x2 \ +-device vhost-user-gpu-pci,iommu_platform=off,id=video1,max_outputs=1,chardev=chr-vu-video1,bus=pci.0,addr=0x3 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-options-video-packed.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-video-packed.x86_64-latest.args index dcccd58d63..f431df9062 100644 --- a/tests/qemuxml2argvdata/virtio-options-video-packed.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-video-packed.x86_64-latest.args @@ -30,8 +30,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -audiodev id=audio1,driver=none \ -chardev socket,id=chr-vu-video0,fd=1729 \ -chardev socket,id=chr-vu-video1,fd=1729 \ --device vhost-user-vga,id=video0,max_outputs=1,chardev=chr-vu-video0,bus=pci.0,addr=0x2,packed=on \ --device vhost-user-gpu-pci,id=video1,max_outputs=1,chardev=chr-vu-video1,bus=pci.0,addr=0x3,packed=off \ +-device vhost-user-vga,id=video0,max_outputs=1,chardev=chr-vu-video0,bus=pci.0,addr=0x2 \ +-device vhost-user-gpu-pci,packed=off,id=video1,max_outputs=1,chardev=chr-vu-video1,bus=pci.0,addr=0x3 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-options.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options.x86_64-latest.args index 06a4520036..d6dcbdd90f 100644 --- a/tests/qemuxml2argvdata/virtio-options.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options.x86_64-latest.args @@ -28,25 +28,25 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -device virtio-scsi-pci,iommu_platform=on,ats=on,packed=on,id=scsi0,bus=pci.0,addr=0x8 \ --device virtio-serial-pci,id=virtio-serial0,iommu_platform=on,ats=on,packed=on,bus=pci.0,addr=0x9 \ +-device virtio-serial-pci,iommu_platform=on,ats=on,packed=on,id=virtio-serial0,bus=pci.0,addr=0x9 \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/img1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ -device virtio-blk-pci,iommu_platform=on,ats=on,packed=on,bus=pci.0,addr=0xa,drive=libvirt-1-format,id=virtio-disk0,bootindex=1 \ -fsdev local,security_model=passthrough,id=fsdev-fs0,path=/export/fs1 \ --device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,iommu_platform=on,ats=on,packed=on,bus=pci.0,addr=0x3 \ +-device virtio-9p-pci,iommu_platform=on,ats=on,packed=on,id=fs0,fsdev=fsdev-fs0,mount_tag=fs1,bus=pci.0,addr=0x3 \ -fsdev local,security_model=mapped,writeout=immediate,id=fsdev-fs1,path=/export/fs2 \ --device virtio-9p-pci,id=fs1,fsdev=fsdev-fs1,mount_tag=fs2,iommu_platform=on,ats=on,packed=on,bus=pci.0,addr=0x4 \ +-device virtio-9p-pci,iommu_platform=on,ats=on,packed=on,id=fs1,fsdev=fsdev-fs1,mount_tag=fs2,bus=pci.0,addr=0x4 \ -netdev user,id=hostnet0 \ --device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:56:58:5a:5c,bus=pci.0,addr=0x6,iommu_platform=on,ats=on,packed=on \ --device virtio-mouse-pci,id=input0,bus=pci.0,addr=0xe,iommu_platform=on,ats=on,packed=on \ --device virtio-keyboard-pci,id=input1,bus=pci.0,addr=0x10,iommu_platform=on,ats=on,packed=on \ --device virtio-tablet-pci,id=input2,bus=pci.0,addr=0x11,iommu_platform=on,ats=on,packed=on \ --device virtio-input-host-pci,id=input3,evdev=/dev/input/event1234,bus=pci.0,addr=0x12,iommu_platform=on,ats=on,packed=on \ +-device virtio-net-pci,iommu_platform=on,ats=on,packed=on,netdev=hostnet0,id=net0,mac=52:54:56:58:5a:5c,bus=pci.0,addr=0x6 \ +-device virtio-mouse-pci,iommu_platform=on,ats=on,packed=on,id=input0,bus=pci.0,addr=0xe \ +-device virtio-keyboard-pci,iommu_platform=on,ats=on,packed=on,id=input1,bus=pci.0,addr=0x10 \ +-device virtio-tablet-pci,iommu_platform=on,ats=on,packed=on,id=input2,bus=pci.0,addr=0x11 \ +-device virtio-input-host-pci,iommu_platform=on,ats=on,packed=on,id=input3,evdev=/dev/input/event1234,bus=pci.0,addr=0x12 \ -audiodev id=audio1,driver=none \ -chardev socket,id=chr-vu-video0,fd=1729 \ --device vhost-user-vga,id=video0,max_outputs=1,chardev=chr-vu-video0,bus=pci.0,addr=0x2,iommu_platform=on,ats=on,packed=on \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0xc,iommu_platform=on,ats=on,packed=on \ +-device vhost-user-vga,id=video0,max_outputs=1,chardev=chr-vu-video0,bus=pci.0,addr=0x2 \ +-device virtio-balloon-pci,iommu_platform=on,ats=on,packed=on,id=balloon0,bus=pci.0,addr=0xc \ -object '{"qom-type":"rng-random","id":"objrng0","filename":"/dev/random"}' \ --device virtio-rng-pci,rng=objrng0,id=rng0,iommu_platform=on,ats=on,packed=on,bus=pci.0,addr=0xd \ +-device virtio-rng-pci,iommu_platform=on,ats=on,packed=on,rng=objrng0,id=rng0,bus=pci.0,addr=0xd \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Merge the code from qemuBuildVirtioOptionsStr so that we don't have to call two separate functions.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 39 ++++++++++--------- .../vhost-vsock-ccw-iommu.s390x-latest.args | 2 +- ...-options-controller-ats.x86_64-latest.args | 4 +- ...ptions-controller-iommu.x86_64-latest.args | 4 +- ...tions-controller-packed.x86_64-latest.args | 4 +- .../virtio-options-fs-ats.x86_64-latest.args | 4 +- ...virtio-options-fs-iommu.x86_64-latest.args | 4 +- ...irtio-options-fs-packed.x86_64-latest.args | 4 +- ...irtio-options-input-ats.x86_64-latest.args | 4 +- ...tio-options-input-iommu.x86_64-latest.args | 4 +- ...io-options-input-packed.x86_64-latest.args | 4 +- ...-options-memballoon-ats.x86_64-latest.args | 2 +- ...ptions-memballoon-iommu.x86_64-latest.args | 2 +- ...tions-memballoon-packed.x86_64-latest.args | 2 +- .../virtio-options-net-ats.x86_64-latest.args | 4 +- ...irtio-options-net-iommu.x86_64-latest.args | 4 +- ...rtio-options-net-packed.x86_64-latest.args | 4 +- .../virtio-options-rng-ats.x86_64-latest.args | 4 +- ...irtio-options-rng-iommu.x86_64-latest.args | 4 +- ...rtio-options-rng-packed.x86_64-latest.args | 4 +- ...irtio-options-video-ats.x86_64-latest.args | 4 +- ...tio-options-video-iommu.x86_64-latest.args | 4 +- ...io-options-video-packed.x86_64-latest.args | 4 +- .../virtio-options.x86_64-latest.args | 22 +++++------ 24 files changed, 72 insertions(+), 69 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 60404b6dd8..daaccff9b6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1042,13 +1042,6 @@ qemuBuildVirtioDevStr(virBuffer *buf, return 0; } -static void -qemuBuildVirtioOptionsStr(virBuffer *buf G_GNUC_UNUSED, - virDomainVirtioOptions *virtio G_GNUC_UNUSED) -{ - if (!virtio) - return; -} static int qemuBuildRomStr(virBuffer *buf, @@ -2026,8 +2019,6 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, virBufferAsprintf(&opt, ",queue-size=%u", disk->queue_size); } - qemuBuildVirtioOptionsStr(&opt, disk->virtio); - if (qemuBuildDeviceAddressStr(&opt, def, &disk->info) < 0) return NULL; break; @@ -2455,7 +2446,6 @@ qemuBuildVHostUserFsDevStr(virDomainFSDef *fs, virBufferAsprintf(&buf, ",queue-size=%llu", fs->queue_size); virBufferAddLit(&buf, ",tag="); virQEMUBuildBufferEscapeComma(&buf, fs->dst); - qemuBuildVirtioOptionsStr(&buf, fs->virtio); if (fs->info.bootIndex) virBufferAsprintf(&buf, ",bootindex=%u", fs->info.bootIndex); @@ -2560,8 +2550,6 @@ qemuBuildFSDevStr(const virDomainDef *def, virBufferAddLit(&opt, ",mount_tag="); virQEMUBuildBufferEscapeComma(&opt, fs->dst); - qemuBuildVirtioOptionsStr(&opt, fs->virtio); - if (qemuBuildDeviceAddressStr(&opt, def, &fs->info) < 0) return NULL; @@ -2789,8 +2777,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, virBufferAsprintf(&buf, ",iothread=iothread%u", def->iothread); } - - qemuBuildVirtioOptionsStr(&buf, def->virtio); break; case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: virBufferAddLit(&buf, "lsi"); @@ -2844,7 +2830,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, virBufferAsprintf(&buf, ",vectors=%d", def->opts.vioserial.vectors); } - qemuBuildVirtioOptionsStr(&buf, def->virtio); break; case VIR_DOMAIN_CONTROLLER_TYPE_CCID: @@ -3853,8 +3838,6 @@ qemuBuildNicDevStr(virDomainDef *def, return NULL; if (bootindex) virBufferAsprintf(&buf, ",bootindex=%u", bootindex); - if (usingVirtio) - qemuBuildVirtioOptionsStr(&buf, net->virtio); return virBufferContentAndReset(&buf); } @@ -4144,8 +4127,6 @@ qemuBuildMemballoonCommandLine(virCommand *cmd, virTristateSwitchTypeToString(def->memballoon->free_page_reporting)); } - qemuBuildVirtioOptionsStr(&buf, def->memballoon->virtio); - if (qemuCommandAddExtDevice(cmd, &def->memballoon->info) < 0) return -1; @@ -4220,8 +4201,6 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def, if (qemuBuildDeviceAddressStr(&buf, def, &dev->info) < 0) return NULL; - qemuBuildVirtioOptionsStr(&buf, dev->virtio); - return virBufferContentAndReset(&buf); } @@ -4571,8 +4550,6 @@ qemuBuildDeviceVideoStr(const virDomainDef *def, if (qemuBuildDeviceAddressStr(&buf, def, &video->info) < 0) return NULL; - qemuBuildVirtioOptionsStr(&buf, video->virtio); - return virBufferContentAndReset(&buf); } @@ -5755,8 +5732,6 @@ qemuBuildRNGDevStr(const virDomainDef *def, virBufferAddLit(&buf, ",period=1000"); } - qemuBuildVirtioOptionsStr(&buf, dev->virtio); - if (qemuBuildDeviceAddressStr(&buf, def, &dev->info) < 0) return NULL; @@ -10432,8 +10407,6 @@ qemuBuildVsockDevStr(virDomainDef *def, virBufferAsprintf(&buf, ",guest-cid=%u", vsock->guest_cid); virBufferAsprintf(&buf, ",vhostfd=%s%u", fdprefix, priv->vhostfd); - qemuBuildVirtioOptionsStr(&buf, vsock->virtio); - if (qemuBuildDeviceAddressStr(&buf, def, &vsock->info) < 0) return NULL; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 27 --------------------------- 1 file changed, 27 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

'virtio-vga' is a virtio device but we didn't use the virtio formatter for it. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index daaccff9b6..dc3320ba9a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4475,7 +4475,7 @@ qemuBuildDeviceVideoStr(const virDomainDef *def, if (!(model = qemuDeviceVideoGetModel(qemuCaps, video, &virtio, &virtioBusSuffix))) return NULL; - if (virtioBusSuffix) { + if (virtio) { if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_VIDEO, video) < 0) { return NULL; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
'virtio-vga' is a virtio device but we didn't use the virtio formatter for it.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

'effectiveBootIndex' is a copy of 'bootIndex' if '<boot order=' was present and left unassigned if not. This allows hypervisor drivers to reinterpret <os><boot> without being visible in the XML. QEMU driver had a internal implementation for disks, which is now replaced. Additionally this will simplify a refactor of network boot assignment. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/device_conf.h | 4 ++++ src/conf/domain_conf.c | 2 ++ src/qemu/qemu_command.c | 10 ++++------ src/qemu/qemu_domain.h | 4 ---- src/qemu/qemu_process.c | 15 ++++++--------- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index 09ef5dda92..d118966379 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -149,6 +149,10 @@ struct _virDomainDeviceInfo { /* bootIndex is only used for disk, network interface, hostdev * and redirdev devices */ unsigned int bootIndex; + /* 'effectiveBootIndex' is same as 'bootIndex' (if provided in the XML) but + * not formatted back. This allows HV drivers to update it if <os><boot .. + * is present. */ + unsigned int effectiveBootIndex; /* Valid for any PCI device. Can be used for NIC to get * stable numbering in Linux */ unsigned int acpiIndex; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b8370f6950..6b89b9404c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6492,6 +6492,8 @@ virDomainDeviceBootParseXML(xmlNodePtr node, &info->bootIndex) < 0) return -1; + info->effectiveBootIndex = info->bootIndex; + loadparm = virXMLPropString(node, "loadparm"); if (loadparm) { if (virStringToUpper(&info->loadparm, loadparm) != 1) { diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index dc3320ba9a..07a8f104f4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1862,7 +1862,6 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, virDomainDiskDef *disk, virQEMUCaps *qemuCaps) { - qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER; const char *contAlias; g_autofree char *backendAlias = NULL; @@ -2065,8 +2064,8 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, virBufferAsprintf(&opt, ",id=%s", disk->info.alias); /* bootindex for floppies is configured via the fdc controller */ if (disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY && - diskPriv->effectiveBootindex > 0) - virBufferAsprintf(&opt, ",bootindex=%u", diskPriv->effectiveBootindex); + disk->info.effectiveBootIndex > 0) + virBufferAsprintf(&opt, ",bootindex=%u", disk->info.effectiveBootIndex); if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKIO)) { if (disk->blockio.logical_block_size > 0) virBufferAsprintf(&opt, ",logical_block_size=%u", @@ -2180,7 +2179,6 @@ qemuBuildFloppyCommandLineControllerOptions(virCommand *cmd, g_autofree char *backendStr = NULL; g_autofree char *bootindexStr = NULL; virDomainDiskDef *disk = def->disks[i]; - qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); if (disk->bus != VIR_DOMAIN_DISK_BUS_FDC) continue; @@ -2192,9 +2190,9 @@ qemuBuildFloppyCommandLineControllerOptions(virCommand *cmd, else driveLetter = 'A'; - if (diskPriv->effectiveBootindex > 0) + if (disk->info.effectiveBootIndex > 0) bootindexStr = g_strdup_printf("bootindex%c=%u", driveLetter, - diskPriv->effectiveBootindex); + disk->info.effectiveBootIndex); /* with -blockdev we setup the floppy device and it's backend with -device */ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 31971e29ac..9cf5d5479e 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -270,10 +270,6 @@ struct _qemuDomainDiskPrivate { char *qomName; /* QOM path of the disk (also refers to the block backend) */ char *nodeCopyOnRead; /* nodename of the disk-wide copy-on-read blockdev layer */ - unsigned int effectiveBootindex; /* boot index of the disk based on one - of the two ways we use to select a boot - device */ - bool transientOverlayCreated; /* the overlay image of a transient disk was created and the definition was updated */ }; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 09a2ff8ef2..f5c28ed4bf 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6271,6 +6271,9 @@ qemuProcessPrepareDomainDiskBootorder(virDomainDef *def) unsigned int bootFloppy = 0; unsigned int bootDisk = 0; + if (def->os.nBootDevs == 0) + return; + for (i = 0; i < def->os.nBootDevs; i++) { switch ((virDomainBootOrder) def->os.bootDevs[i]) { case VIR_DOMAIN_BOOT_CDROM: @@ -6295,27 +6298,21 @@ qemuProcessPrepareDomainDiskBootorder(virDomainDef *def) for (i = 0; i < def->ndisks; i++) { virDomainDiskDef *disk = def->disks[i]; - qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); - - if (disk->info.bootIndex > 0) { - diskPriv->effectiveBootindex = disk->info.bootIndex; - continue; - } switch (disk->device) { case VIR_DOMAIN_DISK_DEVICE_CDROM: - diskPriv->effectiveBootindex = bootCD; + disk->info.effectiveBootIndex = bootCD; bootCD = 0; break; case VIR_DOMAIN_DISK_DEVICE_DISK: case VIR_DOMAIN_DISK_DEVICE_LUN: - diskPriv->effectiveBootindex = bootDisk; + disk->info.effectiveBootIndex = bootDisk; bootDisk = 0; break; case VIR_DOMAIN_DISK_DEVICE_FLOPPY: - diskPriv->effectiveBootindex = bootFloppy; + disk->info.effectiveBootIndex = bootFloppy; bootFloppy = 0; break; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
'effectiveBootIndex' is a copy of 'bootIndex' if '<boot order=' was present and left unassigned if not. This allows hypervisor drivers to reinterpret <os><boot> without being visible in the XML.
QEMU driver had a internal implementation for disks, which is now replaced. Additionally this will simplify a refactor of network boot assignment.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/device_conf.h | 4 ++++ src/conf/domain_conf.c | 2 ++ src/qemu/qemu_command.c | 10 ++++------ src/qemu/qemu_domain.h | 4 ---- src/qemu/qemu_process.c | 15 ++++++--------- 5 files changed, 16 insertions(+), 19 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Rename it to 'qemuProcessPrepareDeviceBootorder' and call it from 'qemuProcessPrepareDomain' rather than 'qemuProcessPrepareDomainStorage'. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_process.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f5c28ed4bf..58fbb38c5e 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6264,7 +6264,7 @@ qemuProcessPrepareDomainNUMAPlacement(virDomainObj *vm) static void -qemuProcessPrepareDomainDiskBootorder(virDomainDef *def) +qemuProcessPrepareDeviceBootorder(virDomainDef *def) { size_t i; unsigned int bootCD = 0; @@ -6350,8 +6350,6 @@ qemuProcessPrepareDomainStorage(virQEMUDriver *driver, return -1; } - qemuProcessPrepareDomainDiskBootorder(vm->def); - return 0; } @@ -6559,6 +6557,8 @@ qemuProcessPrepareDomain(virQEMUDriver *driver, if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0) return -1; + qemuProcessPrepareDeviceBootorder(vm->def); + VIR_DEBUG("Setting graphics devices"); if (qemuProcessSetupGraphics(driver, vm, priv->qemuCaps, flags) < 0) return -1; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Rename it to 'qemuProcessPrepareDeviceBootorder' and call it from 'qemuProcessPrepareDomain' rather than 'qemuProcessPrepareDomainStorage'.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_process.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Fill in the effective boot index for network devices (or hostdev-backed network devices via 'qemuProcessPrepareDeviceBootorder'. This patch doesn't clean up the cruft to make it more obvious what's happening. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 14 ++++++-------- src/qemu/qemu_process.c | 27 ++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 07a8f104f4..bb91098c76 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3699,7 +3699,7 @@ qemuBuildLegacyNicStr(virDomainNetDef *net) char * qemuBuildNicDevStr(virDomainDef *def, virDomainNetDef *net, - unsigned int bootindex, + unsigned int bootindex G_GNUC_UNUSED, size_t vhostfdSize, virQEMUCaps *qemuCaps) { @@ -3834,8 +3834,8 @@ qemuBuildNicDevStr(virDomainDef *def, return NULL; if (qemuBuildRomStr(&buf, &net->info) < 0) return NULL; - if (bootindex) - virBufferAsprintf(&buf, ",bootindex=%u", bootindex); + if (net->info.effectiveBootIndex > 0) + virBufferAsprintf(&buf, ",bootindex=%u", net->info.effectiveBootIndex); return virBufferContentAndReset(&buf); } @@ -4621,7 +4621,7 @@ qemuBuildVideoCommandLine(virCommand *cmd, char * qemuBuildPCIHostdevDevStr(const virDomainDef *def, virDomainHostdevDef *dev, - unsigned int bootIndex, /* used iff dev->info->bootIndex == 0 */ + unsigned int bootIndex G_GNUC_UNUSED, virQEMUCaps *qemuCaps G_GNUC_UNUSED) { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; @@ -4653,10 +4653,8 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def, pcisrc->addr.slot, pcisrc->addr.function); virBufferAsprintf(&buf, ",id=%s", dev->info->alias); - if (dev->info->bootIndex) - bootIndex = dev->info->bootIndex; - if (bootIndex) - virBufferAsprintf(&buf, ",bootindex=%u", bootIndex); + if (dev->info->effectiveBootIndex > 0) + virBufferAsprintf(&buf, ",bootindex=%u", dev->info->effectiveBootIndex); if (qemuBuildDeviceAddressStr(&buf, def, dev->info) < 0) return NULL; if (qemuBuildRomStr(&buf, dev->info) < 0) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 58fbb38c5e..c3e994b1a2 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6270,6 +6270,7 @@ qemuProcessPrepareDeviceBootorder(virDomainDef *def) unsigned int bootCD = 0; unsigned int bootFloppy = 0; unsigned int bootDisk = 0; + unsigned int bootNetwork = 0; if (def->os.nBootDevs == 0) return; @@ -6289,7 +6290,9 @@ qemuProcessPrepareDeviceBootorder(virDomainDef *def) break; case VIR_DOMAIN_BOOT_NET: - /* network boot is handled in network device formatting code */ + bootNetwork = i + 1; + break; + case VIR_DOMAIN_BOOT_LAST: default: break; @@ -6321,6 +6324,28 @@ qemuProcessPrepareDeviceBootorder(virDomainDef *def) break; } } + + if (def->nnets > 0 && bootNetwork > 0) { + /* If network boot is enabled, the first network device gets enabled. If + * that one is backed by a host device, then we need to find the first + * corresponding host device */ + if (virDomainNetGetActualType(def->nets[0]) == VIR_DOMAIN_NET_TYPE_HOSTDEV) { + for (i = 0; i < def->nhostdevs; i++) { + virDomainHostdevDef *hostdev = def->hostdevs[i]; + virDomainHostdevSubsys *subsys = &hostdev->source.subsys; + + if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && + subsys->type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI && + hostdev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED && + hostdev->parentnet) { + hostdev->info->effectiveBootIndex = bootNetwork; + break; + } + } + } else { + def->nets[0]->info.effectiveBootIndex = bootNetwork; + } + } } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Fill in the effective boot index for network devices (or hostdev-backed network devices via 'qemuProcessPrepareDeviceBootorder'. This patch doesn't clean up the cruft to make it more obvious what's happening.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 14 ++++++-------- src/qemu/qemu_process.c | 27 ++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 9 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Remove the nw unused boot-index related attributes and the code which is assigning it. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 71 ++++++++--------------------------------- src/qemu/qemu_command.h | 2 -- src/qemu/qemu_hotplug.c | 5 ++- 3 files changed, 16 insertions(+), 62 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index bb91098c76..75a30f75ff 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3699,7 +3699,6 @@ qemuBuildLegacyNicStr(virDomainNetDef *net) char * qemuBuildNicDevStr(virDomainDef *def, virDomainNetDef *net, - unsigned int bootindex G_GNUC_UNUSED, size_t vhostfdSize, virQEMUCaps *qemuCaps) { @@ -4621,7 +4620,6 @@ qemuBuildVideoCommandLine(virCommand *cmd, char * qemuBuildPCIHostdevDevStr(const virDomainDef *def, virDomainHostdevDef *dev, - unsigned int bootIndex G_GNUC_UNUSED, virQEMUCaps *qemuCaps G_GNUC_UNUSED) { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; @@ -5389,8 +5387,7 @@ qemuBuildHostdevSCSICommandLine(virCommand *cmd, static int qemuBuildHostdevCommandLine(virCommand *cmd, const virDomainDef *def, - virQEMUCaps *qemuCaps, - unsigned int *bootHostdevNet) + virQEMUCaps *qemuCaps) { size_t i; @@ -5400,7 +5397,6 @@ qemuBuildHostdevCommandLine(virCommand *cmd, virDomainHostdevSubsysMediatedDev *mdevsrc = &subsys->u.mdev; g_autofree char *devstr = NULL; g_autofree char *vhostfdName = NULL; - unsigned int bootIndex = hostdev->info->bootIndex; int vhostfd = -1; if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) @@ -5419,14 +5415,6 @@ qemuBuildHostdevCommandLine(virCommand *cmd, /* PCI */ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: - /* bootNet will be non-0 if boot order was set and no other - * net devices were encountered - */ - if (hostdev->parentnet && bootIndex == 0) { - bootIndex = *bootHostdevNet; - *bootHostdevNet = 0; - } - /* Ignore unassigned devices */ if (hostdev->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED) continue; @@ -5435,7 +5423,7 @@ qemuBuildHostdevCommandLine(virCommand *cmd, return -1; virCommandAddArg(cmd, "-device"); - devstr = qemuBuildPCIHostdevDevStr(def, hostdev, bootIndex, qemuCaps); + devstr = qemuBuildPCIHostdevDevStr(def, hostdev, qemuCaps); if (!devstr) return -1; virCommandAddArg(cmd, devstr); @@ -8623,7 +8611,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, virCommand *cmd, virDomainNetDef *net, virQEMUCaps *qemuCaps, - unsigned int bootindex, virNetDevVPortProfileOp vmop, bool standalone, size_t *nnicindexes, @@ -8649,10 +8636,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, size_t i; g_autoptr(virJSONValue) hostnetprops = NULL; - - if (!bootindex) - bootindex = net->info.bootIndex; - if (qemuDomainValidateActualNetDef(net, qemuCaps) < 0) return -1; @@ -8898,8 +8881,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, if (qemuCommandAddExtDevice(cmd, &net->info) < 0) goto cleanup; - if (!(nic = qemuBuildNicDevStr(def, net, bootindex, - net->driver.virtio.queues, qemuCaps))) + if (!(nic = qemuBuildNicDevStr(def, net, net->driver.virtio.queues, qemuCaps))) goto cleanup; virCommandAddArgList(cmd, "-device", nic, NULL); } else if (!requireNicdev) { @@ -8959,47 +8941,23 @@ qemuBuildNetCommandLine(virQEMUDriver *driver, virNetDevVPortProfileOp vmop, bool standalone, size_t *nnicindexes, - int **nicindexes, - unsigned int *bootHostdevNet) + int **nicindexes) { size_t i; int last_good_net = -1; virErrorPtr originalError = NULL; virDomainDef *def = vm->def; - if (def->nnets) { - unsigned int bootNet = 0; - - /* convert <boot dev='network'/> to bootindex since we didn't emit -boot n */ - for (i = 0; i < def->os.nBootDevs; i++) { - if (def->os.bootDevs[i] == VIR_DOMAIN_BOOT_NET) { - bootNet = i + 1; - break; - } - } - - for (i = 0; i < def->nnets; i++) { - virDomainNetDef *net = def->nets[i]; + for (i = 0; i < def->nnets; i++) { + virDomainNetDef *net = def->nets[i]; - if (qemuBuildInterfaceCommandLine(driver, vm, logManager, secManager, cmd, net, - qemuCaps, bootNet, vmop, - standalone, nnicindexes, - nicindexes) < 0) - goto error; + if (qemuBuildInterfaceCommandLine(driver, vm, logManager, secManager, cmd, net, + qemuCaps, vmop, + standalone, nnicindexes, + nicindexes) < 0) + goto error; - last_good_net = i; - /* if this interface is a type='hostdev' interface and we - * haven't yet added a "bootindex" parameter to an - * emulated network device, save the bootindex - hostdev - * interface commandlines will be built later on when we - * cycle through all the hostdevs, and we'll use it then. - */ - if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_HOSTDEV && - *bootHostdevNet == 0) { - *bootHostdevNet = bootNet; - } - bootNet = 0; - } + last_good_net = i; } return 0; @@ -10534,7 +10492,6 @@ qemuBuildCommandLine(virQEMUDriver *driver, char uuid[VIR_UUID_STRING_BUFLEN]; g_autoptr(virCommand) cmd = NULL; g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); - unsigned int bootHostdevNet = 0; qemuDomainObjPrivate *priv = vm->privateData; virDomainDef *def = vm->def; virQEMUCaps *qemuCaps = priv->qemuCaps; @@ -10682,7 +10639,7 @@ qemuBuildCommandLine(virQEMUDriver *driver, if (qemuBuildNetCommandLine(driver, vm, logManager, secManager, cmd, qemuCaps, vmop, standalone, - nnicindexes, nicindexes, &bootHostdevNet) < 0) + nnicindexes, nicindexes) < 0) return NULL; if (qemuBuildSmartcardCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps, @@ -10730,7 +10687,7 @@ qemuBuildCommandLine(virQEMUDriver *driver, chardevStdioLogd) < 0) return NULL; - if (qemuBuildHostdevCommandLine(cmd, def, qemuCaps, &bootHostdevNet) < 0) + if (qemuBuildHostdevCommandLine(cmd, def, qemuCaps) < 0) return NULL; if (migrateURI) diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 00efcfd5fd..d59a55e8aa 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -100,7 +100,6 @@ virJSONValue *qemuBuildHostNetStr(virDomainNetDef *net, /* Current, best practice */ char *qemuBuildNicDevStr(virDomainDef *def, virDomainNetDef *net, - unsigned int bootindex, size_t vhostfdSize, virQEMUCaps *qemuCaps); @@ -169,7 +168,6 @@ qemuBuildMemoryDeviceStr(const virDomainDef *def, /* Current, best practice */ char *qemuBuildPCIHostdevDevStr(const virDomainDef *def, virDomainHostdevDef *dev, - unsigned int bootIndex, virQEMUCaps *qemuCaps); char *qemuBuildRNGDevStr(const virDomainDef *def, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1c310249e2..d5f6722d5a 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1493,8 +1493,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, for (i = 0; i < vhostfdSize; i++) VIR_FORCE_CLOSE(vhostfd[i]); - if (!(nicstr = qemuBuildNicDevStr(vm->def, net, 0, - queueSize, priv->qemuCaps))) + if (!(nicstr = qemuBuildNicDevStr(vm->def, net, queueSize, priv->qemuCaps))) goto try_remove; qemuDomainObjEnterMonitor(driver, vm); @@ -1716,7 +1715,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriver *driver, goto error; } - if (!(devstr = qemuBuildPCIHostdevDevStr(vm->def, hostdev, 0, priv->qemuCaps))) + if (!(devstr = qemuBuildPCIHostdevDevStr(vm->def, hostdev, priv->qemuCaps))) goto error; qemuDomainObjEnterMonitor(driver, vm); -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Remove the nw unused boot-index related attributes and the code which is
*now
assigning it.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 71 ++++++++--------------------------------- src/qemu/qemu_command.h | 2 -- src/qemu/qemu_hotplug.c | 5 ++- 3 files changed, 16 insertions(+), 62 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 2 +- src/qemu/qemu_validate.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6b89b9404c..b6d22a1a1d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4165,7 +4165,7 @@ virDomainObjGetOneDef(virDomainObj *vm, } virDomainDeviceInfo * -virDomainDeviceGetInfo(virDomainDeviceDef *device) +virDomainDeviceGetInfo(const virDomainDeviceDef *device) { switch ((virDomainDeviceType) device->type) { case VIR_DOMAIN_DEVICE_DISK: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c23c233184..4b6afe95bb 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3332,7 +3332,7 @@ virDomainDeviceDef *virDomainDeviceDefCopy(virDomainDeviceDef *src, const virDomainDef *def, virDomainXMLOption *xmlopt, void *parseOpaque); -virDomainDeviceInfo *virDomainDeviceGetInfo(virDomainDeviceDef *device); +virDomainDeviceInfo *virDomainDeviceGetInfo(const virDomainDeviceDef *device); void virDomainDeviceSetData(virDomainDeviceDef *device, void *devicedata); void virDomainTPMDefFree(virDomainTPMDef *def); diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 8a779f24c7..e120f3385f 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1304,7 +1304,7 @@ qemuValidateDomainDeviceDefAddress(const virDomainDeviceDef *dev, { virDomainDeviceInfo *info; - if (!(info = virDomainDeviceGetInfo((virDomainDeviceDef *)dev))) + if (!(info = virDomainDeviceGetInfo(dev))) return 0; switch ((virDomainDeviceAddressType) info->type) { -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 2 +- src/qemu/qemu_validate.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Commit ffda44030a2 added validation of the 'acpiIndex' field in virDomainDeviceInfo by calling 'virDomainDeviceInfoIterate' from 'qemuValidateDomainDef'. This is overly complicated we have 'qemuValidateDomainDeviceDef' which is already called for every single device so we can avoid the extra loop. Restructure the code by calling 'qemuValidateDomainDeviceInfo' directly from 'qemuValidateDomainDeviceDef' and avoid unnecessary calls to 'virDomainDeviceGetInfo' by calling 'qemuValidateDomainDeviceDefAddress' from 'qemuValidateDomainDeviceInfo' Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_validate.c | 79 ++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 44 deletions(-) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index e120f3385f..3f76adb586 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -997,33 +997,6 @@ qemuValidateDomainDefPanic(const virDomainDef *def, } -static int -qemuValidateDomainDeviceInfo(virDomainDef *def G_GNUC_UNUSED, - virDomainDeviceDef *dev G_GNUC_UNUSED, - virDomainDeviceInfo *info, - void *opaque) -{ - virQEMUCaps *qemuCaps = opaque; - - if (info->acpiIndex) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_ACPI_INDEX)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("ACPI index is not supported with this QEMU")); - return -1; - } - - if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && - info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("ACPI index is only supported for PCI devices")); - return -1; - } - } - - return 0; -} - - int qemuValidateLifecycleAction(virDomainLifecycleAction onPoweroff, virDomainLifecycleAction onReboot, @@ -1252,15 +1225,6 @@ qemuValidateDomainDef(const virDomainDef *def, return -1; } - /* Explicitly discarding 'const' from 'def' is ok because - * we know our callback qemuValidateDomainDeviceInfo will - * not modify it - */ - if (virDomainDeviceInfoIterate((virDomainDef *)def, - qemuValidateDomainDeviceInfo, - qemuCaps) < 0) - return -1; - return 0; } @@ -1298,15 +1262,10 @@ qemuValidateDomainDeviceDefZPCIAddress(virDomainDeviceInfo *info, static int -qemuValidateDomainDeviceDefAddress(const virDomainDeviceDef *dev, +qemuValidateDomainDeviceDefAddress(virDomainDeviceInfo *info, const virDomainDef *def, virQEMUCaps *qemuCaps) { - virDomainDeviceInfo *info; - - if (!(info = virDomainDeviceGetInfo(dev))) - return 0; - switch ((virDomainDeviceAddressType) info->type) { case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: if (qemuValidateDomainDeviceDefZPCIAddress(info, qemuCaps) < 0) @@ -1375,6 +1334,38 @@ qemuValidateDomainDeviceDefAddress(const virDomainDeviceDef *dev, } +static int +qemuValidateDomainDeviceInfo(const virDomainDeviceDef *dev, + const virDomainDef *def, + virQEMUCaps *qemuCaps) +{ + virDomainDeviceInfo *info; + + if (!(info = virDomainDeviceGetInfo(dev))) + return 0; + + if (qemuValidateDomainDeviceDefAddress(info, def, qemuCaps) < 0) + return -1; + + if (info->acpiIndex) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_ACPI_INDEX)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("ACPI index is not supported with this QEMU")); + return -1; + } + + if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("ACPI index is only supported for PCI devices")); + return -1; + } + } + + return 0; +} + + static bool qemuValidateNetSupportsCoalesce(virDomainNetType type) { @@ -5020,8 +5011,8 @@ qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev, qemuCaps = qemuCapsLocal; } - if ((ret = qemuValidateDomainDeviceDefAddress(dev, def, qemuCaps)) < 0) - return ret; + if (qemuValidateDomainDeviceInfo(dev, def, qemuCaps) < 0) + return -1; switch ((virDomainDeviceType)dev->type) { case VIR_DOMAIN_DEVICE_NET: -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Commit ffda44030a2 added validation of the 'acpiIndex' field in virDomainDeviceInfo by calling 'virDomainDeviceInfoIterate' from 'qemuValidateDomainDef'. This is overly complicated we have 'qemuValidateDomainDeviceDef' which is already called for every single device so we can avoid the extra loop.
One step closer to O(n log(n)) command-line generation.
Restructure the code by calling 'qemuValidateDomainDeviceInfo' directly from 'qemuValidateDomainDeviceDef' and avoid unnecessary calls to 'virDomainDeviceGetInfo' by calling 'qemuValidateDomainDeviceDefAddress' from 'qemuValidateDomainDeviceInfo'
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_validate.c | 79 ++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 44 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_validate.c | 72 ++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 48 deletions(-) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 3f76adb586..499c9ed571 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -4998,7 +4998,6 @@ qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev, void *opaque, void *parseOpaque) { - int ret = 0; virQEMUDriver *driver = opaque; g_autoptr(virQEMUCaps) qemuCapsLocal = NULL; virQEMUCaps *qemuCaps = parseOpaque; @@ -5016,99 +5015,76 @@ qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev, switch ((virDomainDeviceType)dev->type) { case VIR_DOMAIN_DEVICE_NET: - ret = qemuValidateDomainDeviceDefNetwork(dev->data.net, qemuCaps); - break; + return qemuValidateDomainDeviceDefNetwork(dev->data.net, qemuCaps); case VIR_DOMAIN_DEVICE_CHR: - ret = qemuValidateDomainChrDef(dev->data.chr, def, qemuCaps); - break; + return qemuValidateDomainChrDef(dev->data.chr, def, qemuCaps); case VIR_DOMAIN_DEVICE_SMARTCARD: - ret = qemuValidateDomainSmartcardDef(dev->data.smartcard, qemuCaps); - break; + return qemuValidateDomainSmartcardDef(dev->data.smartcard, qemuCaps); case VIR_DOMAIN_DEVICE_RNG: - ret = qemuValidateDomainRNGDef(dev->data.rng, qemuCaps); - break; + return qemuValidateDomainRNGDef(dev->data.rng, qemuCaps); case VIR_DOMAIN_DEVICE_REDIRDEV: - ret = qemuValidateDomainRedirdevDef(dev->data.redirdev, def, qemuCaps); - break; + return qemuValidateDomainRedirdevDef(dev->data.redirdev, def, qemuCaps); case VIR_DOMAIN_DEVICE_WATCHDOG: - ret = qemuValidateDomainWatchdogDef(dev->data.watchdog, def); - break; + return qemuValidateDomainWatchdogDef(dev->data.watchdog, def); case VIR_DOMAIN_DEVICE_HOSTDEV: - ret = qemuValidateDomainDeviceDefHostdev(dev->data.hostdev, def, + return qemuValidateDomainDeviceDefHostdev(dev->data.hostdev, def, qemuCaps); - break; case VIR_DOMAIN_DEVICE_VIDEO: - ret = qemuValidateDomainDeviceDefVideo(dev->data.video, qemuCaps); - break; + return qemuValidateDomainDeviceDefVideo(dev->data.video, qemuCaps); case VIR_DOMAIN_DEVICE_DISK: - ret = qemuValidateDomainDeviceDefDisk(dev->data.disk, def, qemuCaps); - break; + return qemuValidateDomainDeviceDefDisk(dev->data.disk, def, qemuCaps); case VIR_DOMAIN_DEVICE_CONTROLLER: - ret = qemuValidateDomainDeviceDefController(dev->data.controller, def, + return qemuValidateDomainDeviceDefController(dev->data.controller, def, qemuCaps); - break; case VIR_DOMAIN_DEVICE_VSOCK: - ret = qemuValidateDomainDeviceDefVsock(dev->data.vsock, qemuCaps); - break; + return qemuValidateDomainDeviceDefVsock(dev->data.vsock, qemuCaps); case VIR_DOMAIN_DEVICE_TPM: - ret = qemuValidateDomainDeviceDefTPM(dev->data.tpm, def, qemuCaps); - break; + return qemuValidateDomainDeviceDefTPM(dev->data.tpm, def, qemuCaps); case VIR_DOMAIN_DEVICE_GRAPHICS: - ret = qemuValidateDomainDeviceDefGraphics(dev->data.graphics, def, + return qemuValidateDomainDeviceDefGraphics(dev->data.graphics, def, driver, qemuCaps); - break; case VIR_DOMAIN_DEVICE_INPUT: - ret = qemuValidateDomainDeviceDefInput(dev->data.input, def, qemuCaps); - break; + return qemuValidateDomainDeviceDefInput(dev->data.input, def, qemuCaps); case VIR_DOMAIN_DEVICE_MEMBALLOON: - ret = qemuValidateDomainDeviceDefMemballoon(dev->data.memballoon, qemuCaps); - break; + return qemuValidateDomainDeviceDefMemballoon(dev->data.memballoon, qemuCaps); case VIR_DOMAIN_DEVICE_IOMMU: - ret = qemuValidateDomainDeviceDefIOMMU(dev->data.iommu, def, qemuCaps); - break; + return qemuValidateDomainDeviceDefIOMMU(dev->data.iommu, def, qemuCaps); case VIR_DOMAIN_DEVICE_FS: - ret = qemuValidateDomainDeviceDefFS(dev->data.fs, def, driver, qemuCaps); - break; + return qemuValidateDomainDeviceDefFS(dev->data.fs, def, driver, qemuCaps); case VIR_DOMAIN_DEVICE_NVRAM: - ret = qemuValidateDomainDeviceDefNVRAM(dev->data.nvram, def, qemuCaps); - break; + return qemuValidateDomainDeviceDefNVRAM(dev->data.nvram, def, qemuCaps); case VIR_DOMAIN_DEVICE_HUB: - ret = qemuValidateDomainDeviceDefHub(dev->data.hub, qemuCaps); - break; + return qemuValidateDomainDeviceDefHub(dev->data.hub, qemuCaps); case VIR_DOMAIN_DEVICE_SOUND: - ret = qemuValidateDomainDeviceDefSound(dev->data.sound, qemuCaps); - break; + return qemuValidateDomainDeviceDefSound(dev->data.sound, qemuCaps); case VIR_DOMAIN_DEVICE_MEMORY: - ret = qemuValidateDomainDeviceDefMemory(dev->data.memory, qemuCaps); - break; + return qemuValidateDomainDeviceDefMemory(dev->data.memory, qemuCaps); case VIR_DOMAIN_DEVICE_SHMEM: - ret = qemuValidateDomainDeviceDefShmem(dev->data.shmem, qemuCaps); - break; + return qemuValidateDomainDeviceDefShmem(dev->data.shmem, qemuCaps); case VIR_DOMAIN_DEVICE_AUDIO: - ret = qemuValidateDomainDeviceDefAudio(dev->data.audio, qemuCaps); - break; + return qemuValidateDomainDeviceDefAudio(dev->data.audio, qemuCaps); case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_PANIC: @@ -5117,5 +5093,5 @@ qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev, break; } - return ret; + return 0; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_validate.c | 72 ++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 48 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Move the validation from 'qemuBuildRomStr' into the function which validates device info. It was originally named 'qemuValidateDomainDeviceDefAddress' but this commit renames it to 'qemuValidateDomainDeviceDefInfo'. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 6 ------ src/qemu/qemu_validate.c | 8 ++++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 75a30f75ff..95395805e5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1048,12 +1048,6 @@ qemuBuildRomStr(virBuffer *buf, virDomainDeviceInfo *info) { if (info->romenabled || info->rombar || info->romfile) { - if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("ROM tuning is only supported for PCI devices")); - return -1; - } - /* Passing an empty romfile= tells QEMU to disable ROM entirely for * this device, and makes other settings irrelevant */ if (info->romenabled == VIR_TRISTATE_BOOL_NO) { diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 499c9ed571..08f7fb2f42 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1362,6 +1362,14 @@ qemuValidateDomainDeviceInfo(const virDomainDeviceDef *dev, } } + if (info->romenabled || info->rombar || info->romfile) { + if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("ROM tuning is only supported for PCI devices")); + return -1; + } + } + return 0; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Move the validation from 'qemuBuildRomStr' into the function which validates device info. It was originally named 'qemuValidateDomainDeviceDefAddress' but this commit renames it to 'qemuValidateDomainDeviceDefInfo'.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 6 ------ src/qemu/qemu_validate.c | 8 ++++++++ 2 files changed, 8 insertions(+), 6 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Add a JSON variant of the generator of properties for virtio devices. For convenience both the old and new are for now marked as unused, which will be removed once the conversion is complete. The formatted properties have following types according to QEMU. 'virtio-blk-pci' was used as an example: disable-legacy=<OnOffAuto> - on/off/auto (default: "auto") disable-modern=<bool> - (default: false) iommu_platform=<bool> - on/off (default: false) ats=<bool> - on/off (default: false) packed=<bool> - on/off (default: false) Note that <OnOffAuto> is an enum type without alternates in QMP so it must be represented as a string in JSON. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 58 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 95395805e5..d27e8b2648 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -155,6 +155,16 @@ VIR_ENUM_IMPL(qemuAudioDriver, ); +static const char * +qemuOnOffAuto(virTristateSwitch s) +{ + if (s == VIR_TRISTATE_SWITCH_ABSENT) + return NULL; + + return virTristateSwitchTypeToString(s); +} + + static int qemuBuildObjectCommandlineFromJSON(virCommand *cmd, virJSONValue *props, @@ -980,6 +990,52 @@ qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, } +/** + * qemuBuildVirtioDevProps + * @devtype: virDomainDeviceType of the device. Ex: VIR_DOMAIN_DEVICE_TYPE_RNG + * @devdata: *Def * of the device definition + * @qemuCaps: qemu capabilities + * + * Build the qemu virtio -device JSON properties name from the passed parameters. + */ +static G_GNUC_UNUSED virJSONValue * +qemuBuildVirtioDevProps(virDomainDeviceType devtype, + void *devdata, + virQEMUCaps *qemuCaps) +{ + g_autoptr(virJSONValue) props = NULL; + virDomainDeviceDef device = { .type = devtype }; + g_autofree char *model = NULL; + virTristateSwitch disableLegacy = VIR_TRISTATE_SWITCH_ABSENT; + virTristateSwitch disableModern = VIR_TRISTATE_SWITCH_ABSENT; + virDomainVirtioOptions *virtioOptions = NULL; + + virDomainDeviceSetData(&device, devdata); + + if (qemuBuildVirtioDevGetConfig(&device, qemuCaps, &model, &virtioOptions, + &disableLegacy, &disableModern) < 0) + return NULL; + + if (virJSONValueObjectCreate(&props, + "s:driver", model, + "S:disable-legacy", qemuOnOffAuto(disableLegacy), + "T:disable-modern", disableModern, + NULL) < 0) + return NULL; + + if (virtioOptions) { + if (virJSONValueObjectAdd(props, + "T:iommu_platform", virtioOptions->iommu, + "T:ats", virtioOptions->ats, + "T:packed", virtioOptions->packed, + NULL) < 0) + return NULL; + } + + return g_steal_pointer(&props); +} + + /** * qemuBuildVirtioDevStr * @buf: virBuffer * to append the built string @@ -994,7 +1050,7 @@ qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, * * Returns: -1 on failure, 0 on success */ -static int +static G_GNUC_UNUSED int qemuBuildVirtioDevStr(virBuffer *buf, virQEMUCaps *qemuCaps, virDomainDeviceType devtype, -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Add a JSON variant of the generator of properties for virtio devices. For convenience both the old and new are for now marked as unused, which will be removed once the conversion is complete.
The formatted properties have following types according to QEMU. 'virtio-blk-pci' was used as an example:
disable-legacy=<OnOffAuto> - on/off/auto (default: "auto") disable-modern=<bool> - (default: false) iommu_platform=<bool> - on/off (default: false) ats=<bool> - on/off (default: false) packed=<bool> - on/off (default: false)
Note that <OnOffAuto> is an enum type without alternates in QMP so it must be represented as a string in JSON.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 58 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The helper converts the JSON object to a string and adds it to the current command as arguments of '-device'. The helper also prepares for '-device' taking JSON directly. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d27e8b2648..9c8a3a85af 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -221,6 +221,33 @@ qemuBuildNetdevCommandlineFromJSON(virCommand *cmd, } +static G_GNUC_UNUSED int +qemuBuildDeviceCommandlineFromJSON(virCommand *cmd, + virJSONValue *props, + virQEMUCaps *qemuCaps) +{ + g_autofree char *arg = NULL; + + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_JSON)) { + if (!(arg = virJSONValueToString(props, false))) + return -1; + } else { + const char *driver = virJSONValueObjectGetString(props, "driver"); + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + + virBufferAsprintf(&buf, "%s,", driver); + + if (virQEMUBuildCommandLineJSON(props, &buf, "driver", NULL) < 0) + return -1; + + arg = virBufferContentAndReset(&buf); + } + + virCommandAddArgList(cmd, "-device", arg, NULL); + return 0; +} + + /** * qemuBuildMasterKeyCommandLine: * @cmd: the command to modify -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The helper converts the JSON object to a string and adds it to the current command as arguments of '-device'. The helper also prepares for '-device' taking JSON directly.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Add a JSON variant of the generator 'rom' properties. For convenience both the old and new are for now marked as unused, which will be removed once the conversion is complete. The formatted properties have following types according to QEMU. 'virtio-blk-pci' was used as an example: rombar=<uint32> - (default: 1) romfile=<str> Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 42 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9c8a3a85af..c9d98b8f1a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1126,7 +1126,47 @@ qemuBuildVirtioDevStr(virBuffer *buf, } -static int +static int G_GNUC_UNUSED +qemuBuildRomProps(virJSONValue *props, + virDomainDeviceInfo *info) +{ + const char *romfile = NULL; + int rombar = -1; + + if (info->romenabled == VIR_TRISTATE_BOOL_ABSENT && + info->rombar == VIR_TRISTATE_SWITCH_ABSENT && + !info->romfile) + return 0; + + if (info->romenabled == VIR_TRISTATE_BOOL_NO) { + romfile = ""; + } else { + romfile = info->romfile; + + switch (info->rombar) { + case VIR_TRISTATE_SWITCH_OFF: + rombar = 0; + break; + case VIR_TRISTATE_SWITCH_ON: + rombar = 1; + break; + case VIR_TRISTATE_SWITCH_ABSENT: + case VIR_TRISTATE_SWITCH_LAST: + break; + } + } + + if (virJSONValueObjectAdd(props, + "k:rombar", rombar, + "S:romfile", romfile, + NULL) < 0) + return -1; + + return 0; +} + + +static int G_GNUC_UNUSED qemuBuildRomStr(virBuffer *buf, virDomainDeviceInfo *info) { -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Add a JSON variant of the generator 'rom' properties. For convenience both the old and new are for now marked as unused, which will be removed once the conversion is complete.
The formatted properties have following types according to QEMU. 'virtio-blk-pci' was used as an example: rombar=<uint32> - (default: 1) romfile=<str>
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 42 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Format a JSON object with the device properties and then use qemuBuildDeviceCommandlineFromJSON to convert it to the standard commandline for now. The 'ioport' property of 'pvpanic' is a number in QEMU: ioport=<uint16> - (default: 1285) Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c9d98b8f1a..25859ee653 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10161,25 +10161,36 @@ qemuBuildVMCoreInfoCommandLine(virCommand *cmd, static int qemuBuildPanicCommandLine(virCommand *cmd, - const virDomainDef *def) + const virDomainDef *def, + virQEMUCaps *qemuCaps) { size_t i; for (i = 0; i < def->npanics; i++) { switch ((virDomainPanicModel) def->panics[i]->model) { - case VIR_DOMAIN_PANIC_MODEL_ISA: - switch (def->panics[i]->info.type) { - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA: - virCommandAddArg(cmd, "-device"); - virCommandAddArgFormat(cmd, "pvpanic,ioport=%d", - def->panics[i]->info.addr.isa.iobase); - break; + case VIR_DOMAIN_PANIC_MODEL_ISA: { + g_autoptr(virJSONValue) props = NULL; - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: - virCommandAddArgList(cmd, "-device", "pvpanic", NULL); - break; + if (virJSONValueObjectCreate(&props, + "s:driver", "pvpanic", + NULL) < 0) + return -1; + + /* pvpanic uses 'ioport' instead of 'iobase' so + * qemuBuildDeviceAddressProps can't be used */ + if (def->panics[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) { + if (virJSONValueObjectAdd(props, + "u:ioport", def->panics[i]->info.addr.isa.iobase, + NULL) < 0) + return -1; } + if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0) + return -1; + + break; + } + case VIR_DOMAIN_PANIC_MODEL_S390: case VIR_DOMAIN_PANIC_MODEL_HYPERV: case VIR_DOMAIN_PANIC_MODEL_PSERIES: @@ -10844,7 +10855,7 @@ qemuBuildCommandLine(virQEMUDriver *driver, if (qemuBuildSeccompSandboxCommandLine(cmd, cfg, qemuCaps) < 0) return NULL; - if (qemuBuildPanicCommandLine(cmd, def) < 0) + if (qemuBuildPanicCommandLine(cmd, def, qemuCaps) < 0) return NULL; for (i = 0; i < def->nshmems; i++) { -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Format a JSON object with the device properties and then use qemuBuildDeviceCommandlineFromJSON to convert it to the standard commandline for now.
The 'ioport' property of 'pvpanic' is a number in QEMU: ioport=<uint16> - (default: 1285)
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The watchdog doesn't have any special properties. Convert the command line generator and hotplug code. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 31 +++++++++++++++---------------- src/qemu/qemu_command.h | 6 +++--- src/qemu/qemu_hotplug.c | 6 +++--- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 25859ee653..6fa804f7d8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4150,21 +4150,22 @@ qemuBuildHostNetStr(virDomainNetDef *net, } -char * -qemuBuildWatchdogDevStr(const virDomainDef *def, - virDomainWatchdogDef *dev, - virQEMUCaps *qemuCaps G_GNUC_UNUSED) +virJSONValue * +qemuBuildWatchdogDevProps(const virDomainDef *def, + virDomainWatchdogDef *dev) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; - virBufferAsprintf(&buf, "%s,id=%s", - virDomainWatchdogModelTypeToString(dev->model), - dev->info.alias); + if (virJSONValueObjectCreate(&props, + "s:driver", virDomainWatchdogModelTypeToString(dev->model), + "s:id", dev->info.alias, + NULL) < 0) + return NULL; - if (qemuBuildDeviceAddressStr(&buf, def, &dev->info) < 0) + if (qemuBuildDeviceAddressProps(props, def, &dev->info) < 0) return NULL; - return virBufferContentAndReset(&buf); + return g_steal_pointer(&props); } @@ -4174,7 +4175,7 @@ qemuBuildWatchdogCommandLine(virCommand *cmd, virQEMUCaps *qemuCaps) { virDomainWatchdogDef *watchdog = def->watchdog; - g_autofree char *optstr = NULL; + g_autoptr(virJSONValue) props = NULL; const char *action; int actualAction; @@ -4184,13 +4185,11 @@ qemuBuildWatchdogCommandLine(virCommand *cmd, if (qemuCommandAddExtDevice(cmd, &def->watchdog->info) < 0) return -1; - virCommandAddArg(cmd, "-device"); - - optstr = qemuBuildWatchdogDevStr(def, watchdog, qemuCaps); - if (!optstr) + if (!(props = qemuBuildWatchdogDevProps(def, watchdog))) return -1; - virCommandAddArg(cmd, optstr); + if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps)) + return -1; /* qemu doesn't have a 'dump' action; we tell qemu to 'pause', then libvirt listens for the watchdog event, and we perform the dump diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index d59a55e8aa..6ce151d8d9 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -234,9 +234,9 @@ char *qemuBuildShmemDevStr(virDomainDef *def, virQEMUCaps *qemuCaps) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); -char *qemuBuildWatchdogDevStr(const virDomainDef *def, - virDomainWatchdogDef *dev, - virQEMUCaps *qemuCaps); +virJSONValue * +qemuBuildWatchdogDevProps(const virDomainDef *def, + virDomainWatchdogDef *dev); int qemuBuildInputDevStr(char **devstr, const virDomainDef *def, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d5f6722d5a..f833a619a7 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3121,7 +3121,7 @@ qemuDomainAttachWatchdog(virQEMUDriver *driver, int ret = -1; qemuDomainObjPrivate *priv = vm->privateData; virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_WATCHDOG, { .watchdog = watchdog } }; - g_autofree char *watchdogstr = NULL; + g_autoptr(virJSONValue) props = NULL; bool releaseAddress = false; int rv; @@ -3145,7 +3145,7 @@ qemuDomainAttachWatchdog(virQEMUDriver *driver, goto cleanup; } - if (!(watchdogstr = qemuBuildWatchdogDevStr(vm->def, watchdog, priv->qemuCaps))) + if (!(props = qemuBuildWatchdogDevProps(vm->def, watchdog))) goto cleanup; qemuDomainObjEnterMonitor(driver, vm); @@ -3203,7 +3203,7 @@ qemuDomainAttachWatchdog(virQEMUDriver *driver, } if (rv >= 0) - rv = qemuMonitorAddDevice(priv->mon, watchdogstr); + rv = qemuMonitorAddDeviceProps(priv->mon, &props); if (qemuDomainObjExitMonitor(driver, vm) < 0) { releaseAddress = false; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The watchdog doesn't have any special properties.
Convert the command line generator and hotplug code.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 31 +++++++++++++++---------------- src/qemu/qemu_command.h | 6 +++--- src/qemu/qemu_hotplug.c | 6 +++--- 3 files changed, 21 insertions(+), 22 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

This includes the 'pc-dimm', 'nvdimm', 'virtio-pmem-pci' and 'virtio-mem-pci' devices. The value types according to QEMU are: 'pc-dimm' node=<uint32> - (default: 0) memdev=<link<memory-backend>> 'nvdimm' label-size=<int> memdev=<link<memory-backend>> node=<uint32> - (default: 0) unarmed=<bool> - (default: false) uuid=<QemuUUID> 'virtio-pmem-pci' memdev=<link<memory-backend>> 'virtio-mem-pci' block-size=<size> memdev=<link<memory-backend>> node=<uint32> - (default: 0) requested-size=<size> Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 60 +++++++++++++++++++---------------------- src/qemu/qemu_command.h | 7 +++-- src/qemu/qemu_hotplug.c | 6 ++--- 3 files changed, 33 insertions(+), 40 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6fa804f7d8..794119a58c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3723,13 +3723,14 @@ qemuBuildMemoryDimmBackendStr(virCommand *cmd, } -char * -qemuBuildMemoryDeviceStr(const virDomainDef *def, - virDomainMemoryDef *mem, - virQEMUCaps *qemuCaps G_GNUC_UNUSED) +virJSONValue * +qemuBuildMemoryDeviceProps(const virDomainDef *def, + virDomainMemoryDef *mem) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; const char *device = NULL; + g_autofree char *uuidstr = NULL; + virTristateBool unarmed = VIR_TRISTATE_BOOL_ABSENT; if (!mem->info.alias) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -3761,37 +3762,31 @@ qemuBuildMemoryDeviceStr(const virDomainDef *def, break; } - virBufferAsprintf(&buf, "%s,", device); - - if (mem->targetNode >= 0) - virBufferAsprintf(&buf, "node=%d,", mem->targetNode); - - if (mem->labelsize) - virBufferAsprintf(&buf, "label-size=%llu,", mem->labelsize * 1024); - - if (mem->blocksize) { - virBufferAsprintf(&buf, "block-size=%llu,", mem->blocksize * 1024); - virBufferAsprintf(&buf, "requested-size=%llu,", mem->requestedsize * 1024); - } + if (mem->readonly) + unarmed = VIR_TRISTATE_BOOL_YES; if (mem->uuid) { - char uuidstr[VIR_UUID_STRING_BUFLEN]; - + uuidstr = g_new0(char, VIR_UUID_STRING_BUFLEN); virUUIDFormat(mem->uuid, uuidstr); - virBufferAsprintf(&buf, "uuid=%s,", uuidstr); } - if (mem->readonly) { - virBufferAddLit(&buf, "unarmed=on,"); - } - - virBufferAsprintf(&buf, "memdev=mem%s,id=%s", - mem->info.alias, mem->info.alias); + if (virJSONValueObjectCreate(&props, + "s:driver", device, + "k:node", mem->targetNode, + "P:label-size", mem->labelsize * 1024, + "P:block-size", mem->blocksize * 1024, + "P:requested-size", mem->requestedsize * 1024, + "S:uuid", uuidstr, + "T:unarmed", unarmed, + "f:memdev", g_strdup_printf("mem%s", mem->info.alias), + "s:id", mem->info.alias, + NULL) < 0) + return NULL; - if (qemuBuildDeviceAddressStr(&buf, def, &mem->info) < 0) + if (qemuBuildDeviceAddressProps(props, def, &mem->info) < 0) return NULL; - return virBufferContentAndReset(&buf); + return g_steal_pointer(&props); } @@ -7837,17 +7832,16 @@ qemuBuildMemoryDeviceCommandLine(virCommand *cmd, /* memory hotplug requires NUMA to be enabled - we already checked * that memory devices are present only when NUMA is */ for (i = 0; i < def->nmems; i++) { - char *dimmStr; + g_autoptr(virJSONValue) props = NULL; if (qemuBuildMemoryDimmBackendStr(cmd, def->mems[i], def, cfg, priv) < 0) return -1; - if (!(dimmStr = qemuBuildMemoryDeviceStr(def, def->mems[i], priv->qemuCaps))) + if (!(props = qemuBuildMemoryDeviceProps(def, def->mems[i]))) return -1; - virCommandAddArgList(cmd, "-device", dimmStr, NULL); - - VIR_FREE(dimmStr); + if (qemuBuildDeviceCommandlineFromJSON(cmd, props, priv->qemuCaps) < 0) + return -1; } return 0; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 6ce151d8d9..86df734c57 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -160,10 +160,9 @@ int qemuBuildMemoryBackendProps(virJSONValue **backendProps, bool force, bool systemMemory); -char * -qemuBuildMemoryDeviceStr(const virDomainDef *def, - virDomainMemoryDef *mem, - virQEMUCaps *qemuCaps); +virJSONValue * +qemuBuildMemoryDeviceProps(const virDomainDef *def, + virDomainMemoryDef *mem); /* Current, best practice */ char *qemuBuildPCIHostdevDevStr(const virDomainDef *def, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f833a619a7..3e0c9cf981 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2434,7 +2434,7 @@ qemuDomainAttachMemory(virQEMUDriver *driver, g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); unsigned long long oldmem = virDomainDefGetMemoryTotal(vm->def); unsigned long long newmem = oldmem + mem->size; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; g_autofree char *objalias = NULL; bool objAdded = false; bool releaseaddr = false; @@ -2463,7 +2463,7 @@ qemuDomainAttachMemory(virQEMUDriver *driver, objalias = g_strdup_printf("mem%s", mem->info.alias); - if (!(devstr = qemuBuildMemoryDeviceStr(vm->def, mem, priv->qemuCaps))) + if (!(devprops = qemuBuildMemoryDeviceProps(vm->def, mem))) goto cleanup; if (qemuBuildMemoryBackendProps(&props, objalias, cfg, @@ -2495,7 +2495,7 @@ qemuDomainAttachMemory(virQEMUDriver *driver, goto exit_monitor; objAdded = true; - if (qemuMonitorAddDevice(priv->mon, devstr) < 0) + if (qemuMonitorAddDeviceProps(priv->mon, &devprops) < 0) goto exit_monitor; if (qemuDomainObjExitMonitor(driver, vm) < 0) { -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
This includes the 'pc-dimm', 'nvdimm', 'virtio-pmem-pci' and 'virtio-mem-pci' devices.
The value types according to QEMU are:
'pc-dimm' node=<uint32> - (default: 0) memdev=<link<memory-backend>>
'nvdimm' label-size=<int> memdev=<link<memory-backend>> node=<uint32> - (default: 0) unarmed=<bool> - (default: false) uuid=<QemuUUID>
'virtio-pmem-pci' memdev=<link<memory-backend>>
'virtio-mem-pci' block-size=<size> memdev=<link<memory-backend>> node=<uint32> - (default: 0) requested-size=<size>
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 60 +++++++++++++++++++---------------------- src/qemu/qemu_command.h | 7 +++-- src/qemu/qemu_hotplug.c | 6 ++--- 3 files changed, 33 insertions(+), 40 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6fa804f7d8..794119a58c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3723,13 +3723,14 @@ qemuBuildMemoryDimmBackendStr(virCommand *cmd, }
-char * -qemuBuildMemoryDeviceStr(const virDomainDef *def, - virDomainMemoryDef *mem, - virQEMUCaps *qemuCaps G_GNUC_UNUSED) +virJSONValue * +qemuBuildMemoryDeviceProps(const virDomainDef *def, + virDomainMemoryDef *mem) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; const char *device = NULL; + g_autofree char *uuidstr = NULL; + virTristateBool unarmed = VIR_TRISTATE_BOOL_ABSENT;
if (!mem->info.alias) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -3761,37 +3762,31 @@ qemuBuildMemoryDeviceStr(const virDomainDef *def, break; }
- virBufferAsprintf(&buf, "%s,", device); - - if (mem->targetNode >= 0) - virBufferAsprintf(&buf, "node=%d,", mem->targetNode); - - if (mem->labelsize) - virBufferAsprintf(&buf, "label-size=%llu,", mem->labelsize * 1024); - - if (mem->blocksize) { - virBufferAsprintf(&buf, "block-size=%llu,", mem->blocksize * 1024); - virBufferAsprintf(&buf, "requested-size=%llu,", mem->requestedsize * 1024); - } + if (mem->readonly) + unarmed = VIR_TRISTATE_BOOL_YES;
if (mem->uuid) { - char uuidstr[VIR_UUID_STRING_BUFLEN]; - + uuidstr = g_new0(char, VIR_UUID_STRING_BUFLEN); virUUIDFormat(mem->uuid, uuidstr); - virBufferAsprintf(&buf, "uuid=%s,", uuidstr); }
- if (mem->readonly) { - virBufferAddLit(&buf, "unarmed=on,"); - } - - virBufferAsprintf(&buf, "memdev=mem%s,id=%s", - mem->info.alias, mem->info.alias); + if (virJSONValueObjectCreate(&props, + "s:driver", device, + "k:node", mem->targetNode, + "P:label-size", mem->labelsize * 1024, + "P:block-size", mem->blocksize * 1024, + "P:requested-size", mem->requestedsize * 1024, + "S:uuid", uuidstr, + "T:unarmed", unarmed, + "f:memdev", g_strdup_printf("mem%s", mem->info.alias),
One more usage of 'f'. Also, I'm really glad these keys use letters, instead of, let's say, Morse code.
+ "s:id", mem->info.alias, + NULL) < 0) + return NULL;
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Note that the legacy 'ivshmem' device was already removed upstream, but it's converted so that the code is identical. For the two modern devices QEMU considers the properties being of following types: 'ivshmem-doorbell' chardev=<str> - ID of a chardev to use as a backend ioeventfd=<bool> - on/off (default: true) master=<OnOffAuto> - on/off/auto (default: "off") vectors=<uint32> - (default: 1) 'ivshmem-plain' master=<OnOffAuto> - on/off/auto (default: "off") memdev=<link<memory-backend>> Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 107 ++++++++++++++++++++++------------------ src/qemu/qemu_command.h | 7 ++- src/qemu/qemu_hotplug.c | 6 +-- 3 files changed, 64 insertions(+), 56 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 794119a58c..cbd0b2890f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9201,60 +9201,64 @@ qemuBuildSmartcardCommandLine(virLogManager *logManager, } -static char * -qemuBuildShmemDevLegacyStr(virDomainDef *def, - virDomainShmemDef *shmem, - virQEMUCaps *qemuCaps G_GNUC_UNUSED) +static virJSONValue * +qemuBuildShmemDevLegacyProps(virDomainDef *def, + virDomainShmemDef *shmem) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; + g_autofree char *size = NULL; + const char *shm = NULL; + g_autofree char *chardev = NULL; - virBufferAddLit(&buf, "ivshmem"); - virBufferAsprintf(&buf, ",id=%s", shmem->info.alias); + /* while this would result in a type error with newer qemus, the 'ivshmem' + * device was removed in qemu-4.0, so for the sake of not changing the + * commandline we do this hack */ + size = g_strdup_printf("%llum", shmem->size >> 20); - if (shmem->size) - virBufferAsprintf(&buf, ",size=%llum", shmem->size >> 20); + if (shmem->server.enabled) + chardev = g_strdup_printf("char%s", shmem->info.alias); + else + shm = shmem->name; - if (!shmem->server.enabled) { - virBufferAsprintf(&buf, ",shm=%s", shmem->name); - } else { - virBufferAsprintf(&buf, ",chardev=char%s", shmem->info.alias); - if (shmem->msi.enabled) { - virBufferAddLit(&buf, ",msi=on"); - if (shmem->msi.vectors) - virBufferAsprintf(&buf, ",vectors=%u", shmem->msi.vectors); - if (shmem->msi.ioeventfd) - virBufferAsprintf(&buf, ",ioeventfd=%s", - virTristateSwitchTypeToString(shmem->msi.ioeventfd)); - } - } + if (virJSONValueObjectCreate(&props, + "s:driver", "ivshmem", + "s:id", shmem->info.alias, + "s:size", size, + "S:shm", shm, + "S:chardev", chardev, + "B:msi", shmem->msi.enabled, + "p:vectors", shmem->msi.vectors, + "T:ioeventfd", shmem->msi.ioeventfd, + NULL) < 0) + return NULL; - if (qemuBuildDeviceAddressStr(&buf, def, &shmem->info) < 0) + if (qemuBuildDeviceAddressProps(props, def, &shmem->info) < 0) return NULL; - return virBufferContentAndReset(&buf); + return g_steal_pointer(&props); } -char * -qemuBuildShmemDevStr(virDomainDef *def, - virDomainShmemDef *shmem, - virQEMUCaps *qemuCaps G_GNUC_UNUSED) -{ - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - virBufferAdd(&buf, virDomainShmemModelTypeToString(shmem->model), -1); - virBufferAsprintf(&buf, ",id=%s", shmem->info.alias); +virJSONValue * +qemuBuildShmemDevProps(virDomainDef *def, + virDomainShmemDef *shmem) +{ + g_autoptr(virJSONValue) props = NULL; + g_autofree char *chardev = NULL; + g_autofree char *memdev = NULL; + virTristateSwitch master = VIR_TRISTATE_SWITCH_ABSENT; if (shmem->server.enabled) { - virBufferAsprintf(&buf, ",chardev=char%s", shmem->info.alias); + chardev = g_strdup_printf("char%s", shmem->info.alias); } else { - virBufferAsprintf(&buf, ",memdev=shmmem-%s", shmem->info.alias); + memdev = g_strdup_printf("shmmem-%s", shmem->info.alias); switch (shmem->role) { case VIR_DOMAIN_SHMEM_ROLE_MASTER: - virBufferAddLit(&buf, ",master=on"); + master = VIR_TRISTATE_SWITCH_ON; break; case VIR_DOMAIN_SHMEM_ROLE_PEER: - virBufferAddLit(&buf, ",master=off"); + master = VIR_TRISTATE_SWITCH_OFF; break; case VIR_DOMAIN_SHMEM_ROLE_DEFAULT: case VIR_DOMAIN_SHMEM_ROLE_LAST: @@ -9262,17 +9266,21 @@ qemuBuildShmemDevStr(virDomainDef *def, } } - if (shmem->msi.vectors) - virBufferAsprintf(&buf, ",vectors=%u", shmem->msi.vectors); - if (shmem->msi.ioeventfd) { - virBufferAsprintf(&buf, ",ioeventfd=%s", - virTristateSwitchTypeToString(shmem->msi.ioeventfd)); - } + if (virJSONValueObjectCreate(&props, + "s:driver", virDomainShmemModelTypeToString(shmem->model), + "s:id", shmem->info.alias, + "S:chardev", chardev, + "S:memdev", memdev, + "S:master", qemuOnOffAuto(master), + "p:vectors", shmem->msi.vectors, + "T:ioeventfd", shmem->msi.ioeventfd, + NULL) < 0) + return NULL; - if (qemuBuildDeviceAddressStr(&buf, def, &shmem->info) < 0) + if (qemuBuildDeviceAddressProps(props, def, &shmem->info) < 0) return NULL; - return virBufferContentAndReset(&buf); + return g_steal_pointer(&props); } @@ -9308,7 +9316,7 @@ qemuBuildShmemCommandLine(virLogManager *logManager, bool chardevStdioLogd) { g_autoptr(virJSONValue) memProps = NULL; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devProps = NULL; g_autofree char *chardev = NULL; unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT | QEMU_BUILD_CHARDEV_UNIX_FD_PASS; @@ -9343,7 +9351,7 @@ qemuBuildShmemCommandLine(virLogManager *logManager, switch (shmem->model) { case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM: - devstr = qemuBuildShmemDevLegacyStr(def, shmem, qemuCaps); + devProps = qemuBuildShmemDevLegacyProps(def, shmem); break; case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN: @@ -9355,20 +9363,21 @@ qemuBuildShmemCommandLine(virLogManager *logManager, G_GNUC_FALLTHROUGH; case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL: - devstr = qemuBuildShmemDevStr(def, shmem, qemuCaps); + devProps = qemuBuildShmemDevProps(def, shmem); break; case VIR_DOMAIN_SHMEM_MODEL_LAST: break; } - if (!devstr) + if (!devProps) return -1; if (qemuCommandAddExtDevice(cmd, &shmem->info) < 0) return -1; - virCommandAddArgList(cmd, "-device", devstr, NULL); + if (qemuBuildDeviceCommandlineFromJSON(cmd, devProps, qemuCaps) < 0) + return -1; if (shmem->server.enabled) { chardev = qemuBuildChrChardevStr(logManager, secManager, diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 86df734c57..3cf1671c79 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -228,10 +228,9 @@ virJSONValue *qemuBuildHotpluggableCPUProps(const virDomainVcpuDef *vcpu) virJSONValue *qemuBuildShmemBackendMemProps(virDomainShmemDef *shmem) ATTRIBUTE_NONNULL(1); -char *qemuBuildShmemDevStr(virDomainDef *def, - virDomainShmemDef *shmem, - virQEMUCaps *qemuCaps) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); +virJSONValue * +qemuBuildShmemDevProps(virDomainDef *def, + virDomainShmemDef *shmem); virJSONValue * qemuBuildWatchdogDevProps(const virDomainDef *def, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 3e0c9cf981..3ee0ccd088 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3004,7 +3004,7 @@ qemuDomainAttachShmemDevice(virQEMUDriver *driver, virDomainShmemDef *shmem) { int ret = -1; - g_autofree char *shmstr = NULL; + g_autoptr(virJSONValue) devProps = NULL; g_autofree char *charAlias = NULL; g_autofree char *memAlias = NULL; bool release_backing = false; @@ -3040,7 +3040,7 @@ qemuDomainAttachShmemDevice(virQEMUDriver *driver, (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0)) return -1; - if (!(shmstr = qemuBuildShmemDevStr(vm->def, shmem, priv->qemuCaps))) + if (!(devProps = qemuBuildShmemDevProps(vm->def, shmem))) goto cleanup; if (shmem->server.enabled) { @@ -3067,7 +3067,7 @@ qemuDomainAttachShmemDevice(virQEMUDriver *driver, if (qemuDomainAttachExtensionDevice(priv->mon, &shmem->info) < 0) goto exit_monitor; - if (qemuMonitorAddDevice(priv->mon, shmstr) < 0) { + if (qemuMonitorAddDeviceProps(priv->mon, &devProps) < 0) { ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &shmem->info)); goto exit_monitor; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Note that the legacy 'ivshmem' device was already removed upstream, but it's converted so that the code is identical.
For the two modern devices QEMU considers the properties being of following types:
'ivshmem-doorbell' chardev=<str> - ID of a chardev to use as a backend ioeventfd=<bool> - on/off (default: true) master=<OnOffAuto> - on/off/auto (default: "off") vectors=<uint32> - (default: 1)
'ivshmem-plain' master=<OnOffAuto> - on/off/auto (default: "off") memdev=<link<memory-backend>>
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 107 ++++++++++++++++++++++------------------ src/qemu/qemu_command.h | 7 ++- src/qemu/qemu_hotplug.c | 6 +-- 3 files changed, 64 insertions(+), 56 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The generated properties have the following types according to QEMU: deflate-on-oom=<bool> - on/off (default: false) free-page-reporting=<bool> - on/off (default: false) Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index cbd0b2890f..9b2e2f2719 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4210,36 +4210,35 @@ qemuBuildMemballoonCommandLine(virCommand *cmd, const virDomainDef *def, virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; if (!virDomainDefHasMemballoon(def)) return 0; - if (qemuBuildVirtioDevStr(&buf, qemuCaps, - VIR_DOMAIN_DEVICE_MEMBALLOON, - def->memballoon) < 0) { + if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_MEMBALLOON, + def->memballoon, qemuCaps))) return -1; - } - virBufferAsprintf(&buf, ",id=%s", def->memballoon->info.alias); - if (qemuBuildDeviceAddressStr(&buf, def, &def->memballoon->info) < 0) + if (virJSONValueObjectAdd(props, + "s:id", def->memballoon->info.alias, + NULL) < 0) return -1; - if (def->memballoon->autodeflate != VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAsprintf(&buf, ",deflate-on-oom=%s", - virTristateSwitchTypeToString(def->memballoon->autodeflate)); - } + if (qemuBuildDeviceAddressProps(props, def, &def->memballoon->info) < 0) + return -1; - if (def->memballoon->free_page_reporting != VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAsprintf(&buf, ",free-page-reporting=%s", - virTristateSwitchTypeToString(def->memballoon->free_page_reporting)); - } + if (virJSONValueObjectAdd(props, + "T:deflate-on-oom", def->memballoon->autodeflate, + "T:free-page-reporting", def->memballoon->free_page_reporting, + NULL) < 0) + return -1; if (qemuCommandAddExtDevice(cmd, &def->memballoon->info) < 0) return -1; - virCommandAddArg(cmd, "-device"); - virCommandAddArgBuffer(cmd, &buf); + if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0) + return -1; + return 0; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The generated properties have the following types according to QEMU: deflate-on-oom=<bool> - on/off (default: false) free-page-reporting=<bool> - on/off (default: false)
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

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> --- src/qemu/qemu_command.c | 8 ++------ tests/qemuxml2argvdata/balloon-ccw-deflate.args | 2 +- tests/qemuxml2argvdata/balloon-device-deflate-off.args | 2 +- tests/qemuxml2argvdata/balloon-device-deflate.args | 2 +- ...tions-memballoon-freepage-reporting.x86_64-latest.args | 2 +- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9b2e2f2719..95070e4a06 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4221,18 +4221,14 @@ qemuBuildMemballoonCommandLine(virCommand *cmd, if (virJSONValueObjectAdd(props, "s:id", def->memballoon->info.alias, + "T:deflate-on-oom", def->memballoon->autodeflate, + "T:free-page-reporting", def->memballoon->free_page_reporting, NULL) < 0) return -1; if (qemuBuildDeviceAddressProps(props, def, &def->memballoon->info) < 0) return -1; - if (virJSONValueObjectAdd(props, - "T:deflate-on-oom", def->memballoon->autodeflate, - "T:free-page-reporting", def->memballoon->free_page_reporting, - NULL) < 0) - return -1; - if (qemuCommandAddExtDevice(cmd, &def->memballoon->info) < 0) return -1; diff --git a/tests/qemuxml2argvdata/balloon-ccw-deflate.args b/tests/qemuxml2argvdata/balloon-ccw-deflate.args index bf56265638..0f2a8f0a30 100644 --- a/tests/qemuxml2argvdata/balloon-ccw-deflate.args +++ b/tests/qemuxml2argvdata/balloon-ccw-deflate.args @@ -24,5 +24,5 @@ QEMU_AUDIO_DRV=none \ -rtc base=utc \ -no-shutdown \ -boot strict=on \ --device virtio-balloon-ccw,id=balloon0,devno=fe.0.000a,deflate-on-oom=on \ +-device virtio-balloon-ccw,id=balloon0,deflate-on-oom=on,devno=fe.0.000a \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/balloon-device-deflate-off.args b/tests/qemuxml2argvdata/balloon-device-deflate-off.args index 4dba0f0e63..efe85c8194 100644 --- a/tests/qemuxml2argvdata/balloon-device-deflate-off.args +++ b/tests/qemuxml2argvdata/balloon-device-deflate-off.args @@ -28,5 +28,5 @@ QEMU_AUDIO_DRV=none \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x12,deflate-on-oom=off \ +-device virtio-balloon-pci,id=balloon0,deflate-on-oom=off,bus=pci.0,addr=0x12 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/balloon-device-deflate.args b/tests/qemuxml2argvdata/balloon-device-deflate.args index 778329f68b..ae05d0069c 100644 --- a/tests/qemuxml2argvdata/balloon-device-deflate.args +++ b/tests/qemuxml2argvdata/balloon-device-deflate.args @@ -28,5 +28,5 @@ QEMU_AUDIO_DRV=none \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x12,deflate-on-oom=on \ +-device virtio-balloon-pci,id=balloon0,deflate-on-oom=on,bus=pci.0,addr=0x12 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-options-memballoon-freepage-reporting.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options-memballoon-freepage-reporting.x86_64-latest.args index e3e32e4f34..e6ac1e27f2 100644 --- a/tests/qemuxml2argvdata/virtio-options-memballoon-freepage-reporting.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options-memballoon-freepage-reporting.x86_64-latest.args @@ -28,6 +28,6 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -audiodev id=audio1,driver=none \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2,free-page-reporting=on \ +-device virtio-balloon-pci,id=balloon0,free-page-reporting=on,bus=pci.0,addr=0x2 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
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> --- src/qemu/qemu_command.c | 8 ++------ tests/qemuxml2argvdata/balloon-ccw-deflate.args | 2 +- tests/qemuxml2argvdata/balloon-device-deflate-off.args | 2 +- tests/qemuxml2argvdata/balloon-device-deflate.args | 2 +- ...tions-memballoon-freepage-reporting.x86_64-latest.args | 2 +- 5 files changed, 6 insertions(+), 10 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The 'virtio-rng' has the following property types according to QEMU: rng=<link<rng-backend>> max-bytes=<uint64> - (default: 9223372036854775807) period=<uint32> - (default: 65536) Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 46 +++++++++++++++++++++++------------------ src/qemu/qemu_command.h | 7 ++++--- src/qemu/qemu_hotplug.c | 6 +++--- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 95070e4a06..b321c964ab 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5800,32 +5800,36 @@ qemuBuildRNGBackendProps(virDomainRNGDef *rng, } -char * -qemuBuildRNGDevStr(const virDomainDef *def, - virDomainRNGDef *dev, - virQEMUCaps *qemuCaps) +virJSONValue * +qemuBuildRNGDevProps(const virDomainDef *def, + virDomainRNGDef *dev, + virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; + unsigned int period = 0; - if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_RNG, dev) < 0) { + if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_RNG, dev, qemuCaps))) return NULL; - } - - virBufferAsprintf(&buf, ",rng=obj%s,id=%s", - dev->info.alias, dev->info.alias); if (dev->rate > 0) { - virBufferAsprintf(&buf, ",max-bytes=%u", dev->rate); - if (dev->period) - virBufferAsprintf(&buf, ",period=%u", dev->period); - else - virBufferAddLit(&buf, ",period=1000"); + period = dev->period; + + if (period == 0) + period = 1000; } - if (qemuBuildDeviceAddressStr(&buf, def, &dev->info) < 0) + if (virJSONValueObjectAdd(props, + "f:rng", g_strdup_printf("obj%s", dev->info.alias), + "s:id", dev->info.alias, + "p:max-bytes", dev->rate, + "p:period", period, + NULL) < 0) return NULL; - return virBufferContentAndReset(&buf); + if (qemuBuildDeviceAddressProps(props, def, &dev->info) < 0) + return NULL; + + return g_steal_pointer(&props); } @@ -5844,7 +5848,7 @@ qemuBuildRNGCommandLine(virLogManager *logManager, g_autoptr(virJSONValue) props = NULL; virDomainRNGDef *rng = def->rngs[i]; g_autofree char *chardev = NULL; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; if (!rng->info.alias) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -5871,9 +5875,11 @@ qemuBuildRNGCommandLine(virLogManager *logManager, if (qemuCommandAddExtDevice(cmd, &rng->info) < 0) return -1; - if (!(devstr = qemuBuildRNGDevStr(def, rng, qemuCaps))) + if (!(devprops = qemuBuildRNGDevProps(def, rng, qemuCaps))) + return -1; + + if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0) return -1; - virCommandAddArgList(cmd, "-device", devstr, NULL); } return 0; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 3cf1671c79..709b75c252 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -169,9 +169,10 @@ char *qemuBuildPCIHostdevDevStr(const virDomainDef *def, virDomainHostdevDef *dev, virQEMUCaps *qemuCaps); -char *qemuBuildRNGDevStr(const virDomainDef *def, - virDomainRNGDef *dev, - virQEMUCaps *qemuCaps); +virJSONValue * +qemuBuildRNGDevProps(const virDomainDef *def, + virDomainRNGDef *dev, + virQEMUCaps *qemuCaps); int qemuBuildRNGBackendProps(virDomainRNGDef *rng, virJSONValue **props); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 3ee0ccd088..4230f6f70e 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2309,7 +2309,7 @@ qemuDomainAttachRNGDevice(virQEMUDriver *driver, qemuDomainObjPrivate *priv = vm->privateData; virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_RNG, { .rng = rng } }; virErrorPtr orig_err; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; g_autofree char *charAlias = NULL; g_autofree char *objAlias = NULL; g_autofree char *tlsAlias = NULL; @@ -2338,7 +2338,7 @@ qemuDomainAttachRNGDevice(virQEMUDriver *driver, teardowncgroup = true; /* build required metadata */ - if (!(devstr = qemuBuildRNGDevStr(vm->def, rng, priv->qemuCaps))) + if (!(devprops = qemuBuildRNGDevProps(vm->def, rng, priv->qemuCaps))) goto cleanup; if (qemuBuildRNGBackendProps(rng, &props) < 0) @@ -2369,7 +2369,7 @@ qemuDomainAttachRNGDevice(virQEMUDriver *driver, if (qemuDomainAttachExtensionDevice(priv->mon, &rng->info) < 0) goto exit_monitor; - if (qemuMonitorAddDevice(priv->mon, devstr) < 0) { + if (qemuMonitorAddDeviceProps(priv->mon, &devprops) < 0) { ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &rng->info)); goto exit_monitor; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The 'virtio-rng' has the following property types according to QEMU: rng=<link<rng-backend>> max-bytes=<uint64> - (default: 9223372036854775807) period=<uint32> - (default: 65536)
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 46 +++++++++++++++++++++++------------------ src/qemu/qemu_command.h | 7 ++++--- src/qemu/qemu_hotplug.c | 6 +++--- 3 files changed, 33 insertions(+), 26 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The 'vfio-pci-nohotplug' device has the following property types according to QEMU: display=<OnOffAuto> - on/off/auto (default: "off") sysfsdev=<str> ramfb=<bool> bootindex=<int32> Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 48 ++++++++++++++++++----------------------- src/qemu/qemu_command.h | 7 +++--- src/qemu/qemu_hotplug.c | 7 +++--- 3 files changed, 27 insertions(+), 35 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b321c964ab..2f9e99068a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5338,40 +5338,34 @@ qemuBuildHostdevMdevModelTypeString(virDomainHostdevSubsysMediatedDev *mdev) } -char * -qemuBuildHostdevMediatedDevStr(const virDomainDef *def, - virDomainHostdevDef *dev, - virQEMUCaps *qemuCaps G_GNUC_UNUSED) +virJSONValue * +qemuBuildHostdevMediatedDevProps(const virDomainDef *def, + virDomainHostdevDef *dev) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; virDomainHostdevSubsysMediatedDev *mdevsrc = &dev->source.subsys.u.mdev; g_autofree char *mdevPath = NULL; - const char *dev_str = NULL; mdevPath = virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr); - dev_str = qemuBuildHostdevMdevModelTypeString(mdevsrc); - if (!dev_str) + if (virJSONValueObjectCreate(&props, + "s:driver", qemuBuildHostdevMdevModelTypeString(mdevsrc), + "s:id", dev->info->alias, + "s:sysfsdev", mdevPath, + "S:display", qemuOnOffAuto(mdevsrc->display), + NULL) < 0) return NULL; - virBufferAdd(&buf, dev_str, -1); - virBufferAsprintf(&buf, ",id=%s,sysfsdev=%s", dev->info->alias, mdevPath); - - if (mdevsrc->display != VIR_TRISTATE_SWITCH_ABSENT) - virBufferAsprintf(&buf, ",display=%s", - virTristateSwitchTypeToString(mdevsrc->display)); - - if (qemuBuildDeviceAddressStr(&buf, def, dev->info) < 0) + if (qemuBuildDeviceAddressProps(props, def, dev->info) < 0) return NULL; - if (dev->info->bootIndex) - virBufferAsprintf(&buf, ",bootindex=%u", dev->info->bootIndex); - - if (mdevsrc->ramfb == VIR_TRISTATE_SWITCH_ON) - virBufferAsprintf(&buf, ",ramfb=%s", - virTristateSwitchTypeToString(mdevsrc->ramfb)); + if (virJSONValueObjectAdd(props, + "T:ramfb", mdevsrc->ramfb, + "p:bootindex", dev->info->bootIndex, + NULL) < 0) + return NULL; - return virBufferContentAndReset(&buf); + return g_steal_pointer(&props); } @@ -5502,6 +5496,7 @@ qemuBuildHostdevCommandLine(virCommand *cmd, virDomainHostdevSubsys *subsys = &hostdev->source.subsys; virDomainHostdevSubsysMediatedDev *mdevsrc = &subsys->u.mdev; g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; g_autofree char *vhostfdName = NULL; int vhostfd = -1; @@ -5581,12 +5576,11 @@ qemuBuildHostdevCommandLine(virCommand *cmd, return -1; } - virCommandAddArg(cmd, "-device"); - if (!(devstr = - qemuBuildHostdevMediatedDevStr(def, hostdev, qemuCaps))) + if (!(devprops = qemuBuildHostdevMediatedDevProps(def, hostdev))) return -1; - virCommandAddArg(cmd, devstr); + if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0) + return -1; break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 709b75c252..45a9cb0ac1 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -199,10 +199,9 @@ qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def, virQEMUCaps *qemuCaps, char *vhostfdName); -char * -qemuBuildHostdevMediatedDevStr(const virDomainDef *def, - virDomainHostdevDef *dev, - virQEMUCaps *qemuCaps); +virJSONValue * +qemuBuildHostdevMediatedDevProps(const virDomainDef *def, + virDomainHostdevDef *dev); char *qemuBuildRedirdevDevStr(const virDomainDef *def, virDomainRedirdevDef *dev, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 4230f6f70e..8250ca76a2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2855,7 +2855,7 @@ qemuDomainAttachMediatedDevice(virQEMUDriver *driver, virDomainHostdevDef *hostdev) { int ret = -1; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; bool added = false; bool teardowncgroup = false; bool teardownlabel = false; @@ -2901,8 +2901,7 @@ qemuDomainAttachMediatedDevice(virQEMUDriver *driver, if (qemuAssignDeviceHostdevAlias(vm->def, &hostdev->info->alias, -1) < 0) goto cleanup; - if (!(devstr = qemuBuildHostdevMediatedDevStr(vm->def, hostdev, - priv->qemuCaps))) + if (!(devprops = qemuBuildHostdevMediatedDevProps(vm->def, hostdev))) goto cleanup; VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1); @@ -2912,7 +2911,7 @@ qemuDomainAttachMediatedDevice(virQEMUDriver *driver, teardownmemlock = true; qemuDomainObjEnterMonitor(driver, vm); - ret = qemuMonitorAddDevice(priv->mon, devstr); + ret = qemuMonitorAddDeviceProps(priv->mon, &devprops); if (qemuDomainObjExitMonitor(driver, vm) < 0) { ret = -1; goto cleanup; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The 'vfio-pci-nohotplug' device has the following property types according to QEMU:
display=<OnOffAuto> - on/off/auto (default: "off") sysfsdev=<str> ramfb=<bool> bootindex=<int32>
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 48 ++++++++++++++++++----------------------- src/qemu/qemu_command.h | 7 +++--- src/qemu/qemu_hotplug.c | 7 +++--- 3 files changed, 27 insertions(+), 35 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Simplify the generator by moving few properties earlier. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 8 ++------ .../hostdev-mdev-display-ramfb.x86_64-latest.args | 2 +- .../hostdev-subsys-mdev-vfio-ccw-boot.s390x-latest.args | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2f9e99068a..99287c013a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5353,18 +5353,14 @@ qemuBuildHostdevMediatedDevProps(const virDomainDef *def, "s:id", dev->info->alias, "s:sysfsdev", mdevPath, "S:display", qemuOnOffAuto(mdevsrc->display), + "T:ramfb", mdevsrc->ramfb, + "p:bootindex", dev->info->bootIndex, NULL) < 0) return NULL; if (qemuBuildDeviceAddressProps(props, def, dev->info) < 0) return NULL; - if (virJSONValueObjectAdd(props, - "T:ramfb", mdevsrc->ramfb, - "p:bootindex", dev->info->bootIndex, - NULL) < 0) - return NULL; - return g_steal_pointer(&props); } diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-latest.args b/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-latest.args index 0fd2da8c73..ab1ac4e1be 100644 --- a/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-latest.args +++ b/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-latest.args @@ -29,6 +29,6 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest2/.config \ -audiodev id=audio1,driver=none \ -vnc 127.0.0.1:0,audiodev=audio1 \ -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vram64_size_mb=0,vgamem_mb=16,max_outputs=1,bus=pci.0,addr=0x2 \ --device vfio-pci-nohotplug,id=hostdev0,sysfsdev=/sys/bus/mdev/devices/53764d0e-85a0-42b4-af5c-2046b460b1dc,display=on,bus=pci.0,addr=0x3,ramfb=on \ +-device vfio-pci-nohotplug,id=hostdev0,sysfsdev=/sys/bus/mdev/devices/53764d0e-85a0-42b4-af5c-2046b460b1dc,display=on,ramfb=on,bus=pci.0,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-boot.s390x-latest.args b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-boot.s390x-latest.args index 3b0e262336..ca90ef6c55 100644 --- a/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-boot.s390x-latest.args +++ b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-boot.s390x-latest.args @@ -26,7 +26,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-shutdown \ -boot strict=on \ -audiodev id=audio1,driver=none \ --device vfio-ccw,id=hostdev0,sysfsdev=/sys/bus/mdev/devices/90c6c135-ad44-41d0-b1b7-bae47de48627,devno=fe.0.0000,bootindex=1 \ +-device vfio-ccw,id=hostdev0,sysfsdev=/sys/bus/mdev/devices/90c6c135-ad44-41d0-b1b7-bae47de48627,bootindex=1,devno=fe.0.0000 \ -device virtio-balloon-ccw,id=balloon0,devno=fe.0.0001 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Simplify the generator by moving few properties earlier.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 8 ++------ .../hostdev-mdev-display-ramfb.x86_64-latest.args | 2 +- .../hostdev-subsys-mdev-vfio-ccw-boot.s390x-latest.args | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The 'usb-host' device has the following types according to QEMU for properties we control: hostdevice=<str> hostbus=<uint32> - (default: 0) hostaddr=<uint32> - (default: 0) bootindex=<int32> Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 46 ++++++++++++++++++++++++----------------- src/qemu/qemu_command.h | 7 ++++--- src/qemu/qemu_hotplug.c | 6 +++--- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 99287c013a..810a4cc760 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4779,15 +4779,17 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def, } -char * -qemuBuildUSBHostdevDevStr(const virDomainDef *def, - virDomainHostdevDef *dev, - virQEMUCaps *qemuCaps) +virJSONValue * +qemuBuildUSBHostdevDevProps(const virDomainDef *def, + virDomainHostdevDef *dev, + virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; virDomainHostdevSubsysUSB *usbsrc = &dev->source.subsys.u.usb; + unsigned int hostbus = 0; + unsigned int hostaddr = 0; + g_autofree char *hostdevice = NULL; - virBufferAddLit(&buf, "usb-host"); if (!dev->missing) { if (usbsrc->bus == 0 && usbsrc->device == 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -4796,21 +4798,28 @@ qemuBuildUSBHostdevDevStr(const virDomainDef *def, } if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_USB_HOST_HOSTDEVICE)) { - virBufferAsprintf(&buf, ",hostdevice=/dev/bus/usb/%03d/%03d", - usbsrc->bus, usbsrc->device); + hostdevice = g_strdup_printf("/dev/bus/usb/%03d/%03d", + usbsrc->bus, usbsrc->device); } else { - virBufferAsprintf(&buf, ",hostbus=%d,hostaddr=%d", - usbsrc->bus, usbsrc->device); + hostbus = usbsrc->bus; + hostaddr = usbsrc->device; } } - virBufferAsprintf(&buf, ",id=%s", dev->info->alias); - if (dev->info->bootIndex) - virBufferAsprintf(&buf, ",bootindex=%u", dev->info->bootIndex); - if (qemuBuildDeviceAddressStr(&buf, def, dev->info) < 0) + if (virJSONValueObjectCreate(&props, + "s:driver", "usb-host", + "S:hostdevice", hostdevice, + "p:hostbus", hostbus, + "p:hostaddr", hostaddr, + "s:id", dev->info->alias, + "p:bootindex", dev->info->bootIndex, + NULL) < 0) return NULL; - return virBufferContentAndReset(&buf); + if (qemuBuildDeviceAddressProps(props, def, dev->info) < 0) + return NULL; + + return g_steal_pointer(&props); } @@ -5502,12 +5511,11 @@ qemuBuildHostdevCommandLine(virCommand *cmd, switch ((virDomainHostdevSubsysType) subsys->type) { /* USB */ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: - virCommandAddArg(cmd, "-device"); - if (!(devstr = - qemuBuildUSBHostdevDevStr(def, hostdev, qemuCaps))) + if (!(devprops = qemuBuildUSBHostdevDevProps(def, hostdev, qemuCaps))) return -1; - virCommandAddArg(cmd, devstr); + if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0) + return -1; break; /* PCI */ diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 45a9cb0ac1..6995780f83 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -177,9 +177,10 @@ int qemuBuildRNGBackendProps(virDomainRNGDef *rng, virJSONValue **props); /* Current, best practice */ -char *qemuBuildUSBHostdevDevStr(const virDomainDef *def, - virDomainHostdevDef *dev, - virQEMUCaps *qemuCaps); +virJSONValue * +qemuBuildUSBHostdevDevProps(const virDomainDef *def, + virDomainHostdevDef *dev, + virQEMUCaps *qemuCaps); char *qemuBuildSCSIHostdevDevStr(const virDomainDef *def, virDomainHostdevDef *dev, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 8250ca76a2..e1db3d55f3 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2573,7 +2573,7 @@ qemuDomainAttachHostUSBDevice(virQEMUDriver *driver, virDomainHostdevDef *hostdev) { qemuDomainObjPrivate *priv = vm->privateData; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; bool added = false; bool teardowncgroup = false; bool teardownlabel = false; @@ -2601,13 +2601,13 @@ qemuDomainAttachHostUSBDevice(virQEMUDriver *driver, if (qemuAssignDeviceHostdevAlias(vm->def, &hostdev->info->alias, -1) < 0) goto cleanup; - if (!(devstr = qemuBuildUSBHostdevDevStr(vm->def, hostdev, priv->qemuCaps))) + if (!(devprops = qemuBuildUSBHostdevDevProps(vm->def, hostdev, priv->qemuCaps))) goto cleanup; VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1); qemuDomainObjEnterMonitor(driver, vm); - ret = qemuMonitorAddDevice(priv->mon, devstr); + ret = qemuMonitorAddDeviceProps(priv->mon, &devprops); if (qemuDomainObjExitMonitor(driver, vm) < 0) { ret = -1; goto cleanup; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The 'usb-host' device has the following types according to QEMU for properties we control:
hostdevice=<str> hostbus=<uint32> - (default: 0) hostaddr=<uint32> - (default: 0) bootindex=<int32>
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 46 ++++++++++++++++++++++++----------------- src/qemu/qemu_command.h | 7 ++++--- src/qemu/qemu_hotplug.c | 6 +++--- 3 files changed, 34 insertions(+), 25 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The 'usb-redir' device has the following types according to QEMU for properties we control: chardev=<str> - ID of a chardev to use as a backend filter=<str> bootindex=<int32> Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 49 +++++++++++++++++++++++------------------ src/qemu/qemu_command.h | 6 ++--- src/qemu/qemu_hotplug.c | 6 ++--- 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 810a4cc760..bab1da1c11 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9710,20 +9710,17 @@ qemuBuildConsoleCommandLine(virLogManager *logManager, } -char * -qemuBuildRedirdevDevStr(const virDomainDef *def, - virDomainRedirdevDef *dev, - virQEMUCaps *qemuCaps G_GNUC_UNUSED) +virJSONValue * +qemuBuildRedirdevDevProps(const virDomainDef *def, + virDomainRedirdevDef *dev) { - size_t i; - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; virDomainRedirFilterDef *redirfilter = def->redirfilter; + g_autofree char *filter = NULL; - virBufferAsprintf(&buf, "usb-redir,chardev=char%s,id=%s", - dev->info.alias, dev->info.alias); - - if (redirfilter && redirfilter->nusbdevs) { - virBufferAddLit(&buf, ",filter="); + if (redirfilter) { + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + size_t i; for (i = 0; i < redirfilter->nusbdevs; i++) { virDomainRedirFilterUSBDevDef *usbdev = redirfilter->usbdevs[i]; @@ -9747,19 +9744,26 @@ qemuBuildRedirdevDevStr(const virDomainDef *def, else virBufferAddLit(&buf, "-1:"); - virBufferAsprintf(&buf, "%u", usbdev->allow); - if (i < redirfilter->nusbdevs -1) - virBufferAddLit(&buf, "|"); + virBufferAsprintf(&buf, "%u|", usbdev->allow); } + virBufferTrim(&buf, "|"); + + filter = virBufferContentAndReset(&buf); } - if (dev->info.bootIndex) - virBufferAsprintf(&buf, ",bootindex=%u", dev->info.bootIndex); + if (virJSONValueObjectCreate(&props, + "s:driver", "usb-redir", + "f:chardev", g_strdup_printf("char%s", dev->info.alias), + "s:id", dev->info.alias, + "S:filter", filter, + "p:bootindex", dev->info.bootIndex, + NULL) < 0) + return NULL; - if (qemuBuildDeviceAddressStr(&buf, def, &dev->info) < 0) + if (qemuBuildDeviceAddressProps(props, def, &dev->info) < 0) return NULL; - return virBufferContentAndReset(&buf); + return g_steal_pointer(&props); } @@ -9780,6 +9784,7 @@ qemuBuildRedirdevCommandLine(virLogManager *logManager, for (i = 0; i < def->nredirdevs; i++) { virDomainRedirdevDef *redirdev = def->redirdevs[i]; + g_autoptr(virJSONValue) devprops = NULL; char *devstr; if (!(devstr = qemuBuildChrChardevStr(logManager, secManager, @@ -9794,11 +9799,11 @@ qemuBuildRedirdevCommandLine(virLogManager *logManager, virCommandAddArg(cmd, devstr); VIR_FREE(devstr); - virCommandAddArg(cmd, "-device"); - if (!(devstr = qemuBuildRedirdevDevStr(def, redirdev, qemuCaps))) + if (!(devprops = qemuBuildRedirdevDevProps(def, redirdev))) + return -1; + + if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, devstr); - VIR_FREE(devstr); } return 0; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 6995780f83..f965125277 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -204,9 +204,9 @@ virJSONValue * qemuBuildHostdevMediatedDevProps(const virDomainDef *def, virDomainHostdevDef *dev); -char *qemuBuildRedirdevDevStr(const virDomainDef *def, - virDomainRedirdevDef *dev, - virQEMUCaps *qemuCaps); +virJSONValue * +qemuBuildRedirdevDevProps(const virDomainDef *def, + virDomainRedirdevDef *dev); char *qemuBuildZPCIDevStr(virDomainDeviceInfo *dev); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index e1db3d55f3..422ab267cf 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1961,7 +1961,7 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriver *driver, qemuDomainObjPrivate *priv = vm->privateData; virDomainDef *def = vm->def; g_autofree char *charAlias = NULL; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; bool chardevAdded = false; g_autofree char *tlsAlias = NULL; const char *secAlias = NULL; @@ -1976,7 +1976,7 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriver *driver, if ((virDomainUSBAddressEnsure(priv->usbaddrs, &redirdev->info)) < 0) return -1; - if (!(devstr = qemuBuildRedirdevDevStr(def, redirdev, priv->qemuCaps))) + if (!(devprops = qemuBuildRedirdevDevProps(def, redirdev))) goto cleanup; VIR_REALLOC_N(def->redirdevs, def->nredirdevs+1); @@ -1994,7 +1994,7 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriver *driver, goto exit_monitor; chardevAdded = true; - if (qemuMonitorAddDevice(priv->mon, devstr) < 0) + if (qemuMonitorAddDeviceProps(priv->mon, &devprops) < 0) goto exit_monitor; if (qemuDomainObjExitMonitor(driver, vm) < 0) -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The 'usb-redir' device has the following types according to QEMU for properties we control:
chardev=<str> - ID of a chardev to use as a backend filter=<str> bootindex=<int32>
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 49 +++++++++++++++++++++++------------------ src/qemu/qemu_command.h | 6 ++--- src/qemu/qemu_hotplug.c | 6 ++--- 3 files changed, 33 insertions(+), 28 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

For 'usb-mouse'/'usb-tablet'/'usb-kbd' we don't use any special property. For 'virtio-input-pci' we only use the 'evdev' argument which is a string so this conversion doesn't impact anything. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 107 +++++++++++++++++++++------------------- src/qemu/qemu_command.h | 14 +++--- src/qemu/qemu_hotplug.c | 46 ++++++++++------- 3 files changed, 91 insertions(+), 76 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index bab1da1c11..9f593151ab 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4271,21 +4271,19 @@ qemuBuildNVRAMCommandLine(virCommand *cmd, } -static char * -qemuBuildVirtioInputDevStr(const virDomainDef *def, - virDomainInputDef *dev, - virQEMUCaps *qemuCaps) +virJSONValue * +qemuBuildInputVirtioDevProps(const virDomainDef *def, + virDomainInputDef *dev, + virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; + const char *evdev = NULL; switch ((virDomainInputType)dev->type) { case VIR_DOMAIN_INPUT_TYPE_MOUSE: case VIR_DOMAIN_INPUT_TYPE_TABLET: case VIR_DOMAIN_INPUT_TYPE_KBD: case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH: - if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_INPUT, dev) < 0) { - return NULL; - } break; case VIR_DOMAIN_INPUT_TYPE_EVDEV: case VIR_DOMAIN_INPUT_TYPE_LAST: @@ -4294,42 +4292,54 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def, return NULL; } - virBufferAsprintf(&buf, ",id=%s", dev->info.alias); + if (dev->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) + evdev = dev->source.evdev; - if (dev->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) { - virBufferAddLit(&buf, ",evdev="); - virQEMUBuildBufferEscapeComma(&buf, dev->source.evdev); - } + if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_INPUT, dev, qemuCaps))) + return NULL; - if (qemuBuildDeviceAddressStr(&buf, def, &dev->info) < 0) + if (virJSONValueObjectAdd(props, + "s:id", dev->info.alias, + "S:evdev", evdev, + NULL) < 0) return NULL; - return virBufferContentAndReset(&buf); + if (qemuBuildDeviceAddressProps(props, def, &dev->info) < 0) + return NULL; + + return g_steal_pointer(&props); } -static char * -qemuBuildUSBInputDevStr(const virDomainDef *def, - virDomainInputDef *dev, - virQEMUCaps *qemuCaps G_GNUC_UNUSED) + +virJSONValue * +qemuBuildInputUSBDevProps(const virDomainDef *def, + virDomainInputDef *dev) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; + const char *driver = NULL; switch (dev->type) { case VIR_DOMAIN_INPUT_TYPE_MOUSE: - virBufferAsprintf(&buf, "usb-mouse,id=%s", dev->info.alias); + driver = "usb-mouse"; break; case VIR_DOMAIN_INPUT_TYPE_TABLET: - virBufferAsprintf(&buf, "usb-tablet,id=%s", dev->info.alias); + driver = "usb-tablet"; break; case VIR_DOMAIN_INPUT_TYPE_KBD: - virBufferAsprintf(&buf, "usb-kbd,id=%s", dev->info.alias); + driver = "usb-kbd"; break; } - if (qemuBuildDeviceAddressStr(&buf, def, &dev->info) < 0) + if (virJSONValueObjectCreate(&props, + "s:driver", driver, + "s:id", dev->info.alias, + NULL) < 0) return NULL; - return virBufferContentAndReset(&buf); + if (qemuBuildDeviceAddressProps(props, def, &dev->info) < 0) + return NULL; + + return g_steal_pointer(&props); } @@ -4356,27 +4366,6 @@ qemuBuildInputEvdevProps(virDomainInputDef *dev) } -int -qemuBuildInputDevStr(char **devstr, - const virDomainDef *def, - virDomainInputDef *input, - virQEMUCaps *qemuCaps) -{ - switch (input->bus) { - case VIR_DOMAIN_INPUT_BUS_USB: - if (!(*devstr = qemuBuildUSBInputDevStr(def, input, qemuCaps))) - return -1; - break; - - case VIR_DOMAIN_INPUT_BUS_VIRTIO: - if (!(*devstr = qemuBuildVirtioInputDevStr(def, input, qemuCaps))) - return -1; - break; - } - return 0; -} - - static int qemuBuildInputCommandLine(virCommand *cmd, const virDomainDef *def, @@ -4399,15 +4388,29 @@ qemuBuildInputCommandLine(virCommand *cmd, if (qemuBuildObjectCommandlineFromJSON(cmd, props, qemuCaps) < 0) return -1; } else { - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) props = NULL; - if (qemuBuildInputDevStr(&devstr, def, input, qemuCaps) < 0) - return -1; + switch ((virDomainInputBus) input->bus) { + case VIR_DOMAIN_INPUT_BUS_USB: + if (!(props = qemuBuildInputUSBDevProps(def, input))) + return -1; + break; - if (devstr) { - virCommandAddArg(cmd, "-device"); - virCommandAddArg(cmd, devstr); + case VIR_DOMAIN_INPUT_BUS_VIRTIO: + if (!(props = qemuBuildInputVirtioDevProps(def, input, qemuCaps))) + return -1; + + case VIR_DOMAIN_INPUT_BUS_PS2: + case VIR_DOMAIN_INPUT_BUS_XEN: + case VIR_DOMAIN_INPUT_BUS_PARALLELS: + case VIR_DOMAIN_INPUT_BUS_NONE: + case VIR_DOMAIN_INPUT_BUS_LAST: + break; } + + if (props && + qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0) + return -1; } } diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index f965125277..e8561c0a3c 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -237,12 +237,14 @@ virJSONValue * qemuBuildWatchdogDevProps(const virDomainDef *def, virDomainWatchdogDef *dev); -int qemuBuildInputDevStr(char **devstr, - const virDomainDef *def, - virDomainInputDef *input, - virQEMUCaps *qemuCaps) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) - ATTRIBUTE_NONNULL(4); +virJSONValue * +qemuBuildInputVirtioDevProps(const virDomainDef *def, + virDomainInputDef *dev, + virQEMUCaps *qemuCaps); + +virJSONValue * +qemuBuildInputUSBDevProps(const virDomainDef *def, + virDomainInputDef *dev); char * qemuBuildVsockDevStr(virDomainDef *def, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 422ab267cf..3c76e9be91 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3229,7 +3229,7 @@ qemuDomainAttachInputDevice(virQEMUDriver *driver, virDomainInputDef *input) { int ret = -1; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; qemuDomainObjPrivate *priv = vm->privateData; virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_INPUT, { .input = input } }; @@ -3239,28 +3239,38 @@ qemuDomainAttachInputDevice(virQEMUDriver *driver, bool teardownlabel = false; bool teardowncgroup = false; - if (input->bus != VIR_DOMAIN_INPUT_BUS_USB && - input->bus != VIR_DOMAIN_INPUT_BUS_VIRTIO) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, - _("input device on bus '%s' cannot be hot plugged."), - virDomainInputBusTypeToString(input->bus)); + if (qemuAssignDeviceInputAlias(vm->def, input, -1) < 0) return -1; - } - if (input->bus == VIR_DOMAIN_INPUT_BUS_VIRTIO) { - if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev) < 0) - return -1; - } else if (input->bus == VIR_DOMAIN_INPUT_BUS_USB) { + switch ((virDomainInputBus) input->bus) { + case VIR_DOMAIN_INPUT_BUS_USB: if (virDomainUSBAddressEnsure(priv->usbaddrs, &input->info) < 0) - goto cleanup; + return -1; + releaseaddr = true; - } - if (qemuAssignDeviceInputAlias(vm->def, input, -1) < 0) - goto cleanup; + if (!(devprops = qemuBuildInputUSBDevProps(vm->def, input))) + goto cleanup; + break; - if (qemuBuildInputDevStr(&devstr, vm->def, input, priv->qemuCaps) < 0) - goto cleanup; + case VIR_DOMAIN_INPUT_BUS_VIRTIO: + if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev) < 0) + goto cleanup; + + if (!(devprops = qemuBuildInputVirtioDevProps(vm->def, input, priv->qemuCaps))) + goto cleanup; + break; + + case VIR_DOMAIN_INPUT_BUS_PS2: + case VIR_DOMAIN_INPUT_BUS_XEN: + case VIR_DOMAIN_INPUT_BUS_PARALLELS: + case VIR_DOMAIN_INPUT_BUS_NONE: + case VIR_DOMAIN_INPUT_BUS_LAST: + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("input device on bus '%s' cannot be hot plugged."), + virDomainInputBusTypeToString(input->bus)); + return -1; + } if (qemuDomainNamespaceSetupInput(vm, input, &teardowndevice) < 0) goto cleanup; @@ -3280,7 +3290,7 @@ qemuDomainAttachInputDevice(virQEMUDriver *driver, if (qemuDomainAttachExtensionDevice(priv->mon, &input->info) < 0) goto exit_monitor; - if (qemuMonitorAddDevice(priv->mon, devstr) < 0) { + if (qemuMonitorAddDeviceProps(priv->mon, &devprops) < 0) { ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &input->info)); goto exit_monitor; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
For 'usb-mouse'/'usb-tablet'/'usb-kbd' we don't use any special property.
For 'virtio-input-pci' we only use the 'evdev' argument which is a string so this conversion doesn't impact anything.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 107 +++++++++++++++++++++------------------- src/qemu/qemu_command.h | 14 +++--- src/qemu/qemu_hotplug.c | 46 ++++++++++------- 3 files changed, 91 insertions(+), 76 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Generate the 'zpci' device via JSON. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 81 +++++++++++++++++++---------------------- src/qemu/qemu_command.h | 3 +- src/qemu/qemu_hotplug.c | 27 +++++--------- 3 files changed, 49 insertions(+), 62 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9f593151ab..e8043f0055 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2232,48 +2232,43 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, return virBufferContentAndReset(&opt); } -char * -qemuBuildZPCIDevStr(virDomainDeviceInfo *dev) -{ - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - - virBufferAsprintf(&buf, - "zpci,uid=%u,fid=%u,target=%s,id=zpci%u", - dev->addr.pci.zpci.uid.value, - dev->addr.pci.zpci.fid.value, - dev->alias, - dev->addr.pci.zpci.uid.value); - - return virBufferContentAndReset(&buf); -} -static int -qemuCommandAddZPCIDevice(virCommand *cmd, - virDomainDeviceInfo *dev) +virJSONValue * +qemuBuildZPCIDevProps(virDomainDeviceInfo *dev) { - g_autofree char *devstr = NULL; + virJSONValue *props = NULL; - virCommandAddArg(cmd, "-device"); - - if (!(devstr = qemuBuildZPCIDevStr(dev))) - return -1; - - virCommandAddArg(cmd, devstr); + virJSONValueObjectCreate(&props, + "s:driver", "zpci", + "u:uid", dev->addr.pci.zpci.uid.value, + "u:fid", dev->addr.pci.zpci.fid.value, + "s:target", dev->alias, + "f:id", g_strdup_printf("zpci%u", dev->addr.pci.zpci.uid.value), + NULL); - return 0; + return props; } + static int qemuCommandAddExtDevice(virCommand *cmd, - virDomainDeviceInfo *dev) + virDomainDeviceInfo *dev, + virQEMUCaps *qemuCaps) { if (dev->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI || dev->addr.pci.extFlags == VIR_PCI_ADDRESS_EXTENSION_NONE) { return 0; } - if (dev->addr.pci.extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) - return qemuCommandAddZPCIDevice(cmd, dev); + if (dev->addr.pci.extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) { + g_autoptr(virJSONValue) devprops = NULL; + + if (!(devprops = qemuBuildZPCIDevProps(dev))) + return -1; + + if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0) + return -1; + } return 0; } @@ -2480,7 +2475,7 @@ qemuBuildDiskCommandLine(virCommand *cmd, !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) return 0; - if (qemuCommandAddExtDevice(cmd, &disk->info) < 0) + if (qemuCommandAddExtDevice(cmd, &disk->info, qemuCaps) < 0) return -1; virCommandAddArg(cmd, "-device"); @@ -2588,7 +2583,7 @@ qemuBuildVHostUserFsCommandLine(virCommand *cmd, virCommandAddArg(cmd, "-chardev"); virCommandAddArg(cmd, chrdevstr); - if (qemuCommandAddExtDevice(cmd, &fs->info) < 0) + if (qemuCommandAddExtDevice(cmd, &fs->info, priv->qemuCaps) < 0) return -1; if (!(devstr = qemuBuildVHostUserFsDevStr(fs, def, chardev_alias, priv))) @@ -2686,7 +2681,7 @@ qemuBuildFSDevCommandLine(virCommand *cmd, return -1; virCommandAddArg(cmd, fsdevstr); - if (qemuCommandAddExtDevice(cmd, &fs->info) < 0) + if (qemuCommandAddExtDevice(cmd, &fs->info, qemuCaps) < 0) return -1; virCommandAddArg(cmd, "-device"); @@ -3228,7 +3223,7 @@ qemuBuildControllersByTypeCommandLine(virCommand *cmd, return -1; if (devstr) { - if (qemuCommandAddExtDevice(cmd, &cont->info) < 0) + if (qemuCommandAddExtDevice(cmd, &cont->info, qemuCaps) < 0) return -1; virCommandAddArg(cmd, "-device"); @@ -4177,7 +4172,7 @@ qemuBuildWatchdogCommandLine(virCommand *cmd, if (!def->watchdog) return 0; - if (qemuCommandAddExtDevice(cmd, &def->watchdog->info) < 0) + if (qemuCommandAddExtDevice(cmd, &def->watchdog->info, qemuCaps) < 0) return -1; if (!(props = qemuBuildWatchdogDevProps(def, watchdog))) @@ -4229,7 +4224,7 @@ qemuBuildMemballoonCommandLine(virCommand *cmd, if (qemuBuildDeviceAddressProps(props, def, &def->memballoon->info) < 0) return -1; - if (qemuCommandAddExtDevice(cmd, &def->memballoon->info) < 0) + if (qemuCommandAddExtDevice(cmd, &def->memballoon->info, qemuCaps) < 0) return -1; if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0) @@ -4376,7 +4371,7 @@ qemuBuildInputCommandLine(virCommand *cmd, for (i = 0; i < def->ninputs; i++) { virDomainInputDef *input = def->inputs[i]; - if (qemuCommandAddExtDevice(cmd, &input->info) < 0) + if (qemuCommandAddExtDevice(cmd, &input->info, qemuCaps) < 0) return -1; if (input->type == VIR_DOMAIN_INPUT_TYPE_EVDEV) { @@ -4522,7 +4517,7 @@ qemuBuildSoundCommandLine(virCommand *cmd, if (sound->model == VIR_DOMAIN_SOUND_MODEL_PCSPK) { virCommandAddArgList(cmd, "-soundhw", "pcspk", NULL); } else { - if (qemuCommandAddExtDevice(cmd, &sound->info) < 0) + if (qemuCommandAddExtDevice(cmd, &sound->info, qemuCaps) < 0) return -1; virCommandAddArg(cmd, "-device"); @@ -4711,7 +4706,7 @@ qemuBuildVideoCommandLine(virCommand *cmd, if (video->type == VIR_DOMAIN_VIDEO_TYPE_NONE) continue; - if (qemuCommandAddExtDevice(cmd, &def->videos[i]->info) < 0) + if (qemuCommandAddExtDevice(cmd, &def->videos[i]->info, qemuCaps) < 0) return -1; virCommandAddArg(cmd, "-device"); @@ -5527,7 +5522,7 @@ qemuBuildHostdevCommandLine(virCommand *cmd, if (hostdev->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED) continue; - if (qemuCommandAddExtDevice(cmd, hostdev->info) < 0) + if (qemuCommandAddExtDevice(cmd, hostdev->info, qemuCaps) < 0) return -1; virCommandAddArg(cmd, "-device"); @@ -5873,7 +5868,7 @@ qemuBuildRNGCommandLine(virLogManager *logManager, return -1; /* add the device */ - if (qemuCommandAddExtDevice(cmd, &rng->info) < 0) + if (qemuCommandAddExtDevice(cmd, &rng->info, qemuCaps) < 0) return -1; if (!(devprops = qemuBuildRNGDevProps(def, rng, qemuCaps))) @@ -8990,14 +8985,14 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, * New way: -netdev type=tap,id=netdev1 -device e1000,id=netdev1 */ if (qemuDomainSupportsNicdev(def, net)) { - if (qemuCommandAddExtDevice(cmd, &net->info) < 0) + if (qemuCommandAddExtDevice(cmd, &net->info, qemuCaps) < 0) goto cleanup; if (!(nic = qemuBuildNicDevStr(def, net, net->driver.virtio.queues, qemuCaps))) goto cleanup; virCommandAddArgList(cmd, "-device", nic, NULL); } else if (!requireNicdev) { - if (qemuCommandAddExtDevice(cmd, &net->info) < 0) + if (qemuCommandAddExtDevice(cmd, &net->info, qemuCaps) < 0) goto cleanup; if (!(nic = qemuBuildLegacyNicStr(net))) @@ -9375,7 +9370,7 @@ qemuBuildShmemCommandLine(virLogManager *logManager, if (!devProps) return -1; - if (qemuCommandAddExtDevice(cmd, &shmem->info) < 0) + if (qemuCommandAddExtDevice(cmd, &shmem->info, qemuCaps) < 0) return -1; if (qemuBuildDeviceCommandlineFromJSON(cmd, devProps, qemuCaps) < 0) @@ -10520,7 +10515,7 @@ qemuBuildVsockCommandLine(virCommand *cmd, virCommandPassFD(cmd, priv->vhostfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); priv->vhostfd = -1; - if (qemuCommandAddExtDevice(cmd, &vsock->info) < 0) + if (qemuCommandAddExtDevice(cmd, &vsock->info, qemuCaps) < 0) return -1; virCommandAddArgList(cmd, "-device", devstr, NULL); diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index e8561c0a3c..81cdbed384 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -208,7 +208,8 @@ virJSONValue * qemuBuildRedirdevDevProps(const virDomainDef *def, virDomainRedirdevDef *dev); -char *qemuBuildZPCIDevStr(virDomainDeviceInfo *dev); +virJSONValue * +qemuBuildZPCIDevProps(virDomainDeviceInfo *dev); int qemuNetworkPrepareDevices(virDomainDef *def); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 3c76e9be91..ea7028eae5 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -138,22 +138,6 @@ qemuDomainDeleteDevice(virDomainObj *vm, } -static int -qemuDomainAttachZPCIDevice(qemuMonitor *mon, - virDomainDeviceInfo *info) -{ - g_autofree char *devstr_zpci = NULL; - - if (!(devstr_zpci = qemuBuildZPCIDevStr(info))) - return -1; - - if (qemuMonitorAddDevice(mon, devstr_zpci) < 0) - return -1; - - return 0; -} - - static int qemuDomainDetachZPCIDevice(qemuMonitor *mon, virDomainDeviceInfo *info) @@ -178,8 +162,15 @@ qemuDomainAttachExtensionDevice(qemuMonitor *mon, return 0; } - if (info->addr.pci.extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) - return qemuDomainAttachZPCIDevice(mon, info); + if (info->addr.pci.extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) { + g_autoptr(virJSONValue) devprops = NULL; + + if (!(devprops = qemuBuildZPCIDevProps(info))) + return -1; + + if (qemuMonitorAddDeviceProps(mon, &devprops) < 0) + return -1; + } return 0; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Generate the 'zpci' device via JSON.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 81 +++++++++++++++++++---------------------- src/qemu/qemu_command.h | 3 +- src/qemu/qemu_hotplug.c | 27 +++++--------- 3 files changed, 49 insertions(+), 62 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

For properties we use these are the QEMU types: host=<str> - Address (bus/device/function) of the host device, example: 04:10.0 bootindex=<int32> failover_pair_id=<str> Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 69 ++++++++++++++++++++++------------------- src/qemu/qemu_command.h | 6 ++-- src/qemu/qemu_hotplug.c | 6 ++-- 3 files changed, 43 insertions(+), 38 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e8043f0055..5a1ad69148 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4721,20 +4721,23 @@ qemuBuildVideoCommandLine(virCommand *cmd, } -char * -qemuBuildPCIHostdevDevStr(const virDomainDef *def, - virDomainHostdevDef *dev, - virQEMUCaps *qemuCaps G_GNUC_UNUSED) +virJSONValue * +qemuBuildPCIHostdevDevProps(const virDomainDef *def, + virDomainHostdevDef *dev) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; virDomainHostdevSubsysPCI *pcisrc = &dev->source.subsys.u.pci; - int backend = pcisrc->backend; virDomainNetTeamingInfo *teaming; + g_autofree char *host = g_strdup_printf(VIR_PCI_DEVICE_ADDRESS_FMT, + pcisrc->addr.domain, + pcisrc->addr.bus, + pcisrc->addr.slot, + pcisrc->addr.function); + const char *failover_pair_id = NULL; /* caller has to assign proper passthrough backend type */ - switch ((virDomainHostdevSubsysPCIBackendType)backend) { + switch ((virDomainHostdevSubsysPCIBackendType) pcisrc->backend) { case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO: - virBufferAddLit(&buf, "vfio-pci"); break; case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM: @@ -4743,25 +4746,10 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def, case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid PCI passthrough type '%s'"), - virDomainHostdevSubsysPCIBackendTypeToString(backend)); + virDomainHostdevSubsysPCIBackendTypeToString(pcisrc->backend)); return NULL; } - virBufferAddLit(&buf, ",host="); - virBufferAsprintf(&buf, - VIR_PCI_DEVICE_ADDRESS_FMT, - pcisrc->addr.domain, - pcisrc->addr.bus, - pcisrc->addr.slot, - pcisrc->addr.function); - virBufferAsprintf(&buf, ",id=%s", dev->info->alias); - if (dev->info->effectiveBootIndex > 0) - virBufferAsprintf(&buf, ",bootindex=%u", dev->info->effectiveBootIndex); - if (qemuBuildDeviceAddressStr(&buf, def, dev->info) < 0) - return NULL; - if (qemuBuildRomStr(&buf, dev->info) < 0) - return NULL; - if (dev->parentnet) teaming = dev->parentnet->teaming; else @@ -4769,11 +4757,29 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def, if (teaming && teaming->type == VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT && - teaming->persistent) { - virBufferAsprintf(&buf, ",failover_pair_id=%s", teaming->persistent); - } + teaming->persistent) + failover_pair_id = teaming->persistent; - return virBufferContentAndReset(&buf); + if (virJSONValueObjectCreate(&props, + "s:driver", "vfio-pci", + "s:host", host, + "s:id", dev->info->alias, + "p:bootindex", dev->info->effectiveBootIndex, + NULL) < 0) + return NULL; + + if (qemuBuildDeviceAddressProps(props, def, dev->info) < 0) + return NULL; + + if (qemuBuildRomProps(props, dev->info) < 0) + return NULL; + + if (virJSONValueObjectAdd(props, + "S:failover_pair_id", failover_pair_id, + NULL) < 0) + return NULL; + + return g_steal_pointer(&props); } @@ -5525,12 +5531,11 @@ qemuBuildHostdevCommandLine(virCommand *cmd, if (qemuCommandAddExtDevice(cmd, hostdev->info, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-device"); - devstr = qemuBuildPCIHostdevDevStr(def, hostdev, qemuCaps); - if (!devstr) + if (!(devprops = qemuBuildPCIHostdevDevProps(def, hostdev))) return -1; - virCommandAddArg(cmd, devstr); + if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0) + return -1; break; /* SCSI */ diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 81cdbed384..8ad87f4277 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -165,9 +165,9 @@ qemuBuildMemoryDeviceProps(const virDomainDef *def, virDomainMemoryDef *mem); /* Current, best practice */ -char *qemuBuildPCIHostdevDevStr(const virDomainDef *def, - virDomainHostdevDef *dev, - virQEMUCaps *qemuCaps); +virJSONValue * +qemuBuildPCIHostdevDevProps(const virDomainDef *def, + virDomainHostdevDef *dev); virJSONValue * qemuBuildRNGDevProps(const virDomainDef *def, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ea7028eae5..67aed2c128 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1629,7 +1629,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriver *driver, { .hostdev = hostdev } }; virDomainDeviceInfo *info = hostdev->info; int ret; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; bool releaseaddr = false; bool teardowncgroup = false; bool teardownlabel = false; @@ -1706,7 +1706,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriver *driver, goto error; } - if (!(devstr = qemuBuildPCIHostdevDevStr(vm->def, hostdev, priv->qemuCaps))) + if (!(devprops = qemuBuildPCIHostdevDevProps(vm->def, hostdev))) goto error; qemuDomainObjEnterMonitor(driver, vm); @@ -1714,7 +1714,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriver *driver, if ((ret = qemuDomainAttachExtensionDevice(priv->mon, hostdev->info)) < 0) goto exit_monitor; - if ((ret = qemuMonitorAddDevice(priv->mon, devstr)) < 0) + if ((ret = qemuMonitorAddDeviceProps(priv->mon, &devprops)) < 0) ignore_value(qemuDomainDetachExtensionDevice(priv->mon, hostdev->info)); exit_monitor: -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
For properties we use these are the QEMU types: host=<str> - Address (bus/device/function) of the host device, example: 04:10.0 bootindex=<int32> failover_pair_id=<str>
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 69 ++++++++++++++++++++++------------------- src/qemu/qemu_command.h | 6 ++-- src/qemu/qemu_hotplug.c | 6 ++-- 3 files changed, 43 insertions(+), 38 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 6 +----- tests/qemuxml2argvdata/net-virtio-teaming-hostdev.args | 4 ++-- tests/qemuxml2argvdata/net-virtio-teaming.args | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5a1ad69148..3cdfb7f5b1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4765,6 +4765,7 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def, "s:host", host, "s:id", dev->info->alias, "p:bootindex", dev->info->effectiveBootIndex, + "S:failover_pair_id", failover_pair_id, NULL) < 0) return NULL; @@ -4774,11 +4775,6 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def, if (qemuBuildRomProps(props, dev->info) < 0) return NULL; - if (virJSONValueObjectAdd(props, - "S:failover_pair_id", failover_pair_id, - NULL) < 0) - return NULL; - return g_steal_pointer(&props); } diff --git a/tests/qemuxml2argvdata/net-virtio-teaming-hostdev.args b/tests/qemuxml2argvdata/net-virtio-teaming-hostdev.args index 0efa7f7d50..ee1e48eebd 100644 --- a/tests/qemuxml2argvdata/net-virtio-teaming-hostdev.args +++ b/tests/qemuxml2argvdata/net-virtio-teaming-hostdev.args @@ -32,7 +32,7 @@ QEMU_AUDIO_DRV=none \ -device virtio-net-pci,failover=on,netdev=hostua-backup0,id=ua-backup0,mac=00:11:22:33:44:55,bus=pci.0,addr=0x3 \ -netdev user,id=hostua-backup1 \ -device virtio-net-pci,failover=on,netdev=hostua-backup1,id=ua-backup1,mac=66:44:33:22:11:00,bus=pci.0,addr=0x4 \ --device vfio-pci,host=0000:03:07.1,id=hostdev0,bus=pci.0,addr=0x5,failover_pair_id=ua-backup0 \ --device vfio-pci,host=0000:03:07.2,id=hostdev1,bus=pci.0,addr=0x6,failover_pair_id=ua-backup1 \ +-device vfio-pci,host=0000:03:07.1,id=hostdev0,failover_pair_id=ua-backup0,bus=pci.0,addr=0x5 \ +-device vfio-pci,host=0000:03:07.2,id=hostdev1,failover_pair_id=ua-backup1,bus=pci.0,addr=0x6 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/net-virtio-teaming.args b/tests/qemuxml2argvdata/net-virtio-teaming.args index bde442221c..4c7637de00 100644 --- a/tests/qemuxml2argvdata/net-virtio-teaming.args +++ b/tests/qemuxml2argvdata/net-virtio-teaming.args @@ -32,7 +32,7 @@ QEMU_AUDIO_DRV=none \ -device virtio-net-pci,failover=on,netdev=hostua-backup0,id=ua-backup0,mac=00:11:22:33:44:55,bus=pci.0,addr=0x2 \ -netdev user,id=hostua-backup1 \ -device virtio-net-pci,failover=on,netdev=hostua-backup1,id=ua-backup1,mac=66:44:33:22:11:00,bus=pci.0,addr=0x3 \ --device vfio-pci,host=0000:03:07.1,id=hostdev0,bus=pci.0,addr=0x4,failover_pair_id=ua-backup0 \ --device vfio-pci,host=0000:03:07.2,id=hostdev1,bus=pci.0,addr=0x5,failover_pair_id=ua-backup1 \ +-device vfio-pci,host=0000:03:07.1,id=hostdev0,failover_pair_id=ua-backup0,bus=pci.0,addr=0x4 \ +-device vfio-pci,host=0000:03:07.2,id=hostdev1,failover_pair_id=ua-backup1,bus=pci.0,addr=0x5 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 \ -msg timestamp=on -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 6 +----- tests/qemuxml2argvdata/net-virtio-teaming-hostdev.args | 4 ++-- tests/qemuxml2argvdata/net-virtio-teaming.args | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Introduce infrastructure to format 'drive' addresses via the standard helper rather than hand-rolled generators used inline. The code needs to know the disk bus to format the correct address which is passed in via an internal field in virDomainDeviceDriveAddress. The field types according to QEMU are as following: 'ide-hd' for VIR_DOMAIN_DISK_BUS_IDE and VIR_DOMAIN_DISK_BUS_SATA unit=<uint32> - (default: 4294967295) 'floppy' for VIR_DOMAIN_DISK_BUS_FDC unit=<uint32> - (default: 4294967295) 'scsi-hd' for VIR_DOMAIN_DISK_BUS_SCSI channel=<uint32> - (default: 0) scsi-id=<uint32> - (default: 4294967295) lun=<uint32> - (default: 4294967295) Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/device_conf.h | 3 + src/conf/domain_conf.c | 4 +- src/qemu/qemu_command.c | 140 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 144 insertions(+), 3 deletions(-) diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index d118966379..b6b710d313 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -57,6 +57,9 @@ struct _virDomainDeviceDriveAddress { unsigned int bus; unsigned int target; unsigned int unit; + + /* internal fields for the address formatter */ + unsigned int diskbus; /* virDomainDiskBus */ }; typedef struct _virDomainDeviceVirtioSerialAddress virDomainDeviceVirtioSerialAddress; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b6d22a1a1d..0d6f7f5fad 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5151,7 +5151,7 @@ virDomainControllerSCSINextUnit(const virDomainDef *def, for (i = 0; i < def->scsiBusMaxUnit; i++) { /* Default to assigning addresses using bus = target = 0 */ - const virDomainDeviceDriveAddress addr = {controller, 0, 0, i}; + const virDomainDeviceDriveAddress addr = {controller, 0, 0, i, 0}; if (!virDomainSCSIDriveAddressIsUsed(def, &addr)) return i; @@ -7672,7 +7672,7 @@ virDomainDiskDefAssignAddress(virDomainXMLOption *xmlopt G_GNUC_UNUSED, switch (def->bus) { case VIR_DOMAIN_DISK_BUS_SCSI: { - virDomainDeviceDriveAddress addr = {0, 0, 0, 0}; + virDomainDeviceDriveAddress addr = {0, 0, 0, 0, 0}; unsigned int controller; unsigned int unit; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3cdfb7f5b1..1fe7121fa1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -521,6 +521,142 @@ qemuBuildDeviceAddressStr(virBuffer *buf, } +static int +qemuBuildDeviceAddresDriveProps(virJSONValue *props, + const virDomainDef *domainDef, + virDomainDeviceInfo *info) +{ + g_autofree char *bus = NULL; + virDomainControllerDef *controller = NULL; + const char *controllerAlias = NULL; + + switch ((virDomainDiskBus) info->addr.drive.diskbus) { + case VIR_DOMAIN_DISK_BUS_IDE: + /* When domain has builtin IDE controller we don't put it onto cmd + * line. Therefore we can't set its alias. In that case, use the + * default one. */ + if (qemuDomainHasBuiltinIDE(domainDef)) { + controllerAlias = "ide"; + } else { + if (!(controllerAlias = virDomainControllerAliasFind(domainDef, + VIR_DOMAIN_CONTROLLER_TYPE_IDE, + info->addr.drive.controller))) + return -1; + } + + bus = g_strdup_printf("%s.%u", controllerAlias, info->addr.drive.bus); + + if (virJSONValueObjectAdd(props, + "s:bus", bus, + "u:unit", info->addr.drive.unit, + NULL) < 0) + return -1; + + break; + + case VIR_DOMAIN_DISK_BUS_SATA: + /* When domain has builtin SATA controller we don't put it onto cmd + * line. Therefore we can't set its alias. In that case, use the + * default one. */ + if (qemuDomainIsQ35(domainDef) && + info->addr.drive.controller == 0) { + controllerAlias = "ide"; + } else { + if (!(controllerAlias = virDomainControllerAliasFind(domainDef, + VIR_DOMAIN_CONTROLLER_TYPE_SATA, + info->addr.drive.controller))) + return -1; + } + + bus = g_strdup_printf("%s.%u", controllerAlias, info->addr.drive.unit); + + if (virJSONValueObjectAdd(props, + "s:bus", bus, + NULL) < 0) + return -1; + + break; + + case VIR_DOMAIN_DISK_BUS_FDC: + if (virJSONValueObjectAdd(props, + "u:unit", info->addr.drive.unit, + NULL) < 0) + return -1; + + break; + + case VIR_DOMAIN_DISK_BUS_SCSI: + if (!(controller = virDomainDeviceFindSCSIController(domainDef, &info->addr.drive))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to find a SCSI controller for idx=%d"), + info->addr.drive.controller); + return -1; + } + + switch ((virDomainControllerModelSCSI) controller->model) { + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_NCR53C90: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DC390: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AM53C974: + bus = g_strdup_printf("%s.%u", controller->info.alias, info->addr.drive.bus); + + if (virJSONValueObjectAdd(props, + "s:bus", bus, + "u:scsi-id", info->addr.drive.unit, + NULL) < 0) + return -1; + + break; + + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: + bus = g_strdup_printf("%s.0", controller->info.alias); + + if (virJSONValueObjectAdd(props, + "s:bus", bus, + "u:channel", info->addr.drive.bus, + "u:scsi-id", info->addr.drive.target, + "u:lun", info->addr.drive.unit, + NULL) < 0) + return -1; + + break; + + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected SCSI controller model %d"), + controller->model); + return -1; + } + + break; + + case VIR_DOMAIN_DISK_BUS_VIRTIO: + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_LAST: + default: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("address type drive is not supported for bus '%s'"), + NULLSTR(virDomainDiskBusTypeToString(info->addr.drive.diskbus))); + return -1; + } + + return 0; +} + + static int G_GNUC_UNUSED qemuBuildDeviceAddressProps(virJSONValue *props, const virDomainDef *domainDef, @@ -606,8 +742,10 @@ qemuBuildDeviceAddressProps(virJSONValue *props, return 0; - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: + return qemuBuildDeviceAddresDriveProps(props, domainDef, info); + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Introduce infrastructure to format 'drive' addresses via the standard helper rather than hand-rolled generators used inline.
The code needs to know the disk bus to format the correct address which is passed in via an internal field in virDomainDeviceDriveAddress.
The field types according to QEMU are as following:
'ide-hd' for VIR_DOMAIN_DISK_BUS_IDE and VIR_DOMAIN_DISK_BUS_SATA unit=<uint32> - (default: 4294967295)
'floppy' for VIR_DOMAIN_DISK_BUS_FDC unit=<uint32> - (default: 4294967295)
'scsi-hd' for VIR_DOMAIN_DISK_BUS_SCSI channel=<uint32> - (default: 0) scsi-id=<uint32> - (default: 4294967295) lun=<uint32> - (default: 4294967295)
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/device_conf.h | 3 + src/conf/domain_conf.c | 4 +- src/qemu/qemu_command.c | 140 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 144 insertions(+), 3 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Move the code from 'qemuValidateDomainDeviceDefDiskFrontend' into 'qemuValidateDomainDeviceDefAddressDrive' which is called from 'qemuValidateDomainDeviceDefAddress' so that we have all address validation code together. This also allows us to remove the inline validation inside 'qemuBuildSCSIHostdevDevStr'. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 16 --- src/qemu/qemu_validate.c | 210 +++++++++++++++++++++++---------------- 2 files changed, 124 insertions(+), 102 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1fe7121fa1..bdfc84ba2d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5081,22 +5081,6 @@ qemuBuildSCSIHostdevDevStr(const virDomainDef *def, if (model < 0) return NULL; - if (model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) { - if (dev->info->addr.drive.target != 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("target must be 0 for scsi host device " - "if its controller model is 'lsilogic'")); - return NULL; - } - - if (dev->info->addr.drive.unit > 7) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unit must be not more than 7 for scsi host " - "device if its controller model is 'lsilogic'")); - return NULL; - } - } - virBufferAddLit(&buf, "scsi-generic"); if (!(contAlias = virDomainControllerAliasFind(def, VIR_DOMAIN_CONTROLLER_TYPE_SCSI, diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 08f7fb2f42..802393a506 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1262,7 +1262,117 @@ qemuValidateDomainDeviceDefZPCIAddress(virDomainDeviceInfo *info, static int -qemuValidateDomainDeviceDefAddress(virDomainDeviceInfo *info, +qemuValidateDomainDeviceDefAddressDrive(virDomainDeviceInfo *info, + const virDomainDef *def, + virQEMUCaps *qemuCaps) +{ + virDomainControllerDef *controller = NULL; + + switch ((virDomainDiskBus) info->addr.drive.diskbus) { + case VIR_DOMAIN_DISK_BUS_SCSI: + /* Setting bus= attr for SCSI drives, causes a controller + * to be created. Yes this is slightly odd. It is not possible + * to have > 1 bus on a SCSI controller (yet). */ + if (info->addr.drive.bus != 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("SCSI controller only supports 1 bus")); + return -1; + } + + /* We allow hotplug/hotunplug disks without a controller, + * hence we don't error out if controller wasn't found. */ + if ((controller = virDomainDeviceFindSCSIController(def, &info->addr.drive))) { + if (controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) { + if (info->addr.drive.target != 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("target must be 0 for controller model 'lsilogic'")); + return -1; + } + } else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_CHANNEL)) { + if (info->addr.drive.target > 7) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU doesn't support target greater than 7")); + return -1; + } + + if (info->addr.drive.bus != 0 && + info->addr.drive.unit != 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU only supports both bus and unit equal to 0")); + return -1; + } + } + } + break; + + case VIR_DOMAIN_DISK_BUS_IDE: + /* We can only have 1 IDE controller (currently) */ + if (info->addr.drive.controller != 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Only 1 IDE controller is supported")); + return -1; + } + + if (info->addr.drive.target != 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("target must be 0 for ide controller")); + return -1; + } + break; + + case VIR_DOMAIN_DISK_BUS_FDC: + /* We can only have 1 FDC controller (currently) */ + if (info->addr.drive.controller != 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Only 1 fdc controller is supported")); + return -1; + } + + /* We can only have 1 FDC bus (currently) */ + if (info->addr.drive.bus != 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Only 1 fdc bus is supported")); + return -1; + } + + if (info->addr.drive.target != 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("target must be 0 for controller fdc")); + return -1; + } + break; + + case VIR_DOMAIN_DISK_BUS_SATA: + if (info->addr.drive.bus != 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("bus must be 0 for sata controller")); + return -1; + } + + if (info->addr.drive.target != 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("target must be 0 for sata controller")); + return -1; + } + break; + + case VIR_DOMAIN_DISK_BUS_VIRTIO: + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_LAST: + break; + } + + return 0; +} + + +static int +qemuValidateDomainDeviceDefAddress(const virDomainDeviceDef *dev, + virDomainDeviceInfo *info, const virDomainDef *def, virQEMUCaps *qemuCaps) { @@ -1314,6 +1424,18 @@ qemuValidateDomainDeviceDefAddress(virDomainDeviceInfo *info, break; case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: + /* drive address validation needs a disk bus type filled in. We assume + * that it's SCSI if it's not a disk since everything else would be + * a SCSI host device. */ + if (dev->type == VIR_DOMAIN_DEVICE_DISK) + info->addr.drive.diskbus = dev->data.disk->bus; + else + info->addr.drive.diskbus = VIR_DOMAIN_DISK_BUS_SCSI; + + if (qemuValidateDomainDeviceDefAddressDrive(info, def, qemuCaps) < 0) + return -1; + break; + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: @@ -1344,7 +1466,7 @@ qemuValidateDomainDeviceInfo(const virDomainDeviceDef *dev, if (!(info = virDomainDeviceGetInfo(dev))) return 0; - if (qemuValidateDomainDeviceDefAddress(info, def, qemuCaps) < 0) + if (qemuValidateDomainDeviceDefAddress(dev, info, def, qemuCaps) < 0) return -1; if (info->acpiIndex) { @@ -2491,9 +2613,6 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk, const virDomainDef *def, virQEMUCaps *qemuCaps) { - virDomainDeviceInfo *diskInfo; - int cModel; - if (disk->geometry.cylinders > 0 && disk->geometry.heads > 0 && disk->geometry.sectors > 0) { @@ -2653,53 +2772,11 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk, switch (disk->bus) { case VIR_DOMAIN_DISK_BUS_SCSI: - diskInfo = (virDomainDeviceInfo *)&disk->info; - cModel = qemuDomainFindSCSIControllerModel(def, diskInfo); - if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("unexpected address type for scsi disk")); return -1; } - - /* Setting bus= attr for SCSI drives, causes a controller - * to be created. Yes this is slightly odd. It is not possible - * to have > 1 bus on a SCSI controller (yet). */ - if (disk->info.addr.drive.bus != 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("SCSI controller only supports 1 bus")); - return -1; - } - - /* We allow hotplug/hotunplug disks without a controller, - * hence we don't error out if cModel is < 0. These - * validations were originally made under the assumption of - * a controller being found though. */ - if (cModel > 0) { - if (cModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) { - if (disk->info.addr.drive.target != 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("target must be 0 for controller " - "model 'lsilogic'")); - return -1; - } - } else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_CHANNEL)) { - if (disk->info.addr.drive.target > 7) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("This QEMU doesn't support target " - "greater than 7")); - return -1; - } - - if (disk->info.addr.drive.bus != 0 && - disk->info.addr.drive.unit != 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("This QEMU only supports both bus and " - "unit equal to 0")); - return -1; - } - } - } break; case VIR_DOMAIN_DISK_BUS_IDE: @@ -2708,17 +2785,6 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk, _("unexpected address type for ide disk")); return -1; } - /* We can only have 1 IDE controller (currently) */ - if (disk->info.addr.drive.controller != 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Only 1 IDE controller is supported")); - return -1; - } - if (disk->info.addr.drive.target != 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("target must be 0 for ide controller")); - return -1; - } break; case VIR_DOMAIN_DISK_BUS_FDC: @@ -2727,23 +2793,6 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk, _("unexpected address type for fdc disk")); return -1; } - /* We can only have 1 FDC controller (currently) */ - if (disk->info.addr.drive.controller != 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Only 1 fdc controller is supported")); - return -1; - } - /* We can only have 1 FDC bus (currently) */ - if (disk->info.addr.drive.bus != 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Only 1 fdc bus is supported")); - return -1; - } - if (disk->info.addr.drive.target != 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("target must be 0 for controller fdc")); - return -1; - } break; case VIR_DOMAIN_DISK_BUS_SATA: @@ -2752,17 +2801,6 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk, _("unexpected address type for sata disk")); return -1; } - - if (disk->info.addr.drive.bus != 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("bus must be 0 for sata controller")); - return -1; - } - if (disk->info.addr.drive.target != 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("target must be 0 for sata controller")); - return -1; - } break; case VIR_DOMAIN_DISK_BUS_VIRTIO: -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Move the code from 'qemuValidateDomainDeviceDefDiskFrontend' into 'qemuValidateDomainDeviceDefAddressDrive' which is called from 'qemuValidateDomainDeviceDefAddress' so that we have all address validation code together.
This also allows us to remove the inline validation inside 'qemuBuildSCSIHostdevDevStr'.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 16 --- src/qemu/qemu_validate.c | 210 +++++++++++++++++++++++---------------- 2 files changed, 124 insertions(+), 102 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Since 'qemuBuildDeviceAddressProps' now also builds 'drive' addresses the generator is way simpler and doesn't use any special fields. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 56 ++++++++++++++++------------------------- src/qemu/qemu_command.h | 7 +++--- src/qemu/qemu_hotplug.c | 6 ++--- 3 files changed, 28 insertions(+), 41 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index bdfc84ba2d..5bea3991a9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5068,44 +5068,29 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDef *dev) return virBufferContentAndReset(&buf); } -char * -qemuBuildSCSIHostdevDevStr(const virDomainDef *def, - virDomainHostdevDef *dev, - const char *backendAlias) +virJSONValue * +qemuBuildSCSIHostdevDevProps(const virDomainDef *def, + virDomainHostdevDef *dev, + const char *backendAlias) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - int model = -1; - const char *contAlias; + g_autoptr(virJSONValue) props = NULL; - model = qemuDomainFindSCSIControllerModel(def, dev->info); - if (model < 0) + if (virJSONValueObjectCreate(&props, + "s:driver", "scsi-generic", + NULL) < 0) return NULL; - virBufferAddLit(&buf, "scsi-generic"); - - if (!(contAlias = virDomainControllerAliasFind(def, VIR_DOMAIN_CONTROLLER_TYPE_SCSI, - dev->info->addr.drive.controller))) + if (qemuBuildDeviceAddressProps(props, def, dev->info) < 0) return NULL; - if (model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) { - virBufferAsprintf(&buf, ",bus=%s.%d,scsi-id=%d", - contAlias, - dev->info->addr.drive.bus, - dev->info->addr.drive.unit); - } else { - virBufferAsprintf(&buf, ",bus=%s.0,channel=%d,scsi-id=%d,lun=%d", - contAlias, - dev->info->addr.drive.bus, - dev->info->addr.drive.target, - dev->info->addr.drive.unit); - } - - virBufferAsprintf(&buf, ",drive=%s,id=%s", backendAlias, dev->info->alias); - - if (dev->info->bootIndex) - virBufferAsprintf(&buf, ",bootindex=%u", dev->info->bootIndex); + if (virJSONValueObjectAdd(props, + "s:drive", backendAlias, + "s:id", dev->info->alias, + "p:bootindex", dev->info->bootIndex, + NULL) < 0) + return NULL; - return virBufferContentAndReset(&buf); + return g_steal_pointer(&props); } static int @@ -5593,7 +5578,7 @@ qemuBuildHostdevSCSICommandLine(virCommand *cmd, virQEMUCaps *qemuCaps) { g_autoptr(qemuBlockStorageSourceAttachData) data = NULL; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; const char *backendAlias = NULL; if (!(data = qemuBuildHostdevSCSIAttachPrepare(hostdev, &backendAlias, qemuCaps))) @@ -5602,10 +5587,11 @@ qemuBuildHostdevSCSICommandLine(virCommand *cmd, if (qemuBuildBlockStorageSourceAttachDataCommandline(cmd, data, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-device"); - if (!(devstr = qemuBuildSCSIHostdevDevStr(def, hostdev, backendAlias))) + if (!(devprops = qemuBuildSCSIHostdevDevProps(def, hostdev, backendAlias))) + return -1; + + if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, devstr); return 0; } diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 8ad87f4277..5b1b727b84 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -182,9 +182,10 @@ qemuBuildUSBHostdevDevProps(const virDomainDef *def, virDomainHostdevDef *dev, virQEMUCaps *qemuCaps); -char *qemuBuildSCSIHostdevDevStr(const virDomainDef *def, - virDomainHostdevDef *dev, - const char *backendAlias); +virJSONValue * +qemuBuildSCSIHostdevDevProps(const virDomainDef *def, + virDomainHostdevDef *dev, + const char *backendAlias); qemuBlockStorageSourceAttachData * qemuBuildHostdevSCSIAttachPrepare(virDomainHostdevDef *hostdev, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 67aed2c128..28cafd11d2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2639,7 +2639,7 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriver *driver, virErrorPtr orig_err; g_autoptr(qemuBlockStorageSourceAttachData) data = NULL; const char *backendalias = NULL; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; bool teardowncgroup = false; bool teardownlabel = false; bool teardowndevice = false; @@ -2683,7 +2683,7 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriver *driver, priv->qemuCaps))) goto cleanup; - if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, hostdev, backendalias))) + if (!(devprops = qemuBuildSCSIHostdevDevProps(vm->def, hostdev, backendalias))) goto cleanup; VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1); @@ -2693,7 +2693,7 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriver *driver, if (qemuBlockStorageSourceAttachApply(priv->mon, data) < 0) goto exit_monitor; - if (qemuMonitorAddDevice(priv->mon, devstr) < 0) + if (qemuMonitorAddDeviceProps(priv->mon, &devprops) < 0) goto exit_monitor; if (qemuDomainObjExitMonitor(driver, vm) < 0) -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Since 'qemuBuildDeviceAddressProps' now also builds 'drive' addresses the generator is way simpler and doesn't use any special fields.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 56 ++++++++++++++++------------------------- src/qemu/qemu_command.h | 7 +++--- src/qemu/qemu_hotplug.c | 6 ++--- 3 files changed, 28 insertions(+), 41 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Simplify the generator by shuffling around few fields. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 10 +++------- .../hostdev-scsi-lsi.x86_64-4.1.0.args | 12 ++++++------ .../hostdev-scsi-lsi.x86_64-latest.args | 12 ++++++------ .../hostdev-scsi-virtio-scsi.x86_64-4.1.0.args | 14 +++++++------- .../hostdev-scsi-virtio-scsi.x86_64-latest.args | 14 +++++++------- tests/qemuxml2argvdata/name-escape.args | 2 +- 6 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5bea3991a9..008700cc5f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5077,19 +5077,15 @@ qemuBuildSCSIHostdevDevProps(const virDomainDef *def, if (virJSONValueObjectCreate(&props, "s:driver", "scsi-generic", + "s:drive", backendAlias, + "s:id", dev->info->alias, + "p:bootindex", dev->info->bootIndex, NULL) < 0) return NULL; if (qemuBuildDeviceAddressProps(props, def, dev->info) < 0) return NULL; - if (virJSONValueObjectAdd(props, - "s:drive", backendAlias, - "s:id", dev->info->alias, - "p:bootindex", dev->info->bootIndex, - NULL) < 0) - return NULL; - return g_steal_pointer(&props); } diff --git a/tests/qemuxml2argvdata/hostdev-scsi-lsi.x86_64-4.1.0.args b/tests/qemuxml2argvdata/hostdev-scsi-lsi.x86_64-4.1.0.args index f4745a5f4f..66ebe317ec 100644 --- a/tests/qemuxml2argvdata/hostdev-scsi-lsi.x86_64-4.1.0.args +++ b/tests/qemuxml2argvdata/hostdev-scsi-lsi.x86_64-4.1.0.args @@ -30,19 +30,19 @@ QEMU_AUDIO_DRV=none \ -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ -drive file=/dev/sg0,if=none,format=raw,id=drive-hostdev0 \ --device scsi-generic,bus=scsi0.0,scsi-id=7,drive=drive-hostdev0,id=hostdev0 \ +-device scsi-generic,drive=drive-hostdev0,id=hostdev0,bus=scsi0.0,scsi-id=7 \ -drive file=/dev/sg0,if=none,format=raw,id=drive-hostdev1,readonly=on \ --device scsi-generic,bus=scsi0.0,scsi-id=6,drive=drive-hostdev1,id=hostdev1 \ +-device scsi-generic,drive=drive-hostdev1,id=hostdev1,bus=scsi0.0,scsi-id=6 \ -drive file.driver=iscsi,file.portal=example.org:3260,file.target=iqn.1992-01.com.example,file.lun=0,file.transport=tcp,if=none,format=raw,id=drive-hostdev2 \ --device scsi-generic,bus=scsi0.0,scsi-id=4,drive=drive-hostdev2,id=hostdev2 \ +-device scsi-generic,drive=drive-hostdev2,id=hostdev2,bus=scsi0.0,scsi-id=4 \ -drive file.driver=iscsi,file.portal=example.org:3260,file.target=iqn.1992-01.com.example,file.lun=1,file.transport=tcp,if=none,format=raw,id=drive-hostdev3 \ --device scsi-generic,bus=scsi0.0,scsi-id=5,drive=drive-hostdev3,id=hostdev3 \ +-device scsi-generic,drive=drive-hostdev3,id=hostdev3,bus=scsi0.0,scsi-id=5 \ -object secret,id=hostdev4-secret0,data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \ -drive file.driver=iscsi,file.portal=example.org:3260,file.target=iqn.1992-01.com.example:storage,file.lun=1,file.transport=tcp,file.user=myname,file.password-secret=hostdev4-secret0,if=none,format=raw,id=drive-hostdev4 \ --device scsi-generic,bus=scsi0.0,scsi-id=3,drive=drive-hostdev4,id=hostdev4 \ +-device scsi-generic,drive=drive-hostdev4,id=hostdev4,bus=scsi0.0,scsi-id=3 \ -object secret,id=hostdev5-secret0,data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \ -drive file.driver=iscsi,file.portal=example.org:3260,file.target=iqn.1992-01.com.example:storage,file.lun=2,file.transport=tcp,file.user=myname,file.password-secret=hostdev5-secret0,if=none,format=raw,id=drive-hostdev5 \ --device scsi-generic,bus=scsi0.0,scsi-id=2,drive=drive-hostdev5,id=hostdev5 \ +-device scsi-generic,drive=drive-hostdev5,id=hostdev5,bus=scsi0.0,scsi-id=2 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/hostdev-scsi-lsi.x86_64-latest.args b/tests/qemuxml2argvdata/hostdev-scsi-lsi.x86_64-latest.args index edfcca6ded..eeec33fe98 100644 --- a/tests/qemuxml2argvdata/hostdev-scsi-lsi.x86_64-latest.args +++ b/tests/qemuxml2argvdata/hostdev-scsi-lsi.x86_64-latest.args @@ -33,19 +33,19 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest2/.config \ -device ide-hd,bus=ide.0,unit=0,drive=libvirt-1-format,id=ide0-0-0,bootindex=1 \ -audiodev id=audio1,driver=none \ -blockdev '{"driver":"host_device","filename":"/dev/sg0","node-name":"libvirt-2-backend","read-only":false}' \ --device scsi-generic,bus=scsi0.0,scsi-id=7,drive=libvirt-2-backend,id=hostdev0 \ +-device scsi-generic,drive=libvirt-2-backend,id=hostdev0,bus=scsi0.0,scsi-id=7 \ -blockdev '{"driver":"host_device","filename":"/dev/sg0","node-name":"libvirt-3-backend","read-only":true}' \ --device scsi-generic,bus=scsi0.0,scsi-id=6,drive=libvirt-3-backend,id=hostdev1 \ +-device scsi-generic,drive=libvirt-3-backend,id=hostdev1,bus=scsi0.0,scsi-id=6 \ -blockdev '{"driver":"iscsi","portal":"example.org:3260","target":"iqn.1992-01.com.example","lun":0,"transport":"tcp","node-name":"libvirt-4-backend","read-only":false}' \ --device scsi-generic,bus=scsi0.0,scsi-id=4,drive=libvirt-4-backend,id=hostdev2 \ +-device scsi-generic,drive=libvirt-4-backend,id=hostdev2,bus=scsi0.0,scsi-id=4 \ -blockdev '{"driver":"iscsi","portal":"example.org:3260","target":"iqn.1992-01.com.example","lun":1,"transport":"tcp","node-name":"libvirt-5-backend","read-only":false}' \ --device scsi-generic,bus=scsi0.0,scsi-id=5,drive=libvirt-5-backend,id=hostdev3 \ +-device scsi-generic,drive=libvirt-5-backend,id=hostdev3,bus=scsi0.0,scsi-id=5 \ -object '{"qom-type":"secret","id":"libvirt-6-backend-secret0","data":"9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1","keyid":"masterKey0","iv":"AAECAwQFBgcICQoLDA0ODw==","format":"base64"}' \ -blockdev '{"driver":"iscsi","portal":"example.org:3260","target":"iqn.1992-01.com.example:storage","lun":1,"transport":"tcp","user":"myname","password-secret":"libvirt-6-backend-secret0","node-name":"libvirt-6-backend","read-only":false}' \ --device scsi-generic,bus=scsi0.0,scsi-id=3,drive=libvirt-6-backend,id=hostdev4 \ +-device scsi-generic,drive=libvirt-6-backend,id=hostdev4,bus=scsi0.0,scsi-id=3 \ -object '{"qom-type":"secret","id":"libvirt-7-backend-secret0","data":"9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1","keyid":"masterKey0","iv":"AAECAwQFBgcICQoLDA0ODw==","format":"base64"}' \ -blockdev '{"driver":"iscsi","portal":"example.org:3260","target":"iqn.1992-01.com.example:storage","lun":2,"transport":"tcp","user":"myname","password-secret":"libvirt-7-backend-secret0","node-name":"libvirt-7-backend","read-only":false}' \ --device scsi-generic,bus=scsi0.0,scsi-id=2,drive=libvirt-7-backend,id=hostdev5 \ +-device scsi-generic,drive=libvirt-7-backend,id=hostdev5,bus=scsi0.0,scsi-id=2 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args index 91deda1cd8..3ce8f3fea1 100644 --- a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args +++ b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-4.1.0.args @@ -30,21 +30,21 @@ QEMU_AUDIO_DRV=none \ -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ -drive file=/dev/sg0,if=none,format=raw,id=drive-hostdev0 \ --device scsi-generic,bus=scsi0.0,channel=0,scsi-id=4,lun=8,drive=drive-hostdev0,id=hostdev0 \ +-device scsi-generic,drive=drive-hostdev0,id=hostdev0,bus=scsi0.0,channel=0,scsi-id=4,lun=8 \ -drive file=/dev/sg0,if=none,format=raw,id=drive-hostdev1,readonly=on \ --device scsi-generic,bus=scsi0.0,channel=0,scsi-id=4,lun=7,drive=drive-hostdev1,id=hostdev1 \ +-device scsi-generic,drive=drive-hostdev1,id=hostdev1,bus=scsi0.0,channel=0,scsi-id=4,lun=7 \ -drive file=/dev/sg0,if=none,format=raw,id=drive-ua-7996c8dc-a4fa-4012-b76f-043d20144263 \ --device scsi-generic,bus=scsi0.0,channel=0,scsi-id=4,lun=6,drive=drive-ua-7996c8dc-a4fa-4012-b76f-043d20144263,id=ua-7996c8dc-a4fa-4012-b76f-043d20144263 \ +-device scsi-generic,drive=drive-ua-7996c8dc-a4fa-4012-b76f-043d20144263,id=ua-7996c8dc-a4fa-4012-b76f-043d20144263,bus=scsi0.0,channel=0,scsi-id=4,lun=6 \ -drive file.driver=iscsi,file.portal=example.org:3260,file.target=iqn.1992-01.com.example,file.lun=0,file.transport=tcp,if=none,format=raw,id=drive-hostdev2 \ --device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=4,drive=drive-hostdev2,id=hostdev2 \ +-device scsi-generic,drive=drive-hostdev2,id=hostdev2,bus=scsi0.0,channel=0,scsi-id=2,lun=4 \ -drive file.driver=iscsi,file.portal=example.org:3260,file.target=iqn.1992-01.com.example,file.lun=1,file.transport=tcp,if=none,format=raw,id=drive-hostdev3,readonly=on \ --device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=5,drive=drive-hostdev3,id=hostdev3 \ +-device scsi-generic,drive=drive-hostdev3,id=hostdev3,bus=scsi0.0,channel=0,scsi-id=2,lun=5 \ -object secret,id=hostdev4-secret0,data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \ -drive file.driver=iscsi,file.portal=example.org:3260,file.target=iqn.1992-01.com.example:storage,file.lun=1,file.transport=tcp,file.user=myname,file.password-secret=hostdev4-secret0,if=none,format=raw,id=drive-hostdev4 \ --device scsi-generic,bus=scsi0.0,channel=0,scsi-id=3,lun=4,drive=drive-hostdev4,id=hostdev4 \ +-device scsi-generic,drive=drive-hostdev4,id=hostdev4,bus=scsi0.0,channel=0,scsi-id=3,lun=4 \ -object secret,id=hostdev5-secret0,data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \ -drive file.driver=iscsi,file.portal=example.org:3260,file.target=iqn.1992-01.com.example:storage,file.lun=2,file.transport=tcp,file.user=myname,file.password-secret=hostdev5-secret0,file.initiator-name=iqn.2020-07.com.example:test,if=none,format=raw,id=drive-hostdev5 \ --device scsi-generic,bus=scsi0.0,channel=0,scsi-id=3,lun=5,drive=drive-hostdev5,id=hostdev5 \ +-device scsi-generic,drive=drive-hostdev5,id=hostdev5,bus=scsi0.0,channel=0,scsi-id=3,lun=5 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-latest.args b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-latest.args index a2985ddad5..ad2cde5171 100644 --- a/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-latest.args +++ b/tests/qemuxml2argvdata/hostdev-scsi-virtio-scsi.x86_64-latest.args @@ -33,21 +33,21 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest2/.config \ -device ide-hd,bus=ide.0,unit=0,drive=libvirt-1-format,id=ide0-0-0,bootindex=1 \ -audiodev id=audio1,driver=none \ -blockdev '{"driver":"host_device","filename":"/dev/sg0","node-name":"libvirt-2-backend","read-only":false}' \ --device scsi-generic,bus=scsi0.0,channel=0,scsi-id=4,lun=8,drive=libvirt-2-backend,id=hostdev0 \ +-device scsi-generic,drive=libvirt-2-backend,id=hostdev0,bus=scsi0.0,channel=0,scsi-id=4,lun=8 \ -blockdev '{"driver":"host_device","filename":"/dev/sg0","node-name":"libvirt-3-backend","read-only":true}' \ --device scsi-generic,bus=scsi0.0,channel=0,scsi-id=4,lun=7,drive=libvirt-3-backend,id=hostdev1 \ +-device scsi-generic,drive=libvirt-3-backend,id=hostdev1,bus=scsi0.0,channel=0,scsi-id=4,lun=7 \ -blockdev '{"driver":"host_device","filename":"/dev/sg0","node-name":"libvirt-4-backend","read-only":false}' \ --device scsi-generic,bus=scsi0.0,channel=0,scsi-id=4,lun=6,drive=libvirt-4-backend,id=ua-7996c8dc-a4fa-4012-b76f-043d20144263 \ +-device scsi-generic,drive=libvirt-4-backend,id=ua-7996c8dc-a4fa-4012-b76f-043d20144263,bus=scsi0.0,channel=0,scsi-id=4,lun=6 \ -blockdev '{"driver":"iscsi","portal":"example.org:3260","target":"iqn.1992-01.com.example","lun":0,"transport":"tcp","node-name":"libvirt-5-backend","read-only":false}' \ --device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=4,drive=libvirt-5-backend,id=hostdev2 \ +-device scsi-generic,drive=libvirt-5-backend,id=hostdev2,bus=scsi0.0,channel=0,scsi-id=2,lun=4 \ -blockdev '{"driver":"iscsi","portal":"example.org:3260","target":"iqn.1992-01.com.example","lun":1,"transport":"tcp","node-name":"libvirt-6-backend","read-only":true}' \ --device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=5,drive=libvirt-6-backend,id=hostdev3 \ +-device scsi-generic,drive=libvirt-6-backend,id=hostdev3,bus=scsi0.0,channel=0,scsi-id=2,lun=5 \ -object '{"qom-type":"secret","id":"libvirt-7-backend-secret0","data":"9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1","keyid":"masterKey0","iv":"AAECAwQFBgcICQoLDA0ODw==","format":"base64"}' \ -blockdev '{"driver":"iscsi","portal":"example.org:3260","target":"iqn.1992-01.com.example:storage","lun":1,"transport":"tcp","user":"myname","password-secret":"libvirt-7-backend-secret0","node-name":"libvirt-7-backend","read-only":false}' \ --device scsi-generic,bus=scsi0.0,channel=0,scsi-id=3,lun=4,drive=libvirt-7-backend,id=hostdev4 \ +-device scsi-generic,drive=libvirt-7-backend,id=hostdev4,bus=scsi0.0,channel=0,scsi-id=3,lun=4 \ -object '{"qom-type":"secret","id":"libvirt-8-backend-secret0","data":"9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1","keyid":"masterKey0","iv":"AAECAwQFBgcICQoLDA0ODw==","format":"base64"}' \ -blockdev '{"driver":"iscsi","portal":"example.org:3260","target":"iqn.1992-01.com.example:storage","lun":2,"transport":"tcp","user":"myname","password-secret":"libvirt-8-backend-secret0","initiator-name":"iqn.2020-07.com.example:test","node-name":"libvirt-8-backend","read-only":false}' \ --device scsi-generic,bus=scsi0.0,channel=0,scsi-id=3,lun=5,drive=libvirt-8-backend,id=hostdev5 \ +-device scsi-generic,drive=libvirt-8-backend,id=hostdev5,bus=scsi0.0,channel=0,scsi-id=3,lun=5 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/name-escape.args b/tests/qemuxml2argvdata/name-escape.args index eaef25b3f1..eb8d9ac10a 100644 --- a/tests/qemuxml2argvdata/name-escape.args +++ b/tests/qemuxml2argvdata/name-escape.args @@ -40,6 +40,6 @@ QEMU_AUDIO_DRV=spice \ -spice unix,addr=/tmp/lib/domain--1-foo=1,,bar=2/spice.sock,gl=on,rendernode=/dev/dri/foo,,bar,seamless-migration=on \ -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 \ -drive file.driver=iscsi,file.portal=example.foo.org:3260,file.target=iqn.1992-01.com.example:my,,storage,file.lun=1,file.transport=tcp,if=none,format=raw,id=drive-hostdev0 \ --device scsi-generic,bus=scsi0.0,channel=0,scsi-id=0,lun=4,drive=drive-hostdev0,id=hostdev0 \ +-device scsi-generic,drive=drive-hostdev0,id=hostdev0,bus=scsi0.0,channel=0,scsi-id=0,lun=4 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -msg timestamp=on -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Simplify the generator by shuffling around few fields.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 10 +++------- .../hostdev-scsi-lsi.x86_64-4.1.0.args | 12 ++++++------ .../hostdev-scsi-lsi.x86_64-latest.args | 12 ++++++------ .../hostdev-scsi-virtio-scsi.x86_64-4.1.0.args | 14 +++++++------- .../hostdev-scsi-virtio-scsi.x86_64-latest.args | 14 +++++++------- tests/qemuxml2argvdata/name-escape.args | 2 +- 6 files changed, 30 insertions(+), 34 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The support for the 'ioeventfd' knob of virtio devices was introduced by QEMU commit 25db9ebe15125 contained in v0.14.0-rc0 and it can't be compiled out. Thus libvirt can assume it's support and remove conditional code. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 008700cc5f..0ff933fde9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1339,9 +1339,9 @@ qemuBuildRomStr(virBuffer *buf, static int qemuBuildIoEventFdStr(virBuffer *buf, virTristateSwitch use, - virQEMUCaps *qemuCaps) + virQEMUCaps *qemuCaps G_GNUC_UNUSED) { - if (use && virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_IOEVENTFD)) + if (use) virBufferAsprintf(buf, ",ioeventfd=%s", virTristateSwitchTypeToString(use)); return 0; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The support for the 'ioeventfd' knob of virtio devices was introduced by QEMU commit 25db9ebe15125 contained in v0.14.0-rc0 and it can't be compiled out. Thus libvirt can assume it's support and remove
its support it's supported
conditional code.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

It's not used since last commit. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_capabilities.c | 3 +-- src/qemu/qemu_capabilities.h | 2 +- tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml | 1 - tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml | 1 - tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml | 1 - tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml | 1 - tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 - tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 1 - tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 1 - tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml | 1 - tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml | 1 - tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml | 1 - tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml | 1 - tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml | 1 - tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml | 1 - tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml | 1 - tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml | 1 - tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml | 1 - tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml | 1 - tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml | 1 - tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml | 1 - tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml | 1 - tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml | 1 - tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml | 1 - tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml | 1 - tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 1 - tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml | 1 - tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml | 1 - tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml | 1 - tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml | 1 - tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml | 1 - tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml | 1 - tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml | 1 - tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml | 1 - tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml | 1 - tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml | 1 - tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml | 1 - tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml | 1 - 38 files changed, 2 insertions(+), 39 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 4bed967782..b60ed5ca2f 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -148,7 +148,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "virtio-tx-alg", /* QEMU_CAPS_VIRTIO_TX_ALG */ "device-qxl-vga", /* X_QEMU_CAPS_DEVICE_QXL_VGA */ "pci-multifunction", /* X_QEMU_CAPS_PCI_MULTIFUNCTION */ - "virtio-blk-pci.ioeventfd", /* QEMU_CAPS_VIRTIO_IOEVENTFD */ + "virtio-blk-pci.ioeventfd", /* X_QEMU_CAPS_VIRTIO_IOEVENTFD */ /* 60 */ "sga", /* X_QEMU_CAPS_SGA */ @@ -1402,7 +1402,6 @@ virQEMUCapsDevicePropsVirtioBlkSCSIDefault(virJSONValue *props, static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVirtioBlk[] = { - { "ioeventfd", QEMU_CAPS_VIRTIO_IOEVENTFD, NULL }, { "event_idx", QEMU_CAPS_VIRTIO_BLK_EVENT_IDX, NULL }, { "scsi", QEMU_CAPS_VIRTIO_BLK_SCSI, virQEMUCapsDevicePropsVirtioBlkSCSIDefault }, { "logical_block_size", QEMU_CAPS_BLOCKIO, NULL }, diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 16a36da63d..d2e9e9a598 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -127,7 +127,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_VIRTIO_TX_ALG, /* -device virtio-net-pci,tx=string */ X_QEMU_CAPS_DEVICE_QXL_VGA, /* primary qxl device named qxl-vga? */ X_QEMU_CAPS_PCI_MULTIFUNCTION, /* -device multifunction=on|off */ - QEMU_CAPS_VIRTIO_IOEVENTFD, /* virtio-{net|blk}-pci.ioeventfd=on */ + X_QEMU_CAPS_VIRTIO_IOEVENTFD, /* virtio-{net|blk}-pci.ioeventfd=on */ /* 60 */ X_QEMU_CAPS_SGA, /* Serial Graphics Adapter */ diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml index e9fd6e96e5..b7996f02c4 100644 --- a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml @@ -6,7 +6,6 @@ <flag name='kvm'/> <flag name='sdl'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='virtio-blk-pci.scsi'/> diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml index d6549d6440..2271812d34 100644 --- a/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml @@ -11,7 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml index 302206cf6f..66e1661f20 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml @@ -7,7 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml index bf3afc904c..265e0d9f2f 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml @@ -7,7 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml index cd5e39b5f3..15625dd1a9 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml @@ -6,7 +6,6 @@ <flag name='kvm'/> <flag name='sdl'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='virtio-blk-pci.scsi'/> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml index 354a95cebc..00d1df5d53 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml @@ -11,7 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml index 21d5c088d7..1f9357d674 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml @@ -7,7 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml b/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml index 6e60415999..6d5539277e 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml @@ -6,7 +6,6 @@ <flag name='kvm'/> <flag name='sdl'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='usb-redir'/> diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml index cffe482bf6..b621b0a798 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml @@ -11,7 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml index b8739804e2..24ea8eefb3 100644 --- a/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml @@ -7,7 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml index 514e5985ac..c09335e376 100644 --- a/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml @@ -11,7 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml index af1ccb93ed..ee213e5403 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml @@ -7,7 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml index 2d7f0e91df..94541c38db 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml @@ -7,7 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml index 363e3aba12..03ef0262be 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml @@ -9,7 +9,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml index 16915bf78b..3e3a713280 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml @@ -9,7 +9,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml b/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml index 3a39d82ae6..38898324bf 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml @@ -6,7 +6,6 @@ <flag name='kvm'/> <flag name='sdl'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='usb-redir'/> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml index 5e733fec13..1c309c2d9a 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -11,7 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml index ba9ee0dd96..a4a35951ca 100644 --- a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml @@ -11,7 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml index 976e8447f8..5f516c4e47 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml @@ -7,7 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml index 963fad815e..e880018ef1 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml @@ -7,7 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml b/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml index 64a43940a4..783c9ca5d2 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml @@ -6,7 +6,6 @@ <flag name='kvm'/> <flag name='sdl'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='usb-redir'/> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml index 034a770b08..a052800d30 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml @@ -11,7 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml index 2c125044de..493504d640 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml @@ -7,7 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml index ce0f63c2b8..51b36e7b5e 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml @@ -7,7 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml index 05c8e0e467..636ef0fb6f 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml @@ -9,7 +9,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml index aae5fe018f..4099bf144c 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml @@ -11,7 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml index e9ae3c5abb..4798ab7d96 100644 --- a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml @@ -11,7 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml index 59e1f746ca..de9b785459 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml @@ -7,7 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml index 0ce8a5ba2f..4c280f0b96 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml @@ -7,7 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml index 1219ba2666..eba031c41d 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml @@ -9,7 +9,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml b/tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml index db92662f4c..c043ada9a6 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml @@ -6,7 +6,6 @@ <flag name='kvm'/> <flag name='sdl'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='usb-redir'/> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml index 98b5f34f2b..c7ee6c39f1 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml @@ -11,7 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml index 6a9833a176..2c197bc40a 100644 --- a/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml @@ -7,7 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml b/tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml index a96c756ef8..47155f6e5c 100644 --- a/tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml @@ -6,7 +6,6 @@ <flag name='kvm'/> <flag name='sdl'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='usb-redir'/> diff --git a/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml index f13a909314..9cfa4faae6 100644 --- a/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml @@ -11,7 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> diff --git a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml index 87b37a2b7c..12ed6d2101 100644 --- a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml @@ -11,7 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.ioeventfd'/> <flag name='virtio-blk-pci.event_idx'/> <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
It's not used since last commit.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_capabilities.c | 3 +-- src/qemu/qemu_capabilities.h | 2 +-
[...]
38 files changed, 2 insertions(+), 39 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The 'event_idx' option for virtio devices was introduced by QEMU commit bcbabae8f which is contained in v0.15.0-rc0 and can't be compiled out, thus we don't need to conditionally enable it. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0ff933fde9..a7fceeb50c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2250,8 +2250,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, virBufferAsprintf(&opt, ",iothread=iothread%u", disk->iothread); qemuBuildIoEventFdStr(&opt, disk->ioeventfd, qemuCaps); - if (disk->event_idx && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BLK_EVENT_IDX)) { + if (disk->event_idx) { virBufferAsprintf(&opt, ",event_idx=%s", virTristateSwitchTypeToString(disk->event_idx)); } @@ -3988,8 +3987,7 @@ qemuBuildNicDevStr(virDomainDef *def, } } qemuBuildIoEventFdStr(&buf, net->driver.virtio.ioeventfd, qemuCaps); - if (net->driver.virtio.event_idx && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_EVENT_IDX)) { + if (net->driver.virtio.event_idx) { virBufferAsprintf(&buf, ",event_idx=%s", virTristateSwitchTypeToString(net->driver.virtio.event_idx)); } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The 'event_idx' option for virtio devices was introduced by QEMU commit bcbabae8f which is contained in v0.15.0-rc0 and can't be compiled out, thus we don't need to conditionally enable it.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Both are assumed as always present since last commit. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_capabilities.c | 6 ++---- src/qemu/qemu_capabilities.h | 4 ++-- tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml | 2 -- tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml | 2 -- tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml | 2 -- tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml | 2 -- tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 2 -- tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 2 -- tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 2 -- tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml | 2 -- tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml | 2 -- tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml | 2 -- tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml | 2 -- tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml | 2 -- tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml | 2 -- tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml | 2 -- tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml | 2 -- tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml | 2 -- tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml | 2 -- tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml | 2 -- tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml | 2 -- tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml | 2 -- tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml | 2 -- tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml | 2 -- tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml | 2 -- tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 2 -- tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml | 2 -- tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml | 2 -- tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml | 2 -- tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml | 2 -- tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml | 2 -- tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml | 2 -- tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml | 2 -- tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml | 2 -- tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml | 2 -- tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml | 2 -- tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml | 2 -- tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml | 2 -- 38 files changed, 4 insertions(+), 78 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b60ed5ca2f..9a87f40743 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -152,8 +152,8 @@ VIR_ENUM_IMPL(virQEMUCaps, /* 60 */ "sga", /* X_QEMU_CAPS_SGA */ - "virtio-blk-pci.event_idx", /* QEMU_CAPS_VIRTIO_BLK_EVENT_IDX */ - "virtio-net-pci.event_idx", /* QEMU_CAPS_VIRTIO_NET_EVENT_IDX */ + "virtio-blk-pci.event_idx", /* X_QEMU_CAPS_VIRTIO_BLK_EVENT_IDX */ + "virtio-net-pci.event_idx", /* X_QEMU_CAPS_VIRTIO_NET_EVENT_IDX */ "cache-directsync", /* X_QEMU_CAPS_DRIVE_CACHE_DIRECTSYNC */ "piix3-usb-uhci", /* QEMU_CAPS_PIIX3_USB_UHCI */ @@ -1402,7 +1402,6 @@ virQEMUCapsDevicePropsVirtioBlkSCSIDefault(virJSONValue *props, static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVirtioBlk[] = { - { "event_idx", QEMU_CAPS_VIRTIO_BLK_EVENT_IDX, NULL }, { "scsi", QEMU_CAPS_VIRTIO_BLK_SCSI, virQEMUCapsDevicePropsVirtioBlkSCSIDefault }, { "logical_block_size", QEMU_CAPS_BLOCKIO, NULL }, { "num-queues", QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES, NULL }, @@ -1419,7 +1418,6 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVirtioBlk[] = { static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVirtioNet[] = { { "tx", QEMU_CAPS_VIRTIO_TX_ALG, NULL }, - { "event_idx", QEMU_CAPS_VIRTIO_NET_EVENT_IDX, NULL }, { "rx_queue_size", QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE, NULL }, { "tx_queue_size", QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE, NULL }, { "host_mtu", QEMU_CAPS_VIRTIO_NET_HOST_MTU, NULL }, diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index d2e9e9a598..72cd4700a9 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -131,8 +131,8 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ /* 60 */ X_QEMU_CAPS_SGA, /* Serial Graphics Adapter */ - QEMU_CAPS_VIRTIO_BLK_EVENT_IDX, /* virtio-blk-pci.event_idx */ - QEMU_CAPS_VIRTIO_NET_EVENT_IDX, /* virtio-net-pci.event_idx */ + X_QEMU_CAPS_VIRTIO_BLK_EVENT_IDX, /* virtio-blk-pci.event_idx */ + X_QEMU_CAPS_VIRTIO_NET_EVENT_IDX, /* virtio-net-pci.event_idx */ X_QEMU_CAPS_DRIVE_CACHE_DIRECTSYNC, /* Is cache=directsync supported? */ QEMU_CAPS_PIIX3_USB_UHCI, /* -device piix3-usb-uhci */ diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml index b7996f02c4..2bade882a4 100644 --- a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml @@ -6,8 +6,6 @@ <flag name='kvm'/> <flag name='sdl'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='virtio-blk-pci.scsi'/> <flag name='scsi-disk.channel'/> <flag name='scsi-block'/> diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml index 2271812d34..2c432bff9e 100644 --- a/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml @@ -11,8 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml index 66e1661f20..8a927796bc 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml @@ -7,8 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml index 265e0d9f2f..a68605f4dd 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml @@ -7,8 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml index 15625dd1a9..b711c05eff 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml @@ -6,8 +6,6 @@ <flag name='kvm'/> <flag name='sdl'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='virtio-blk-pci.scsi'/> <flag name='scsi-disk.channel'/> <flag name='scsi-block'/> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml index 00d1df5d53..429c0c260e 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml @@ -11,8 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml index 1f9357d674..2e81e837a2 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml @@ -7,8 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml b/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml index 6d5539277e..19a9f31860 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml @@ -6,8 +6,6 @@ <flag name='kvm'/> <flag name='sdl'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='usb-redir'/> <flag name='virtio-blk-pci.scsi'/> <flag name='scsi-disk.channel'/> diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml index b621b0a798..be1283d449 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml @@ -11,8 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml index 24ea8eefb3..d0d7e26055 100644 --- a/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml @@ -7,8 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml index c09335e376..738e781aae 100644 --- a/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml @@ -11,8 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml index ee213e5403..02fc0df0b3 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml @@ -7,8 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml index 94541c38db..bc0cc57eec 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml @@ -7,8 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml index 03ef0262be..2692dcbe6d 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml @@ -9,8 +9,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml index 3e3a713280..e2bcfd788c 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml @@ -9,8 +9,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml b/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml index 38898324bf..a57d2dbc09 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml @@ -6,8 +6,6 @@ <flag name='kvm'/> <flag name='sdl'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='usb-redir'/> <flag name='virtio-blk-pci.scsi'/> <flag name='scsi-disk.channel'/> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml index 1c309c2d9a..624dd5344b 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -11,8 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml index a4a35951ca..757cdf0504 100644 --- a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml @@ -11,8 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml index 5f516c4e47..a466bc51b9 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml @@ -7,8 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml index e880018ef1..bb65c49f5d 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml @@ -7,8 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml b/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml index 783c9ca5d2..8c10fa260d 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml @@ -6,8 +6,6 @@ <flag name='kvm'/> <flag name='sdl'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='usb-redir'/> <flag name='virtio-blk-pci.scsi'/> <flag name='scsi-disk.channel'/> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml index a052800d30..28ba47afd7 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml @@ -11,8 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml index 493504d640..920feb1f07 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml @@ -7,8 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml index 51b36e7b5e..e97419a08b 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml @@ -7,8 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml index 636ef0fb6f..c6f183769e 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml @@ -9,8 +9,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml index 4099bf144c..4398da6599 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml @@ -11,8 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml index 4798ab7d96..40904c8803 100644 --- a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml @@ -11,8 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml index de9b785459..042060235e 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml @@ -7,8 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml index 4c280f0b96..61328e1987 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml @@ -7,8 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml index eba031c41d..5f7b02a396 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml @@ -9,8 +9,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml b/tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml index c043ada9a6..3c653acbde 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.s390x.xml @@ -6,8 +6,6 @@ <flag name='kvm'/> <flag name='sdl'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='usb-redir'/> <flag name='virtio-blk-pci.scsi'/> <flag name='scsi-disk.channel'/> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml index c7ee6c39f1..bd2dc77d21 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml @@ -11,8 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml index 2c197bc40a..0c897137a4 100644 --- a/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml @@ -7,8 +7,6 @@ <flag name='sdl'/> <flag name='hda-duplex'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml b/tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml index 47155f6e5c..5d75b2ef63 100644 --- a/tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_6.0.0.s390x.xml @@ -6,8 +6,6 @@ <flag name='kvm'/> <flag name='sdl'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='usb-redir'/> <flag name='virtio-blk-pci.scsi'/> <flag name='scsi-disk.channel'/> diff --git a/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml index 9cfa4faae6..dc0c01c25b 100644 --- a/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml @@ -11,8 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> diff --git a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml index 12ed6d2101..87ca50b2c6 100644 --- a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml @@ -11,8 +11,6 @@ <flag name='ccid-emulated'/> <flag name='ccid-passthru'/> <flag name='virtio-tx-alg'/> - <flag name='virtio-blk-pci.event_idx'/> - <flag name='virtio-net-pci.event_idx'/> <flag name='piix3-usb-uhci'/> <flag name='piix4-usb-uhci'/> <flag name='usb-ehci'/> -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Both are assumed as always present since last commit.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_capabilities.c | 6 ++---- src/qemu/qemu_capabilities.h | 4 ++-- tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml | 2 -- tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml | 2 -- [..] tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml | 2 -- tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml | 2 -- 38 files changed, 4 insertions(+), 78 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Extract the logic to determine the actual settings into 'qemuBuildDiskGetErrorPolicy' so that it can be reused when we'll convert the disk -device formatter to JSON. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a7fceeb50c..a13332f8f5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1956,28 +1956,37 @@ qemuBuildDiskThrottling(virDomainDiskDef *disk, static void -qemuBuildDiskFrontendAttributeErrorPolicy(virDomainDiskDef *disk, - virBuffer *buf) +qemuBuildDiskGetErrorPolicy(virDomainDiskDef *disk, + const char **wpolicy, + const char **rpolicy) { - const char *wpolicy = NULL; - const char *rpolicy = NULL; - if (disk->error_policy) - wpolicy = virDomainDiskErrorPolicyTypeToString(disk->error_policy); + *wpolicy = virDomainDiskErrorPolicyTypeToString(disk->error_policy); if (disk->rerror_policy) - rpolicy = virDomainDiskErrorPolicyTypeToString(disk->rerror_policy); + *rpolicy = virDomainDiskErrorPolicyTypeToString(disk->rerror_policy); if (disk->error_policy == VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE) { /* in the case of enospace, the option is spelled * differently in qemu, and it's only valid for werror, * not for rerror, so leave rerror NULL. */ - wpolicy = "enospc"; - } else if (!rpolicy) { + *wpolicy = "enospc"; + } else if (!*rpolicy) { /* for other policies, rpolicy can match wpolicy */ - rpolicy = wpolicy; + *rpolicy = *wpolicy; } +} + + +static void +qemuBuildDiskFrontendAttributeErrorPolicy(virDomainDiskDef *disk, + virBuffer *buf) +{ + const char *wpolicy = NULL; + const char *rpolicy = NULL; + + qemuBuildDiskGetErrorPolicy(disk, &wpolicy, &rpolicy); if (wpolicy) virBufferAsprintf(buf, ",werror=%s", wpolicy); -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Extract the logic to determine the actual settings into 'qemuBuildDiskGetErrorPolicy' so that it can be reused when we'll convert the disk -device formatter to JSON.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

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> --- src/qemu/qemu_command.c | 360 +++++++----------- src/qemu/qemu_command.h | 8 +- src/qemu/qemu_hotplug.c | 6 +- .../disk-ide-wwn.x86_64-latest.args | 2 +- .../disk-scsi-disk-wwn.x86_64-latest.args | 4 +- .../disk-scsi.x86_64-latest.args | 2 +- 6 files changed, 146 insertions(+), 236 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a13332f8f5..a8a93274c6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1995,31 +1995,6 @@ qemuBuildDiskFrontendAttributeErrorPolicy(virDomainDiskDef *disk, } -static void -qemuBuildDiskFrontendAttributes(virDomainDiskDef *disk, - virBuffer *buf) -{ - /* generate geometry command string */ - if (disk->geometry.cylinders > 0 && - disk->geometry.heads > 0 && - disk->geometry.sectors > 0) { - virBufferAsprintf(buf, ",cyls=%u,heads=%u,secs=%u", - disk->geometry.cylinders, - disk->geometry.heads, - disk->geometry.sectors); - - if (disk->geometry.trans != VIR_DOMAIN_DISK_TRANS_DEFAULT) - virBufferAsprintf(buf, ",bios-chs-trans=%s", - virDomainDiskGeometryTransTypeToString(disk->geometry.trans)); - } - - if (disk->serial) { - virBufferAddLit(buf, ",serial="); - virBufferEscape(buf, '\\', " ", "%s", disk->serial); - } -} - - static char * qemuBuildDriveStr(virDomainDiskDef *disk, virQEMUCaps *qemuCaps) @@ -2092,82 +2067,46 @@ qemuBuildDriveStr(virDomainDiskDef *disk, } -static int -qemuBuildDriveDevCacheStr(virDomainDiskDef *disk, - virBuffer *buf, - virQEMUCaps *qemuCaps) -{ - bool wb; - - if (disk->cachemode == VIR_DOMAIN_DISK_CACHE_DEFAULT) - return 0; - - /* VIR_DOMAIN_DISK_DEVICE_LUN translates into 'scsi-block' - * where any caching setting makes no sense. */ - if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) - return 0; - - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DISK_WRITE_CACHE)) - return 0; - - if (qemuDomainDiskCachemodeFlags(disk->cachemode, &wb, NULL, NULL) < 0) - return -1; - - virBufferStrcat(buf, ",write-cache=", - virTristateSwitchTypeToString(virTristateSwitchFromBool(wb)), - NULL); - - return 0; -} - - -char * -qemuBuildDiskDeviceStr(const virDomainDef *def, - virDomainDiskDef *disk, - virQEMUCaps *qemuCaps) +virJSONValue * +qemuBuildDiskDeviceProps(const virDomainDef *def, + virDomainDiskDef *disk, + virQEMUCaps *qemuCaps) { - g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER; - const char *contAlias; - g_autofree char *backendAlias = NULL; + g_autoptr(virJSONValue) props = NULL; + const char *driver = NULL; g_autofree char *scsiVPDDeviceId = NULL; - int controllerModel; + virTristateSwitch shareRW = VIR_TRISTATE_SWITCH_ABSENT; + g_autofree char *chardev = NULL; + g_autofree char *drive = NULL; + unsigned int bootindex = 0; + unsigned int logical_block_size = 0; + unsigned int physical_block_size = 0; + g_autoptr(virJSONValue) wwn = NULL; + g_autofree char *serial = NULL; + virTristateSwitch removable = VIR_TRISTATE_SWITCH_ABSENT; + virTristateSwitch writeCache = VIR_TRISTATE_SWITCH_ABSENT; + const char *biosCHSTrans = NULL; + const char *wpolicy = NULL; + const char *rpolicy = NULL; switch ((virDomainDiskBus) disk->bus) { case VIR_DOMAIN_DISK_BUS_IDE: + case VIR_DOMAIN_DISK_BUS_SATA: if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) - virBufferAddLit(&opt, "ide-cd"); + driver = "ide-cd"; else - virBufferAddLit(&opt, "ide-hd"); + driver = "ide-hd"; - /* When domain has builtin IDE controller we don't put it onto cmd - * line. Therefore we can't set its alias. In that case, use the - * default one. */ - if (qemuDomainHasBuiltinIDE(def)) { - contAlias = "ide"; - } else { - if (!(contAlias = virDomainControllerAliasFind(def, - VIR_DOMAIN_CONTROLLER_TYPE_IDE, - disk->info.addr.drive.controller))) - return NULL; - } - virBufferAsprintf(&opt, ",bus=%s.%d,unit=%d", - contAlias, - disk->info.addr.drive.bus, - disk->info.addr.drive.unit); break; case VIR_DOMAIN_DISK_BUS_SCSI: - controllerModel = qemuDomainFindSCSIControllerModel(def, &disk->info); - if (controllerModel < 0) - return NULL; - if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) { - virBufferAddLit(&opt, "scsi-block"); + driver = "scsi-block"; } else { if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) - virBufferAddLit(&opt, "scsi-cd"); + driver = "scsi-cd"; else - virBufferAddLit(&opt, "scsi-hd"); + driver = "scsi-hd"; /* qemu historically used the name of -drive as one of the device * ids in the Vital Product Data Device Identification page if @@ -2184,116 +2123,56 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, } } - if (!(contAlias = virDomainControllerAliasFind(def, VIR_DOMAIN_CONTROLLER_TYPE_SCSI, - disk->info.addr.drive.controller))) - return NULL; - - switch ((virDomainControllerModelSCSI)controllerModel) { - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_NCR53C90: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DC390: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AM53C974: - virBufferAsprintf(&opt, ",bus=%s.%d,scsi-id=%d", - contAlias, - disk->info.addr.drive.bus, - disk->info.addr.drive.unit); - break; - - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: - virBufferAsprintf(&opt, ",bus=%s.0,channel=%d,scsi-id=%d,lun=%d", - contAlias, - disk->info.addr.drive.bus, - disk->info.addr.drive.target, - disk->info.addr.drive.unit); - break; - - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected SCSI controller model %d"), - controllerModel); - return NULL; - } - - if (scsiVPDDeviceId) - virBufferStrcat(&opt, ",device_id=", scsiVPDDeviceId, NULL); - break; - case VIR_DOMAIN_DISK_BUS_SATA: - if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) - virBufferAddLit(&opt, "ide-cd"); - else - virBufferAddLit(&opt, "ide-hd"); - - /* When domain has builtin SATA controller we don't put it onto cmd - * line. Therefore we can't set its alias. In that case, use the - * default one. */ - if (qemuDomainIsQ35(def) && - disk->info.addr.drive.controller == 0) { - contAlias = "ide"; - } else { - if (!(contAlias = virDomainControllerAliasFind(def, - VIR_DOMAIN_CONTROLLER_TYPE_SATA, - disk->info.addr.drive.controller))) - return NULL; - } - virBufferAsprintf(&opt, ",bus=%s.%d", - contAlias, - disk->info.addr.drive.unit); - break; + case VIR_DOMAIN_DISK_BUS_VIRTIO: { + virTristateSwitch scsi = VIR_TRISTATE_SWITCH_ABSENT; + g_autofree char *iothread = NULL; - case VIR_DOMAIN_DISK_BUS_VIRTIO: - if (qemuBuildVirtioDevStr(&opt, qemuCaps, VIR_DOMAIN_DEVICE_DISK, disk) < 0) - return NULL; + if (disk->iothread > 0) + iothread = g_strdup_printf("iothread%u", disk->iothread); - if (disk->iothread) - virBufferAsprintf(&opt, ",iothread=iothread%u", disk->iothread); - - qemuBuildIoEventFdStr(&opt, disk->ioeventfd, qemuCaps); - if (disk->event_idx) { - virBufferAsprintf(&opt, ",event_idx=%s", - virTristateSwitchTypeToString(disk->event_idx)); - } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BLK_SCSI) && - !(virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BLK_SCSI_DEFAULT_DISABLED) && - disk->device != VIR_DOMAIN_DISK_DEVICE_LUN)) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BLK_SCSI)) { /* if sg_io is true but the scsi option isn't supported, * that means it's just always on in this version of qemu. */ - virBufferAsprintf(&opt, ",scsi=%s", - (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) - ? "on" : "off"); + if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) { + scsi = VIR_TRISTATE_SWITCH_ON; + } else { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BLK_SCSI_DEFAULT_DISABLED)) + scsi = VIR_TRISTATE_SWITCH_OFF; + } } - if (disk->queues) { - virBufferAsprintf(&opt, ",num-queues=%u", disk->queues); - } - if (disk->queue_size > 0) { - virBufferAsprintf(&opt, ",queue-size=%u", disk->queue_size); - } + if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_DISK, disk, qemuCaps))) + return NULL; - if (qemuBuildDeviceAddressStr(&opt, def, &disk->info) < 0) + if (virJSONValueObjectAdd(props, + "S:iothread", iothread, + "T:ioeventfd", disk->ioeventfd, + "T:event_idx", disk->event_idx, + "T:scsi", scsi, + "p:num-queues", disk->queues, + "p:queue-size", disk->queue_size, + NULL) < 0) return NULL; + } break; case VIR_DOMAIN_DISK_BUS_USB: - virBufferAddLit(&opt, "usb-storage"); + driver = "usb-storage"; + + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_USB_STORAGE_REMOVABLE)) { + if (disk->removable == VIR_TRISTATE_SWITCH_ABSENT) + removable = VIR_TRISTATE_SWITCH_OFF; + else + removable = disk->removable; + } - if (qemuBuildDeviceAddressStr(&opt, def, &disk->info) < 0) - return NULL; break; case VIR_DOMAIN_DISK_BUS_FDC: - virBufferAsprintf(&opt, "floppy,unit=%d", disk->info.addr.drive.unit); + driver = "floppy"; break; case VIR_DOMAIN_DISK_BUS_XEN: @@ -2308,74 +2187,105 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, return NULL; } + if (driver) { + if (virJSONValueObjectCreate(&props, + "s:driver", driver, + NULL) < 0) + return NULL; + } + + if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) + disk->info.addr.drive.diskbus = disk->bus; + + if (qemuBuildDeviceAddressProps(props, def, &disk->info) < 0) + return NULL; + if (disk->src->shared && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DISK_SHARE_RW)) - virBufferAddLit(&opt, ",share-rw=on"); + shareRW = VIR_TRISTATE_SWITCH_ON; if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_VHOST_USER) { - backendAlias = qemuDomainGetVhostUserChrAlias(disk->info.alias); - - virBufferAsprintf(&opt, ",chardev=%s", backendAlias); + chardev = qemuDomainGetVhostUserChrAlias(disk->info.alias); } else { - if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, &backendAlias) < 0) + if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, &drive) < 0) return NULL; - - if (backendAlias) - virBufferAsprintf(&opt, ",drive=%s", backendAlias); } - virBufferAsprintf(&opt, ",id=%s", disk->info.alias); /* bootindex for floppies is configured via the fdc controller */ - if (disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY && - disk->info.effectiveBootIndex > 0) - virBufferAsprintf(&opt, ",bootindex=%u", disk->info.effectiveBootIndex); + if (disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) + bootindex = disk->info.effectiveBootIndex; + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKIO)) { - if (disk->blockio.logical_block_size > 0) - virBufferAsprintf(&opt, ",logical_block_size=%u", - disk->blockio.logical_block_size); - if (disk->blockio.physical_block_size > 0) - virBufferAsprintf(&opt, ",physical_block_size=%u", - disk->blockio.physical_block_size); + logical_block_size = disk->blockio.logical_block_size; + physical_block_size = disk->blockio.physical_block_size; } if (disk->wwn) { - if (STRPREFIX(disk->wwn, "0x")) - virBufferAsprintf(&opt, ",wwn=%s", disk->wwn); - else - virBufferAsprintf(&opt, ",wwn=0x%s", disk->wwn); - } + unsigned long long w = 0; - if (disk->rotation_rate) - virBufferAsprintf(&opt, ",rotation_rate=%u", disk->rotation_rate); + if (virStrToLong_ull(disk->wwn, NULL, 16, &w) < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("Failed to parse wwn '%s' as number"), disk->wwn); + return NULL; + } - if (disk->vendor) { - virBufferAddLit(&opt, ",vendor="); - virQEMUBuildBufferEscapeComma(&opt, disk->vendor); + wwn = virJSONValueNewNumberUlong(w); } - if (disk->product) { - virBufferAddLit(&opt, ",product="); - virQEMUBuildBufferEscapeComma(&opt, disk->product); - } + if (disk->cachemode != VIR_DOMAIN_DISK_CACHE_DEFAULT) { + /* VIR_DOMAIN_DISK_DEVICE_LUN translates into 'scsi-block' + * where any caching setting makes no sense. */ + if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_DISK_WRITE_CACHE)) { + bool wb; - if (disk->bus == VIR_DOMAIN_DISK_BUS_USB) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_USB_STORAGE_REMOVABLE)) { - if (disk->removable == VIR_TRISTATE_SWITCH_ON) - virBufferAddLit(&opt, ",removable=on"); - else - virBufferAddLit(&opt, ",removable=off"); + if (qemuDomainDiskCachemodeFlags(disk->cachemode, &wb, NULL, + NULL) < 0) + return NULL; + + writeCache = virTristateSwitchFromBool(wb); } } - if (qemuBuildDriveDevCacheStr(disk, &opt, qemuCaps) < 0) - return NULL; + if (disk->geometry.trans != VIR_DOMAIN_DISK_TRANS_DEFAULT) + biosCHSTrans = virDomainDiskGeometryTransTypeToString(disk->geometry.trans); - qemuBuildDiskFrontendAttributes(disk, &opt); + if (disk->serial) { + virBuffer buf = VIR_BUFFER_INITIALIZER; + + virBufferEscape(&buf, '\\', " ", "%s", disk->serial); + serial = virBufferContentAndReset(&buf); + } if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_STORAGE_WERROR)) - qemuBuildDiskFrontendAttributeErrorPolicy(disk, &opt); + qemuBuildDiskGetErrorPolicy(disk, &wpolicy, &rpolicy); - return virBufferContentAndReset(&opt); + if (virJSONValueObjectAdd(props, + "S:device_id", scsiVPDDeviceId, + "T:share-rw", shareRW, + "S:drive", drive, + "S:chardev", chardev, + "s:id", disk->info.alias, + "p:bootindex", bootindex, + "p:logical_block_size", logical_block_size, + "p:physical_block_size", physical_block_size, + "A:wwn", &wwn, + "p:rotation_rate", disk->rotation_rate, + "S:vendor", disk->vendor, + "S:product", disk->product, + "T:removable", removable, + "S:write-cache", qemuOnOffAuto(writeCache), + "p:cyls", disk->geometry.cylinders, + "p:heads", disk->geometry.heads, + "p:secs", disk->geometry.sectors, + "S:bios-chs-trans", biosCHSTrans, + "S:serial", serial, + "S:werror", wpolicy, + "S:rerror", rpolicy, + NULL) < 0) + return NULL; + + return g_steal_pointer(&props); } @@ -2605,7 +2515,7 @@ qemuBuildDiskCommandLine(virCommand *cmd, virDomainDiskDef *disk, virQEMUCaps *qemuCaps) { - g_autofree char *optstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; if (qemuBuildDiskSourceCommandLine(cmd, disk, qemuCaps) < 0) return -1; @@ -2624,11 +2534,11 @@ qemuBuildDiskCommandLine(virCommand *cmd, if (qemuCommandAddExtDevice(cmd, &disk->info, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-device"); + if (!(devprops = qemuBuildDiskDeviceProps(def, disk, qemuCaps))) + return -1; - if (!(optstr = qemuBuildDiskDeviceStr(def, disk, qemuCaps))) + if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, optstr); return 0; } diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 5b1b727b84..18d4c4130b 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -134,10 +134,10 @@ qemuBlockStorageSourceChainData * qemuBuildStorageSourceChainAttachPrepareBlockdevTop(virStorageSource *top, virStorageSource *backingStore); -char -*qemuBuildDiskDeviceStr(const virDomainDef *def, - virDomainDiskDef *disk, - virQEMUCaps *qemuCaps); +virJSONValue * +qemuBuildDiskDeviceProps(const virDomainDef *def, + virDomainDiskDef *disk, + virQEMUCaps *qemuCaps); char * qemuBuildVHostUserFsDevStr(virDomainFSDef *fs, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 28cafd11d2..1b5f63f271 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -710,7 +710,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, { g_autoptr(qemuBlockStorageSourceChainData) data = NULL; qemuDomainObjPrivate *priv = vm->privateData; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); bool extensionDeviceAttached = false; int rc; @@ -772,7 +772,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, ignore_value(VIR_INSERT_ELEMENT(data->srcdata, 0, data->nsrcdata, backend)); } - if (!(devstr = qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps))) + if (!(devprops = qemuBuildDiskDeviceProps(vm->def, disk, priv->qemuCaps))) goto rollback; if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) @@ -782,7 +782,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, extensionDeviceAttached = true; if (rc == 0) - rc = qemuMonitorAddDevice(priv->mon, devstr); + rc = qemuMonitorAddDeviceProps(priv->mon, &devprops); /* Setup throttling of disk via block_set_io_throttle QMP command. This * is a hack until the 'throttle' blockdev driver will support modification diff --git a/tests/qemuxml2argvdata/disk-ide-wwn.x86_64-latest.args b/tests/qemuxml2argvdata/disk-ide-wwn.x86_64-latest.args index 9a74262c15..8560754c24 100644 --- a/tests/qemuxml2argvdata/disk-ide-wwn.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-ide-wwn.x86_64-latest.args @@ -29,7 +29,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ --device ide-hd,bus=ide.0,unit=1,drive=libvirt-1-format,id=ide0-0-1,bootindex=1,wwn=0x5000c50015ea71ad,serial=WD-WMAP9A966149 \ +-device ide-hd,bus=ide.0,unit=1,drive=libvirt-1-format,id=ide0-0-1,bootindex=1,wwn=5764824127192592813,serial=WD-WMAP9A966149 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/disk-scsi-disk-wwn.x86_64-latest.args b/tests/qemuxml2argvdata/disk-scsi-disk-wwn.x86_64-latest.args index 7648bfdc4e..887d2219af 100644 --- a/tests/qemuxml2argvdata/disk-scsi-disk-wwn.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-scsi-disk-wwn.x86_64-latest.args @@ -31,10 +31,10 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -device lsi,id=scsi1,bus=pci.0,addr=0x3 \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-2-format","read-only":true,"driver":"raw","file":"libvirt-2-storage"}' \ --device scsi-cd,bus=scsi0.0,channel=0,scsi-id=1,lun=0,device_id=WD-WMAP9A966149,drive=libvirt-2-format,id=scsi0-0-1-0,wwn=0x5000c50015ea71ac,serial=WD-WMAP9A966149 \ +-device scsi-cd,bus=scsi0.0,channel=0,scsi-id=1,lun=0,device_id=WD-WMAP9A966149,drive=libvirt-2-format,id=scsi0-0-1-0,wwn=5764824127192592812,serial=WD-WMAP9A966149 \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ --device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,device_id=drive-scsi0-0-0-0,drive=libvirt-1-format,id=scsi0-0-0-0,bootindex=1,wwn=0x5000c50015ea71ad \ +-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,device_id=drive-scsi0-0-0-0,drive=libvirt-1-format,id=scsi0-0-0-0,bootindex=1,wwn=5764824127192592813 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/disk-scsi.x86_64-latest.args b/tests/qemuxml2argvdata/disk-scsi.x86_64-latest.args index bcd998a968..d9971582ac 100644 --- a/tests/qemuxml2argvdata/disk-scsi.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-scsi.x86_64-latest.args @@ -43,7 +43,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -device scsi-hd,bus=scsi1.0,channel=0,scsi-id=0,lun=0,device_id=abcdefghijklmn,drive=libvirt-4-format,id=scsi1-0-0-0,serial=abcdefghijklmn \ -blockdev '{"driver":"file","filename":"/tmp/scsidisk3.img","node-name":"libvirt-3-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-3-format","read-only":false,"driver":"raw","file":"libvirt-3-storage"}' \ --device scsi-hd,bus=scsi2.0,channel=0,scsi-id=0,lun=0,device_id=drive-scsi2-0-0-0,drive=libvirt-3-format,id=scsi2-0-0-0,wwn=0x5000c50015ea71ac \ +-device scsi-hd,bus=scsi2.0,channel=0,scsi-id=0,lun=0,device_id=drive-scsi2-0-0-0,drive=libvirt-3-format,id=scsi2-0-0-0,wwn=5764824127192592812 \ -blockdev '{"driver":"file","filename":"/tmp/scsidisk4.img","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-2-format","read-only":false,"driver":"raw","file":"libvirt-2-storage"}' \ -device scsi-hd,bus=scsi3.0,channel=0,scsi-id=0,lun=0,device_id=drive-scsi3-0-0-0,drive=libvirt-2-format,id=scsi3-0-0-0 \ -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
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> --- src/qemu/qemu_command.c | 360 +++++++----------- src/qemu/qemu_command.h | 8 +- src/qemu/qemu_hotplug.c | 6 +- .../disk-ide-wwn.x86_64-latest.args | 2 +- .../disk-scsi-disk-wwn.x86_64-latest.args | 4 +- .../disk-scsi.x86_64-latest.args | 2 +- 6 files changed, 146 insertions(+), 236 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

virtio-net-pci specific properties and their types according to QEMU: tx=<str> ioeventfd=<bool> - on/off (default: true) event_idx=<bool> - on/off (default: true) csum=<bool> - on/off (default: true) gso=<bool> - on/off (default: true) host_tso4=<bool> - on/off (default: true) host_tso6=<bool> - on/off (default: true) host_ecn=<bool> - on/off (default: true) host_ufo=<bool> - on/off (default: true) mrg_rxbuf=<bool> - on/off (default: true) guest_csum=<bool> - on/off (default: true) guest_tso4=<bool> - on/off (default: true) guest_tso6=<bool> - on/off (default: true) guest_ecn=<bool> - on/off (default: true) guest_ufo=<bool> - on/off (default: true) mq=<bool> - on/off (default: false) vectors=<uint32> - (default: 4294967295) rx_queue_size=<uint16> - (default: 256) tx_queue_size=<uint16> - (default: 256) host_mtu=<uint16> - (default: 0) failover=<bool> - (default: false) properties common for all network interfaces: netdev=<str> - ID of a netdev to use as a backend mac=<str> - Ethernet 6-byte MAC Address, example: 52:54:00:12:34:56 bootindex=<int32> Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 166 +++++++++++++++++----------------------- src/qemu/qemu_command.h | 9 ++- src/qemu/qemu_hotplug.c | 6 +- 3 files changed, 78 insertions(+), 103 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a8a93274c6..54f50c9a5e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3859,37 +3859,29 @@ qemuBuildLegacyNicStr(virDomainNetDef *net) } -char * -qemuBuildNicDevStr(virDomainDef *def, - virDomainNetDef *net, - size_t vhostfdSize, - virQEMUCaps *qemuCaps) +virJSONValue * +qemuBuildNicDevProps(virDomainDef *def, + virDomainNetDef *net, + size_t vhostfdSize, + virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - bool usingVirtio = false; + g_autoptr(virJSONValue) props = NULL; char macaddr[VIR_MAC_STRING_BUFLEN]; if (virDomainNetIsVirtioModel(net)) { - if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_NET, net) < 0) { - return NULL; - } - - usingVirtio = true; - } else { - virBufferAddStr(&buf, virDomainNetGetModelString(net)); - } + const char *tx = NULL; + virTristateSwitch mq = VIR_TRISTATE_SWITCH_ABSENT; + unsigned long long vectors = 0; + virTristateSwitch failover = VIR_TRISTATE_SWITCH_ABSENT; - if (usingVirtio) { - if (net->driver.virtio.txmode && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_TX_ALG)) { - virBufferAddLit(&buf, ",tx="); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_TX_ALG)) { switch (net->driver.virtio.txmode) { case VIR_DOMAIN_NET_VIRTIO_TX_MODE_IOTHREAD: - virBufferAddLit(&buf, "bh"); + tx = "bh"; break; case VIR_DOMAIN_NET_VIRTIO_TX_MODE_TIMER: - virBufferAddLit(&buf, "timer"); + tx = "timer"; break; case VIR_DOMAIN_NET_VIRTIO_TX_MODE_DEFAULT: @@ -3905,100 +3897,80 @@ qemuBuildNicDevStr(virDomainDef *def, return NULL; } } - qemuBuildIoEventFdStr(&buf, net->driver.virtio.ioeventfd, qemuCaps); - if (net->driver.virtio.event_idx) { - virBufferAsprintf(&buf, ",event_idx=%s", - virTristateSwitchTypeToString(net->driver.virtio.event_idx)); - } - if (net->driver.virtio.host.csum) { - virBufferAsprintf(&buf, ",csum=%s", - virTristateSwitchTypeToString(net->driver.virtio.host.csum)); - } - if (net->driver.virtio.host.gso) { - virBufferAsprintf(&buf, ",gso=%s", - virTristateSwitchTypeToString(net->driver.virtio.host.gso)); - } - if (net->driver.virtio.host.tso4) { - virBufferAsprintf(&buf, ",host_tso4=%s", - virTristateSwitchTypeToString(net->driver.virtio.host.tso4)); - } - if (net->driver.virtio.host.tso6) { - virBufferAsprintf(&buf, ",host_tso6=%s", - virTristateSwitchTypeToString(net->driver.virtio.host.tso6)); - } - if (net->driver.virtio.host.ecn) { - virBufferAsprintf(&buf, ",host_ecn=%s", - virTristateSwitchTypeToString(net->driver.virtio.host.ecn)); - } - if (net->driver.virtio.host.ufo) { - virBufferAsprintf(&buf, ",host_ufo=%s", - virTristateSwitchTypeToString(net->driver.virtio.host.ufo)); - } - if (net->driver.virtio.host.mrg_rxbuf) { - virBufferAsprintf(&buf, ",mrg_rxbuf=%s", - virTristateSwitchTypeToString(net->driver.virtio.host.mrg_rxbuf)); - } - if (net->driver.virtio.guest.csum) { - virBufferAsprintf(&buf, ",guest_csum=%s", - virTristateSwitchTypeToString(net->driver.virtio.guest.csum)); - } - if (net->driver.virtio.guest.tso4) { - virBufferAsprintf(&buf, ",guest_tso4=%s", - virTristateSwitchTypeToString(net->driver.virtio.guest.tso4)); - } - if (net->driver.virtio.guest.tso6) { - virBufferAsprintf(&buf, ",guest_tso6=%s", - virTristateSwitchTypeToString(net->driver.virtio.guest.tso6)); - } - if (net->driver.virtio.guest.ecn) { - virBufferAsprintf(&buf, ",guest_ecn=%s", - virTristateSwitchTypeToString(net->driver.virtio.guest.ecn)); - } - if (net->driver.virtio.guest.ufo) { - virBufferAsprintf(&buf, ",guest_ufo=%s", - virTristateSwitchTypeToString(net->driver.virtio.guest.ufo)); - } if (vhostfdSize > 1) { if (net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { /* ccw provides a one to one relation of fds to queues and * does not support the vectors option */ - virBufferAddLit(&buf, ",mq=on"); + mq = VIR_TRISTATE_SWITCH_ON; } else { /* As advised at https://www.linux-kvm.org/page/Multiqueue * we should add vectors=2*N+2 where N is the vhostfdSize */ - virBufferAsprintf(&buf, ",mq=on,vectors=%zu", 2 * vhostfdSize + 2); + mq = VIR_TRISTATE_SWITCH_ON; + vectors = 2 * vhostfdSize + 2; } } - if (net->driver.virtio.rx_queue_size) - virBufferAsprintf(&buf, ",rx_queue_size=%u", net->driver.virtio.rx_queue_size); - - if (net->driver.virtio.tx_queue_size) - virBufferAsprintf(&buf, ",tx_queue_size=%u", net->driver.virtio.tx_queue_size); + if (net->teaming && net->teaming->type == VIR_DOMAIN_NET_TEAMING_TYPE_PERSISTENT) + failover = VIR_TRISTATE_SWITCH_ON; - if (net->mtu) - virBufferAsprintf(&buf, ",host_mtu=%u", net->mtu); + if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_NET, net, qemuCaps))) + return NULL; - if (net->teaming && net->teaming->type == VIR_DOMAIN_NET_TEAMING_TYPE_PERSISTENT) - virBufferAddLit(&buf, ",failover=on"); + if (virJSONValueObjectAdd(props, + "S:tx", tx, + "T:ioeventfd", net->driver.virtio.ioeventfd, + "T:event_idx", net->driver.virtio.event_idx, + "T:csum", net->driver.virtio.host.csum, + "T:gso", net->driver.virtio.host.gso, + "T:host_tso4", net->driver.virtio.host.tso4, + "T:host_tso6", net->driver.virtio.host.tso6, + "T:host_ecn", net->driver.virtio.host.ecn, + "T:host_ufo", net->driver.virtio.host.ufo, + "T:mrg_rxbuf", net->driver.virtio.host.mrg_rxbuf, + "T:guest_csum", net->driver.virtio.guest.csum, + "T:guest_tso4", net->driver.virtio.guest.tso4, + "T:guest_tso6", net->driver.virtio.guest.tso6, + "T:guest_ecn", net->driver.virtio.guest.ecn, + "T:guest_ufo", net->driver.virtio.guest.ufo, + "T:mq", mq, + "P:vectors", vectors, + "p:rx_queue_size", net->driver.virtio.rx_queue_size, + "p:tx_queue_size", net->driver.virtio.tx_queue_size, + "p:host_mtu", net->mtu, + "T:failover", failover, + NULL) < 0) + return NULL; + } else { + if (virJSONValueObjectCreate(&props, + "s:driver", virDomainNetGetModelString(net), + NULL) < 0) + return NULL; } - virBufferAsprintf(&buf, ",netdev=host%s", net->info.alias); - virBufferAsprintf(&buf, ",id=%s", net->info.alias); - virBufferAsprintf(&buf, ",mac=%s", - virMacAddrFormat(&net->mac, macaddr)); + virMacAddrFormat(&net->mac, macaddr); - if (qemuBuildDeviceAddressStr(&buf, def, &net->info) < 0) + if (virJSONValueObjectAdd(props, + "f:netdev", g_strdup_printf("host%s", net->info.alias), + "s:id", net->info.alias, + "s:mac", macaddr, + NULL) < 0) return NULL; - if (qemuBuildRomStr(&buf, &net->info) < 0) + + if (qemuBuildDeviceAddressProps(props, def, &net->info) < 0) return NULL; - if (net->info.effectiveBootIndex > 0) - virBufferAsprintf(&buf, ",bootindex=%u", net->info.effectiveBootIndex); - return virBufferContentAndReset(&buf); + if (qemuBuildRomProps(props, &net->info) < 0) + return NULL; + + if (virJSONValueObjectAdd(props, + "p:bootindex", net->info.effectiveBootIndex, + NULL) < 0) + return NULL; + + return g_steal_pointer(&props); } @@ -8747,6 +8719,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, { virDomainDef *def = vm->def; int ret = -1; + g_autoptr(virJSONValue) nicprops = NULL; g_autofree char *nic = NULL; g_autofree char *chardev = NULL; int *tapfd = NULL; @@ -9010,9 +8983,10 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, if (qemuCommandAddExtDevice(cmd, &net->info, qemuCaps) < 0) goto cleanup; - if (!(nic = qemuBuildNicDevStr(def, net, net->driver.virtio.queues, qemuCaps))) + if (!(nicprops = qemuBuildNicDevProps(def, net, net->driver.virtio.queues, qemuCaps))) + goto cleanup; + if (qemuBuildDeviceCommandlineFromJSON(cmd, nicprops, qemuCaps) < 0) goto cleanup; - virCommandAddArgList(cmd, "-device", nic, NULL); } else if (!requireNicdev) { if (qemuCommandAddExtDevice(cmd, &net->info, qemuCaps) < 0) goto cleanup; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 18d4c4130b..29db16e729 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -98,10 +98,11 @@ virJSONValue *qemuBuildHostNetStr(virDomainNetDef *net, const char *vdpadev); /* Current, best practice */ -char *qemuBuildNicDevStr(virDomainDef *def, - virDomainNetDef *net, - size_t vhostfdSize, - virQEMUCaps *qemuCaps); +virJSONValue * +qemuBuildNicDevProps(virDomainDef *def, + virDomainNetDef *net, + size_t vhostfdSize, + virQEMUCaps *qemuCaps); char *qemuDeviceDriveHostAlias(virDomainDiskDef *disk); bool qemuDiskBusIsSD(int bus); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1b5f63f271..1c0056da16 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1175,7 +1175,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, int *vhostfd = NULL; size_t vhostfdSize = 0; size_t queueSize = 0; - g_autofree char *nicstr = NULL; + g_autoptr(virJSONValue) nicprops = NULL; g_autoptr(virJSONValue) netprops = NULL; int ret = -1; bool releaseaddr = false; @@ -1484,7 +1484,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, for (i = 0; i < vhostfdSize; i++) VIR_FORCE_CLOSE(vhostfd[i]); - if (!(nicstr = qemuBuildNicDevStr(vm->def, net, queueSize, priv->qemuCaps))) + if (!(nicprops = qemuBuildNicDevProps(vm->def, net, queueSize, priv->qemuCaps))) goto try_remove; qemuDomainObjEnterMonitor(driver, vm); @@ -1495,7 +1495,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, goto try_remove; } - if (qemuMonitorAddDevice(priv->mon, nicstr) < 0) { + if (qemuMonitorAddDeviceProps(priv->mon, &nicprops) < 0) { ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &net->info)); ignore_value(qemuDomainObjExitMonitor(driver, vm)); virDomainAuditNet(vm, NULL, net, "attach", false); -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
virtio-net-pci specific properties and their types according to QEMU: tx=<str> ioeventfd=<bool> - on/off (default: true) event_idx=<bool> - on/off (default: true) csum=<bool> - on/off (default: true) gso=<bool> - on/off (default: true) host_tso4=<bool> - on/off (default: true) host_tso6=<bool> - on/off (default: true) host_ecn=<bool> - on/off (default: true) host_ufo=<bool> - on/off (default: true) mrg_rxbuf=<bool> - on/off (default: true) guest_csum=<bool> - on/off (default: true) guest_tso4=<bool> - on/off (default: true) guest_tso6=<bool> - on/off (default: true) guest_ecn=<bool> - on/off (default: true) guest_ufo=<bool> - on/off (default: true) mq=<bool> - on/off (default: false) vectors=<uint32> - (default: 4294967295) rx_queue_size=<uint16> - (default: 256) tx_queue_size=<uint16> - (default: 256) host_mtu=<uint16> - (default: 0) failover=<bool> - (default: false)
properties common for all network interfaces: netdev=<str> - ID of a netdev to use as a backend mac=<str> - Ethernet 6-byte MAC Address, example: 52:54:00:12:34:56 bootindex=<int32>
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 166 +++++++++++++++++----------------------- src/qemu/qemu_command.h | 9 ++- src/qemu/qemu_hotplug.c | 6 +- 3 files changed, 78 insertions(+), 103 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Move the bootindex before the address so that the code is simpler. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 6 +----- tests/qemuxml2argvdata/aarch64-video-virtio-gpu-pci.args | 2 +- tests/qemuxml2argvdata/boot-complex.args | 2 +- tests/qemuxml2argvdata/boot-order.args | 2 +- tests/qemuxml2argvdata/controller-order.args | 2 +- .../machine-loadparm-multiple-disks-nets-s390.args | 2 +- tests/qemuxml2argvdata/machine-loadparm-net-s390.args | 2 +- 7 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 54f50c9a5e..2d47528d53 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3956,6 +3956,7 @@ qemuBuildNicDevProps(virDomainDef *def, "f:netdev", g_strdup_printf("host%s", net->info.alias), "s:id", net->info.alias, "s:mac", macaddr, + "p:bootindex", net->info.effectiveBootIndex, NULL) < 0) return NULL; @@ -3965,11 +3966,6 @@ qemuBuildNicDevProps(virDomainDef *def, if (qemuBuildRomProps(props, &net->info) < 0) return NULL; - if (virJSONValueObjectAdd(props, - "p:bootindex", net->info.effectiveBootIndex, - NULL) < 0) - return NULL; - return g_steal_pointer(&props); } diff --git a/tests/qemuxml2argvdata/aarch64-video-virtio-gpu-pci.args b/tests/qemuxml2argvdata/aarch64-video-virtio-gpu-pci.args index 49d918e393..ce3b68bf18 100644 --- a/tests/qemuxml2argvdata/aarch64-video-virtio-gpu-pci.args +++ b/tests/qemuxml2argvdata/aarch64-video-virtio-gpu-pci.args @@ -29,6 +29,6 @@ QEMU_AUDIO_DRV=none \ -device ioh3420,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ -device ioh3420,port=0x9,chassis=2,id=pci.2,bus=pcie.0,multifunction=on,addr=0x1.0x1 \ -netdev user,id=hostnet0 \ --device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:73:34:53,bus=pci.1,addr=0x0,bootindex=1 \ +-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:73:34:53,bootindex=1,bus=pci.1,addr=0x0 \ -device virtio-gpu-pci,id=video0,bus=pci.2,addr=0x0 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/boot-complex.args b/tests/qemuxml2argvdata/boot-complex.args index 90d3770117..1fcd9df61e 100644 --- a/tests/qemuxml2argvdata/boot-complex.args +++ b/tests/qemuxml2argvdata/boot-complex.args @@ -42,7 +42,7 @@ QEMU_AUDIO_DRV=none \ -global isa-fdc.bootindexA=4 \ -global isa-fdc.driveB=drive-fdc0-0-1 \ -netdev user,id=hostnet0 \ --device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:11,bus=pci.0,addr=0x2,bootindex=2 \ +-device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:11,bootindex=2,bus=pci.0,addr=0x2 \ -netdev user,id=hostnet1 \ -device virtio-net-pci,netdev=hostnet1,id=net1,mac=00:11:22:33:44:22,bus=pci.0,addr=0x3 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/boot-order.args b/tests/qemuxml2argvdata/boot-order.args index 0969ea9bd5..e2b9e8bbe8 100644 --- a/tests/qemuxml2argvdata/boot-order.args +++ b/tests/qemuxml2argvdata/boot-order.args @@ -36,6 +36,6 @@ QEMU_AUDIO_DRV=none \ -global isa-fdc.driveB=drive-fdc0-0-1 \ -global isa-fdc.bootindexB=4 \ -netdev user,id=hostnet0 \ --device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:55,bus=pci.0,addr=0x2,bootindex=2 \ +-device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:55,bootindex=2,bus=pci.0,addr=0x2 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/controller-order.args b/tests/qemuxml2argvdata/controller-order.args index a97fbc7d5d..e5524f3413 100644 --- a/tests/qemuxml2argvdata/controller-order.args +++ b/tests/qemuxml2argvdata/controller-order.args @@ -32,7 +32,7 @@ QEMU_AUDIO_DRV=spice \ -drive file=/tmp/Fedora-17-x86_64-Live-Desktop.iso,format=raw,if=none,id=drive-ide0-1-0,readonly=on \ -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -netdev user,id=hostnet0 \ --device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:4d:4b:19,bus=pci.0,addr=0x3,bootindex=2 \ +-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:4d:4b:19,bootindex=2,bus=pci.0,addr=0x3 \ -chardev spicevmc,id=charsmartcard0,name=smartcard \ -device ccid-card-passthru,chardev=charsmartcard0,id=smartcard0,bus=ccid0.0 \ -chardev pty,id=charserial0 \ diff --git a/tests/qemuxml2argvdata/machine-loadparm-multiple-disks-nets-s390.args b/tests/qemuxml2argvdata/machine-loadparm-multiple-disks-nets-s390.args index 68470173fb..6cba98b36f 100644 --- a/tests/qemuxml2argvdata/machine-loadparm-multiple-disks-nets-s390.args +++ b/tests/qemuxml2argvdata/machine-loadparm-multiple-disks-nets-s390.args @@ -29,7 +29,7 @@ QEMU_AUDIO_DRV=none \ -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-virtio-disk1 \ -device virtio-blk-ccw,devno=fe.0.0003,drive=drive-virtio-disk1,id=virtio-disk1,bootindex=3 \ -netdev user,id=hostnet0 \ --device virtio-net-ccw,netdev=hostnet0,id=net0,mac=00:11:22:33:44:54,devno=fe.0.0000,bootindex=2 \ +-device virtio-net-ccw,netdev=hostnet0,id=net0,mac=00:11:22:33:44:54,bootindex=2,devno=fe.0.0000 \ -netdev user,id=hostnet1 \ -device virtio-net-ccw,netdev=hostnet1,id=net1,mac=00:11:22:33:42:36,devno=fe.0.0004 \ -device virtio-balloon-ccw,id=balloon0,devno=fe.0.0001 \ diff --git a/tests/qemuxml2argvdata/machine-loadparm-net-s390.args b/tests/qemuxml2argvdata/machine-loadparm-net-s390.args index 13e099bb80..44af82b787 100644 --- a/tests/qemuxml2argvdata/machine-loadparm-net-s390.args +++ b/tests/qemuxml2argvdata/machine-loadparm-net-s390.args @@ -25,6 +25,6 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -boot strict=on \ -netdev user,id=hostnet0 \ --device virtio-net-ccw,netdev=hostnet0,id=net0,mac=00:11:22:33:44:54,devno=fe.0.0000,bootindex=1 \ +-device virtio-net-ccw,netdev=hostnet0,id=net0,mac=00:11:22:33:44:54,bootindex=1,devno=fe.0.0000 \ -device virtio-balloon-ccw,id=balloon0,devno=fe.0.0001 \ -msg timestamp=on -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Move the bootindex before the address so that the code is simpler.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 6 +----- tests/qemuxml2argvdata/aarch64-video-virtio-gpu-pci.args | 2 +- tests/qemuxml2argvdata/boot-complex.args | 2 +- tests/qemuxml2argvdata/boot-order.args | 2 +- tests/qemuxml2argvdata/controller-order.args | 2 +- .../machine-loadparm-multiple-disks-nets-s390.args | 2 +- tests/qemuxml2argvdata/machine-loadparm-net-s390.args | 2 +- 7 files changed, 7 insertions(+), 11 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Now that all users were converted to qemuBuildRomProps we can remove the old code and un-mark qemuBuildRomProps as unused. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2d47528d53..f6466b3248 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1264,7 +1264,7 @@ qemuBuildVirtioDevStr(virBuffer *buf, } -static int G_GNUC_UNUSED +static int qemuBuildRomProps(virJSONValue *props, virDomainDeviceInfo *info) { @@ -1304,38 +1304,6 @@ qemuBuildRomProps(virJSONValue *props, } -static int G_GNUC_UNUSED -qemuBuildRomStr(virBuffer *buf, - virDomainDeviceInfo *info) -{ - if (info->romenabled || info->rombar || info->romfile) { - /* Passing an empty romfile= tells QEMU to disable ROM entirely for - * this device, and makes other settings irrelevant */ - if (info->romenabled == VIR_TRISTATE_BOOL_NO) { - virBufferAddLit(buf, ",romfile="); - return 0; - } - - switch (info->rombar) { - case VIR_TRISTATE_SWITCH_OFF: - virBufferAddLit(buf, ",rombar=0"); - break; - case VIR_TRISTATE_SWITCH_ON: - virBufferAddLit(buf, ",rombar=1"); - break; - case VIR_TRISTATE_SWITCH_ABSENT: - case VIR_TRISTATE_SWITCH_LAST: - break; - } - if (info->romfile) { - virBufferAddLit(buf, ",romfile="); - virQEMUBuildBufferEscapeComma(buf, info->romfile); - } - } - - return 0; -} - static int qemuBuildIoEventFdStr(virBuffer *buf, virTristateSwitch use, -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Now that all users were converted to qemuBuildRomProps we can remove the old code and un-mark qemuBuildRomProps as unused.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Move the code into a new function called qemuBuildControllerSCSIDevStr so that the code is self contained and the original function easier to follow. This patch also moves the formatting of the properties relevant only for the 'virtio-scsi' controller to the specific case so it's more clear where they belong to. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 142 +++++++++++++++++++++++----------------- 1 file changed, 82 insertions(+), 60 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f6466b3248..f756bb2edd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2867,6 +2867,86 @@ qemuBuildUSBControllerDevStr(const virDomainDef *domainDef, } +static char * +qemuBuildControllerSCSIDevStr(const virDomainDef *domainDef, + virDomainControllerDef *def, + virQEMUCaps *qemuCaps) +{ + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + const char *driver = NULL; + + switch ((virDomainControllerModelSCSI) def->model) { + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: + if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_CONTROLLER, def) < 0) { + return NULL; + } + + if (def->iothread) { + virBufferAsprintf(&buf, ",iothread=iothread%u", + def->iothread); + } + + virBufferAsprintf(&buf, ",id=%s", def->info.alias); + + if (def->queues) + virBufferAsprintf(&buf, ",num_queues=%u", def->queues); + + if (def->cmd_per_lun) + virBufferAsprintf(&buf, ",cmd_per_lun=%u", def->cmd_per_lun); + + if (def->max_sectors) + virBufferAsprintf(&buf, ",max_sectors=%u", def->max_sectors); + + qemuBuildIoEventFdStr(&buf, def->ioeventfd, qemuCaps); + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: + driver = "lsi"; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI: + driver = "spapr-vscsi"; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068: + driver = "mptsas1068"; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078: + driver = "megasas"; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI: + driver = "pvscsi"; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AM53C974: + driver = "am53c974"; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DC390: + driver = "dc-390"; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_NCR53C90: /* It is built-in dev */ + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unsupported controller model: %s"), + virDomainControllerModelSCSITypeToString(def->model)); + return NULL; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT: + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected SCSI controller model %d"), + def->model); + return NULL; + } + + if (driver) + virBufferAsprintf(&buf, "%s,id=%s", driver, def->info.alias); + + if (qemuBuildDeviceAddressStr(&buf, domainDef, &def->info) < 0) + return NULL; + + return virBufferContentAndReset(&buf); +} + + /** * qemuBuildControllerDevStr: * @domainDef: domain definition @@ -2899,56 +2979,9 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, switch ((virDomainControllerType)def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: - switch ((virDomainControllerModelSCSI) def->model) { - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: - if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_CONTROLLER, def) < 0) { - return -1; - } - - if (def->iothread) { - virBufferAsprintf(&buf, ",iothread=iothread%u", - def->iothread); - } - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: - virBufferAddLit(&buf, "lsi"); - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI: - virBufferAddLit(&buf, "spapr-vscsi"); - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068: - virBufferAddLit(&buf, "mptsas1068"); - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078: - virBufferAddLit(&buf, "megasas"); - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI: - virBufferAddLit(&buf, "pvscsi"); - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AM53C974: - virBufferAddLit(&buf, "am53c974"); - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DC390: - virBufferAddLit(&buf, "dc-390"); - break; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_NCR53C90: /* It is built-in dev */ - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unsupported controller model: %s"), - virDomainControllerModelSCSITypeToString(def->model)); + if (!(*devstr = qemuBuildControllerSCSIDevStr(domainDef, def, qemuCaps))) return -1; - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT: - case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected SCSI controller model %d"), - def->model); - return -1; - } - virBufferAsprintf(&buf, ",id=%s", def->info.alias); - break; + return 0; case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_CONTROLLER, def) < 0) { @@ -3062,17 +3095,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, return -1; } - if (def->queues) - virBufferAsprintf(&buf, ",num_queues=%u", def->queues); - - if (def->cmd_per_lun) - virBufferAsprintf(&buf, ",cmd_per_lun=%u", def->cmd_per_lun); - - if (def->max_sectors) - virBufferAsprintf(&buf, ",max_sectors=%u", def->max_sectors); - - qemuBuildIoEventFdStr(&buf, def->ioeventfd, qemuCaps); - if (qemuBuildDeviceAddressStr(&buf, domainDef, &def->info) < 0) return -1; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Move the code into a new function called qemuBuildControllerSCSIDevStr so that the code is self contained and the original function easier to follow.
This patch also moves the formatting of the properties relevant only for the 'virtio-scsi' controller to the specific case so it's more clear where they belong to.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 142 +++++++++++++++++++++++----------------- 1 file changed, 82 insertions(+), 60 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Move the code into a new function called qemuBuildControllerPCIDevStr so that the code is self contained and the original function easier to follow. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 157 ++++++++++++++++++++++------------------ 1 file changed, 87 insertions(+), 70 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f756bb2edd..31fd9a540d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2947,6 +2947,91 @@ qemuBuildControllerSCSIDevStr(const virDomainDef *domainDef, } +static int +qemuBuildControllerPCIDevStr(virDomainControllerDef *def, + const virDomainDef *domainDef, + char **devstr) +{ + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + const virDomainPCIControllerOpts *pciopts = &def->opts.pciopts; + const char *modelName = virDomainControllerPCIModelNameTypeToString(pciopts->modelName); + + *devstr = NULL; + + /* Skip the implicit PHB for pSeries guests */ + if (def->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT && + pciopts->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE && + pciopts->targetIndex == 0) { + return 0; + } + + if (!modelName) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown virDomainControllerPCIModelName value: %d"), + pciopts->modelName); + return -1; + } + + switch ((virDomainControllerModelPCI) def->model) { + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: + virBufferAsprintf(&buf, "%s,chassis_nr=%d,id=%s", + modelName, pciopts->chassisNr, + def->info.alias); + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: + virBufferAsprintf(&buf, "%s,bus_nr=%d,id=%s", + modelName, pciopts->busNr, + def->info.alias); + if (pciopts->numaNode != -1) { + virBufferAsprintf(&buf, ",numa_node=%d", + pciopts->numaNode); + } + break; + case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_TO_PCI_BRIDGE: + virBufferAsprintf(&buf, "%s,id=%s", modelName, def->info.alias); + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: + virBufferAsprintf(&buf, "%s,port=0x%x,chassis=%d,id=%s", + modelName, pciopts->port, + pciopts->chassis, def->info.alias); + if (pciopts->hotplug != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&buf, ",hotplug=%s", + virTristateSwitchTypeToString(pciopts->hotplug)); + } + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: + virBufferAsprintf(&buf, "%s,index=%d,id=%s", + modelName, pciopts->targetIndex, + def->info.alias); + + if (pciopts->numaNode != -1) + virBufferAsprintf(&buf, ",numa_node=%d", pciopts->numaNode); + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Unsupported PCI Express root controller")); + return -1; + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected PCI controller model %d"), + def->model); + return -1; + } + + if (qemuBuildDeviceAddressStr(&buf, domainDef, &def->info) < 0) + return -1; + + *devstr = virBufferContentAndReset(&buf); + return 0; +} + + + /** * qemuBuildControllerDevStr: * @domainDef: domain definition @@ -3013,76 +3098,8 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, break; - case VIR_DOMAIN_CONTROLLER_TYPE_PCI: { - const virDomainPCIControllerOpts *pciopts = &def->opts.pciopts; - const char *modelName = virDomainControllerPCIModelNameTypeToString(pciopts->modelName); - - /* Skip the implicit PHB for pSeries guests */ - if (def->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT && - pciopts->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE && - pciopts->targetIndex == 0) { - return 0; - } - - if (!modelName) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown virDomainControllerPCIModelName value: %d"), - pciopts->modelName); - return -1; - } - - switch ((virDomainControllerModelPCI) def->model) { - case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: - virBufferAsprintf(&buf, "%s,chassis_nr=%d,id=%s", - modelName, pciopts->chassisNr, - def->info.alias); - break; - case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: - virBufferAsprintf(&buf, "%s,bus_nr=%d,id=%s", - modelName, pciopts->busNr, - def->info.alias); - if (pciopts->numaNode != -1) { - virBufferAsprintf(&buf, ",numa_node=%d", - pciopts->numaNode); - } - break; - case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_TO_PCI_BRIDGE: - virBufferAsprintf(&buf, "%s,id=%s", modelName, def->info.alias); - break; - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: - virBufferAsprintf(&buf, "%s,port=0x%x,chassis=%d,id=%s", - modelName, pciopts->port, - pciopts->chassis, def->info.alias); - if (pciopts->hotplug != VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAsprintf(&buf, ",hotplug=%s", - virTristateSwitchTypeToString(pciopts->hotplug)); - } - break; - case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: - virBufferAsprintf(&buf, "%s,index=%d,id=%s", - modelName, pciopts->targetIndex, - def->info.alias); - - if (pciopts->numaNode != -1) - virBufferAsprintf(&buf, ",numa_node=%d", pciopts->numaNode); - break; - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Unsupported PCI Express root controller")); - return -1; - case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT: - case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected PCI controller model %d"), - def->model); - return -1; - } - break; - } + case VIR_DOMAIN_CONTROLLER_TYPE_PCI: + return qemuBuildControllerPCIDevStr(def, domainDef, devstr); case VIR_DOMAIN_CONTROLLER_TYPE_IDE: case VIR_DOMAIN_CONTROLLER_TYPE_FDC: -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Move the code into a new function called qemuBuildControllerPCIDevStr so that the code is self contained and the original function easier to follow.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 157 ++++++++++++++++++++++------------------ 1 file changed, 87 insertions(+), 70 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

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> --- src/qemu/qemu_command.c | 81 ++++++++++--------- .../disk-scsi.x86_64-latest.args | 2 +- .../pseries-vio-user-assigned.args | 4 +- tests/qemuxml2argvdata/pseries-vio.args | 4 +- .../tpm-emulator-spapr.ppc64-latest.args | 4 +- 5 files changed, 49 insertions(+), 46 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 31fd9a540d..7e3e526fa5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1304,17 +1304,6 @@ qemuBuildRomProps(virJSONValue *props, } -static int -qemuBuildIoEventFdStr(virBuffer *buf, - virTristateSwitch use, - virQEMUCaps *qemuCaps G_GNUC_UNUSED) -{ - if (use) - virBufferAsprintf(buf, ",ioeventfd=%s", - virTristateSwitchTypeToString(use)); - return 0; -} - /** * qemuBuildSecretInfoProps: * @secinfo: pointer to the secret info object @@ -2867,40 +2856,37 @@ qemuBuildUSBControllerDevStr(const virDomainDef *domainDef, } -static char * -qemuBuildControllerSCSIDevStr(const virDomainDef *domainDef, - virDomainControllerDef *def, - virQEMUCaps *qemuCaps) +static virJSONValue * +qemuBuildControllerSCSIDevProps(const virDomainDef *domainDef, + virDomainControllerDef *def, + virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; + g_autofree char *iothread = NULL; const char *driver = NULL; switch ((virDomainControllerModelSCSI) def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL: - if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_CONTROLLER, def) < 0) { + if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_CONTROLLER, def, + qemuCaps))) return NULL; - } - - if (def->iothread) { - virBufferAsprintf(&buf, ",iothread=iothread%u", - def->iothread); - } - - virBufferAsprintf(&buf, ",id=%s", def->info.alias); - if (def->queues) - virBufferAsprintf(&buf, ",num_queues=%u", def->queues); + if (def->iothread > 0) + iothread = g_strdup_printf("iothread%u", def->iothread); - if (def->cmd_per_lun) - virBufferAsprintf(&buf, ",cmd_per_lun=%u", def->cmd_per_lun); - - if (def->max_sectors) - virBufferAsprintf(&buf, ",max_sectors=%u", def->max_sectors); - - qemuBuildIoEventFdStr(&buf, def->ioeventfd, qemuCaps); + if (virJSONValueObjectAdd(props, + "S:iothread", iothread, + "s:id", def->info.alias, + "p:num_queues", def->queues, + "p:cmd_per_lun", def->cmd_per_lun, + "p:max_sectors", def->max_sectors, + "T:ioeventfd", def->ioeventfd, + NULL) < 0) + return NULL; break; + case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: driver = "lsi"; break; @@ -2937,13 +2923,18 @@ qemuBuildControllerSCSIDevStr(const virDomainDef *domainDef, return NULL; } - if (driver) - virBufferAsprintf(&buf, "%s,id=%s", driver, def->info.alias); + if (driver) { + if (virJSONValueObjectCreate(&props, + "s:driver", driver, + "s:id", def->info.alias, + NULL) < 0) + return NULL; + } - if (qemuBuildDeviceAddressStr(&buf, domainDef, &def->info) < 0) + if (qemuBuildDeviceAddressProps(props, domainDef, &def->info) < 0) return NULL; - return virBufferContentAndReset(&buf); + return g_steal_pointer(&props); } @@ -3059,13 +3050,25 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, char **devstr) { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; + const char *driver = NULL; *devstr = NULL; switch ((virDomainControllerType)def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: - if (!(*devstr = qemuBuildControllerSCSIDevStr(domainDef, def, qemuCaps))) + if (!(props = qemuBuildControllerSCSIDevProps(domainDef, def, qemuCaps))) + return -1; + + driver = virJSONValueObjectGetString(props, "driver"); + + virBufferAsprintf(&buf, "%s,", driver); + + if (virQEMUBuildCommandLineJSON(props, &buf, "driver", NULL) < 0) return -1; + + *devstr = virBufferContentAndReset(&buf); + return 0; case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: diff --git a/tests/qemuxml2argvdata/disk-scsi.x86_64-latest.args b/tests/qemuxml2argvdata/disk-scsi.x86_64-latest.args index d9971582ac..79b66da881 100644 --- a/tests/qemuxml2argvdata/disk-scsi.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-scsi.x86_64-latest.args @@ -30,7 +30,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -device lsi,id=scsi0,bus=pci.0,addr=0x2 \ -device megasas,id=scsi1,bus=pci.0,addr=0x3 \ -device mptsas1068,id=scsi2,bus=pci.0,addr=0x4 \ --device spapr-vscsi,id=scsi3,reg=0x00002000 \ +-device spapr-vscsi,id=scsi3,reg=8192 \ -device pvscsi,id=scsi4,bus=pci.0,addr=0x5 \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-6-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-6-format","read-only":false,"driver":"raw","file":"libvirt-6-storage"}' \ diff --git a/tests/qemuxml2argvdata/pseries-vio-user-assigned.args b/tests/qemuxml2argvdata/pseries-vio-user-assigned.args index 5295cfaca4..dfc3ad0d1b 100644 --- a/tests/qemuxml2argvdata/pseries-vio-user-assigned.args +++ b/tests/qemuxml2argvdata/pseries-vio-user-assigned.args @@ -24,8 +24,8 @@ QEMU_AUDIO_DRV=none \ -rtc base=utc \ -no-shutdown \ -boot strict=on \ --device spapr-vscsi,id=scsi0,reg=0x00002000 \ --device spapr-vscsi,id=scsi1,reg=0x30000000 \ +-device spapr-vscsi,id=scsi0,reg=8192 \ +-device spapr-vscsi,id=scsi1,reg=805306368 \ -usb \ -drive file=/tmp/scsidisk.img,format=raw,if=none,id=drive-scsi1-0-0-0 \ -device scsi-hd,bus=scsi1.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi1-0-0-0,id=scsi1-0-0-0,bootindex=1 \ diff --git a/tests/qemuxml2argvdata/pseries-vio.args b/tests/qemuxml2argvdata/pseries-vio.args index f179e89cd2..a8e18fae5a 100644 --- a/tests/qemuxml2argvdata/pseries-vio.args +++ b/tests/qemuxml2argvdata/pseries-vio.args @@ -24,8 +24,8 @@ QEMU_AUDIO_DRV=none \ -rtc base=utc \ -no-shutdown \ -boot strict=on \ --device spapr-vscsi,id=scsi0,reg=0x00002000 \ --device spapr-vscsi,id=scsi1,reg=0x00003000 \ +-device spapr-vscsi,id=scsi0,reg=8192 \ +-device spapr-vscsi,id=scsi1,reg=12288 \ -usb \ -drive file=/tmp/scsidisk.img,format=raw,if=none,id=drive-scsi1-0-0-0 \ -device scsi-hd,bus=scsi1.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi1-0-0-0,id=scsi1-0-0-0,bootindex=1 \ diff --git a/tests/qemuxml2argvdata/tpm-emulator-spapr.ppc64-latest.args b/tests/qemuxml2argvdata/tpm-emulator-spapr.ppc64-latest.args index 29151a0084..04d632c091 100644 --- a/tests/qemuxml2argvdata/tpm-emulator-spapr.ppc64-latest.args +++ b/tests/qemuxml2argvdata/tpm-emulator-spapr.ppc64-latest.args @@ -26,8 +26,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-TPM-VM/.config \ -no-shutdown \ -boot menu=on,strict=on \ -device pci-ohci,id=usb,bus=pci.0,addr=0x1 \ --device spapr-vscsi,id=scsi0,reg=0x00002000 \ --device spapr-vscsi,id=scsi1,reg=0x00003000 \ +-device spapr-vscsi,id=scsi0,reg=8192 \ +-device spapr-vscsi,id=scsi1,reg=12288 \ -blockdev '{"driver":"file","filename":"/tmp/scsidisk.img","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ -device scsi-hd,bus=scsi1.0,channel=0,scsi-id=0,lun=0,device_id=drive-scsi1-0-0-0,drive=libvirt-1-format,id=scsi1-0-0-0,bootindex=1 \ -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
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> --- src/qemu/qemu_command.c | 81 ++++++++++--------- .../disk-scsi.x86_64-latest.args | 2 +- .../pseries-vio-user-assigned.args | 4 +- tests/qemuxml2argvdata/pseries-vio.args | 4 +- .../tpm-emulator-spapr.ppc64-latest.args | 4 +- 5 files changed, 49 insertions(+), 46 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

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> --- src/qemu/qemu_command.c | 99 +++++++++++++------ ...fault-cpu-kvm-virt-4.2.aarch64-latest.args | 4 +- ...fault-cpu-tcg-virt-4.2.aarch64-latest.args | 4 +- .../qemuxml2argvdata/aarch64-pci-serial.args | 2 +- .../aarch64-traditional-pci.args | 4 +- .../aarch64-video-default.args | 2 +- .../aarch64-video-virtio-gpu-pci.args | 4 +- .../aarch64-virt-2.6-virtio-pci-default.args | 2 +- .../aarch64-virt-graphics.aarch64-latest.args | 16 +-- .../aarch64-virt-headless.aarch64-latest.args | 14 +-- .../aarch64-virtio-pci-default.args | 12 +-- tests/qemuxml2argvdata/autoindex.args | 22 ++--- tests/qemuxml2argvdata/bios-nvram-secure.args | 2 +- tests/qemuxml2argvdata/cpu-host-model.args | 2 +- .../cpu-host-model.x86_64-2.11.0.args | 6 +- .../cpu-host-model.x86_64-2.12.0.args | 6 +- .../cpu-host-model.x86_64-3.0.0.args | 6 +- .../cpu-host-model.x86_64-3.1.0.args | 6 +- .../cpu-host-model.x86_64-4.0.0.args | 6 +- .../cpu-host-model.x86_64-4.1.0.args | 6 +- .../cpu-host-model.x86_64-4.2.0.args | 6 +- .../cpu-host-model.x86_64-5.0.0.args | 6 +- .../cpu-host-model.x86_64-5.1.0.args | 6 +- .../cpu-host-model.x86_64-5.2.0.args | 6 +- .../cpu-host-model.x86_64-6.0.0.args | 6 +- .../cpu-host-model.x86_64-6.1.0.args | 6 +- .../cpu-host-model.x86_64-latest.args | 6 +- ...ult-video-type-aarch64.aarch64-latest.args | 4 +- ...ult-video-type-riscv64.riscv64-latest.args | 4 +- .../disk-floppy-q35-2_11.x86_64-2.12.0.args | 4 +- .../disk-floppy-q35-2_11.x86_64-latest.args | 4 +- .../disk-floppy-q35-2_9.x86_64-2.12.0.args | 4 +- .../disk-floppy-q35-2_9.x86_64-latest.args | 4 +- .../hostdev-scsi-vhost-scsi-pcie.args | 4 +- .../mach-virt-serial-pci.args | 2 +- .../mach-virt-serial-usb.args | 4 +- tests/qemuxml2argvdata/machine-smm-opt.args | 2 +- .../os-firmware-bios.x86_64-latest.args | 2 +- ...re-efi-no-enrolled-keys.x86_64-latest.args | 4 +- ...os-firmware-efi-secboot.x86_64-latest.args | 2 +- .../os-firmware-efi.x86_64-latest.args | 2 +- tests/qemuxml2argvdata/pcie-expander-bus.args | 66 ++++++------- .../pcie-root-port-model-generic.args | 6 +- .../pcie-root-port-model-ioh3420.args | 4 +- ...cie-root-port-nohotplug.x86_64-latest.args | 14 +-- tests/qemuxml2argvdata/pcie-root-port.args | 4 +- .../pcie-switch-downstream-port.args | 16 +-- .../pcie-switch-upstream-port.args | 4 +- .../q35-default-devices-only.args | 6 +- tests/qemuxml2argvdata/q35-multifunction.args | 36 +++---- .../q35-pci-force-address.args | 2 +- tests/qemuxml2argvdata/q35-pcie-autoadd.args | 28 +++--- tests/qemuxml2argvdata/q35-pcie.args | 26 ++--- .../q35-pm-disable-fallback.args | 2 +- tests/qemuxml2argvdata/q35-pm-disable.args | 2 +- .../q35-virt-manager-basic.args | 12 +-- tests/qemuxml2argvdata/q35-virtio-pci.args | 26 ++--- .../riscv64-virt-graphics.riscv64-latest.args | 16 +-- .../riscv64-virt-headless.riscv64-latest.args | 14 +-- .../tseg-explicit-size.x86_64-latest.args | 6 +- ...vhost-user-fs-hugepages.x86_64-latest.args | 8 +- .../virtio-non-transitional.x86_64-3.1.0.args | 22 ++--- ...virtio-non-transitional.x86_64-latest.args | 22 ++--- .../virtio-transitional.x86_64-3.1.0.args | 4 +- .../virtio-transitional.x86_64-latest.args | 4 +- ...default-cpu-kvm-q35-4.2.x86_64-latest.args | 8 +- ...default-cpu-tcg-q35-4.2.x86_64-latest.args | 8 +- .../x86_64-q35-graphics.x86_64-latest.args | 14 +-- .../x86_64-q35-headless.x86_64-latest.args | 14 +-- 69 files changed, 372 insertions(+), 335 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7e3e526fa5..68b6bf868e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2939,15 +2939,15 @@ qemuBuildControllerSCSIDevProps(const virDomainDef *domainDef, static int -qemuBuildControllerPCIDevStr(virDomainControllerDef *def, - const virDomainDef *domainDef, - char **devstr) +qemuBuildControllerPCIDevProps(virDomainControllerDef *def, + const virDomainDef *domainDef, + virJSONValue **devprops) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; const virDomainPCIControllerOpts *pciopts = &def->opts.pciopts; const char *modelName = virDomainControllerPCIModelNameTypeToString(pciopts->modelName); - *devstr = NULL; + *devprops = NULL; /* Skip the implicit PHB for pSeries guests */ if (def->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT && @@ -2965,42 +2965,65 @@ qemuBuildControllerPCIDevStr(virDomainControllerDef *def, switch ((virDomainControllerModelPCI) def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: - virBufferAsprintf(&buf, "%s,chassis_nr=%d,id=%s", - modelName, pciopts->chassisNr, - def->info.alias); + if (virJSONValueObjectCreate(&props, + "s:driver", modelName, + "i:chassis_nr", pciopts->chassisNr, + "s:id", def->info.alias, + NULL) < 0) + return -1; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: - virBufferAsprintf(&buf, "%s,bus_nr=%d,id=%s", - modelName, pciopts->busNr, - def->info.alias); - if (pciopts->numaNode != -1) { - virBufferAsprintf(&buf, ",numa_node=%d", - pciopts->numaNode); - } + if (virJSONValueObjectCreate(&props, + "s:driver", modelName, + "i:bus_nr", pciopts->busNr, + "s:id", def->info.alias, + NULL) < 0) + return -1; + + if (pciopts->numaNode != -1 && + virJSONValueObjectAdd(props, "i:numa_node", pciopts->numaNode, NULL) < 0) + return -1; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_TO_PCI_BRIDGE: - virBufferAsprintf(&buf, "%s,id=%s", modelName, def->info.alias); + if (virJSONValueObjectCreate(&props, + "s:driver", modelName, + "s:id", def->info.alias, + NULL) < 0) + return -1; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: - virBufferAsprintf(&buf, "%s,port=0x%x,chassis=%d,id=%s", - modelName, pciopts->port, - pciopts->chassis, def->info.alias); - if (pciopts->hotplug != VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAsprintf(&buf, ",hotplug=%s", - virTristateSwitchTypeToString(pciopts->hotplug)); - } + if (virJSONValueObjectCreate(&props, + "s:driver", modelName, + "i:port", pciopts->port, + "i:chassis", pciopts->chassis, + "s:id", def->info.alias, + "T:hotplug", pciopts->hotplug, + NULL) < 0) + return -1; + break; case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: - virBufferAsprintf(&buf, "%s,index=%d,id=%s", - modelName, pciopts->targetIndex, - def->info.alias); + if (virJSONValueObjectCreate(&props, + "s:driver", modelName, + "i:index", pciopts->targetIndex, + "s:id", def->info.alias, + NULL) < 0) + return -1; + + if (pciopts->numaNode != -1 && + virJSONValueObjectAdd(props, "i:numa_node", pciopts->numaNode, NULL) < 0) + return -1; - if (pciopts->numaNode != -1) - virBufferAsprintf(&buf, ",numa_node=%d", pciopts->numaNode); break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -3014,10 +3037,10 @@ qemuBuildControllerPCIDevStr(virDomainControllerDef *def, return -1; } - if (qemuBuildDeviceAddressStr(&buf, domainDef, &def->info) < 0) + if (qemuBuildDeviceAddressProps(props, domainDef, &def->info) < 0) return -1; - *devstr = virBufferContentAndReset(&buf); + *devprops = g_steal_pointer(&props); return 0; } @@ -3102,7 +3125,21 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, break; case VIR_DOMAIN_CONTROLLER_TYPE_PCI: - return qemuBuildControllerPCIDevStr(def, domainDef, devstr); + if (qemuBuildControllerPCIDevProps(def, domainDef, &props) < 0) + return -1; + + if (!props) + return 0; + + driver = virJSONValueObjectGetString(props, "driver"); + + virBufferAsprintf(&buf, "%s,", driver); + + if (virQEMUBuildCommandLineJSON(props, &buf, "driver", NULL) < 0) + return -1; + + *devstr = virBufferContentAndReset(&buf); + return 0; case VIR_DOMAIN_CONTROLLER_TYPE_IDE: case VIR_DOMAIN_CONTROLLER_TYPE_FDC: diff --git a/tests/qemuxml2argvdata/aarch64-default-cpu-kvm-virt-4.2.aarch64-latest.args b/tests/qemuxml2argvdata/aarch64-default-cpu-kvm-virt-4.2.aarch64-latest.args index b2285a5e1d..9a702f6a16 100644 --- a/tests/qemuxml2argvdata/aarch64-default-cpu-kvm-virt-4.2.aarch64-latest.args +++ b/tests/qemuxml2argvdata/aarch64-default-cpu-kvm-virt-4.2.aarch64-latest.args @@ -25,8 +25,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/guest.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage"}' \ -device virtio-blk-pci,bus=pci.1,addr=0x0,drive=libvirt-1-format,id=virtio-disk0,bootindex=1 \ diff --git a/tests/qemuxml2argvdata/aarch64-default-cpu-tcg-virt-4.2.aarch64-latest.args b/tests/qemuxml2argvdata/aarch64-default-cpu-tcg-virt-4.2.aarch64-latest.args index d4b63539a3..7647de0342 100644 --- a/tests/qemuxml2argvdata/aarch64-default-cpu-tcg-virt-4.2.aarch64-latest.args +++ b/tests/qemuxml2argvdata/aarch64-default-cpu-tcg-virt-4.2.aarch64-latest.args @@ -26,8 +26,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/guest.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage"}' \ -device virtio-blk-pci,bus=pci.1,addr=0x0,drive=libvirt-1-format,id=virtio-disk0,bootindex=1 \ diff --git a/tests/qemuxml2argvdata/aarch64-pci-serial.args b/tests/qemuxml2argvdata/aarch64-pci-serial.args index 92f6c00556..7be4bf60e3 100644 --- a/tests/qemuxml2argvdata/aarch64-pci-serial.args +++ b/tests/qemuxml2argvdata/aarch64-pci-serial.args @@ -27,7 +27,7 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1 \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device pcie-root-port,port=0x10,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \ +-device pcie-root-port,port=16,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \ -chardev pty,id=charserial0,logfile=/tmp/log,logappend=on \ -device pci-serial,chardev=charserial0,id=serial0,bus=pci.2,addr=0x1 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/aarch64-traditional-pci.args b/tests/qemuxml2argvdata/aarch64-traditional-pci.args index d2779f0528..0da111db80 100644 --- a/tests/qemuxml2argvdata/aarch64-traditional-pci.args +++ b/tests/qemuxml2argvdata/aarch64-traditional-pci.args @@ -25,9 +25,9 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ --device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ -chardev pty,id=charserial0 \ -device pci-serial,chardev=charserial0,id=serial0,bus=pci.2,addr=0x1 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/aarch64-video-default.args b/tests/qemuxml2argvdata/aarch64-video-default.args index 568b456389..ea9449df34 100644 --- a/tests/qemuxml2argvdata/aarch64-video-default.args +++ b/tests/qemuxml2argvdata/aarch64-video-default.args @@ -27,7 +27,7 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1 \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device ioh3420,port=0x10,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \ +-device ioh3420,port=16,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \ -vnc 127.0.0.1:0 \ -device virtio-gpu-pci,id=video0,bus=pci.2,addr=0x1 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/aarch64-video-virtio-gpu-pci.args b/tests/qemuxml2argvdata/aarch64-video-virtio-gpu-pci.args index ce3b68bf18..fd1d69cf65 100644 --- a/tests/qemuxml2argvdata/aarch64-video-virtio-gpu-pci.args +++ b/tests/qemuxml2argvdata/aarch64-video-virtio-gpu-pci.args @@ -26,8 +26,8 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device ioh3420,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device ioh3420,port=0x9,chassis=2,id=pci.2,bus=pcie.0,multifunction=on,addr=0x1.0x1 \ +-device ioh3420,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device ioh3420,port=9,chassis=2,id=pci.2,bus=pcie.0,multifunction=on,addr=0x1.0x1 \ -netdev user,id=hostnet0 \ -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:73:34:53,bootindex=1,bus=pci.1,addr=0x0 \ -device virtio-gpu-pci,id=video0,bus=pci.2,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/aarch64-virt-2.6-virtio-pci-default.args b/tests/qemuxml2argvdata/aarch64-virt-2.6-virtio-pci-default.args index 0f898010f8..185303200c 100644 --- a/tests/qemuxml2argvdata/aarch64-virt-2.6-virtio-pci-default.args +++ b/tests/qemuxml2argvdata/aarch64-virt-2.6-virtio-pci-default.args @@ -32,7 +32,7 @@ QEMU_AUDIO_DRV=none \ -dtb /aarch64.dtb \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1 \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device ioh3420,port=0x10,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \ +-device ioh3420,port=16,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \ -device virtio-serial-pci,id=virtio-serial0,bus=pci.2,addr=0x2 \ -drive file=/aarch64.raw,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,bus=pci.2,addr=0x3,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ diff --git a/tests/qemuxml2argvdata/aarch64-virt-graphics.aarch64-latest.args b/tests/qemuxml2argvdata/aarch64-virt-graphics.aarch64-latest.args index 5f98b32dad..878deacf76 100644 --- a/tests/qemuxml2argvdata/aarch64-virt-graphics.aarch64-latest.args +++ b/tests/qemuxml2argvdata/aarch64-virt-graphics.aarch64-latest.args @@ -28,14 +28,14 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -rtc base=utc \ -no-shutdown \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ --device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ --device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ --device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ --device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ --device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=11,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ +-device pcie-root-port,port=12,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ +-device pcie-root-port,port=13,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ +-device pcie-root-port,port=14,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ +-device pcie-root-port,port=15,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ -device qemu-xhci,p2=15,p3=15,id=usb,bus=pci.2,addr=0x0 \ -device virtio-serial-pci,id=virtio-serial0,bus=pci.3,addr=0x0 \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/guest.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ diff --git a/tests/qemuxml2argvdata/aarch64-virt-headless.aarch64-latest.args b/tests/qemuxml2argvdata/aarch64-virt-headless.aarch64-latest.args index e4ee704275..71838bc407 100644 --- a/tests/qemuxml2argvdata/aarch64-virt-headless.aarch64-latest.args +++ b/tests/qemuxml2argvdata/aarch64-virt-headless.aarch64-latest.args @@ -29,13 +29,13 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -rtc base=utc \ -no-shutdown \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ --device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ --device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ --device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ --device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=11,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ +-device pcie-root-port,port=12,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ +-device pcie-root-port,port=13,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ +-device pcie-root-port,port=14,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ -device qemu-xhci,p2=15,p3=15,id=usb,bus=pci.2,addr=0x0 \ -device virtio-serial-pci,id=virtio-serial0,bus=pci.3,addr=0x0 \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/guest.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ diff --git a/tests/qemuxml2argvdata/aarch64-virtio-pci-default.args b/tests/qemuxml2argvdata/aarch64-virtio-pci-default.args index 426881a10d..15c64312e3 100644 --- a/tests/qemuxml2argvdata/aarch64-virtio-pci-default.args +++ b/tests/qemuxml2argvdata/aarch64-virtio-pci-default.args @@ -30,12 +30,12 @@ QEMU_AUDIO_DRV=none \ -initrd /aarch64.initrd \ -append 'earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait' \ -dtb /aarch64.dtb \ --device ioh3420,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device ioh3420,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device ioh3420,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ --device ioh3420,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ --device ioh3420,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ --device ioh3420,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ +-device ioh3420,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device ioh3420,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device ioh3420,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device ioh3420,port=11,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ +-device ioh3420,port=12,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ +-device ioh3420,port=13,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ -device virtio-serial-pci,id=virtio-serial0,bus=pci.2,addr=0x0 \ -drive file=/aarch64.raw,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,bus=pci.3,addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ diff --git a/tests/qemuxml2argvdata/autoindex.args b/tests/qemuxml2argvdata/autoindex.args index 2a6233a1ed..50e9ef0fe9 100644 --- a/tests/qemuxml2argvdata/autoindex.args +++ b/tests/qemuxml2argvdata/autoindex.args @@ -27,18 +27,18 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device ioh3420,port=0x8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ +-device ioh3420,port=8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ -device x3130-upstream,id=pci.4,bus=pci.3,addr=0x0 \ --device xio3130-downstream,port=0x0,chassis=5,id=pci.5,bus=pci.4,addr=0x0 \ --device xio3130-downstream,port=0x1,chassis=6,id=pci.6,bus=pci.4,addr=0x1 \ --device xio3130-downstream,port=0x2,chassis=7,id=pci.7,bus=pci.4,addr=0x2 \ --device xio3130-downstream,port=0x3,chassis=8,id=pci.8,bus=pci.4,addr=0x3 \ --device xio3130-downstream,port=0x4,chassis=9,id=pci.9,bus=pci.4,addr=0x4 \ --device xio3130-downstream,port=0x5,chassis=10,id=pci.10,bus=pci.4,addr=0x5 \ --device xio3130-downstream,port=0x6,chassis=11,id=pci.11,bus=pci.4,addr=0x6 \ --device xio3130-downstream,port=0x7,chassis=12,id=pci.12,bus=pci.4,addr=0x7 \ --device xio3130-downstream,port=0x8,chassis=13,id=pci.13,bus=pci.4,addr=0x8 \ --device xio3130-downstream,port=0x9,chassis=14,id=pci.14,bus=pci.4,addr=0x9 \ +-device xio3130-downstream,port=0,chassis=5,id=pci.5,bus=pci.4,addr=0x0 \ +-device xio3130-downstream,port=1,chassis=6,id=pci.6,bus=pci.4,addr=0x1 \ +-device xio3130-downstream,port=2,chassis=7,id=pci.7,bus=pci.4,addr=0x2 \ +-device xio3130-downstream,port=3,chassis=8,id=pci.8,bus=pci.4,addr=0x3 \ +-device xio3130-downstream,port=4,chassis=9,id=pci.9,bus=pci.4,addr=0x4 \ +-device xio3130-downstream,port=5,chassis=10,id=pci.10,bus=pci.4,addr=0x5 \ +-device xio3130-downstream,port=6,chassis=11,id=pci.11,bus=pci.4,addr=0x6 \ +-device xio3130-downstream,port=7,chassis=12,id=pci.12,bus=pci.4,addr=0x7 \ +-device xio3130-downstream,port=8,chassis=13,id=pci.13,bus=pci.4,addr=0x8 \ +-device xio3130-downstream,port=9,chassis=14,id=pci.14,bus=pci.4,addr=0x9 \ -device ich9-usb-ehci1,id=usb,bus=pcie.0,addr=0x1d.0x7 \ -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pcie.0,multifunction=on,addr=0x1d \ -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pcie.0,addr=0x1d.0x1 \ diff --git a/tests/qemuxml2argvdata/bios-nvram-secure.args b/tests/qemuxml2argvdata/bios-nvram-secure.args index 7b9a958536..0bf2cbbe34 100644 --- a/tests/qemuxml2argvdata/bios-nvram-secure.args +++ b/tests/qemuxml2argvdata/bios-nvram-secure.args @@ -29,7 +29,7 @@ QEMU_AUDIO_DRV=none \ -boot menu=on,strict=on \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device ioh3420,port=0x8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ +-device ioh3420,port=8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ -device virtio-scsi-pci,id=scsi0,bus=pci.2,addr=0x1 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-scsi0-0-0-0 \ -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1 \ diff --git a/tests/qemuxml2argvdata/cpu-host-model.args b/tests/qemuxml2argvdata/cpu-host-model.args index 96fe2f9edb..8096929399 100644 --- a/tests/qemuxml2argvdata/cpu-host-model.args +++ b/tests/qemuxml2argvdata/cpu-host-model.args @@ -28,7 +28,7 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device ioh3420,port=0x8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ +-device ioh3420,port=8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ -device ich9-usb-ehci1,id=usb,bus=pcie.0,addr=0x1d.0x7 \ -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pcie.0,multifunction=on,addr=0x1d \ -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pcie.0,addr=0x1d.0x1 \ diff --git a/tests/qemuxml2argvdata/cpu-host-model.x86_64-2.11.0.args b/tests/qemuxml2argvdata/cpu-host-model.x86_64-2.11.0.args index bd3a9e26d2..ba89e4cce3 100644 --- a/tests/qemuxml2argvdata/cpu-host-model.x86_64-2.11.0.args +++ b/tests/qemuxml2argvdata/cpu-host-model.x86_64-2.11.0.args @@ -26,9 +26,9 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/cpu-host-model.x86_64-2.12.0.args b/tests/qemuxml2argvdata/cpu-host-model.x86_64-2.12.0.args index 6bf18db474..55d5f5652a 100644 --- a/tests/qemuxml2argvdata/cpu-host-model.x86_64-2.12.0.args +++ b/tests/qemuxml2argvdata/cpu-host-model.x86_64-2.12.0.args @@ -26,9 +26,9 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/cpu-host-model.x86_64-3.0.0.args b/tests/qemuxml2argvdata/cpu-host-model.x86_64-3.0.0.args index cb378765b0..4002974a95 100644 --- a/tests/qemuxml2argvdata/cpu-host-model.x86_64-3.0.0.args +++ b/tests/qemuxml2argvdata/cpu-host-model.x86_64-3.0.0.args @@ -26,9 +26,9 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/cpu-host-model.x86_64-3.1.0.args b/tests/qemuxml2argvdata/cpu-host-model.x86_64-3.1.0.args index 9af5a7fffa..ba95587e8b 100644 --- a/tests/qemuxml2argvdata/cpu-host-model.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/cpu-host-model.x86_64-3.1.0.args @@ -26,9 +26,9 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/cpu-host-model.x86_64-4.0.0.args b/tests/qemuxml2argvdata/cpu-host-model.x86_64-4.0.0.args index 28af7263a2..eee0be673d 100644 --- a/tests/qemuxml2argvdata/cpu-host-model.x86_64-4.0.0.args +++ b/tests/qemuxml2argvdata/cpu-host-model.x86_64-4.0.0.args @@ -26,9 +26,9 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/cpu-host-model.x86_64-4.1.0.args b/tests/qemuxml2argvdata/cpu-host-model.x86_64-4.1.0.args index b6a9afb359..bda5f557d9 100644 --- a/tests/qemuxml2argvdata/cpu-host-model.x86_64-4.1.0.args +++ b/tests/qemuxml2argvdata/cpu-host-model.x86_64-4.1.0.args @@ -26,9 +26,9 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/cpu-host-model.x86_64-4.2.0.args b/tests/qemuxml2argvdata/cpu-host-model.x86_64-4.2.0.args index 69dc442bfc..59f22d1e54 100644 --- a/tests/qemuxml2argvdata/cpu-host-model.x86_64-4.2.0.args +++ b/tests/qemuxml2argvdata/cpu-host-model.x86_64-4.2.0.args @@ -25,9 +25,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/cpu-host-model.x86_64-5.0.0.args b/tests/qemuxml2argvdata/cpu-host-model.x86_64-5.0.0.args index 3ce594ba13..0c6ec3fe64 100644 --- a/tests/qemuxml2argvdata/cpu-host-model.x86_64-5.0.0.args +++ b/tests/qemuxml2argvdata/cpu-host-model.x86_64-5.0.0.args @@ -25,9 +25,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/cpu-host-model.x86_64-5.1.0.args b/tests/qemuxml2argvdata/cpu-host-model.x86_64-5.1.0.args index 6c6ebb03f6..dfc31cd4c2 100644 --- a/tests/qemuxml2argvdata/cpu-host-model.x86_64-5.1.0.args +++ b/tests/qemuxml2argvdata/cpu-host-model.x86_64-5.1.0.args @@ -25,9 +25,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/cpu-host-model.x86_64-5.2.0.args b/tests/qemuxml2argvdata/cpu-host-model.x86_64-5.2.0.args index c943457ced..c9aab8533f 100644 --- a/tests/qemuxml2argvdata/cpu-host-model.x86_64-5.2.0.args +++ b/tests/qemuxml2argvdata/cpu-host-model.x86_64-5.2.0.args @@ -26,9 +26,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/cpu-host-model.x86_64-6.0.0.args b/tests/qemuxml2argvdata/cpu-host-model.x86_64-6.0.0.args index 702cd70bd8..dd8182c8de 100644 --- a/tests/qemuxml2argvdata/cpu-host-model.x86_64-6.0.0.args +++ b/tests/qemuxml2argvdata/cpu-host-model.x86_64-6.0.0.args @@ -26,9 +26,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/cpu-host-model.x86_64-6.1.0.args b/tests/qemuxml2argvdata/cpu-host-model.x86_64-6.1.0.args index fee116de1e..d43200523c 100644 --- a/tests/qemuxml2argvdata/cpu-host-model.x86_64-6.1.0.args +++ b/tests/qemuxml2argvdata/cpu-host-model.x86_64-6.1.0.args @@ -26,9 +26,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/cpu-host-model.x86_64-latest.args b/tests/qemuxml2argvdata/cpu-host-model.x86_64-latest.args index c9eb5a42ab..ee31f01bf7 100644 --- a/tests/qemuxml2argvdata/cpu-host-model.x86_64-latest.args +++ b/tests/qemuxml2argvdata/cpu-host-model.x86_64-latest.args @@ -26,9 +26,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/default-video-type-aarch64.aarch64-latest.args b/tests/qemuxml2argvdata/default-video-type-aarch64.aarch64-latest.args index 02986bb0df..5b7f77e348 100644 --- a/tests/qemuxml2argvdata/default-video-type-aarch64.aarch64-latest.args +++ b/tests/qemuxml2argvdata/default-video-type-aarch64.aarch64-latest.args @@ -24,8 +24,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-default-video-type-a/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -audiodev id=audio1,driver=none \ -vnc 127.0.0.1:0,audiodev=audio1 \ -device virtio-gpu-pci,id=video0,max_outputs=1,bus=pci.1,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/default-video-type-riscv64.riscv64-latest.args b/tests/qemuxml2argvdata/default-video-type-riscv64.riscv64-latest.args index 885de6d3a8..f2d54056d7 100644 --- a/tests/qemuxml2argvdata/default-video-type-riscv64.riscv64-latest.args +++ b/tests/qemuxml2argvdata/default-video-type-riscv64.riscv64-latest.args @@ -22,8 +22,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-default-video-type-r/.config \ -rtc base=utc \ -no-shutdown \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -audiodev id=audio1,driver=spice \ -spice port=0,seamless-migration=on \ -device virtio-gpu-pci,id=video0,max_outputs=1,bus=pci.1,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-2.12.0.args b/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-2.12.0.args index 4db6287eaf..bd5b79e294 100644 --- a/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-2.12.0.args +++ b/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-2.12.0.args @@ -25,8 +25,8 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -drive file=/tmp/firmware.img,format=raw,if=none,id=drive-fdc0-0-0 \ -drive file=/tmp/data.img,format=qcow2,if=none,id=drive-fdc0-0-1 \ diff --git a/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args b/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args index 5000112cdc..ca01a34f58 100644 --- a/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args @@ -26,8 +26,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -device isa-fdc,bootindexA=1 \ -blockdev '{"driver":"file","filename":"/tmp/firmware.img","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \ diff --git a/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-2.12.0.args b/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-2.12.0.args index 67aeb49697..d489581cf8 100644 --- a/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-2.12.0.args +++ b/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-2.12.0.args @@ -25,8 +25,8 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -drive file=/tmp/firmware.img,format=raw,if=none,id=drive-fdc0-0-0 \ -drive file=/tmp/data.img,format=qcow2,if=none,id=drive-fdc0-0-1 \ diff --git a/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args b/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args index 76b481243f..1bb3851b2a 100644 --- a/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args @@ -26,8 +26,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -device isa-fdc,bootindexA=1 \ -blockdev '{"driver":"file","filename":"/tmp/firmware.img","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \ diff --git a/tests/qemuxml2argvdata/hostdev-scsi-vhost-scsi-pcie.args b/tests/qemuxml2argvdata/hostdev-scsi-vhost-scsi-pcie.args index e1b1a385ae..a5d2246278 100644 --- a/tests/qemuxml2argvdata/hostdev-scsi-vhost-scsi-pcie.args +++ b/tests/qemuxml2argvdata/hostdev-scsi-vhost-scsi-pcie.args @@ -25,7 +25,7 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -device vhost-scsi-pci,wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.1,addr=0x0 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/mach-virt-serial-pci.args b/tests/qemuxml2argvdata/mach-virt-serial-pci.args index c7b12375b0..fe9e938932 100644 --- a/tests/qemuxml2argvdata/mach-virt-serial-pci.args +++ b/tests/qemuxml2argvdata/mach-virt-serial-pci.args @@ -27,7 +27,7 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1 \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device pcie-root-port,port=0x10,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \ +-device pcie-root-port,port=16,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \ -chardev pty,id=charserial0 \ -device pci-serial,chardev=charserial0,id=serial0,bus=pci.2,addr=0x1 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/mach-virt-serial-usb.args b/tests/qemuxml2argvdata/mach-virt-serial-usb.args index 77490c1427..13bba0a790 100644 --- a/tests/qemuxml2argvdata/mach-virt-serial-usb.args +++ b/tests/qemuxml2argvdata/mach-virt-serial-usb.args @@ -25,8 +25,8 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -chardev pty,id=charserial0 \ -device usb-serial,chardev=charserial0,id=serial0,bus=usb.0,port=1 \ diff --git a/tests/qemuxml2argvdata/machine-smm-opt.args b/tests/qemuxml2argvdata/machine-smm-opt.args index eda178beb4..669d3b3a6e 100644 --- a/tests/qemuxml2argvdata/machine-smm-opt.args +++ b/tests/qemuxml2argvdata/machine-smm-opt.args @@ -27,7 +27,7 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device ioh3420,port=0x8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ +-device ioh3420,port=8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ -device virtio-scsi-pci,id=scsi0,bus=pci.2,addr=0x1 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-scsi0-0-0-0 \ -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1 \ diff --git a/tests/qemuxml2argvdata/os-firmware-bios.x86_64-latest.args b/tests/qemuxml2argvdata/os-firmware-bios.x86_64-latest.args index 957249dc42..12f4e8fcb9 100644 --- a/tests/qemuxml2argvdata/os-firmware-bios.x86_64-latest.args +++ b/tests/qemuxml2argvdata/os-firmware-bios.x86_64-latest.args @@ -30,7 +30,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-fedora/.config \ -boot menu=on,strict=on \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device ioh3420,port=0x8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ +-device ioh3420,port=8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ -device ich9-usb-ehci1,id=usb,bus=pcie.0,addr=0x1d.0x7 \ -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pcie.0,multifunction=on,addr=0x1d \ -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pcie.0,addr=0x1d.0x1 \ diff --git a/tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.x86_64-latest.args b/tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.x86_64-latest.args index 99b1d45176..5669c4c12a 100644 --- a/tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.x86_64-latest.args +++ b/tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.x86_64-latest.args @@ -29,8 +29,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-fedora/.config \ -rtc base=utc \ -no-shutdown \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -audiodev id=audio1,driver=none \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/os-firmware-efi-secboot.x86_64-latest.args b/tests/qemuxml2argvdata/os-firmware-efi-secboot.x86_64-latest.args index 256377ace0..b0dc79088a 100644 --- a/tests/qemuxml2argvdata/os-firmware-efi-secboot.x86_64-latest.args +++ b/tests/qemuxml2argvdata/os-firmware-efi-secboot.x86_64-latest.args @@ -34,7 +34,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-fedora/.config \ -boot menu=on,strict=on \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device ioh3420,port=0x8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ +-device ioh3420,port=8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ -device ich9-usb-ehci1,id=usb,bus=pcie.0,addr=0x1d.0x7 \ -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pcie.0,multifunction=on,addr=0x1d \ -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pcie.0,addr=0x1d.0x1 \ diff --git a/tests/qemuxml2argvdata/os-firmware-efi.x86_64-latest.args b/tests/qemuxml2argvdata/os-firmware-efi.x86_64-latest.args index d7807758d3..99dcc39d0f 100644 --- a/tests/qemuxml2argvdata/os-firmware-efi.x86_64-latest.args +++ b/tests/qemuxml2argvdata/os-firmware-efi.x86_64-latest.args @@ -33,7 +33,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-fedora/.config \ -boot menu=on,strict=on \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device ioh3420,port=0x8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ +-device ioh3420,port=8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ -device ich9-usb-ehci1,id=usb,bus=pcie.0,addr=0x1d.0x7 \ -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pcie.0,multifunction=on,addr=0x1d \ -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pcie.0,addr=0x1d.0x1 \ diff --git a/tests/qemuxml2argvdata/pcie-expander-bus.args b/tests/qemuxml2argvdata/pcie-expander-bus.args index 9cd3d93f3c..f040735d4c 100644 --- a/tests/qemuxml2argvdata/pcie-expander-bus.args +++ b/tests/qemuxml2argvdata/pcie-expander-bus.args @@ -28,40 +28,40 @@ QEMU_AUDIO_DRV=none \ -no-acpi \ -boot strict=on \ -device pxb-pcie,bus_nr=254,id=pci.1,numa_node=0,bus=pcie.0,addr=0x4 \ --device ioh3420,port=0x0,chassis=2,id=pci.2,bus=pci.1,addr=0x0 \ +-device ioh3420,port=0,chassis=2,id=pci.2,bus=pci.1,addr=0x0 \ -device x3130-upstream,id=pci.3,bus=pci.2,addr=0x0 \ --device xio3130-downstream,port=0x0,chassis=4,id=pci.4,bus=pci.3,addr=0x0 \ --device xio3130-downstream,port=0x1,chassis=5,id=pci.5,bus=pci.3,addr=0x1 \ --device xio3130-downstream,port=0x2,chassis=6,id=pci.6,bus=pci.3,addr=0x2 \ --device xio3130-downstream,port=0x3,chassis=7,id=pci.7,bus=pci.3,addr=0x3 \ --device xio3130-downstream,port=0x4,chassis=8,id=pci.8,bus=pci.3,addr=0x4 \ --device xio3130-downstream,port=0x5,chassis=9,id=pci.9,bus=pci.3,addr=0x5 \ --device xio3130-downstream,port=0x6,chassis=10,id=pci.10,bus=pci.3,addr=0x6 \ --device xio3130-downstream,port=0x7,chassis=11,id=pci.11,bus=pci.3,addr=0x7 \ --device xio3130-downstream,port=0x8,chassis=12,id=pci.12,bus=pci.3,addr=0x8 \ --device xio3130-downstream,port=0x9,chassis=13,id=pci.13,bus=pci.3,addr=0x9 \ --device xio3130-downstream,port=0xa,chassis=14,id=pci.14,bus=pci.3,addr=0xa \ --device xio3130-downstream,port=0xb,chassis=15,id=pci.15,bus=pci.3,addr=0xb \ --device xio3130-downstream,port=0xc,chassis=16,id=pci.16,bus=pci.3,addr=0xc \ --device xio3130-downstream,port=0xd,chassis=17,id=pci.17,bus=pci.3,addr=0xd \ --device xio3130-downstream,port=0xe,chassis=18,id=pci.18,bus=pci.3,addr=0xe \ --device xio3130-downstream,port=0xf,chassis=19,id=pci.19,bus=pci.3,addr=0xf \ --device xio3130-downstream,port=0x10,chassis=20,id=pci.20,bus=pci.3,addr=0x10 \ --device xio3130-downstream,port=0x11,chassis=21,id=pci.21,bus=pci.3,addr=0x11 \ --device xio3130-downstream,port=0x12,chassis=22,id=pci.22,bus=pci.3,addr=0x12 \ --device xio3130-downstream,port=0x13,chassis=23,id=pci.23,bus=pci.3,addr=0x13 \ --device xio3130-downstream,port=0x14,chassis=24,id=pci.24,bus=pci.3,addr=0x14 \ --device xio3130-downstream,port=0x15,chassis=25,id=pci.25,bus=pci.3,addr=0x15 \ --device xio3130-downstream,port=0x16,chassis=26,id=pci.26,bus=pci.3,addr=0x16 \ --device xio3130-downstream,port=0x17,chassis=27,id=pci.27,bus=pci.3,addr=0x17 \ --device xio3130-downstream,port=0x18,chassis=28,id=pci.28,bus=pci.3,addr=0x18 \ --device xio3130-downstream,port=0x19,chassis=29,id=pci.29,bus=pci.3,addr=0x19 \ --device xio3130-downstream,port=0x1a,chassis=30,id=pci.30,bus=pci.3,addr=0x1a \ --device xio3130-downstream,port=0x1b,chassis=31,id=pci.31,bus=pci.3,addr=0x1b \ --device xio3130-downstream,port=0x1c,chassis=32,id=pci.32,bus=pci.3,addr=0x1c \ --device xio3130-downstream,port=0x1d,chassis=33,id=pci.33,bus=pci.3,addr=0x1d \ --device xio3130-downstream,port=0x1e,chassis=34,id=pci.34,bus=pci.3,addr=0x1e \ --device xio3130-downstream,port=0x1f,chassis=35,id=pci.35,bus=pci.3,addr=0x1f \ +-device xio3130-downstream,port=0,chassis=4,id=pci.4,bus=pci.3,addr=0x0 \ +-device xio3130-downstream,port=1,chassis=5,id=pci.5,bus=pci.3,addr=0x1 \ +-device xio3130-downstream,port=2,chassis=6,id=pci.6,bus=pci.3,addr=0x2 \ +-device xio3130-downstream,port=3,chassis=7,id=pci.7,bus=pci.3,addr=0x3 \ +-device xio3130-downstream,port=4,chassis=8,id=pci.8,bus=pci.3,addr=0x4 \ +-device xio3130-downstream,port=5,chassis=9,id=pci.9,bus=pci.3,addr=0x5 \ +-device xio3130-downstream,port=6,chassis=10,id=pci.10,bus=pci.3,addr=0x6 \ +-device xio3130-downstream,port=7,chassis=11,id=pci.11,bus=pci.3,addr=0x7 \ +-device xio3130-downstream,port=8,chassis=12,id=pci.12,bus=pci.3,addr=0x8 \ +-device xio3130-downstream,port=9,chassis=13,id=pci.13,bus=pci.3,addr=0x9 \ +-device xio3130-downstream,port=10,chassis=14,id=pci.14,bus=pci.3,addr=0xa \ +-device xio3130-downstream,port=11,chassis=15,id=pci.15,bus=pci.3,addr=0xb \ +-device xio3130-downstream,port=12,chassis=16,id=pci.16,bus=pci.3,addr=0xc \ +-device xio3130-downstream,port=13,chassis=17,id=pci.17,bus=pci.3,addr=0xd \ +-device xio3130-downstream,port=14,chassis=18,id=pci.18,bus=pci.3,addr=0xe \ +-device xio3130-downstream,port=15,chassis=19,id=pci.19,bus=pci.3,addr=0xf \ +-device xio3130-downstream,port=16,chassis=20,id=pci.20,bus=pci.3,addr=0x10 \ +-device xio3130-downstream,port=17,chassis=21,id=pci.21,bus=pci.3,addr=0x11 \ +-device xio3130-downstream,port=18,chassis=22,id=pci.22,bus=pci.3,addr=0x12 \ +-device xio3130-downstream,port=19,chassis=23,id=pci.23,bus=pci.3,addr=0x13 \ +-device xio3130-downstream,port=20,chassis=24,id=pci.24,bus=pci.3,addr=0x14 \ +-device xio3130-downstream,port=21,chassis=25,id=pci.25,bus=pci.3,addr=0x15 \ +-device xio3130-downstream,port=22,chassis=26,id=pci.26,bus=pci.3,addr=0x16 \ +-device xio3130-downstream,port=23,chassis=27,id=pci.27,bus=pci.3,addr=0x17 \ +-device xio3130-downstream,port=24,chassis=28,id=pci.28,bus=pci.3,addr=0x18 \ +-device xio3130-downstream,port=25,chassis=29,id=pci.29,bus=pci.3,addr=0x19 \ +-device xio3130-downstream,port=26,chassis=30,id=pci.30,bus=pci.3,addr=0x1a \ +-device xio3130-downstream,port=27,chassis=31,id=pci.31,bus=pci.3,addr=0x1b \ +-device xio3130-downstream,port=28,chassis=32,id=pci.32,bus=pci.3,addr=0x1c \ +-device xio3130-downstream,port=29,chassis=33,id=pci.33,bus=pci.3,addr=0x1d \ +-device xio3130-downstream,port=30,chassis=34,id=pci.34,bus=pci.3,addr=0x1e \ +-device xio3130-downstream,port=31,chassis=35,id=pci.35,bus=pci.3,addr=0x1f \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-sata0-0-0 \ -device ide-hd,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0,bootindex=1 \ -netdev user,id=hostnet0 \ diff --git a/tests/qemuxml2argvdata/pcie-root-port-model-generic.args b/tests/qemuxml2argvdata/pcie-root-port-model-generic.args index dabdefdf20..8c26233c83 100644 --- a/tests/qemuxml2argvdata/pcie-root-port-model-generic.args +++ b/tests/qemuxml2argvdata/pcie-root-port-model-generic.args @@ -25,7 +25,7 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device ioh3420,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device ioh3420,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/pcie-root-port-model-ioh3420.args b/tests/qemuxml2argvdata/pcie-root-port-model-ioh3420.args index 7a47183bd1..a777ffd4ab 100644 --- a/tests/qemuxml2argvdata/pcie-root-port-model-ioh3420.args +++ b/tests/qemuxml2argvdata/pcie-root-port-model-ioh3420.args @@ -25,6 +25,6 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device ioh3420,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device ioh3420,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device ioh3420,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device ioh3420,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/pcie-root-port-nohotplug.x86_64-latest.args b/tests/qemuxml2argvdata/pcie-root-port-nohotplug.x86_64-latest.args index a611e882da..a43f6dda90 100644 --- a/tests/qemuxml2argvdata/pcie-root-port-nohotplug.x86_64-latest.args +++ b/tests/qemuxml2argvdata/pcie-root-port-nohotplug.x86_64-latest.args @@ -26,14 +26,14 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,hotplug=off,bus=pcie.0,addr=0x1.0x1 \ --device ioh3420,port=0xa,chassis=3,id=pci.3,hotplug=off,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,hotplug=off,bus=pcie.0,addr=0x1.0x1 \ +-device ioh3420,port=10,chassis=3,id=pci.3,hotplug=off,bus=pcie.0,addr=0x1.0x2 \ -device x3130-upstream,id=pci.4,bus=pci.1,addr=0x0 \ --device xio3130-downstream,port=0x0,chassis=5,id=pci.5,hotplug=off,bus=pci.4,addr=0x0 \ --device xio3130-downstream,port=0x1,chassis=6,id=pci.6,hotplug=on,bus=pci.4,addr=0x1 \ --device xio3130-downstream,port=0x2,chassis=7,id=pci.7,bus=pci.4,addr=0x2 \ --device xio3130-downstream,port=0x27,chassis=30,id=pci.8,bus=pci.4,addr=0x3 \ +-device xio3130-downstream,port=0,chassis=5,id=pci.5,hotplug=off,bus=pci.4,addr=0x0 \ +-device xio3130-downstream,port=1,chassis=6,id=pci.6,hotplug=on,bus=pci.4,addr=0x1 \ +-device xio3130-downstream,port=2,chassis=7,id=pci.7,bus=pci.4,addr=0x2 \ +-device xio3130-downstream,port=39,chassis=30,id=pci.8,bus=pci.4,addr=0x3 \ -device qemu-xhci,id=usb,bus=pci.2,addr=0x0 \ -audiodev id=audio1,driver=none \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/pcie-root-port.args b/tests/qemuxml2argvdata/pcie-root-port.args index 0785bc5bd7..961cd51c3a 100644 --- a/tests/qemuxml2argvdata/pcie-root-port.args +++ b/tests/qemuxml2argvdata/pcie-root-port.args @@ -25,8 +25,8 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device ioh3420,port=0x10,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2 \ --device ioh3420,port=0x1a,chassis=40,id=pci.2,bus=pcie.0,addr=0x2.0x1 \ +-device ioh3420,port=16,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2 \ +-device ioh3420,port=26,chassis=40,id=pci.2,bus=pcie.0,addr=0x2.0x1 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-sata0-0-0 \ -device ide-hd,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0,bootindex=1 \ -device qxl-vga,id=video0,ram_size=67108864,vram_size=33554432,bus=pcie.0,addr=0x1 \ diff --git a/tests/qemuxml2argvdata/pcie-switch-downstream-port.args b/tests/qemuxml2argvdata/pcie-switch-downstream-port.args index 9becddc068..3b12252568 100644 --- a/tests/qemuxml2argvdata/pcie-switch-downstream-port.args +++ b/tests/qemuxml2argvdata/pcie-switch-downstream-port.args @@ -25,16 +25,16 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device ioh3420,port=0x10,chassis=1,id=pci.1,bus=pcie.0,addr=0x2 \ +-device ioh3420,port=16,chassis=1,id=pci.1,bus=pcie.0,addr=0x2 \ -device x3130-upstream,id=pci.2,bus=pci.1,addr=0x0 \ --device xio3130-downstream,port=0x0,chassis=3,id=pci.3,bus=pci.2,addr=0x0 \ --device xio3130-downstream,port=0x1,chassis=4,id=pci.4,bus=pci.2,addr=0x1 \ --device xio3130-downstream,port=0x2,chassis=5,id=pci.5,bus=pci.2,addr=0x2 \ --device xio3130-downstream,port=0x27,chassis=30,id=pci.6,bus=pci.2,addr=0x3 \ +-device xio3130-downstream,port=0,chassis=3,id=pci.3,bus=pci.2,addr=0x0 \ +-device xio3130-downstream,port=1,chassis=4,id=pci.4,bus=pci.2,addr=0x1 \ +-device xio3130-downstream,port=2,chassis=5,id=pci.5,bus=pci.2,addr=0x2 \ +-device xio3130-downstream,port=39,chassis=30,id=pci.6,bus=pci.2,addr=0x3 \ -device x3130-upstream,id=pci.7,bus=pci.3,addr=0x0 \ --device xio3130-downstream,port=0x4,chassis=8,id=pci.8,bus=pci.2,addr=0x4 \ --device xio3130-downstream,port=0x5,chassis=9,id=pci.9,bus=pci.2,addr=0x5 \ --device xio3130-downstream,port=0x6,chassis=10,id=pci.10,bus=pci.2,addr=0x6 \ +-device xio3130-downstream,port=4,chassis=8,id=pci.8,bus=pci.2,addr=0x4 \ +-device xio3130-downstream,port=5,chassis=9,id=pci.9,bus=pci.2,addr=0x5 \ +-device xio3130-downstream,port=6,chassis=10,id=pci.10,bus=pci.2,addr=0x6 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-sata0-0-0 \ -device ide-hd,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0,bootindex=1 \ -device qxl-vga,id=video0,ram_size=67108864,vram_size=33554432,bus=pcie.0,addr=0x1 \ diff --git a/tests/qemuxml2argvdata/pcie-switch-upstream-port.args b/tests/qemuxml2argvdata/pcie-switch-upstream-port.args index 49b2e63773..067cfc81a8 100644 --- a/tests/qemuxml2argvdata/pcie-switch-upstream-port.args +++ b/tests/qemuxml2argvdata/pcie-switch-upstream-port.args @@ -25,8 +25,8 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device ioh3420,port=0x10,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2 \ --device ioh3420,port=0x11,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 \ +-device ioh3420,port=16,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2 \ +-device ioh3420,port=17,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 \ -device x3130-upstream,id=pci.3,bus=pci.1,addr=0x0 \ -device x3130-upstream,id=pci.4,bus=pci.2,addr=0x0 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-sata0-0-0 \ diff --git a/tests/qemuxml2argvdata/q35-default-devices-only.args b/tests/qemuxml2argvdata/q35-default-devices-only.args index 696f37cc4e..b1d0aae894 100644 --- a/tests/qemuxml2argvdata/q35-default-devices-only.args +++ b/tests/qemuxml2argvdata/q35-default-devices-only.args @@ -25,9 +25,9 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device ioh3420,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device ioh3420,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device ioh3420,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device ioh3420,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device ioh3420,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device ioh3420,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device nec-usb-xhci,id=usb,bus=pci.1,addr=0x0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/q35-multifunction.args b/tests/qemuxml2argvdata/q35-multifunction.args index c065de9455..072a66110d 100644 --- a/tests/qemuxml2argvdata/q35-multifunction.args +++ b/tests/qemuxml2argvdata/q35-multifunction.args @@ -25,24 +25,24 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device ioh3420,port=0x10,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2 \ --device ioh3420,port=0x11,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 \ --device ioh3420,port=0x12,chassis=3,id=pci.3,bus=pcie.0,addr=0x2.0x2 \ --device ioh3420,port=0x18,chassis=4,id=pci.4,bus=pcie.0,multifunction=on,addr=0x3 \ --device ioh3420,port=0x19,chassis=5,id=pci.5,bus=pcie.0,multifunction=on,addr=0x3.0x1 \ --device ioh3420,port=0x20,chassis=6,id=pci.6,bus=pcie.0,multifunction=off,addr=0x4 \ --device ioh3420,port=0x21,chassis=7,id=pci.7,bus=pcie.0,addr=0x4.0x1 \ --device ioh3420,port=0x8,chassis=8,id=pci.8,bus=pcie.0,multifunction=on,addr=0x1 \ --device ioh3420,port=0x9,chassis=9,id=pci.9,bus=pcie.0,addr=0x1.0x1 \ --device ioh3420,port=0xa,chassis=10,id=pci.10,bus=pcie.0,addr=0x1.0x2 \ --device ioh3420,port=0xb,chassis=11,id=pci.11,bus=pcie.0,addr=0x1.0x3 \ --device ioh3420,port=0xc,chassis=12,id=pci.12,bus=pcie.0,addr=0x1.0x4 \ --device ioh3420,port=0xd,chassis=13,id=pci.13,bus=pcie.0,addr=0x1.0x5 \ --device ioh3420,port=0xe,chassis=14,id=pci.14,bus=pcie.0,addr=0x1.0x6 \ --device ioh3420,port=0xf,chassis=15,id=pci.15,bus=pcie.0,addr=0x1.0x7 \ --device ioh3420,port=0x13,chassis=16,id=pci.16,bus=pcie.0,addr=0x2.0x3 \ --device ioh3420,port=0x14,chassis=17,id=pci.17,bus=pcie.0,addr=0x2.0x4 \ --device ioh3420,port=0x15,chassis=18,id=pci.18,bus=pcie.0,addr=0x2.0x5 \ +-device ioh3420,port=16,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2 \ +-device ioh3420,port=17,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 \ +-device ioh3420,port=18,chassis=3,id=pci.3,bus=pcie.0,addr=0x2.0x2 \ +-device ioh3420,port=24,chassis=4,id=pci.4,bus=pcie.0,multifunction=on,addr=0x3 \ +-device ioh3420,port=25,chassis=5,id=pci.5,bus=pcie.0,multifunction=on,addr=0x3.0x1 \ +-device ioh3420,port=32,chassis=6,id=pci.6,bus=pcie.0,multifunction=off,addr=0x4 \ +-device ioh3420,port=33,chassis=7,id=pci.7,bus=pcie.0,addr=0x4.0x1 \ +-device ioh3420,port=8,chassis=8,id=pci.8,bus=pcie.0,multifunction=on,addr=0x1 \ +-device ioh3420,port=9,chassis=9,id=pci.9,bus=pcie.0,addr=0x1.0x1 \ +-device ioh3420,port=10,chassis=10,id=pci.10,bus=pcie.0,addr=0x1.0x2 \ +-device ioh3420,port=11,chassis=11,id=pci.11,bus=pcie.0,addr=0x1.0x3 \ +-device ioh3420,port=12,chassis=12,id=pci.12,bus=pcie.0,addr=0x1.0x4 \ +-device ioh3420,port=13,chassis=13,id=pci.13,bus=pcie.0,addr=0x1.0x5 \ +-device ioh3420,port=14,chassis=14,id=pci.14,bus=pcie.0,addr=0x1.0x6 \ +-device ioh3420,port=15,chassis=15,id=pci.15,bus=pcie.0,addr=0x1.0x7 \ +-device ioh3420,port=19,chassis=16,id=pci.16,bus=pcie.0,addr=0x2.0x3 \ +-device ioh3420,port=20,chassis=17,id=pci.17,bus=pcie.0,addr=0x2.0x4 \ +-device ioh3420,port=21,chassis=18,id=pci.18,bus=pcie.0,addr=0x2.0x5 \ -device nec-usb-xhci,id=usb,bus=pci.1,addr=0x0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/q35-pci-force-address.args b/tests/qemuxml2argvdata/q35-pci-force-address.args index fc6f182c1f..f449c6158f 100644 --- a/tests/qemuxml2argvdata/q35-pci-force-address.args +++ b/tests/qemuxml2argvdata/q35-pci-force-address.args @@ -27,7 +27,7 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device ioh3420,port=0x8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ +-device ioh3420,port=8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ -netdev user,id=hostnet0 \ -device e1000e,netdev=hostnet0,id=net0,mac=52:54:00:aa:bf:ef,bus=pci.2,addr=0x1 \ -device intel-hda,id=sound0,bus=pci.3,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/q35-pcie-autoadd.args b/tests/qemuxml2argvdata/q35-pcie-autoadd.args index 1113eecc42..4398b66349 100644 --- a/tests/qemuxml2argvdata/q35-pcie-autoadd.args +++ b/tests/qemuxml2argvdata/q35-pcie-autoadd.args @@ -25,20 +25,20 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device ioh3420,port=0x10,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2 \ --device ioh3420,port=0x11,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 \ --device ioh3420,port=0x12,chassis=3,id=pci.3,bus=pcie.0,addr=0x2.0x2 \ --device ioh3420,port=0x13,chassis=4,id=pci.4,bus=pcie.0,addr=0x2.0x3 \ --device ioh3420,port=0x14,chassis=5,id=pci.5,bus=pcie.0,addr=0x2.0x4 \ --device ioh3420,port=0x15,chassis=6,id=pci.6,bus=pcie.0,addr=0x2.0x5 \ --device ioh3420,port=0x16,chassis=7,id=pci.7,bus=pcie.0,addr=0x2.0x6 \ --device ioh3420,port=0x17,chassis=8,id=pci.8,bus=pcie.0,addr=0x2.0x7 \ --device ioh3420,port=0x18,chassis=9,id=pci.9,bus=pcie.0,multifunction=on,addr=0x3 \ --device ioh3420,port=0x19,chassis=10,id=pci.10,bus=pcie.0,addr=0x3.0x1 \ --device ioh3420,port=0x1a,chassis=11,id=pci.11,bus=pcie.0,addr=0x3.0x2 \ --device ioh3420,port=0x1b,chassis=12,id=pci.12,bus=pcie.0,addr=0x3.0x3 \ --device ioh3420,port=0x1c,chassis=13,id=pci.13,bus=pcie.0,addr=0x3.0x4 \ --device ioh3420,port=0x1d,chassis=14,id=pci.14,bus=pcie.0,addr=0x3.0x5 \ +-device ioh3420,port=16,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2 \ +-device ioh3420,port=17,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 \ +-device ioh3420,port=18,chassis=3,id=pci.3,bus=pcie.0,addr=0x2.0x2 \ +-device ioh3420,port=19,chassis=4,id=pci.4,bus=pcie.0,addr=0x2.0x3 \ +-device ioh3420,port=20,chassis=5,id=pci.5,bus=pcie.0,addr=0x2.0x4 \ +-device ioh3420,port=21,chassis=6,id=pci.6,bus=pcie.0,addr=0x2.0x5 \ +-device ioh3420,port=22,chassis=7,id=pci.7,bus=pcie.0,addr=0x2.0x6 \ +-device ioh3420,port=23,chassis=8,id=pci.8,bus=pcie.0,addr=0x2.0x7 \ +-device ioh3420,port=24,chassis=9,id=pci.9,bus=pcie.0,multifunction=on,addr=0x3 \ +-device ioh3420,port=25,chassis=10,id=pci.10,bus=pcie.0,addr=0x3.0x1 \ +-device ioh3420,port=26,chassis=11,id=pci.11,bus=pcie.0,addr=0x3.0x2 \ +-device ioh3420,port=27,chassis=12,id=pci.12,bus=pcie.0,addr=0x3.0x3 \ +-device ioh3420,port=28,chassis=13,id=pci.13,bus=pcie.0,addr=0x3.0x4 \ +-device ioh3420,port=29,chassis=14,id=pci.14,bus=pcie.0,addr=0x3.0x5 \ -device nec-usb-xhci,id=usb,bus=pci.6,addr=0x0 \ -device virtio-scsi-pci,id=scsi0,bus=pci.5,addr=0x0 \ -device virtio-serial-pci,id=virtio-serial0,bus=pci.4,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/q35-pcie.args b/tests/qemuxml2argvdata/q35-pcie.args index 4c4a716417..c91f43060b 100644 --- a/tests/qemuxml2argvdata/q35-pcie.args +++ b/tests/qemuxml2argvdata/q35-pcie.args @@ -27,19 +27,19 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device ioh3420,port=0x10,chassis=3,id=pci.3,bus=pcie.0,multifunction=on,addr=0x2 \ --device ioh3420,port=0x11,chassis=4,id=pci.4,bus=pcie.0,addr=0x2.0x1 \ --device ioh3420,port=0x12,chassis=5,id=pci.5,bus=pcie.0,addr=0x2.0x2 \ --device ioh3420,port=0x13,chassis=6,id=pci.6,bus=pcie.0,addr=0x2.0x3 \ --device ioh3420,port=0x14,chassis=7,id=pci.7,bus=pcie.0,addr=0x2.0x4 \ --device ioh3420,port=0x15,chassis=8,id=pci.8,bus=pcie.0,addr=0x2.0x5 \ --device ioh3420,port=0x16,chassis=9,id=pci.9,bus=pcie.0,addr=0x2.0x6 \ --device ioh3420,port=0x17,chassis=10,id=pci.10,bus=pcie.0,addr=0x2.0x7 \ --device ioh3420,port=0x18,chassis=11,id=pci.11,bus=pcie.0,multifunction=on,addr=0x3 \ --device ioh3420,port=0x19,chassis=12,id=pci.12,bus=pcie.0,addr=0x3.0x1 \ --device ioh3420,port=0x1a,chassis=13,id=pci.13,bus=pcie.0,addr=0x3.0x2 \ --device ioh3420,port=0x1b,chassis=14,id=pci.14,bus=pcie.0,addr=0x3.0x3 \ --device ioh3420,port=0x1c,chassis=15,id=pci.15,bus=pcie.0,addr=0x3.0x4 \ +-device ioh3420,port=16,chassis=3,id=pci.3,bus=pcie.0,multifunction=on,addr=0x2 \ +-device ioh3420,port=17,chassis=4,id=pci.4,bus=pcie.0,addr=0x2.0x1 \ +-device ioh3420,port=18,chassis=5,id=pci.5,bus=pcie.0,addr=0x2.0x2 \ +-device ioh3420,port=19,chassis=6,id=pci.6,bus=pcie.0,addr=0x2.0x3 \ +-device ioh3420,port=20,chassis=7,id=pci.7,bus=pcie.0,addr=0x2.0x4 \ +-device ioh3420,port=21,chassis=8,id=pci.8,bus=pcie.0,addr=0x2.0x5 \ +-device ioh3420,port=22,chassis=9,id=pci.9,bus=pcie.0,addr=0x2.0x6 \ +-device ioh3420,port=23,chassis=10,id=pci.10,bus=pcie.0,addr=0x2.0x7 \ +-device ioh3420,port=24,chassis=11,id=pci.11,bus=pcie.0,multifunction=on,addr=0x3 \ +-device ioh3420,port=25,chassis=12,id=pci.12,bus=pcie.0,addr=0x3.0x1 \ +-device ioh3420,port=26,chassis=13,id=pci.13,bus=pcie.0,addr=0x3.0x2 \ +-device ioh3420,port=27,chassis=14,id=pci.14,bus=pcie.0,addr=0x3.0x3 \ +-device ioh3420,port=28,chassis=15,id=pci.15,bus=pcie.0,addr=0x3.0x4 \ -device nec-usb-xhci,id=usb,bus=pci.8,addr=0x0 \ -device virtio-scsi-pci,id=scsi0,bus=pci.7,addr=0x0 \ -device virtio-serial-pci,id=virtio-serial0,bus=pci.6,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/q35-pm-disable-fallback.args b/tests/qemuxml2argvdata/q35-pm-disable-fallback.args index 5b35c49a5c..c610cf624f 100644 --- a/tests/qemuxml2argvdata/q35-pm-disable-fallback.args +++ b/tests/qemuxml2argvdata/q35-pm-disable-fallback.args @@ -29,6 +29,6 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device ioh3420,port=0x8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ +-device ioh3420,port=8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x1 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/q35-pm-disable.args b/tests/qemuxml2argvdata/q35-pm-disable.args index 380988992c..8a6fc387ac 100644 --- a/tests/qemuxml2argvdata/q35-pm-disable.args +++ b/tests/qemuxml2argvdata/q35-pm-disable.args @@ -29,6 +29,6 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device ioh3420,port=0x8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ +-device ioh3420,port=8,chassis=3,id=pci.3,bus=pcie.0,addr=0x1 \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x1 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/q35-virt-manager-basic.args b/tests/qemuxml2argvdata/q35-virt-manager-basic.args index 19a134919c..3586752cee 100644 --- a/tests/qemuxml2argvdata/q35-virt-manager-basic.args +++ b/tests/qemuxml2argvdata/q35-virt-manager-basic.args @@ -26,12 +26,12 @@ QEMU_AUDIO_DRV=spice \ -global ICH9-LPC.disable_s3=1 \ -global ICH9-LPC.disable_s4=1 \ -boot strict=on \ --device ioh3420,port=0x10,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2 \ --device ioh3420,port=0x11,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 \ --device ioh3420,port=0x12,chassis=3,id=pci.3,bus=pcie.0,addr=0x2.0x2 \ --device ioh3420,port=0x13,chassis=4,id=pci.4,bus=pcie.0,addr=0x2.0x3 \ --device ioh3420,port=0x14,chassis=5,id=pci.5,bus=pcie.0,addr=0x2.0x4 \ --device ioh3420,port=0x15,chassis=6,id=pci.6,bus=pcie.0,addr=0x2.0x5 \ +-device ioh3420,port=16,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2 \ +-device ioh3420,port=17,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 \ +-device ioh3420,port=18,chassis=3,id=pci.3,bus=pcie.0,addr=0x2.0x2 \ +-device ioh3420,port=19,chassis=4,id=pci.4,bus=pcie.0,addr=0x2.0x3 \ +-device ioh3420,port=20,chassis=5,id=pci.5,bus=pcie.0,addr=0x2.0x4 \ +-device ioh3420,port=21,chassis=6,id=pci.6,bus=pcie.0,addr=0x2.0x5 \ -device nec-usb-xhci,id=usb,bus=pci.2,addr=0x0 \ -device virtio-serial-pci,id=virtio-serial0,bus=pci.3,addr=0x0 \ -drive file=/var/lib/libvirt/images/basic.qcow2,format=qcow2,if=none,id=drive-virtio-disk0 \ diff --git a/tests/qemuxml2argvdata/q35-virtio-pci.args b/tests/qemuxml2argvdata/q35-virtio-pci.args index 94da3660b5..7c6fd24dab 100644 --- a/tests/qemuxml2argvdata/q35-virtio-pci.args +++ b/tests/qemuxml2argvdata/q35-virtio-pci.args @@ -27,19 +27,19 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ --device ioh3420,port=0x10,chassis=3,id=pci.3,bus=pcie.0,multifunction=on,addr=0x2 \ --device ioh3420,port=0x11,chassis=4,id=pci.4,bus=pcie.0,addr=0x2.0x1 \ --device ioh3420,port=0x12,chassis=5,id=pci.5,bus=pcie.0,addr=0x2.0x2 \ --device ioh3420,port=0x13,chassis=6,id=pci.6,bus=pcie.0,addr=0x2.0x3 \ --device ioh3420,port=0x14,chassis=7,id=pci.7,bus=pcie.0,addr=0x2.0x4 \ --device ioh3420,port=0x15,chassis=8,id=pci.8,bus=pcie.0,addr=0x2.0x5 \ --device ioh3420,port=0x16,chassis=9,id=pci.9,bus=pcie.0,addr=0x2.0x6 \ --device ioh3420,port=0x17,chassis=10,id=pci.10,bus=pcie.0,addr=0x2.0x7 \ --device ioh3420,port=0x18,chassis=11,id=pci.11,bus=pcie.0,multifunction=on,addr=0x3 \ --device ioh3420,port=0x19,chassis=12,id=pci.12,bus=pcie.0,addr=0x3.0x1 \ --device ioh3420,port=0x1a,chassis=13,id=pci.13,bus=pcie.0,addr=0x3.0x2 \ --device ioh3420,port=0x1b,chassis=14,id=pci.14,bus=pcie.0,addr=0x3.0x3 \ --device ioh3420,port=0x1c,chassis=15,id=pci.15,bus=pcie.0,addr=0x3.0x4 \ +-device ioh3420,port=16,chassis=3,id=pci.3,bus=pcie.0,multifunction=on,addr=0x2 \ +-device ioh3420,port=17,chassis=4,id=pci.4,bus=pcie.0,addr=0x2.0x1 \ +-device ioh3420,port=18,chassis=5,id=pci.5,bus=pcie.0,addr=0x2.0x2 \ +-device ioh3420,port=19,chassis=6,id=pci.6,bus=pcie.0,addr=0x2.0x3 \ +-device ioh3420,port=20,chassis=7,id=pci.7,bus=pcie.0,addr=0x2.0x4 \ +-device ioh3420,port=21,chassis=8,id=pci.8,bus=pcie.0,addr=0x2.0x5 \ +-device ioh3420,port=22,chassis=9,id=pci.9,bus=pcie.0,addr=0x2.0x6 \ +-device ioh3420,port=23,chassis=10,id=pci.10,bus=pcie.0,addr=0x2.0x7 \ +-device ioh3420,port=24,chassis=11,id=pci.11,bus=pcie.0,multifunction=on,addr=0x3 \ +-device ioh3420,port=25,chassis=12,id=pci.12,bus=pcie.0,addr=0x3.0x1 \ +-device ioh3420,port=26,chassis=13,id=pci.13,bus=pcie.0,addr=0x3.0x2 \ +-device ioh3420,port=27,chassis=14,id=pci.14,bus=pcie.0,addr=0x3.0x3 \ +-device ioh3420,port=28,chassis=15,id=pci.15,bus=pcie.0,addr=0x3.0x4 \ -device nec-usb-xhci,id=usb,bus=pci.4,addr=0x0 \ -device virtio-scsi-pci,id=scsi0,bus=pci.2,addr=0x4 \ -device virtio-serial-pci,id=virtio-serial0,bus=pci.2,addr=0x3 \ diff --git a/tests/qemuxml2argvdata/riscv64-virt-graphics.riscv64-latest.args b/tests/qemuxml2argvdata/riscv64-virt-graphics.riscv64-latest.args index 90563fbfeb..7aeca86674 100644 --- a/tests/qemuxml2argvdata/riscv64-virt-graphics.riscv64-latest.args +++ b/tests/qemuxml2argvdata/riscv64-virt-graphics.riscv64-latest.args @@ -22,14 +22,14 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -rtc base=utc \ -no-shutdown \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ --device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ --device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ --device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ --device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ --device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=11,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ +-device pcie-root-port,port=12,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ +-device pcie-root-port,port=13,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ +-device pcie-root-port,port=14,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ +-device pcie-root-port,port=15,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ -device qemu-xhci,p2=15,p3=15,id=usb,bus=pci.2,addr=0x0 \ -device virtio-serial-pci,id=virtio-serial0,bus=pci.3,addr=0x0 \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/guest.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ diff --git a/tests/qemuxml2argvdata/riscv64-virt-headless.riscv64-latest.args b/tests/qemuxml2argvdata/riscv64-virt-headless.riscv64-latest.args index 4f50061eea..0e5609f158 100644 --- a/tests/qemuxml2argvdata/riscv64-virt-headless.riscv64-latest.args +++ b/tests/qemuxml2argvdata/riscv64-virt-headless.riscv64-latest.args @@ -23,13 +23,13 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -rtc base=utc \ -no-shutdown \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ --device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ --device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ --device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ --device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=11,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ +-device pcie-root-port,port=12,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ +-device pcie-root-port,port=13,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ +-device pcie-root-port,port=14,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ -device qemu-xhci,p2=15,p3=15,id=usb,bus=pci.2,addr=0x0 \ -device virtio-serial-pci,id=virtio-serial0,bus=pci.3,addr=0x0 \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/guest.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ diff --git a/tests/qemuxml2argvdata/tseg-explicit-size.x86_64-latest.args b/tests/qemuxml2argvdata/tseg-explicit-size.x86_64-latest.args index 7810ef49e8..ed72935350 100644 --- a/tests/qemuxml2argvdata/tseg-explicit-size.x86_64-latest.args +++ b/tests/qemuxml2argvdata/tseg-explicit-size.x86_64-latest.args @@ -27,9 +27,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0 \ diff --git a/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args b/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args index 4158456744..8743ef8d3f 100644 --- a/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args +++ b/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args @@ -26,10 +26,10 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -rtc base=utc \ -no-shutdown \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ --device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=11,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/guest.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage"}' \ -device virtio-blk-pci,bus=pci.4,addr=0x0,drive=libvirt-1-format,id=virtio-disk0,bootindex=1 \ diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 5d448c121f..a482d60423 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -25,17 +25,17 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ --device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ --device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ --device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ --device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ --device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ --device pcie-root-port,port=0x10,chassis=9,id=pci.9,bus=pcie.0,multifunction=on,addr=0x2 \ --device pcie-root-port,port=0x11,chassis=10,id=pci.10,bus=pcie.0,addr=0x2.0x1 \ --device pcie-root-port,port=0x12,chassis=11,id=pci.11,bus=pcie.0,addr=0x2.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=11,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ +-device pcie-root-port,port=12,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ +-device pcie-root-port,port=13,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ +-device pcie-root-port,port=14,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ +-device pcie-root-port,port=15,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ +-device pcie-root-port,port=16,chassis=9,id=pci.9,bus=pcie.0,multifunction=on,addr=0x2 \ +-device pcie-root-port,port=17,chassis=10,id=pci.10,bus=pcie.0,addr=0x2.0x1 \ +-device pcie-root-port,port=18,chassis=11,id=pci.11,bus=pcie.0,addr=0x2.0x2 \ -device virtio-scsi-pci,disable-legacy=on,disable-modern=off,id=scsi0,bus=pci.4,addr=0x0 \ -device virtio-serial-pci,disable-legacy=on,disable-modern=off,id=virtio-serial0,bus=pci.3,addr=0x0 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index 5385e30e40..305e2cbc2f 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -26,17 +26,17 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ --device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ --device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ --device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ --device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ --device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ --device pcie-root-port,port=0x10,chassis=9,id=pci.9,bus=pcie.0,multifunction=on,addr=0x2 \ --device pcie-root-port,port=0x11,chassis=10,id=pci.10,bus=pcie.0,addr=0x2.0x1 \ --device pcie-root-port,port=0x12,chassis=11,id=pci.11,bus=pcie.0,addr=0x2.0x2 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=11,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ +-device pcie-root-port,port=12,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ +-device pcie-root-port,port=13,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ +-device pcie-root-port,port=14,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ +-device pcie-root-port,port=15,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \ +-device pcie-root-port,port=16,chassis=9,id=pci.9,bus=pcie.0,multifunction=on,addr=0x2 \ +-device pcie-root-port,port=17,chassis=10,id=pci.10,bus=pcie.0,addr=0x2.0x1 \ +-device pcie-root-port,port=18,chassis=11,id=pci.11,bus=pcie.0,addr=0x2.0x2 \ -device virtio-scsi-pci-non-transitional,id=scsi0,bus=pci.4,addr=0x0 \ -device virtio-serial-pci-non-transitional,id=virtio-serial0,bus=pci.3,addr=0x0 \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index 386660fb1a..6699bfb104 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -25,9 +25,9 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ --device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ -device virtio-scsi-pci,disable-legacy=off,disable-modern=off,id=scsi0,bus=pci.2,addr=0x4 \ -device virtio-serial-pci,disable-legacy=off,disable-modern=off,id=virtio-serial0,bus=pci.2,addr=0x3 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index 2f6714a28e..8c2dbfebd8 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -26,9 +26,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -no-shutdown \ -no-acpi \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ -device pcie-pci-bridge,id=pci.2,bus=pci.1,addr=0x0 \ --device pcie-root-port,port=0x9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=9,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x1 \ -device virtio-scsi-pci-transitional,id=scsi0,bus=pci.2,addr=0x4 \ -device virtio-serial-pci-transitional,id=virtio-serial0,bus=pci.2,addr=0x3 \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ diff --git a/tests/qemuxml2argvdata/x86_64-default-cpu-kvm-q35-4.2.x86_64-latest.args b/tests/qemuxml2argvdata/x86_64-default-cpu-kvm-q35-4.2.x86_64-latest.args index e327dd919e..c1501e6c0a 100644 --- a/tests/qemuxml2argvdata/x86_64-default-cpu-kvm-q35-4.2.x86_64-latest.args +++ b/tests/qemuxml2argvdata/x86_64-default-cpu-kvm-q35-4.2.x86_64-latest.args @@ -25,10 +25,10 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -rtc base=utc \ -no-shutdown \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ --device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=11,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/guest.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage"}' \ diff --git a/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-q35-4.2.x86_64-latest.args b/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-q35-4.2.x86_64-latest.args index f0a5dbf2b9..d4f7980e5d 100644 --- a/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-q35-4.2.x86_64-latest.args +++ b/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-q35-4.2.x86_64-latest.args @@ -25,10 +25,10 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -rtc base=utc \ -no-shutdown \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ --device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=11,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/guest.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage"}' \ diff --git a/tests/qemuxml2argvdata/x86_64-q35-graphics.x86_64-latest.args b/tests/qemuxml2argvdata/x86_64-q35-graphics.x86_64-latest.args index fbae37342b..4ba4567e86 100644 --- a/tests/qemuxml2argvdata/x86_64-q35-graphics.x86_64-latest.args +++ b/tests/qemuxml2argvdata/x86_64-q35-graphics.x86_64-latest.args @@ -28,13 +28,13 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -global ICH9-LPC.disable_s3=1 \ -global ICH9-LPC.disable_s4=1 \ -boot strict=on \ --device pcie-root-port,port=0x10,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2 \ --device pcie-root-port,port=0x11,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 \ --device pcie-root-port,port=0x12,chassis=3,id=pci.3,bus=pcie.0,addr=0x2.0x2 \ --device pcie-root-port,port=0x13,chassis=4,id=pci.4,bus=pcie.0,addr=0x2.0x3 \ --device pcie-root-port,port=0x14,chassis=5,id=pci.5,bus=pcie.0,addr=0x2.0x4 \ --device pcie-root-port,port=0x15,chassis=6,id=pci.6,bus=pcie.0,addr=0x2.0x5 \ --device pcie-root-port,port=0x16,chassis=7,id=pci.7,bus=pcie.0,addr=0x2.0x6 \ +-device pcie-root-port,port=16,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2 \ +-device pcie-root-port,port=17,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 \ +-device pcie-root-port,port=18,chassis=3,id=pci.3,bus=pcie.0,addr=0x2.0x2 \ +-device pcie-root-port,port=19,chassis=4,id=pci.4,bus=pcie.0,addr=0x2.0x3 \ +-device pcie-root-port,port=20,chassis=5,id=pci.5,bus=pcie.0,addr=0x2.0x4 \ +-device pcie-root-port,port=21,chassis=6,id=pci.6,bus=pcie.0,addr=0x2.0x5 \ +-device pcie-root-port,port=22,chassis=7,id=pci.7,bus=pcie.0,addr=0x2.0x6 \ -device qemu-xhci,p2=15,p3=15,id=usb,bus=pci.2,addr=0x0 \ -device virtio-serial-pci,id=virtio-serial0,bus=pci.3,addr=0x0 \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/guest.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ diff --git a/tests/qemuxml2argvdata/x86_64-q35-headless.x86_64-latest.args b/tests/qemuxml2argvdata/x86_64-q35-headless.x86_64-latest.args index 5b5d980f41..26fe95eac3 100644 --- a/tests/qemuxml2argvdata/x86_64-q35-headless.x86_64-latest.args +++ b/tests/qemuxml2argvdata/x86_64-q35-headless.x86_64-latest.args @@ -29,13 +29,13 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -global ICH9-LPC.disable_s3=1 \ -global ICH9-LPC.disable_s4=1 \ -boot strict=on \ --device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ --device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ --device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ --device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ --device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ --device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ --device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ +-device pcie-root-port,port=8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \ +-device pcie-root-port,port=9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ +-device pcie-root-port,port=10,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ +-device pcie-root-port,port=11,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ +-device pcie-root-port,port=12,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ +-device pcie-root-port,port=13,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ +-device pcie-root-port,port=14,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ -device qemu-xhci,p2=15,p3=15,id=usb,bus=pci.2,addr=0x0 \ -device virtio-serial-pci,id=virtio-serial0,bus=pci.3,addr=0x0 \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/guest.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
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> --- src/qemu/qemu_command.c | 99 +++++++++++++------ ...fault-cpu-kvm-virt-4.2.aarch64-latest.args | 4 +- ...fault-cpu-tcg-virt-4.2.aarch64-latest.args | 4 +- .../qemuxml2argvdata/aarch64-pci-serial.args | 2 +-
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

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> --- src/qemu/qemu_command.c | 62 ++++++++++--------- ...sb-controller-explicit-unavailable-q35.err | 2 +- .../usb-controller-qemu-xhci-unavailable.err | 2 +- 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 68b6bf868e..f7a2304d5c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2771,6 +2771,38 @@ qemuControllerModelUSBToCaps(int model) } +static int +qemuValidateDomainDeviceDefControllerUSB(const virDomainControllerDef *def, + virQEMUCaps *qemuCaps) +{ + if (def->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("no model provided for USB controller")); + return -1; + } + + if (!virQEMUCapsGet(qemuCaps, qemuControllerModelUSBToCaps(def->model))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("USB controller model '%s' not supported in this QEMU binary"), + virDomainControllerModelUSBTypeToString(def->model)); + return -1; + } + + if (def->opts.usbopts.ports != -1) { + if ((def->model != VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI || + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI_PORTS)) && + def->model != VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("usb controller type '%s' doesn't support 'ports' with this QEMU binary"), + virDomainControllerModelUSBTypeToString(def->model)); + return -1; + } + } + + return 0; +} + + static const char * qemuBuildUSBControllerFindMasterAlias(const virDomainDef *domainDef, const virDomainControllerDef *def) @@ -2802,38 +2834,12 @@ qemuBuildUSBControllerDevStr(const virDomainDef *domainDef, virQEMUCaps *qemuCaps, virBuffer *buf) { - const char *smodel; - int model, flags; - - model = def->model; - - if (model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("no model provided for USB controller")); - return -1; - } - - smodel = qemuControllerModelUSBTypeToString(model); - flags = qemuControllerModelUSBToCaps(model); - - if (flags == -1 || !virQEMUCapsGet(qemuCaps, flags)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("%s not supported in this QEMU binary"), smodel); + if (qemuValidateDomainDeviceDefControllerUSB(def, qemuCaps) < 0) return -1; - } - virBufferAsprintf(buf, "%s", smodel); + virBufferAsprintf(buf, "%s", qemuControllerModelUSBTypeToString(def->model)); if (def->opts.usbopts.ports != -1) { - if ((model != VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI || - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI_PORTS)) && - model != VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("usb controller type %s doesn't support 'ports' " - "with this QEMU binary"), smodel); - return -1; - } - virBufferAsprintf(buf, ",p2=%d,p3=%d", def->opts.usbopts.ports, def->opts.usbopts.ports); } diff --git a/tests/qemuxml2argvdata/usb-controller-explicit-unavailable-q35.err b/tests/qemuxml2argvdata/usb-controller-explicit-unavailable-q35.err index 4940f896cc..6907a51505 100644 --- a/tests/qemuxml2argvdata/usb-controller-explicit-unavailable-q35.err +++ b/tests/qemuxml2argvdata/usb-controller-explicit-unavailable-q35.err @@ -1 +1 @@ -unsupported configuration: nec-usb-xhci not supported in this QEMU binary +unsupported configuration: USB controller model 'nec-xhci' not supported in this QEMU binary diff --git a/tests/qemuxml2argvdata/usb-controller-qemu-xhci-unavailable.err b/tests/qemuxml2argvdata/usb-controller-qemu-xhci-unavailable.err index 1b797dd343..aec91f7559 100644 --- a/tests/qemuxml2argvdata/usb-controller-qemu-xhci-unavailable.err +++ b/tests/qemuxml2argvdata/usb-controller-qemu-xhci-unavailable.err @@ -1 +1 @@ -unsupported configuration: qemu-xhci not supported in this QEMU binary +unsupported configuration: USB controller model 'qemu-xhci' not supported in this QEMU binary -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
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> --- src/qemu/qemu_command.c | 62 ++++++++++--------- ...sb-controller-explicit-unavailable-q35.err | 2 +- .../usb-controller-qemu-xhci-unavailable.err | 2 +- 3 files changed, 36 insertions(+), 30 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Internally format the PCI controller properties into JSON, but convert it back to a string as preparation for upcoming refactors. The following types are declared for the properties we use by QEMU: 'nec-usb-xhci' p2=<uint32> - (default: 4) p3=<uint32> - (default: 4) 'ich9-usb-uhci6' masterbus=<str> firstport=<uint32> - (default: 0) Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 61 +++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f7a2304d5c..2f1d4b846a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2828,37 +2828,48 @@ qemuBuildUSBControllerFindMasterAlias(const virDomainDef *domainDef, } -static int -qemuBuildUSBControllerDevStr(const virDomainDef *domainDef, - virDomainControllerDef *def, - virQEMUCaps *qemuCaps, - virBuffer *buf) +static virJSONValue * +qemuBuildUSBControllerDevProps(const virDomainDef *domainDef, + virDomainControllerDef *def, + virQEMUCaps *qemuCaps) { - if (qemuValidateDomainDeviceDefControllerUSB(def, qemuCaps) < 0) - return -1; + g_autoptr(virJSONValue) props = NULL; - virBufferAsprintf(buf, "%s", qemuControllerModelUSBTypeToString(def->model)); + if (qemuValidateDomainDeviceDefControllerUSB(def, qemuCaps) < 0) + return NULL; - if (def->opts.usbopts.ports != -1) { - virBufferAsprintf(buf, ",p2=%d,p3=%d", - def->opts.usbopts.ports, def->opts.usbopts.ports); - } + if (virJSONValueObjectCreate(&props, + "s:driver", qemuControllerModelUSBTypeToString(def->model), + "k:p2", def->opts.usbopts.ports, + "k:p3", def->opts.usbopts.ports, + NULL) < 0) + return NULL; if (def->info.mastertype == VIR_DOMAIN_CONTROLLER_MASTER_USB) { - const char *masterbus; + const char *alias; - if (!(masterbus = qemuBuildUSBControllerFindMasterAlias(domainDef, def))) { + if (!(alias = qemuBuildUSBControllerFindMasterAlias(domainDef, def))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("masterbus not found")); - return -1; + return NULL; } - virBufferAsprintf(buf, ",masterbus=%s.0,firstport=%d", - masterbus, def->info.master.usb.startport); + + if (virJSONValueObjectAdd(props, + "s:masterbus", g_strdup_printf("%s.0", alias), + "i:firstport", def->info.master.usb.startport, + NULL) < 0) + return NULL; } else { - virBufferAsprintf(buf, ",id=%s", def->info.alias); + if (virJSONValueObjectAdd(props, + "s:id", def->info.alias, + NULL) < 0) + return NULL; } - return 0; + if (qemuBuildDeviceAddressProps(props, domainDef, &def->info) < 0) + return NULL; + + return g_steal_pointer(&props); } @@ -3125,9 +3136,19 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, break; case VIR_DOMAIN_CONTROLLER_TYPE_USB: - if (qemuBuildUSBControllerDevStr(domainDef, def, qemuCaps, &buf) == -1) + if (!(props = qemuBuildUSBControllerDevProps(domainDef, def, qemuCaps))) return -1; + driver = virJSONValueObjectGetString(props, "driver"); + + virBufferAsprintf(&buf, "%s,", driver); + + if (virQEMUBuildCommandLineJSON(props, &buf, "driver", NULL) < 0) + return -1; + + *devstr = virBufferContentAndReset(&buf); + + return 0; break; case VIR_DOMAIN_CONTROLLER_TYPE_PCI: -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Internally format the PCI controller properties into JSON, but convert it back to a string as preparation for upcoming refactors.
The following types are declared for the properties we use by QEMU:
'nec-usb-xhci' p2=<uint32> - (default: 4) p3=<uint32> - (default: 4)
'ich9-usb-uhci6' masterbus=<str> firstport=<uint32> - (default: 0)
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 61 +++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 20 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The handlers for PCI, SCSI and USB controllers already use JSON internally. This patch converts 'virtio-serial', 'ccid' and 'sata' to do the same and passes out the JSON directly so that it can be used in monitor code to avoid conversion.
From the controllers converted in this patch only 'virtio-serial' has special properties. QEMU thinks they have the following types:
max_ports=<uint32> - (default: 31) vectors=<uint32> - (default: 2) Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 122 +++++++++++++++------------------------- src/qemu/qemu_command.h | 9 +-- src/qemu/qemu_hotplug.c | 8 +-- 3 files changed, 54 insertions(+), 85 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2f1d4b846a..81b1eb5980 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2866,16 +2866,12 @@ qemuBuildUSBControllerDevProps(const virDomainDef *domainDef, return NULL; } - if (qemuBuildDeviceAddressProps(props, domainDef, &def->info) < 0) - return NULL; - return g_steal_pointer(&props); } static virJSONValue * -qemuBuildControllerSCSIDevProps(const virDomainDef *domainDef, - virDomainControllerDef *def, +qemuBuildControllerSCSIDevProps(virDomainControllerDef *def, virQEMUCaps *qemuCaps) { g_autoptr(virJSONValue) props = NULL; @@ -2948,16 +2944,12 @@ qemuBuildControllerSCSIDevProps(const virDomainDef *domainDef, return NULL; } - if (qemuBuildDeviceAddressProps(props, domainDef, &def->info) < 0) - return NULL; - return g_steal_pointer(&props); } static int qemuBuildControllerPCIDevProps(virDomainControllerDef *def, - const virDomainDef *domainDef, virJSONValue **devprops) { g_autoptr(virJSONValue) props = NULL; @@ -3054,9 +3046,6 @@ qemuBuildControllerPCIDevProps(virDomainControllerDef *def, return -1; } - if (qemuBuildDeviceAddressProps(props, domainDef, &def->info) < 0) - return -1; - *devprops = g_steal_pointer(&props); return 0; } @@ -3068,8 +3057,7 @@ qemuBuildControllerPCIDevProps(virDomainControllerDef *def, * @domainDef: domain definition * @def: controller definition * @qemuCaps: QEMU binary capabilities - * @devstr: device string - * @nusbcontroller: number of USB controllers + * @devprops: filled with JSON object describing @def * * Turn @def into a description of the controller that QEMU will understand, * to be used either on the command line or through the monitor. @@ -3084,89 +3072,65 @@ qemuBuildControllerPCIDevProps(virDomainControllerDef *def, * Returns: 0 on success, <0 on failure */ int -qemuBuildControllerDevStr(const virDomainDef *domainDef, - virDomainControllerDef *def, - virQEMUCaps *qemuCaps, - char **devstr) +qemuBuildControllerDevProps(const virDomainDef *domainDef, + virDomainControllerDef *def, + virQEMUCaps *qemuCaps, + virJSONValue **devprops) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_autoptr(virJSONValue) props = NULL; - const char *driver = NULL; - *devstr = NULL; + *devprops = NULL; switch ((virDomainControllerType)def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: - if (!(props = qemuBuildControllerSCSIDevProps(domainDef, def, qemuCaps))) + if (!(props = qemuBuildControllerSCSIDevProps(def, qemuCaps))) return -1; - driver = virJSONValueObjectGetString(props, "driver"); - - virBufferAsprintf(&buf, "%s,", driver); + break; - if (virQEMUBuildCommandLineJSON(props, &buf, "driver", NULL) < 0) + case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: + if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_CONTROLLER, def, + qemuCaps))) return -1; - *devstr = virBufferContentAndReset(&buf); - - return 0; - - case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: - if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_CONTROLLER, def) < 0) { + if (virJSONValueObjectAdd(props, + "s:id", def->info.alias, + "k:max_ports", def->opts.vioserial.ports, + "k:vectors", def->opts.vioserial.vectors, + NULL) < 0) return -1; - } - virBufferAsprintf(&buf, ",id=%s", def->info.alias); - if (def->opts.vioserial.ports != -1) { - virBufferAsprintf(&buf, ",max_ports=%d", - def->opts.vioserial.ports); - } - if (def->opts.vioserial.vectors != -1) { - virBufferAsprintf(&buf, ",vectors=%d", - def->opts.vioserial.vectors); - } break; case VIR_DOMAIN_CONTROLLER_TYPE_CCID: - virBufferAsprintf(&buf, "usb-ccid,id=%s", def->info.alias); + if (virJSONValueObjectCreate(&props, + "s:driver", "usb-ccid", + "s:id", def->info.alias, + NULL) < 0) + return -1; + break; case VIR_DOMAIN_CONTROLLER_TYPE_SATA: - virBufferAsprintf(&buf, "ahci,id=%s", def->info.alias); + if (virJSONValueObjectCreate(&props, + "s:driver", "ahci", + "s:id", def->info.alias, + NULL) < 0) + return -1; + break; case VIR_DOMAIN_CONTROLLER_TYPE_USB: if (!(props = qemuBuildUSBControllerDevProps(domainDef, def, qemuCaps))) return -1; - driver = virJSONValueObjectGetString(props, "driver"); - - virBufferAsprintf(&buf, "%s,", driver); - - if (virQEMUBuildCommandLineJSON(props, &buf, "driver", NULL) < 0) - return -1; - - *devstr = virBufferContentAndReset(&buf); - - return 0; break; case VIR_DOMAIN_CONTROLLER_TYPE_PCI: - if (qemuBuildControllerPCIDevProps(def, domainDef, &props) < 0) + if (qemuBuildControllerPCIDevProps(def, &props) < 0) return -1; - if (!props) - return 0; - - driver = virJSONValueObjectGetString(props, "driver"); - - virBufferAsprintf(&buf, "%s,", driver); - - if (virQEMUBuildCommandLineJSON(props, &buf, "driver", NULL) < 0) - return -1; - - *devstr = virBufferContentAndReset(&buf); - return 0; + break; case VIR_DOMAIN_CONTROLLER_TYPE_IDE: case VIR_DOMAIN_CONTROLLER_TYPE_FDC: @@ -3179,10 +3143,13 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, return -1; } - if (qemuBuildDeviceAddressStr(&buf, domainDef, &def->info) < 0) + if (!props) + return 0; + + if (qemuBuildDeviceAddressProps(props, domainDef, &def->info) < 0) return -1; - *devstr = virBufferContentAndReset(&buf); + *devprops = g_steal_pointer(&props); return 0; } @@ -3313,7 +3280,7 @@ qemuBuildControllersByTypeCommandLine(virCommand *cmd, for (i = 0; i < def->ncontrollers; i++) { virDomainControllerDef *cont = def->controllers[i]; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) props = NULL; if (cont->type != type) continue; @@ -3349,16 +3316,17 @@ qemuBuildControllersByTypeCommandLine(virCommand *cmd, continue; } - if (qemuBuildControllerDevStr(def, cont, qemuCaps, &devstr) < 0) + if (qemuBuildControllerDevProps(def, cont, qemuCaps, &props) < 0) return -1; - if (devstr) { - if (qemuCommandAddExtDevice(cmd, &cont->info, qemuCaps) < 0) - return -1; + if (!props) + continue; - virCommandAddArg(cmd, "-device"); - virCommandAddArg(cmd, devstr); - } + if (qemuCommandAddExtDevice(cmd, &cont->info, qemuCaps) < 0) + return -1; + + if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0) + return -1; } return 0; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 29db16e729..cf57fc9a41 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -147,10 +147,11 @@ qemuBuildVHostUserFsDevStr(virDomainFSDef *fs, qemuDomainObjPrivate *priv); /* Current, best practice */ -int qemuBuildControllerDevStr(const virDomainDef *domainDef, - virDomainControllerDef *def, - virQEMUCaps *qemuCaps, - char **devstr); +int +qemuBuildControllerDevProps(const virDomainDef *domainDef, + virDomainControllerDef *def, + virQEMUCaps *qemuCaps, + virJSONValue **devprops); int qemuBuildMemoryBackendProps(virJSONValue **backendProps, const char *alias, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1c0056da16..f55cedc784 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -828,7 +828,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriver *driver, { int ret = -1; const char* type = virDomainControllerTypeToString(controller->type); - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; qemuDomainObjPrivate *priv = vm->privateData; virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_CONTROLLER, { .controller = controller } }; @@ -862,10 +862,10 @@ int qemuDomainAttachControllerDevice(virQEMUDriver *driver, if (qemuAssignDeviceControllerAlias(vm->def, controller) < 0) goto cleanup; - if (qemuBuildControllerDevStr(vm->def, controller, priv->qemuCaps, &devstr) < 0) + if (qemuBuildControllerDevProps(vm->def, controller, priv->qemuCaps, &devprops) < 0) goto cleanup; - if (!devstr) + if (!devprops) goto cleanup; VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers+1); @@ -877,7 +877,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriver *driver, goto exit_monitor; } - if ((ret = qemuMonitorAddDevice(priv->mon, devstr)) < 0) + if ((ret = qemuMonitorAddDeviceProps(priv->mon, &devprops)) < 0) ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &controller->info)); exit_monitor: -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The handlers for PCI, SCSI and USB controllers already use JSON internally. This patch converts 'virtio-serial', 'ccid' and 'sata' to do the same and passes out the JSON directly so that it can be used in monitor code to avoid conversion.
From the controllers converted in this patch only 'virtio-serial' has special properties. QEMU thinks they have the following types:
max_ports=<uint32> - (default: 31) vectors=<uint32> - (default: 2)
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 122 +++++++++++++++------------------------- src/qemu/qemu_command.h | 9 +-- src/qemu/qemu_hotplug.c | 8 +-- 3 files changed, 54 insertions(+), 85 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

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> --- src/qemu/qemu_command.c | 224 ++++++++++-------- src/qemu/qemu_command.h | 10 +- src/qemu/qemu_hotplug.c | 8 +- ...ault-cpu-kvm-pseries-2.7.ppc64-latest.args | 2 +- ...ault-cpu-kvm-pseries-3.1.ppc64-latest.args | 2 +- ...ault-cpu-kvm-pseries-4.2.ppc64-latest.args | 2 +- ...ault-cpu-tcg-pseries-2.7.ppc64-latest.args | 2 +- ...ault-cpu-tcg-pseries-3.1.ppc64-latest.args | 2 +- ...ault-cpu-tcg-pseries-4.2.ppc64-latest.args | 2 +- .../ppc64-pseries-graphics.ppc64-latest.args | 2 +- .../ppc64-pseries-headless.ppc64-latest.args | 2 +- tests/qemuxml2argvdata/pseries-basic.args | 2 +- .../pseries-cpu-compat-power9.args | 2 +- .../qemuxml2argvdata/pseries-cpu-compat.args | 2 +- tests/qemuxml2argvdata/pseries-cpu-exact.args | 2 +- tests/qemuxml2argvdata/pseries-cpu-le.args | 2 +- .../pseries-panic-missing.args | 2 +- .../pseries-panic-no-address.args | 2 +- .../pseries-serial-native.args | 2 +- .../qemuxml2argvdata/pseries-usb-default.args | 2 +- tests/qemuxml2argvdata/pseries-usb-kbd.args | 2 +- tests/qemuxml2argvdata/pseries-usb-multi.args | 2 +- .../pseries-vio-user-assigned.args | 4 +- tests/qemuxml2argvdata/pseries-vio.args | 4 +- .../qemuxml2argvdata/s390-panic-missing.args | 2 +- .../serial-dev-chardev-iobase.args | 2 +- .../tpm-emulator-spapr.ppc64-latest.args | 4 +- 27 files changed, 163 insertions(+), 133 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 81b1eb5980..954513ce83 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -745,8 +745,27 @@ qemuBuildDeviceAddressProps(virJSONValue *props, case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: return qemuBuildDeviceAddresDriveProps(props, domainDef, info); + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL: { + const char *contAlias; + g_autofree char *bus = NULL; + + if (!(contAlias = virDomainControllerAliasFind(domainDef, + VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL, + info->addr.vioserial.controller))) + return -1; + + bus = g_strdup_printf("%s.%d", contAlias, info->addr.vioserial.bus); + + if (virJSONValueObjectAdd(props, + "s:bus", bus, + "i:nr", info->addr.vioserial.port, + NULL) < 0) + return -1; + + return 0; + } + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: @@ -5658,19 +5677,21 @@ qemuBuildMonitorCommandLine(virLogManager *logManager, } -static char * -qemuBuildVirtioSerialPortDevStr(const virDomainDef *def, - virDomainChrDef *dev) +static virJSONValue * +qemuBuildVirtioSerialPortDevProps(const virDomainDef *def, + virDomainChrDef *dev) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - const char *contAlias; + g_autoptr(virJSONValue) props = NULL; + const char *driver; + const char *targetname = NULL; + g_autofree char *chardev = NULL; switch (dev->deviceType) { case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: - virBufferAddLit(&buf, "virtconsole"); + driver = "virtconsole"; break; case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: - virBufferAddLit(&buf, "virtserialport"); + driver = "virtserialport"; break; default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -5687,14 +5708,6 @@ qemuBuildVirtioSerialPortDevStr(const virDomainDef *def, return NULL; } - contAlias = virDomainControllerAliasFind(def, VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL, - dev->info.addr.vioserial.controller); - if (!contAlias) - return NULL; - - virBufferAsprintf(&buf, ",bus=%s.%d,nr=%d", contAlias, - dev->info.addr.vioserial.bus, - dev->info.addr.vioserial.port); } if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && @@ -5707,29 +5720,50 @@ qemuBuildVirtioSerialPortDevStr(const virDomainDef *def, return NULL; } - virBufferAsprintf(&buf, ",chardev=char%s,id=%s", - dev->info.alias, dev->info.alias); + if (virJSONValueObjectCreate(&props, + "s:driver", driver, + NULL) < 0) + return NULL; + + if (qemuBuildDeviceAddressProps(props, def, &dev->info) < 0) + return NULL; + + chardev = g_strdup_printf("char%s", dev->info.alias); + if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && (dev->source->type == VIR_DOMAIN_CHR_TYPE_SPICEVMC || dev->target.name)) { - virBufferAsprintf(&buf, ",name=%s", dev->target.name - ? dev->target.name : "com.redhat.spice.0"); + if (dev->target.name) + targetname = dev->target.name; + else + targetname = "com.redhat.spice.0"; } - return virBufferContentAndReset(&buf); + if (virJSONValueObjectAdd(props, + "s:chardev", chardev, + "s:id", dev->info.alias, + "S:name", targetname, + NULL) < 0) + return NULL; + + return g_steal_pointer(&props); } -static char * -qemuBuildSclpDevStr(virDomainChrDef *dev) + +static virJSONValue * +qemuBuildSclpDevProps(virDomainChrDef *dev) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; + g_autofree char *chardev = g_strdup_printf("char%s", dev->info.alias); + const char *driver = NULL; + if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE) { switch (dev->targetType) { case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP: - virBufferAddLit(&buf, "sclpconsole"); + driver = "sclpconsole"; break; case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM: - virBufferAddLit(&buf, "sclplmconsole"); + driver = "sclplmconsole"; break; } } else { @@ -5737,10 +5771,15 @@ qemuBuildSclpDevStr(virDomainChrDef *dev) _("Cannot use slcp with devices other than console")); return NULL; } - virBufferAsprintf(&buf, ",chardev=char%s,id=%s", - dev->info.alias, dev->info.alias); - return virBufferContentAndReset(&buf); + if (virJSONValueObjectCreate(&props, + "s:driver", driver, + "s:chardev", chardev, + "s:id", dev->info.alias, + NULL) < 0) + return NULL; + + return g_steal_pointer(&props); } @@ -9460,12 +9499,14 @@ qemuBuildChrDeviceCommandLine(virCommand *cmd, virDomainChrDef *chr, virQEMUCaps *qemuCaps) { - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) props = NULL; - if (qemuBuildChrDeviceStr(&devstr, def, chr, qemuCaps) < 0) + if (!(props = qemuBuildChrDeviceProps(def, chr, qemuCaps))) + return -1; + + if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0) return -1; - virCommandAddArgList(cmd, "-device", devstr, NULL); return 0; } @@ -10914,16 +10955,13 @@ qemuBuildCommandLine(virQEMUDriver *driver, } -/* This function generates the correct '-device' string for character - * devices of each architecture. - */ -static int -qemuBuildSerialChrDeviceStr(char **deviceStr, - const virDomainDef *def, - virDomainChrDef *serial, - virQEMUCaps *qemuCaps) +static virJSONValue * +qemuBuildSerialChrDeviceProps(const virDomainDef *def, + virDomainChrDef *serial, + virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; + g_autofree char *chardev = g_strdup_printf("char%s", serial->info.alias); virQEMUCapsFlags caps; switch ((virDomainChrSerialTargetModel) serial->targetModel) { @@ -10940,7 +10978,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("'%s' is not supported in this QEMU binary"), virDomainChrSerialTargetModelTypeToString(serial->targetModel)); - return -1; + return NULL; } break; @@ -10954,27 +10992,37 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, * branch and we will not have ended up here. */ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid target model for serial device")); - return -1; + return NULL; } - virBufferAsprintf(&buf, "%s,chardev=char%s,id=%s", - virDomainChrSerialTargetModelTypeToString(serial->targetModel), - serial->info.alias, serial->info.alias); + if (virJSONValueObjectCreate(&props, + "s:driver", virDomainChrSerialTargetModelTypeToString(serial->targetModel), + "s:chardev", chardev, + "s:id", serial->info.alias, + NULL) < 0) + return NULL; - if (qemuBuildDeviceAddressStr(&buf, def, &serial->info) < 0) - return -1; + if (qemuBuildDeviceAddressProps(props, def, &serial->info) < 0) + return NULL; - *deviceStr = virBufferContentAndReset(&buf); - return 0; + return g_steal_pointer(&props); } -static int -qemuBuildParallelChrDeviceStr(char **deviceStr, - virDomainChrDef *chr) + +static virJSONValue * +qemuBuildParallelChrDeviceProps(virDomainChrDef *chr) { - *deviceStr = g_strdup_printf("isa-parallel,chardev=char%s,id=%s", - chr->info.alias, chr->info.alias); - return 0; + g_autoptr(virJSONValue) props = NULL; + g_autofree char *chardev = g_strdup_printf("char%s", chr->info.alias); + + if (virJSONValueObjectCreate(&props, + "s:driver", "isa-parallel", + "s:chardev", chardev, + "s:id", chr->info.alias, + NULL) < 0) + return NULL; + + return g_steal_pointer(&props); } @@ -11013,48 +11061,38 @@ qemuBuildChannelGuestfwdNetdevProps(virDomainChrDef *chr) } -static int -qemuBuildChannelChrDeviceStr(char **deviceStr, - const virDomainDef *def, - virDomainChrDef *chr) +static virJSONValue * +qemuBuildChannelChrDeviceProps(const virDomainDef *def, + virDomainChrDef *chr) { switch ((virDomainChrChannelTargetType)chr->targetType) { case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: - if (!(*deviceStr = qemuBuildVirtioSerialPortDevStr(def, chr))) - return -1; - break; + return qemuBuildVirtioSerialPortDevProps(def, chr); case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: /* guestfwd is as a netdev handled separately */ case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN: case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_NONE: case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST: - return -1; + break; } - return 0; + return NULL; } -static int -qemuBuildConsoleChrDeviceStr(char **deviceStr, - const virDomainDef *def, - virDomainChrDef *chr) +static virJSONValue * +qemuBuildConsoleChrDeviceProps(const virDomainDef *def, + virDomainChrDef *chr) { switch ((virDomainChrConsoleTargetType)chr->targetType) { case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP: case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM: - if (!(*deviceStr = qemuBuildSclpDevStr(chr))) - return -1; - break; + return qemuBuildSclpDevProps(chr); case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO: - if (!(*deviceStr = qemuBuildVirtioSerialPortDevStr(def, chr))) - return -1; - break; + return qemuBuildVirtioSerialPortDevProps(def, chr); case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL: - break; - case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE: case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN: case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML: @@ -11064,42 +11102,36 @@ qemuBuildConsoleChrDeviceStr(char **deviceStr, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported console target type %s"), NULLSTR(virDomainChrConsoleTargetTypeToString(chr->targetType))); - return -1; + break; } - return 0; + return NULL; } -int -qemuBuildChrDeviceStr(char **deviceStr, - const virDomainDef *vmdef, - virDomainChrDef *chr, - virQEMUCaps *qemuCaps) -{ - int ret = -1; +virJSONValue * +qemuBuildChrDeviceProps(const virDomainDef *vmdef, + virDomainChrDef *chr, + virQEMUCaps *qemuCaps) +{ switch ((virDomainChrDeviceType)chr->deviceType) { case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: - ret = qemuBuildSerialChrDeviceStr(deviceStr, vmdef, chr, qemuCaps); - break; + return qemuBuildSerialChrDeviceProps(vmdef, chr, qemuCaps); case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: - ret = qemuBuildParallelChrDeviceStr(deviceStr, chr); - break; + return qemuBuildParallelChrDeviceProps(chr); case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: - ret = qemuBuildChannelChrDeviceStr(deviceStr, vmdef, chr); - break; + return qemuBuildChannelChrDeviceProps(vmdef, chr); case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: - ret = qemuBuildConsoleChrDeviceStr(deviceStr, vmdef, chr); - break; + return qemuBuildConsoleChrDeviceProps(vmdef, chr); case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST: - return ret; + break; } - return ret; + return NULL; } diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index cf57fc9a41..65e896b634 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -79,12 +79,10 @@ int qemuBuildTLSx509BackendProps(const char *tlspath, int qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev) G_GNUC_NO_INLINE; -/* Generate '-device' string for chardev device */ -int -qemuBuildChrDeviceStr(char **deviceStr, - const virDomainDef *vmdef, - virDomainChrDef *chr, - virQEMUCaps *qemuCaps); +virJSONValue * +qemuBuildChrDeviceProps(const virDomainDef *vmdef, + virDomainChrDef *chr, + virQEMUCaps *qemuCaps); virJSONValue * qemuBuildChannelGuestfwdNetdevProps(virDomainChrDef *chr); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f55cedc784..c7da38b49b 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2181,7 +2181,7 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver, qemuDomainObjPrivate *priv = vm->privateData; virErrorPtr orig_err; virDomainDef *vmdef = vm->def; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; g_autoptr(virJSONValue) netdevprops = NULL; virDomainChrSourceDef *dev = chr->source; g_autofree char *charAlias = NULL; @@ -2224,7 +2224,7 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver, if (!(netdevprops = qemuBuildChannelGuestfwdNetdevProps(chr))) goto cleanup; } else { - if (qemuBuildChrDeviceStr(&devstr, vmdef, chr, priv->qemuCaps) < 0) + if (!(devprops = qemuBuildChrDeviceProps(vmdef, chr, priv->qemuCaps))) goto cleanup; } @@ -2251,8 +2251,8 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver, goto exit_monitor; } - if (devstr) { - if (qemuMonitorAddDevice(priv->mon, devstr) < 0) + if (devprops) { + if (qemuMonitorAddDeviceProps(priv->mon, &devprops) < 0) goto exit_monitor; } diff --git a/tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-2.7.ppc64-latest.args b/tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-2.7.ppc64-latest.args index dde5d44d45..8a6f0a94fb 100644 --- a/tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-2.7.ppc64-latest.args +++ b/tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-2.7.ppc64-latest.args @@ -30,7 +30,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage"}' \ -device virtio-blk-pci,bus=pci.0,addr=0x2,drive=libvirt-1-format,id=virtio-disk0,bootindex=1 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-3.1.ppc64-latest.args b/tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-3.1.ppc64-latest.args index a4aaea7571..2362c5a057 100644 --- a/tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-3.1.ppc64-latest.args +++ b/tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-3.1.ppc64-latest.args @@ -30,7 +30,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage"}' \ -device virtio-blk-pci,bus=pci.0,addr=0x2,drive=libvirt-1-format,id=virtio-disk0,bootindex=1 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-4.2.ppc64-latest.args b/tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-4.2.ppc64-latest.args index a8b22d3e48..ed62c92c12 100644 --- a/tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-4.2.ppc64-latest.args +++ b/tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-4.2.ppc64-latest.args @@ -30,7 +30,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage"}' \ -device virtio-blk-pci,bus=pci.0,addr=0x2,drive=libvirt-1-format,id=virtio-disk0,bootindex=1 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-2.7.ppc64-latest.args b/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-2.7.ppc64-latest.args index 576f97261b..5b9d07c46e 100644 --- a/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-2.7.ppc64-latest.args +++ b/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-2.7.ppc64-latest.args @@ -30,7 +30,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage"}' \ -device virtio-blk-pci,bus=pci.0,addr=0x2,drive=libvirt-1-format,id=virtio-disk0,bootindex=1 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-3.1.ppc64-latest.args b/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-3.1.ppc64-latest.args index e3ca4a8465..7324e69410 100644 --- a/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-3.1.ppc64-latest.args +++ b/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-3.1.ppc64-latest.args @@ -30,7 +30,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage"}' \ -device virtio-blk-pci,bus=pci.0,addr=0x2,drive=libvirt-1-format,id=virtio-disk0,bootindex=1 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-4.2.ppc64-latest.args b/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-4.2.ppc64-latest.args index 1762e8f5f5..6591810bf8 100644 --- a/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-4.2.ppc64-latest.args +++ b/tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-4.2.ppc64-latest.args @@ -30,7 +30,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage"}' \ -device virtio-blk-pci,bus=pci.0,addr=0x2,drive=libvirt-1-format,id=virtio-disk0,bootindex=1 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/ppc64-pseries-graphics.ppc64-latest.args b/tests/qemuxml2argvdata/ppc64-pseries-graphics.ppc64-latest.args index 2d3be80be3..61a9c458d4 100644 --- a/tests/qemuxml2argvdata/ppc64-pseries-graphics.ppc64-latest.args +++ b/tests/qemuxml2argvdata/ppc64-pseries-graphics.ppc64-latest.args @@ -32,7 +32,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -netdev user,id=hostnet0 \ -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:a2:44:92,bus=pci.0,addr=0x1 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -chardev socket,id=charchannel0,fd=1729,server=on,wait=off \ -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0 \ -device usb-tablet,id=input0,bus=usb.0,port=1 \ diff --git a/tests/qemuxml2argvdata/ppc64-pseries-headless.ppc64-latest.args b/tests/qemuxml2argvdata/ppc64-pseries-headless.ppc64-latest.args index e46978c0d2..819ad483a4 100644 --- a/tests/qemuxml2argvdata/ppc64-pseries-headless.ppc64-latest.args +++ b/tests/qemuxml2argvdata/ppc64-pseries-headless.ppc64-latest.args @@ -33,7 +33,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ -netdev user,id=hostnet0 \ -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:09:a4:37,bus=pci.0,addr=0x1 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -chardev socket,id=charchannel0,fd=1729,server=on,wait=off \ -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0 \ -audiodev id=audio1,driver=none \ diff --git a/tests/qemuxml2argvdata/pseries-basic.args b/tests/qemuxml2argvdata/pseries-basic.args index 241850399f..ebb289fe31 100644 --- a/tests/qemuxml2argvdata/pseries-basic.args +++ b/tests/qemuxml2argvdata/pseries-basic.args @@ -26,5 +26,5 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -usb \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/pseries-cpu-compat-power9.args b/tests/qemuxml2argvdata/pseries-cpu-compat-power9.args index 29dd9bc29e..abc3421565 100644 --- a/tests/qemuxml2argvdata/pseries-cpu-compat-power9.args +++ b/tests/qemuxml2argvdata/pseries-cpu-compat-power9.args @@ -27,5 +27,5 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -usb \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/pseries-cpu-compat.args b/tests/qemuxml2argvdata/pseries-cpu-compat.args index c54088c505..18dbc62dc5 100644 --- a/tests/qemuxml2argvdata/pseries-cpu-compat.args +++ b/tests/qemuxml2argvdata/pseries-cpu-compat.args @@ -27,5 +27,5 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -usb \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/pseries-cpu-exact.args b/tests/qemuxml2argvdata/pseries-cpu-exact.args index 1d11f5fa93..7ee7ee4b34 100644 --- a/tests/qemuxml2argvdata/pseries-cpu-exact.args +++ b/tests/qemuxml2argvdata/pseries-cpu-exact.args @@ -27,5 +27,5 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -usb \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/pseries-cpu-le.args b/tests/qemuxml2argvdata/pseries-cpu-le.args index 1247f3af8e..1325a0edd2 100644 --- a/tests/qemuxml2argvdata/pseries-cpu-le.args +++ b/tests/qemuxml2argvdata/pseries-cpu-le.args @@ -26,5 +26,5 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -usb \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/pseries-panic-missing.args b/tests/qemuxml2argvdata/pseries-panic-missing.args index 241850399f..ebb289fe31 100644 --- a/tests/qemuxml2argvdata/pseries-panic-missing.args +++ b/tests/qemuxml2argvdata/pseries-panic-missing.args @@ -26,5 +26,5 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -usb \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/pseries-panic-no-address.args b/tests/qemuxml2argvdata/pseries-panic-no-address.args index 241850399f..ebb289fe31 100644 --- a/tests/qemuxml2argvdata/pseries-panic-no-address.args +++ b/tests/qemuxml2argvdata/pseries-panic-no-address.args @@ -26,5 +26,5 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -usb \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/pseries-serial-native.args b/tests/qemuxml2argvdata/pseries-serial-native.args index 9c2e3c156a..1c89689f9f 100644 --- a/tests/qemuxml2argvdata/pseries-serial-native.args +++ b/tests/qemuxml2argvdata/pseries-serial-native.args @@ -25,5 +25,5 @@ QEMU_AUDIO_DRV=none \ -no-shutdown \ -boot strict=on \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/pseries-usb-default.args b/tests/qemuxml2argvdata/pseries-usb-default.args index b3b57320c5..dadab3fe10 100644 --- a/tests/qemuxml2argvdata/pseries-usb-default.args +++ b/tests/qemuxml2argvdata/pseries-usb-default.args @@ -26,5 +26,5 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -device pci-ohci,id=usb,bus=pci.0,addr=0x1 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/pseries-usb-kbd.args b/tests/qemuxml2argvdata/pseries-usb-kbd.args index 7e0623eef8..a650420cff 100644 --- a/tests/qemuxml2argvdata/pseries-usb-kbd.args +++ b/tests/qemuxml2argvdata/pseries-usb-kbd.args @@ -26,6 +26,6 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -device pci-ohci,id=usb,bus=pci.0,addr=0x1 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -device usb-kbd,id=input0,bus=usb.0,port=1 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/pseries-usb-multi.args b/tests/qemuxml2argvdata/pseries-usb-multi.args index 2d4ef84838..34651b8ec4 100644 --- a/tests/qemuxml2argvdata/pseries-usb-multi.args +++ b/tests/qemuxml2argvdata/pseries-usb-multi.args @@ -27,5 +27,5 @@ QEMU_AUDIO_DRV=none \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1 \ -device pci-ohci,id=usb1,bus=pci.0,addr=0x2 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/pseries-vio-user-assigned.args b/tests/qemuxml2argvdata/pseries-vio-user-assigned.args index dfc3ad0d1b..80ded18692 100644 --- a/tests/qemuxml2argvdata/pseries-vio-user-assigned.args +++ b/tests/qemuxml2argvdata/pseries-vio-user-assigned.args @@ -30,7 +30,7 @@ QEMU_AUDIO_DRV=none \ -drive file=/tmp/scsidisk.img,format=raw,if=none,id=drive-scsi1-0-0-0 \ -device scsi-hd,bus=scsi1.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi1-0-0-0,id=scsi1-0-0-0,bootindex=1 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x20000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=536870912 \ -chardev pty,id=charserial1 \ --device spapr-vty,chardev=charserial1,id=serial1,reg=0x30001000 \ +-device spapr-vty,chardev=charserial1,id=serial1,reg=805310464 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/pseries-vio.args b/tests/qemuxml2argvdata/pseries-vio.args index a8e18fae5a..e266d4c01b 100644 --- a/tests/qemuxml2argvdata/pseries-vio.args +++ b/tests/qemuxml2argvdata/pseries-vio.args @@ -30,7 +30,7 @@ QEMU_AUDIO_DRV=none \ -drive file=/tmp/scsidisk.img,format=raw,if=none,id=drive-scsi1-0-0-0 \ -device scsi-hd,bus=scsi1.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi1-0-0-0,id=scsi1-0-0-0,bootindex=1 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -chardev pty,id=charserial1 \ --device spapr-vty,chardev=charserial1,id=serial1,reg=0x30001000 \ +-device spapr-vty,chardev=charserial1,id=serial1,reg=805310464 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/s390-panic-missing.args b/tests/qemuxml2argvdata/s390-panic-missing.args index be0873ced9..a1c1731f0c 100644 --- a/tests/qemuxml2argvdata/s390-panic-missing.args +++ b/tests/qemuxml2argvdata/s390-panic-missing.args @@ -26,6 +26,6 @@ QEMU_AUDIO_DRV=none \ -boot strict=on \ -device virtio-serial-ccw,id=virtio-serial0,devno=fe.0.0000 \ -chardev pty,id=charconsole0 \ --device virtconsole,chardev=charconsole0,id=console0 \ +-device virtconsole,devno=fe.0.0001,chardev=charconsole0,id=console0 \ -device virtio-balloon-ccw,id=balloon0,devno=fe.0.0002 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/serial-dev-chardev-iobase.args b/tests/qemuxml2argvdata/serial-dev-chardev-iobase.args index ecaa342a26..27de77305e 100644 --- a/tests/qemuxml2argvdata/serial-dev-chardev-iobase.args +++ b/tests/qemuxml2argvdata/serial-dev-chardev-iobase.args @@ -29,6 +29,6 @@ QEMU_AUDIO_DRV=none \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ -chardev tty,id=charserial0,path=/dev/ttyS2 \ --device isa-serial,chardev=charserial0,id=serial0,iobase=0x3f8,irq=0x4 \ +-device isa-serial,chardev=charserial0,id=serial0,iobase=1016,irq=4 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/tpm-emulator-spapr.ppc64-latest.args b/tests/qemuxml2argvdata/tpm-emulator-spapr.ppc64-latest.args index 04d632c091..c8dc4c74fe 100644 --- a/tests/qemuxml2argvdata/tpm-emulator-spapr.ppc64-latest.args +++ b/tests/qemuxml2argvdata/tpm-emulator-spapr.ppc64-latest.args @@ -32,9 +32,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-TPM-VM/.config \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ -device scsi-hd,bus=scsi1.0,channel=0,scsi-id=0,lun=0,device_id=drive-scsi1-0-0-0,drive=libvirt-1-format,id=scsi1-0-0-0,bootindex=1 \ -chardev pty,id=charserial0 \ --device spapr-vty,chardev=charserial0,id=serial0,reg=0x30000000 \ +-device spapr-vty,chardev=charserial0,id=serial0,reg=805306368 \ -chardev pty,id=charserial1 \ --device spapr-vty,chardev=charserial1,id=serial1,reg=0x30001000 \ +-device spapr-vty,chardev=charserial1,id=serial1,reg=805310464 \ -tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \ -chardev socket,id=chrtpm,path=/dev/test \ -device tpm-spapr,tpmdev=tpm-tpm0,id=tpm0,reg=0x00005000 \ -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
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> --- src/qemu/qemu_command.c | 224 ++++++++++-------- src/qemu/qemu_command.h | 10 +- src/qemu/qemu_hotplug.c | 8 +- ...ault-cpu-kvm-pseries-2.7.ppc64-latest.args | 2 +- ...ault-cpu-kvm-pseries-3.1.ppc64-latest.args | 2 +-
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Build the properties of 'vhost-scsi' device via JSON. In comparison to previous similar refactors this also modifies the hotplug code to attach the vhost fd handle explicitly rather than using 'qemuMonitorAddDeviceWithFd'. The 'vhost-scsi' device doesn't have any special (non-string) properties. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 44 +++++++++++++++++++++-------------------- src/qemu/qemu_command.h | 10 +++++----- src/qemu/qemu_hotplug.c | 31 ++++++++++++++++++++--------- 3 files changed, 50 insertions(+), 35 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 954513ce83..a92bdd62f9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4964,30 +4964,33 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDef *dev) return virBufferContentAndReset(&buf); } -char * -qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def, - virDomainHostdevDef *dev, - virQEMUCaps *qemuCaps, - char *vhostfdName) + +virJSONValue * +qemuBuildSCSIVHostHostdevDevProps(const virDomainDef *def, + virDomainHostdevDef *dev, + virQEMUCaps *qemuCaps, + char *vhostfdName) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; virDomainHostdevSubsysSCSIVHost *hostsrc = &dev->source.subsys.u.scsi_host; - if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_HOSTDEV, dev) < 0) { + if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_HOSTDEV, dev, qemuCaps))) return NULL; - } - virBufferAsprintf(&buf, ",wwpn=%s,vhostfd=%s,id=%s", - hostsrc->wwpn, - vhostfdName, - dev->info->alias); + if (virJSONValueObjectAdd(props, + "s:wwpn", hostsrc->wwpn, + "s:vhostfd", vhostfdName, + "s:id", dev->info->alias, + NULL) < 0) + return NULL; - if (qemuBuildDeviceAddressStr(&buf, def, dev->info) < 0) + if (qemuBuildDeviceAddressProps(props, def, dev->info) < 0) return NULL; - return virBufferContentAndReset(&buf); + return g_steal_pointer(&props); } + static char * qemuBuildSCSIHostdevDrvStr(virDomainHostdevDef *dev) { @@ -5550,7 +5553,6 @@ qemuBuildHostdevCommandLine(virCommand *cmd, virDomainHostdevDef *hostdev = def->hostdevs[i]; virDomainHostdevSubsys *subsys = &hostdev->source.subsys; virDomainHostdevSubsysMediatedDev *mdevsrc = &subsys->u.mdev; - g_autofree char *devstr = NULL; g_autoptr(virJSONValue) devprops = NULL; g_autofree char *vhostfdName = NULL; int vhostfd = -1; @@ -5603,14 +5605,14 @@ qemuBuildHostdevCommandLine(virCommand *cmd, virCommandPassFD(cmd, vhostfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); - virCommandAddArg(cmd, "-device"); - if (!(devstr = qemuBuildSCSIVHostHostdevDevStr(def, - hostdev, - qemuCaps, - vhostfdName))) + if (!(devprops = qemuBuildSCSIVHostHostdevDevProps(def, + hostdev, + qemuCaps, + vhostfdName))) return -1; - virCommandAddArg(cmd, devstr); + if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0) + return -1; } break; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 65e896b634..2a87a8a929 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -195,11 +195,11 @@ qemuBlockStorageSourceAttachData * qemuBuildHostdevSCSIDetachPrepare(virDomainHostdevDef *hostdev, virQEMUCaps *qemuCaps); -char * -qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def, - virDomainHostdevDef *dev, - virQEMUCaps *qemuCaps, - char *vhostfdName); +virJSONValue * +qemuBuildSCSIVHostHostdevDevProps(const virDomainDef *def, + virDomainHostdevDef *dev, + virQEMUCaps *qemuCaps, + char *vhostfdName); virJSONValue * qemuBuildHostdevMediatedDevProps(const virDomainDef *def, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index c7da38b49b..1e91fb393e 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2743,7 +2743,9 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriver *driver, virDomainCCWAddressSet *ccwaddrs = NULL; g_autofree char *vhostfdName = NULL; int vhostfd = -1; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; + bool removeextension = false; + bool removehandle = false; bool teardowncgroup = false; bool teardownlabel = false; bool teardowndevice = false; @@ -2790,10 +2792,10 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriver *driver, if (qemuAssignDeviceHostdevAlias(vm->def, &hostdev->info->alias, -1) < 0) goto cleanup; - if (!(devstr = qemuBuildSCSIVHostHostdevDevStr(vm->def, - hostdev, - priv->qemuCaps, - vhostfdName))) + if (!(devprops = qemuBuildSCSIVHostHostdevDevProps(vm->def, + hostdev, + priv->qemuCaps, + vhostfdName))) goto cleanup; VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1); @@ -2803,13 +2805,24 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriver *driver, if ((ret = qemuDomainAttachExtensionDevice(priv->mon, hostdev->info)) < 0) goto exit_monitor; - if ((ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr, vhostfd, - vhostfdName)) < 0) { - ignore_value(qemuDomainDetachExtensionDevice(priv->mon, hostdev->info)); + removeextension = true; + + if ((ret = qemuMonitorSendFileHandle(priv->mon, vhostfdName, vhostfd))) goto exit_monitor; - } + + removehandle = true; + + if ((ret = qemuMonitorAddDeviceProps(priv->mon, &devprops)) < 0) + goto exit_monitor; + + removeextension = false; + removehandle = false; exit_monitor: + if (removehandle) + ignore_value(qemuMonitorCloseFileHandle(priv->mon, vhostfdName)); + if (removeextension) + ignore_value(qemuDomainDetachExtensionDevice(priv->mon, hostdev->info)); if (qemuDomainObjExitMonitor(driver, vm) < 0 || ret < 0) goto audit; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Build the properties of 'vhost-scsi' device via JSON. In comparison to previous similar refactors this also modifies the hotplug code to attach the vhost fd handle explicitly rather than using 'qemuMonitorAddDeviceWithFd'.
The 'vhost-scsi' device doesn't have any special (non-string) properties.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 44 +++++++++++++++++++++-------------------- src/qemu/qemu_command.h | 10 +++++----- src/qemu/qemu_hotplug.c | 31 ++++++++++++++++++++--------- 3 files changed, 50 insertions(+), 35 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Build the properties of 'vhost-vsock' device via JSON. In comparison to previous similar refactors this also modifies the hotplug code to attach the vhost fd handle explicitly rather than using 'qemuMonitorAddDeviceWithFd'. The properties of vhost-vsock have the following types according to QEMU: guest-cid=<uint64> - (default: 0) vhostfd=<str> Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 36 ++++++++++++++++++++---------------- src/qemu/qemu_command.h | 12 +++++------- src/qemu/qemu_hotplug.c | 21 ++++++++++++++++----- 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a92bdd62f9..c566ab7bd5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10553,27 +10553,30 @@ qemuBuildSeccompSandboxCommandLine(virCommand *cmd, } -char * -qemuBuildVsockDevStr(virDomainDef *def, - virDomainVsockDef *vsock, - virQEMUCaps *qemuCaps, - const char *fdprefix) +virJSONValue * +qemuBuildVsockDevProps(virDomainDef *def, + virDomainVsockDef *vsock, + virQEMUCaps *qemuCaps, + const char *fdprefix) { qemuDomainVsockPrivate *priv = (qemuDomainVsockPrivate *)vsock->privateData; - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; + g_autofree char *vhostfd = g_strdup_printf("%s%u", fdprefix, priv->vhostfd); - if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_VSOCK, vsock) < 0) { + if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_VSOCK, vsock, qemuCaps))) return NULL; - } - virBufferAsprintf(&buf, ",id=%s", vsock->info.alias); - virBufferAsprintf(&buf, ",guest-cid=%u", vsock->guest_cid); - virBufferAsprintf(&buf, ",vhostfd=%s%u", fdprefix, priv->vhostfd); + if (virJSONValueObjectAdd(props, + "s:id", vsock->info.alias, + "u:guest-cid", vsock->guest_cid, + "s:vhostfd", vhostfd, + NULL) < 0) + return NULL; - if (qemuBuildDeviceAddressStr(&buf, def, &vsock->info) < 0) + if (qemuBuildDeviceAddressProps(props, def, &vsock->info) < 0) return NULL; - return virBufferContentAndReset(&buf); + return g_steal_pointer(&props); } @@ -10584,9 +10587,9 @@ qemuBuildVsockCommandLine(virCommand *cmd, virQEMUCaps *qemuCaps) { qemuDomainVsockPrivate *priv = (qemuDomainVsockPrivate *)vsock->privateData; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; - if (!(devstr = qemuBuildVsockDevStr(def, vsock, qemuCaps, ""))) + if (!(devprops = qemuBuildVsockDevProps(def, vsock, qemuCaps, ""))) return -1; virCommandPassFD(cmd, priv->vhostfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); @@ -10595,7 +10598,8 @@ qemuBuildVsockCommandLine(virCommand *cmd, if (qemuCommandAddExtDevice(cmd, &vsock->info, qemuCaps) < 0) return -1; - virCommandAddArgList(cmd, "-device", devstr, NULL); + if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0) + return -1; return 0; } diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 2a87a8a929..56999b7424 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -248,13 +248,11 @@ virJSONValue * qemuBuildInputUSBDevProps(const virDomainDef *def, virDomainInputDef *dev); -char * -qemuBuildVsockDevStr(virDomainDef *def, - virDomainVsockDef *vsock, - virQEMUCaps *qemuCaps, - const char *fdprefix) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) - ATTRIBUTE_NONNULL(4); +virJSONValue * +qemuBuildVsockDevProps(virDomainDef *def, + virDomainVsockDef *vsock, + virQEMUCaps *qemuCaps, + const char *fdprefix); /* this function is exported so that tests can mock the FDs */ int diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1e91fb393e..b9937220db 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3349,7 +3349,9 @@ qemuDomainAttachVsockDevice(virQEMUDriver *driver, const char *fdprefix = "vsockfd"; bool releaseaddr = false; g_autofree char *fdname = NULL; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; + bool removeextension = false; + bool removehandle = false; int ret = -1; if (vm->def->vsock) { @@ -3369,7 +3371,7 @@ qemuDomainAttachVsockDevice(virQEMUDriver *driver, fdname = g_strdup_printf("%s%u", fdprefix, vsockPriv->vhostfd); - if (!(devstr = qemuBuildVsockDevStr(vm->def, vsock, priv->qemuCaps, fdprefix))) + if (!(devprops = qemuBuildVsockDevProps(vm->def, vsock, priv->qemuCaps, fdprefix))) goto cleanup; qemuDomainObjEnterMonitor(driver, vm); @@ -3377,10 +3379,15 @@ qemuDomainAttachVsockDevice(virQEMUDriver *driver, if (qemuDomainAttachExtensionDevice(priv->mon, &vsock->info) < 0) goto exit_monitor; - if (qemuMonitorAddDeviceWithFd(priv->mon, devstr, vsockPriv->vhostfd, fdname) < 0) { - ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &vsock->info)); + removeextension = true; + + if ((ret = qemuMonitorSendFileHandle(priv->mon, fdname, vsockPriv->vhostfd)) < 0) + goto exit_monitor; + + removehandle = true; + + if ((ret = qemuMonitorAddDeviceProps(priv->mon, &devprops)) < 0) goto exit_monitor; - } if (qemuDomainObjExitMonitor(driver, vm) < 0) { releaseaddr = false; @@ -3402,6 +3409,10 @@ qemuDomainAttachVsockDevice(virQEMUDriver *driver, return ret; exit_monitor: + if (removehandle) + ignore_value(qemuMonitorCloseFileHandle(priv->mon, fdname)); + if (removeextension) + ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &vsock->info)); if (qemuDomainObjExitMonitor(driver, vm) < 0) releaseaddr = false; goto cleanup; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Build the properties of 'vhost-vsock' device via JSON. In comparison to previous similar refactors this also modifies the hotplug code to attach the vhost fd handle explicitly rather than using 'qemuMonitorAddDeviceWithFd'.
The properties of vhost-vsock have the following types according to QEMU:
guest-cid=<uint64> - (default: 0) vhostfd=<str>
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 36 ++++++++++++++++++++---------------- src/qemu/qemu_command.h | 12 +++++------- src/qemu/qemu_hotplug.c | 21 ++++++++++++++++----- 3 files changed, 41 insertions(+), 28 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

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> --- src/qemu/qemu_monitor.c | 34 -------- src/qemu/qemu_monitor.h | 7 -- src/qemu/qemu_monitor_json.c | 151 ----------------------------------- src/qemu/qemu_monitor_json.h | 2 - tests/qemumonitorjsontest.c | 2 - 5 files changed, 196 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index fe65d46ae9..7ff6a1161f 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2858,40 +2858,6 @@ qemuMonitorDelDevice(qemuMonitor *mon, } -int -qemuMonitorAddDeviceWithFd(qemuMonitor *mon, - const char *devicestr, - int fd, - const char *fdname) -{ - int ret; - - VIR_DEBUG("device=%s fd=%d fdname=%s", devicestr, fd, NULLSTR(fdname)); - - QEMU_CHECK_MONITOR(mon); - - if (fd >= 0 && qemuMonitorSendFileHandle(mon, fdname, fd) < 0) - return -1; - - ret = qemuMonitorJSONAddDevice(mon, devicestr); - - if (ret < 0 && fd >= 0) { - if (qemuMonitorCloseFileHandle(mon, fdname) < 0) - VIR_WARN("failed to close device handle '%s'", fdname); - } - - return ret; -} - - -int -qemuMonitorAddDevice(qemuMonitor *mon, - const char *devicestr) -{ - return qemuMonitorAddDeviceWithFd(mon, devicestr, -1, NULL); -} - - /** * qemuMonitorAddDeviceProps: * @mon: monitor object diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 5edf6a161b..52ff34d316 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1030,13 +1030,6 @@ int qemuMonitorAttachPCIDiskController(qemuMonitor *mon, int qemuMonitorAddDeviceProps(qemuMonitor *mon, virJSONValue **props); -int qemuMonitorAddDevice(qemuMonitor *mon, - const char *devicestr); - -int qemuMonitorAddDeviceWithFd(qemuMonitor *mon, - const char *devicestr, - int fd, - const char *fdname); int qemuMonitorDelDevice(qemuMonitor *mon, const char *devalias); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index f831cfeeb5..579d986e02 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -579,144 +579,6 @@ qemuMonitorJSONMakeCommand(const char *cmdname, } -static void -qemuMonitorJSONParseKeywordsFree(int nkeywords, - char **keywords, - char **values) -{ - size_t i; - for (i = 0; i < nkeywords; i++) { - g_free(keywords[i]); - g_free(values[i]); - } - g_free(keywords); - g_free(values); -} - - -/* - * Takes a string containing a set of key=value,key=value,key... - * parameters and splits them up, returning two arrays with - * the individual keys and values. - * The "=value" part is optional and if a key with no value is found, - * NULL will be placed into corresponding place in retvalues. - */ -static int -qemuMonitorJSONParseKeywords(const char *str, - char ***retkeywords, - char ***retvalues, - int *retnkeywords) -{ - int keywordCount = 0; - int keywordAlloc = 0; - char **keywords = NULL; - char **values = NULL; - const char *start = str; - const char *end; - - *retkeywords = NULL; - *retvalues = NULL; - *retnkeywords = 0; - end = start + strlen(str); - - while (start) { - const char *separator; - const char *endmark; - char *keyword; - char *value = NULL; - - endmark = start; - do { - /* QEMU accepts ',,' as an escape for a literal comma; - * skip past those here while searching for the end of the - * value, then strip them down below */ - endmark = strchr(endmark, ','); - } while (endmark && endmark[1] == ',' && (endmark += 2)); - if (!endmark) - endmark = end; - if (!(separator = strchr(start, '='))) - separator = end; - - if (separator >= endmark) - separator = endmark; - - keyword = g_strndup(start, separator - start); - - if (separator < endmark) { - separator++; - value = g_strndup(separator, endmark - separator); - if (strchr(value, ',')) { - char *p = strchr(value, ',') + 1; - char *q = p + 1; - while (*q) { - if (*q == ',') - q++; - *p++ = *q++; - } - *p = '\0'; - } - } - - if (keywordAlloc == keywordCount) { - VIR_REALLOC_N(keywords, keywordAlloc + 10); - VIR_REALLOC_N(values, keywordAlloc + 10); - keywordAlloc += 10; - } - - keywords[keywordCount] = keyword; - values[keywordCount] = value; - keywordCount++; - - start = endmark < end ? endmark + 1 : NULL; - } - - *retkeywords = keywords; - *retvalues = values; - *retnkeywords = keywordCount; - return 0; -} - - -static virJSONValue * -qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword) -{ - virJSONValue *ret = virJSONValueNewObject(); - char **keywords = NULL; - char **values = NULL; - int nkeywords = 0; - size_t i; - - if (qemuMonitorJSONParseKeywords(str, &keywords, &values, &nkeywords) < 0) - goto error; - - for (i = 0; i < nkeywords; i++) { - if (values[i] == NULL) { - if (i != 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected empty keyword in %s"), str); - goto error; - } else { - /* This 3rd arg isn't a typo - the way the parser works is - * that the value ended up in the keyword field */ - if (virJSONValueObjectAppendString(ret, firstkeyword, keywords[i]) < 0) - goto error; - } - } else { - if (virJSONValueObjectAppendString(ret, keywords[i], values[i]) < 0) - goto error; - } - } - - qemuMonitorJSONParseKeywordsFree(nkeywords, keywords, values); - return ret; - - error: - qemuMonitorJSONParseKeywordsFree(nkeywords, keywords, values); - virJSONValueFree(ret); - return NULL; -} - - static void qemuMonitorJSONHandleShutdown(qemuMonitor *mon, virJSONValue *data) { bool guest = false; @@ -4576,19 +4438,6 @@ qemuMonitorJSONAddDeviceProps(qemuMonitor *mon, } -int -qemuMonitorJSONAddDevice(qemuMonitor *mon, - const char *devicestr) -{ - g_autoptr(virJSONValue) props = NULL; - - if (!(props = qemuMonitorJSONKeywordStringToJSON(devicestr, "driver"))) - return -1; - - return qemuMonitorJSONAddDeviceProps(mon, &props); -} - - int qemuMonitorJSONAddObject(qemuMonitor *mon, virJSONValue **props) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 8dc2350642..c841de0a03 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -237,8 +237,6 @@ int qemuMonitorJSONAttachPCIDiskController(qemuMonitor *mon, int qemuMonitorJSONAddDeviceProps(qemuMonitor *mon, virJSONValue **props); -int qemuMonitorJSONAddDevice(qemuMonitor *mon, - const char *devicestr); int qemuMonitorJSONDelDevice(qemuMonitor *mon, const char *devalias); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 1e4c2fd14e..30a19d27e8 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1184,7 +1184,6 @@ GEN_TEST_FUNC(qemuMonitorJSONGraphicsRelocate, VIR_DOMAIN_GRAPHICS_TYPE_SPICE, "localhost", 12345, 12346, "certsubjectval") GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0") GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0") -GEN_TEST_FUNC(qemuMonitorJSONAddDevice, "some_dummy_devicestr") GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar", "formatstr", 1024, 1234, 31234, true, true) GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targetnode", 1024, 1234, 31234, true) GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "jobname", true, "/foo/bar1", "backingnode", "backingfilename", 1024) @@ -3024,7 +3023,6 @@ mymain(void) DO_TEST_GEN(qemuMonitorJSONGraphicsRelocate); DO_TEST_GEN(qemuMonitorJSONRemoveNetdev); DO_TEST_GEN(qemuMonitorJSONDelDevice); - DO_TEST_GEN(qemuMonitorJSONAddDevice); DO_TEST_GEN(qemuMonitorJSONDriveMirror); DO_TEST_GEN(qemuMonitorJSONBlockdevMirror); DO_TEST_GEN(qemuMonitorJSONBlockStream); -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
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> --- src/qemu/qemu_monitor.c | 34 -------- src/qemu/qemu_monitor.h | 7 -- src/qemu/qemu_monitor_json.c | 151 ----------------------------------- src/qemu/qemu_monitor_json.h | 2 - tests/qemumonitorjsontest.c | 2 - 5 files changed, 196 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The 'vhost-user-fs-pci' has following properties we control: chardev=<str> - ID of a chardev to use as a backend queue-size=<uint16> - (default: 128) tag=<str> bootindex=<int32> Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 43 ++++++++++++++++++++--------------------- src/qemu/qemu_command.h | 10 +++++----- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c566ab7bd5..f47d77548d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2571,31 +2571,30 @@ qemuBuildVHostUserFsChardevStr(const virDomainFSDef *fs, } -char * -qemuBuildVHostUserFsDevStr(virDomainFSDef *fs, - const virDomainDef *def, - const char *chardev_alias, - qemuDomainObjPrivate *priv) +virJSONValue * +qemuBuildVHostUserFsDevProps(virDomainFSDef *fs, + const virDomainDef *def, + const char *chardev_alias, + qemuDomainObjPrivate *priv) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; - if (qemuBuildVirtioDevStr(&buf, priv->qemuCaps, VIR_DOMAIN_DEVICE_FS, fs) < 0) + if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_FS, fs, priv->qemuCaps))) return NULL; - virBufferAsprintf(&buf, ",id=%s", fs->info.alias); - virBufferAsprintf(&buf, ",chardev=%s", chardev_alias); - if (fs->queue_size) - virBufferAsprintf(&buf, ",queue-size=%llu", fs->queue_size); - virBufferAddLit(&buf, ",tag="); - virQEMUBuildBufferEscapeComma(&buf, fs->dst); - - if (fs->info.bootIndex) - virBufferAsprintf(&buf, ",bootindex=%u", fs->info.bootIndex); + if (virJSONValueObjectAdd(props, + "s:id", fs->info.alias, + "s:chardev", chardev_alias, + "P:queue-size", fs->queue_size, + "s:tag", fs->dst, + "p:bootindex", fs->info.bootIndex, + NULL) < 0) + return NULL; - if (qemuBuildDeviceAddressStr(&buf, def, &fs->info) < 0) + if (qemuBuildDeviceAddressProps(props, def, &fs->info) < 0) return NULL; - return virBufferContentAndReset(&buf); + return g_steal_pointer(&props); } @@ -2607,7 +2606,7 @@ qemuBuildVHostUserFsCommandLine(virCommand *cmd, { g_autofree char *chardev_alias = NULL; g_autofree char *chrdevstr = NULL; - g_autofree char *devstr = NULL; + g_autoptr(virJSONValue) devprops = NULL; chardev_alias = qemuDomainGetVhostUserChrAlias(fs->info.alias); chrdevstr = qemuBuildVHostUserFsChardevStr(fs, chardev_alias, priv); @@ -2618,11 +2617,11 @@ qemuBuildVHostUserFsCommandLine(virCommand *cmd, if (qemuCommandAddExtDevice(cmd, &fs->info, priv->qemuCaps) < 0) return -1; - if (!(devstr = qemuBuildVHostUserFsDevStr(fs, def, chardev_alias, priv))) + if (!(devprops = qemuBuildVHostUserFsDevProps(fs, def, chardev_alias, priv))) return -1; - virCommandAddArg(cmd, "-device"); - virCommandAddArg(cmd, devstr); + if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, priv->qemuCaps) < 0) + return -1; return 0; } diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 56999b7424..81fd24406d 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -138,11 +138,11 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, virDomainDiskDef *disk, virQEMUCaps *qemuCaps); -char * -qemuBuildVHostUserFsDevStr(virDomainFSDef *fs, - const virDomainDef *def, - const char *chardev_alias, - qemuDomainObjPrivate *priv); +virJSONValue * +qemuBuildVHostUserFsDevProps(virDomainFSDef *fs, + const virDomainDef *def, + const char *chardev_alias, + qemuDomainObjPrivate *priv); /* Current, best practice */ int -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The 'vhost-user-fs-pci' has following properties we control: chardev=<str> - ID of a chardev to use as a backend queue-size=<uint16> - (default: 128) tag=<str> bootindex=<int32>
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 43 ++++++++++++++++++++--------------------- src/qemu/qemu_command.h | 10 +++++----- 2 files changed, 26 insertions(+), 27 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f47d77548d..71816288e5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2675,26 +2675,32 @@ qemuBuildFSStr(virDomainFSDef *fs) } -static char * -qemuBuildFSDevStr(const virDomainDef *def, +static int +qemuBuildFSDevCmd(virCommand *cmd, + const virDomainDef *def, virDomainFSDef *fs, virQEMUCaps *qemuCaps) { - g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) devprops = NULL; + g_autofree char *fsdev = g_strdup_printf("%s%s", QEMU_FSDEV_HOST_PREFIX, fs->info.alias); - if (qemuBuildVirtioDevStr(&opt, qemuCaps, VIR_DOMAIN_DEVICE_FS, fs) < 0) - return NULL; + if (!(devprops = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_FS, fs, qemuCaps))) + return -1; - virBufferAsprintf(&opt, ",id=%s", fs->info.alias); - virBufferAsprintf(&opt, ",fsdev=%s%s", - QEMU_FSDEV_HOST_PREFIX, fs->info.alias); - virBufferAddLit(&opt, ",mount_tag="); - virQEMUBuildBufferEscapeComma(&opt, fs->dst); + if (virJSONValueObjectAdd(devprops, + "s:id", fs->info.alias, + "s:fsdev", fsdev, + "s:mount_tag", fs->dst, + NULL) < 0) + return -1; - if (qemuBuildDeviceAddressStr(&opt, def, &fs->info) < 0) - return NULL; + if (qemuBuildDeviceAddressProps(devprops, def, &fs->info) < 0) + return -1; - return virBufferContentAndReset(&opt); + if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0) + return -1; + + return 0; } @@ -2705,7 +2711,6 @@ qemuBuildFSDevCommandLine(virCommand *cmd, virQEMUCaps *qemuCaps) { g_autofree char *fsdevstr = NULL; - g_autofree char *devicestr = NULL; virCommandAddArg(cmd, "-fsdev"); if (!(fsdevstr = qemuBuildFSStr(fs))) @@ -2715,10 +2720,8 @@ qemuBuildFSDevCommandLine(virCommand *cmd, if (qemuCommandAddExtDevice(cmd, &fs->info, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-device"); - if (!(devicestr = qemuBuildFSDevStr(def, fs, qemuCaps))) + if (qemuBuildFSDevCmd(cmd, def, fs, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, devicestr); return 0; } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

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> --- src/qemu/qemu_command.c | 130 ++++++++++-------- ...eo-bochs-display-device.x86_64-latest.args | 2 +- 2 files changed, 74 insertions(+), 58 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 71816288e5..b9c9027748 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4645,99 +4645,120 @@ qemuBuildSoundCommandLine(virCommand *cmd, } -static char * -qemuBuildDeviceVideoStr(const virDomainDef *def, +static int +qemuBuildDeviceVideoCmd(virCommand *cmd, + const virDomainDef *def, virDomainVideoDef *video, virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; const char *model = NULL; - virTristateSwitch accel3d = VIR_TRISTATE_SWITCH_ABSENT; + virTristateSwitch virgl = VIR_TRISTATE_SWITCH_ABSENT; bool virtio = false; bool virtioBusSuffix = false; - - if (video->accel) - accel3d = video->accel->accel3d; + g_autoptr(virJSONValue) props = NULL; if (!(model = qemuDeviceVideoGetModel(qemuCaps, video, &virtio, &virtioBusSuffix))) - return NULL; + return -1; if (virtio) { - if (qemuBuildVirtioDevStr(&buf, qemuCaps, VIR_DOMAIN_DEVICE_VIDEO, video) < 0) { - return NULL; - } + if (!(props = qemuBuildVirtioDevProps(VIR_DOMAIN_DEVICE_VIDEO, video, qemuCaps))) + return -1; } else { - virBufferAsprintf(&buf, "%s", model); + if (virJSONValueObjectCreate(&props, + "s:driver", model, + NULL) < 0) + return -1; } - virBufferAsprintf(&buf, ",id=%s", video->info.alias); - if (video->backend != VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER && video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { if (video->accel && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_VIRGL) && - (accel3d == VIR_TRISTATE_SWITCH_ON || - accel3d == VIR_TRISTATE_SWITCH_OFF)) { - virBufferAsprintf(&buf, ",virgl=%s", - virTristateSwitchTypeToString(accel3d)); + virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_VIRGL)) { + virgl = video->accel->accel3d; } } - if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL) { - if (video->ram) { - /* QEMU accepts bytes for ram_size. */ - virBufferAsprintf(&buf, ",ram_size=%u", video->ram * 1024); - } + if (virJSONValueObjectAdd(props, + "s:id", video->info.alias, + "T:virgl", virgl, + NULL) < 0) + return -1; - if (video->vram) { - /* QEMU accepts bytes for vram_size. */ - virBufferAsprintf(&buf, ",vram_size=%u", video->vram * 1024); - } + if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL) { + if (virJSONValueObjectAdd(props, + "p:ram_size", video->ram * 1024, + "p:vram_size", video->vram * 1024, + NULL) < 0) + return -1; if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VRAM64)) { - /* QEMU accepts mebibytes for vram64_size_mb. */ - virBufferAsprintf(&buf, ",vram64_size_mb=%u", video->vram64 / 1024); + if (virJSONValueObjectAdd(props, + "u:vram64_size_mb", video->vram64 / 1024, + NULL) < 0) + return -1; } if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGAMEM)) { - /* QEMU accepts mebibytes for vgamem_mb. */ - virBufferAsprintf(&buf, ",vgamem_mb=%u", video->vgamem / 1024); + if (virJSONValueObjectAdd(props, + "u:vgamem_mb", video->vgamem / 1024, + NULL) < 0) + return -1; } if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_MAX_OUTPUTS)) { - if (video->heads) - virBufferAsprintf(&buf, ",max_outputs=%u", video->heads); + if (virJSONValueObjectAdd(props, + "p:max_outputs", video->heads, + NULL) < 0) + return -1; } } else if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) { g_autofree char *alias = qemuDomainGetVhostUserChrAlias(video->info.alias); - if (video->heads) - virBufferAsprintf(&buf, ",max_outputs=%u", video->heads); - virBufferAsprintf(&buf, ",chardev=%s", alias); + + if (virJSONValueObjectAdd(props, + "p:max_outputs", video->heads, + "s:chardev", alias, + NULL) < 0) + return -1; } else if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS)) { - if (video->heads) - virBufferAsprintf(&buf, ",max_outputs=%u", video->heads); - } + unsigned int heads = 0; + + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS)) + heads = video->heads; + + if (virJSONValueObjectAdd(props, + "p:max_outputs", heads, + NULL) < 0) + return -1; } else if ((video->type == VIR_DOMAIN_VIDEO_TYPE_VGA && virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) || (video->type == VIR_DOMAIN_VIDEO_TYPE_VMVGA && virQEMUCapsGet(qemuCaps, QEMU_CAPS_VMWARE_SVGA_VGAMEM))) { - if (video->vram) - virBufferAsprintf(&buf, ",vgamem_mb=%u", video->vram / 1024); + if (virJSONValueObjectAdd(props, + "p:vgamem_mb", video->vram / 1024, + NULL) < 0) + return -1; } else if (video->type == VIR_DOMAIN_VIDEO_TYPE_BOCHS) { - if (video->vram) - virBufferAsprintf(&buf, ",vgamem=%uk", video->vram); + if (virJSONValueObjectAdd(props, + "p:vgamem", video->vram * 1024, + NULL) < 0) + return -1; } - if (video->res && video->res->x && video->res->y) { - /* QEMU accepts resolution xres and yres. */ - virBufferAsprintf(&buf, ",xres=%u,yres=%u", video->res->x, video->res->y); + if (video->res) { + if (virJSONValueObjectAdd(props, + "p:xres", video->res->x, + "p:yres", video->res->y, + NULL) < 0) + return -1; } - if (qemuBuildDeviceAddressStr(&buf, def, &video->info) < 0) - return NULL; + if (qemuBuildDeviceAddressProps(props, def, &video->info) < 0) + return -1; - return virBufferContentAndReset(&buf); + if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0) + return -1; + + return 0; } @@ -4786,7 +4807,6 @@ qemuBuildVideoCommandLine(virCommand *cmd, } for (i = 0; i < def->nvideos; i++) { - g_autofree char *str = NULL; virDomainVideoDef *video = def->videos[i]; if (video->type == VIR_DOMAIN_VIDEO_TYPE_NONE) @@ -4795,12 +4815,8 @@ qemuBuildVideoCommandLine(virCommand *cmd, if (qemuCommandAddExtDevice(cmd, &def->videos[i]->info, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-device"); - - if (!(str = qemuBuildDeviceVideoStr(def, video, qemuCaps))) + if (qemuBuildDeviceVideoCmd(cmd, def, video, qemuCaps) < 0) return -1; - - virCommandAddArg(cmd, str); } return 0; diff --git a/tests/qemuxml2argvdata/video-bochs-display-device.x86_64-latest.args b/tests/qemuxml2argvdata/video-bochs-display-device.x86_64-latest.args index 834986edd1..3af0ecf2b1 100644 --- a/tests/qemuxml2argvdata/video-bochs-display-device.x86_64-latest.args +++ b/tests/qemuxml2argvdata/video-bochs-display-device.x86_64-latest.args @@ -31,7 +31,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"cache":{"direct":true,"no-flush":false},"driver":"qcow2","file":"libvirt-1-storage"}' \ -device ide-hd,bus=ide.0,unit=0,drive=libvirt-1-format,id=ide0-0-0,bootindex=1,write-cache=on \ -audiodev id=audio1,driver=none \ --device bochs-display,id=video0,vgamem=16384k,bus=pci.0,addr=0x2 \ +-device bochs-display,id=video0,vgamem=16777216,bus=pci.0,addr=0x2 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
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> --- src/qemu/qemu_command.c | 130 ++++++++++-------- ...eo-bochs-display-device.x86_64-latest.args | 2 +- 2 files changed, 74 insertions(+), 58 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

All virtio devices were converted to the new JSON formatter so we can remove the old one. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 65 +---------------------------------------- 1 file changed, 1 insertion(+), 64 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b9c9027748..324da4adc5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1182,7 +1182,7 @@ qemuBuildVirtioDevGetConfig(virDomainDeviceDef *device, * * Build the qemu virtio -device JSON properties name from the passed parameters. */ -static G_GNUC_UNUSED virJSONValue * +static virJSONValue * qemuBuildVirtioDevProps(virDomainDeviceType devtype, void *devdata, virQEMUCaps *qemuCaps) @@ -1220,69 +1220,6 @@ qemuBuildVirtioDevProps(virDomainDeviceType devtype, } -/** - * qemuBuildVirtioDevStr - * @buf: virBuffer * to append the built string - * @qemuCaps: virQEMUCapPtr - * @devtype: virDomainDeviceType of the device. Ex: VIR_DOMAIN_DEVICE_TYPE_RNG - * @devdata: *Def * of the device definition - * - * Build the qemu virtio -device name from the passed parameters. Currently - * this is mostly about attaching the correct string prefix to @baseName for - * the passed @type. So for @baseName "virtio-rng" and devdata->info.type - * VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI, generate "virtio-rng-pci" - * - * Returns: -1 on failure, 0 on success - */ -static G_GNUC_UNUSED int -qemuBuildVirtioDevStr(virBuffer *buf, - virQEMUCaps *qemuCaps, - virDomainDeviceType devtype, - void *devdata) -{ - virDomainDeviceDef device = { .type = devtype }; - g_autofree char *model = NULL; - virTristateSwitch disableLegacy = VIR_TRISTATE_SWITCH_ABSENT; - virTristateSwitch disableModern = VIR_TRISTATE_SWITCH_ABSENT; - virDomainVirtioOptions *virtioOptions = NULL; - - virDomainDeviceSetData(&device, devdata); - - if (qemuBuildVirtioDevGetConfig(&device, qemuCaps, &model, &virtioOptions, - &disableLegacy, &disableModern) < 0) - return -1; - - virBufferAdd(buf, model, -1); - - if (disableLegacy != VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAsprintf(buf, ",disable-legacy=%s", - virTristateSwitchTypeToString(disableLegacy)); - } - - if (disableModern != VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAsprintf(buf, ",disable-modern=%s", - virTristateSwitchTypeToString(disableModern)); - } - - if (virtioOptions) { - if (virtioOptions->iommu != VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAsprintf(buf, ",iommu_platform=%s", - virTristateSwitchTypeToString(virtioOptions->iommu)); - } - if (virtioOptions->ats != VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAsprintf(buf, ",ats=%s", - virTristateSwitchTypeToString(virtioOptions->ats)); - } - if (virtioOptions->packed != VIR_TRISTATE_SWITCH_ABSENT) { - virBufferAsprintf(buf, ",packed=%s", - virTristateSwitchTypeToString(virtioOptions->packed)); - } - } - - return 0; -} - - static int qemuBuildRomProps(virJSONValue *props, virDomainDeviceInfo *info) -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
All virtio devices were converted to the new JSON formatter so we can remove the old one.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 65 +---------------------------------------- 1 file changed, 1 insertion(+), 64 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The sound devices have only the 'audiodev' property which is a string. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 324da4adc5..cf56ec3a76 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4447,15 +4447,16 @@ qemuGetAudioIDString(const virDomainDef *def, int id) return g_strdup_printf("audio%d", audio->id); } -static char * -qemuBuildSoundDevStr(const virDomainDef *def, +static int +qemuBuildSoundDevCmd(virCommand *cmd, + const virDomainDef *def, virDomainSoundDef *sound, virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; const char *model = NULL; + g_autofree char *audioid = NULL; - /* Hack for devices with different names in QEMU and libvirt */ switch (sound->model) { case VIR_DOMAIN_SOUND_MODEL_ES1370: model = "ES1370"; @@ -4478,21 +4479,29 @@ qemuBuildSoundDevStr(const virDomainDef *def, case VIR_DOMAIN_SOUND_MODEL_PCSPK: /* pc-speaker is handled separately */ case VIR_DOMAIN_SOUND_MODEL_ICH7: case VIR_DOMAIN_SOUND_MODEL_LAST: - return NULL; + return -1; } - virBufferAsprintf(&buf, "%s,id=%s", model, sound->info.alias); if (!virDomainSoundModelSupportsCodecs(sound) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_AUDIODEV)) { - g_autofree char *audioid = qemuGetAudioIDString(def, sound->audioId); - if (!audioid) - return NULL; - virBufferAsprintf(&buf, ",audiodev=%s", audioid); + if (!(audioid = qemuGetAudioIDString(def, sound->audioId))) + return -1; } - if (qemuBuildDeviceAddressStr(&buf, def, &sound->info) < 0) - return NULL; - return virBufferContentAndReset(&buf); + if (virJSONValueObjectCreate(&props, + "s:driver", model, + "s:id", sound->info.alias, + "S:audiodev", audioid, + NULL) < 0) + return -1; + + if (qemuBuildDeviceAddressProps(props, def, &sound->info) < 0) + return -1; + + if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0) + return -1; + + return 0; } @@ -4532,7 +4541,6 @@ qemuBuildSoundCommandLine(virCommand *cmd, for (i = 0; i < def->nsounds; i++) { virDomainSoundDef *sound = def->sounds[i]; - g_autofree char *str = NULL; /* Sadly pcspk device doesn't use -device syntax. Fortunately * we don't need to set any PCI address on it, so we don't @@ -4543,11 +4551,9 @@ qemuBuildSoundCommandLine(virCommand *cmd, if (qemuCommandAddExtDevice(cmd, &sound->info, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-device"); - if (!(str = qemuBuildSoundDevStr(def, sound, qemuCaps))) + if (qemuBuildSoundDevCmd(cmd, def, sound, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, str); if (virDomainSoundModelSupportsCodecs(sound)) { for (j = 0; j < sound->ncodecs; j++) { g_autofree char *codecstr = NULL; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The sound devices have only the 'audiodev' property which is a string.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 324da4adc5..cf56ec3a76 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4447,15 +4447,16 @@ qemuGetAudioIDString(const virDomainDef *def, int id) [..]
+ g_autofree char *audioid = NULL;
- /* Hack for devices with different names in QEMU and libvirt */
Nice, you also got rid of the hack.
switch (sound->model) { case VIR_DOMAIN_SOUND_MODEL_ES1370: model = "ES1370"; @@ -4478,21 +4479,29 @@ qemuBuildSoundDevStr(const virDomainDef *def, case VIR_DOMAIN_SOUND_MODEL_PCSPK: /* pc-speaker is handled separately */ case VIR_DOMAIN_SOUND_MODEL_ICH7: case VIR_DOMAIN_SOUND_MODEL_LAST: - return NULL; + return -1; }
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The codec devices have the following properties we control: cad=<uint32> - (default: 4294967295) audiodev=<str> - ID of an audiodev to use as a backend Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 64 ++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index cf56ec3a76..d0bf3dbb30 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4505,30 +4505,36 @@ qemuBuildSoundDevCmd(virCommand *cmd, } -static char * -qemuBuildSoundCodecStr(const virDomainDef *def, +static int +qemuBuildSoundCodecCmd(virCommand *cmd, + const virDomainDef *def, virDomainSoundDef *sound, virDomainSoundCodecDef *codec, virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - const char *stype; - int type; - - type = codec->type; - stype = qemuSoundCodecTypeToString(type); - - virBufferAsprintf(&buf, "%s,id=%s-codec%d,bus=%s.0,cad=%d", - stype, sound->info.alias, codec->cad, sound->info.alias, codec->cad); + g_autoptr(virJSONValue) props = NULL; + g_autofree char *audioid = NULL; + g_autofree char *alias = g_strdup_printf("%s-codec%d", sound->info.alias, codec->cad); + g_autofree char *bus = g_strdup_printf("%s.0", sound->info.alias); if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_AUDIODEV)) { - g_autofree char *audioid = qemuGetAudioIDString(def, sound->audioId); - if (!audioid) - return NULL; - virBufferAsprintf(&buf, ",audiodev=%s", audioid); + if (!(audioid = qemuGetAudioIDString(def, sound->audioId))) + return -1; } - return virBufferContentAndReset(&buf); + if (virJSONValueObjectCreate(&props, + "s:driver", qemuSoundCodecTypeToString(codec->type), + "s:id", alias, + "s:bus", bus, + "i:cad", codec->cad, + "S:audiodev", audioid, + NULL) < 0) + return -1; + + if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0) + return -1; + + return 0; } @@ -4556,30 +4562,16 @@ qemuBuildSoundCommandLine(virCommand *cmd, if (virDomainSoundModelSupportsCodecs(sound)) { for (j = 0; j < sound->ncodecs; j++) { - g_autofree char *codecstr = NULL; - virCommandAddArg(cmd, "-device"); - if (!(codecstr = - qemuBuildSoundCodecStr(def, sound, - sound->codecs[j], qemuCaps))) { + if (qemuBuildSoundCodecCmd(cmd, def, sound, sound->codecs[j], + qemuCaps) < 0) return -1; - - } - virCommandAddArg(cmd, codecstr); } + if (j == 0) { - g_autofree char *codecstr = NULL; - virDomainSoundCodecDef codec = { - VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX, - 0 - }; - virCommandAddArg(cmd, "-device"); - if (!(codecstr = - qemuBuildSoundCodecStr(def, sound, - &codec, qemuCaps))) { - return -1; + virDomainSoundCodecDef codec = { VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX, 0 }; - } - virCommandAddArg(cmd, codecstr); + if (qemuBuildSoundCodecCmd(cmd, def, sound, &codec, qemuCaps) < 0) + return -1; } } } -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The codec devices have the following properties we control: cad=<uint32> - (default: 4294967295) audiodev=<str> - ID of an audiodev to use as a backend
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 64 ++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 36 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

The 'usb-hub' device doesn't have any special properties. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d0bf3dbb30..306dcc6b8c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4860,19 +4860,27 @@ qemuBuildUSBHostdevDevProps(const virDomainDef *def, } -static char * -qemuBuildHubDevStr(const virDomainDef *def, +static int +qemuBuildHubDevCmd(virCommand *cmd, + const virDomainDef *def, virDomainHubDef *dev, - virQEMUCaps *qemuCaps G_GNUC_UNUSED) + virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; - virBufferAddLit(&buf, "usb-hub"); - virBufferAsprintf(&buf, ",id=%s", dev->info.alias); - if (qemuBuildDeviceAddressStr(&buf, def, &dev->info) < 0) - return NULL; + if (virJSONValueObjectCreate(&props, + "s:driver", "usb-hub", + "s:id", dev->info.alias, + NULL) < 0) + return -1; - return virBufferContentAndReset(&buf); + if (qemuBuildDeviceAddressProps(props, def, &dev->info) < 0) + return -1; + + if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0) + return -1; + + return 0; } @@ -4884,13 +4892,8 @@ qemuBuildHubCommandLine(virCommand *cmd, size_t i; for (i = 0; i < def->nhubs; i++) { - virDomainHubDef *hub = def->hubs[i]; - g_autofree char *optstr = NULL; - - virCommandAddArg(cmd, "-device"); - if (!(optstr = qemuBuildHubDevStr(def, hub, qemuCaps))) + if (qemuBuildHubDevCmd(cmd, def, def->hubs[i], qemuCaps) < 0) return -1; - virCommandAddArg(cmd, optstr); } return 0; -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
The 'usb-hub' device doesn't have any special properties.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

We control only the 'tpmdev' property of TPM devices which is a string. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 32 +++++++++++-------- .../ppc64-tpmproxy-with-tpm.ppc64-latest.args | 2 +- .../tpm-emulator-spapr.ppc64-latest.args | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 306dcc6b8c..53f38ff306 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9912,24 +9912,33 @@ qemuBuildDomainLoaderCommandLine(virCommand *cmd, } -static char * -qemuBuildTPMDevStr(const virDomainDef *def, +static int +qemuBuildTPMDevCmd(virCommand *cmd, + const virDomainDef *def, virDomainTPMDef *tpm, - virQEMUCaps *qemuCaps G_GNUC_UNUSED) + virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; const char *model = virDomainTPMModelTypeToString(tpm->model); + g_autofree char *tpmdev = g_strdup_printf("tpm-%s", tpm->info.alias); if (tpm->model == VIR_DOMAIN_TPM_MODEL_TIS && def->os.arch == VIR_ARCH_AARCH64) model = "tpm-tis-device"; - virBufferAsprintf(&buf, "%s,tpmdev=tpm-%s,id=%s", - model, tpm->info.alias, tpm->info.alias); + if (virJSONValueObjectCreate(&props, + "s:driver", model, + "s:tpmdev", tpmdev, + "s:id", tpm->info.alias, + NULL) < 0) + return -1; - if (qemuBuildDeviceAddressStr(&buf, def, &tpm->info) < 0) - return NULL; + if (qemuBuildDeviceAddressProps(props, def, &tpm->info) < 0) + return -1; - return virBufferContentAndReset(&buf); + if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0) + return -1; + + return 0; } @@ -10056,12 +10065,9 @@ qemuBuildTPMCommandLine(virCommand *cmd, VIR_FREE(fdset); } - if (!(optstr = qemuBuildTPMDevStr(def, tpm, qemuCaps))) + if (qemuBuildTPMDevCmd(cmd, def, tpm, qemuCaps) < 0) return -1; - virCommandAddArgList(cmd, "-device", optstr, NULL); - VIR_FREE(optstr); - return 0; } diff --git a/tests/qemuxml2argvdata/ppc64-tpmproxy-with-tpm.ppc64-latest.args b/tests/qemuxml2argvdata/ppc64-tpmproxy-with-tpm.ppc64-latest.args index d72f7efe06..e20fe53b3c 100644 --- a/tests/qemuxml2argvdata/ppc64-tpmproxy-with-tpm.ppc64-latest.args +++ b/tests/qemuxml2argvdata/ppc64-tpmproxy-with-tpm.ppc64-latest.args @@ -29,7 +29,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -device spapr-tpm-proxy,id=tpm0,host-path=/dev/tpmrm0 \ -tpmdev emulator,id=tpm-tpm1,chardev=chrtpm \ -chardev socket,id=chrtpm,path=/dev/test \ --device tpm-spapr,tpmdev=tpm-tpm1,id=tpm1,reg=0x00004000 \ +-device tpm-spapr,tpmdev=tpm-tpm1,id=tpm1,reg=16384 \ -audiodev id=audio1,driver=none \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ diff --git a/tests/qemuxml2argvdata/tpm-emulator-spapr.ppc64-latest.args b/tests/qemuxml2argvdata/tpm-emulator-spapr.ppc64-latest.args index c8dc4c74fe..8875b38ad5 100644 --- a/tests/qemuxml2argvdata/tpm-emulator-spapr.ppc64-latest.args +++ b/tests/qemuxml2argvdata/tpm-emulator-spapr.ppc64-latest.args @@ -37,7 +37,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-TPM-VM/.config \ -device spapr-vty,chardev=charserial1,id=serial1,reg=805310464 \ -tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \ -chardev socket,id=chrtpm,path=/dev/test \ --device tpm-spapr,tpmdev=tpm-tpm0,id=tpm0,reg=0x00005000 \ +-device tpm-spapr,tpmdev=tpm-tpm0,id=tpm0,reg=20480 \ -audiodev id=audio1,driver=none \ -global spapr-nvram.reg=0x4000 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
We control only the 'tpmdev' property of TPM devices which is a string.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 32 +++++++++++-------- .../ppc64-tpmproxy-with-tpm.ppc64-latest.args | 2 +- .../tpm-emulator-spapr.ppc64-latest.args | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

On a Monday in 2021, Ján Tomko wrote:
On a Thursday in 2021, Peter Krempa wrote:
We control only the 'tpmdev' property of TPM devices which is a string.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 32 +++++++++++-------- .../ppc64-tpmproxy-with-tpm.ppc64-latest.args | 2 +- .../tpm-emulator-spapr.ppc64-latest.args | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Also, this is the last conversion to use qemuBuildDeviceCommandlineFromJSON so you can un-mark it as unused.
Jano

All users were converted to the JSON counterpart. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 99 +---------------------------------------- 1 file changed, 1 insertion(+), 98 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 53f38ff306..bfba69a974 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -424,103 +424,6 @@ qemuBuildDeviceAddressPCIGetBus(const virDomainDef *domainDef, } -static int -qemuBuildDeviceAddressPCIStr(virBuffer *buf, - const virDomainDef *domainDef, - virDomainDeviceInfo *info) -{ - g_autofree char *bus = NULL; - - if (!(bus = qemuBuildDeviceAddressPCIGetBus(domainDef, info))) - return -1; - - virBufferStrcat(buf, ",bus=", bus, NULL); - - if (info->addr.pci.multi == VIR_TRISTATE_SWITCH_ON) - virBufferAddLit(buf, ",multifunction=on"); - else if (info->addr.pci.multi == VIR_TRISTATE_SWITCH_OFF) - virBufferAddLit(buf, ",multifunction=off"); - - virBufferAsprintf(buf, ",addr=0x%x", info->addr.pci.slot); - - if (info->addr.pci.function != 0) - virBufferAsprintf(buf, ".0x%x", info->addr.pci.function); - - if (info->acpiIndex != 0) - virBufferAsprintf(buf, ",acpi-index=%u", info->acpiIndex); - - return 0; -} - - -static int G_GNUC_UNUSED -qemuBuildDeviceAddressStr(virBuffer *buf, - const virDomainDef *domainDef, - virDomainDeviceInfo *info) -{ - const char *contAlias = NULL; - - switch ((virDomainDeviceAddressType)info->type) { - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: - if (qemuBuildDeviceAddressPCIStr(buf, domainDef, info) < 0) - return -1; - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: - if (!(contAlias = virDomainControllerAliasFind(domainDef, - VIR_DOMAIN_CONTROLLER_TYPE_USB, - info->addr.usb.bus))) - return -1; - virBufferAsprintf(buf, ",bus=%s.0", contAlias); - if (virDomainUSBAddressPortIsValid(info->addr.usb.port)) { - virBufferAddLit(buf, ",port="); - virDomainUSBAddressPortFormatBuf(buf, info->addr.usb.port); - } - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO: - if (info->addr.spaprvio.has_reg) - virBufferAsprintf(buf, ",reg=0x%08llx", info->addr.spaprvio.reg); - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: - if (info->addr.ccw.assigned) - virBufferAsprintf(buf, ",devno=%x.%x.%04x", - info->addr.ccw.cssid, - info->addr.ccw.ssid, - info->addr.ccw.devno); - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA: - virBufferAsprintf(buf, ",iobase=0x%x,irq=0x%x", - info->addr.isa.iobase, - info->addr.isa.irq); - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM: - virBufferAsprintf(buf, ",slot=%d", info->addr.dimm.slot); - if (info->addr.dimm.base) - virBufferAsprintf(buf, ",addr=%llu", info->addr.dimm.base); - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED: - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST: - virReportEnumRangeError(virDomainDeviceAddressType, info->type); - return -1; - } - - return 0; -} - - static int qemuBuildDeviceAddresDriveProps(virJSONValue *props, const virDomainDef *domainDef, @@ -657,7 +560,7 @@ qemuBuildDeviceAddresDriveProps(virJSONValue *props, } -static int G_GNUC_UNUSED +static int qemuBuildDeviceAddressProps(virJSONValue *props, const virDomainDef *domainDef, virDomainDeviceInfo *info) -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
All users were converted to the JSON counterpart.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 99 +---------------------------------------- 1 file changed, 1 insertion(+), 98 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (3)
-
Ján Tomko
-
Kristina Hanicova
-
Peter Krempa