[PATCH 5/7] qemu: Support update net's bootindex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Support to update the net's bootindex using 'virsh update-device'.
Using flag --config or --persistent to change the boot index and the
change will be affected after reboot. With --persistent, we can get
the result of change immediently, but it still takes effect after reboot.

Signed-off-by: Jiang Jiacheng <jiangjiacheng@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c  |  4 ++++
 src/qemu/qemu_hotplug.c | 17 ++++++++++++-----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 65abc04998..863b779514 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7568,6 +7568,10 @@ qemuDomainUpdateDeviceConfig(virDomainDef *vmdef,
                                          false) < 0)
             return -1;
 
+        if (qemuCheckBootIndex(&vmdef->nets[pos]->info,
+                               net->info.bootIndex) < 0)
+            return -1;
+
         if (virDomainNetUpdate(vmdef, pos, net))
             return -1;
 
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index da92ced2f4..5d1913d0c7 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -3468,6 +3468,7 @@ qemuDomainChangeNet(virQEMUDriver *driver,
     bool needCoalesceChange = false;
     bool needVlanUpdate = false;
     bool needIsolatedPortChange = false;
+    int needChangeIndex = 0;
     int ret = -1;
     int changeidx = -1;
     g_autoptr(virConnect) conn = NULL;
@@ -3633,11 +3634,8 @@ qemuDomainChangeNet(virQEMUDriver *driver,
         goto cleanup;
     }
 
-    if (newdev->info.bootIndex == 0)
-        newdev->info.bootIndex = olddev->info.bootIndex;
-    if (olddev->info.bootIndex != newdev->info.bootIndex) {
-        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
-                       _("cannot modify network device boot index setting"));
+    if ((needChangeIndex = qemuCheckBootIndex(&olddev->info,
+                                              newdev->info.bootIndex)) < 0) {
         goto cleanup;
     }
 
@@ -3918,6 +3916,15 @@ qemuDomainChangeNet(virQEMUDriver *driver,
         needReplaceDevDef = true;
     }
 
+    if (needChangeIndex) {
+        if (qemuDomainChangeBootIndex(vm, &olddev->info, newdev->info.bootIndex) < 0)
+            goto cleanup;
+        /* we successfully switched to the new boot index, and we've
+         * determined that the rest of newdev is equivalent to olddev,
+         * so move newdev into place */
+        needReplaceDevDef = true;
+    }
+
     if (needReplaceDevDef) {
         /* the changes above warrant replacing olddev with newdev in
          * the domain's nets list.
-- 
2.33.0





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux