From patchwork Mon Dec 16 08:05:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 301503 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 0B6C32C0085 for ; Mon, 16 Dec 2013 19:11:27 +1100 (EST) Received: from localhost ([::1]:54367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsTGt-0006ba-JO for incoming@patchwork.ozlabs.org; Mon, 16 Dec 2013 03:11:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsTGO-0006Ws-Ra for qemu-devel@nongnu.org; Mon, 16 Dec 2013 03:10:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VsTGJ-0003oU-0B for qemu-devel@nongnu.org; Mon, 16 Dec 2013 03:10:52 -0500 Received: from mail-pd0-x236.google.com ([2607:f8b0:400e:c02::236]:48012) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsTGI-0003oI-4w for qemu-devel@nongnu.org; Mon, 16 Dec 2013 03:10:46 -0500 Received: by mail-pd0-f182.google.com with SMTP id v10so5061865pde.27 for ; Mon, 16 Dec 2013 00:10:45 -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=CcpUVjbsojefvmCTxyO9KbEFE1bTLsZx5H0emUr80PE=; b=sAULXgALJxy+mBzaf1uN8cmWOytqTamMsRvWXs8oVQGDu2QrZ3TOZAXhlkSqRCIu+v JyC01QNt7CZ+ekDpKCP5n9pCXjBZL1PnNOazYdAU/2PgjhNZzxFi40UOAV6H03PdjwGL t1FawIhjR14HbkOnA+rfesc9n+zibL6jEd4dTyaij1f4pv7OZ96k/GkSjxfFmGN32+7Q tfEn0z2yJHleMUsl6lajQgOf9YgQawB4koJpeDZY5pIB3xdz6uc+ZKuXJwMyzKefLqV5 /tKi3S5NfvWzPqEM2Fx5GrmJ0+XxvbGwVd86pwWeMaiDqGLJmZjtzAyJr/dMwBa9IRmw DXrQ== X-Received: by 10.68.189.5 with SMTP id ge5mr18663223pbc.42.1387181445327; Mon, 16 Dec 2013 00:10:45 -0800 (PST) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPSA id ic7sm4006125pbc.29.2013.12.16.00.10.44 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 16 Dec 2013 00:10:45 -0800 (PST) From: edgar.iglesias@gmail.com To: qemu-devel@nongnu.org Date: Mon, 16 Dec 2013 18:05:55 +1000 Message-Id: <1387181170-23267-8-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1387181170-23267-1-git-send-email-edgar.iglesias@gmail.com> References: <1387181170-23267-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:400e:c02::236 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 v1 07/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 | 46 ++++++++++++++++++++++++++++++++++++++ include/hw/qdev-properties.h | 5 +++++ 2 files changed, 51 insertions(+) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 729efa8..f78bd50 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -170,6 +170,42 @@ PropertyInfo qdev_prop_chr = { .release = release_chr, }; +/* --- AddressSpace --- */ + +static int parse_address_space(DeviceState *dev, const char *name, void **ptr) +{ + AddressSpace *as = address_space_find_by_name(name); + if (as == NULL) { + return -ENOENT; + } + *ptr = as; + return 0; +} + +static const char *print_address_space(void *ptr) +{ + AddressSpace *as = ptr; + return as->name; +} + +static void get_address_space(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + get_pointer(obj, v, opaque, print_address_space, name, errp); +} + +static void set_address_space(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + set_pointer(obj, v, opaque, parse_address_space, name, errp); +} + +PropertyInfo qdev_prop_address_space = { + .name = "address_space", + .get = get_address_space, + .set = set_address_space, +}; + /* --- netdev device --- */ static int parse_netdev(DeviceState *dev, const char *str, void **ptr) @@ -369,6 +405,16 @@ void qdev_prop_set_netdev(DeviceState *dev, const char *name, assert_no_error(errp); } +void qdev_prop_set_address_space(DeviceState *dev, const char *name, + AddressSpace *value) +{ + Error *errp = NULL; + assert(!value || value->name); + object_property_set_str(OBJECT(dev), + value ? value->name : "", name, &errp); + assert_no_error(errp); +} + void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd) { qdev_prop_set_macaddr(dev, "mac", nd->macaddr.a); diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 692f82e..0e1076d 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; @@ -124,6 +125,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) \ @@ -160,6 +163,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;