mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 01:18:00 +03:00
qemu: command line generation for vfio-ccw device
Generates the QEMU command line for the vfio-ccw device. Adds various functionality testing for vfio-ccw in libvirt: 1. Generation of QEMU command line from domain xml file 2. Generation of dump xml from domain xml file 3. Checks duplicate/invalid addresses for vfio-ccw devices. Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com> Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
7224144400
commit
21442874cf
@ -5103,11 +5103,17 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def,
|
||||
virDomainHostdevSubsysMediatedDevPtr mdevsrc = &dev->source.subsys.u.mdev;
|
||||
char *ret = NULL;
|
||||
char *mdevPath = NULL;
|
||||
const char *dev_str = NULL;
|
||||
|
||||
if (!(mdevPath = virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr)))
|
||||
goto cleanup;
|
||||
|
||||
virBufferAddLit(&buf, "vfio-pci");
|
||||
dev_str = virMediatedDeviceModelTypeToString(mdevsrc->model);
|
||||
|
||||
if (!dev_str)
|
||||
goto cleanup;
|
||||
|
||||
virBufferAdd(&buf, dev_str, -1);
|
||||
virBufferAsprintf(&buf, ",id=%s,sysfsdev=%s", dev->info->alias, mdevPath);
|
||||
|
||||
if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
|
||||
@ -5327,11 +5333,28 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
|
||||
|
||||
/* MDEV */
|
||||
if (virHostdevIsMdevDevice(hostdev)) {
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("VFIO PCI device assignment is not "
|
||||
"supported by this version of qemu"));
|
||||
switch ((virMediatedDeviceModelType) subsys->u.mdev.model) {
|
||||
case VIR_MDEV_MODEL_TYPE_VFIO_PCI:
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("VFIO PCI device assignment is not "
|
||||
"supported by this version of QEMU"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case VIR_MDEV_MODEL_TYPE_VFIO_CCW:
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_CCW)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("VFIO CCW device assignment is not "
|
||||
"supported by this version of QEMU"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case VIR_MDEV_MODEL_TYPE_LAST:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unexpected vfio type '%d'"), subsys->u.mdev.model);
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
||||
virCommandAddArg(cmd, "-device");
|
||||
|
@ -0,0 +1,29 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>524288</memory>
|
||||
<currentMemory unit='KiB'>524288</currentMemory>
|
||||
<vcpu placement='static'>2</vcpu>
|
||||
<os>
|
||||
<type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-s390x</emulator>
|
||||
<hostdev mode='subsystem' type='mdev' model='vfio-ccw'>
|
||||
<source>
|
||||
<address uuid='90c6c135-ad44-41d0-b1b7-bae47de48627'/>
|
||||
</source>
|
||||
<address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
|
||||
</hostdev>
|
||||
<hostdev mode='subsystem' type='mdev' model='vfio-ccw'>
|
||||
<source>
|
||||
<address uuid='71b411af-5491-4100-b03e-0705e0b2eb27'/>
|
||||
</source>
|
||||
<address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
|
||||
</hostdev>
|
||||
</devices>
|
||||
</domain>
|
@ -0,0 +1,23 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>524288</memory>
|
||||
<currentMemory unit='KiB'>524288</currentMemory>
|
||||
<vcpu placement='static'>2</vcpu>
|
||||
<os>
|
||||
<type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-s390x</emulator>
|
||||
<hostdev mode='subsystem' type='mdev' model='vfio-ccw'>
|
||||
<source>
|
||||
<address uuid='90c6c135-ad44-41d0-b1b7-bae47de48627'/>
|
||||
</source>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||
</hostdev>
|
||||
</devices>
|
||||
</domain>
|
26
tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.args
Normal file
26
tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.args
Normal file
@ -0,0 +1,26 @@
|
||||
LC_ALL=C \
|
||||
PATH=/bin \
|
||||
HOME=/home/test \
|
||||
USER=test \
|
||||
LOGNAME=test \
|
||||
QEMU_AUDIO_DRV=none \
|
||||
/usr/bin/qemu-system-s390x \
|
||||
-name QEMUGuest1 \
|
||||
-S \
|
||||
-machine s390-ccw-virtio,accel=tcg,usb=off,dump-guest-core=off \
|
||||
-m 512 \
|
||||
-smp 2,sockets=2,cores=1,threads=1 \
|
||||
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
|
||||
-display none \
|
||||
-no-user-config \
|
||||
-nodefaults \
|
||||
-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
|
||||
server,nowait \
|
||||
-mon chardev=charmonitor,id=monitor,mode=control \
|
||||
-rtc base=utc \
|
||||
-no-shutdown \
|
||||
-boot c \
|
||||
-device vfio-ccw,id=hostdev0,\
|
||||
sysfsdev=/sys/bus/mdev/devices/90c6c135-ad44-41d0-b1b7-bae47de48627,\
|
||||
devno=fe.0.0000 \
|
||||
-device virtio-balloon-ccw,id=balloon0,devno=fe.0.0001
|
@ -1542,6 +1542,22 @@ mymain(void)
|
||||
DO_TEST("pci-rom-disabled", NONE);
|
||||
DO_TEST("pci-rom-disabled-invalid", NONE);
|
||||
|
||||
DO_TEST("hostdev-subsys-mdev-vfio-ccw",
|
||||
QEMU_CAPS_CCW,
|
||||
QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
|
||||
QEMU_CAPS_DEVICE_VFIO_CCW);
|
||||
DO_TEST_FAILURE("hostdev-subsys-mdev-vfio-ccw",
|
||||
QEMU_CAPS_CCW,
|
||||
QEMU_CAPS_CCW_CSSID_UNRESTRICTED);
|
||||
DO_TEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ccw-duplicate-address",
|
||||
QEMU_CAPS_CCW,
|
||||
QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
|
||||
QEMU_CAPS_DEVICE_VFIO_CCW);
|
||||
DO_TEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ccw-invalid-address",
|
||||
QEMU_CAPS_CCW,
|
||||
QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
|
||||
QEMU_CAPS_DEVICE_VFIO_CCW);
|
||||
|
||||
DO_TEST_FULL("restore-v2", "exec:cat", 7, 0, 0, GIC_NONE, NONE);
|
||||
DO_TEST_FULL("restore-v2-fd", "stdio", 7, 0, 0, GIC_NONE, NONE);
|
||||
DO_TEST_FULL("restore-v2-fd", "fd:7", 7, 0, 0, GIC_NONE, NONE);
|
||||
|
Loading…
Reference in New Issue
Block a user