aboutsummaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-04-21 20:49:11 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-04-21 20:49:11 +0000
commit8d6249a73adefb2468154b7da70c61b23e393d5b (patch)
treed6fa8961f718f75daba289fcfd372c39f048d42e /net.c
parentd4ebe1934a89b1ab699a9485c85c42f1ec9ae2ad (diff)
net: Prevent multiple slirp instances (Jan Kiszka)
The slirp stack is full of global variables which prevents instantiating it more than once. Catch this during net_slirp_init to prevent more harm later on. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7208 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'net.c')
-rw-r--r--net.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/net.c b/net.c
index aa196a3da0..db2f8d345e 100644
--- a/net.c
+++ b/net.c
@@ -544,15 +544,27 @@ static void slirp_receive(void *opaque, const uint8_t *buf, int size)
slirp_input(buf, size);
}
+static int slirp_in_use;
+
+static void net_slirp_cleanup(VLANClientState *vc)
+{
+ slirp_in_use = 0;
+}
+
static int net_slirp_init(VLANState *vlan, const char *model, const char *name)
{
+ if (slirp_in_use) {
+ /* slirp only supports a single instance so far */
+ return -1;
+ }
if (!slirp_inited) {
slirp_inited = 1;
slirp_init(slirp_restrict, slirp_ip);
}
slirp_vc = qemu_new_vlan_client(vlan, model, name,
- slirp_receive, NULL, NULL, NULL);
+ slirp_receive, NULL, net_slirp_cleanup, NULL);
slirp_vc->info_str[0] = '\0';
+ slirp_in_use = 1;
return 0;
}