source: trunk/packages/xen-3.1/xen-3.1/tools/ioemu/patches/xen-network @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

File size: 2.7 KB
Line 
1Index: ioemu/vl.c
2===================================================================
3--- ioemu.orig/vl.c     2007-05-03 10:07:52.000000000 +0100
4+++ ioemu/vl.c  2007-05-03 10:07:52.000000000 +0100
5@@ -90,6 +90,7 @@
6 
7 #include <xen/hvm/params.h>
8 #define DEFAULT_NETWORK_SCRIPT "/etc/xen/qemu-ifup"
9+#define DEFAULT_BRIDGE "xenbr0"
10 
11 //#define DEBUG_UNUSED_IOPORT
12 //#define DEBUG_IOPORT
13@@ -3091,11 +3092,11 @@
14 #endif
15 
16 static int net_tap_init(VLANState *vlan, const char *ifname1,
17-                        const char *setup_script)
18+                        const char *setup_script, const char *bridge)
19 {
20     TAPState *s;
21     int pid, status, fd;
22-    char *args[3];
23+    char *args[4];
24     char **parg;
25     char ifname[128];
26 
27@@ -3114,9 +3115,18 @@
28         pid = fork();
29         if (pid >= 0) {
30             if (pid == 0) {
31+                int open_max = sysconf(_SC_OPEN_MAX), i;
32+                for (i = 0; i < open_max; i++)
33+                    if (i != STDIN_FILENO &&
34+                        i != STDOUT_FILENO &&
35+                        i != STDERR_FILENO &&
36+                        i != fd)
37+                        close(i);
38+
39                 parg = args;
40                 *parg++ = (char *)setup_script;
41                 *parg++ = ifname;
42+                *parg++ = (char *)bridge;
43                 *parg++ = NULL;
44                 execv(setup_script, args);
45                 _exit(1);
46@@ -3672,6 +3682,7 @@
47     if (!strcmp(device, "tap")) {
48         char ifname[64];
49         char setup_script[1024];
50+        char bridge[16];
51         int fd;
52         if (get_param_value(buf, sizeof(buf), "fd", p) > 0) {
53             fd = strtol(buf, NULL, 0);
54@@ -3684,7 +3695,10 @@
55             if (get_param_value(setup_script, sizeof(setup_script), "script", p) == 0) {
56                 pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT);
57             }
58-            ret = net_tap_init(vlan, ifname, setup_script);
59+            if (get_param_value(bridge, sizeof(bridge), "bridge", p) == 0) {
60+                pstrcpy(bridge, sizeof(bridge), DEFAULT_BRIDGE);
61+            }
62+            ret = net_tap_init(vlan, ifname, setup_script, bridge);
63         }
64     } else
65 #endif
66@@ -5209,7 +5223,7 @@
67            "-net tap[,vlan=n],ifname=name\n"
68            "                connect the host TAP network interface to VLAN 'n'\n"
69 #else
70-           "-net tap[,vlan=n][,fd=h][,ifname=name][,script=file]\n"
71+           "-net tap[,vlan=n][,fd=h][,ifname=name][,script=file][,bridge=br]\n"
72            "                connect the host TAP network interface to VLAN 'n' and use\n"
73            "                the network script 'file' (default=%s);\n"
74            "                use 'fd=h' to connect to an already opened TAP interface\n"
Note: See TracBrowser for help on using the repository browser.