diff mbox series

[1/2] block: Fix VM size field width in snapshot dump

Message ID 20200117105859.241818-2-mreitz@redhat.com (mailing list archive)
State New, archived
Headers show
Series block: Fix VM size field width in snapshot dump | expand

Commit Message

Max Reitz Jan. 17, 2020, 10:58 a.m. UTC
When printing the snapshot list (e.g. with qemu-img snapshot -l), the VM
size field is only seven characters wide.  As of de38b5005e9, this is
not necessarily sufficient: We generally print three digits, and this
may require a decimal point.  Also, the unit field grew from something
as plain as "M" to " MiB".  This means that number and unit may take up
eight characters in total; but we also want spaces in front.

Considering previously the maximum width was four characters and the
field width was chosen to be three characters wider, let us adjust the
field width to be eleven now.

Fixes: de38b5005e946aa3714963ea4c501e279e7d3666
Buglink: https://bugs.launchpad.net/qemu/+bug/1859989
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/qapi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Eric Blake Jan. 17, 2020, 1:52 p.m. UTC | #1
On 1/17/20 4:58 AM, Max Reitz wrote:
> When printing the snapshot list (e.g. with qemu-img snapshot -l), the VM
> size field is only seven characters wide.  As of de38b5005e9, this is
> not necessarily sufficient: We generally print three digits, and this
> may require a decimal point.  Also, the unit field grew from something
> as plain as "M" to " MiB".  This means that number and unit may take up
> eight characters in total; but we also want spaces in front.
> 
> Considering previously the maximum width was four characters and the
> field width was chosen to be three characters wider, let us adjust the
> field width to be eleven now.
> 
> Fixes: de38b5005e946aa3714963ea4c501e279e7d3666

My patch - hmm, yet another example of an "obvious bugfix" having 
non-obvious consequences :)

> Buglink: https://bugs.launchpad.net/qemu/+bug/1859989
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>   block/qapi.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox series

Patch

diff --git a/block/qapi.c b/block/qapi.c
index 9a5d0c9b27..ffa539250d 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -657,7 +657,7 @@  void bdrv_snapshot_dump(QEMUSnapshotInfo *sn)
     char *sizing = NULL;
 
     if (!sn) {
-        qemu_printf("%-10s%-20s%7s%20s%15s",
+        qemu_printf("%-10s%-20s%11s%20s%15s",
                     "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK");
     } else {
         ti = sn->date_sec;
@@ -672,7 +672,7 @@  void bdrv_snapshot_dump(QEMUSnapshotInfo *sn)
                  (int)(secs % 60),
                  (int)((sn->vm_clock_nsec / 1000000) % 1000));
         sizing = size_to_str(sn->vm_state_size);
-        qemu_printf("%-10s%-20s%7s%20s%15s",
+        qemu_printf("%-10s%-20s%11s%20s%15s",
                     sn->id_str, sn->name,
                     sizing,
                     date_buf,