[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 22/26] Add a fallback bios file search, if -L
From: |
Michael Tokarev |
Subject: |
Re: [Qemu-devel] [PATCH v3 22/26] Add a fallback bios file search, if -L fails. |
Date: |
Sun, 21 Oct 2012 11:26:49 +0400 |
User-agent: |
Mozilla/5.0 (X11; Linux i686 on x86_64; rv:10.0.7) Gecko/20120922 Icedove/10.0.7 |
On 20.10.2012 00:43, Jason Baron wrote:
> From: Jason Baron <address@hidden>
>
> If -L <dir> is specified, and qemu does not find the bios file in <dir>, then
> the search fails. Add infrastructure such that the search will continue in
> the default paths, if not found in the -L path.
>
> Reviewed-by: Paolo Bonzini <address@hidden>
> Signed-off-by: Jason Baron <address@hidden>
> ---
> vl.c | 36 +++++++++++++++++++++++++-----------
> 1 files changed, 25 insertions(+), 11 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index 6b1e546..2a2d217 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -177,6 +177,7 @@ int main(int argc, char **argv)
> #define MAX_VIRTIO_CONSOLES 1
>
> static const char *data_dir;
> +static const char *data_dir_fallback;
> const char *bios_name = NULL;
> enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
> DisplayType display_type = DT_DEFAULT;
> @@ -1892,16 +1893,16 @@ static int balloon_parse(const char *arg)
> return -1;
> }
>
> -char *qemu_find_file(int type, const char *name)
> +static char *qemu_find_file_in_dir(int type, const char *name, const char
> *dir)
> {
> int len;
> const char *subdir;
> char *buf;
>
> - /* Try the name as a straight path first */
> - if (access(name, R_OK) == 0) {
> - return g_strdup(name);
> + if (!dir) {
> + return NULL;
> }
> +
> switch (type) {
> case QEMU_FILE_TYPE_BIOS:
> subdir = "";
> @@ -1912,9 +1913,9 @@ char *qemu_find_file(int type, const char *name)
> default:
> abort();
> }
> - len = strlen(data_dir) + strlen(name) + strlen(subdir) + 2;
> + len = strlen(dir) + strlen(name) + strlen(subdir) + 2;
> buf = g_malloc0(len);
> - snprintf(buf, len, "%s/%s%s", data_dir, subdir, name);
> + snprintf(buf, len, "%s/%s%s", dir, subdir, name);
> if (access(buf, R_OK)) {
> g_free(buf);
> return NULL;
> @@ -1922,6 +1923,21 @@ char *qemu_find_file(int type, const char *name)
> return buf;
> }
>
> +char *qemu_find_file(int type, const char *name)
> +{
> + char *filename;
> +
> + /* Try the name as a straight path first */
> + if (access(name, R_OK) == 0) {
> + return g_strdup(name);
> + }
FWIW, this can be a security issue, when a more privileged
user tries to run qemu from trusted path (/usr/bin) in a
directory owned by non-privileged user, to utilize -runas
or somesuch. I understand it's been this way since the
beginning.
Maybe we can do a bit better here, like (windows systems
aside) this:
if (strchr(name, '/') && access(name, R_OK) == 0) {...}
Note that -L can be set to "." in order to check in current
directory too.
And going forward, maybe we can treat -L argument as a PATH
(separated by whatever delimiter is okay) instead of just
a single directory? This way, for example, we can put
various kinds of data (pxe roms, vgabios roms etc) into
different places and qemu will be able to find them all.
I understand this whole thing is not really related to q35
changes, so can be pushed/applied separately.
Thanks,
/mjt
- [Qemu-devel] [PATCH v3 13/26] ich9: Add the lpc chip, (continued)
- [Qemu-devel] [PATCH v3 13/26] ich9: Add the lpc chip, Jason Baron, 2012/10/19
- [Qemu-devel] [PATCH v3 18/26] q35: Suppress SMM BIOS initialization under KVM, Jason Baron, 2012/10/19
- [Qemu-devel] [PATCH v3 16/26] ich9: Add i82801b11 dmi-to-pci bridge, Jason Baron, 2012/10/19
- [Qemu-devel] [PATCH v3 14/26] ich9: Add smbus, Jason Baron, 2012/10/19
- [Qemu-devel] [PATCH v3 22/26] Add a fallback bios file search, if -L fails., Jason Baron, 2012/10/19
- Re: [Qemu-devel] [PATCH v3 22/26] Add a fallback bios file search, if -L fails.,
Michael Tokarev <=
- [Qemu-devel] [PATCH v3 23/26] q35: automatically load the q35 dsdt table, Jason Baron, 2012/10/19
- [Qemu-devel] [PATCH v3 25/26] q35: fill in usb pci slots with -usb, Jason Baron, 2012/10/19
- [Qemu-devel] [PATCH v3 15/26] q35: Introduce q35 pc based chipset emulator, Jason Baron, 2012/10/19
- [Qemu-devel] [PATCH v3 21/26] q35: Add kvmclock support, Jason Baron, 2012/10/19
- [Qemu-devel] [PATCH v3 26/26] ich9: add support pci assignment, Jason Baron, 2012/10/19
- [Qemu-devel] [PATCH v3 20/26] q35: smbus: Remove PCI_STATUS_SIG_SYSTEM_ERROR and PCI_STATUS_DETECTED_PARITY from w1cmask, Jason Baron, 2012/10/19