From 9858958385ae145196a0b95befbd9ae8f2f5ce18 Mon Sep 17 00:00:00 2001
From: jiangdongxu1 <jiangdongxu1@huawei.com>
Date: Wed, 13 Mar 2024 15:28:47 +0800
Subject: [PATCH] vdpa: Release pci slot address when unplugging vdpa device

Signed-off-by: jiangdongxu1 <jiangdongxu1@huawei.com>
---
 src/qemu/qemu_hotplug.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 3c5540291b..f44ac938ae 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -4560,6 +4560,12 @@ qemuDomainRemoveMediatedDevice(virQEMUDriverPtr driver,
     qemuDomainReleaseDeviceAddress(vm, hostdev->info);
 }
 
+static void
+qemuDomainRemoveVDPADevice(virDomainObjPtr vm,
+                           virDomainHostdevDefPtr hostdev)
+{
+    qemuDomainReleaseDeviceAddress(vm, hostdev->info);
+}
 
 static int
 qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
@@ -4653,6 +4659,8 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
         qemuDomainRemoveMediatedDevice(driver, vm, hostdev);
         break;
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_VDPA:
+        qemuDomainRemoveVDPADevice(vm, hostdev);
+        break;
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
         break;
     }
-- 
2.27.0

