From patchwork Tue Dec 24 17:04:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 305022 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 0D3C12C00B7 for ; Wed, 25 Dec 2013 04:19:42 +1100 (EST) Received: from localhost ([::1]:39832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VvVdr-00087i-6f for incoming@patchwork.ozlabs.org; Tue, 24 Dec 2013 12:19:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VvVPT-00060X-O9 for qemu-devel@nongnu.org; Tue, 24 Dec 2013 12:04:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VvVPN-00046z-Ii for qemu-devel@nongnu.org; Tue, 24 Dec 2013 12:04:47 -0500 Received: from cantor2.suse.de ([195.135.220.15]:54428 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VvVPN-00046i-DO for qemu-devel@nongnu.org; Tue, 24 Dec 2013 12:04:41 -0500 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 00EE3AC19; Tue, 24 Dec 2013 17:04:41 +0000 (UTC) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Tue, 24 Dec 2013 18:04:24 +0100 Message-Id: <1387904675-7962-14-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1387904675-7962-1-git-send-email-afaerber@suse.de> References: <1387904675-7962-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.135.220.15 Cc: Markus Armbruster , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PULL v2 13/24] qdev: Document that pointer properties kill device_add 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: Markus Armbruster Ask users of DEFINE_PROP_PTR() to set cannot_instantiate_with_device_add_yet, or explain why it's not needed. Signed-off-by: Markus Armbruster Signed-off-by: Andreas Färber --- include/hw/qdev-properties.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 692f82e..77c6f7c 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -122,8 +122,25 @@ extern PropertyInfo qdev_prop_arraylen; #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t) +/* + * Please avoid pointer properties. If you must use them, you must + * cover them in their device's class init function as follows: + * + * - If the property must be set, the device cannot be used with + * device_add, so add code like this: + * |* Reason: pointer property "NAME-OF-YOUR-PROP" *| + * DeviceClass *dc = DEVICE_CLASS(class); + * dc->cannot_instantiate_with_device_add_yet = true; + * + * - If the property may safely remain null, document it like this: + * |* + * * Note: pointer property "interrupt_vector" may remain null, thus + * * no need for dc->cannot_instantiate_with_device_add_yet = true; + * *| + */ #define DEFINE_PROP_PTR(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*) + #define DEFINE_PROP_CHR(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*) #define DEFINE_PROP_STRING(_n, _s, _f) \