Skip to contentSkip to conversation

libxl: fix guest networking

PATCH In review Christoph Egger 3 participants 3 messages Jan 12, 2011 – Jan 17, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: fix guest networking

Hi!

As previously reported when I start guests with xl then the guest network does not work because the qemu-ifup script no longer runs.
NetBSD doesn't have something like udev. Changing xm/xend, libxl and xenbackendd to make everything behave the same way is a lot more intrusive than enabling it for NetBSD again.

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
tools/libxl/libxl_dm.c +14 -4
diff -r 1db44b952f52 tools/libxl/libxl_dm.c
@@ -28,6 +28,15 @@
 #include "libxl.h"
 #include "flexarray.h"
 
+static const char *libxl_tapif_script(libxl__gc *gc)
+{
+#ifdef __linux__
+    return libxl__strdup(gc, "no");
+#else
+    return libxl__sprintf(gc, "%s/qemu-ifup", libxl_xen_script_dir_path());
+#endif
+}
+
 static char ** libxl_build_device_model_args_old(libxl__gc *gc,
                                              libxl_device_model_info *info,
                                              libxl_device_nic *vifs,
@@ -129,8 +138,9 @@ static char ** libxl_build_device_model_
                 flexarray_vappend(dm_args,
                                 "-net", libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
                                                        vifs[i].devid, smac, vifs[i].model),
-                                "-net", libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,bridge=%s,script=no",
-                                                       vifs[i].devid, ifname, vifs[i].bridge), NULL);
+                                "-net", libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,bridge=%s,script=%s",
+                                                       vifs[i].devid, ifname, vifs[i].bridge, libxl_tapif_script(gc)),
+                                NULL);
                 ioemu_vifs++;
             }
         }
@@ -261,8 +271,8 @@ static char ** libxl_build_device_model_
                 flexarray_append(dm_args, libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
                             vifs[i].devid, smac, vifs[i].model));
                 flexarray_append(dm_args, "-net");
-                flexarray_append(dm_args, libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,script=no",
-                            vifs[i].devid, ifname));
+                flexarray_append(dm_args, libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,script=%s",
+                            vifs[i].devid, ifname, libxl_tapif_script(gc)));
                 ioemu_vifs++;
             }
         }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Christoph Egger writes ("[Xen-devel] [PATCH] libxl: fix guest networking"):

Quoted 3 lines

As previously reported when I start guests with xl then the guest network does not work because the qemu-ifup script no longer runs.

Thanks, I have applied this patch. However, two comments:

Firstly, like many of your patches, I had to change the Subject of the commit message to something more informative. "fix guest networking" is rather vague. You'd make our lives just infinitesimally easier if you wrote a better subject line yourself :-).

Secondly,

+static const char *libxl_tapif_script(libxl__gc *gc) +{
+#ifdef __linux__
+ return libxl__strdup(gc, "no");
+#else
+ return libxl__sprintf(gc, "%s/qemu-ifup", libxl_xen_script_dir_path());
+#endif
+}

I'm really not a fan of #ifdefs in the main parts of the code. Perhaps we can (in 4.2) create a file where we can dump these kind of things.

Thanks,
Ian.

#2 lore raw
Quoted 9 lines · Ian Jackson
tools/libxl/libxl_dm.c +8 -0
+static const char *libxl_tapif_script(libxl__gc *gc)
+{
+#ifdef __linux__
+    return libxl__strdup(gc, "no");
+#else
+    return libxl__sprintf(gc, "%s/qemu-ifup", libxl_xen_script_dir_path());
+#endif
+}
Quoted 3 lines

I'm really not a fan of #ifdefs in the main parts of the code. Perhaps we can (in 4.2) create a file where we can dump these kind of things.

IMHO it would be better to switch netbsd to the new model for 4.2.

Ian.