]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Make macvtap ethernet share host view
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 1 Mar 2023 10:05:49 +0000 (11:05 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 6 Mar 2023 11:20:15 +0000 (12:20 +0100)
When fetching stats for a domain's <interface/>, or when setting
up its QoS, we can face two situations:

1) the device "shares" the host view, meaning each packet
   sent/received on the interface by a domain is accounted for in
   the same category on the host, or

2) the device is at the other side, and a packet send by a
   domain, is in fact packet received on the host.

This fact affects whether we need to swap RX/TX values when
fetching stats, or setting up QoS. We have this convenient helper
function (virDomainNetTypeSharesHostView()), which returns to
which category given interface type falls into.

Now, for unmanaged type='ethernet' our options are quite limited,
because it's user's responsibility to set up the host side of the
interface. And it can be just anything. Fortunately, we have
another convenience function (virNetDevMacVLanIsMacvtap()), which
determines whether given interface is a macvtap (which is
notoriously known for falling into the first category).
Let's use it to help virDomainNetTypeSharesHostView() determine
the view more accurately.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2175449
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/conf/domain_conf.c

index 34d38f9958bf67453db2008e6057a269524e12f5..ee74d5ab8ae8ee371eeecb7d9919bda49d9c228c 100644 (file)
@@ -29576,8 +29576,12 @@ virDomainNetTypeSharesHostView(const virDomainNetDef *net)
     switch (actualType) {
     case VIR_DOMAIN_NET_TYPE_DIRECT:
         return true;
-    case VIR_DOMAIN_NET_TYPE_USER:
     case VIR_DOMAIN_NET_TYPE_ETHERNET:
+        if (net->managed_tap == VIR_TRISTATE_BOOL_NO &&
+            virNetDevMacVLanIsMacvtap(net->ifname))
+            return true;
+        break;
+    case VIR_DOMAIN_NET_TYPE_USER:
     case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
     case VIR_DOMAIN_NET_TYPE_SERVER:
     case VIR_DOMAIN_NET_TYPE_CLIENT: