]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virsh: improve storage unit parsing
authorEric Blake <eblake@redhat.com>
Thu, 8 Mar 2012 01:10:30 +0000 (18:10 -0700)
committerEric Blake <eblake@redhat.com>
Thu, 8 Mar 2012 01:24:44 +0000 (18:24 -0700)
commitab95da40587665063b0c8eaeae22c91003f0da1c
tree26c9b58dcf47ec0042f2317e1bce3ad17457011f
parentaf3f9aabdee73472a9dd7758f88b9dde508be73f
virsh: improve storage unit parsing

Now can now do:

virsh vol-resize $vol 10M
virsh blockresize $dom $vol 10M

to get both interfaces to resize to 10MiB.  The remaining wart
is that vol-resize defaults to bytes, but blockresize defaults
to KiB, but we can't break existing scripts; oh well, it's no
worse than the same wart of the underlying virDomainBlockResize.

The API for virStorageVolResize states that capacity must always
be positive, and that the presence of shrink and delta flags is
what implies a negative change.

* tools/virsh.c (vshCommandOptScaledInt): New function.
(cmdVolResize): Don't pass negative size.
(cmdVolSize): Rename...
(vshVolSize): ...and use new helper routine.
(cmdBlockResize): Use new helper routine, and support new bytes
flag.
* tools/virsh.pod (NOTES): Document suffixes.
(blockresize, vol-create-as, vol-resize): Point to notes.
tools/virsh.c
tools/virsh.pod