yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From 695e02fdf90a0487f70b26b276e71e0924a817dc Mon Sep 17 00:00:00 2001
9ae3a8
From: Markus Armbruster <armbru@redhat.com>
9ae3a8
Date: Thu, 16 Jan 2014 15:25:19 -0500
9ae3a8
Subject: [PATCH 13/14] qdev: Document that pointer properties kill device_add
9ae3a8
MIME-Version: 1.0
9ae3a8
Content-Type: text/plain; charset=UTF-8
9ae3a8
Content-Transfer-Encoding: 8bit
9ae3a8
9ae3a8
Message-id: <1389885919-16158-3-git-send-email-armbru@redhat.com>
9ae3a8
Patchwork-id: 56749
9ae3a8
O-Subject: [PATCH 7.0 qemu-kvm 2/2] qdev: Document that pointer properties kill device_add
9ae3a8
Bugzilla: 1031098
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
Ask users of DEFINE_PROP_PTR() to set
9ae3a8
cannot_instantiate_with_device_add_yet, or explain why it's not
9ae3a8
needed.
9ae3a8
9ae3a8
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
Signed-off-by: Andreas Färber <afaerber@suse.de>
9ae3a8
(cherry picked from commit c272758f93b9c88c884461a2baa37b8f4008bf02)
9ae3a8
---
9ae3a8
 include/hw/qdev-properties.h | 17 +++++++++++++++++
9ae3a8
 1 file changed, 17 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 include/hw/qdev-properties.h | 17 +++++++++++++++++
9ae3a8
 1 file changed, 17 insertions(+)
9ae3a8
9ae3a8
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
9ae3a8
index 692f82e..77c6f7c 100644
9ae3a8
--- a/include/hw/qdev-properties.h
9ae3a8
+++ b/include/hw/qdev-properties.h
9ae3a8
@@ -122,8 +122,25 @@ extern PropertyInfo qdev_prop_arraylen;
9ae3a8
 #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d)                   \
9ae3a8
     DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
9ae3a8
 
9ae3a8
+/*
9ae3a8
+ * Please avoid pointer properties.  If you must use them, you must
9ae3a8
+ * cover them in their device's class init function as follows:
9ae3a8
+ *
9ae3a8
+ * - If the property must be set, the device cannot be used with
9ae3a8
+ *   device_add, so add code like this:
9ae3a8
+ *   |* Reason: pointer property "NAME-OF-YOUR-PROP" *|
9ae3a8
+ *   DeviceClass *dc = DEVICE_CLASS(class);
9ae3a8
+ *   dc->cannot_instantiate_with_device_add_yet = true;
9ae3a8
+ *
9ae3a8
+ * - If the property may safely remain null, document it like this:
9ae3a8
+ *   |*
9ae3a8
+ *    * Note: pointer property "interrupt_vector" may remain null, thus
9ae3a8
+ *    * no need for dc->cannot_instantiate_with_device_add_yet = true;
9ae3a8
+ *    *|
9ae3a8
+ */
9ae3a8
 #define DEFINE_PROP_PTR(_n, _s, _f)             \
9ae3a8
     DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)
9ae3a8
+
9ae3a8
 #define DEFINE_PROP_CHR(_n, _s, _f)             \
9ae3a8
     DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
9ae3a8
 #define DEFINE_PROP_STRING(_n, _s, _f)             \
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8