From patchwork Tue Apr 15 02:21:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 339133 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2AAB014007B for ; Tue, 15 Apr 2014 12:22:08 +1000 (EST) Received: from localhost ([::1]:46464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZt0f-00055A-W4 for incoming@patchwork.ozlabs.org; Mon, 14 Apr 2014 22:22:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55424) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZt0I-0004TT-SZ for qemu-devel@nongnu.org; Mon, 14 Apr 2014 22:21:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WZt0A-00033e-CK for qemu-devel@nongnu.org; Mon, 14 Apr 2014 22:21:42 -0400 Received: from mail-qa0-f43.google.com ([209.85.216.43]:62674) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZt0A-00033a-8O for qemu-devel@nongnu.org; Mon, 14 Apr 2014 22:21:34 -0400 Received: by mail-qa0-f43.google.com with SMTP id j15so8911398qaq.30 for ; Mon, 14 Apr 2014 19:21:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=9YzcrY7QrPsYG7J1M4vgwd07LQCEKZc78N2yPC6PSIY=; b=c2O2IiRLIgOUHk/iE68BAHMNc5LYFDdNMALTQI+WL+6tq6lNXpFJ9fQxzS9qaMISZ0 HIBaPo6izbn5gWIVOe750lNbBhm2PULsCNaSaOU7UoXkMiQa/zeg5v5wERGcKAGzvobz dnt++HV/lNNvY9hjiQgyUfDWsGeuB+57BP4L4P42EnhXRZbY50UL+PJG2NtE3+4OAPC0 WqQRTTNkQakuT0ux249lhsNIMGbWYRyqxrqyTNkrYknJ7yGTXqATmw7DQ1IwYnx4xynb gqhqM7kj29X2YGmj1xJ4bq9AFafF5I7+c07vwSHHYsGmZQR0NGgzyo8i8SkSXqGfrckL ggIw== X-Gm-Message-State: ALoCoQmQvI4WkwugfsiRl4LlIhvteSv9M4/Gq/XgR8Nk7hXYfhvUgwydaaCxSzEjruSh4wwhGTL3 X-Received: by 10.224.36.194 with SMTP id u2mr23972299qad.73.1397528493960; Mon, 14 Apr 2014 19:21:33 -0700 (PDT) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPSA id f3sm34783162qag.7.2014.04.14.19.21.32 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 14 Apr 2014 19:21:33 -0700 (PDT) From: Peter Crosthwaite To: qemu-devel@nongnu.org Date: Mon, 14 Apr 2014 19:21:01 -0700 Message-Id: <8a19b27e4e9eed971bdd4e0d5e5789a923f8c8b6.1397527916.git.peter.crosthwaite@xilinx.com> X-Mailer: git-send-email 1.9.2.1.g06c4abd In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.216.43 Cc: peter.maydell@linaro.org, agraf@suse.de, armbru@redhat.com, edgar.iglesias@gmail.com, alistair.francis@xilinx.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v1 1/3] qdev: Expose the qdev id string as a prop X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org So clients can set the top level id string. Signed-off-by: Peter Crosthwaite --- hw/core/qdev.c | 13 +++++++++++-- include/hw/qdev-core.h | 2 +- qdev-monitor.c | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 60f9df1..a32e39b 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -833,13 +833,16 @@ static void device_initfn(Object *obj) device_get_hotpluggable, NULL, NULL); class = object_get_class(OBJECT(dev)); - do { + for (;;) { for (prop = DEVICE_CLASS(class)->props; prop && prop->name; prop++) { qdev_property_add_legacy(dev, prop, &error_abort); qdev_property_add_static(dev, prop, &error_abort); } + if (class == object_class_by_name(TYPE_DEVICE)) { + break; + } class = object_class_get_parent(class); - } while (class != object_class_by_name(TYPE_DEVICE)); + } object_property_add_link(OBJECT(dev), "parent_bus", TYPE_BUS, (Object **)&dev->parent_bus, NULL, 0, @@ -906,6 +909,11 @@ static void device_unparent(Object *obj) } } +static Property device_props[] = { + DEFINE_PROP_STRING("device-id", DeviceState, id), + DEFINE_PROP_END_OF_LIST(), +}; + static void device_class_init(ObjectClass *class, void *data) { DeviceClass *dc = DEVICE_CLASS(class); @@ -913,6 +921,7 @@ static void device_class_init(ObjectClass *class, void *data) class->unparent = device_unparent; dc->realize = device_realize; dc->unrealize = device_unrealize; + dc->props = device_props; /* by default all devices were considered as hotpluggable, * so with intent to check it in generic qdev_unplug() / diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index dbe473c..38557d3 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -143,7 +143,7 @@ struct DeviceState { Object parent_obj; /*< public >*/ - const char *id; + char *id; bool realized; QemuOpts *opts; int hotplugged; diff --git a/qdev-monitor.c b/qdev-monitor.c index 9268c87..f0713a9 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -531,7 +531,8 @@ DeviceState *qdev_device_add(QemuOpts *opts) id = qemu_opts_id(opts); if (id) { - dev->id = id; + /* FIXME: Qdev String props cant handle consts */ + dev->id = (char *)id; } if (dev->id) {