SHA256
1
0
forked from pool/libvirt
libvirt/8a4b8996-conf-move-virDomainCheckVirtioOptions.patch

164 lines
5.6 KiB
Diff
Raw Normal View History

commit 8a4b8996f78f86bf10fea3e91d54e82db168547b
Author: Michal Prívozník <mprivozn@redhat.com>
Date: Thu Jan 28 14:06:55 2021 +0100
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>
Index: libvirt-7.0.0/src/conf/domain_conf.c
===================================================================
--- libvirt-7.0.0.orig/src/conf/domain_conf.c
+++ libvirt-7.0.0/src/conf/domain_conf.c
@@ -5130,34 +5130,6 @@ virDomainHostdevDefPostParse(virDomainHo
}
-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)
@@ -5254,11 +5226,6 @@ virDomainDiskDefPostParse(virDomainDiskD
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;
@@ -5308,13 +5275,8 @@ virDomainControllerDefPostParse(virDomai
static int
-virDomainNetDefPostParse(virDomainNetDefPtr net)
+virDomainNetDefPostParse(virDomainNetDefPtr net G_GNUC_UNUSED)
{
- if (!virDomainNetIsVirtioModel(net) &&
- virDomainCheckVirtioOptions(net->virtio) < 0) {
- return -1;
- }
-
return 0;
}
Index: libvirt-7.0.0/src/conf/domain_validate.c
===================================================================
--- libvirt-7.0.0.orig/src/conf/domain_validate.c
+++ libvirt-7.0.0/src/conf/domain_validate.c
@@ -226,6 +226,34 @@ virSecurityDeviceLabelDefValidate(virSec
}
+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 virDomain
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 virDomainN
return -1;
}
+ if (!virDomainNetIsVirtioModel(net) &&
+ virDomainCheckVirtioOptions(net->virtio) < 0) {
+ return -1;
+ }
+
return 0;
}