qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 06/15] set_property(): extend signature with Erro


From: Laszlo Ersek
Subject: [Qemu-devel] [PATCH v2 06/15] set_property(): extend signature with Error
Date: Tue, 5 Feb 2013 21:39:19 +0100

Signed-off-by: Laszlo Ersek <address@hidden>
---
 hw/qdev-monitor.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
index cf96046..545e66c 100644
--- a/hw/qdev-monitor.c
+++ b/hw/qdev-monitor.c
@@ -100,9 +100,14 @@ static void qdev_print_devinfo(ObjectClass *klass, void 
*opaque)
     error_printf("\n");
 }
 
+typedef struct {
+    DeviceState *dev;
+    Error **errp;
+} PropertyContext;
+
 static int set_property(const char *name, const char *value, void *opaque)
 {
-    DeviceState *dev = opaque;
+    PropertyContext *ctx = opaque;
     Error *err = NULL;
 
     if (strcmp(name, "driver") == 0)
@@ -110,7 +115,7 @@ static int set_property(const char *name, const char 
*value, void *opaque)
     if (strcmp(name, "bus") == 0)
         return 0;
 
-    qdev_prop_parse(dev, name, value, &err);
+    qdev_prop_parse(ctx->dev, name, value, &err);
     if (error_is_set(&err)) {
         qerror_report_err(err);
         error_free(err);
@@ -481,10 +486,16 @@ DeviceState *qdev_device_add(QemuOpts *opts)
     if (id) {
         qdev->id = id;
     }
-    if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {
-        qdev_free(qdev);
-        return NULL;
+
+    {
+        PropertyContext ctx = { .dev = qdev, .errp = NULL };
+
+        if (qemu_opt_foreach(opts, set_property, &ctx, 1) != 0) {
+            qdev_free(qdev);
+            return NULL;
+        }
     }
+
     if (qdev->id) {
         object_property_add_child(qdev_get_peripheral(), qdev->id,
                                   OBJECT(qdev), NULL);
-- 
1.7.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]