---
tools/virsh.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 591a1ce..2c0446c 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1292,6 +1292,7 @@ static const vshCmdOptDef opts_list[] = {
{"managed-save", VSH_OT_BOOL, 0,
N_("mark inactive domains with managed save state")},
{"title", VSH_OT_BOOL, 0, N_("show short domain description")},
+ {"hostname", VSH_OT_BOOL, 0, N_("show domain hostname")},
{NULL, 0, 0, NULL}
};
@@ -1307,8 +1308,9 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
bool optTable = vshCommandOptBool(cmd, "table");
bool optUUID = vshCommandOptBool(cmd, "uuid");
bool optName = vshCommandOptBool(cmd, "name");
+ bool optHostname = vshCommandOptBool(cmd, "hostname");
int i;
- char *title;
+ char *title, *hostname;
char uuid[VIR_UUID_STRING_BUFLEN];
int state;
bool ret = false;
@@ -1366,6 +1368,11 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
_("Id"), _("Name"), _("State"),
_("Title"),
"-----------------------------------------"
"-----------------------------------------");
+ else if (optHostname)
+ vshPrintExtra(ctl, " %-5s %-30s %-10s %-20s\n%s\n",
+ _("Id"), _("Name"), _("State"),
_("Hostname"),
+ "-----------------------------------------"
+ "-----------------------------------------");
else
vshPrintExtra(ctl, " %-5s %-30s %s\n%s\n",
_("Id"), _("Name"), _("State"),
@@ -1397,6 +1404,15 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
title);
VIR_FREE(title);
+ } else if (optHostname) {
+ if (!(hostname = virDomainGetHostname (dom, 0)))
+ goto cleanup;
+
+ vshPrint(ctl, " %-5s %-30s %-10s %-20s\n", id_buf,
+ virDomainGetName(dom),
+ state == -2 ? _("saved") :
_(vshDomainStateToString(state)),
+ hostname);
+ VIR_FREE(hostname);
} else {
vshPrint(ctl, " %-5s %-30s %s\n", id_buf,
virDomainGetName(dom),
--
1.7.10.4