From nobody Wed May 15 11:21:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1559550022; cv=none; d=zoho.com; s=zohoarc; b=Tx/pdBXpOhVYaqo/f9TsXQtws26k+XYUXt1cg1L6Zb754RaLKy3S6gGN/n7LW/n4NzISoU+YPTaz0hpd5W245hQIjYk7OTfBc2JT8lgW3dTV85c1sgojXTazseY81Ga5938lG8JbLU6rUQQ7p155CgiN9mR4wAqsfOkLibU6JDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559550022; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=RASIv4j0yvNDPjwkc4m/NY0pDahcsfVH0VcO2nL6+60=; b=nAaXPVOGlrFwXaHDPmUySLRuGhybe4xGANVBvpoXAYWxPG6Zz9a1SUZH2/i4mcyTROhub7pINRt6jr/WQMm+ZTwUVMEQIoCF86WH4pwZE+NGrkD7/0BhXdmmd1JrvzlAo0gx01orMsLWwhfdJJ8Bj7pLG0MobrjPiJzGdn5RxGg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559550022570362.3726149854473; Mon, 3 Jun 2019 01:20:22 -0700 (PDT) Received: from localhost ([127.0.0.1]:59470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXiBr-0001Sk-Tt for importer@patchew.org; Mon, 03 Jun 2019 04:19:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXi6A-000644-Mx for qemu-devel@nongnu.org; Mon, 03 Jun 2019 04:13:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXi69-0006iQ-JN for qemu-devel@nongnu.org; Mon, 03 Jun 2019 04:13:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40102) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hXi69-0006ha-DX for qemu-devel@nongnu.org; Mon, 03 Jun 2019 04:13:41 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B260630821F4 for ; Mon, 3 Jun 2019 08:13:40 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-59.ams2.redhat.com [10.36.112.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D38B5C8BD; Mon, 3 Jun 2019 08:13:38 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 3 Jun 2019 10:13:35 +0200 Message-Id: <20190603081335.8185-2-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 03 Jun 2019 08:13:40 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] qgraph: fix qos_node_contains with options X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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, QOSCrea= teDriverFunc function) } =20 void qos_node_contains(const char *container, const char *contained, - ...) + QOSGraphEdgeOptions *opts, ...) { va_list va; - va_start(va, contained); - QOSGraphEdgeOptions *opts; =20 + if (opts =3D=3D NULL) { + add_edge(container, contained, QEDGE_CONTAINS, NULL); + return; + } + + va_start(va, opts); do { - opts =3D va_arg(va, QOSGraphEdgeOptions *); add_edge(container, contained, QEDGE_CONTAINS, opts); + opts =3D va_arg(va, QOSGraphEdgeOptions *); } while (opts !=3D NULL); =20 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= ); =20 /** - * 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, QOSCreate= DriverFunc 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, ...); =20 /** * qos_node_produces(): creates an edge of type QEDGE_PRODUCES and --=20 2.21.0