mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
conf: Move virDomainCheckVirtioOptions() into domain_validate.c
The aim of virDomainCheckVirtioOptions() function is to check whether no virtio options are set, i.e. no @iommu no @ats and no @packed attributes were present in given device's XML (yeah, the function has very misleading name). Nevertheless, this kind of check belongs to validation phase, but now is done in post parse phase. Move the function and its calls to domain_validate.c so that future code is not tempted to repeat this mistake. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
e211b23192
commit
8a4b8996f7
@ -5132,34 +5132,6 @@ virDomainHostdevDefPostParse(virDomainHostdevDefPtr dev,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virDomainCheckVirtioOptions(virDomainVirtioOptionsPtr virtio)
|
||||
{
|
||||
if (!virtio)
|
||||
return 0;
|
||||
|
||||
if (virtio->iommu != VIR_TRISTATE_SWITCH_ABSENT) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("iommu driver option is only supported "
|
||||
"for virtio devices"));
|
||||
return -1;
|
||||
}
|
||||
if (virtio->ats != VIR_TRISTATE_SWITCH_ABSENT) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("ats driver option is only supported "
|
||||
"for virtio devices"));
|
||||
return -1;
|
||||
}
|
||||
if (virtio->packed != VIR_TRISTATE_SWITCH_ABSENT) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("packed driver option is only supported "
|
||||
"for virtio devices"));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virDomainChrDefPostParse(virDomainChrDefPtr chr,
|
||||
const virDomainDef *def)
|
||||
@ -5256,11 +5228,6 @@ virDomainDiskDefPostParse(virDomainDiskDefPtr disk,
|
||||
virDomainPostParseCheckISCSIPath(&disk->src->path);
|
||||
}
|
||||
|
||||
if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO &&
|
||||
virDomainCheckVirtioOptions(disk->virtio) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (disk->src->type == VIR_STORAGE_TYPE_NVME) {
|
||||
if (disk->src->nvme->managed == VIR_TRISTATE_BOOL_ABSENT)
|
||||
disk->src->nvme->managed = VIR_TRISTATE_BOOL_YES;
|
||||
@ -5310,13 +5277,8 @@ virDomainControllerDefPostParse(virDomainControllerDefPtr cdev)
|
||||
|
||||
|
||||
static int
|
||||
virDomainNetDefPostParse(virDomainNetDefPtr net)
|
||||
virDomainNetDefPostParse(virDomainNetDefPtr net G_GNUC_UNUSED)
|
||||
{
|
||||
if (!virDomainNetIsVirtioModel(net) &&
|
||||
virDomainCheckVirtioOptions(net->virtio) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -226,6 +226,34 @@ virSecurityDeviceLabelDefValidate(virSecurityDeviceLabelDefPtr *seclabels,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virDomainCheckVirtioOptions(virDomainVirtioOptionsPtr virtio)
|
||||
{
|
||||
if (!virtio)
|
||||
return 0;
|
||||
|
||||
if (virtio->iommu != VIR_TRISTATE_SWITCH_ABSENT) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("iommu driver option is only supported "
|
||||
"for virtio devices"));
|
||||
return -1;
|
||||
}
|
||||
if (virtio->ats != VIR_TRISTATE_SWITCH_ABSENT) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("ats driver option is only supported "
|
||||
"for virtio devices"));
|
||||
return -1;
|
||||
}
|
||||
if (virtio->packed != VIR_TRISTATE_SWITCH_ABSENT) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("packed driver option is only supported "
|
||||
"for virtio devices"));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#define VENDOR_LEN 8
|
||||
#define PRODUCT_LEN 16
|
||||
|
||||
@ -277,15 +305,19 @@ virDomainDiskDefValidate(const virDomainDef *def,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO &&
|
||||
(disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO ||
|
||||
disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL ||
|
||||
disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("disk model '%s' not supported for bus '%s'"),
|
||||
virDomainDiskModelTypeToString(disk->model),
|
||||
virDomainDiskBusTypeToString(disk->bus));
|
||||
return -1;
|
||||
if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) {
|
||||
if (disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO ||
|
||||
disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL ||
|
||||
disk->model == VIR_DOMAIN_DISK_MODEL_VIRTIO_NON_TRANSITIONAL) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("disk model '%s' not supported for bus '%s'"),
|
||||
virDomainDiskModelTypeToString(disk->model),
|
||||
virDomainDiskBusTypeToString(disk->bus));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virDomainCheckVirtioOptions(disk->virtio) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (disk->src->type == VIR_STORAGE_TYPE_NVME) {
|
||||
@ -1330,6 +1362,11 @@ virDomainNetDefValidate(const virDomainNetDef *net)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!virDomainNetIsVirtioModel(net) &&
|
||||
virDomainCheckVirtioOptions(net->virtio) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user