[libvirt] [RFC PATCH 26/28] qemu: hotplug : Prevent updates to mulitfunction device

Shivaprasad G Bhat posted 28 patches 6 years, 8 months ago
[libvirt] [RFC PATCH 26/28] qemu: hotplug : Prevent updates to mulitfunction device
Posted by Shivaprasad G Bhat 6 years, 8 months ago
The PCI hostdevs once part of the domain, cant be changed.
So, prevent attempts.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
---
 src/qemu/qemu_driver.c |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fb14475d8c..94f76979e5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8646,6 +8646,8 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
     virQEMUDriverPtr driver = dom->conn->privateData;
     virDomainObjPtr vm = NULL;
     virDomainDefPtr vmdef = NULL;
+    virDomainDeviceDefListPtr devlist;
+    virDomainDeviceDefListData data = {.xmlopt = driver->xmlopt, .caps = NULL};
     virDomainDeviceDefPtr dev = NULL, dev_copy = NULL;
     bool force = (flags & VIR_DOMAIN_DEVICE_MODIFY_FORCE) != 0;
     int ret = -1;
@@ -8663,9 +8665,11 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
 
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;
+    data.caps = caps;
 
     if (!(vm = qemuDomObjFromDomain(dom)))
         goto cleanup;
+    data.def = vm->def;
 
     if (virDomainUpdateDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
         goto cleanup;
@@ -8673,12 +8677,18 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
     if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
         goto cleanup;
 
-    dev = dev_copy = virDomainDeviceDefParse(xml, vm->def,
-                                             caps, driver->xmlopt,
-                                             parse_flags);
-    if (dev == NULL)
+    devlist = qemuDomainDeviceParseXMLMany(xml, &data, parse_flags);
+    if (!devlist)
         goto endjob;
 
+    if (devlist->count > 1) {
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                       _("update of device multifunction devices is not supported"));
+        goto endjob;
+    }
+
+    dev = dev_copy = devlist->devs[0];
+
     if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
         goto endjob;
 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list