conf: Make macvtap ethernet share host view

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>
This commit is contained in:
Michal Privoznik 2023-03-01 11:05:49 +01:00
parent cea8402e1c
commit 172dd3d9f7

View 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: