Skip to contentSkip to conversation

libxl: minor portability nits

PATCH In review Christoph Egger 2 participants 2 messages Aug 26, 2010 – Aug 31, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: minor portability nits

Hi!

Use #defines for network related default settinsg. Distinguish between default Linux and NetBSD network bridge interfaces.

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/xl_cmdimpl.c +12 -4
diff -r 3c4c3d48a835 tools/libxl/xl_cmdimpl.c
@@ -41,6 +41,14 @@
 #include "libxlutil.h"
 #include "xl.h"
 
+#define NET_DEFAULT_ADDRESS       "127.0.0.1"
+#if defined(__linux__)
+#define NET_DEFAULT_BRIDGE        "xenbr0"
+#endif
+#if defined(__NetBSD__)
+#define NET_DEFAULT_BRIDGE        "bridge0"
+#endif
+
 #define CHK_ERRNO( call ) ({                                            \
         int chk_errno = (call);                                         \
         if (chk_errno < 0) {                                                \
@@ -309,7 +317,7 @@ static void init_dm_info(libxl_device_mo
 
     dm_info->stdvga = 0;
     dm_info->vnc = 1;
-    dm_info->vnclisten = "127.0.0.1";
+    dm_info->vnclisten = NET_DEFAULT_ADDRESS;
     dm_info->vncdisplay = 0;
     dm_info->vncunused = 1;
     dm_info->keymap = NULL;
@@ -339,7 +347,7 @@ static void init_nic_info(libxl_device_n
     nic_info->mac[4] = 1 + (int) (0xff * (rand() / (RAND_MAX + 1.0)));
     nic_info->mac[5] = 1 + (int) (0xff * (rand() / (RAND_MAX + 1.0)));
     nic_info->ifname = NULL;
-    nic_info->bridge = strdup("xenbr0");
+    nic_info->bridge = strdup(NET_DEFAULT_BRIDGE);
     CHK_ERRNO( asprintf(&nic_info->script, "%s/vif-bridge",
                libxl_xen_script_dir_path()) );
     nic_info->nictype = NICTYPE_IOEMU;
@@ -365,7 +373,7 @@ static void init_net2_info(libxl_device_
     net2_info->back_trusted = 1;
     net2_info->filter_mac = 1;
     net2_info->max_bypasses = 5;
-    net2_info->bridge = "xenbr0";
+    net2_info->bridge = NET_DEFAULT_BRIDGE;
 }
 
 static void init_vfb_info(libxl_device_vfb *vfb, int dev_num)
@@ -373,7 +381,7 @@ static void init_vfb_info(libxl_device_v
     memset(vfb, 0x00, sizeof(libxl_device_vfb));
     vfb->devid = dev_num;
     vfb->vnc = 1;
-    vfb->vnclisten = "127.0.0.1";
+    vfb->vnclisten = NET_DEFAULT_ADDRESS;
     vfb->vncdisplay = 0;
     vfb->vncunused = 1;
     vfb->keymap = NULL;

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

#1 lore raw

Christoph Egger writes ("[Xen-devel] [PATCH] libxl: minor portability nits"):

Quoted 2 lines

Use #defines for network related default settinsg. Distinguish between default Linux and NetBSD network bridge interfaces.

I don't understand how and when NET_DEFAULT_ADDRESS ought to be set to something different at compile-time. If what you want is a global setting, for the administrator to arrange to bind to a particular address of the host (and you are happy with the security implications), then I agree that we need a global config file for this and various other reasons. But not a #define.

tools/libxl/xl_cmdimpl.c line 50

Quoted 7 lines
tools/libxl/xl_cmdimpl.c +7 -0
+#define NET_DEFAULT_ADDRESS       "127.0.0.1"
+#if defined(__linux__)
+#define NET_DEFAULT_BRIDGE        "xenbr0"
+#endif
+#if defined(__NetBSD__)
+#define NET_DEFAULT_BRIDGE        "bridge0"
+#endif

This should be in libxl_osdeps.h.
Furthermore, the xenbr0 version should be the default. Ie.
+#ifndef NET_DEFAULT_BRIDGE
+#define NET_DEFAULT_BRIDGE "xenbr0"
+#endif
preceded by some suitable thing for netbsd. Also please use #ifdef not #if defined(...).

Thanks,
Ian.