Skip to contentSkip to conversation

w32: Fix build with new net bridge code

PATCH Applied Stefan Weil 3 participants 3 messages Feb 4, 2012 – Feb 5, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 w32: Fix build with new net bridge code

Commit a7c36ee4920ea3acc227a0248dd161693f207357 added code for a net bridge and explicitly said that "this is very Linux centric".

Indeed, compilation failed for w32, so the bridge code is now conditional. Hosts which don't support it can simply remove the definition of CONFIG_NET_BRIDGE.

---

Was the .name = "helper" intentional? That name is rather unspecific.

Regards,
Stefan Weil

 net.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
net.c +16 -3
index 1944539..c34474f 100644
@@ -38,6 +38,11 @@
 #include "hw/qdev.h"
 #include "iov.h"
 
+/* Net bridge is currently not supported for W32. */
+#if !defined(_WIN32)
+# define CONFIG_NET_BRIDGE
+#endif
+
 static QTAILQ_HEAD(, VLANState) vlans;
 static QTAILQ_HEAD(, VLANClientState) non_vlan_clients;
 
@@ -952,10 +957,12 @@ static const struct {
                 .type = QEMU_OPT_STRING,
                 .help = "script to shut down the interface",
             }, {
+#ifdef CONFIG_NET_BRIDGE
                 .name = "helper",
                 .type = QEMU_OPT_STRING,
                 .help = "command to execute to configure bridge",
             }, {
+#endif
                 .name = "sndbuf",
                 .type = QEMU_OPT_SIZE,
                 .help = "send buffer limit"
@@ -1057,6 +1064,7 @@ static const struct {
             { /* end of list */ }
         },
     },
+#ifdef CONFIG_NET_BRIDGE
     [NET_CLIENT_TYPE_BRIDGE] = {
         .type = "bridge",
         .init = net_init_bridge,
@@ -1074,6 +1082,7 @@ static const struct {
             { /* end of list */ }
         },
     },
+#endif /* CONFIG_NET_BRIDGE */
 };
 
 int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
@@ -1090,14 +1099,16 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
 
     if (is_netdev) {
         if (strcmp(type, "tap") != 0 &&
+#ifdef CONFIG_NET_BRIDGE
+            strcmp(type, "bridge") != 0 &&
+#endif
 #ifdef CONFIG_SLIRP
             strcmp(type, "user") != 0 &&
 #endif
 #ifdef CONFIG_VDE
             strcmp(type, "vde") != 0 &&
 #endif
-            strcmp(type, "socket") != 0 &&
-            strcmp(type, "bridge") != 0) {
+            strcmp(type, "socket") != 0) {
             qerror_report(QERR_INVALID_PARAMETER_VALUE, "type",
                           "a netdev backend type");
             return -1;
@@ -1161,13 +1172,15 @@ static int net_host_check_device(const char *device)
 {
     int i;
     const char *valid_param_list[] = { "tap", "socket", "dump"
+#ifdef CONFIG_NET_BRIDGE
+                                       , "bridge"
+#endif
 #ifdef CONFIG_SLIRP
                                        ,"user"
 #endif
 #ifdef CONFIG_VDE
                                        ,"vde"
 #endif
-                                       , "bridge"
     };
     for (i = 0; i < sizeof(valid_param_list) / sizeof(char *); i++) {
         if (!strncmp(valid_param_list[i], device,
Signature · 1 line
1.7.8.3
Applied
#1 lore raw

Thanks, applied.

Quoted 103 lines · Stefan Weil

Commit a7c36ee4920ea3acc227a0248dd161693f207357 added code for a net bridge and explicitly said that "this is very Linux centric".

Indeed, compilation failed for w32, so the bridge code is now conditional. Hosts which don't support it can simply remove the definition of CONFIG_NET_BRIDGE.

---

Was the .name = "helper" intentional? That name is rather unspecific.

Regards,
Stefan Weil

 net.c |   19 ++++++++++++++++---

 1 files changed, 16 insertions(+), 3 deletions(-)
net.c +7 -0
index 1944539..c34474f 100644
@@ -38,6 +38,11 @@
  #include "hw/qdev.h"
  #include "iov.h"
 
+/* Net bridge is currently not supported for W32. */
+#if !defined(_WIN32)
+# define CONFIG_NET_BRIDGE
+#endif
+
  static QTAILQ_HEAD(, VLANState) vlans;
  static QTAILQ_HEAD(, VLANClientState) non_vlan_clients;
 
@@ -952,10 +957,12 @@ static const struct {
                 .type = QEMU_OPT_STRING,
                 .help = "script to shut down the interface",
             }, {
+#ifdef CONFIG_NET_BRIDGE
                 .name = "helper",
                 .type = QEMU_OPT_STRING,
                 .help = "command to execute to configure bridge",
             }, {
+#endif
                 .name = "sndbuf",
                 .type = QEMU_OPT_SIZE,

                .help = "send buffer limit"

net.c +2 -0
@@ -1057,6 +1064,7 @@ static const struct {
             { /* end of list */ }
         },
     },
+#ifdef CONFIG_NET_BRIDGE
     [NET_CLIENT_TYPE_BRIDGE] = {
         .type = "bridge",
         .init = net_init_bridge,
@@ -1074,6 +1082,7 @@ static const struct {
             { /* end of list */ }
         },
     },
+#endif /* CONFIG_NET_BRIDGE */
  };
 
  int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
@@ -1090,14 +1099,16 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
 
     if (is_netdev) {

        if (strcmp(type, "tap") != 0 &&

net.c +3 -0
+#ifdef CONFIG_NET_BRIDGE
+            strcmp(type, "bridge") != 0 &&
+#endif

 #ifdef CONFIG_SLIRP
            strcmp(type, "user") != 0 &&
 #endif
 #ifdef CONFIG_VDE
            strcmp(type, "vde") != 0 &&
 #endif
-            strcmp(type, "socket") != 0 &&
-            strcmp(type, "bridge") != 0) {
+            strcmp(type, "socket") != 0) { qerror_report(QERR_INVALID_PARAMETER_VALUE, "type", "a netdev backend type"); return -1;

net.c +0 -0
@@ -1161,13 +1172,15 @@ static int net_host_check_device(const char *device)
  {
     int i;

    const char *valid_param_list[] = { "tap", "socket", "dump"

net.c +3 -0
+#ifdef CONFIG_NET_BRIDGE
+                                       , "bridge"
+#endif

 #ifdef CONFIG_SLIRP
                                       ,"user"
 #endif
 #ifdef CONFIG_VDE
                                       ,"vde"
 #endif
-                                       , "bridge"
    };
    for (i = 0; i < sizeof(valid_param_list) / sizeof(char *); i++) { if (!strncmp(valid_param_list[i], device,
--
1.7.8.3

#2 lore raw
In reply to Stefan Weil
Quoted 7 lines · Stefan Weil

Commit a7c36ee4920ea3acc227a0248dd161693f207357 added code for a net bridge and explicitly said that "this is very Linux centric".

Indeed, compilation failed for w32, so the bridge code is now conditional. Hosts which don't support it can simply remove the definition of CONFIG_NET_BRIDGE.

Quoted 8 lines

---

Was the .name = "helper" intentional? That name is rather unspecific.

Regards,
Stefan Weil

Thanks a lot for the patch.

The "helper" option takes a command to execute a helper program that adds a tap device to a network bridge. So I'm thinking "bridgehelper" would be more descriptive, though a bit long.

Signature · 2 lines
Regards,
Corey
Quoted 84 lines
  net.c |   19 ++++++++++++++++---
  1 files changed, 16 insertions(+), 3 deletions(-)
net.c +16 -3
index 1944539..c34474f 100644
@@ -38,6 +38,11 @@
  #include "hw/qdev.h"
  #include "iov.h"
 
+/* Net bridge is currently not supported for W32. */
+#if !defined(_WIN32)
+# define CONFIG_NET_BRIDGE
+#endif
+
  static QTAILQ_HEAD(, VLANState) vlans;
  static QTAILQ_HEAD(, VLANClientState) non_vlan_clients;
 
@@ -952,10 +957,12 @@ static const struct {
                  .type = QEMU_OPT_STRING,
                  .help = "script to shut down the interface",
              }, {
+#ifdef CONFIG_NET_BRIDGE
                  .name = "helper",
                  .type = QEMU_OPT_STRING,
                  .help = "command to execute to configure bridge",
              }, {
+#endif
                  .name = "sndbuf",
                  .type = QEMU_OPT_SIZE,
                  .help = "send buffer limit"
@@ -1057,6 +1064,7 @@ static const struct {
              { /* end of list */ }
          },
      },
+#ifdef CONFIG_NET_BRIDGE
      [NET_CLIENT_TYPE_BRIDGE] = {
          .type = "bridge",
          .init = net_init_bridge,
@@ -1074,6 +1082,7 @@ static const struct {
              { /* end of list */ }
          },
      },
+#endif /* CONFIG_NET_BRIDGE */
  };
 
  int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
@@ -1090,14 +1099,16 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
 
      if (is_netdev) {
          if (strcmp(type, "tap") != 0&&
+#ifdef CONFIG_NET_BRIDGE
+            strcmp(type, "bridge") != 0&&
+#endif
  #ifdef CONFIG_SLIRP
              strcmp(type, "user") != 0&&
  #endif
  #ifdef CONFIG_VDE
              strcmp(type, "vde") != 0&&
  #endif
-            strcmp(type, "socket") != 0&&
-            strcmp(type, "bridge") != 0) {
+            strcmp(type, "socket") != 0) {
              qerror_report(QERR_INVALID_PARAMETER_VALUE, "type",
                            "a netdev backend type");
              return -1;
@@ -1161,13 +1172,15 @@ static int net_host_check_device(const char *device)
  {
      int i;
      const char *valid_param_list[] = { "tap", "socket", "dump"
+#ifdef CONFIG_NET_BRIDGE
+                                       , "bridge"
+#endif
  #ifdef CONFIG_SLIRP
                                         ,"user"
  #endif
  #ifdef CONFIG_VDE
                                         ,"vde"
  #endif
-                                       , "bridge"
      };
      for (i = 0; i<  sizeof(valid_param_list) / sizeof(char *); i++) {
          if (!strncmp(valid_param_list[i], device,