]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: interface: check and use ovs command to set qos of ovs managed port
authorzhangjl02 <zhangjl02@inspur.com>
Wed, 7 Jul 2021 09:18:19 +0000 (17:18 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 12 Jul 2021 07:40:13 +0000 (09:40 +0200)
When qos is set or delete, we have to check if the port is an ovs managed
port. If true, call the virNetDevOpenvswitchInterfaceSetQos function when qos
is set, and call the virNetDevOpenvswitchInterfaceClearQos function when
the interface is to be destroyed.

Signed-off-by: Jinsheng Zhang <zhangjl02@inspur.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_driver.c
src/qemu/qemu_hotplug.c
src/qemu/qemu_process.c

index 0473e7deaa6d8a1683933c925404d349b569e683..6af1faa3cd3a1b375b846f2f3e66cc1913c2f646 100644 (file)
@@ -8611,9 +8611,15 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
     actualBandwidth = virDomainNetGetActualBandwidth(net);
     if (actualBandwidth) {
         if (virNetDevSupportsBandwidth(actualType)) {
-            if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false,
-                                      !virDomainNetTypeSharesHostView(net)) < 0)
+            if (virDomainNetDefIsOvsport(net)) {
+                if (virNetDevOpenvswitchInterfaceSetQos(net->ifname, actualBandwidth,
+                                                        def->uuid,
+                                                        !virDomainNetTypeSharesHostView(net)) < 0)
+                    goto cleanup;
+            } else if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false,
+                                             !virDomainNetTypeSharesHostView(net)) < 0) {
                 goto cleanup;
+            }
         } else {
             VIR_WARN("setting bandwidth on interfaces of "
                      "type '%s' is not implemented yet",
index 235f575901cf6bc8e011cf89c06bfeb61bc5ab1c..72f550bf8de565f4f3b17a34df21d447d2b771aa 100644 (file)
@@ -10231,6 +10231,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
     bool inboundSpecified = false, outboundSpecified = false;
     int actualType;
     bool qosSupported = true;
+    bool ovsType = false;
 
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG, -1);
@@ -10277,6 +10278,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
     if (net) {
         actualType = virDomainNetGetActualType(net);
         qosSupported = virNetDevSupportsBandwidth(actualType);
+        ovsType = virDomainNetDefIsOvsport(net);
     }
 
     if (qosSupported && persistentNet) {
@@ -10366,8 +10368,25 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
             }
         }
 
-        if (virNetDevBandwidthSet(net->ifname, newBandwidth, false,
-                                  !virDomainNetTypeSharesHostView(net)) < 0) {
+        if (ovsType) {
+            if (virNetDevOpenvswitchInterfaceSetQos(net->ifname, newBandwidth,
+                                                    vm->def->uuid,
+                                                    !virDomainNetTypeSharesHostView(net)) < 0) {
+                virErrorPtr orig_err;
+
+                virErrorPreserveLast(&orig_err);
+                ignore_value(virNetDevOpenvswitchInterfaceSetQos(net->ifname, newBandwidth,
+                                                                 vm->def->uuid,
+                                                                 !virDomainNetTypeSharesHostView(net)));
+                if (net->bandwidth) {
+                    ignore_value(virDomainNetBandwidthUpdate(net,
+                                                             net->bandwidth));
+                }
+                virErrorRestore(&orig_err);
+                goto endjob;
+            }
+        } else if (virNetDevBandwidthSet(net->ifname, newBandwidth, false,
+                                         !virDomainNetTypeSharesHostView(net)) < 0) {
             virErrorPtr orig_err;
 
             virErrorPreserveLast(&orig_err);
index d2a354d026c7ce18cf0ce8020488d752948cdcea..cb6a4e4ea51d6c4011b117ea221add3272a77d59 100644 (file)
@@ -1409,9 +1409,15 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
     actualBandwidth = virDomainNetGetActualBandwidth(net);
     if (actualBandwidth) {
         if (virNetDevSupportsBandwidth(actualType)) {
-            if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false,
-                                      !virDomainNetTypeSharesHostView(net)) < 0)
+            if (virDomainNetDefIsOvsport(net)) {
+                if (virNetDevOpenvswitchInterfaceSetQos(net->ifname, actualBandwidth,
+                                                        vm->def->uuid,
+                                                        !virDomainNetTypeSharesHostView(net)) < 0)
+                    goto cleanup;
+            } else if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false,
+                                             !virDomainNetTypeSharesHostView(net)) < 0) {
                 goto cleanup;
+            }
         } else {
             VIR_WARN("setting bandwidth on interfaces of "
                      "type '%s' is not implemented yet",
@@ -3914,9 +3920,15 @@ qemuDomainChangeNet(virQEMUDriver *driver,
         const virNetDevBandwidth *newb = virDomainNetGetActualBandwidth(newdev);
 
         if (newb) {
-            if (virNetDevBandwidthSet(newdev->ifname, newb, false,
-                                      !virDomainNetTypeSharesHostView(newdev)) < 0)
+            if (virDomainNetDefIsOvsport(newdev)) {
+                if (virNetDevOpenvswitchInterfaceSetQos(newdev->ifname, newb,
+                                                        vm->def->uuid,
+                                                        !virDomainNetTypeSharesHostView(newdev)) < 0)
+                    goto cleanup;
+            } else if (virNetDevBandwidthSet(newdev->ifname, newb, false,
+                                             !virDomainNetTypeSharesHostView(newdev)) < 0) {
                 goto cleanup;
+            }
         } else {
             /*
              * virNetDevBandwidthSet() doesn't clear any existing
@@ -4665,11 +4677,16 @@ qemuDomainRemoveNetDevice(virQEMUDriver *driver,
     if (!(charDevAlias = qemuAliasChardevFromDevAlias(net->info.alias)))
         return -1;
 
-    if (virDomainNetGetActualBandwidth(net) &&
-        virNetDevSupportsBandwidth(virDomainNetGetActualType(net)) &&
-        virNetDevBandwidthClear(net->ifname) < 0)
-        VIR_WARN("cannot clear bandwidth setting for device : %s",
-                 net->ifname);
+    if (virNetDevSupportsBandwidth(virDomainNetGetActualType(net))) {
+        if (virDomainNetDefIsOvsport(net)) {
+            if (virNetDevOpenvswitchInterfaceClearQos(net->ifname, vm->def->uuid) < 0)
+                VIR_WARN("cannot clear bandwidth setting for ovs device : %s",
+                         net->ifname);
+        } else if (virNetDevBandwidthClear(net->ifname) < 0) {
+            VIR_WARN("cannot clear bandwidth setting for device : %s",
+                     net->ifname);
+        }
+    }
 
     /* deactivate the tap/macvtap device on the host, which could also
      * affect the parent device (e.g. macvtap passthrough mode sets
index 2b03b0ab98b07d87c03527d4e8dc12e0ddf21a3e..3693796b060e09071d08fae7ca0c8ebae9062fb2 100644 (file)
@@ -7966,7 +7966,6 @@ void qemuProcessStop(virQEMUDriver *driver,
     for (i = 0; i < def->nnets; i++) {
         virDomainNetDef *net = def->nets[i];
         vport = virDomainNetGetActualVirtPortProfile(net);
-
         switch (virDomainNetGetActualType(net)) {
         case VIR_DOMAIN_NET_TYPE_DIRECT:
             ignore_value(virNetDevMacVLanDeleteWithVPortProfile(
@@ -8023,6 +8022,12 @@ void qemuProcessStop(virQEMUDriver *driver,
             else
                 VIR_WARN("Unable to release network device '%s'", NULLSTR(net->ifname));
         }
+
+        if (virDomainNetDefIsOvsport(net) &&
+            virNetDevOpenvswitchInterfaceClearQos(net->ifname, vm->def->uuid) < 0) {
+            VIR_WARN("cannot clear bandwidth setting for ovs device : %s",
+                     net->ifname);
+        }
     }
 
  retry: