[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH V3 0/8] virsh: rework command parsing

Old virsh command parsing mashes all the args back into a string and
miss the quotes, this patches fix it. It is also needed for introducing
qemu-monitor-command which is very useful.

This patches add vrshCommandParser abstraction to parser the args.
For command string, we use vshCommandStringParse()
For command argument vector, we use vshCommandArgvParse()

And the usage was changed:
virsh [options] [commands]

virsh [options]... [<command_string>]
virsh [options]... <command> [args...]

So we still support commands like:
# virsh "define D.xml; dumpxml D"
"define D.xml; dumpxml D" was parsed as a commands-string.

and support commands like:
# virsh qemu-monitor-command f13guest "info cpus"
we will not mash them into a string, we use new argv parser for it.

But we don't support the command like:
# virsh "define D.xml; dumpxml" D
"define D.xml; dumpxml" was parsed as a command-name, but we have no such command-name.

Misc changed behavior:
1) support single quote
2) support escape '\'
3) a better double quoting support, the following commands are now supported:
     virsh # dumpxml --"update-cpu" vm1
     virsh # dumpxml --update-cpu vm"1"
4) better handling the boolean options, in old code the following commands are equivalent: 
     virsh # dumpxml --update-cpu=vm1
     virsh # dumpxml --update-cpu vm1
   after this patch applied, the first one will become illegal.
5) support "--"

The idea of this patch is from Daniel P. Berrange.

changed from V1:
	changed the usage as Eric Blake suggested.
changed from V2
	new vrshCommandParser abstraction
	apply Eric Blake's comments.

Signed-off-by: Lai Jiangshan <laijs cn fujitsu com>
 virsh.c |  259 +++++++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 152 insertions(+), 107 deletions(-)

I was preparing for linuxcon japan and attended it and took a long vacation
after it, very late for V3.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]