From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Cc: Erwan Velu <erwan.velu@free.fr>
Subject: [Qemu-devel] [PATCH 3/3] Change -tftp option to take a root directory
Date: Sat, 17 Feb 2007 19:07:16 -0600 [thread overview]
Message-ID: <45D7A6C4.1020600@codemonkey.ws> (raw)
In-Reply-To: <45D7A43B.20808@codemonkey.ws>
[-- Attachment #1: Type: text/plain, Size: 542 bytes --]
This patch changes the -tftp option to take a root directory instead of
a prefix. I know it's common for a TFTP server to take a prefix but
it's easier typing wise to expose files as being part of a root. For
example, without this patch, to PXE boot:
qemu -hda disk.img -tftp /home/anthony/tftpboot -bootp
/home/anthony/tftpboot/pxelinux.0
With the patch:
qemu -hda disk.img -tftp /home/anthony/tftpboot -bootp /pxelinux.0
Also helps deal with the fact that TFTP filenames are limited to 512
characters.
Regards,
Anthony Liguori
[-- Attachment #2: tftp-root.diff --]
[-- Type: text/x-patch, Size: 2500 bytes --]
diff -r 91f98dfbdc3f qemu-doc.texi
--- a/qemu-doc.texi Thu Feb 15 21:22:02 2007 -0600
+++ b/qemu-doc.texi Thu Feb 15 21:22:03 2007 -0600
@@ -438,13 +438,12 @@ override the default configuration (@opt
override the default configuration (@option{-net nic -net user}) which
is activated if no @option{-net} options are provided.
-@item -tftp prefix
+@item -tftp dir
When using the user mode network stack, activate a built-in TFTP
-server. All filenames beginning with @var{prefix} can be downloaded
-from the host to the guest using a TFTP client. The TFTP client on the
-guest must be configured in binary mode (use the command @code{bin} of
-the Unix TFTP client). The host IP address on the guest is as usual
-10.0.2.2.
+server. The files in @var{dir} will be exposed as the root of a TFTP server.
+The TFTP client on the guest must be configured in binary mode (use the command
+@code{bin} of the Unix TFTP client). The host IP address on the guest is as
+usual 10.0.2.2.
@item -bootp file
When using the user mode network stack, broadcast @var{file} as the BOOTP
diff -r 91f98dfbdc3f slirp/tftp.c
--- a/slirp/tftp.c Thu Feb 15 21:22:02 2007 -0600
+++ b/slirp/tftp.c Thu Feb 15 21:22:03 2007 -0600
@@ -102,8 +102,15 @@ static int tftp_read_data(struct tftp_se
{
int fd;
int bytes_read = 0;
-
- fd = open(spt->filename, O_RDONLY | O_BINARY);
+ char buffer[1024];
+ int n;
+
+ n = snprintf(buffer, sizeof(buffer), "%s/%s",
+ tftp_prefix, spt->filename);
+ if (n >= sizeof(buffer))
+ return -1;
+
+ fd = open(buffer, O_RDONLY | O_BINARY);
if (fd < 0) {
return -1;
@@ -328,8 +335,7 @@ static void tftp_handle_rrq(struct tftp_
/* only allow exported prefixes */
- if (!tftp_prefix
- || (strncmp(spt->filename, tftp_prefix, strlen(tftp_prefix)) != 0)) {
+ if (!tftp_prefix) {
tftp_send_error(spt, 2, "Access violation", tp);
return;
}
diff -r 91f98dfbdc3f vl.c
--- a/vl.c Thu Feb 15 21:22:02 2007 -0600
+++ b/vl.c Thu Feb 15 21:22:03 2007 -0600
@@ -6487,7 +6487,7 @@ void help(void)
" is provided, the default is '-net nic -net user'\n"
"\n"
#ifdef CONFIG_SLIRP
- "-tftp prefix allow tftp access to files starting with prefix [-net user]\n"
+ "-tftp dir allow tftp access to files in dir [-net user]\n"
"-bootp file advertise file in BOOTP replies\n"
#ifndef _WIN32
"-smb dir allow SMB access to files in 'dir' [-net user]\n"
next prev parent reply other threads:[~2007-02-18 1:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-18 0:56 [Qemu-devel] [PATCH 0/3] Make BOOTP work with slirp Anthony Liguori
2007-02-18 1:01 ` [Qemu-devel] [PATCH 1/3] Add OACK support to slirp TFTP server Anthony Liguori
2007-02-18 1:04 ` [Qemu-devel] [PATCH 2/3] Add -bootp option for slip Anthony Liguori
2007-02-18 1:07 ` Anthony Liguori [this message]
2007-02-18 11:29 ` [Qemu-devel] Re: [PATCH 0/3] Make BOOTP work with slirp Erwan Velu
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=45D7A6C4.1020600@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=erwan.velu@free.fr \
--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).