[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: old: virsh [options] [commands] new: 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.

On 10/12/2010 01:13 AM, Lai Jiangshan wrote:
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.
Thanks for splitting it up! It will make reviews easier. However, in the future, you should try and convince 'git send-email' or whatever mechanism you use to send patches to do shallow threading (all 8 of the n/8 patches should be in-reply-to the 0/8 cover letter), as it makes reviewing easier when the series is a single thread. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 10/12/2010 09:50 AM, Eric Blake wrote:
On 10/12/2010 01:13 AM, Lai Jiangshan wrote:
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.
Thanks for splitting it up! It will make reviews easier. However, in the future, you should try and convince 'git send-email' or whatever mechanism you use to send patches to do shallow threading (all 8 of the n/8 patches should be in-reply-to the 0/8 cover letter), as it makes reviewing easier when the series is a single thread.
Now that I've done a bit more research; here's the results, to make it easier for others to do: git config sendemail.chainreplyto false git config sendemail.thread false git config format.thread shallow Then: git send-email -8 --cover-letter will automatically send 8 messages all in reply to the cover letter, creating a single thread. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 10/12/2010 12:26 PM, Eric Blake wrote:
Now that I've done a bit more research; here's the results, to make it easier for others to do:
git config sendemail.chainreplyto false git config sendemail.thread false git config format.thread shallow
Then:
git send-email -8 --cover-letter
will automatically send 8 messages all in reply to the cover letter, creating a single thread.
Odd that it should require any configuring - mine has just always worked that way when I do, eg: git send-email -8 --compose (I hadn't seen "--cover-letter" before. The man page for git-send-email only lists "--compose", and I see the man page for git-format-patch only lists --cover-letter, but git send-email accepts both; I assume they're synonyms)

On 10/12/2010 01:01 PM, Laine Stump wrote:
On 10/12/2010 12:26 PM, Eric Blake wrote:
Now that I've done a bit more research; here's the results, to make it easier for others to do:
git config sendemail.chainreplyto false git config sendemail.thread false git config format.thread shallow
Then:
git send-email -8 --cover-letter
will automatically send 8 messages all in reply to the cover letter, creating a single thread.
Odd that it should require any configuring
Well, both send-email and format-patch can do threading; send-email calls format-patch under the hood, then skips threading if what format-patch returns contains threading. There's some historical baggage there, too; the two commands learned threading at different times, and in different ways (for example, format-patch --thread used to do deep threading unconditionally, where every patch is a reply to the previous patch rather than to the cover letter).
git send-email -8 --compose
(I hadn't seen "--cover-letter" before.
--compose starts up a blank cover letter; --cover-letter starts up a cover letter with 'git diff --stat' information already plugged in.
The man page for git-send-email only lists "--compose", and I see the man page for git-format-patch only lists --cover-letter, but git send-email accepts both; I assume they're synonyms)
Rather, the git-send-email man page states that all unrecognized options to get-send-email are passed through to git-format-patch (yes, that's a bit cheap of the documentation to take that shortcut, but you're welcome to file that as a git bug if you want). -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (3)
-
Eric Blake
-
Lai Jiangshan
-
Laine Stump