render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
43fe83
From 9fea9b854c82af06f17830c5e1fb585fdf78fff8 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <9fea9b854c82af06f17830c5e1fb585fdf78fff8.1381871411.git.jdenemar@redhat.com>
43fe83
From: Michal Privoznik <mprivozn@redhat.com>
43fe83
Date: Wed, 2 Oct 2013 11:04:08 +0200
43fe83
Subject: [PATCH] qemu_hotplug: Allow QoS update in qemuDomainChangeNet
43fe83
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=1014503
43fe83
43fe83
The qemuDomainChangeNet() is called when 'virsh update-device' is
43fe83
invoked on a NIC. Currently, we fail to update the QoS even though
43fe83
we have routines for that.
43fe83
43fe83
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
43fe83
(cherry picked from commit 9fa10d3901a14997f724fe50ad8a33d7f0d23abe)
43fe83
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
43fe83
---
43fe83
 src/qemu/qemu_hotplug.c | 19 +++++++++++++++++--
43fe83
 1 file changed, 17 insertions(+), 2 deletions(-)
43fe83
43fe83
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
43fe83
index 83e193b..7e884c0 100644
43fe83
--- a/src/qemu/qemu_hotplug.c
43fe83
+++ b/src/qemu/qemu_hotplug.c
43fe83
@@ -1677,6 +1677,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
43fe83
     bool needFilterChange = false;
43fe83
     bool needLinkStateChange = false;
43fe83
     bool needReplaceDevDef = false;
43fe83
+    bool needBandwidthSet = false;
43fe83
     int ret = -1;
43fe83
 
43fe83
     if (!devslot || !(olddev = *devslot)) {
43fe83
@@ -1940,8 +1941,6 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
43fe83
         virDomainNetGetActualDirectMode(olddev) != virDomainNetGetActualDirectMode(olddev) ||
43fe83
         !virNetDevVPortProfileEqual(virDomainNetGetActualVirtPortProfile(olddev),
43fe83
                                     virDomainNetGetActualVirtPortProfile(newdev)) ||
43fe83
-        !virNetDevBandwidthEqual(virDomainNetGetActualBandwidth(olddev),
43fe83
-                                 virDomainNetGetActualBandwidth(newdev)) ||
43fe83
         !virNetDevVlanEqual(virDomainNetGetActualVlan(olddev),
43fe83
                             virDomainNetGetActualVlan(newdev))) {
43fe83
         needReconnect = true;
43fe83
@@ -1950,6 +1949,10 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
43fe83
     if (olddev->linkstate != newdev->linkstate)
43fe83
         needLinkStateChange = true;
43fe83
 
43fe83
+    if (!virNetDevBandwidthEqual(virDomainNetGetActualBandwidth(olddev),
43fe83
+                                 virDomainNetGetActualBandwidth(newdev)))
43fe83
+        needBandwidthSet = true;
43fe83
+
43fe83
     /* FINALLY - actually perform the required actions */
43fe83
 
43fe83
     if (needReconnect) {
43fe83
@@ -1959,6 +1962,18 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
43fe83
         goto cleanup;
43fe83
     }
43fe83
 
43fe83
+    if (needBandwidthSet) {
43fe83
+        if (virNetDevBandwidthSet(newdev->ifname,
43fe83
+                                  virDomainNetGetActualBandwidth(newdev),
43fe83
+                                  false) < 0) {
43fe83
+            virReportError(VIR_ERR_INTERNAL_ERROR,
43fe83
+                           _("cannot set bandwidth limits on %s"),
43fe83
+                           newdev->ifname);
43fe83
+            goto cleanup;
43fe83
+        }
43fe83
+        needReplaceDevDef = true;
43fe83
+    }
43fe83
+
43fe83
     if (needBridgeChange) {
43fe83
         if (qemuDomainChangeNetBridge(dom->conn, vm, olddev, newdev) < 0)
43fe83
             goto cleanup;
43fe83
-- 
43fe83
1.8.3.2
43fe83