From: Stefan Hajnoczi <stefanha@gmail.com>
To: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/7] tests: qgraph API for the qtest driver framework
Date: Wed, 11 Jul 2018 15:28:19 +0100 [thread overview]
Message-ID: <20180711142819.GM31228@stefanha-x1.localdomain> (raw)
In-Reply-To: <20180709091136.28849-2-e.emanuelegiuseppe@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4943 bytes --]
On Mon, Jul 09, 2018 at 11:11:30AM +0200, Emanuele Giuseppe Esposito wrote:
> +/* Graph Edge.*/
> +struct QOSGraphEdge {
> + QOSEdgeType type;
> + char *dest;
> + char *arg; /* just for CONTAIS and CONSUMED_BY */
CONTAINS?
> +/**
> + * remove_node(): removes a node @val from the nodes hash table.
> + * Note that node->name is not free'd since it will represent the
> + * hash table key
> + */
> +static void remove_node(void *val)
This is a confusing function name and doc comment. It does not remove
the node from a hash table, it just frees it.
Please call this destroy_node(). The g_hash_table_new_full() argument
is GDestroyNotify value_destroy_func, so that would be consistent with
glib naming too.
> +{
> + QOSGraphNode *node = (QOSGraphNode *) val;
There is no need to cast void pointers in C. Just "QOSGraphNode *node =
val;" will do.
> +/**
> + * build_driver_cmd_line(): builds the command line for the driver
> + * @node. The node name must be a valid qemu identifier, since it
> + * will be used to build the command line.
> + *
> + * It is also possible to pass an optional @args that will be
> + * concatenated to the command line.
> + *
> + * For drivers, prepend -device to the driver name.
> + */
> +static void build_driver_cmd_line(QOSGraphNode *node, const char *args)
Why is this called "driver" instead of "device"?
> +{
> + if (args) {
> + node->command_line = g_strconcat("-device ", node->name, ",",
> + args, NULL);
> + } else {
> + node->command_line = g_strconcat("-device ", node->name, NULL);
> + }
> +}
> +
> +/**
> + * build_test_cmd_line(): builds the command line for the test
> + * @node. The node name need not to be a valid qemu identifier, since it
> + * will not be used to build the command line.
> + *
> + * It is also possible to pass an optional @args that will be
> + * used as additional command line.
> + */
> +static void build_test_cmd_line(QOSGraphNode *node, const char *args)
> +{
> + if (args) {
> + node->command_line = g_strdup(args);
> + } else {
> + node->command_line = NULL;
> + }
This is equivalent to:
node->command_line = g_strdup(args);
https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strdup
> diff --git a/tests/libqos/qgraph.h b/tests/libqos/qgraph.h
> new file mode 100644
> index 0000000000..54a1786c1e
> --- /dev/null
> +++ b/tests/libqos/qgraph.h
> @@ -0,0 +1,259 @@
> +/*
> + * libqos driver framework
The per-function doc comment are good. Please also include higher-level
examples of how to use this. At first glance all these functions are
overwhelming and it's not clear how to implement new tests, drivers,
interfaces, or machines.
See include/qom/object.h for inspiration.
> +/* edge types*/
> +enum QOSEdgeType {
> + CONTAINS,
> + PRODUCES,
> + CONSUMED_BY
> +};
> +
> +/* node types*/
> +enum QOSNodeType {
> + MACHINE,
> + DRIVER,
> + INTERFACE,
> + TEST
> +};
The QOSEdgeType and QOSNodeType enum constants use commonly-used names
in the global namespace. Please prefix them since this is a header
file that will be included from many source files.
> +
> +/**
> + * Each driver, test or machine will have this as first field.
> + * Depending on the edge, the node will call the corresponding
> + * function when walking the path.
> + *
> + * QOSGraphObject also provides a destructor, used to deallocate the
> + * after the test has been executed.
> + */
> +struct QOSGraphObject {
> + /* for produces, returns void * */
> + QOSGetDriver get_driver;
Unused?
> + /* for contains, returns a QOSGraphObject * */
> + QOSGetDevice get_device;
Unused?
> diff --git a/tests/libqos/qgraph_extra.h b/tests/libqos/qgraph_extra.h
> new file mode 100644
> index 0000000000..22850c0368
> --- /dev/null
> +++ b/tests/libqos/qgraph_extra.h
> @@ -0,0 +1,155 @@
> +/*
> + * libqos driver framework
> + *
> + * Copyright (c) 2018 Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License version 2 as published by the Free Software Foundation.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, see <http://www.gnu.org/licenses/>
> + */
> +
> +#ifndef QGRAPH_EXTRA_H
> +#define QGRAPH_EXTRA_H
> +
> +#include "qgraph.h"
> +#define PRINT_DEBUG 0
I would expect the #ifdef to be in the C file that uses it. PRINT_DEBUG
is too generic a name for a .h file, it may cause namespace collisions.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply other threads:[~2018-07-11 14:28 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-09 9:11 [Qemu-devel] [PATCH 0/7] Qtest driver framework Emanuele Giuseppe Esposito
2018-07-09 9:11 ` [Qemu-devel] [PATCH 1/7] tests: qgraph API for the qtest " Emanuele Giuseppe Esposito
2018-07-11 14:28 ` Stefan Hajnoczi [this message]
2018-07-11 14:58 ` Paolo Bonzini
2018-07-18 14:23 ` Stefan Hajnoczi
2018-07-18 18:05 ` Emanuele
2018-07-18 19:28 ` Paolo Bonzini
2018-07-18 21:13 ` Emanuele
2018-07-27 12:54 ` Stefan Hajnoczi
2018-07-09 9:11 ` [Qemu-devel] [PATCH 2/7] tests/qgraph: pci-pc driver and interface nodes Emanuele Giuseppe Esposito
2018-07-11 14:49 ` Stefan Hajnoczi
2018-07-11 15:18 ` Paolo Bonzini
2018-07-18 14:29 ` Stefan Hajnoczi
2018-07-18 18:29 ` Emanuele
2018-07-18 19:33 ` Paolo Bonzini
2018-07-18 20:49 ` Emanuele
2018-07-11 17:46 ` Emanuele
2018-07-18 15:02 ` Stefan Hajnoczi
2018-07-18 19:38 ` Paolo Bonzini
2018-07-11 20:05 ` Philippe Mathieu-Daudé
2018-07-09 9:11 ` [Qemu-devel] [PATCH 3/7] tests/qgraph: sdhci " Emanuele Giuseppe Esposito
2018-07-11 20:13 ` Philippe Mathieu-Daudé
2018-07-11 20:44 ` Emanuele
2018-07-09 9:11 ` [Qemu-devel] [PATCH 4/7] tests/qgraph: arm/raspi2 machine node Emanuele Giuseppe Esposito
2018-07-11 14:59 ` Stefan Hajnoczi
2018-07-11 15:30 ` Paolo Bonzini
2018-07-11 20:19 ` Philippe Mathieu-Daudé
2018-07-09 9:11 ` [Qemu-devel] [PATCH 5/7] tests/qgraph: x86_64/pc " Emanuele Giuseppe Esposito
2018-07-09 9:11 ` [Qemu-devel] [PATCH 6/7] tests/qgraph: gtest integration Emanuele Giuseppe Esposito
2018-07-11 15:02 ` Stefan Hajnoczi
2018-07-09 9:11 ` [Qemu-devel] [PATCH 7/7] tests/qgraph: sdhci test node Emanuele Giuseppe Esposito
2018-07-11 15:15 ` Stefan Hajnoczi
2018-07-11 17:52 ` Emanuele
2018-07-12 12:07 ` Paolo Bonzini
2018-07-11 14:00 ` [Qemu-devel] [PATCH 0/7] Qtest driver framework Stefan Hajnoczi
2018-07-11 14:17 ` Emanuele
2018-07-11 15:27 ` Stefan Hajnoczi
2018-07-18 17:14 ` Markus Armbruster
2018-07-18 19:35 ` Paolo Bonzini
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=20180711142819.GM31228@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=e.emanuelegiuseppe@gmail.com \
--cc=f4bug@amsat.org \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@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).