[libvirt] [PATCH] Allow 5 characters for domain IDs

From: "Daniel P. Berrange" <berrange@redhat.com> Domain IDs are at least 16 bits for most hypervisors, theoretically event 32-bits. 3 characters is clearly too small an alignment. Increase alignment to 5 characters to allow 16-bit domain IDs to display cleanly. Commonly seen with LXC where domain IDs are the process IDs by default --- tools/virsh.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index f4c0063..e3aca32 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -944,7 +944,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) qsort(&names[0], maxname, sizeof(char*), namesorter); } } - vshPrintExtra(ctl, "%3s %-20s %s\n", _("Id"), _("Name"), _("State")); + vshPrintExtra(ctl, "%5s %-20s %s\n", _("Id"), _("Name"), _("State")); vshPrintExtra(ctl, "----------------------------------\n"); for (i = 0; i < maxid; i++) { @@ -954,7 +954,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) if (!dom) continue; - vshPrint(ctl, "%3d %-20s %s\n", + vshPrint(ctl, "%5d %-20s %s\n", virDomainGetID(dom), virDomainGetName(dom), _(vshDomainStateToString(vshDomainState(ctl, dom, NULL)))); @@ -974,7 +974,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) virDomainHasManagedSaveImage(dom, 0) > 0) state = -2; - vshPrint(ctl, "%3s %-20s %s\n", + vshPrint(ctl, "%5s %-20s %s\n", "-", names[i], state == -2 ? _("saved") : _(vshDomainStateToString(state))); -- 1.7.7.5

On 01/12/2012 12:49 PM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange"<berrange@redhat.com>
Domain IDs are at least 16 bits for most hypervisors, theoretically event 32-bits. 3 characters is clearly too small an alignment. Increase alignment to 5 characters to allow 16-bit domain IDs to display cleanly. Commonly seen with LXC where domain IDs are the process IDs by default ---
ACK. I was wondering if 3 characters were enough in long term usage. Hopefuly we won't break user's scripts with this change. (The parser would have to be really stupid to depend on 3 chars per domain ID) Peter

On 01/12/2012 12:49 PM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange"<berrange@redhat.com>
Domain IDs are at least 16 bits for most hypervisors, theoretically event 32-bits. 3 characters is clearly too small an alignment. Increase alignment to 5 characters to allow 16-bit domain IDs to display cleanly. Commonly seen with LXC where domain IDs are the process IDs by default --- tools/virsh.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c index f4c0063..e3aca32 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -944,7 +944,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) qsort(&names[0], maxname, sizeof(char*), namesorter); } } - vshPrintExtra(ctl, "%3s %-20s %s\n", _("Id"), _("Name"), _("State")); + vshPrintExtra(ctl, "%5s %-20s %s\n", _("Id"), _("Name"), _("State")); vshPrintExtra(ctl, "----------------------------------\n");
Oh maybe you should add some dashes to the line to incorporate the enlongation you made on the above string. Anyhow, ACK. Peter
participants (2)
-
Daniel P. Berrange
-
Peter Krempa