mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
qemu: command: move qemuBuildHostdevCommandLine caps validation to qemu_domain
Move QEMU caps validation of qemuBuildHostdevCommandLine() to qemuDomainDeviceDefValidateHostdev() and qemuDomainMdevDefValidate(), allowing them to be validated at domain define time. Tests were adapted to consider the new caps being needed in this earlier stage. Reviewed-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
8ed79ecc88
commit
3d21545f6d
@ -5364,17 +5364,6 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
|
||||
/* PCI */
|
||||
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
||||
subsys->type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
|
||||
int backend = subsys->u.pci.backend;
|
||||
|
||||
if (backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int bootIndex = hostdev->info->bootIndex;
|
||||
|
||||
/* bootNet will be non-0 if boot order was set and no other
|
||||
@ -5457,29 +5446,8 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
|
||||
|
||||
switch ((virMediatedDeviceModelType) mdevsrc->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_VFIO_AP:
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_AP)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("VFIO AP device assignment is not "
|
||||
"supported by this version of QEMU"));
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case VIR_MDEV_MODEL_TYPE_LAST:
|
||||
default:
|
||||
|
@ -6109,6 +6109,13 @@ qemuDomainMdevDefVFIOPCIValidate(const virDomainHostdevDef *hostdev,
|
||||
{
|
||||
const virDomainHostdevSubsysMediatedDev *dev;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* VFIO-PCI does not support boot */
|
||||
if (hostdev->info->bootIndex) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
@ -6152,11 +6159,19 @@ qemuDomainMdevDefVFIOPCIValidate(const virDomainHostdevDef *hostdev,
|
||||
|
||||
static int
|
||||
qemuDomainMdevDefVFIOAPValidate(const virDomainHostdevDef *hostdev,
|
||||
const virDomainDef *def)
|
||||
const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
size_t i;
|
||||
bool vfioap_found = false;
|
||||
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_AP)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("VFIO AP device assignment is not "
|
||||
"supported by this version of QEMU"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* VFIO-AP does not support boot */
|
||||
if (hostdev->info->bootIndex) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
@ -6198,8 +6213,14 @@ qemuDomainMdevDefValidate(const virDomainHostdevDef *hostdev,
|
||||
case VIR_MDEV_MODEL_TYPE_VFIO_PCI:
|
||||
return qemuDomainMdevDefVFIOPCIValidate(hostdev, def, qemuCaps);
|
||||
case VIR_MDEV_MODEL_TYPE_VFIO_AP:
|
||||
return qemuDomainMdevDefVFIOAPValidate(hostdev, def);
|
||||
return qemuDomainMdevDefVFIOAPValidate(hostdev, def, qemuCaps);
|
||||
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:
|
||||
default:
|
||||
@ -6217,6 +6238,8 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev,
|
||||
const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
int backend;
|
||||
|
||||
/* forbid capabilities mode hostdev in this kind of hypervisor */
|
||||
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
@ -6229,9 +6252,22 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev,
|
||||
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
|
||||
switch ((virDomainHostdevSubsysType) hostdev->source.subsys.type) {
|
||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
|
||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
|
||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
|
||||
backend = hostdev->source.subsys.u.pci.backend;
|
||||
|
||||
if (backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
|
||||
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_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
|
||||
if (hostdev->info->bootIndex) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
|
@ -106,6 +106,18 @@ mymain(void)
|
||||
DO_TEST("pc-kvm", 0);
|
||||
DO_TEST("pc-tcg", 0);
|
||||
|
||||
if (!(qemuCaps = virQEMUCapsNew())) {
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI);
|
||||
|
||||
if (qemuTestCapsCacheInsert(driver.qemuCapsCache, qemuCaps) < 0) {
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
};
|
||||
|
||||
DO_TEST("pc-hardlimit", 2147483648);
|
||||
DO_TEST("pc-locked", VIR_DOMAIN_MEMORY_PARAM_UNLIMITED);
|
||||
DO_TEST("pc-hostdev", 2147483648);
|
||||
@ -116,10 +128,6 @@ mymain(void)
|
||||
DO_TEST("pc-locked+hostdev", VIR_DOMAIN_MEMORY_PARAM_UNLIMITED);
|
||||
|
||||
qemuTestSetHostArch(&driver, VIR_ARCH_PPC64);
|
||||
if (!(qemuCaps = virQEMUCapsNew())) {
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
|
||||
if (qemuTestCapsCacheInsert(driver.qemuCapsCache, qemuCaps) < 0) {
|
||||
|
@ -1638,9 +1638,9 @@ mymain(void)
|
||||
QEMU_CAPS_DEVICE_VFIO_CCW);
|
||||
DO_TEST_CAPS_ARCH_LATEST("hostdev-subsys-mdev-vfio-ccw-boot",
|
||||
"s390x");
|
||||
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",
|
||||
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,
|
||||
|
@ -405,7 +405,7 @@ mymain(void)
|
||||
DO_TEST("net-virtio-rxtxqueuesize", NONE);
|
||||
DO_TEST("net-hostdev", NONE);
|
||||
DO_TEST("net-hostdev-bootorder", NONE);
|
||||
DO_TEST("net-hostdev-vfio", NONE);
|
||||
DO_TEST("net-hostdev-vfio", QEMU_CAPS_DEVICE_VFIO_PCI);
|
||||
DO_TEST("net-midonet", NONE);
|
||||
DO_TEST("net-openvswitch", NONE);
|
||||
DO_TEST("sound", NONE);
|
||||
@ -432,9 +432,10 @@ mymain(void)
|
||||
|
||||
DO_TEST("hostdev-usb-address", NONE);
|
||||
DO_TEST("hostdev-pci-address", NONE);
|
||||
DO_TEST("hostdev-pci-multifunction", NONE);
|
||||
DO_TEST("hostdev-vfio", NONE);
|
||||
DO_TEST("hostdev-pci-multifunction", QEMU_CAPS_DEVICE_VFIO_PCI);
|
||||
DO_TEST("hostdev-vfio", QEMU_CAPS_DEVICE_VFIO_PCI);
|
||||
DO_TEST("hostdev-vfio-zpci",
|
||||
QEMU_CAPS_DEVICE_VFIO_PCI,
|
||||
QEMU_CAPS_DEVICE_ZPCI,
|
||||
QEMU_CAPS_CCW);
|
||||
DO_TEST("hostdev-vfio-zpci-multidomain-many",
|
||||
@ -448,10 +449,11 @@ mymain(void)
|
||||
QEMU_CAPS_DEVICE_VFIO_PCI,
|
||||
QEMU_CAPS_DEVICE_PCI_BRIDGE,
|
||||
QEMU_CAPS_DEVICE_ZPCI);
|
||||
DO_TEST("hostdev-mdev-precreated", NONE);
|
||||
DO_TEST("hostdev-mdev-precreated", QEMU_CAPS_DEVICE_VFIO_PCI);
|
||||
DO_TEST("hostdev-mdev-display",
|
||||
QEMU_CAPS_DEVICE_QXL,
|
||||
QEMU_CAPS_VFIO_PCI_DISPLAY);
|
||||
QEMU_CAPS_VFIO_PCI_DISPLAY,
|
||||
QEMU_CAPS_DEVICE_VFIO_PCI);
|
||||
DO_TEST("pci-rom", NONE);
|
||||
DO_TEST("pci-rom-disabled", NONE);
|
||||
DO_TEST("pci-rom-disabled-invalid", NONE);
|
||||
|
Loading…
Reference in New Issue
Block a user