Commit 47d5d01a45d64d231fb856a9cdfecf5d567371e6
1 parent
5f189496
Add -bootp option for slirp, by Anthony Liguori.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2439 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
4 changed files
with
23 additions
and
0 deletions
qemu-doc.texi
| ... | ... | @@ -452,6 +452,16 @@ guest must be configured in binary mode (use the command @code{bin} of |
| 452 | 452 | the Unix TFTP client). The host IP address on the guest is as usual |
| 453 | 453 | 10.0.2.2. |
| 454 | 454 | |
| 455 | +@item -bootp file | |
| 456 | +When using the user mode network stack, broadcast @var{file} as the BOOTP | |
| 457 | +filename. In conjunction with @option{-tftp}, this can be used to network boot | |
| 458 | +a guest from a local directory. | |
| 459 | + | |
| 460 | +Example (using pxelinux): | |
| 461 | +@example | |
| 462 | +qemu -hda linux.img -boot n -tftp /path/to/tftp/files -bootp /pxelinux.0 | |
| 463 | +@end example | |
| 464 | + | |
| 455 | 465 | @item -smb dir |
| 456 | 466 | When using the user mode network stack, activate a built-in SMB |
| 457 | 467 | server so that Windows OSes can access to the host files in @file{dir} | ... | ... |
slirp/bootp.c
| ... | ... | @@ -38,6 +38,8 @@ typedef struct { |
| 38 | 38 | |
| 39 | 39 | BOOTPClient bootp_clients[NB_ADDR]; |
| 40 | 40 | |
| 41 | +const char *bootp_filename; | |
| 42 | + | |
| 41 | 43 | static const uint8_t rfc1533_cookie[] = { RFC1533_COOKIE }; |
| 42 | 44 | |
| 43 | 45 | #ifdef DEBUG |
| ... | ... | @@ -168,6 +170,10 @@ static void bootp_reply(struct bootp_t *bp) |
| 168 | 170 | goto new_addr; |
| 169 | 171 | } |
| 170 | 172 | } |
| 173 | + | |
| 174 | + if (bootp_filename) | |
| 175 | + snprintf(rbp->bp_file, sizeof(rbp->bp_file), "%s", bootp_filename); | |
| 176 | + | |
| 171 | 177 | dprintf("offered addr=%08x\n", ntohl(daddr.sin_addr.s_addr)); |
| 172 | 178 | |
| 173 | 179 | saddr.sin_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_ALIAS); | ... | ... |
vl.c
| ... | ... | @@ -6403,6 +6403,7 @@ void help(void) |
| 6403 | 6403 | "\n" |
| 6404 | 6404 | #ifdef CONFIG_SLIRP |
| 6405 | 6405 | "-tftp prefix allow tftp access to files starting with prefix [-net user]\n" |
| 6406 | + "-bootp file advertise file in BOOTP replies\n" | |
| 6406 | 6407 | #ifndef _WIN32 |
| 6407 | 6408 | "-smb dir allow SMB access to files in 'dir' [-net user]\n" |
| 6408 | 6409 | #endif |
| ... | ... | @@ -6491,6 +6492,7 @@ enum { |
| 6491 | 6492 | |
| 6492 | 6493 | QEMU_OPTION_net, |
| 6493 | 6494 | QEMU_OPTION_tftp, |
| 6495 | + QEMU_OPTION_bootp, | |
| 6494 | 6496 | QEMU_OPTION_smb, |
| 6495 | 6497 | QEMU_OPTION_redir, |
| 6496 | 6498 | |
| ... | ... | @@ -6567,6 +6569,7 @@ const QEMUOption qemu_options[] = { |
| 6567 | 6569 | { "net", HAS_ARG, QEMU_OPTION_net}, |
| 6568 | 6570 | #ifdef CONFIG_SLIRP |
| 6569 | 6571 | { "tftp", HAS_ARG, QEMU_OPTION_tftp }, |
| 6572 | + { "bootp", HAS_ARG, QEMU_OPTION_bootp }, | |
| 6570 | 6573 | #ifndef _WIN32 |
| 6571 | 6574 | { "smb", HAS_ARG, QEMU_OPTION_smb }, |
| 6572 | 6575 | #endif |
| ... | ... | @@ -7085,6 +7088,9 @@ int main(int argc, char **argv) |
| 7085 | 7088 | case QEMU_OPTION_tftp: |
| 7086 | 7089 | tftp_prefix = optarg; |
| 7087 | 7090 | break; |
| 7091 | + case QEMU_OPTION_bootp: | |
| 7092 | + bootp_filename = optarg; | |
| 7093 | + break; | |
| 7088 | 7094 | #ifndef _WIN32 |
| 7089 | 7095 | case QEMU_OPTION_smb: |
| 7090 | 7096 | net_slirp_smb(optarg); | ... | ... |
vl.h