[libvirt] [PATCH v2 1/2] lxc: check actual type of interface not config type

Ján Tomko jtomko at redhat.com
Fri Dec 7 09:26:21 UTC 2018


On Thu, Dec 06, 2018 at 10:58:22AM -0500, Laine Stump wrote:
>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 at laine.org>
>---
> src/lxc/lxc_controller.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
>diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
>index e853d02d65..07342cbc77 100644
>--- a/src/lxc/lxc_controller.c
>+++ b/src/lxc/lxc_controller.c
>@@ -367,7 +367,10 @@ 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]);

Please join these two lines into one.

>+
>+        switch (actualType) {
>         case VIR_DOMAIN_NET_TYPE_BRIDGE:
>         case VIR_DOMAIN_NET_TYPE_NETWORK:
>         case VIR_DOMAIN_NET_TYPE_ETHERNET:
>@@ -396,11 +399,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;
>         }

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20181207/52c76d89/attachment-0001.sig>


More information about the libvir-list mailing list