* [Qemu-devel] [PATCH] qdev: Use GList for global properties
@ 2016-01-28 15:02 Eduardo Habkost
2016-01-28 17:01 ` Michael S. Tsirkin
0 siblings, 1 reply; 5+ messages in thread
From: Eduardo Habkost @ 2016-01-28 15:02 UTC (permalink / raw)
To: qemu-devel
Cc: Igor Mammedov, Gerd Hoffmann, Andreas Färber, Michael S. Tsirkin
If the same GlobalProperty struct is registered twice, the list
entry gets corrupted, making tqe_next points to itself, and
qdev_prop_set_globals() gets stuck in a loop. The bug can be
easily reproduced by running:
$ qemu-system-x86_64 -rtc-td-hack -rtc-td-hack
Change global_props to use GList instead of queue.h, making the
code simpler and able to deal with properties being registered
twice.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/core/qdev-properties.c | 17 ++++++++++-------
include/hw/qdev-core.h | 1 -
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index aacad66..180e0da 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1,3 +1,5 @@
+#include <glib.h>
+
#include "net/net.h"
#include "hw/qdev.h"
#include "qapi/qmp/qerror.h"
@@ -1009,12 +1011,11 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
*ptr = value;
}
-static QTAILQ_HEAD(, GlobalProperty) global_props =
- QTAILQ_HEAD_INITIALIZER(global_props);
+static GList *global_props;
void qdev_prop_register_global(GlobalProperty *prop)
{
- QTAILQ_INSERT_TAIL(&global_props, prop, next);
+ global_props = g_list_append(global_props, prop);
}
void qdev_prop_register_global_list(GlobalProperty *props)
@@ -1028,10 +1029,11 @@ void qdev_prop_register_global_list(GlobalProperty *props)
int qdev_prop_check_globals(void)
{
- GlobalProperty *prop;
+ GList *l;
int ret = 0;
- QTAILQ_FOREACH(prop, &global_props, next) {
+ for (l = global_props; l; l = l->next) {
+ GlobalProperty *prop = l->data;
ObjectClass *oc;
DeviceClass *dc;
if (prop->used) {
@@ -1062,9 +1064,10 @@ int qdev_prop_check_globals(void)
static void qdev_prop_set_globals_for_type(DeviceState *dev,
const char *typename)
{
- GlobalProperty *prop;
+ GList *l;
- QTAILQ_FOREACH(prop, &global_props, next) {
+ for (l = global_props; l; l = l->next) {
+ GlobalProperty *prop = l->data;
Error *err = NULL;
if (strcmp(typename, prop->driver) != 0) {
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index abcdee8..1fdbaaa 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -268,7 +268,6 @@ typedef struct GlobalProperty {
const char *value;
bool user_provided;
bool used;
- QTAILQ_ENTRY(GlobalProperty) next;
} GlobalProperty;
/*** Board API. This should go away once we have a machine config file. ***/
--
2.1.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] qdev: Use GList for global properties
2016-01-28 15:02 [Qemu-devel] [PATCH] qdev: Use GList for global properties Eduardo Habkost
@ 2016-01-28 17:01 ` Michael S. Tsirkin
2016-01-29 14:15 ` Eduardo Habkost
0 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2016-01-28 17:01 UTC (permalink / raw)
To: Eduardo Habkost
Cc: Igor Mammedov, Gerd Hoffmann, qemu-devel, Andreas Färber
On Thu, Jan 28, 2016 at 01:02:26PM -0200, Eduardo Habkost wrote:
> If the same GlobalProperty struct is registered twice, the list
> entry gets corrupted, making tqe_next points to itself, and
> qdev_prop_set_globals() gets stuck in a loop. The bug can be
> easily reproduced by running:
>
> $ qemu-system-x86_64 -rtc-td-hack -rtc-td-hack
>
> Change global_props to use GList instead of queue.h, making the
> code simpler and able to deal with properties being registered
> twice.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> hw/core/qdev-properties.c | 17 ++++++++++-------
> include/hw/qdev-core.h | 1 -
> 2 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index aacad66..180e0da 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -1,3 +1,5 @@
> +#include <glib.h>
> +
> #include "net/net.h"
> #include "hw/qdev.h"
> #include "qapi/qmp/qerror.h"
> @@ -1009,12 +1011,11 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
> *ptr = value;
> }
>
> -static QTAILQ_HEAD(, GlobalProperty) global_props =
> - QTAILQ_HEAD_INITIALIZER(global_props);
> +static GList *global_props;
>
> void qdev_prop_register_global(GlobalProperty *prop)
> {
> - QTAILQ_INSERT_TAIL(&global_props, prop, next);
> + global_props = g_list_append(global_props, prop);
> }
>
> void qdev_prop_register_global_list(GlobalProperty *props)
> @@ -1028,10 +1029,11 @@ void qdev_prop_register_global_list(GlobalProperty *props)
>
> int qdev_prop_check_globals(void)
> {
> - GlobalProperty *prop;
> + GList *l;
> int ret = 0;
>
> - QTAILQ_FOREACH(prop, &global_props, next) {
> + for (l = global_props; l; l = l->next) {
> + GlobalProperty *prop = l->data;
> ObjectClass *oc;
> DeviceClass *dc;
> if (prop->used) {
> @@ -1062,9 +1064,10 @@ int qdev_prop_check_globals(void)
> static void qdev_prop_set_globals_for_type(DeviceState *dev,
> const char *typename)
> {
> - GlobalProperty *prop;
> + GList *l;
>
> - QTAILQ_FOREACH(prop, &global_props, next) {
> + for (l = global_props; l; l = l->next) {
> + GlobalProperty *prop = l->data;
> Error *err = NULL;
>
> if (strcmp(typename, prop->driver) != 0) {
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index abcdee8..1fdbaaa 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -268,7 +268,6 @@ typedef struct GlobalProperty {
> const char *value;
> bool user_provided;
> bool used;
> - QTAILQ_ENTRY(GlobalProperty) next;
> } GlobalProperty;
>
> /*** Board API. This should go away once we have a machine config file. ***/
> --
> 2.1.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] qdev: Use GList for global properties
2016-01-28 17:01 ` Michael S. Tsirkin
@ 2016-01-29 14:15 ` Eduardo Habkost
2016-05-12 12:26 ` Eduardo Habkost
0 siblings, 1 reply; 5+ messages in thread
From: Eduardo Habkost @ 2016-01-29 14:15 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Igor Mammedov, Gerd Hoffmann, qemu-devel, Andreas Färber
On Thu, Jan 28, 2016 at 07:01:12PM +0200, Michael S. Tsirkin wrote:
> On Thu, Jan 28, 2016 at 01:02:26PM -0200, Eduardo Habkost wrote:
> > If the same GlobalProperty struct is registered twice, the list
> > entry gets corrupted, making tqe_next points to itself, and
> > qdev_prop_set_globals() gets stuck in a loop. The bug can be
> > easily reproduced by running:
> >
> > $ qemu-system-x86_64 -rtc-td-hack -rtc-td-hack
> >
> > Change global_props to use GList instead of queue.h, making the
> > code simpler and able to deal with properties being registered
> > twice.
> >
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Thanks! It seems we don't have a maintainer for hw/core/qdev*.
Who should merge this?
--
Eduardo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] qdev: Use GList for global properties
2016-01-29 14:15 ` Eduardo Habkost
@ 2016-05-12 12:26 ` Eduardo Habkost
[not found] ` <5734ADCC.2050201@suse.de>
0 siblings, 1 reply; 5+ messages in thread
From: Eduardo Habkost @ 2016-05-12 12:26 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Igor Mammedov, Gerd Hoffmann, qemu-devel, Andreas Färber
On Fri, Jan 29, 2016 at 12:15:12PM -0200, Eduardo Habkost wrote:
> On Thu, Jan 28, 2016 at 07:01:12PM +0200, Michael S. Tsirkin wrote:
> > On Thu, Jan 28, 2016 at 01:02:26PM -0200, Eduardo Habkost wrote:
> > > If the same GlobalProperty struct is registered twice, the list
> > > entry gets corrupted, making tqe_next points to itself, and
> > > qdev_prop_set_globals() gets stuck in a loop. The bug can be
> > > easily reproduced by running:
> > >
> > > $ qemu-system-x86_64 -rtc-td-hack -rtc-td-hack
> > >
> > > Change global_props to use GList instead of queue.h, making the
> > > code simpler and able to deal with properties being registered
> > > twice.
> > >
> > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> >
> > Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
>
> Thanks! It seems we don't have a maintainer for hw/core/qdev*.
> Who should merge this?
I've just noticed that this didn't get included. Andreas, is it
OK if I merge this through the machine core tree?
--
Eduardo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] qdev: Use GList for global properties
[not found] ` <5734ADCC.2050201@suse.de>
@ 2016-05-18 18:59 ` Eduardo Habkost
0 siblings, 0 replies; 5+ messages in thread
From: Eduardo Habkost @ 2016-05-18 18:59 UTC (permalink / raw)
To: Andreas Färber
Cc: Michael S. Tsirkin, Igor Mammedov, Gerd Hoffmann, qemu-devel
On Thu, May 12, 2016 at 06:22:36PM +0200, Andreas Färber wrote:
> Am 12.05.2016 um 14:26 schrieb Eduardo Habkost:
> > On Fri, Jan 29, 2016 at 12:15:12PM -0200, Eduardo Habkost wrote:
> >> On Thu, Jan 28, 2016 at 07:01:12PM +0200, Michael S. Tsirkin wrote:
> >>> On Thu, Jan 28, 2016 at 01:02:26PM -0200, Eduardo Habkost wrote:
> >>>> If the same GlobalProperty struct is registered twice, the list
> >>>> entry gets corrupted, making tqe_next points to itself, and
> >>>> qdev_prop_set_globals() gets stuck in a loop. The bug can be
> >>>> easily reproduced by running:
> >>>>
> >>>> $ qemu-system-x86_64 -rtc-td-hack -rtc-td-hack
> >>>>
> >>>> Change global_props to use GList instead of queue.h, making the
> >>>> code simpler and able to deal with properties being registered
> >>>> twice.
> >>>>
> >>>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> >>>
> >>> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> >>
> >> Thanks! It seems we don't have a maintainer for hw/core/qdev*.
> >> Who should merge this?
> >
> > I've just noticed that this didn't get included. Andreas, is it
> > OK if I merge this through the machine core tree?
>
> In general I don't mind about those lists, but I still have the bus
> refactoring sitting in my tree that didn't make it into 2.6 because
> someone made last-minute changes to osdep.h that resulted in hundreds of
> errors in my tree... If you make sure it doesn't conflict, feel free to
> take it.
Which branch should I look at, to ensure it doesn't conflict?
--
Eduardo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-05-18 18:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-28 15:02 [Qemu-devel] [PATCH] qdev: Use GList for global properties Eduardo Habkost
2016-01-28 17:01 ` Michael S. Tsirkin
2016-01-29 14:15 ` Eduardo Habkost
2016-05-12 12:26 ` Eduardo Habkost
[not found] ` <5734ADCC.2050201@suse.de>
2016-05-18 18:59 ` Eduardo Habkost
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.