Re: [PATCH 4/4] virsh: concatenate qemu-monitor-command arguments

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

 



On 08/08/2011 03:40 AM, Daniel P. Berrange wrote:
On Fri, Aug 05, 2011 at 06:00:08PM -0600, Eric Blake wrote:
Call me lazy, but:

virsh qemu-monitor-command dom --hmp info status

is nicer than:

virsh qemu-monitor-command dom --hmp 'info status'

This does introduce a quoting problem though. eg consider

    virsh qemu-monitor-command dom --hmp 'foo  "Hello World"'

vs what you'd now allow:

    virsh qemu-monitor-command dom --hmp foo "Hello World"

This is no different from how the shell behaves. If you _want_ literal quotes to be part of the command, then you have to double-quote or otherwise escape those quotes. Here's some examples using two spaces to show where spacing is quoted vs. where concatenation occurs, in both shell and virsh.

$ echo a  "b  c"
a b  c
$ echo 'a  "b  c"'
a  "b  c"
$ echo a  \"b  c\"
a "b c"
$ virsh echo a  'b  c'
a b  c
$ virsh echo 'a  "b  c"'
a  "b  c"
$ virsh echo a  \"b  c\"
a "b c"
$ virsh
virsh # echo a  "b  c"
a b  c
virsh # echo 'a  "b  c"'
a  "b  c"
virsh # echo a  \"b  c\"
a "b c"
virsh # exit


-    if (vshCommandOptString(cmd, "cmd",&monitor_cmd)<= 0) {
-        vshError(ctl, "%s", _("missing monitor command"));
+    while ((opt = vshCommandOptArgv(cmd, opt))) {
+        virBufferAdd(&buf, opt->data, -1);
+        if (pad)
+            virBufferAddChar(&buf, ' ');
+        pad = true;
+    }

...this loop will loose the quoting on 'Hello World' I believe.

The shell already lost the quoting. Virsh should not be using heuristics to re-add arbitrary quoting, rather, if you need quoting to be passed through to the monitor command, you _have_ to use double-quoting or escapes. Your argument about losing quotes does not change this patch. Argument concatenation is most useful only for words that do not themselves contain quoting or spaces.

--
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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]