[libvirt] [PATCH] storage: Ensure 'qemu-img resize' size arg is a 512 multiple

Christophe Fergeau cfergeau at redhat.com
Tue May 14 14:28:34 UTC 2013


On Tue, May 14, 2013 at 09:56:44PM +0800, Osier Yang wrote:
> On 14/05/13 21:50, Christophe Fergeau wrote:
> >qemu-img resize will fail with "The new size must be a multiple of 512"
> >if libvirt doesn't round it first.
> >This fixes rhbz#951495
> >
> >Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
> >---
> >  src/storage/storage_backend_fs.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> >diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
> >index 9b83e57..99973b0 100644
> >--- a/src/storage/storage_backend_fs.c
> >+++ b/src/storage/storage_backend_fs.c
> >@@ -1219,6 +1219,10 @@ virStorageBackendFilesystemResizeQemuImg(const char *path,
> >          return -1;
> >      }
> >+    /* Round capacity up to the closest 512 multiple as qemu-img errors out
> >+     * on sizes which are not a multiple of 512 */
> >+    capacity = (capacity + 511) / 512 * 512;
> 
> There is macro VIR_DIV_UP for the purpose. 

Ah thanks, I knew there had to be such a macro, but could not find it ;)


> And should we document it somewhere?

In v2 I've added a short blob about the rounding in virStorageVolResize API
doc, hopefully that's a good place for that.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130514/4755862a/attachment-0001.sig>


More information about the libvir-list mailing list