[libvirt] [PATCH 04/16] storage_backend: Convert virRunWithHook usage to virCommand
Eric Blake
eblake at redhat.com
Tue May 10 23:25:55 UTC 2011
On 05/10/2011 02:07 PM, Cole Robinson wrote:
> virRunWithHook is now unused, so we can drop it. Tested w/ raw + qcow2
> volume creation and copying.
>
> Signed-off-by: Cole Robinson <crobinso at redhat.com>
> ---
> src/libvirt_private.syms | 1 -
> src/storage/storage_backend.c | 151 +++++++++++++++--------------------------
> src/util/util.c | 23 ++-----
> src/util/util.h | 3 -
> 4 files changed, 61 insertions(+), 117 deletions(-)
Only a 1:2 ratio; not quite as impressive as the 1:9 ratio in 1/16 :)
> @@ -945,13 +905,12 @@ virStorageBackendCreateQcowCreate(virConnectPtr conn ATTRIBUTE_UNUSED,
> return -1;
> }
>
> - imgargv[0] = virFindFileInPath("qcow-create");
> - imgargv[1] = size;
> - imgargv[2] = vol->target.path;
> - imgargv[3] = NULL;
> + create_tool = virFindFileInPath("qcow-create");
> + cmd = virCommandNewArgList(create_tool, size, vol->target.path, NULL);
Instead of separately tracking size as an allocated string for the
converted vol->capacity value, you can get a further reduction in lines
as well as less malloc pressure by using virCommandAddArgFormat("%llu",
VIR_DIV_UP(vol->capacity,1024*1024)) at the right location. Up to you
if you want to squash that in now or leave it for a followup patch.
ACK.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110510/33210c8b/attachment-0001.sig>
More information about the libvir-list
mailing list