[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] qemu-nbd: Shrink image size by specified off
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v2] qemu-nbd: Shrink image size by specified offset |
Date: |
Wed, 5 Oct 2016 16:51:51 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 |
On 10/05/2016 04:40 PM, Tomáš Golembiovský wrote:
> When --offset is set the apparent device size has to be adjusted
> accordingly. Otherwise client may request read/write beyond the file end
> which would fail.
>
> Signed-off-by: Tomáš Golembiovský <address@hidden>
> ---
> qemu-nbd.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
Reviewed-by: Eric Blake <address@hidden>
>
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index 99297a5..705b95e 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -901,6 +901,14 @@ int main(int argc, char **argv)
> exit(EXIT_FAILURE);
> }
>
> + if (dev_offset >= fd_size) {
> + error_report("Offset (%lld) has to be smaller than the image size "
> + "(%lld)",
> + (long long int)dev_offset, (long long int)fd_size);
> + exit(EXIT_FAILURE);
> + }
> + fd_size -= dev_offset;
> +
> if (partition != -1) {
> ret = find_partition(blk, partition, &dev_offset, &fd_size);
> if (ret < 0) {
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature