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,6 +452,16 @@ guest must be configured in binary mode (use the command @code{bin} of | ||
| 452 | the Unix TFTP client). The host IP address on the guest is as usual | 452 | the Unix TFTP client). The host IP address on the guest is as usual |
| 453 | 10.0.2.2. | 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 | @item -smb dir | 465 | @item -smb dir |
| 456 | When using the user mode network stack, activate a built-in SMB | 466 | When using the user mode network stack, activate a built-in SMB |
| 457 | server so that Windows OSes can access to the host files in @file{dir} | 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,6 +38,8 @@ typedef struct { | ||
| 38 | 38 | ||
| 39 | BOOTPClient bootp_clients[NB_ADDR]; | 39 | BOOTPClient bootp_clients[NB_ADDR]; |
| 40 | 40 | ||
| 41 | +const char *bootp_filename; | ||
| 42 | + | ||
| 41 | static const uint8_t rfc1533_cookie[] = { RFC1533_COOKIE }; | 43 | static const uint8_t rfc1533_cookie[] = { RFC1533_COOKIE }; |
| 42 | 44 | ||
| 43 | #ifdef DEBUG | 45 | #ifdef DEBUG |
| @@ -168,6 +170,10 @@ static void bootp_reply(struct bootp_t *bp) | @@ -168,6 +170,10 @@ static void bootp_reply(struct bootp_t *bp) | ||
| 168 | goto new_addr; | 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 | dprintf("offered addr=%08x\n", ntohl(daddr.sin_addr.s_addr)); | 177 | dprintf("offered addr=%08x\n", ntohl(daddr.sin_addr.s_addr)); |
| 172 | 178 | ||
| 173 | saddr.sin_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_ALIAS); | 179 | saddr.sin_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_ALIAS); |
vl.c
| @@ -6403,6 +6403,7 @@ void help(void) | @@ -6403,6 +6403,7 @@ void help(void) | ||
| 6403 | "\n" | 6403 | "\n" |
| 6404 | #ifdef CONFIG_SLIRP | 6404 | #ifdef CONFIG_SLIRP |
| 6405 | "-tftp prefix allow tftp access to files starting with prefix [-net user]\n" | 6405 | "-tftp prefix allow tftp access to files starting with prefix [-net user]\n" |
| 6406 | + "-bootp file advertise file in BOOTP replies\n" | ||
| 6406 | #ifndef _WIN32 | 6407 | #ifndef _WIN32 |
| 6407 | "-smb dir allow SMB access to files in 'dir' [-net user]\n" | 6408 | "-smb dir allow SMB access to files in 'dir' [-net user]\n" |
| 6408 | #endif | 6409 | #endif |
| @@ -6491,6 +6492,7 @@ enum { | @@ -6491,6 +6492,7 @@ enum { | ||
| 6491 | 6492 | ||
| 6492 | QEMU_OPTION_net, | 6493 | QEMU_OPTION_net, |
| 6493 | QEMU_OPTION_tftp, | 6494 | QEMU_OPTION_tftp, |
| 6495 | + QEMU_OPTION_bootp, | ||
| 6494 | QEMU_OPTION_smb, | 6496 | QEMU_OPTION_smb, |
| 6495 | QEMU_OPTION_redir, | 6497 | QEMU_OPTION_redir, |
| 6496 | 6498 | ||
| @@ -6567,6 +6569,7 @@ const QEMUOption qemu_options[] = { | @@ -6567,6 +6569,7 @@ const QEMUOption qemu_options[] = { | ||
| 6567 | { "net", HAS_ARG, QEMU_OPTION_net}, | 6569 | { "net", HAS_ARG, QEMU_OPTION_net}, |
| 6568 | #ifdef CONFIG_SLIRP | 6570 | #ifdef CONFIG_SLIRP |
| 6569 | { "tftp", HAS_ARG, QEMU_OPTION_tftp }, | 6571 | { "tftp", HAS_ARG, QEMU_OPTION_tftp }, |
| 6572 | + { "bootp", HAS_ARG, QEMU_OPTION_bootp }, | ||
| 6570 | #ifndef _WIN32 | 6573 | #ifndef _WIN32 |
| 6571 | { "smb", HAS_ARG, QEMU_OPTION_smb }, | 6574 | { "smb", HAS_ARG, QEMU_OPTION_smb }, |
| 6572 | #endif | 6575 | #endif |
| @@ -7085,6 +7088,9 @@ int main(int argc, char **argv) | @@ -7085,6 +7088,9 @@ int main(int argc, char **argv) | ||
| 7085 | case QEMU_OPTION_tftp: | 7088 | case QEMU_OPTION_tftp: |
| 7086 | tftp_prefix = optarg; | 7089 | tftp_prefix = optarg; |
| 7087 | break; | 7090 | break; |
| 7091 | + case QEMU_OPTION_bootp: | ||
| 7092 | + bootp_filename = optarg; | ||
| 7093 | + break; | ||
| 7088 | #ifndef _WIN32 | 7094 | #ifndef _WIN32 |
| 7089 | case QEMU_OPTION_smb: | 7095 | case QEMU_OPTION_smb: |
| 7090 | net_slirp_smb(optarg); | 7096 | net_slirp_smb(optarg); |
vl.h
| @@ -159,6 +159,7 @@ extern int smp_cpus; | @@ -159,6 +159,7 @@ extern int smp_cpus; | ||
| 159 | extern int no_quit; | 159 | extern int no_quit; |
| 160 | extern int semihosting_enabled; | 160 | extern int semihosting_enabled; |
| 161 | extern int autostart; | 161 | extern int autostart; |
| 162 | +extern const char *bootp_filename; | ||
| 162 | 163 | ||
| 163 | #define MAX_OPTION_ROMS 16 | 164 | #define MAX_OPTION_ROMS 16 |
| 164 | extern const char *option_rom[MAX_OPTION_ROMS]; | 165 | extern const char *option_rom[MAX_OPTION_ROMS]; |