From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LPZ5i-0004gr-SM for qemu-devel@nongnu.org; Wed, 21 Jan 2009 04:09:42 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LPZ5h-0004gO-8i for qemu-devel@nongnu.org; Wed, 21 Jan 2009 04:09:42 -0500 Received: from [199.232.76.173] (port=41464 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LPZ5h-0004gJ-5a for qemu-devel@nongnu.org; Wed, 21 Jan 2009 04:09:41 -0500 Received: from nougat.ucs.ed.ac.uk ([129.215.13.205]:43658) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LPZ5g-0001U5-LT for qemu-devel@nongnu.org; Wed, 21 Jan 2009 04:09:40 -0500 Received: from lmtp1.ucs.ed.ac.uk (lmtp1.ucs.ed.ac.uk [129.215.149.64]) by nougat.ucs.ed.ac.uk (8.13.8/8.13.4) with ESMTP id n0L99H8T017422 for ; Wed, 21 Jan 2009 09:09:22 GMT Received: from emperor.ucs.ed.ac.uk (emperor.ucs.ed.ac.uk [194.81.249.143]) by lmtp1.ucs.ed.ac.uk (8.13.8/8.13.7) with ESMTP id n0L99HCU025862 for ; Wed, 21 Jan 2009 09:09:17 GMT Message-ID: <4976E63D.50700@ed.ac.uk> Date: Wed, 21 Jan 2009 09:09:17 +0000 From: James Jarvis MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------010302040705020202030906" Subject: [Qemu-devel] Patch for adding custom hardware address in -net user, macaddr= 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 This is a multi-part message in MIME format. --------------010302040705020202030906 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Dear Qemu-Dev list, Find attached a patch against the 0.9.1 code base to allow the addition of a macaddr in -net user mode. This feature is unlikely to be widely used, but we had a requirement for it when using qemu for testing. The patch has been tested in i386 mode only. In the dev tree much code has been moved out of vl.c - not sure how keen you are to see this patch in there too but it would be a feature appreciated by some. :-) Regards, James Jarvis Information Services The University of Edinburgh -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. --------------010302040705020202030906 Content-Type: text/x-patch; name="qemu-0.9.1-net-user-mode-macaddr.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="qemu-0.9.1-net-user-mode-macaddr.patch" --- qemu-0.9.1-orig/vl.c 2008-01-06 19:38:42.000000000 +0000 +++ qemu-0.9.1/vl.c 2009-01-19 15:56:32.000000000 +0000 @@ -4729,7 +4729,35 @@ if (get_param_value(buf, sizeof(buf), "hostname", p)) { pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf); } - vlan->nb_host_devs++; + /*** BEGIN - Allow mac to be set in NAT ***/ + NICInfo *nd; + uint8_t *macaddr; + + if (nb_nics >= MAX_NICS) { + fprintf(stderr, "Too Many NICs\n"); + return -1; + } + nd = &nd_table[nb_nics]; + macaddr = nd->macaddr; + macaddr[0] = 0x52; + macaddr[1] = 0x54; + macaddr[2] = 0x00; + macaddr[3] = 0x12; + macaddr[4] = 0x34; + macaddr[5] = 0x56 + nb_nics; + + if (get_param_value(buf, sizeof(buf), "macaddr", p)) { + if (parse_macaddr(macaddr, buf) < 0) { + fprintf(stderr, "invalid syntax for ethernet address\n"); + return -1; + } + nd->vlan = vlan; + nb_nics++; + vlan->nb_guest_devs++; + }else { + /*** END - Allow mac to be set in NAT ***/ + vlan->nb_host_devs++; + } ret = net_slirp_init(vlan); } else #endif @@ -7547,7 +7575,7 @@ "-net nic[,vlan=n][,macaddr=addr][,model=type]\n" " create a new Network Interface Card and connect it to VLAN 'n'\n" #ifdef CONFIG_SLIRP - "-net user[,vlan=n][,hostname=host]\n" + "-net user[,vlan=n][,macaddr=addr][,hostname=host]\n" " connect the user mode network stack to VLAN 'n' and send\n" " hostname 'host' to DHCP clients\n" #endif --------------010302040705020202030906--