From: James Jarvis <James.Jarvis@ed.ac.uk>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Patch for adding custom hardware address in -net user, macaddr=
Date: Wed, 21 Jan 2009 09:09:17 +0000 [thread overview]
Message-ID: <4976E63D.50700@ed.ac.uk> (raw)
[-- Attachment #1: Type: text/plain, Size: 632 bytes --]
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.
[-- Attachment #2: qemu-0.9.1-net-user-mode-macaddr.patch --]
[-- Type: text/x-patch, Size: 1717 bytes --]
--- 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
reply other threads:[~2009-01-21 9:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4976E63D.50700@ed.ac.uk \
--to=james.jarvis@ed.ac.uk \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).