提交 1219f0ca 编写于 作者: B Boris Fiuczynski 提交者: Ján Tomko

qemu: refactor mdev validation method signatures

Refactoring the method signatures in preparation for
checking boot index of the mediated devices.
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NMarc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: NBjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: NBoris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: NJán Tomko <jtomko@redhat.com>
上级 1aed9d84
...@@ -5190,10 +5190,13 @@ qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net) ...@@ -5190,10 +5190,13 @@ qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net)
static int static int
qemuDomainMdevDefVFIOPCIValidate(const virDomainHostdevSubsysMediatedDev *dev, qemuDomainMdevDefVFIOPCIValidate(const virDomainHostdevDef *hostdev,
const virDomainDef *def, const virDomainDef *def,
virQEMUCapsPtr qemuCaps) virQEMUCapsPtr qemuCaps)
{ {
const virDomainHostdevSubsysMediatedDev *dev;
dev = &hostdev->source.subsys.u.mdev;
if (dev->display == VIR_TRISTATE_SWITCH_ABSENT) if (dev->display == VIR_TRISTATE_SWITCH_ABSENT)
return 0; return 0;
...@@ -5226,17 +5229,18 @@ qemuDomainMdevDefVFIOPCIValidate(const virDomainHostdevSubsysMediatedDev *dev, ...@@ -5226,17 +5229,18 @@ qemuDomainMdevDefVFIOPCIValidate(const virDomainHostdevSubsysMediatedDev *dev,
static int static int
qemuDomainMdevDefVFIOAPValidate(const virDomainDef *def) qemuDomainMdevDefVFIOAPValidate(const virDomainHostdevDef *hostdev ATTRIBUTE_UNUSED,
const virDomainDef *def)
{ {
size_t i; size_t i;
bool vfioap_found = false; bool vfioap_found = false;
/* VFIO-AP is restricted to a single mediated device only */ /* VFIO-AP is restricted to a single mediated device only */
for (i = 0; i < def->nhostdevs; i++) { for (i = 0; i < def->nhostdevs; i++) {
virDomainHostdevDefPtr hostdev = def->hostdevs[i]; virDomainHostdevDefPtr hdev = def->hostdevs[i];
if (virHostdevIsMdevDevice(hostdev) && if (virHostdevIsMdevDevice(hdev) &&
hostdev->source.subsys.u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_AP) { hdev->source.subsys.u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_AP) {
if (vfioap_found) { if (vfioap_found) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Only one hostdev of model vfio-ap is " _("Only one hostdev of model vfio-ap is "
...@@ -5252,15 +5256,18 @@ qemuDomainMdevDefVFIOAPValidate(const virDomainDef *def) ...@@ -5252,15 +5256,18 @@ qemuDomainMdevDefVFIOAPValidate(const virDomainDef *def)
static int static int
qemuDomainMdevDefValidate(const virDomainHostdevSubsysMediatedDev *mdevsrc, qemuDomainMdevDefValidate(const virDomainHostdevDef *hostdev,
const virDomainDef *def, const virDomainDef *def,
virQEMUCapsPtr qemuCaps) virQEMUCapsPtr qemuCaps)
{ {
const virDomainHostdevSubsysMediatedDev *mdevsrc;
mdevsrc = &hostdev->source.subsys.u.mdev;
switch ((virMediatedDeviceModelType) mdevsrc->model) { switch ((virMediatedDeviceModelType) mdevsrc->model) {
case VIR_MDEV_MODEL_TYPE_VFIO_PCI: case VIR_MDEV_MODEL_TYPE_VFIO_PCI:
return qemuDomainMdevDefVFIOPCIValidate(mdevsrc, def, qemuCaps); return qemuDomainMdevDefVFIOPCIValidate(hostdev, def, qemuCaps);
case VIR_MDEV_MODEL_TYPE_VFIO_AP: case VIR_MDEV_MODEL_TYPE_VFIO_AP:
return qemuDomainMdevDefVFIOAPValidate(def); return qemuDomainMdevDefVFIOAPValidate(hostdev, def);
case VIR_MDEV_MODEL_TYPE_VFIO_CCW: case VIR_MDEV_MODEL_TYPE_VFIO_CCW:
break; break;
case VIR_MDEV_MODEL_TYPE_LAST: case VIR_MDEV_MODEL_TYPE_LAST:
...@@ -5279,8 +5286,6 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev, ...@@ -5279,8 +5286,6 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev,
const virDomainDef *def, const virDomainDef *def,
virQEMUCapsPtr qemuCaps) virQEMUCapsPtr qemuCaps)
{ {
const virDomainHostdevSubsysMediatedDev *mdevsrc;
/* forbid capabilities mode hostdev in this kind of hypervisor */ /* forbid capabilities mode hostdev in this kind of hypervisor */
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) { if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
...@@ -5311,8 +5316,7 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev, ...@@ -5311,8 +5316,7 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev,
"supported by mediated devices")); "supported by mediated devices"));
return -1; return -1;
} }
mdevsrc = &hostdev->source.subsys.u.mdev; return qemuDomainMdevDefValidate(hostdev, def, qemuCaps);
return qemuDomainMdevDefValidate(mdevsrc, def, qemuCaps);
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
default: default:
virReportEnumRangeError(virDomainHostdevSubsysType, virReportEnumRangeError(virDomainHostdevSubsysType,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册