qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: thuth@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qgraph: fix qos_node_contains with options
Date: Mon, 3 Jun 2019 10:34:59 +0200	[thread overview]
Message-ID: <a586ecb9-08b2-33ed-0926-47c75b2f8f80@redhat.com> (raw)
In-Reply-To: <20190603081335.8185-2-pbonzini@redhat.com>

On 6/3/19 10:13 AM, Paolo Bonzini wrote:
> Currently, if qos_node_contains was passed options, it would still
> create an edge without any options.  Instead, in that case
> NULL acts as a terminator.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  tests/libqos/qgraph.c | 12 ++++++++----
>  tests/libqos/qgraph.h | 15 +++++++++------
>  2 files changed, 17 insertions(+), 10 deletions(-)
> 
> diff --git a/tests/libqos/qgraph.c b/tests/libqos/qgraph.c
> index b149caaaa9..7a7ae2a19e 100644
> --- a/tests/libqos/qgraph.c
> +++ b/tests/libqos/qgraph.c
> @@ -632,15 +632,19 @@ void qos_node_create_driver(const char *name, QOSCreateDriverFunc function)
>  }
>  
>  void qos_node_contains(const char *container, const char *contained,
> -                       ...)
> +                       QOSGraphEdgeOptions *opts, ...)
>  {
>      va_list va;
> -    va_start(va, contained);
> -    QOSGraphEdgeOptions *opts;
>  
> +    if (opts == NULL) {
> +        add_edge(container, contained, QEDGE_CONTAINS, NULL);
> +        return;
> +    }
> +
> +    va_start(va, opts);
>      do {
> -        opts = va_arg(va, QOSGraphEdgeOptions *);
>          add_edge(container, contained, QEDGE_CONTAINS, opts);

'opts' argument is non-null, you use add it, ...

> +        opts = va_arg(va, QOSGraphEdgeOptions *);

... and fill it (now used as local variable) with the next vararg after
the 'opts' from the call arguments. OK.
Interesting optimization, although not trivial to review.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

>      } while (opts != NULL);
>  
>      va_end(va);
> diff --git a/tests/libqos/qgraph.h b/tests/libqos/qgraph.h
> index e799095b30..3a25dda4b2 100644
> --- a/tests/libqos/qgraph.h
> +++ b/tests/libqos/qgraph.h
> @@ -453,14 +453,16 @@ void qos_node_create_machine_args(const char *name,
>  void qos_node_create_driver(const char *name, QOSCreateDriverFunc function);
>  
>  /**
> - * qos_node_contains(): creates an edge of type QEDGE_CONTAINS and
> - * adds it to the edge list mapped to @container in the
> + * qos_node_contains(): creates one or more edges of type QEDGE_CONTAINS
> + * and adds them to the edge list mapped to @container in the
>   * edge hash table.
>   *
> - * This edge will have @container as source and @contained as destination.
> + * The edges will have @container as source and @contained as destination.
>   *
> - * It also has the possibility to add optional NULL-terminated
> - * @opts parameters (see %QOSGraphEdgeOptions)
> + * If @opts is NULL, a single edge will be added with no options.
> + * If @opts is non-NULL, the arguments after @contained represent a
> + * NULL-terminated list of %QOSGraphEdgeOptions structs, and an
> + * edge will be added for each of them.
>   *
>   * This function can be useful when there are multiple devices
>   * with the same node name contained in a machine/other node
> @@ -480,7 +482,8 @@ void qos_node_create_driver(const char *name, QOSCreateDriverFunc function);
>   * For contains, op1.arg and op1.size_arg represent the arg to pass
>   * to @contained constructor to properly initialize it.
>   */
> -void qos_node_contains(const char *container, const char *contained, ...);
> +void qos_node_contains(const char *container, const char *contained,
> +                       QOSGraphEdgeOptions *opts, ...);
>  
>  /**
>   * qos_node_produces(): creates an edge of type QEDGE_PRODUCES and
> 


      reply	other threads:[~2019-06-03  8:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-03  8:13 [Qemu-devel] [PATCH] qgraph: fix qos_node_contains with options Paolo Bonzini
2019-06-03  8:34 ` Philippe Mathieu-Daudé [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=a586ecb9-08b2-33ed-0926-47c75b2f8f80@redhat.com \
    --to=philmd@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.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).