qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Kővágó Zoltán" <dirty.ice.hu@gmail.com>
Cc: qemu-trivial@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
	qemu-devel@nongnu.org,
	"open list:Block layer core" <qemu-block@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] opts: produce valid command line in qemu_opts_print
Date: Fri, 03 Jul 2015 16:18:18 +0200	[thread overview]
Message-ID: <87y4ix1g0l.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <5596927F.5000407@gmail.com> ("Kővágó Zoltán"'s message of "Fri, 3 Jul 2015 15:47:43 +0200")

"Kővágó Zoltán" <dirty.ice.hu@gmail.com> writes:

> 2015-07-03 15:01 keltezéssel, Markus Armbruster írta:
>> "Kővágó, Zoltán" <dirty.ice.hu@gmail.com> writes:
>>
>>> This will let us print options in a format that the user would actually
>>> write it on the command line (foo=bar,baz=asd,etc=def), without
>>> prepending a spurious comma at the beginning of the list, or quoting
>>> values unnecessarily.  This patch provides the following changes:
>>> * write and id=, if the option has an id
>>> * do not print separator before the first element
>>> * do not quote string arguments
>>> * properly escape commas (,) for QEMU
>>>
>>> Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com>
>>> ---
>>>
>>> Changes from patch submitted as part of `qapi flattening':
>>> * no longer tries to do proper escaping for the shell
>>>
>>>   block.c            |  2 +-
>>>   util/qemu-option.c | 30 +++++++++++++++++++++++++++---
>>>   2 files changed, 28 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/block.c b/block.c
>>> index 7e130cc..78a5304 100644
>>> --- a/block.c
>>> +++ b/block.c
>>> @@ -3813,7 +3813,7 @@ void bdrv_img_create(const char *filename, const char *fmt,
>>>       }
>>>
>>>       if (!quiet) {
>>> -        printf("Formatting '%s', fmt=%s", filename, fmt);
>>> +        printf("Formatting '%s', fmt=%s ", filename, fmt);
>>>           qemu_opts_print(opts, " ");
>>>           puts("");
>>>       }
>>> diff --git a/util/qemu-option.c b/util/qemu-option.c
>>> index efe9d27..55ef172 100644
>>> --- a/util/qemu-option.c
>>> +++ b/util/qemu-option.c
>>> @@ -730,14 +730,36 @@ void qemu_opts_del(QemuOpts *opts)
>>>       g_free(opts);
>>>   }
>>>
>>> -void qemu_opts_print(QemuOpts *opts, const char *sep)
>>> +/* print value, escaping any commas in value */
>>> +static void escaped_print(const char *value)
>>
>> Have you searched the tree for existing code doing this?
>
> I didn't found any function like that.

Okay.

>>> +{
>>> +    const char *ptr;
>>> +
>>> +    for (ptr = value; *ptr; ++ptr) {
>>> +        if (*ptr == ',') {
>>> +            printf(",,");
>>> +        } else {
>>> +            putchar(*ptr);
>>> +        }
>>> +    }
>>
>> Slightly simpler:
>>
>>          if (*ptr == ',') {
>>              putchar(',');
>>          }
>>          putchar(*ptr);
>>
>> Matter of taste.
>
> I also like it better that way. Should I send a v2 patch?

If it's not too much trouble...  Feel free to keep my R-by then.

      reply	other threads:[~2015-07-03 14:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-03 11:40 [Qemu-devel] [PATCH] opts: produce valid command line in qemu_opts_print Kővágó, Zoltán
2015-07-03 13:01 ` Markus Armbruster
2015-07-03 13:47   ` Kővágó Zoltán
2015-07-03 14:18     ` Markus Armbruster [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y4ix1g0l.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=dirty.ice.hu@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).