Skip to contentSkip to conversation

QOM devices patch queue 2015-05-27

GIT PULL Andreas Färber 4 participants 19 messages May 27, 2015 – Jun 19, 2015 Arm STM32

lore
Share & tools
lore
#0 lore raw

Hello Peter,

This is my QOM (devices) patch queue. Please pull.

v2 contains changes that hopefully fix warnings on gcc 4.7.

Regards,
Andreas

Cc Peter Maydell <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Daniel P. Berrange <[email protected]>

The following changes since commit 0915aed5842bd4dbe396b92d4f3b846ae29ad663:

Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging (2015-05-26 11:31:03 +0100)

are available in the git repository at:

git://github.com/afaerber/qemu-cpu.git tags/qom-devices-for-peter

for you to fetch changes up to 2e6124921d6238f8c77326a7fdac5c1c211c88f7:

qom: Add object_property_add_const_link() (2015-05-27 20:16:30 +0200)

----------------------------------------------------------------
QOM infrastructure fixes and device conversions

* Changes to name string ownership for alias properties
* Improvements around enum properties
* Cleanups around -object handling
* New helper functions
* Add path argument to qom-tree script
* QTest cleanup to use new qtest_add_data_func() consistently

----------------------------------------------------------------
Andreas Färber (1):
tests: Use qtest_add_data_func() consistently

Daniel P. Berrange (7):
backends: Fix typename of 'policy' enum property in hostmem obj
doc: Document user creatable object types in help text
vl: Create (most) objects before creating chardev backends
qom: Add helper method for getting user objects root
qom: Add object_new_with_props() / object_new_withpropv() helpers
qom: Make enum string tables const-correct
qom: Add an object_property_add_enum() helper function

Eduardo Habkost (2):
qom: strdup() target property name on object_property_add_alias()
qdev: Free property names after registering gpio aliases

Martin Cerveny (1):
scripts: Add support for path as argument of qom-tree

Paolo Bonzini (1):
qom: Add object_property_add_const_link()

 backends/hostmem.c          |   2 +-
 hw/core/qdev.c              |   2 +
 include/hw/qdev-core.h      |   2 +-
 include/qapi/util.h         |   2 +-
 include/qapi/visitor-impl.h |   6 +-
 include/qapi/visitor.h      |   2 +-
 include/qemu/compiler.h     |   6 +
 include/qom/object.h        | 179 +++++++++++++++++++++++++++++-
 iothread.c                  |   4 +-
 numa.c                      |   2 +-
 qapi/qapi-dealloc-visitor.c |   3 +-
 qapi/qapi-util.c            |   2 +-
 qapi/qapi-visit-core.c      |   6 +-
 qemu-options.hx             |  70 +++++++++---
 qmp.c                       |   6 +-
 qom/object.c                | 195 ++++++++++++++++++++++++++++++++-
 scripts/qapi-types.py       |   4 +-
 scripts/qmp/qom-tree        |   9 +-
 tests/.gitignore            |   1 +
 tests/Makefile              |   5 +-
 tests/ahci-test.c           |   9 +-
 tests/check-qom-proplist.c  | 259 ++++++++++++++++++++++++++++++++++++++++++++
 tests/e1000-test.c          |   4 +-
 tests/eepro100-test.c       |   5 +-
 tests/endianness-test.c     |  18 +--
 tests/pc-cpu-test.c         |  13 +--
 tests/qom-test.c            |   4 +-
 vl.c                        |  40 ++++++-
 28 files changed, 785 insertions(+), 75 deletions(-)
 create mode 100644 tests/check-qom-proplist.c
#1 lore raw

[Qemu-devel] [PULL v2 01/12] qom: strdup() target property name on object_property_add_alias()

From: Eduardo Habkost <[email protected]>

With this, object_property_add_alias() callers can safely free the target property name, like what already happens with the 'name' argument to all object_property_add*() functions.

---
 qom/object.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
qom/object.c +3 -2
index b8dff43..550dd48 100644
@@ -1689,7 +1689,7 @@ void object_property_add_uint64_ptr(Object *obj, const char *name,
 
 typedef struct {
     Object *target_obj;
-    const char *target_name;
+    char *target_name;
 } AliasProperty;
 
 static void property_get_alias(Object *obj, struct Visitor *v, void *opaque,
@@ -1720,6 +1720,7 @@ static void property_release_alias(Object *obj, const char *name, void *opaque)
 {
     AliasProperty *prop = opaque;
 
+    g_free(prop->target_name);
     g_free(prop);
 }
 
@@ -1747,7 +1748,7 @@ void object_property_add_alias(Object *obj, const char *name,
 
     prop = g_malloc(sizeof(*prop));
     prop->target_obj = target_obj;
-    prop->target_name = target_name;
+    prop->target_name = g_strdup(target_name);
 
     op = object_property_add(obj, name, prop_type,
                              property_get_alias,
Signature · 1 line
2.1.4
#2 lore raw

[Qemu-devel] [PULL v2 12/12] qom: Add object_property_add_const_link()

In reply to Andreas Färber

From: Paolo Bonzini <[email protected]>

This helper adds a read-only link<> property.

---
 include/qom/object.h | 18 ++++++++++++++++++
 qom/object.c         | 16 ++++++++++++++++
 2 files changed, 34 insertions(+)
include/qom/object.h +18 -0
index 270a3ef..e8fb863 100644
@@ -1449,6 +1449,24 @@ void object_property_add_alias(Object *obj, const char *name,
                                Error **errp);
 
 /**
+ * object_property_add_const_link:
+ * @obj: the object to add a property to
+ * @name: the name of the property
+ * @target: the object to be referred by the link
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Add an unmodifiable link for a property on an object.  This function will
+ * add a property of type link<TYPE> where TYPE is the type of @target.
+ *
+ * The caller must ensure that @target stays alive as long as
+ * this property exists.  In the case @target is a child of @obj,
+ * this will be the case.  Otherwise, the caller is responsible for
+ * taking a reference.
+ */
+void object_property_add_const_link(Object *obj, const char *name,
+                                    Object *target, Error **errp);
+
+/**
  * object_property_set_description:
  * @obj: the object owning the property
  * @name: the name of the property
qom/object.c +16 -0
index f1b289c..8f0d8a7 100644
@@ -1386,6 +1386,22 @@ out:
     g_free(full_type);
 }
 
+void object_property_add_const_link(Object *obj, const char *name,
+                                    Object *target, Error **errp)
+{
+    char *link_type;
+    ObjectProperty *op;
+
+    link_type = g_strdup_printf("link<%s>", object_get_typename(target));
+    op = object_property_add(obj, name, link_type,
+                             object_get_child_property, NULL,
+                             NULL, target, errp);
+    if (op != NULL) {
+        op->resolve = object_resolve_child_property;
+    }
+    g_free(link_type);
+}
+
 gchar *object_get_canonical_path_component(Object *obj)
 {
     ObjectProperty *prop = NULL;
Signature · 1 line
2.1.4
#3 lore raw

[Qemu-devel] [PULL v2 02/12] qdev: Free property names after registering gpio aliases

In reply to Andreas Färber

From: Eduardo Habkost <[email protected]>

Now that object_property_add_alias() strdup()s target_name, we can free the property names in qdev_pass_gpios().

---
 hw/core/qdev.c | 2 ++
 1 file changed, 2 insertions(+)
hw/core/qdev.c +2 -0
index b0f0f84..d10fa5f 100644
@@ -563,6 +563,7 @@ void qdev_pass_gpios(DeviceState *dev, DeviceState *container,
         object_property_add_alias(OBJECT(container), propname,
                                   OBJECT(dev), propname,
                                   &error_abort);
+        g_free(propname);
     }
     for (i = 0; i < ngl->num_out; i++) {
         const char *nm = ngl->name ? ngl->name : "unnamed-gpio-out";
@@ -571,6 +572,7 @@ void qdev_pass_gpios(DeviceState *dev, DeviceState *container,
         object_property_add_alias(OBJECT(container), propname,
                                   OBJECT(dev), propname,
                                   &error_abort);
+        g_free(propname);
     }
     QLIST_REMOVE(ngl, node);
     QLIST_INSERT_HEAD(&container->gpios, ngl, node);
Signature · 1 line
2.1.4
#4 lore raw

[Qemu-devel] [PULL v2 04/12] scripts: Add support for path as argument of qom-tree

In reply to Andreas Färber

From: Martin Cerveny <[email protected]>

Add processing of optional argument path as "tree base".

---
 scripts/qmp/qom-tree | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
scripts/qmp/qom-tree +7 -2
index aea11d4..906fcd2 100755
@@ -65,6 +65,11 @@ def list_node(path):
     print ''
     for item in items:
         if item['type'].startswith('child<'):
-            list_node(path + '/' + item['name'])
+            list_node((path if (path != '/') else '')  + '/' + item['name'])
 
-list_node('/machine')
+if len(args) == 0:
+    path = '/'
+else:
+    path = args[0]
+
+list_node(path)
Signature · 1 line
2.1.4
#5 lore raw

[Qemu-devel] [PULL v2 05/12] backends: Fix typename of 'policy' enum property in hostmem obj

In reply to Andreas Färber

From: "Daniel P. Berrange" <[email protected]>

The 'policy' property was being registered with a typename of 'str', but it is in fact an enum of the 'HostMemPolicy' type.

---
 backends/hostmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
backends/hostmem.c +1 -1
index b7b6cf8..f6db33c 100644
@@ -252,7 +252,7 @@ static void host_memory_backend_init(Object *obj)
     object_property_add(obj, "host-nodes", "int",
                         host_memory_backend_get_host_nodes,
                         host_memory_backend_set_host_nodes, NULL, NULL, NULL);
-    object_property_add(obj, "policy", "str",
+    object_property_add(obj, "policy", "HostMemPolicy",
                         host_memory_backend_get_policy,
                         host_memory_backend_set_policy, NULL, NULL, NULL);
 }
Signature · 1 line
2.1.4
#6 lore raw

[Qemu-devel] [PULL v2 06/12] doc: Document user creatable object types in help text

In reply to Andreas Färber

From: "Daniel P. Berrange" <[email protected]>

The QEMU help for -object is essentially useless, just giving users the generic syntax. Move it down into its own section and introduce a nested table where each user creatable object can be documented. The existing memory-backend-file, rng-random and rng-egd object types are documented.

---
 qemu-options.hx | 70 ++++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 54 insertions(+), 16 deletions(-)
qemu-options.hx +54 -16
index ec356f6..00ae287 100644
@@ -3421,22 +3421,6 @@ DEF("no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip, "", QEMU_ARCH_I386)
 HXCOMM Deprecated (ignored)
 DEF("tdf", 0, QEMU_OPTION_tdf,"", QEMU_ARCH_ALL)
 
-DEF("object", HAS_ARG, QEMU_OPTION_object,
-    "-object TYPENAME[,PROP1=VALUE1,...]\n"
-    "                create an new object of type TYPENAME setting properties\n"
-    "                in the order they are specified.  Note that the 'id'\n"
-    "                property must be set.  These objects are placed in the\n"
-    "                '/objects' path.\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -object @var{typename}[,@var{prop1}=@var{value1},...]
-@findex -object
-Create an new object of type @var{typename} setting properties
-in the order they are specified.  Note that the 'id'
-property must be set.  These objects are placed in the
-'/objects' path.
-ETEXI
-
 DEF("msg", HAS_ARG, QEMU_OPTION_msg,
     "-msg timestamp[=on|off]\n"
     "                change the format of messages\n"
@@ -3462,6 +3446,60 @@ Dump json-encoded vmstate information for current machine type to file
 in @var{file}
 ETEXI
 
+DEFHEADING(Generic object creation)
+
+DEF("object", HAS_ARG, QEMU_OPTION_object,
+    "-object TYPENAME[,PROP1=VALUE1,...]\n"
+    "                create a new object of type TYPENAME setting properties\n"
+    "                in the order they are specified.  Note that the 'id'\n"
+    "                property must be set.  These objects are placed in the\n"
+    "                '/objects' path.\n",
+    QEMU_ARCH_ALL)
+STEXI
+@item -object @var{typename}[,@var{prop1}=@var{value1},...]
+@findex -object
+Create a new object of type @var{typename} setting properties
+in the order they are specified.  Note that the 'id'
+property must be set.  These objects are placed in the
+'/objects' path.
+
+@table @option
+
+@item -object memory-backend-file,id=@var{id},size=@var{size},mem-path=@var{dir},share=@var{on|off}
+
+Creates a memory file backend object, which can be used to back
+the guest RAM with huge pages. The @option{id} parameter is a
+unique ID that will be used to reference this memory region
+when configuring the @option{-numa} argument. The @option{size}
+option provides the size of the memory region, and accepts
+common suffixes, eg @option{500M}. The @option{mem-path} provides
+the path to either a shared memory or huge page filesystem mount.
+The @option{share} boolean option determines whether the memory
+region is marked as private to QEMU, or shared. The latter allows
+a co-operating external process to access the QEMU memory region.
+
+@item -object rng-random,id=@var{id},filename=@var{/dev/random}
+
+Creates a random number generator backend which obtains entropy from
+a device on the host. The @option{id} parameter is a unique ID that
+will be used to reference this entropy backend from the @option{virtio-rng}
+device. The @option{filename} parameter specifies which file to obtain
+entropy from and if omitted defaults to @option{/dev/random}.
+
+@item -object rng-egd,id=@var{id},chardev=@var{chardevid}
+
+Creates a random number generator backend which obtains entropy from
+an external daemon running on the host. The @option{id} parameter is
+a unique ID that will be used to reference this entropy backend from
+the @option{virtio-rng} device. The @option{chardev} parameter is
+the unique ID of a character device backend that provides the connection
+to the RNG daemon.
+
+@end table
+
+ETEXI
+
+
 HXCOMM This is the last statement. Insert new options before this line!
 STEXI
 @end table
Signature · 1 line
2.1.4
#7 lore raw

[Qemu-devel] [PULL v2 07/12] vl: Create (most) objects before creating chardev backends

In reply to Andreas Färber

From: "Daniel P. Berrange" <[email protected]>

Some types of object must be created before chardevs, other types of object must be created after chardevs. As such there is no option but to create objects in two phases.

This takes the decision to create as many object types as possible right away before anyother backends are created, and only delay creation of those few which have an explicit dependency on the chardevs. Hopefully the set which need delaying will remain small over time.

---
 vl.c | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)
vl.c +39 -1
index 15bccc4..b7c7511 100644
@@ -2601,6 +2601,33 @@ static int machine_set_property(const char *name, const char *value,
     return 0;
 }
 
+
+/*
+ * Initial object creation happens before all other
+ * QEMU data types are created. The majority of objects
+ * can be created at this point. The rng-egd object
+ * cannot be created here, as it depends on the chardev
+ * already existing.
+ */
+static bool object_create_initial(const char *type)
+{
+    if (g_str_equal(type, "rng-egd")) {
+        return false;
+    }
+    return true;
+}
+
+
+/*
+ * The remainder of object creation happens after the
+ * creation of chardev, fsdev and device data types.
+ */
+static bool object_create_delayed(const char *type)
+{
+    return !object_create_initial(type);
+}
+
+
 static int object_create(QemuOpts *opts, void *opaque)
 {
     Error *err = NULL;
@@ -2609,6 +2636,7 @@ static int object_create(QemuOpts *opts, void *opaque)
     void *dummy = NULL;
     OptsVisitor *ov;
     QDict *pdict;
+    bool (*type_predicate)(const char *) = opaque;
 
     ov = opts_visitor_new(opts);
     pdict = qemu_opts_to_qdict(opts, NULL);
@@ -2623,6 +2651,9 @@ static int object_create(QemuOpts *opts, void *opaque)
     if (err) {
         goto out;
     }
+    if (!type_predicate(type)) {
+        goto out;
+    }
 
     qdict_del(pdict, "id");
     visit_type_str(opts_get_visitor(ov), &id, "id", &err);
@@ -4031,6 +4062,12 @@ int main(int argc, char **argv, char **envp)
 
     socket_init();
 
+    if (qemu_opts_foreach(qemu_find_opts("object"),
+                          object_create,
+                          object_create_initial, 0) != 0) {
+        exit(1);
+    }
+
     if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0)
         exit(1);
 #ifdef CONFIG_VIRTFS
@@ -4050,7 +4087,8 @@ int main(int argc, char **argv, char **envp)
     }
 
     if (qemu_opts_foreach(qemu_find_opts("object"),
-                          object_create, NULL, 0) != 0) {
+                          object_create,
+                          object_create_delayed, 0) != 0) {
         exit(1);
     }
 
Signature · 1 line
2.1.4
#8 lore raw

Re: [Qemu-devel] [PULL v2 07/12] vl: Create (most) objects before creating chardev backends

Am 27.05.2015 um 20:20 schrieb Andreas Färber:

Quoted 12 lines

From: "Daniel P. Berrange" <[email protected]>

Some types of object must be created before chardevs, other types of object must be created after chardevs. As such there is no option but to create objects in two phases.

This takes the decision to create as many object types as possible right away before anyother backends are created, and only delay creation of those few which have an explicit dependency on the chardevs. Hopefully the set which need delaying will remain small over time.

Quoted 6 lines
---
 vl.c | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

Rebasing my queue, I needed the attached changes to make it apply and build. Second pairs of eyes welcome.

Regards,
Andreas

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)
vl.c +0 -0
diff --cc vl.c
index 2201e27,b7c7511..0000000
@@@ -2671,7 -2601,34 +2671,34 @@@ static int machine_set_property(void *o
      return 0;
  }
  
+ 
+ /*
+  * Initial object creation happens before all other
+  * QEMU data types are created. The majority of objects
+  * can be created at this point. The rng-egd object
+  * cannot be created here, as it depends on the chardev
+  * already existing.
+  */
+ static bool object_create_initial(const char *type)
+ {
+     if (g_str_equal(type, "rng-egd")) {
+         return false;
+     }
+     return true;
+ }
+ 
+ 
+ /*
+  * The remainder of object creation happens after the
+  * creation of chardev, fsdev and device data types.
+  */
+ static bool object_create_delayed(const char *type)
+ {
+     return !object_create_initial(type);
+ }
+ 
+ 
 -static int object_create(QemuOpts *opts, void *opaque)
 +static int object_create(void *opaque, QemuOpts *opts, Error **errp)
  {
      Error *err = NULL;
      char *type = NULL;
@@@ -4114,14 -4062,16 +4145,20 @@@ int main(int argc, char **argv, char **
  
      socket_init();
  
+     if (qemu_opts_foreach(qemu_find_opts("object"),
+                           object_create,
 -                          object_create_initial, 0) != 0) {
++                          object_create_initial, NULL)) {
+         exit(1);
+     }
+ 
 -    if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0)
 +    if (qemu_opts_foreach(qemu_find_opts("chardev"),
 +                          chardev_init_func, NULL, NULL)) {
          exit(1);
 +    }
 +
  #ifdef CONFIG_VIRTFS
 -    if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, 1) != 0) {
 +    if (qemu_opts_foreach(qemu_find_opts("fsdev"),
 +                          fsdev_init_func, NULL, NULL)) {
          exit(1);
      }
  #endif
@@@ -4137,7 -4087,8 +4174,8 @@@
      }
  
      if (qemu_opts_foreach(qemu_find_opts("object"),
-                           object_create, NULL, NULL)) {
+                           object_create,
 -                          object_create_delayed, 0) != 0) {
++                          object_create_delayed, NULL)) {
          exit(1);
      }
  
#9 lore raw

Re: [Qemu-devel] [PULL v2 07/12] vl: Create (most) objects before creating chardev backends

Quoted 20 lines · Andreas Färber

Am 27.05.2015 um 20:20 schrieb Andreas Färber:

Quoted 12 lines

From: "Daniel P. Berrange" <[email protected]>

Some types of object must be created before chardevs, other types of object must be created after chardevs. As such there is no option but to create objects in two phases.

This takes the decision to create as many object types as possible right away before anyother backends are created, and only delay creation of those few which have an explicit dependency on the chardevs. Hopefully the set which need delaying will remain small over time.

Quoted 6 lines
---
 vl.c | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)
Quoted 2 lines

Rebasing my queue, I needed the attached changes to make it apply and build. Second pairs of eyes welcome.

Looks good.

Paolo

#10 lore raw

Re: [Qemu-devel] [PULL v2 07/12] vl: Create (most) objects before creating chardev backends

In reply to Andreas Färber
Quoted 49 lines · Andreas Färber

Am 27.05.2015 um 20:20 schrieb Andreas Färber:

Quoted 12 lines

From: "Daniel P. Berrange" <[email protected]>

Some types of object must be created before chardevs, other types of object must be created after chardevs. As such there is no option but to create objects in two phases.

This takes the decision to create as many object types as possible right away before anyother backends are created, and only delay creation of those few which have an explicit dependency on the chardevs. Hopefully the set which need delaying will remain small over time.

Quoted 6 lines
---
 vl.c | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

Rebasing my queue, I needed the attached changes to make it apply and build. Second pairs of eyes welcome.

(quoted diff) +6 -0
@@@ -4114,14 -4062,16 +4145,20 @@@ int main(int argc, char **argv, char **
 
      socket_init();
 
+     if (qemu_opts_foreach(qemu_find_opts("object"),
+                           object_create,
 -                          object_create_initial, 0) != 0) {
++                          object_create_initial, NULL)) {
+         exit(1);
+     }
+ 
 -    if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0)
 +    if (qemu_opts_foreach(qemu_find_opts("chardev"),
 +                          chardev_init_func, NULL, NULL)) {
          exit(1);
 +    }
 +
  #ifdef CONFIG_VIRTFS
 -    if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, 1) != 0) {
 +    if (qemu_opts_foreach(qemu_find_opts("fsdev"),
 +                          fsdev_init_func, NULL, NULL)) {
          exit(1);
      }
  #endif

Review

Quoted 9 lines
(quoted diff) +2 -1
@@@ -4137,7 -4087,8 +4174,8 @@@
      }
 
      if (qemu_opts_foreach(qemu_find_opts("object"),
-                           object_create, NULL, NULL)) {
+                           object_create,
 -                          object_create_delayed, 0) != 0) {
++                          object_create_delayed, NULL)) {
          exit(1);
      }

Yep, this looks correct wrt the change of Markus' that recently merged in vl.c

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#11 lore raw

[Qemu-devel] [PULL v2 08/12] qom: Add helper method for getting user objects root

In reply to Andreas Färber

From: "Daniel P. Berrange" <[email protected]>

Add object_get_objects_root() method which is a convience for obtaining the Object * located at /objects in the object composition tree. Convert existing code over to use the new API where appropriate.

---
 include/qom/object.h | 12 ++++++++++++
 iothread.c           |  4 +---
 numa.c               |  2 +-
 qmp.c                |  6 +++---
 qom/object.c         |  5 +++++
 5 files changed, 22 insertions(+), 7 deletions(-)
include/qom/object.h +12 -0
index d2d7748..d30c68c 100644
@@ -1026,6 +1026,18 @@ const char *object_property_get_type(Object *obj, const char *name,
  */
 Object *object_get_root(void);
 
+
+/**
+ * object_get_objects_root:
+ *
+ * Get the container object that holds user created
+ * object instances. This is the object at path
+ * "/objects"
+ *
+ * Returns: the user object container
+ */
+Object *object_get_objects_root(void);
+
 /**
  * object_get_canonical_path_component:
  *
iothread.c +1 -3
index 0416fc4..98dcdf9 100644
@@ -19,8 +19,6 @@
 #include "qmp-commands.h"
 #include "qemu/error-report.h"
 
-#define IOTHREADS_PATH "/objects"
-
 typedef ObjectClass IOThreadClass;
 
 #define IOTHREAD_GET_CLASS(obj) \
@@ -153,7 +151,7 @@ IOThreadInfoList *qmp_query_iothreads(Error **errp)
 {
     IOThreadInfoList *head = NULL;
     IOThreadInfoList **prev = &head;
-    Object *container = container_get(object_get_root(), IOTHREADS_PATH);
+    Object *container = object_get_objects_root();
 
     object_child_foreach(container, query_one_iothread, &prev);
     return head;
numa.c +1 -1
index c975fb2..b14a5c1 100644
@@ -486,7 +486,7 @@ MemdevList *qmp_query_memdev(Error **errp)
     Object *obj;
     MemdevList *list = NULL;
 
-    obj = object_resolve_path("/objects", NULL);
+    obj = object_get_objects_root();
     if (obj == NULL) {
         return NULL;
     }
qmp.c +3 -3
index 3f5dfe3..fa013e3 100644
@@ -651,7 +651,7 @@ void object_add(const char *type, const char *id, const QDict *qdict,
         }
     }
 
-    object_property_add_child(container_get(object_get_root(), "/objects"),
+    object_property_add_child(object_get_objects_root(),
                               id, obj, &local_err);
     if (local_err) {
         goto out;
@@ -659,7 +659,7 @@ void object_add(const char *type, const char *id, const QDict *qdict,
 
     user_creatable_complete(obj, &local_err);
     if (local_err) {
-        object_property_del(container_get(object_get_root(), "/objects"),
+        object_property_del(object_get_objects_root(),
                             id, &error_abort);
         goto out;
     }
@@ -706,7 +706,7 @@ void qmp_object_del(const char *id, Error **errp)
     Object *container;
     Object *obj;
 
-    container = container_get(object_get_root(), "/objects");
+    container = object_get_objects_root();
     obj = object_resolve_path_component(container, id);
     if (!obj) {
         error_setg(errp, "object id not found");
qom/object.c +5 -0
index 550dd48..63bd300 100644
@@ -1054,6 +1054,11 @@ Object *object_get_root(void)
     return root;
 }
 
+Object *object_get_objects_root(void)
+{
+    return container_get(object_get_root(), "/objects");
+}
+
 static void object_get_child_property(Object *obj, Visitor *v, void *opaque,
                                       const char *name, Error **errp)
 {
Signature · 1 line
2.1.4
#12 lore raw

[Qemu-devel] [PULL v2 10/12] qom: Make enum string tables const-correct

In reply to Andreas Färber

From: "Daniel P. Berrange" <[email protected]>

The enum string table parameters in various QOM/QAPI methods are declared 'const char *strings[]'. This results in const warnings if passed a variable that was declared as

   static const char * const strings[] = { .... };

Add the extra const annotation to the parameters, since neither the string elements, nor the array itself should ever be modified.

---
 include/hw/qdev-core.h      | 2 +-
 include/qapi/util.h         | 2 +-
 include/qapi/visitor-impl.h | 6 +++---
 include/qapi/visitor.h      | 2 +-
 include/qom/object.h        | 2 +-
 qapi/qapi-dealloc-visitor.c | 3 ++-
 qapi/qapi-util.c            | 2 +-
 qapi/qapi-visit-core.c      | 6 +++---
 qom/object.c                | 2 +-
 scripts/qapi-types.py       | 4 ++--
 10 files changed, 16 insertions(+), 15 deletions(-)
include/hw/qdev-core.h +1 -1
index d4be92f..ad9eb89 100644
@@ -236,7 +236,7 @@ struct Property {
 struct PropertyInfo {
     const char *name;
     const char *description;
-    const char **enum_table;
+    const char * const *enum_table;
     int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
     ObjectPropertyAccessor *get;
     ObjectPropertyAccessor *set;
include/qapi/util.h +1 -1
index de9238b..7ad26c0 100644
@@ -11,7 +11,7 @@
 #ifndef QAPI_UTIL_H
 #define QAPI_UTIL_H
 
-int qapi_enum_parse(const char *lookup[], const char *buf,
+int qapi_enum_parse(const char * const lookup[], const char *buf,
                     int max, int def, Error **errp);
 
 #endif
include/qapi/visitor-impl.h +3 -3
index 09bb0fd..f4a2f74 100644
@@ -30,7 +30,7 @@ struct Visitor
     GenericList *(*next_list)(Visitor *v, GenericList **list, Error **errp);
     void (*end_list)(Visitor *v, Error **errp);
 
-    void (*type_enum)(Visitor *v, int *obj, const char *strings[],
+    void (*type_enum)(Visitor *v, int *obj, const char * const strings[],
                       const char *kind, const char *name, Error **errp);
     void (*get_next_type)(Visitor *v, int *kind, const int *qobjects,
                           const char *name, Error **errp);
@@ -59,9 +59,9 @@ struct Visitor
     void (*end_union)(Visitor *v, bool data_present, Error **errp);
 };
 
-void input_type_enum(Visitor *v, int *obj, const char *strings[],
+void input_type_enum(Visitor *v, int *obj, const char * const strings[],
                      const char *kind, const char *name, Error **errp);
-void output_type_enum(Visitor *v, int *obj, const char *strings[],
+void output_type_enum(Visitor *v, int *obj, const char * const strings[],
                       const char *kind, const char *name, Error **errp);
 
 #endif
include/qapi/visitor.h +1 -1
index 5934f59..00ba104 100644
@@ -43,7 +43,7 @@ void visit_optional(Visitor *v, bool *present, const char *name,
                     Error **errp);
 void visit_get_next_type(Visitor *v, int *obj, const int *qtypes,
                          const char *name, Error **errp);
-void visit_type_enum(Visitor *v, int *obj, const char *strings[],
+void visit_type_enum(Visitor *v, int *obj, const char * const strings[],
                      const char *kind, const char *name, Error **errp);
 void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp);
 void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp);
include/qom/object.h +1 -1
index fcacdb0..d07a506 100644
@@ -1081,7 +1081,7 @@ int64_t object_property_get_int(Object *obj, const char *name,
  * an enum).
  */
 int object_property_get_enum(Object *obj, const char *name,
-                             const char *strings[], Error **errp);
+                             const char * const strings[], Error **errp);
 
 /**
  * object_property_get_uint16List:
qapi/qapi-dealloc-visitor.c +2 -1
index a14a1c7..d7f92c5 100644
@@ -156,7 +156,8 @@ static void qapi_dealloc_type_size(Visitor *v, uint64_t *obj, const char *name,
 {
 }
 
-static void qapi_dealloc_type_enum(Visitor *v, int *obj, const char *strings[],
+static void qapi_dealloc_type_enum(Visitor *v, int *obj,
+                                   const char * const strings[],
                                    const char *kind, const char *name,
                                    Error **errp)
 {
qapi/qapi-util.c +1 -1
index 1d8fb96..bcdc94d 100644
@@ -14,7 +14,7 @@
 #include "qapi/error.h"
 #include "qapi/util.h"
 
-int qapi_enum_parse(const char *lookup[], const char *buf,
+int qapi_enum_parse(const char * const lookup[], const char *buf,
                     int max, int def, Error **errp)
 {
     int i;
qapi/qapi-visit-core.c +3 -3
index b66b93a..a18ba16 100644
@@ -89,7 +89,7 @@ void visit_get_next_type(Visitor *v, int *obj, const int *qtypes,
     }
 }
 
-void visit_type_enum(Visitor *v, int *obj, const char *strings[],
+void visit_type_enum(Visitor *v, int *obj, const char * const strings[],
                      const char *kind, const char *name, Error **errp)
 {
     v->type_enum(v, obj, strings, kind, name, errp);
@@ -260,7 +260,7 @@ void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp)
     v->type_number(v, obj, name, errp);
 }
 
-void output_type_enum(Visitor *v, int *obj, const char *strings[],
+void output_type_enum(Visitor *v, int *obj, const char * const strings[],
                       const char *kind, const char *name,
                       Error **errp)
 {
@@ -279,7 +279,7 @@ void output_type_enum(Visitor *v, int *obj, const char *strings[],
     visit_type_str(v, &enum_str, name, errp);
 }
 
-void input_type_enum(Visitor *v, int *obj, const char *strings[],
+void input_type_enum(Visitor *v, int *obj, const char * const strings[],
                      const char *kind, const char *name,
                      Error **errp)
 {
qom/object.c +1 -1
index 6bf0ee4..3dcb585 100644
@@ -1070,7 +1070,7 @@ int64_t object_property_get_int(Object *obj, const char *name,
 }
 
 int object_property_get_enum(Object *obj, const char *name,
-                             const char *strings[], Error **errp)
+                             const char * const strings[], Error **errp)
 {
     StringOutputVisitor *sov;
     StringInputVisitor *siv;
scripts/qapi-types.py +2 -2
index 6bd0b13..d0ac98b 100644
@@ -109,7 +109,7 @@ struct %(name)s
 
 def generate_enum_lookup(name, values):
     ret = mcgen('''
-const char *%(name)s_lookup[] = {
+const char * const %(name)s_lookup[] = {
 ''',
                 name=c_name(name))
     i = 0
@@ -132,7 +132,7 @@ const char *%(name)s_lookup[] = {
 def generate_enum(name, values):
     name = c_name(name)
     lookup_decl = mcgen('''
-extern const char *%(name)s_lookup[];
+extern const char * const %(name)s_lookup[];
 ''',
                 name=name)
 
Signature · 1 line
2.1.4
#13 lore raw

[Qemu-devel] [PULL v2 11/12] qom: Add an object_property_add_enum() helper function

In reply to Andreas Färber

From: "Daniel P. Berrange" <[email protected]>

A QOM property can be parsed as enum using the visit_type_enum() helper function, but this forces callers to use the more complex generic object_property_add() method when registering it. It also requires that users of that object have access to the string map when they want to read the property value.

This patch introduces a specialized object_property_add_enum() method which simplifies the use of enum properties, so the setters/getters directly get passed the int value.

  typedef enum {
     MYDEV_TYPE_FROG,
     MYDEV_TYPE_ALLIGATOR,
     MYDEV_TYPE_PLATYPUS,

MYDEV_TYPE_LAST
} MyDevType;

Then provide a table of enum <-> string mappings

  static const char *const mydevtypemap[MYDEV_TYPE_LAST + 1] = {
     [MYDEV_TYPE_FROG] = "frog",
     [MYDEV_TYPE_ALLIGATOR] = "alligator",
     [MYDEV_TYPE_PLATYPUS] = "platypus",
     [MYDEV_TYPE_LAST] = NULL,
  };

Assuming an object struct of

   typedef struct {
      Object parent;
      MyDevType devtype;
      ...other fields...
   } MyDev;

The property can then be registered as follows:

   static int mydev_prop_get_devtype(Object *obj,
                                     Error **errp G_GNUC_UNUSED)
   {
       MyDev *dev = MYDEV(obj);
       return dev->devtype;

}

   static void mydev_prop_set_devtype(Object *obj,
                                      int value,
                                      Error **errp G_GNUC_UNUSED)
   {
       MyDev *dev = MYDEV(obj);
       dev->endpoint = value;

}

object_property_add_enum(obj, "devtype",

                            mydevtypemap, "MyDevType",
                            mydev_prop_get_devtype,
                            mydev_prop_set_devtype,
                            NULL);

Note there is no need to check the range of 'value' in the setter, because the string->enum conversion code will have already done that and reported an error as required.

---
 include/qom/object.h       | 19 ++++++++++++
 qom/object.c               | 58 ++++++++++++++++++++++++++++++++++++
 tests/check-qom-proplist.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 150 insertions(+)
include/qom/object.h +19 -0
index d07a506..270a3ef 100644
@@ -1344,6 +1344,25 @@ void object_property_add_bool(Object *obj, const char *name,
                               Error **errp);
 
 /**
+ * object_property_add_enum:
+ * @obj: the object to add a property to
+ * @name: the name of the property
+ * @typename: the name of the enum data type
+ * @get: the getter or %NULL if the property is write-only.
+ * @set: the setter or %NULL if the property is read-only
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Add a enum property using getters/setters.  This function will add a
+ * property of type '@typename'.
+ */
+void object_property_add_enum(Object *obj, const char *name,
+                              const char *typename,
+                              const char * const *strings,
+                              int (*get)(Object *, Error **),
+                              void (*set)(Object *, int, Error **),
+                              Error **errp);
+
+/**
  * object_property_add_tm:
  * @obj: the object to add a property to
  * @name: the name of the property
qom/object.c +58 -0

70 lines not on this page · raw message

tests/check-qom-proplist.c +73 -0

129 lines not on this page · raw message

Signature · 1 line
2.1.4
#14 lore raw

[Qemu-devel] [PULL v2 09/12] qom: Add object_new_with_props() / object_new_withpropv() helpers

In reply to Andreas Färber

From: "Daniel P. Berrange" <[email protected]>

It is reasonably common to want to create an object, set a number of properties, register it in the hierarchy and then mark it as complete (if a user creatable type). This requires quite a lot of error prone, verbose, boilerplate code to achieve.

First a pair of functions object_set_props() / object_set_propv() are added which allow for a list of objects to be set in one single API call.

Then object_new_with_props() / object_new_with_propv() constructors are added which simplify the sequence of calls to create an object, populate properties, register in the object composition tree and mark the object complete, into a single method call.

Usage would be:

   Error *err = NULL;
   Object *obj;
   obj = object_new_with_propv(TYPE_MEMORY_BACKEND_FILE,
                               object_get_objects_root(),
                               "hostmem0",
                               &err,
                               "share", "yes",
                               "mem-path", "/dev/shm/somefile",
                               "prealloc", "yes",
                               "size", "1048576",
                               NULL);

Note all property values are passed in string form and will be parsed into their required data types, using normal QOM semantics for parsing from string format.

---
 include/qemu/compiler.h    |   6 ++
 include/qom/object.h       | 128 +++++++++++++++++++++++++++++++
 qom/object.c               | 109 ++++++++++++++++++++++++++
 tests/.gitignore           |   1 +
 tests/Makefile             |   5 +-
 tests/check-qom-proplist.c | 186 +++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 434 insertions(+), 1 deletion(-)
 create mode 100644 tests/check-qom-proplist.c
include/qemu/compiler.h +6 -0
index ac7c4c4..df9dd51 100644
@@ -24,6 +24,12 @@
 #define QEMU_WARN_UNUSED_RESULT
 #endif
 
+#if QEMU_GNUC_PREREQ(4, 0)
+#define QEMU_SENTINEL __attribute__((sentinel))
+#else
+#define QEMU_SENTINEL
+#endif
+
 #if QEMU_GNUC_PREREQ(4, 3)
 #define QEMU_ARTIFICIAL __attribute__((always_inline, artificial))
 #else
include/qom/object.h +128 -0

134 lines not on this page · raw message

qom/object.c +109 -0

121 lines not on this page · raw message

tests/.gitignore +1 -0
index 0dcb618..dc813c2 100644
@@ -5,6 +5,7 @@ check-qjson
 check-qlist
 check-qstring
 check-qom-interface
+check-qom-proplist
 rcutorture
 test-aio
 test-bitops
tests/Makefile +4 -1
index 729b969..39c6e2c 100644
@@ -68,6 +68,8 @@ check-unit-y += tests/test-bitops$(EXESUF)
 check-unit-$(CONFIG_HAS_GLIB_SUBPROCESS_TESTS) += tests/test-qdev-global-props$(EXESUF)
 check-unit-y += tests/check-qom-interface$(EXESUF)
 gcov-files-check-qom-interface-y = qom/object.c
+check-unit-y += tests/check-qom-proplist$(EXESUF)
+gcov-files-check-qom-proplist-y = qom/object.c
 check-unit-y += tests/test-qemu-opts$(EXESUF)
 gcov-files-test-qemu-opts-y = qom/test-qemu-opts.c
 check-unit-y += tests/test-write-threshold$(EXESUF)
@@ -264,7 +266,7 @@ test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o \
 
 $(test-obj-y): QEMU_INCLUDES += -Itests
 QEMU_CFLAGS += -I$(SRC_PATH)/tests
-qom-core-obj = qom/object.o qom/qom-qobject.o qom/container.o
+qom-core-obj = qom/object.o qom/qom-qobject.o qom/container.o qom/object_interfaces.o
 
 tests/check-qint$(EXESUF): tests/check-qint.o libqemuutil.a
 tests/check-qstring$(EXESUF): tests/check-qstring.o libqemuutil.a
@@ -273,6 +275,7 @@ tests/check-qlist$(EXESUF): tests/check-qlist.o libqemuutil.a
 tests/check-qfloat$(EXESUF): tests/check-qfloat.o libqemuutil.a
 tests/check-qjson$(EXESUF): tests/check-qjson.o libqemuutil.a libqemustub.a
 tests/check-qom-interface$(EXESUF): tests/check-qom-interface.o $(qom-core-obj) libqemuutil.a libqemustub.a
+tests/check-qom-proplist$(EXESUF): tests/check-qom-proplist.o $(qom-core-obj) libqemuutil.a libqemustub.a
 tests/test-coroutine$(EXESUF): tests/test-coroutine.o $(block-obj-y) libqemuutil.a libqemustub.a
 tests/test-aio$(EXESUF): tests/test-aio.o $(block-obj-y) libqemuutil.a libqemustub.a
 tests/test-rfifolock$(EXESUF): tests/test-rfifolock.o libqemuutil.a libqemustub.a
tests/check-qom-proplist.c new file +186 -0

186 lines not on this page · raw message

Signature · 1 line
2.1.4
#15 lore raw

[Qemu-devel] [PULL v2 03/12] tests: Use qtest_add_data_func() consistently

In reply to Andreas Färber

Replace uses of g_test_add_data_func() for QTest test cases.

It is still valid to use it for any non-QTest test cases, which are not run for multiple target binaries.

---
 tests/ahci-test.c       |  9 ++-------
 tests/e1000-test.c      |  4 ++--
 tests/eepro100-test.c   |  5 ++---
 tests/endianness-test.c | 18 +++++++++---------
 tests/pc-cpu-test.c     | 13 ++++++-------
 tests/qom-test.c        |  4 ++--
 6 files changed, 23 insertions(+), 30 deletions(-)
tests/ahci-test.c +2 -7
index 6e3fa81..ae9415d 100644
@@ -1486,7 +1486,6 @@ static void test_io_interface(gconstpointer opaque)
 static void create_ahci_io_test(enum IOMode type, enum AddrMode addr,
                                 enum BuffLen len, enum OffsetType offset)
 {
-    static const char *arch;
     char *name;
     AHCIIOTestOptions *opts = g_malloc(sizeof(AHCIIOTestOptions));
 
@@ -1495,17 +1494,13 @@ static void create_ahci_io_test(enum IOMode type, enum AddrMode addr,
     opts->io_type = type;
     opts->offset = offset;
 
-    if (!arch) {
-        arch = qtest_get_arch();
-    }
-
-    name = g_strdup_printf("/%s/ahci/io/%s/%s/%s/%s", arch,
+    name = g_strdup_printf("ahci/io/%s/%s/%s/%s",
                            io_mode_str[type],
                            addr_mode_str[addr],
                            buff_len_str[len],
                            offset_str[offset]);
 
-    g_test_add_data_func(name, opts, test_io_interface);
+    qtest_add_data_func(name, opts, test_io_interface);
     g_free(name);
 }
 
tests/e1000-test.c +2 -2
index 81f164d..7ca6d7e 100644
@@ -44,8 +44,8 @@ int main(int argc, char **argv)
     for (i = 0; i < ARRAY_SIZE(models); i++) {
         char *path;
 
-        path = g_strdup_printf("/%s/e1000/%s", qtest_get_arch(), models[i]);
-        g_test_add_data_func(path, models[i], test_device);
+        path = g_strdup_printf("e1000/%s", models[i]);
+        qtest_add_data_func(path, models[i], test_device);
     }
 
     return g_test_run();
tests/eepro100-test.c +2 -3
index bf82526..8bfaccd 100644
@@ -54,9 +54,8 @@ int main(int argc, char **argv)
     for (i = 0; i < ARRAY_SIZE(models); i++) {
         char *path;
 
-        path = g_strdup_printf("/%s/eepro100/%s",
-                               qtest_get_arch(), models[i]);
-        g_test_add_data_func(path, models[i], test_device);
+        path = g_strdup_printf("eepro100/%s", models[i]);
+        qtest_add_data_func(path, models[i], test_device);
     }
 
     return g_test_run();
tests/endianness-test.c +9 -9
index 92e17d2..7482ff7 100644
@@ -298,17 +298,17 @@ int main(int argc, char **argv)
         if (strcmp(test_cases[i].arch, arch) != 0) {
             continue;
         }
-        path = g_strdup_printf("/%s/endianness/%s",
-                               arch, test_cases[i].machine);
-        g_test_add_data_func(path, &test_cases[i], test_endianness);
+        path = g_strdup_printf("endianness/%s",
+                               test_cases[i].machine);
+        qtest_add_data_func(path, &test_cases[i], test_endianness);
 
-        path = g_strdup_printf("/%s/endianness/split/%s",
-                               arch, test_cases[i].machine);
-        g_test_add_data_func(path, &test_cases[i], test_endianness_split);
+        path = g_strdup_printf("endianness/split/%s",
+                               test_cases[i].machine);
+        qtest_add_data_func(path, &test_cases[i], test_endianness_split);
 
-        path = g_strdup_printf("/%s/endianness/combine/%s",
-                               arch, test_cases[i].machine);
-        g_test_add_data_func(path, &test_cases[i], test_endianness_combine);
+        path = g_strdup_printf("endianness/combine/%s",
+                               test_cases[i].machine);
+        qtest_add_data_func(path, &test_cases[i], test_endianness_combine);
     }
 
     ret = g_test_run();
tests/pc-cpu-test.c +6 -7
index a0122d3..3505c7c 100644
@@ -75,7 +75,6 @@ static void test_pc_without_cpu_add(gconstpointer data)
 
 static void add_pc_test_cases(void)
 {
-    const char *arch = qtest_get_arch();
     QDict *response, *minfo;
     QList *list;
     const QListEntry *p;
@@ -119,15 +118,15 @@ static void add_pc_test_cases(void)
             (strcmp(mname, "pc-0.12") == 0) ||
             (strcmp(mname, "pc-0.11") == 0) ||
             (strcmp(mname, "pc-0.10") == 0)) {
-            path = g_strdup_printf("/%s/cpu/%s/init/%ux%ux%u&maxcpus=%u",
-                                   arch, mname, data->sockets, data->cores,
+            path = g_strdup_printf("cpu/%s/init/%ux%ux%u&maxcpus=%u",
+                                   mname, data->sockets, data->cores,
                                    data->threads, data->maxcpus);
-            g_test_add_data_func(path, data, test_pc_without_cpu_add);
+            qtest_add_data_func(path, data, test_pc_without_cpu_add);
         } else {
-            path = g_strdup_printf("/%s/cpu/%s/add/%ux%ux%u&maxcpus=%u",
-                                   arch, mname, data->sockets, data->cores,
+            path = g_strdup_printf("cpu/%s/add/%ux%ux%u&maxcpus=%u",
+                                   mname, data->sockets, data->cores,
                                    data->threads, data->maxcpus);
-            g_test_add_data_func(path, data, test_pc_with_cpu_add);
+            qtest_add_data_func(path, data, test_pc_with_cpu_add);
         }
     }
     qtest_end();
tests/qom-test.c +2 -2
index 4246382..fde04e7 100644
@@ -128,8 +128,8 @@ static void add_machine_test_cases(void)
         g_assert(qstr);
         mname = qstring_get_str(qstr);
         if (!is_blacklisted(arch, mname)) {
-            path = g_strdup_printf("/%s/qom/%s", arch, mname);
-            g_test_add_data_func(path, mname, test_machine);
+            path = g_strdup_printf("qom/%s", mname);
+            qtest_add_data_func(path, mname, test_machine);
         }
     }
     qtest_end();
Signature · 1 line
2.1.4
#16 lore raw
In reply to Andreas Färber
Quoted 5 lines · Andreas Färber

Hello Peter,

This is my QOM (devices) patch queue. Please pull.

v2 contains changes that hopefully fix warnings on gcc 4.7.

Hi. I'm afraid this doesn't build on our minimum glib version (2.22):

/Users/pm215/src/qemu/tests/check-qom-proplist.c:235:5: warning: implicit

      declaration of function 'g_assert_null' is invalid in C99
      [-Wimplicit-function-declaration]
    g_assert_null(dobj);
    ^
/Users/pm215/src/qemu/tests/check-qom-proplist.c:236:5: warning: implicit
      declaration of function 'g_assert_nonnull' is invalid in C99
      [-Wimplicit-function-declaration]
    g_assert_nonnull(err);
    ^

g_assert_nonnull() first appears in glib 2.38.

thanks
-- PMM

#17 lore raw

Am 28.05.2015 um 13:46 schrieb Peter Maydell:

Quoted 20 lines · Andreas Färber
Quoted 5 lines

Hello Peter,

This is my QOM (devices) patch queue. Please pull.

v2 contains changes that hopefully fix warnings on gcc 4.7.

Hi. I'm afraid this doesn't build on our minimum glib version (2.22):

/Users/pm215/src/qemu/tests/check-qom-proplist.c:235:5: warning: implicit

      declaration of function 'g_assert_null' is invalid in C99
      [-Wimplicit-function-declaration]
    g_assert_null(dobj);
    ^
/Users/pm215/src/qemu/tests/check-qom-proplist.c:236:5: warning: implicit
      declaration of function 'g_assert_nonnull' is invalid in C99
      [-Wimplicit-function-declaration]
    g_assert_nonnull(err);
    ^
Quoted 1 line

g_assert_nonnull() first appears in glib 2.38.

Holy crap... :/

I could've sworn that Anthony did not apply the same minimum-glib version for make check as for the actual code, and macros should be easy to add to our glib-compat.h, but let's get this in first and consider refactorings then.

Unfortunately the pull no longer applies cleanly due to QemuOpts changes in vl.c, looking into it.

Regards,
Andreas

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)
#18 lore raw
Quoted 21 lines · Andreas Färber

Am 28.05.2015 um 13:46 schrieb Peter Maydell:

Quoted 20 lines · Andreas Färber
Quoted 5 lines

Hello Peter,

This is my QOM (devices) patch queue. Please pull.

v2 contains changes that hopefully fix warnings on gcc 4.7.

Hi. I'm afraid this doesn't build on our minimum glib version (2.22):

/Users/pm215/src/qemu/tests/check-qom-proplist.c:235:5: warning: implicit

      declaration of function 'g_assert_null' is invalid in C99
      [-Wimplicit-function-declaration]
    g_assert_null(dobj);
    ^
/Users/pm215/src/qemu/tests/check-qom-proplist.c:236:5: warning: implicit
      declaration of function 'g_assert_nonnull' is invalid in C99
      [-Wimplicit-function-declaration]
    g_assert_nonnull(err);
    ^
Quoted 6 lines
Quoted 1 line

g_assert_nonnull() first appears in glib 2.38.

Holy crap... :/

I could've sworn that Anthony did not apply the same minimum-glib version for make check as for the actual code

Historically we didn't, because the whole gtester infrastructure we use wasn't in the ancient glib requirement we had for RHEL5; so it wasn't practical to insist that test code run on that. One of the advantages of now using 2.22 as our minimum is that you can actually run 'make check' on every version of glib we support (though 2.22 has a signal race in gtester which means you need to have a little helper script that does a 'killall -CHLD gtester' every so often to unwedge it...)

Even before we moved to 2.22, I would have spotted and asked for fixes for failure of "make check" on a 2.22 glib, because one of my main build-for-pullreqs systems is a 2.22 one.

thanks
-- PMM