virt-resize machine readable output

As I planned earlier I have added machine readable output to virt-resize.

One huge frustration we have had with qemu for a long time is that you cannot query a qemu binary for its “capabilities” (eg. does this binary support virtio? does this binary support particular -drive options?).

virt-resize now supports this kind of querying, thus with any virt-resize ≥ 1.12.5 you can do:

$ virt-resize --machine-readable
virt-resize
ntfsresize-force
32bitok
ntfs
btrfs

The simple list of facts is designed to be easy to parse. Does this virt-resize work on 32-bit platforms (old versions written in Perl didn’t)? Answer: yes because of the 32bitok fact. Does this binary support btrfs guests? In this case yes.

Over time as we add more features to virt-resize we will add facts to this list, so that consumers of virt-resize can tell what the binary supports.

This is a simple plan. Qemu developers, take note!

The second thing that this option does is to make the output of virt-resize more regular and easier to consume. At the moment this means that progress bars in virt-resize will revert to a simple format:

$ virt-resize --machine-readable old.img new.img
...
0/100
1/100
2/100
...

so that programs can just match on ^\d+/\d+$ on stdout, and turn that into a progress bar. User messages go to stdout and errors to stderr. The output is designed to be both very lightweight to parse and easy to understand for humans (and in fact not that much different from the regular virt-resize output). We may make small enhancements in future.

Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s