From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JjoIp-0003dn-Rd for qemu-devel@nongnu.org; Thu, 10 Apr 2008 00:22:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JjoIo-0003bT-7q for qemu-devel@nongnu.org; Thu, 10 Apr 2008 00:22:22 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JjoIn-0003al-8h for qemu-devel@nongnu.org; Thu, 10 Apr 2008 00:22:21 -0400 Received: from mail.windriver.com ([147.11.1.11] helo=mail.wrs.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JjoIm-0003sD-K9 for qemu-devel@nongnu.org; Thu, 10 Apr 2008 00:22:21 -0400 Received: from ALA-MAIL03.corp.ad.wrs.com (ala-mail03 [147.11.57.144]) by mail.wrs.com (8.13.6/8.13.6) with ESMTP id m3A4MHZL013371 for ; Wed, 9 Apr 2008 21:22:19 -0700 (PDT) From: Jason Wessel Date: Wed, 9 Apr 2008 23:22:23 -0500 Message-Id: <1207801343-15955-3-git-send-email-jason.wessel@windriver.com> In-Reply-To: <1207801343-15955-2-git-send-email-jason.wessel@windriver.com> References: <1207801343-15955-1-git-send-email-jason.wessel@windriver.com> <1207801343-15955-2-git-send-email-jason.wessel@windriver.com> Subject: [Qemu-devel] [PATCH 2/2] Fix slirp mac address init Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 --- 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