qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/2] Fix slirp mac address init


From: Jason Wessel
Subject: [Qemu-devel] [PATCH 2/2] Fix slirp mac address init
Date: Wed, 9 Apr 2008 23:22:23 -0500

It is not possible to communicate to a qemu instance via a slirp
redirected udp port until the OS running in qemu has executed a dhcp
request.  This is because the internal qemu dhcp server populates the
slirp mac address.  Until the dhcp request is processed the translated
mac address is zeroed out and the packets bound for the target OS will
not correctly get the mac address of the qemu ethernet adapter.

The solution is to initialize the slirp mac address when the qemu
network adapter client is initialized.  This allows the use
bi-directional udp redirection with a static IP address configured on
the qemu ethernet adapter.

Signed-off-by: Jason Wessel <address@hidden>
---
 slirp/libslirp.h |    2 ++
 slirp/slirp.c    |    5 +++++
 vl.c             |    3 +++
 3 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/slirp/libslirp.h b/slirp/libslirp.h
index 7e4cfa9..e862de6 100644
--- a/slirp/libslirp.h
+++ b/slirp/libslirp.h
@@ -7,6 +7,8 @@ extern "C" {
 
 void slirp_init(void);
 
+void slirp_initial_mac(uint8_t *macaddr);
+
 void slirp_select_fill(int *pnfds,
                        fd_set *readfds, fd_set *writefds, fd_set *xfds);
 
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 303f482..8adc027 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -136,6 +136,11 @@ static void slirp_cleanup(void)
 }
 #endif
 
+void slirp_initial_mac(uint8_t *macaddr)
+{
+    memcpy(client_ethaddr, macaddr, sizeof(client_ethaddr));
+}
+
 void slirp_init(void)
 {
     //    debug_init("/tmp/slirp.log", DEBUG_DEFAULT);
diff --git a/vl.c b/vl.c
index 6aa27c2..2fd1868 100644
--- a/vl.c
+++ b/vl.c
@@ -4792,6 +4792,9 @@ static int net_client_init(const char *str)
                 return -1;
             }
         }
+#ifdef CONFIG_SLIRP
+        slirp_initial_mac(macaddr);
+#endif
         if (get_param_value(buf, sizeof(buf), "model", p)) {
             nd->model = strdup(buf);
         }
-- 
1.5.4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]