qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Bo Tu <tubo@linux.vnet.ibm.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, mreitz@redhat.com, mimu@linux.vnet.ibm.com,
	armbru@redhat.com, silbe@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH v1 1/4] qemu-iotests: refine common.config
Date: Fri, 30 Oct 2015 11:36:51 -0600	[thread overview]
Message-ID: <5633AAB3.50606@redhat.com> (raw)
In-Reply-To: <1446189186-23104-1-git-send-email-tubo@linux.vnet.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 2586 bytes --]

On 10/30/2015 01:13 AM, Bo Tu wrote:
> Be easier to read, and be slightly shorter.

You mentioned a very short "what" in the subject line (good), but the
"why" in the commit body ("easier to read, shorter") is rather terse and
subjective.  It would be nicer to go into details (change the definition
of default_alias_machine) or give a sample of what changes (use grep
instead of awk).

[meta-comment]

When sending a series, please include a 0/4 cover letter.  You may want
to do:
git config format.coverLetter auto
to make it automatic when using git format-patch/send-email.

> 
> Suggested-By: Sascha Silbe <silbe@linux.vnet.ibm.com>
> Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
> Signed-off-by: Bo Tu <tubo@linux.vnet.ibm.com>
> ---
>  tests/qemu-iotests/common.config | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
> index 596bb2b..0a165e8 100644
> --- a/tests/qemu-iotests/common.config
> +++ b/tests/qemu-iotests/common.config
> @@ -129,10 +129,9 @@ export QEMU_IO=_qemu_io_wrapper
>  export QEMU_NBD=_qemu_nbd_wrapper
>  
>  default_machine=$($QEMU -machine \? | awk '/(default)/{print $1}')
> -default_alias_machine=$($QEMU -machine \? |\
> -    awk -v var_default_machine="$default_machine"\)\
> -    '{if ($(NF-2)=="(alias"&&$(NF-1)=="of"&&$(NF)==var_default_machine){print $1}}')
> -if [ ! -z "$default_alias_machine" ]; then
> +default_alias_machine=$($QEMU -machine \? \

As long as we are touching this, we ought to switch to using '-machine
help' rather than the deprecated '-machine \?'.

> +    | grep -F "(alias of ${default_machine})" |cut -d ' ' -f 1 |head -n 1)

Why are you moving the | across lines?

If we are rewriting to avoid awk, why not do it with a single sed
process, rather than a grep|cut|head pipeline?  For that matter, why not
rewrite default_machine to also avoid awk?

default_machine=$($QEMU -machine help | sed -n '/(default)/ s/ .*//p')
default_alias_machine=$($QEMU -machine help | \
  sed -n "/(alias of $default_machine)"' { s/ .*//p; q; }')

(which happens to work even if $default_machine contains '.', but might
get a bit dicey if the machine names could ever contain ?, [, *, or
other regex metacharacters)

> +if [ -n "$default_alias_machine" ]; then

Could shorten this to:

if [[ $default_alias_machine ]]; then

since we are already using bash.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  parent reply	other threads:[~2015-10-30 17:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30  7:13 [Qemu-devel] [PATCH v1 1/4] qemu-iotests: refine common.config Bo Tu
2015-10-30  7:13 ` [Qemu-devel] [PATCH v1 2/4] qemu-iotests: s390x: fix test 051 Bo Tu
2015-10-30  7:13 ` [Qemu-devel] [PATCH v1 3/4] qemu-iotests: s390x: fix test 068 Bo Tu
2015-10-30  7:13 ` [Qemu-devel] [PATCH v1 4/4] qemu-iotests: disable VNC server for test 120 Bo Tu
2015-10-30 17:36 ` Eric Blake [this message]
2015-11-03  6:42   ` [Qemu-devel] [PATCH v1 1/4] qemu-iotests: refine common.config tu bo
2015-11-03 14:59     ` Eric Blake

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=5633AAB3.50606@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mimu@linux.vnet.ibm.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=silbe@linux.vnet.ibm.com \
    --cc=tubo@linux.vnet.ibm.com \
    /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).