[libvirt] patch for virsh list

Hello I thought it would be cool if virsh list behaves a bit more like virt-manager or xm list because as a system-administrator i want to know with one look what VMs are active, how much memory they commit and what their runtime is. I implemented this with the following patch which give such an sample output. What is your opinion and/or have i missed something? [root@rr016 ~]# virsh list --all Id Name Status Mem(kB) VCPUs Time(s) --------------------------------------------------------------- 1 rr019v3 laufend 1572864 2 15,3 2 rr019v4 laufend 1572864 2 11,7 - OpenSolaris08.11 ausschalten - Win7b_64 ausschalten --- a/src/virsh.c 2009-04-15 21:43:26.000000000 +0200 +++ b/src/virsh.c 2009-05-15 21:35:53.000000000 +0200 @@ -658,14 +658,16 @@ qsort(&names[0], maxname, sizeof(char*), namesorter); } } - vshPrintExtra(ctl, "%3s %-20s %s\n", _("Id"), _("Name"), _("State")); - vshPrintExtra(ctl, "----------------------------------\n"); + vshPrintExtra(ctl, "%3s %-20s %-15s %-8s %-5s %-7s\n", _("Id"), _("Name"), _("State"), + _("Mem(kB)"), _("VCPUs"), _("Time(s)")); + vshPrintExtra(ctl, "---------------------------------------------------------------\n"); for (i = 0; i < maxid; i++) { virDomainInfo info; virDomainPtr dom = virDomainLookupByID(ctl->conn, ids[i]); const char *state; - + double cpuUsed = 0; + /* this kind of work with domains is not atomic operation */ if (!dom) continue; @@ -675,10 +677,19 @@ else state = N_(vshDomainStateToString(info.state)); - vshPrint(ctl, "%3d %-20s %s\n", + if (info.cpuTime != 0) { + cpuUsed = info.cpuTime; + + cpuUsed /= 1000000000.0; + } + + vshPrint(ctl, "%3d %-20s %-15s %-8d %-5d %7.1f\n", virDomainGetID(dom), virDomainGetName(dom), - state); + state, + virDomainGetMaxMemory(dom), + info.nrVirtCpu, + cpuUsed); virDomainFree(dom); } for (i = 0; i < maxname; i++) {

On Fri, May 15, 2009 at 09:48:14PM +0200, Gerrit Slomma wrote:
Hello
I thought it would be cool if virsh list behaves a bit more like virt-manager or xm list because as a system-administrator i want to know with one look what VMs are active, how much memory they commit and what their runtime is. I implemented this with the following patch which give such an sample output. What is your opinion and/or have i missed something?
If you want a virt-manager like display of VMs, 'virt-top' is the tool to use http://et.redhat.com/~rjones/virt-top/ Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Daniel P. Berrange schrieb:
If you want a virt-manager like display of VMs, 'virt-top' is the tool to use
http://et.redhat.com/~rjones/virt-top/
Regards, Daniel
Okay that gives the "xm top" but needs another tool to be installed. Since it comes from epel one could install it though. I gather extended info in virsh list is not wanted upstream then? I would find it handy when being in virsh to issue a "list" and find the commited memory, cpus of running VMs before firing up an additional VM. This is a little help to prevent overcommiting on a host and no-one could say he wasn't warned. Gerrit
participants (2)
-
Daniel P. Berrange
-
Gerrit Slomma