qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Lucian Petrut <lpetrut@cloudbasesolutions.com>
Cc: Petrut Lucian <petrutlucian94@gmail.com>,
	"kwolf@redhat.com" <kwolf@redhat.com>,
	"sw@weilnetz.de" <sw@weilnetz.de>,
	"jcody@redhat.com" <jcody@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	Alessandro Pilotti <apilotti@cloudbasesolutions.com>
Subject: Re: [Qemu-devel] [[PATCH v2] 1/1] vpc.c: Add VHD resize support
Date: Tue, 23 Sep 2014 10:58:24 +0100	[thread overview]
Message-ID: <20140923095824.GJ2713@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <64050966FCE0B948BCE2B28DB6E0B7D5F156DA@CBSEX1.cloudbase.local>

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

On Mon, Sep 22, 2014 at 01:24:16PM +0000, Lucian Petrut wrote:
>  >> +    if (cpu_to_be32(footer->type) == VHD_DIFFERENCING) {
>  >footer_buf is big-endian so this should be be32_to_cpu()
> 
> My bad, I’ll fix the BE related issues.

The existing block/vpc.c code confuses beX_to_cpu() and cpu_to_beX().  I
have sent a patch to fix that ("[PATCH] vpc: fix beX_to_cpu() and
cpu_to_beX() confusion").

>  >> +        error_report("Resizing differencing vhd images is not supported.");
>  >> +        return -ENOTSUP;
>  >> +    }
>  >> +
>  >> +    old_bat_size = (s->max_table_entries * 4 + 511) & ~511;
>  >> +    new_total_sectors = offset / BDRV_SECTOR_SIZE;
>  >> +
>  >> +    for (index = 0; new_total_sectors > (int64_t)cyls * heads * secs_per_cyl;
>  >> +            index++) {
>  >> +        if (calculate_geometry(new_total_sectors + index, &cyls, &heads,
>  >> +                               &secs_per_cyl)) {
>  >> +            return -EFBIG;
>  >> +        }
>  >> +    }
>  >> +    new_total_sectors = (int64_t) cyls * heads * secs_per_cyl;
>  >> +    new_num_bat_entries = (new_total_sectors + s->block_size / 512) /
>  >> +                          (s->block_size / 512);
>  >This expression doesn't just round up, it always adds an extra block.
>  >Is this intentional?
>  >I expected the numerator for rounding up to be:
>  >  new_total_sectors + s->block_size / 512 - 1
> 
> This was intended, it may just add an extra entry. Also, the number
> of entries is calculated in the same way in the existing code which
> creates dynamic VHDs, so I wanted to keep consistency with that
> as well.

Okay, if existing code already does it like this it makes sense to be
consistent.

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

      reply	other threads:[~2014-09-23  9:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-19  9:59 [Qemu-devel] [[PATCH v2] 1/1] vpc.c: Add VHD resize support Lucian Petrut
2014-09-22 12:17 ` Stefan Hajnoczi
2014-09-22 13:24   ` Lucian Petrut
2014-09-23  9:58     ` Stefan Hajnoczi [this message]

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=20140923095824.GJ2713@stefanha-thinkpad.redhat.com \
    --to=stefanha@redhat.com \
    --cc=apilotti@cloudbasesolutions.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lpetrut@cloudbasesolutions.com \
    --cc=petrutlucian94@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sw@weilnetz.de \
    /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).