]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
3 years agoqemu: correctly pass qemuBuildVHostUserFsDevProps
Ján Tomko [Tue, 12 Oct 2021 13:31:22 +0000 (15:31 +0200)]
qemu: correctly pass qemuBuildVHostUserFsDevProps

../../work/libvirt/src/qemu/qemu_hotplug.c: In function ‘qemuDomainAttachFSDevice’:
../../work/libvirt/src/qemu/qemu_hotplug.c:3458:68: error: ordered comparison of pointer with integer zero [-Werror=extra]
 3458 |     if (qemuBuildVHostUserFsDevProps(fs, vm->def, charAlias, priv) < 0)
      |                                                                    ^
cc1: all warnings being treated as errors

Fixes: b98787303498cfb8426ab27ee62247b164101242
Signed-off-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: implement virtiofs hotunplug
Ján Tomko [Tue, 5 Oct 2021 16:21:09 +0000 (18:21 +0200)]
qemu: implement virtiofs hotunplug

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: implement virtiofs hotplug
Ján Tomko [Tue, 5 Oct 2021 14:25:38 +0000 (16:25 +0200)]
qemu: implement virtiofs hotplug

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemucapabilitiestest: Add test data for the qemu-6.2 development cycle
Peter Krempa [Fri, 10 Sep 2021 08:52:12 +0000 (10:52 +0200)]
qemucapabilitiestest: Add test data for the qemu-6.2 development cycle

The data is based on commit v6.1.0-1313-gc09124dcb8

Notable changes:

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: Revert "qemuExtDevicesStart: pass logManager"
Ján Tomko [Wed, 6 Oct 2021 09:48:38 +0000 (11:48 +0200)]
qemu: Revert "qemuExtDevicesStart: pass logManager"

This reverts commit b164eac5e1d4ebe17e673f0427b70f862a670f94

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: virtiofs: open a separate connection to virtlogd
Ján Tomko [Wed, 6 Oct 2021 09:33:08 +0000 (11:33 +0200)]
qemu: virtiofs: open a separate connection to virtlogd

Do not depend on passing a logManager. Create a new connection.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agologging: define cleanup func for virLogManager
Ján Tomko [Wed, 6 Oct 2021 09:32:40 +0000 (11:32 +0200)]
logging: define cleanup func for virLogManager

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: command: Remove unused 'qemuBuildDeviceAddressStr'
Peter Krempa [Tue, 5 Oct 2021 16:54:12 +0000 (18:54 +0200)]
qemu: command: Remove unused 'qemuBuildDeviceAddressStr'

All users were converted to the JSON counterpart.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildTPMCommandLine: Generate via JSON
Peter Krempa [Tue, 5 Oct 2021 16:51:54 +0000 (18:51 +0200)]
qemuBuildTPMCommandLine: Generate via JSON

We control only the 'tpmdev' property of TPM devices which is a string.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildHubCommandLine: Generate via JSON
Peter Krempa [Tue, 5 Oct 2021 16:47:16 +0000 (18:47 +0200)]
qemuBuildHubCommandLine: Generate via JSON

The 'usb-hub' device doesn't have any special properties.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildSoundCommandLine: Generate codecs via JSON
Peter Krempa [Tue, 5 Oct 2021 16:42:39 +0000 (18:42 +0200)]
qemuBuildSoundCommandLine: Generate codecs via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildSoundCommandLine: Generate via JSON
Peter Krempa [Tue, 5 Oct 2021 16:35:36 +0000 (18:35 +0200)]
qemuBuildSoundCommandLine: Generate via JSON

The sound devices have only the 'audiodev' property which is a string.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Command remove unused 'qemuBuildVirtioDevStr'
Peter Krempa [Tue, 5 Oct 2021 16:28:33 +0000 (18:28 +0200)]
qemu: Command remove unused 'qemuBuildVirtioDevStr'

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildVideoCommandLine: Generate via JSON
Peter Krempa [Tue, 5 Oct 2021 15:04:40 +0000 (17:04 +0200)]
qemuBuildVideoCommandLine: Generate via JSON

We control the following properties of the devices in question:

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

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

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

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

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

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

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildFSDevCommandLine: Generate via JSON
Peter Krempa [Tue, 5 Oct 2021 14:30:27 +0000 (16:30 +0200)]
qemuBuildFSDevCommandLine: Generate via JSON

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildVHostUserFsCommandLine: Generate via JSON
Peter Krempa [Tue, 5 Oct 2021 14:23:19 +0000 (16:23 +0200)]
qemuBuildVHostUserFsCommandLine: Generate via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: monitor: Remove legacy 'device_add' infrastrcture
Peter Krempa [Tue, 5 Oct 2021 14:14:06 +0000 (16:14 +0200)]
qemu: monitor: Remove legacy 'device_add' infrastrcture

Remove the old-style 'device_add' helpers which parse the commandline
arguments to JSON since we now coverted all usage to use JSON directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildVsockCommandLine: Generate via JSON
Peter Krempa [Tue, 5 Oct 2021 13:39:42 +0000 (15:39 +0200)]
qemuBuildVsockCommandLine: Generate via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildHostdevCommandLine: Generate via JSON
Peter Krempa [Tue, 5 Oct 2021 13:39:42 +0000 (15:39 +0200)]
qemuBuildHostdevCommandLine: Generate via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildChrDeviceCommandLine: Generate via JSON
Peter Krempa [Tue, 5 Oct 2021 13:24:58 +0000 (15:24 +0200)]
qemuBuildChrDeviceCommandLine: Generate via JSON

Build commandlines for character devices via JSON.

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

  nr=<uint32>            -  (default: 4294967295)

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildControllersByTypeCommandLine: Generate via JSON
Peter Krempa [Tue, 5 Oct 2021 12:27:36 +0000 (14:27 +0200)]
qemuBuildControllersByTypeCommandLine: Generate via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildUSBControllerDevStr: Format via JSON properties.
Peter Krempa [Tue, 5 Oct 2021 11:46:03 +0000 (13:46 +0200)]
qemuBuildUSBControllerDevStr: Format via JSON properties.

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildUSBControllerDevStr: Split out validation of USB controller
Peter Krempa [Tue, 5 Oct 2021 11:02:02 +0000 (13:02 +0200)]
qemuBuildUSBControllerDevStr: Split out validation of USB controller

Move the validation code into a separate function. For now the
validation is still kept in the commandline format step as simply just
moving it to the validator causes failures in the test suite, which will
need to be investigated deeper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildControllerPCIDevStr: Format via JSON properties
Peter Krempa [Mon, 4 Oct 2021 21:07:44 +0000 (23:07 +0200)]
qemuBuildControllerPCIDevStr: Format via JSON properties

Internally format the PCI controller properties into JSON, but convert
it back to a string so that we for now change just the SCSI controller.

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

QEMU expects the following types:

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

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

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildControllerSCSIDevStr: Format via JSON properties
Peter Krempa [Mon, 4 Oct 2021 20:53:48 +0000 (22:53 +0200)]
qemuBuildControllerSCSIDevStr: Format via JSON properties

Internally format the SCSI controller properties into JSON, but convert
it back to a string so that we for now change just the SCSI controller.

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

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

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

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

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildControllerDevStr: Split out formatting of PCI controller
Peter Krempa [Mon, 4 Oct 2021 20:27:12 +0000 (22:27 +0200)]
qemuBuildControllerDevStr: Split out formatting of PCI controller

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildControllerDevStr: Split out formatting of SCSI controller
Peter Krempa [Mon, 4 Oct 2021 20:27:12 +0000 (22:27 +0200)]
qemuBuildControllerDevStr: Split out formatting of SCSI controller

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: command: Remove unused qemuBuildRomStr
Peter Krempa [Mon, 4 Oct 2021 16:04:12 +0000 (18:04 +0200)]
qemu: command: Remove unused qemuBuildRomStr

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildNicDevProps: Move formatting of bootindex
Peter Krempa [Mon, 4 Oct 2021 15:57:29 +0000 (17:57 +0200)]
qemuBuildNicDevProps: Move formatting of bootindex

Move the bootindex before the address so that the code is simpler.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildInterfaceCommandLine: Generate via JSON
Peter Krempa [Mon, 4 Oct 2021 15:52:03 +0000 (17:52 +0200)]
qemuBuildInterfaceCommandLine: Generate via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildDiskCommandLine: Generate via JSON
Peter Krempa [Mon, 4 Oct 2021 14:54:54 +0000 (16:54 +0200)]
qemuBuildDiskCommandLine: Generate via JSON

The types for the special fields of the 'virtio-blk-pci' according to
QEMU are:
  iothread=<link<iothread>>
  ioeventfd=<bool>       - on/off (default: true)
  event_idx=<bool>       - on/off (default: true)
  scsi=<bool>            - on/off (default: false)
  num-queues=<uint16>    -  (default: 65535)
  queue-size=<uint16>    -  (default: 256)

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

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildDiskFrontendAttributeErrorPolicy: Extract logic
Peter Krempa [Mon, 4 Oct 2021 14:56:54 +0000 (16:56 +0200)]
qemuBuildDiskFrontendAttributeErrorPolicy: Extract logic

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: capabilities: Retire QEMU_CAPS_VIRTIO_(BLK|NET)_EVENT_IDX
Peter Krempa [Mon, 4 Oct 2021 13:39:07 +0000 (15:39 +0200)]
qemu: capabilities: Retire QEMU_CAPS_VIRTIO_(BLK|NET)_EVENT_IDX

Both are assumed as always present since last commit.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Always assume presence of QEMU_CAPS_VIRTIO_(BLK|NET)_EVENT_IDX
Peter Krempa [Mon, 4 Oct 2021 13:34:26 +0000 (15:34 +0200)]
qemu: Always assume presence of QEMU_CAPS_VIRTIO_(BLK|NET)_EVENT_IDX

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: capabilities: Retire QEMU_CAPS_VIRTIO_IOEVENTFD
Peter Krempa [Mon, 4 Oct 2021 13:19:32 +0000 (15:19 +0200)]
qemu: capabilities: Retire QEMU_CAPS_VIRTIO_IOEVENTFD

It's not used since last commit.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildIoEventFdStr: Always assume support for QEMU_CAPS_VIRTIO_IOEVENTFD
Peter Krempa [Mon, 4 Oct 2021 13:17:35 +0000 (15:17 +0200)]
qemuBuildIoEventFdStr: Always assume support for QEMU_CAPS_VIRTIO_IOEVENTFD

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildSCSIHostdevDevProps: Reorder 'drive','id' and 'bootindex' after address
Peter Krempa [Mon, 4 Oct 2021 12:55:05 +0000 (14:55 +0200)]
qemuBuildSCSIHostdevDevProps: Reorder 'drive','id' and 'bootindex' after address

Simplify the generator by shuffling around few fields.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildHostdevSCSICommandLine: Generate via JSON
Peter Krempa [Mon, 4 Oct 2021 12:53:33 +0000 (14:53 +0200)]
qemuBuildHostdevSCSICommandLine: Generate via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: validate: Move disk address validation code
Peter Krempa [Mon, 4 Oct 2021 12:44:09 +0000 (14:44 +0200)]
qemu: validate: Move disk address validation code

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildDeviceAddressProps: Format also 'drive' addresses
Peter Krempa [Mon, 4 Oct 2021 08:59:58 +0000 (10:59 +0200)]
qemuBuildDeviceAddressProps: Format also 'drive' addresses

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildPCIHostdevDevProps: Move 'failover_pair_id' property before address
Peter Krempa [Wed, 6 Oct 2021 15:04:48 +0000 (17:04 +0200)]
qemuBuildPCIHostdevDevProps: Move 'failover_pair_id' property before address

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildHostdevCommandLine: Format PCI host devices via JSON
Peter Krempa [Fri, 1 Oct 2021 20:28:59 +0000 (22:28 +0200)]
qemuBuildHostdevCommandLine: Format PCI host devices via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuCommandAddExtDevice: Generate via JSON
Peter Krempa [Fri, 1 Oct 2021 12:07:37 +0000 (14:07 +0200)]
qemuCommandAddExtDevice: Generate via JSON

Generate the 'zpci' device via JSON.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildInputCommandLine: Generate via JSON
Peter Krempa [Fri, 1 Oct 2021 11:16:15 +0000 (13:16 +0200)]
qemuBuildInputCommandLine: Generate via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildRedirdevCommandLine: Generate via JSON
Peter Krempa [Fri, 1 Oct 2021 10:58:40 +0000 (12:58 +0200)]
qemuBuildRedirdevCommandLine: Generate via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildHostdevMediatedDevProps: Format USB host devices via JSON
Peter Krempa [Fri, 1 Oct 2021 09:24:04 +0000 (11:24 +0200)]
qemuBuildHostdevMediatedDevProps: Format USB host devices via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildHostdevMediatedDevProps: Move 'ramfb' and 'bootindex' before the address
Peter Krempa [Wed, 6 Oct 2021 14:36:41 +0000 (16:36 +0200)]
qemuBuildHostdevMediatedDevProps: Move 'ramfb' and 'bootindex' before the address

Simplify the generator by moving few properties earlier.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildHostdevCommandLine: Build mediated device commandline via JSON
Peter Krempa [Fri, 1 Oct 2021 08:17:01 +0000 (10:17 +0200)]
qemuBuildHostdevCommandLine: Build mediated device commandline via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildRNGCommandLine: Generate via JSON
Peter Krempa [Thu, 30 Sep 2021 16:07:29 +0000 (18:07 +0200)]
qemuBuildRNGCommandLine: Generate via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildMemballoonCommandLine: Reorder properties
Peter Krempa [Wed, 6 Oct 2021 14:18:37 +0000 (16:18 +0200)]
qemuBuildMemballoonCommandLine: Reorder properties

Move the 'deflate-on-oom' and 'free-page-reporting' before the address
to simplify the genrator code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildMemballoonCommandLine: Generate via JSON
Peter Krempa [Thu, 30 Sep 2021 15:55:49 +0000 (17:55 +0200)]
qemuBuildMemballoonCommandLine: Generate via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildShmemCommandLine: Generate via JSON
Peter Krempa [Mon, 27 Sep 2021 17:26:32 +0000 (19:26 +0200)]
qemuBuildShmemCommandLine: Generate via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildMemoryDeviceCommandLine: Generate via JSON
Peter Krempa [Mon, 27 Sep 2021 16:44:28 +0000 (18:44 +0200)]
qemuBuildMemoryDeviceCommandLine: Generate via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildWatchdogCommandLine: Generate via JSON
Peter Krempa [Mon, 27 Sep 2021 12:37:48 +0000 (14:37 +0200)]
qemuBuildWatchdogCommandLine: Generate via JSON

The watchdog doesn't have any special properties.

Convert the command line generator and hotplug code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildPanicCommandLine: Generate via JSON
Peter Krempa [Fri, 26 Mar 2021 09:09:45 +0000 (10:09 +0100)]
qemuBuildPanicCommandLine: Generate via JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: command: Introduce JSON variant of qemuBuildRomProps
Peter Krempa [Fri, 1 Oct 2021 20:18:39 +0000 (22:18 +0200)]
qemu: command: Introduce JSON variant of qemuBuildRomProps

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: command: Introduce helper for building JSON props of -device into commandline
Peter Krempa [Sat, 25 Sep 2021 07:08:05 +0000 (09:08 +0200)]
qemu: command: Introduce helper for building JSON props of -device into commandline

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: command: Introduce JSON variant of qemuBuildVirtioDevStr
Peter Krempa [Thu, 30 Sep 2021 15:55:45 +0000 (17:55 +0200)]
qemu: command: Introduce JSON variant of qemuBuildVirtioDevStr

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: validate: Move validation of device rom
Peter Krempa [Fri, 1 Oct 2021 14:47:12 +0000 (16:47 +0200)]
qemu: validate: Move validation of device rom

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuValidateDomainDeviceDef: Avoid unneded variable and 'break' statements
Peter Krempa [Fri, 1 Oct 2021 15:11:25 +0000 (17:11 +0200)]
qemuValidateDomainDeviceDef: Avoid unneded variable and 'break' statements

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuValidateDomainDeviceDef: Optimize virDomainDeviceInfo validation
Peter Krempa [Fri, 1 Oct 2021 15:06:27 +0000 (17:06 +0200)]
qemuValidateDomainDeviceDef: Optimize virDomainDeviceInfo validation

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainDeviceGetInfo: Make argument const
Peter Krempa [Fri, 1 Oct 2021 14:57:31 +0000 (16:57 +0200)]
virDomainDeviceGetInfo: Make argument const

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Clean up after old-style passing of 'bootIndex' to network devices
Peter Krempa [Fri, 1 Oct 2021 14:24:08 +0000 (16:24 +0200)]
qemu: Clean up after old-style passing of 'bootIndex' to network devices

Remove the now unused boot-index related attributes and the code which
is assigning it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Use 'effectiveBootIndex' to handle <os><boot dev='network'>
Peter Krempa [Fri, 1 Oct 2021 14:18:13 +0000 (16:18 +0200)]
qemu: Use 'effectiveBootIndex' to handle <os><boot dev='network'>

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: process: Make qemuProcessPrepareDomainDiskBootorder more universal
Peter Krempa [Fri, 1 Oct 2021 13:22:17 +0000 (15:22 +0200)]
qemu: process: Make qemuProcessPrepareDomainDiskBootorder more universal

Rename it to 'qemuProcessPrepareDeviceBootorder' and call it from
'qemuProcessPrepareDomain' rather than
'qemuProcessPrepareDomainStorage'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: Introduce 'effectiveBootIndex' into 'virDomainDeviceInfo'
Peter Krempa [Fri, 1 Oct 2021 13:16:57 +0000 (15:16 +0200)]
conf: Introduce 'effectiveBootIndex' into 'virDomainDeviceInfo'

'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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildDeviceVideoStr: Properly format virtio options for 'virtio-vga'
Peter Krempa [Thu, 30 Sep 2021 15:36:35 +0000 (17:36 +0200)]
qemuBuildDeviceVideoStr: Properly format virtio options for 'virtio-vga'

'virtio-vga' is a virtio device but we didn't use the virtio formatter
for it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildVirtioOptionsStr: Remove empty function
Peter Krempa [Thu, 30 Sep 2021 15:35:43 +0000 (17:35 +0200)]
qemuBuildVirtioOptionsStr: Remove empty function

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildVirtioDevStr: Format also virtioOptions
Peter Krempa [Thu, 30 Sep 2021 15:31:27 +0000 (17:31 +0200)]
qemuBuildVirtioDevStr: Format also virtioOptions

Merge the code from qemuBuildVirtioOptionsStr so that we don't have to
call two separate functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildVirtioDevStr: Remove 'baseName' argument
Peter Krempa [Thu, 30 Sep 2021 15:27:35 +0000 (17:27 +0200)]
qemuBuildVirtioDevStr: Remove 'baseName' argument

The code doesn't need the name as it determines it internally. Remove
the argument and fix all callers. In certain cases it led to
simplification of the logic.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildVirtioDevGetConfigDev: Provide more information
Peter Krempa [Thu, 30 Sep 2021 11:27:13 +0000 (13:27 +0200)]
qemuBuildVirtioDevGetConfigDev: Provide more information

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildVirtioDevGetConfig: Split up formatting of bus suffix
Peter Krempa [Thu, 30 Sep 2021 15:06:02 +0000 (17:06 +0200)]
qemuBuildVirtioDevGetConfig: Split up formatting of bus suffix

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDeviceVideoGetModel: Move to the beginning
Peter Krempa [Thu, 30 Sep 2021 14:44:23 +0000 (16:44 +0200)]
qemuDeviceVideoGetModel: Move to the beginning

The function is static and will be needed in the virtio device config
helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDeviceVideoGetModel: Clarify 'virtio' argument
Peter Krempa [Thu, 30 Sep 2021 14:39:59 +0000 (16:39 +0200)]
qemuDeviceVideoGetModel: Clarify 'virtio' argument

The 'virtio' 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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildVirtioDevGetConfig: Split out per device type code
Peter Krempa [Thu, 30 Sep 2021 08:59:03 +0000 (10:59 +0200)]
qemuBuildVirtioDevGetConfig: Split out per device type code

Split out the function a bit more to separate the per-device code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildVirtioDevStr: Extract code for determining device model
Peter Krempa [Thu, 30 Sep 2021 08:29:35 +0000 (10:29 +0200)]
qemuBuildVirtioDevStr: Extract code for determining device model

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildVirtioDevStr: Don't return early
Peter Krempa [Thu, 30 Sep 2021 08:18:23 +0000 (10:18 +0200)]
qemuBuildVirtioDevStr: Don't return early

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: command: Introduce JSON equivalent of qemuBuildDeviceAddressStr
Peter Krempa [Fri, 26 Mar 2021 14:43:14 +0000 (15:43 +0100)]
qemu: command: Introduce JSON equivalent of qemuBuildDeviceAddressStr

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildDeviceAddressPCIStr: Extract PCI bus name lookup
Peter Krempa [Fri, 26 Mar 2021 13:31:26 +0000 (14:31 +0100)]
qemuBuildDeviceAddressPCIStr: Extract PCI bus name lookup

Split up the bus lookup into a function called
'qemuBuildDeviceAddressPCIGetBus'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildDeviceAddressPCIStr: Make error messages easier to find
Peter Krempa [Sat, 25 Sep 2021 07:38:35 +0000 (09:38 +0200)]
qemuBuildDeviceAddressPCIStr: Make error messages easier to find

Per coding guidelines error messages [1] should not be broken into
lines and variables should be separated by apostrophes.

[1] https://libvirt.org/coding-style.html#error-message-format

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildDeviceAddressStr: Split out formatting of PCI address
Peter Krempa [Tue, 16 Mar 2021 13:47:43 +0000 (14:47 +0100)]
qemuBuildDeviceAddressStr: Split out formatting of PCI address

The PCI address case grew massive over time. Split it out into a new
function qemuBuildDeviceAddressPCIStr.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBlockStorageSourceAttachRollback: Sanitize warning messages
Peter Krempa [Fri, 1 Oct 2021 11:46:53 +0000 (13:46 +0200)]
qemuBlockStorageSourceAttachRollback: Sanitize warning messages

Mention the QMP command 'device_add' rather than 'qemuMonitorAddDevice'
and remove the weird formatting.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirQEMUBuildCommandLineJSONRecurse: Error out when array conversion function is not...
Peter Krempa [Sat, 25 Sep 2021 07:04:55 +0000 (09:04 +0200)]
virQEMUBuildCommandLineJSONRecurse: Error out when array conversion function is not provided

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirQEMUBuildCommandLineJSONIterate: Simplify logic
Peter Krempa [Sat, 25 Sep 2021 07:01:52 +0000 (09:01 +0200)]
virQEMUBuildCommandLineJSONIterate: Simplify logic

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONAddDeviceProps: Refactor cleanup
Peter Krempa [Sat, 25 Sep 2021 06:34:48 +0000 (08:34 +0200)]
qemuMonitorJSONAddDeviceProps: Refactor cleanup

Use automatic memory freeing and remove 'ret' variable and 'cleanup'
label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Rename 'qemuMonitorAddDeviceArgs' to 'qemuMonitorAddDeviceProps'
Peter Krempa [Wed, 24 Mar 2021 10:07:56 +0000 (11:07 +0100)]
qemu: Rename 'qemuMonitorAddDeviceArgs' to 'qemuMonitorAddDeviceProps'

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainHotplugAddVcpu: Refactor cleanup
Peter Krempa [Wed, 24 Mar 2021 09:58:13 +0000 (10:58 +0100)]
qemuDomainHotplugAddVcpu: Refactor cleanup

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Move watchdog model validation into the validation code
Peter Krempa [Tue, 16 Mar 2021 16:12:40 +0000 (17:12 +0100)]
qemu: Move watchdog model validation into the validation code

Report the error from 'qemuValidateDomainWatchdogDef' rather than
'qemuBuildWatchdogDevStr'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2xmltest: Remove 'panic-isa' case
Peter Krempa [Fri, 26 Mar 2021 15:23:34 +0000 (16:23 +0100)]
qemuxml2xmltest: Remove 'panic-isa' case

The same test in regards to the 'panic' device is the 'panic-double'
case, thus panic-isa can be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2argvtest: Convert 'panic' test cases to DO_TEST_CAPS_LATEST
Peter Krempa [Fri, 26 Mar 2021 15:21:19 +0000 (16:21 +0100)]
qemuxml2argvtest: Convert 'panic' test cases to DO_TEST_CAPS_LATEST

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agotests: qemuxml2argv: Test also the i6300esb watchdog
Peter Krempa [Thu, 25 Mar 2021 17:07:07 +0000 (18:07 +0100)]
tests: qemuxml2argv: Test also the i6300esb watchdog

Convert one of the tests to a different device.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agotests: qemuxml2argv: Convert watchdog tests on x86_64 to DO_TEST_CAPS_LATEST
Peter Krempa [Thu, 25 Mar 2021 17:23:19 +0000 (18:23 +0100)]
tests: qemuxml2argv: Convert watchdog tests on x86_64 to DO_TEST_CAPS_LATEST

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: capabilities: Introduce QEMU_CAPS_DEVICE_JSON
Peter Krempa [Fri, 24 Sep 2021 17:02:28 +0000 (19:02 +0200)]
qemu: capabilities: Introduce QEMU_CAPS_DEVICE_JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: capabilities: Introduce QEMU_CAPS_CHARDEV_JSON
Peter Krempa [Fri, 24 Sep 2021 17:08:12 +0000 (19:08 +0200)]
qemu: capabilities: Introduce QEMU_CAPS_CHARDEV_JSON

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirCommandGetArgList: Remove 'nargs' argument
Peter Krempa [Fri, 24 Sep 2021 11:32:16 +0000 (13:32 +0200)]
virCommandGetArgList: Remove 'nargs' argument

The returned argument list is a NULL-terminated string list and the only
caller doesn't use the count. Remove the argument.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2argvtest: Refactor QAPI schema validation code
Peter Krempa [Fri, 24 Sep 2021 11:28:57 +0000 (13:28 +0200)]
qemuxml2argvtest: Refactor QAPI schema validation code

Prevent duplication of code when extending the validator for new
commands. Add a struct describing a command to validate and make the
validation loop a bit more robust to corner cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirQEMUBuildDriveCommandlineFromJSON: Open-code in callers
Peter Krempa [Wed, 24 Mar 2021 13:00:07 +0000 (14:00 +0100)]
virQEMUBuildDriveCommandlineFromJSON: Open-code in callers

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Remove 'qemuBuildCommandLineFlags' and associated code
Peter Krempa [Fri, 24 Sep 2021 17:15:22 +0000 (19:15 +0200)]
qemu: Remove 'qemuBuildCommandLineFlags' and associated code

The -netdev formatter code switched to a real virQEMUCaps flag so we can
remove the old flags which used to enable JSON for -netdev for
validation purposes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirQEMUBuildNetdevCommandlineFromJSON: Remove unused formatter
Peter Krempa [Fri, 24 Sep 2021 17:00:22 +0000 (19:00 +0200)]
virQEMUBuildNetdevCommandlineFromJSON: Remove unused formatter

Now that everything was replaced by the new code we can remove this
function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: command: Format netdev as JSON when QEMU_CAPS_NETDEV_JSON is present
Peter Krempa [Fri, 24 Sep 2021 16:47:59 +0000 (18:47 +0200)]
qemu: command: Format netdev as JSON when QEMU_CAPS_NETDEV_JSON is present

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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>