* [Qemu-devel] [PATCH qom-next 0/2] qdev-monitor: Reference counting follow-ups
@ 2013-10-07 16:43 Andreas Färber
2013-10-07 16:44 ` [Qemu-devel] [PATCH qom-next 1/2] qdev-monitor: Avoid qdev as variable name Andreas Färber
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Andreas Färber @ 2013-10-07 16:43 UTC (permalink / raw)
To: qemu-devel
Cc: Anthony Liguori, Igor Mammedov, Andreas Färber,
Stefan Hajnoczi, Paolo Bonzini
Hello,
I have queued bug fixes by Igor and Stefan for device_add on qom-next and
am rearranging the following changes of mine on top.
1) Further naming cleanups, now rebased on the bugfixes for easier backporting.
2) Inlining of qdev_init(), so that we always have unparent+unref pairs.
If there's no objections, planning to include this in a pull tonight or tomorrow.
Regards,
Andreas
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Anthony Liguori <anthony@codemonkey.ws>
Andreas Färber (2):
qdev-monitor: Avoid qdev as variable name
qdev-monitor: Inline qdev_init() for device_add
qdev-monitor.c | 37 +++++++++++++++++++++----------------
1 file changed, 21 insertions(+), 16 deletions(-)
--
1.8.1.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH qom-next 1/2] qdev-monitor: Avoid qdev as variable name
2013-10-07 16:43 [Qemu-devel] [PATCH qom-next 0/2] qdev-monitor: Reference counting follow-ups Andreas Färber
@ 2013-10-07 16:44 ` Andreas Färber
2013-10-07 16:44 ` [Qemu-devel] [PATCH qom-next 2/2] qdev-monitor: Inline qdev_init() for device_add Andreas Färber
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Andreas Färber @ 2013-10-07 16:44 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber, Stefan Hajnoczi
Prepares for bringing error cleanup code into canonical QOM form.
Includes a whitespace removal after curly brace by Stefan.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
qdev-monitor.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 6aa3bb5..f259e07 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -447,7 +447,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
ObjectClass *oc;
DeviceClass *dc;
const char *driver, *path, *id;
- DeviceState *qdev;
+ DeviceState *dev;
BusState *bus = NULL;
driver = qemu_opt_get(opts, "driver");
@@ -506,38 +506,38 @@ DeviceState *qdev_device_add(QemuOpts *opts)
}
/* create device, set properties */
- qdev = DEVICE(object_new(driver));
+ dev = DEVICE(object_new(driver));
if (bus) {
- qdev_set_parent_bus(qdev, bus);
+ qdev_set_parent_bus(dev, bus);
}
id = qemu_opts_id(opts);
if (id) {
- qdev->id = id;
+ dev->id = id;
}
- if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {
- object_unparent(OBJECT(qdev));
- object_unref(OBJECT(qdev));
+ if (qemu_opt_foreach(opts, set_property, dev, 1) != 0) {
+ object_unparent(OBJECT(dev));
+ object_unref(OBJECT(dev));
return NULL;
}
- if (qdev->id) {
- object_property_add_child(qdev_get_peripheral(), qdev->id,
- OBJECT(qdev), NULL);
+ if (dev->id) {
+ object_property_add_child(qdev_get_peripheral(), dev->id,
+ OBJECT(dev), NULL);
} else {
static int anon_count;
gchar *name = g_strdup_printf("device[%d]", anon_count++);
object_property_add_child(qdev_get_peripheral_anon(), name,
- OBJECT(qdev), NULL);
+ OBJECT(dev), NULL);
g_free(name);
- }
- if (qdev_init(qdev) < 0) {
- object_unref(OBJECT(qdev));
+ }
+ if (qdev_init(dev) < 0) {
+ object_unref(OBJECT(dev));
qerror_report(QERR_DEVICE_INIT_FAILED, driver);
return NULL;
}
- qdev->opts = opts;
- return qdev;
+ dev->opts = opts;
+ return dev;
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH qom-next 2/2] qdev-monitor: Inline qdev_init() for device_add
2013-10-07 16:43 [Qemu-devel] [PATCH qom-next 0/2] qdev-monitor: Reference counting follow-ups Andreas Färber
2013-10-07 16:44 ` [Qemu-devel] [PATCH qom-next 1/2] qdev-monitor: Avoid qdev as variable name Andreas Färber
@ 2013-10-07 16:44 ` Andreas Färber
2013-10-07 17:04 ` [Qemu-devel] [PATCH qom-next 0/2] qdev-monitor: Reference counting follow-ups Paolo Bonzini
2013-10-08 8:37 ` Igor Mammedov
3 siblings, 0 replies; 5+ messages in thread
From: Andreas Färber @ 2013-10-07 16:44 UTC (permalink / raw)
To: qemu-devel; +Cc: Andreas Färber
For historic reasons, qdev_init() unparents the device on failure.
Inline this to make the error paths clearer and consistent.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
qdev-monitor.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/qdev-monitor.c b/qdev-monitor.c
index f259e07..b7daab7 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -449,6 +449,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
const char *driver, *path, *id;
DeviceState *dev;
BusState *bus = NULL;
+ Error *err = NULL;
driver = qemu_opt_get(opts, "driver");
if (!driver) {
@@ -531,7 +532,11 @@ DeviceState *qdev_device_add(QemuOpts *opts)
OBJECT(dev), NULL);
g_free(name);
}
- if (qdev_init(dev) < 0) {
+ object_property_set_bool(OBJECT(dev), true, "realized", &err);
+ if (err != NULL) {
+ qerror_report_err(err);
+ error_free(err);
+ object_unparent(OBJECT(dev));
object_unref(OBJECT(dev));
qerror_report(QERR_DEVICE_INIT_FAILED, driver);
return NULL;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH qom-next 0/2] qdev-monitor: Reference counting follow-ups
2013-10-07 16:43 [Qemu-devel] [PATCH qom-next 0/2] qdev-monitor: Reference counting follow-ups Andreas Färber
2013-10-07 16:44 ` [Qemu-devel] [PATCH qom-next 1/2] qdev-monitor: Avoid qdev as variable name Andreas Färber
2013-10-07 16:44 ` [Qemu-devel] [PATCH qom-next 2/2] qdev-monitor: Inline qdev_init() for device_add Andreas Färber
@ 2013-10-07 17:04 ` Paolo Bonzini
2013-10-08 8:37 ` Igor Mammedov
3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2013-10-07 17:04 UTC (permalink / raw)
To: Andreas Färber
Cc: Igor Mammedov, Stefan Hajnoczi, qemu-devel, Anthony Liguori
Il 07/10/2013 18:43, Andreas Färber ha scritto:
> Hello,
>
> I have queued bug fixes by Igor and Stefan for device_add on qom-next and
> am rearranging the following changes of mine on top.
>
> 1) Further naming cleanups, now rebased on the bugfixes for easier backporting.
> 2) Inlining of qdev_init(), so that we always have unparent+unref pairs.
>
> If there's no objections, planning to include this in a pull tonight or tomorrow.
>
> Regards,
> Andreas
>
> Cc: Igor Mammedov <imammedo@redhat.com>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Anthony Liguori <anthony@codemonkey.ws>
>
> Andreas Färber (2):
> qdev-monitor: Avoid qdev as variable name
> qdev-monitor: Inline qdev_init() for device_add
>
> qdev-monitor.c | 37 +++++++++++++++++++++----------------
> 1 file changed, 21 insertions(+), 16 deletions(-)
>
Yes, looks good.
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH qom-next 0/2] qdev-monitor: Reference counting follow-ups
2013-10-07 16:43 [Qemu-devel] [PATCH qom-next 0/2] qdev-monitor: Reference counting follow-ups Andreas Färber
` (2 preceding siblings ...)
2013-10-07 17:04 ` [Qemu-devel] [PATCH qom-next 0/2] qdev-monitor: Reference counting follow-ups Paolo Bonzini
@ 2013-10-08 8:37 ` Igor Mammedov
3 siblings, 0 replies; 5+ messages in thread
From: Igor Mammedov @ 2013-10-08 8:37 UTC (permalink / raw)
To: Andreas Färber
Cc: Paolo Bonzini, Stefan Hajnoczi, qemu-devel, Anthony Liguori
On Mon, 7 Oct 2013 18:43:59 +0200
Andreas Färber <afaerber@suse.de> wrote:
> Hello,
>
> I have queued bug fixes by Igor and Stefan for device_add on qom-next and
> am rearranging the following changes of mine on top.
>
> 1) Further naming cleanups, now rebased on the bugfixes for easier backporting.
> 2) Inlining of qdev_init(), so that we always have unparent+unref pairs.
>
> If there's no objections, planning to include this in a pull tonight or tomorrow.
>
> Regards,
> Andreas
>
> Cc: Igor Mammedov <imammedo@redhat.com>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Anthony Liguori <anthony@codemonkey.ws>
>
> Andreas Färber (2):
> qdev-monitor: Avoid qdev as variable name
> qdev-monitor: Inline qdev_init() for device_add
>
> qdev-monitor.c | 37 +++++++++++++++++++++----------------
> 1 file changed, 21 insertions(+), 16 deletions(-)
>
Reviewed-By: Igor Mammedov <imammedo@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-10-08 8:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-07 16:43 [Qemu-devel] [PATCH qom-next 0/2] qdev-monitor: Reference counting follow-ups Andreas Färber
2013-10-07 16:44 ` [Qemu-devel] [PATCH qom-next 1/2] qdev-monitor: Avoid qdev as variable name Andreas Färber
2013-10-07 16:44 ` [Qemu-devel] [PATCH qom-next 2/2] qdev-monitor: Inline qdev_init() for device_add Andreas Färber
2013-10-07 17:04 ` [Qemu-devel] [PATCH qom-next 0/2] qdev-monitor: Reference counting follow-ups Paolo Bonzini
2013-10-08 8:37 ` Igor Mammedov
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).