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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Commit ffda44030a 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>