]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
3 years agoqemu_driver: add required capabilities to qemuDomainGetStatsWorkers
Hiroki Narukawa [Fri, 15 Oct 2021 09:49:18 +0000 (18:49 +0900)]
qemu_driver: add required capabilities to qemuDomainGetStatsWorkers

One of qemuDomainGetStatsWorkers requires capabilities to run.

This commit adds capability information to qemuDomainGetStatsWorkers.

Signed-off-by: Hiroki Narukawa <hnarukaw@yahoo-corp.jp>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_capabilities: Add QEMU_CAPS_QUERY_DIRTY_RATE capability
Hiroki Narukawa [Fri, 15 Oct 2021 09:49:17 +0000 (18:49 +0900)]
qemu_capabilities: Add QEMU_CAPS_QUERY_DIRTY_RATE capability

query-dirty-rate command is used for virsh domstats by default, but this
is available only on qemu >=5.2.0.

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

Signed-off-by: Hiroki Narukawa <hnarukaw@yahoo-corp.jp>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: Do not report eof when processing monitor IO
Jim Fehlig [Wed, 6 Oct 2021 04:23:51 +0000 (22:23 -0600)]
qemu: Do not report eof when processing monitor IO

There have been countless reports from users concerned about the following
error reported by libvirtd when qemu domains are shutdown

internal error: End of file from qemu monitor

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

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

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirnetsocket: Use g_auto* more
Michal Privoznik [Fri, 15 Oct 2021 11:41:12 +0000 (13:41 +0200)]
virnetsocket: Use g_auto* more

There are few functions in virnetsocket.c where an object/memory
is freed by explicit call. Use g_autoptr()/g_autofree/VIR_AUTOCLOSE
to do that automatically.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirnetsocket: Don't free virCommand in virNetSocketNewConnectCommand()
Michal Privoznik [Fri, 15 Oct 2021 11:39:36 +0000 (13:39 +0200)]
virnetsocket: Don't free virCommand in virNetSocketNewConnectCommand()

The aim of virNetSocketNewConnectCommand() is to execute passed
command and attach socket pair/pipe to it so that client socket
can be opened (this is used for connections with alternative
transports, e.g. ssh). The virCommand is created in a caller and
then passed to virNetSocketNewConnectCommand() where it is freed
using virCommandFree(). This approach is wrong on two levels:

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

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu_validate: Fix capability check for disk queue_size
Hiroki Narukawa [Fri, 15 Oct 2021 10:11:49 +0000 (19:11 +0900)]
qemu_validate: Fix capability check for disk queue_size

Commit ad209e7d adds QEMU_CAPS_VIRTIO_BLK_QUEUE_SIZE capability, but
the following commit 2d6d67e1 missed to use it and uses
QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES instead.

This commit fixes the mistake.

Signed-off-by: Hiroki Narukawa <hnarukaw@yahoo-corp.jp>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: capabilities: Retire QEMU_CAPS_VIRTIO_PCI_ATS
Michal Privoznik [Fri, 15 Oct 2021 08:47:54 +0000 (10:47 +0200)]
qemu: capabilities: Retire QEMU_CAPS_VIRTIO_PCI_ATS

The capability reflects whether QEMU is capable of -device
virtio-*,ats=. Since the property was introduced in QEMU commit
v2.9.0-rc0~162^2~32 we can safely assume the property is always
present as the minimal version required is 2.11.0.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemuxml2argvtest: Drop negative virtio-*-ats tests
Michal Privoznik [Fri, 15 Oct 2021 08:56:34 +0000 (10:56 +0200)]
qemuxml2argvtest: Drop negative virtio-*-ats tests

There are some tests cases in qemuxml2argvtest that aim to check
whether our validator rejects <driver ats=''/> when
QEMU_CAPS_VIRTIO_PCI_ATS capability is not present.  Well, such
scenario can't happen really because the capability will always
be present.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: capabilities: Retire QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM
Michal Privoznik [Fri, 15 Oct 2021 07:48:48 +0000 (09:48 +0200)]
qemu: capabilities: Retire QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM

The capability reflects whether QEMU is capable of -device
virtio-*,iommu_platform=. Since the property was introduced in
QEMU commit v2.9.0-rc0~162^2~37 we can safely assume the property
is always present as the minimal version required is 2.11.0.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemuxml2argvtest: Drop negative virtio-*-iommu tests
Michal Privoznik [Fri, 15 Oct 2021 08:55:49 +0000 (10:55 +0200)]
qemuxml2argvtest: Drop negative virtio-*-iommu tests

There are some tests cases in qemuxml2argvtest that aim to check
whether our validator rejects <driver iommu=''/> when
QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM capability is not present.
Well, such scenario can't happen really because the capability
will always be present.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agotest: Drop unused .args or .xml files
Michal Privoznik [Fri, 15 Oct 2021 08:10:42 +0000 (10:10 +0200)]
test: Drop unused .args or .xml files

There are a few files containing expected output for test cases
that no longer exist. Remove them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: Add support for virtio device option page-per-vq
Han Han [Fri, 15 Oct 2021 06:09:30 +0000 (14:09 +0800)]
qemu: Add support for virtio device option page-per-vq

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

Signed-off-by: Han Han <hhan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoconf: Add page_per_vq for driver element
Han Han [Fri, 15 Oct 2021 06:09:29 +0000 (14:09 +0800)]
conf: Add page_per_vq for driver element

Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Gavi Teitz <gavi@nvidia.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_migration: drop unnecessary 'migrate_speed' variable
Kristina Hanicova [Fri, 8 Oct 2021 08:19:05 +0000 (10:19 +0200)]
qemu_migration: drop unnecessary 'migrate_speed' variable

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoqemu_migration: set bandwidth in priv during migration
Kristina Hanicova [Fri, 8 Oct 2021 08:19:04 +0000 (10:19 +0200)]
qemu_migration: set bandwidth in priv during migration

We did not set priv->migMaxBandwidth if '--bandwidth' was
specified as an option in the 'migrate' virsh command. This
caused in printing the wrong value if virsh command
'migrate-getspeed' was called during the migration. This patch
first sets the value to the given bandwidth (if one was
specified) and restores the previous value after the migration.

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

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoqemuBuildFloppyCommandLineControllerOptionsExplicit: Generate via JSON
Peter Krempa [Mon, 11 Oct 2021 19:45:25 +0000 (21:45 +0200)]
qemuBuildFloppyCommandLineControllerOptionsExplicit: Generate via JSON

QEMU declares the bootindex types as:

  bootindexA=<int32>
  bootindexB=<int32>

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildFloppyCommandLineControllerOptions: Extract formatting of implicit/explicit fdc
Peter Krempa [Mon, 11 Oct 2021 17:01:28 +0000 (19:01 +0200)]
qemuBuildFloppyCommandLineControllerOptions: Extract formatting of implicit/explicit fdc

qemuBuildFloppyCommandLineControllerOptions was generating config for
both the implicit and explicit fdc. The explicit FDC is using '-device'
and thus will need to be converted to JSON.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildSmartcardCommandLine: Generate via JSON
Peter Krempa [Mon, 11 Oct 2021 15:08:58 +0000 (17:08 +0200)]
qemuBuildSmartcardCommandLine: Generate via JSON

QEMU declares the props we control as:

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

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildIOMMUCommandLine: Generate via JSON
Peter Krempa [Mon, 11 Oct 2021 14:29:49 +0000 (16:29 +0200)]
qemuBuildIOMMUCommandLine: Generate via JSON

QEMU declares the following types for fields we control:

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildVMCoreInfoCommandLine: Generate via JSON
Peter Krempa [Mon, 11 Oct 2021 14:21:31 +0000 (16:21 +0200)]
qemuBuildVMCoreInfoCommandLine: Generate via JSON

While this device doesn't have any properties it must be converted to
use qemuBuildDeviceCommandlineFromJSON so that we can validate it in the
future.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildTPMProxyCommandLine: Generate via JSON
Peter Krempa [Mon, 11 Oct 2021 14:12:52 +0000 (16:12 +0200)]
qemuBuildTPMProxyCommandLine: Generate via JSON

All properties are strings according to QEMU.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildVMGenIDCommandLine: Generate via JSON
Peter Krempa [Mon, 11 Oct 2021 14:08:24 +0000 (16:08 +0200)]
qemuBuildVMGenIDCommandLine: Generate via JSON

QEMU declares the 'guid' property as:

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuValidateDomainSmartcardDef: Move validation of smartcard count
Peter Krempa [Mon, 11 Oct 2021 14:49:34 +0000 (16:49 +0200)]
qemuValidateDomainSmartcardDef: Move validation of smartcard count

Move it into the validator. Note that the placement into the device
validation part is intentional so that it also covers hotplug code
paths.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildSmartcardCommandLine: Replace qemuBuildSmartcardFindCCIDController
Peter Krempa [Mon, 11 Oct 2021 15:01:53 +0000 (17:01 +0200)]
qemuBuildSmartcardCommandLine: Replace qemuBuildSmartcardFindCCIDController

We have a commonly used helper virDomainControllerAliasFind, which does
the same thing and also reports errors internally.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainSmartcardDef: Declare 'type' as virDomainSmartcardType
Peter Krempa [Mon, 11 Oct 2021 14:47:59 +0000 (16:47 +0200)]
virDomainSmartcardDef: Declare 'type' as virDomainSmartcardType

Use 'virXMLPropEnum' to parse it and fix all switch statements which
didn't include the VIR_DOMAIN_SMARTCARD_TYPE_LAST case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuValidateDomainSmartcardDef: Move chardev validation under VIR_DOMAIN_SMARTCARD_TY...
Peter Krempa [Mon, 11 Oct 2021 14:37:56 +0000 (16:37 +0200)]
qemuValidateDomainSmartcardDef: Move chardev validation under VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH

Don't check the type twice, move the chardev validation into the
switch.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuValidateDomainSmartcardDef: Unbreak error messages
Peter Krempa [Mon, 11 Oct 2021 14:33:56 +0000 (16:33 +0200)]
qemuValidateDomainSmartcardDef: Unbreak error messages

https://www.libvirt.org/coding-style.html#error-message-format

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildDeviceCommandlineFromJSON: Remove unused keyword
Peter Krempa [Mon, 11 Oct 2021 14:23:51 +0000 (16:23 +0200)]
qemuBuildDeviceCommandlineFromJSON: Remove unused keyword

Now that the code was converted to use this helper we can remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildStorageSourceAttachPrepareDrive: Fix function comment
Peter Krempa [Mon, 11 Oct 2021 14:22:53 +0000 (16:22 +0200)]
qemuBuildStorageSourceAttachPrepareDrive: Fix function comment

Remove mention of argument which no longer exists.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agotools: add virt-host-validate-ch for ch driver
Praveen K Paladugu [Thu, 7 Oct 2021 21:49:37 +0000 (21:49 +0000)]
tools: add virt-host-validate-ch for ch driver

Signed-off-by: Wei-Chen Chen <weicche@microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agospec: change the ownership of cache directory
Peng Liang [Mon, 11 Oct 2021 11:47:20 +0000 (19:47 +0800)]
spec: change the ownership of cache directory

In a50c473ad6c9 ("qemu: move temp file of screenshot and memorypeek to
per-domain dir") and c4f3c955d578 ("qemu: don't change ownership of
cache directory"), I move the temporary files of screenshot and
memorypeek from the cache directory to per-domain directory, and the
only user of the cache directory is the domain capabilities currently.
Since the domain capabilities are used by libvirtd, no need to set the
ownership of the cache directory to qemu_user and qemu_group.

Signed-off-by: Peng Liang <liangpeng10@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agogitdm: Add other email into Red Hat company list
Julio Faracco [Mon, 11 Oct 2021 22:39:16 +0000 (19:39 -0300)]
gitdm: Add other email into Red Hat company list

Some people from Red Hat does not use 'redhat.com' domain emails.
They use personal or other domains.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
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>