From c802143c07d813a84b03e2598b1b68f297f2139f Mon Sep 17 00:00:00 2001
From: Marcelo Tosatti <mtosatti@redhat.com>
Date: Mon, 1 Mar 2010 20:52:17 -0300
Subject: [PATCH 14/20] net: net_check_clients() runs too early to see -device, fix

RH-Author: Marcelo Tosatti <mtosatti@redhat.com>
Message-id: <229a208fcd0159e6def0f137b869c4f545ba17b5.1267476474.git.mtosatti@redhat.com>
Patchwork-id: 7358
O-Subject: [PATCH 15/21] net: net_check_clients() runs too early to see -device,
	fix
Bugzilla: 569613
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Gleb Natapov <gleb@redhat.com>
RH-Acked-by: Rik van Riel <riel@redhat.com>

From: Markus Armbruster <armbru@redhat.com>

Call it right after -device devices get created.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 668680f75feea79704c603b96126c0833e1ed9a9)
(cherry picked from commit 5e3be6238548b9bf37ea7cbed1924079a4fde4f1)
---
 net.c |    4 +---
 net.h |    1 +
 vl.c  |    2 ++
 3 files changed, 4 insertions(+), 3 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 net.c |    4 +---
 net.h |    1 +
 vl.c  |    2 ++
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/net.c b/net.c
index 109619a..67baaf8 100644
--- a/net.c
+++ b/net.c
@@ -1285,7 +1285,7 @@ void net_cleanup(void)
     }
 }
 
-static void net_check_clients(void)
+void net_check_clients(void)
 {
     VLANState *vlan;
 
@@ -1333,8 +1333,6 @@ int net_init_clients(void)
         return -1;
     }
 
-    net_check_clients();
-
     return 0;
 }
 
diff --git a/net.h b/net.h
index 53f45fb..00dac96 100644
--- a/net.h
+++ b/net.h
@@ -162,6 +162,7 @@ extern const char *legacy_bootp_filename;
 int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev);
 int net_client_parse(QemuOptsList *opts_list, const char *str);
 int net_init_clients(void);
+void net_check_clients(void);
 void net_cleanup(void);
 void net_set_boot_mask(int boot_mask);
 void net_host_device_add(Monitor *mon, const QDict *qdict);
diff --git a/vl.c b/vl.c
index 0420f57..0db6bf0 100644
--- a/vl.c
+++ b/vl.c
@@ -6174,6 +6174,8 @@ int main(int argc, char **argv, char **envp)
     if (qemu_opts_foreach(&qemu_device_opts, device_init_func, NULL, 1) != 0)
         exit(1);
 
+    net_check_clients();
+
     if (!display_state)
         dumb_display_init();
     /* just use the first displaystate for the moment */
-- 
1.7.0.3

