#include "virstring.h"
#include "virxml.h"
#include "conf/snapshot_conf.h"
+#include "vsh-table.h"
/* Helper for snapshot-create and snapshot-create-as */
static bool
char *parent_snap = NULL;
virDomainSnapshotPtr start = NULL;
virshSnapshotListPtr snaplist = NULL;
+ vshTablePtr table = NULL;
VSH_EXCLUSIVE_OPTIONS_VAR(tree, name);
VSH_EXCLUSIVE_OPTIONS_VAR(parent, roots);
if (!tree && !name) {
if (parent)
- vshPrintExtra(ctl, " %-20s %-25s %-15s %s",
- _("Name"), _("Creation Time"), _("State"),
- _("Parent"));
+ table = vshTableNew(_("Name"), _("Creation Time"), _("State"), _("Parent"), NULL);
else
- vshPrintExtra(ctl, " %-20s %-25s %s",
- _("Name"), _("Creation Time"), _("State"));
- vshPrintExtra(ctl, "\n"
- "------------------------------"
- "------------------------------\n");
+ table = vshTableNew(_("Name"), _("Creation Time"), _("State"), NULL);
+
+ if (!table)
+ goto cleanup;
}
if (tree) {
strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S %z",
&time_info);
- if (parent)
- vshPrint(ctl, " %-20s %-25s %-15s %s\n",
- snap_name, timestr, state, parent_snap);
- else
- vshPrint(ctl, " %-20s %-25s %s\n", snap_name, timestr, state);
+ if (parent) {
+ if (vshTableRowAppend(table, snap_name, timestr, state, parent_snap,
+ NULL) < 0)
+ goto cleanup;
+ } else {
+ if (vshTableRowAppend(table, snap_name, timestr, state,
+ NULL) < 0)
+ goto cleanup;
+ }
}
+ if (table)
+ vshTablePrintToStdout(table, ctl);
+
ret = true;
cleanup:
xmlFreeDoc(xml);
VIR_FREE(doc);
virshDomainFree(dom);
+ vshTableFree(table);
return ret;
}