On 6/18/24 11:56, Adam Julis wrote:
Resolves:
https://issues.redhat.com/browse/RHEL-23833
Signed-off-by: Adam Julis <ajulis(a)redhat.com>
---
src/qemu/qemu_driver.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 67b9778c67..74d5e3bb86 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6847,6 +6847,15 @@ qemuDomainAttachDeviceConfig(virDomainDef *vmdef,
vmdef->vsock = g_steal_pointer(&dev->data.vsock);
break;
+ case VIR_DOMAIN_DEVICE_IOMMU:
+ if (vmdef->iommu) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("domain already has an iommu configuration"));
s/configuration/device/
+ return -1;
+ }
+ vmdef->iommu = g_steal_pointer(&dev->data.iommu);
+ break;
+
case VIR_DOMAIN_DEVICE_VIDEO:
case VIR_DOMAIN_DEVICE_GRAPHICS:
case VIR_DOMAIN_DEVICE_HUB:
@@ -6856,7 +6865,6 @@ qemuDomainAttachDeviceConfig(virDomainDef *vmdef,
case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
- case VIR_DOMAIN_DEVICE_IOMMU:
case VIR_DOMAIN_DEVICE_AUDIO:
case VIR_DOMAIN_DEVICE_CRYPTO:
case VIR_DOMAIN_DEVICE_LAST:
@@ -7057,6 +7065,15 @@ qemuDomainDetachDeviceConfig(virDomainDef *vmdef,
g_clear_pointer(&vmdef->vsock, virDomainVsockDefFree);
break;
+ case VIR_DOMAIN_DEVICE_IOMMU:
+ if (!vmdef->iommu) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("matching iommu config not found"));
s/config/device/
+ return -1;
+ }
+ g_clear_pointer(&vmdef->iommu, virDomainIOMMUDefFree);
+ break;
+
case VIR_DOMAIN_DEVICE_VIDEO:
case VIR_DOMAIN_DEVICE_GRAPHICS:
case VIR_DOMAIN_DEVICE_HUB:
@@ -7066,7 +7083,6 @@ qemuDomainDetachDeviceConfig(virDomainDef *vmdef,
case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
- case VIR_DOMAIN_DEVICE_IOMMU:
case VIR_DOMAIN_DEVICE_AUDIO:
case VIR_DOMAIN_DEVICE_CRYPTO:
case VIR_DOMAIN_DEVICE_LAST:
I'll fix both before merging.
Michal