mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
enhance hostdev mode 'capabilities' process
Currently, only LXC has hostdev mode 'capabilities' support, so the other drivers should forbid to define it in XML. The hostdev mode check is added to devicesPostParseCallback() for each hypervisor driver. But there are some drivers lack function devicesPostParseCallback(), so only add check for qemu, libxl, openvz, uml, xen, xenapi. Signed-off-by: Jincheng Miao <jmiao@redhat.com>
This commit is contained in:
parent
9a39f50420
commit
01e508f33c
@ -485,6 +485,15 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
|||||||
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
|
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
|
||||||
virDomainHostdevDefPtr hostdev = dev->data.hostdev;
|
virDomainHostdevDefPtr hostdev = dev->data.hostdev;
|
||||||
|
|
||||||
|
/* forbid capabilities mode hostdev in this kind of hypervisor */
|
||||||
|
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("hostdev mode 'capabilities' is not "
|
||||||
|
"supported in %s"),
|
||||||
|
virDomainVirtTypeToString(def->virtType));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
||||||
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
|
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
|
||||||
hostdev->source.subsys.u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT)
|
hostdev->source.subsys.u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT)
|
||||||
|
@ -113,6 +113,16 @@ openvzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
|||||||
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)
|
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)
|
||||||
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ;
|
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ;
|
||||||
|
|
||||||
|
/* forbid capabilities mode hostdev in this kind of hypervisor */
|
||||||
|
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
|
||||||
|
dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("hostdev mode 'capabilities' is not "
|
||||||
|
"supported in %s"),
|
||||||
|
virDomainVirtTypeToString(def->virtType));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -940,6 +940,16 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
|||||||
dev->data.chr->source.data.nix.listen = true;
|
dev->data.chr->source.data.nix.listen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* forbid capabilities mode hostdev in this kind of hypervisor */
|
||||||
|
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
|
||||||
|
dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("hostdev mode 'capabilities' is not "
|
||||||
|
"supported in %s"),
|
||||||
|
virDomainVirtTypeToString(def->virtType));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -430,6 +430,16 @@ umlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
|||||||
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)
|
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)
|
||||||
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML;
|
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML;
|
||||||
|
|
||||||
|
/* forbid capabilities mode hostdev in this kind of hypervisor */
|
||||||
|
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
|
||||||
|
dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("hostdev mode 'capabilities' is not "
|
||||||
|
"supported in %s"),
|
||||||
|
virDomainVirtTypeToString(def->virtType));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,6 +343,16 @@ xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
|||||||
STRNEQ(def->os.type, "hvm"))
|
STRNEQ(def->os.type, "hvm"))
|
||||||
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
|
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
|
||||||
|
|
||||||
|
/* forbid capabilities mode hostdev in this kind of hypervisor */
|
||||||
|
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
|
||||||
|
dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("hostdev mode 'capabilities' is not "
|
||||||
|
"supported in %s"),
|
||||||
|
virDomainVirtTypeToString(def->virtType));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +55,16 @@ xenapiDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
|||||||
STRNEQ(def->os.type, "hvm"))
|
STRNEQ(def->os.type, "hvm"))
|
||||||
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
|
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
|
||||||
|
|
||||||
|
/* forbid capabilities mode hostdev in this kind of hypervisor */
|
||||||
|
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
|
||||||
|
dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("hostdev mode 'capabilities' is not "
|
||||||
|
"supported in %s"),
|
||||||
|
virDomainVirtTypeToString(def->virtType));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user