Patchwork [FOR,0.12,v4,15/22] default devices: network

login
register
mail settings
Submitter Gerd Hoffmann
Date Dec. 8, 2009, 12:11 p.m.
Message ID <1260274314-2906-16-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/40627/
State New
Headers show

Comments

Gerd Hoffmann - Dec. 8, 2009, 12:11 p.m.
Add a default_net variable which specified whenever a default network
should be created.  It is cleared in case any -net option is specified
and it is also added to the new -nodefaults switch.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 net.c |    5 ++++-
 net.h |    1 +
 vl.c  |    1 +
 3 files changed, 6 insertions(+), 1 deletions(-)

Patch

diff --git a/net.c b/net.c
index 13bdbb2..6ef93e6 100644
--- a/net.c
+++ b/net.c
@@ -39,6 +39,8 @@ 
 static QTAILQ_HEAD(, VLANState) vlans;
 static QTAILQ_HEAD(, VLANClientState) non_vlan_clients;
 
+int default_net = 1;
+
 /***********************************************************/
 /* network device redirectors */
 
@@ -1317,7 +1319,7 @@  static int net_init_netdev(QemuOpts *opts, void *dummy)
 
 int net_init_clients(void)
 {
-    if (QTAILQ_EMPTY(&qemu_net_opts.head)) {
+    if (default_net) {
         /* if no clients, we use a default config */
         qemu_opts_set(&qemu_net_opts, NULL, "type", "nic");
 #ifdef CONFIG_SLIRP
@@ -1353,5 +1355,6 @@  int net_client_parse(QemuOptsList *opts_list, const char *optarg)
         return -1;
     }
 
+    default_net = 0;
     return 0;
 }
diff --git a/net.h b/net.h
index d583d59..4971fcb 100644
--- a/net.h
+++ b/net.h
@@ -139,6 +139,7 @@  struct NICInfo {
 
 extern int nb_nics;
 extern NICInfo nd_table[MAX_NICS];
+extern int default_net;
 
 /* BT HCI info */
 
diff --git a/vl.c b/vl.c
index 69b577f..4825836 100644
--- a/vl.c
+++ b/vl.c
@@ -5476,6 +5476,7 @@  int main(int argc, char **argv, char **envp)
                 default_parallel = 0;
                 default_monitor = 0;
                 default_vga = 0;
+                default_net = 0;
                 break;
 #ifndef _WIN32
             case QEMU_OPTION_chroot: