From patchwork Mon Feb 3 09:44:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 316114 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0D4282C0086 for ; Mon, 3 Feb 2014 21:01:31 +1100 (EST) Received: from localhost ([::1]:45315 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAGLI-00066f-Ve for incoming@patchwork.ozlabs.org; Mon, 03 Feb 2014 05:01:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAGGl-0008N4-HZ for qemu-devel@nongnu.org; Mon, 03 Feb 2014 04:56:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WAGGf-0002eu-MC for qemu-devel@nongnu.org; Mon, 03 Feb 2014 04:56:47 -0500 Received: from mail-qa0-x229.google.com ([2607:f8b0:400d:c00::229]:54729) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAGGf-0002e3-Hb for qemu-devel@nongnu.org; Mon, 03 Feb 2014 04:56:41 -0500 Received: by mail-qa0-f41.google.com with SMTP id w8so9833203qac.0 for ; Mon, 03 Feb 2014 01:56:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HNIqWLePjM/8Te+llmg5TfMlvxLWIYHPAKeS0q3R7kw=; b=IO4UsmxS2eZqjSkfijkweLblYCLvP1pKBBmibv605PcRwTPVUq0iWC5XfG7GLEUbBA 9VbbtLgffT9vJfA1dqf8HU38SIVKelCYW9T4h+OWS7xeNHELjBnJVyXrFE0RPDukynKc wWWCoPDgOJEIEJ970SUIeMWmi0Dq6/LJA7AZXOpWfL1lw29NPaAz3zSo0Dbgq3zQDTmp PRLrGqqE1SXQtK0hbo4IHOf5EdPpkMsqYfBEc8nCZ8Y+nYCZAd8HCFs+y7po1MIZ7MBi Bb9PgHXZgYeQNTXg9MPbzsWODZtqyZgSI2jePo01h7EpLPT3iGQVd4xqA0UBzsndFbGs 1dNw== X-Received: by 10.224.55.197 with SMTP id v5mr55129522qag.9.1391421401109; Mon, 03 Feb 2014 01:56:41 -0800 (PST) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPSA id b4sm26410888qgf.16.2014.02.03.01.56.39 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 03 Feb 2014 01:56:40 -0800 (PST) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org Date: Mon, 3 Feb 2014 19:44:47 +1000 Message-Id: <1391420690-23745-20-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1391420690-23745-1-git-send-email-edgar.iglesias@gmail.com> References: <1391420690-23745-1-git-send-email-edgar.iglesias@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c00::229 Cc: peter.maydell@linaro.org, blauwirbel@gmail.com, aliguori@amazon.com, pcrost@xilinx.com, pbonzini@redhat.com, afaerber@suse.de, aurelien@aurel32.net, rth@twiddle.net Subject: [Qemu-devel] [PATCH v4 19/22] qdev: Add qdev property type for AddressSpaces 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 From: "Edgar E. Iglesias" Signed-off-by: Edgar E. Iglesias --- hw/core/qdev-properties-system.c | 8 ++++++ hw/core/qdev-properties.c | 54 ++++++++++++++++++++++++++++++++++++++++ include/hw/qdev-properties.h | 5 ++++ stubs/Makefile.objs | 1 + stubs/memory.c | 6 +++++ 5 files changed, 74 insertions(+) create mode 100644 stubs/memory.c diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 3f29b49..27c2899 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -365,6 +365,14 @@ void qdev_prop_set_netdev(DeviceState *dev, const char *name, value ? value->name : "", name, &error_abort); } +void qdev_prop_set_address_space(DeviceState *dev, const char *name, + AddressSpace *value) +{ + assert(!value || value->name); + object_property_set_str(OBJECT(dev), + value ? value->name : "", name, &error_abort); +} + void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd) { qdev_prop_set_macaddr(dev, "mac", nd->macaddr.a); diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index b949f0e..68e09e2 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1176,3 +1176,57 @@ PropertyInfo qdev_prop_size = { .get = get_size, .set = set_size, }; + +/* --- AddressSpace --- */ + +static int parse_address_space(DeviceState *dev, const char *name, + AddressSpace **ptr) +{ + AddressSpace *as = address_space_find_by_name(name); + if (as == NULL) { + return -ENOENT; + } + *ptr = as; + return 0; +} + +static void get_address_space(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + AddressSpace *as = qdev_get_prop_ptr(DEVICE(obj), opaque); + char *p = (char *) (as ? as->name : ""); + + visit_type_str(v, &p, name, errp); +} + +static void set_address_space(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + DeviceState *dev = DEVICE(obj); + Property *prop = opaque; + Error *local_err = NULL; + AddressSpace **as = qdev_get_prop_ptr(dev, prop); + char *str; + int ret; + + if (dev->realized) { + qdev_prop_set_after_realize(dev, name, errp); + return; + } + + visit_type_str(v, &str, name, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + ret = parse_address_space(dev, str, as); + error_set_from_qdev_prop_error(errp, ret, dev, prop, str); + g_free(str); +} + +PropertyInfo qdev_prop_address_space = { + .name = "address_space", + .get = get_address_space, + .set = set_address_space, +}; diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 77c6f7c..020439f 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -19,6 +19,7 @@ extern PropertyInfo qdev_prop_size; extern PropertyInfo qdev_prop_string; extern PropertyInfo qdev_prop_chr; extern PropertyInfo qdev_prop_ptr; +extern PropertyInfo qdev_prop_address_space; extern PropertyInfo qdev_prop_macaddr; extern PropertyInfo qdev_prop_losttickpolicy; extern PropertyInfo qdev_prop_bios_chs_trans; @@ -141,6 +142,8 @@ extern PropertyInfo qdev_prop_arraylen; #define DEFINE_PROP_PTR(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*) +#define DEFINE_PROP_ADDRESS_SPACE(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_address_space, AddressSpace*) #define DEFINE_PROP_CHR(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*) #define DEFINE_PROP_STRING(_n, _s, _f) \ @@ -177,6 +180,8 @@ void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value); void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value); void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value); void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value); +void qdev_prop_set_address_space(DeviceState *dev, const char *name, + AddressSpace *value); void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value); void qdev_prop_set_netdev(DeviceState *dev, const char *name, NetClientState *value); int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) QEMU_WARN_UNUSED_RESULT; diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index df92fe5..9e1e5da 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -26,4 +26,5 @@ stub-obj-y += uuid.o stub-obj-y += vm-stop.o stub-obj-y += vmstate.o stub-obj-$(CONFIG_WIN32) += fd-register.o +stub-obj-y += memory.o stub-obj-y += cpus.o diff --git a/stubs/memory.c b/stubs/memory.c new file mode 100644 index 0000000..b3b4736 --- /dev/null +++ b/stubs/memory.c @@ -0,0 +1,6 @@ +#include "exec/address-spaces.h" + +AddressSpace *address_space_find_by_name(const char *name) +{ + return NULL; +}