On Thu, Mar 18, 2010 at 08:12:48PM +0100, Jiri Denemark wrote:
---
tools/virsh.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
tools/virsh.pod | 6 +++++
2 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index aa85ee6..3dd9314 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -227,6 +227,8 @@ static vshCmdOpt *vshCommandOpt(const vshCmd *cmd, const char
*name);
static int vshCommandOptInt(const vshCmd *cmd, const char *name, int *found);
static char *vshCommandOptString(const vshCmd *cmd, const char *name,
int *found);
+static long long vshCommandOptLongLong(const vshCmd *cmd, const char *name,
+ int *found);
#if 0
static int vshCommandOptStringList(const vshCmd *cmd, const char *name, char ***data);
#endif
@@ -2828,6 +2830,51 @@ cmdMigrate (vshControl *ctl, const vshCmd *cmd)
}
/*
+ * "migrate-setmaxdowntime" command
+ */
+static const vshCmdInfo info_migrate_setmaxdowntime[] = {
+ {"help", N_("set maximum tolerable downtime")},
+ {"desc", N_("Set maximum tolerable downtime of a domain which is
being live-migrated to another host.")},
+ {NULL, NULL}
+};
+
+static const vshCmdOptDef opts_migrate_setmaxdowntime[] = {
+ {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or
uuid")},
+ {"downtime", VSH_OT_DATA, VSH_OFLAG_REQ, N_("maximum tolerable
downtime (in nanoseconds) for migration")},
+ {NULL, 0, 0, NULL}
+};
Maybe for virsh command line we could use milliseconds, so that
a "setmaxdowntime foo 1" can still have a chance to actually work,
instead of blocking forever.
[...]
+/*
+ * Returns option as long long
+ */
+static long long
+vshCommandOptLongLong(const vshCmd *cmd, const char *name, int *found)
+{
+ vshCmdOpt *arg = vshCommandOpt(cmd, name);
+ int num_found = FALSE;
+ long long res = 0;
+ char *end_p = NULL;
+
+ if ((arg != NULL) && (arg->data != NULL))
+ num_found = !virStrToLong_ll(arg->data, &end_p, 10, &res);
+ if (found)
+ *found = num_found;
+ return res;
+}
and in that case we could go with a normal int processing there too
On one hand from an usability POV it looks more reasonnable to use
millisecs here, on the other hand each time we make virsh CLI and
libvirt API diverge in some way this leads to confusion.
So I'm still undecided :-)
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/