提交 dfa631b5 编写于 作者: A Andrea Bolognani

qemu: Fix switch() statements for virDomainIOMMUModel

Ensure unexpected values are dealt with correctly, that
is by invoking virReportEnumRangeError() and immediately
returning a negative value to the caller.
Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 571cb9db
......@@ -6961,8 +6961,12 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
virBufferAsprintf(&opts, ",device-iotlb=%s",
virTristateSwitchTypeToString(iommu->iotlb));
}
case VIR_DOMAIN_IOMMU_MODEL_LAST:
break;
case VIR_DOMAIN_IOMMU_MODEL_LAST:
default:
virReportEnumRangeError(virDomainIOMMUModel, iommu->model);
return -1;
}
virCommandAddArg(cmd, "-device");
virCommandAddArgBuffer(cmd, &opts);
......@@ -7609,7 +7613,9 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virBufferAddLit(&buf, ",iommu=on");
break;
case VIR_DOMAIN_IOMMU_MODEL_LAST:
break;
default:
virReportEnumRangeError(virDomainIOMMUModel, def->iommu->model);
return -1;
}
}
......
......@@ -6138,6 +6138,7 @@ qemuDomainDeviceDefValidateIOMMU(const virDomainIOMMUDef *iommu,
case VIR_DOMAIN_IOMMU_MODEL_LAST:
default:
virReportEnumRangeError(virDomainIOMMUModel, iommu->model);
return -1;
}
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册