]> xenbits.xensource.com Git - libvirt.git/commitdiff
libxl: allow only 'ethernet' and 'bridge' interfaces, allow script there
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Thu, 13 Jun 2013 01:54:03 +0000 (03:54 +0200)
committerJim Fehlig <jfehlig@suse.com>
Thu, 13 Jun 2013 21:22:11 +0000 (15:22 -0600)
Actually only those interface types are handled correctly so reject
others instead of ignoring settings (i.e. treating as bridge/ethernet
anyway).
Also allow <script/> in 'ethernet' (which should be the only
script-allowing type). Keep <script/> allowed in bridge to be compatible
with legacy 'xen' driver.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
src/libxl/libxl_conf.c

index 8b765363dc6657d3a00f57b32ca88184e43e1826..4da29d7108accdd11ee20fa85291479d8a2018e0 100644 (file)
@@ -572,18 +572,20 @@ libxlMakeNic(virDomainNetDefPtr l_nic, libxl_device_nic *x_nic)
     if (VIR_STRDUP(x_nic->ifname, l_nic->ifname) < 0)
         return -1;
 
-    if (l_nic->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
-        if (VIR_STRDUP(x_nic->bridge, l_nic->data.bridge.brname) < 0)
-            return -1;
-        if (VIR_STRDUP(x_nic->script, l_nic->script) < 0)
-            return -1;
-    } else {
-        if (l_nic->script) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("scripts are not supported on interfaces of type %s"),
-                           virDomainNetTypeToString(l_nic->type));
+    switch (l_nic->type) {
+        case VIR_DOMAIN_NET_TYPE_BRIDGE:
+            if (VIR_STRDUP(x_nic->bridge, l_nic->data.bridge.brname) < 0)
+                return -1;
+            /* fallthrough */
+        case VIR_DOMAIN_NET_TYPE_ETHERNET:
+            if (VIR_STRDUP(x_nic->script, l_nic->script) < 0)
+                return -1;
+            break;
+        default:
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                    _("libxenlight does not support network device type %s"),
+                    virDomainNetTypeToString(l_nic->type));
             return -1;
-        }
     }
 
     return 0;