Skip to contentSkip to conversation

block: Fix VM size column width in bdrv_snapshot_dump()

PATCH In review Kevin Wolf 3 participants 3 messages Feb 2, 2021 Block layer

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 block: Fix VM size column width in bdrv_snapshot_dump()

size_to_str() can return a size like "4.24 MiB", with a single digit integer part and two fractional digits. This is eight characters, but commit b39847a5 changed the format string to only reserve seven characters for the column.

This can result in unaligned columns, which in turn changes the output of iotests case 267 because exceeding the column size defeats the attempt to filter the size out of the output (observed with the ppc64 emulator). The resulting change is only a whitespace change, but since commit f203080b this is enough for iotests to consider the test failed.

Taking a character away from the tag name column and adding it to the VM size column doesn't change anything in the common case (the tag name is left justified, the VM size is right justified), but fixes this case.

Fixes b39847a50553b7679d6d7fefbe6a108a17aacf8d
---
 block/qapi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block/qapi.c +2 -2
index 0a96099e36..84a0aadc09 100644
@@ -677,7 +677,7 @@ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn)
     char *sizing = NULL;
 
     if (!sn) {
-        qemu_printf("%-10s%-18s%7s%20s%13s%11s",
+        qemu_printf("%-10s%-17s%8s%20s%13s%11s",
                     "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK", "ICOUNT");
     } else {
         ti = sn->date_sec;
@@ -696,7 +696,7 @@ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn)
             snprintf(icount_buf, sizeof(icount_buf),
                 "%"PRId64, sn->icount);
         }
-        qemu_printf("%-9s %-17s %7s%20s%13s%11s",
+        qemu_printf("%-9s %-16s %8s%20s%13s%11s",
                     sn->id_str, sn->name,
                     sizing,
                     date_buf,
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Kevin Wolf

size_to_str() can return a size like "4.24 MiB", with a single digit integer part and two fractional digits. This is eight characters, but commit b39847a5 changed the format string to only reserve seven characters for the column.

This can result in unaligned columns, which in turn changes the output of iotests case 267 because exceeding the column size defeats the attempt to filter the size out of the output (observed with the ppc64 emulator). The resulting change is only a whitespace change, but since commit f203080b this is enough for iotests to consider the test failed.

Quoted 6 lines

Taking a character away from the tag name column and adding it to the VM size column doesn't change anything in the common case (the tag name is left justified, the VM size is right justified), but fixes this case.

Fixes b39847a50553b7679d6d7fefbe6a108a17aacf8d
Quoted 9 lines
---
  block/qapi.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
block/qapi.c +0 -0
index 0a96099e36..84a0aadc09 100644

block/qapi.c void bdrv_snapshot_dump(QEMUSnapshotInfo *sn) · line 680

Quoted 5 lines
block/qapi.c +1 -1
@@ -677,7 +677,7 @@ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn)
      char *sizing = NULL;
 
      if (!sn) {
-        qemu_printf("%-10s%-18s%7s%20s%13s%11s",
+        qemu_printf("%-10s%-17s%8s%20s%13s%11s",

Hmm, the sum is 79, so I think it's safe to keep 18 for tag and still update 7 to 8.. But it doesn't really matter.

Quoted 13 lines
block/qapi.c +1 -1
                      "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK", "ICOUNT");
      } else {
          ti = sn->date_sec;
@@ -696,7 +696,7 @@ void bdrv_snapshot_dump(QEMUSnapshotInfo *sn)
              snprintf(icount_buf, sizeof(icount_buf),
                  "%"PRId64, sn->icount);
          }
-        qemu_printf("%-9s %-17s %7s%20s%13s%11s",
+        qemu_printf("%-9s %-16s %8s%20s%13s%11s",
                      sn->id_str, sn->name,
                      sizing,
                      date_buf,
Signature · 2 lines
Best regards,
Vladimir
Reviewed-by on v1 1/1
#2 lore raw
In reply to Kevin Wolf
Quoted 15 lines · Kevin Wolf

size_to_str() can return a size like "4.24 MiB", with a single digit integer part and two fractional digits. This is eight characters, but commit b39847a5 changed the format string to only reserve seven characters for the column.

This can result in unaligned columns, which in turn changes the output of iotests case 267 because exceeding the column size defeats the attempt to filter the size out of the output (observed with the ppc64 emulator). The resulting change is only a whitespace change, but since commit f203080b this is enough for iotests to consider the test failed.

Taking a character away from the tag name column and adding it to the VM size column doesn't change anything in the common case (the tag name is left justified, the VM size is right justified), but fixes this case.

Quoted 6 lines
Fixes b39847a50553b7679d6d7fefbe6a108a17aacf8d
---
 block/qapi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org