qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Tomáš Golembiovský" <tgolembi@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] qemu-nbd: Shrink image size by specified offset
Date: Wed, 5 Oct 2016 16:51:51 -0500	[thread overview]
Message-ID: <647a7dd0-9d4c-aa40-ed8a-6e8d63214e86@redhat.com> (raw)
In-Reply-To: <8a31654cb182932db78b95aae1e904fc2bd1c465.1475698895.git.tgolembi@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1178 bytes --]

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ý <tgolembi@redhat.com>
> ---
>  qemu-nbd.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> 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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2016-10-05 21:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-05 21:40 [Qemu-devel] [PATCH v2] qemu-nbd: Shrink image size by specified offset Tomáš Golembiovský
2016-10-05 21:51 ` Eric Blake [this message]
2016-10-06 10:46 ` Paolo Bonzini

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=647a7dd0-9d4c-aa40-ed8a-6e8d63214e86@redhat.com \
    --to=eblake@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=tgolembi@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 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).