]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc: check actual type of interface not config type
authorLaine Stump <laine@laine.org>
Wed, 5 Dec 2018 21:58:08 +0000 (16:58 -0500)
committerLaine Stump <laine@laine.org>
Sat, 8 Dec 2018 17:37:32 +0000 (12:37 -0500)
virLXCControllerGetNICIndexes() was deciding whether or not to add the
ifindex for an interface's ifname to the list of ifindexes sent to
CreateMachineWithNetwork based on the interface type stored in the
config. This would be incorrect in the case of <interface
type='network'> where the network was giving out macvlan interfaces
tied to a physical device (i.e. when the actual interface type was
"direct").

Instead of checking the setting of "net->type", we should be checking
the setting of virDomainNetGetActualType(net).

I don't think this caused any actual misbehavior, it was just
technically wrong.

Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/lxc/lxc_controller.c

index e853d02d65433fc5ce5722dfb6100008b3afd590..4fedc2b705cd94adac593d88c7f1007c1c2dd0f8 100644 (file)
@@ -367,7 +367,9 @@ static int virLXCControllerGetNICIndexes(virLXCControllerPtr ctrl)
     VIR_DEBUG("Getting nic indexes");
     for (i = 0; i < ctrl->def->nnets; i++) {
         int nicindex = -1;
-        switch (ctrl->def->nets[i]->type) {
+        virDomainNetType actualType = virDomainNetGetActualType(ctrl->def->nets[i]);
+
+        switch (actualType) {
         case VIR_DOMAIN_NET_TYPE_BRIDGE:
         case VIR_DOMAIN_NET_TYPE_NETWORK:
         case VIR_DOMAIN_NET_TYPE_ETHERNET:
@@ -396,11 +398,11 @@ static int virLXCControllerGetNICIndexes(virLXCControllerPtr ctrl)
         case VIR_DOMAIN_NET_TYPE_HOSTDEV:
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("Unsupported net type %s"),
-                           virDomainNetTypeToString(ctrl->def->nets[i]->type));
+                           virDomainNetTypeToString(actualType));
             goto cleanup;
         case VIR_DOMAIN_NET_TYPE_LAST:
         default:
-            virReportEnumRangeError(virDomainNetType, ctrl->def->nets[i]->type);
+            virReportEnumRangeError(virDomainNetType, actualType);
             goto cleanup;
         }
     }