From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Richard W.M. Jones" <rjones@redhat.com>
Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v5 1/2] loader: Add load_image_gzipped function.
Date: Tue, 05 Aug 2014 10:52:17 +0100 [thread overview]
Message-ID: <8761i7l0tj.fsf@linaro.org> (raw)
In-Reply-To: <1407152873-16772-2-git-send-email-rjones@redhat.com>
Richard W.M. Jones writes:
> As the name suggests this lets you load a ROM/disk image that is
> gzipped. It is uncompressed before storing it in guest memory.
>
<snip>
> +
> + /* Is it a gzip-compressed file? */
> + if (len < 2 ||
> + compressed_data[0] != '\x1f' ||
> + compressed_data[1] != '\x8b') {
> + goto out;
> + }
I was looking to see if the zlib library provided the magic numbers or a
verification routine here but I couldn't find it.
> +
> + if (max_sz > LOAD_IMAGE_MAX_GUNZIP_BYTES) {
> + max_sz = LOAD_IMAGE_MAX_GUNZIP_BYTES;
> + }
> +
> + data = g_malloc(max_sz);
> + bytes = gunzip(data, max_sz, compressed_data, len);
> + if (bytes < 0) {
> + fprintf(stderr, "%s: unable to decompress gzipped kernel file\n",
> + filename);
> + goto out;
> + }
> +
> + rom_add_blob_fixed(filename, data, bytes, addr);
> + ret = bytes;
> +
> + out:
> + g_free(compressed_data);
> + g_free(data);
> + return ret;
> +}
> +
> /*
> * Functions for reboot-persistent memory regions.
> * - used for vga bios and option roms.
> diff --git a/include/hw/loader.h b/include/hw/loader.h
> index 796cbf9..00c9117 100644
> --- a/include/hw/loader.h
> +++ b/include/hw/loader.h
> @@ -15,6 +15,7 @@ int get_image_size(const char *filename);
> int load_image(const char *filename, uint8_t *addr); /* deprecated */
> int load_image_targphys(const char *filename, hwaddr,
> uint64_t max_sz);
> +int load_image_gzipped(const char *filename, hwaddr addr, uint64_t max_sz);
>
> #define ELF_LOAD_FAILED -1
> #define ELF_LOAD_NOT_ELF -2
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
next prev parent reply other threads:[~2014-08-05 9:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-04 11:47 [Qemu-devel] [PATCH v5 0/2] aarch64: Allow -kernel option to take a gzip-compressed kernel Richard W.M. Jones
2014-08-04 11:47 ` [Qemu-devel] [PATCH v5 1/2] loader: Add load_image_gzipped function Richard W.M. Jones
2014-08-05 9:52 ` Alex Bennée [this message]
2014-08-05 9:57 ` Alex Bennée
2014-08-05 10:01 ` Richard W.M. Jones
2014-08-04 11:47 ` [Qemu-devel] [PATCH v5 2/2] aarch64: Allow -kernel option to take a gzip-compressed kernel Richard W.M. Jones
2014-08-05 10:00 ` Alex Bennée
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=8761i7l0tj.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rjones@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.