On 10/12/2010 01:13 AM, Lai Jiangshan wrote:
in old code the following commands are equivalent: virsh # dumpxml --update-cpu=vm1 virsh # dumpxml --update-cpu vm1 because the old code split the option argument into 2 parts: --update-cpu=vm1 is split into update-cpu and vm1, and update-cpu is a boolean option, so the parser takes vm1 as another argument, very strange. after this patch applied, the first one will become illegal. To achieve this, we don't parse/check options when parsing command sting, but check options when parsing a command argument. And the argument is not split when parsing command sting. Signed-off-by: Lai Jiangshan<laijs@xxxxxxxxxxxxxx> +++ b/tools/virsh.c @@ -10164,14 +10164,12 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd) */ #define VSH_TK_ERROR -1 #define VSH_TK_NONE 0 -#define VSH_TK_OPTION 1 -#define VSH_TK_DATA 2 -#define VSH_TK_END 3 +#define VSH_TK_DATA 1 +#define VSH_TK_END 2
Maybe it would be nice to make these an enum rather than #defines, but that would be a separate cleanup patch, no impact to today's review.
@@ -10296,18 +10278,28 @@ vshCommandParse(vshControl *ctl, char *cmdstr) goto syntaxError; /* ... or ignore this command only? */ } VIR_FREE(tkdata); - } else if (tk == VSH_TK_OPTION) { - if (!(opt = vshCmddefGetOption(cmd, tkdata))) { + } else if (*tkdata == '-'&& *(tkdata + 1) == '-'&& *(tkdata + 2) +&& c_isalnum(*(tkdata + 2))) { + char *optstr = strchr(tkdata + 2, '='); + if (optstr) { + *optstr = '\0'; /* conver the '=' to '\0' */
s/conver/convert/ ACK with that nit fixed. -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list