From: Eric Blake <eblake@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>, qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"John Snow" <jsnow@redhat.com>
Subject: Re: [PATCH 03/12] qom: Make object_class_property_add_uint*_ptr() get offset
Date: Fri, 9 Oct 2020 12:24:19 -0500 [thread overview]
Message-ID: <eeb91413-2a1e-5c83-e756-11dbe3be1b6f@redhat.com> (raw)
In-Reply-To: <20201009160122.1662082-4-ehabkost@redhat.com>
[-- Attachment #1.1: Type: text/plain, Size: 1707 bytes --]
On 10/9/20 11:01 AM, Eduardo Habkost wrote:
> The existing object_class_property_add_uint*_ptr() functions are
> not very useful, because they need a pointer to the property
> value, which can't really be provided before the object is
> created.
>
> Replace the pointer parameter in those functions with a
> `ptrdiff_t offset` parameter.
>
> Include a uint8 class property in check-qom-proplist unit tests,
> to ensure the feature is working.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> static void *pointer_property_get_ptr(Object *obj, PointerProperty *prop)
> {
> - return prop->ptr;
> + if (prop->is_offset) {
> + return (void *)obj + prop->offset;
Addition on void* is a gcc extension. Does clang support it as well, or
should you be casting to char* instead?
> + } else {
> + return prop->ptr;
> + }
> }
>
> +++ b/tests/check-qom-proplist.c
> @@ -61,6 +61,7 @@ struct DummyObject {
> bool bv;
> DummyAnimal av;
> char *sv;
> + uint8_t u8v;
> };
>
> struct DummyObjectClass {
> @@ -141,6 +142,9 @@ static void dummy_class_init(ObjectClass *cls, void *data)
> &dummy_animal_map,
> dummy_get_av,
> dummy_set_av);
> + object_class_property_add_uint8_ptr(cls, "u8v",
> + offsetof(DummyObject, u8v),
> + OBJ_PROP_FLAG_READWRITE);
I like how it turns out.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-10-09 17:26 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-09 16:01 [PATCH 00/12] qom: Make all -object types use only class properties Eduardo Habkost
2020-10-09 16:01 ` [PATCH 01/12] qom: Helpers for pointer properties Eduardo Habkost
2020-10-09 16:01 ` [PATCH 02/12] qom: Introduce PointerProperty struct Eduardo Habkost
2020-10-09 16:01 ` [PATCH 03/12] qom: Make object_class_property_add_uint*_ptr() get offset Eduardo Habkost
2020-10-09 17:24 ` Eric Blake [this message]
2020-10-09 17:31 ` Eduardo Habkost
2020-10-21 12:24 ` Igor Mammedov
2020-10-21 13:30 ` Eduardo Habkost
2020-10-22 5:06 ` Markus Armbruster
2020-10-22 21:34 ` Eduardo Habkost
2020-10-23 15:33 ` Igor Mammedov
2020-10-27 22:18 ` Eduardo Habkost
2020-10-28 15:22 ` Paolo Bonzini
2020-10-28 15:53 ` Igor Mammedov
2020-10-29 12:56 ` Eduardo Habkost
2020-10-29 13:37 ` Igor Mammedov
2020-10-09 16:01 ` [PATCH 04/12] sev: Use class properties Eduardo Habkost
2020-10-09 16:01 ` [PATCH 05/12] rng: " Eduardo Habkost
2020-10-09 16:01 ` [PATCH 06/12] can_host: " Eduardo Habkost
2020-10-12 14:52 ` Pavel Pisa
2020-10-09 16:01 ` [PATCH 07/12] colo: " Eduardo Habkost
2020-10-09 16:01 ` [PATCH 08/12] netfilter: Reorder functions Eduardo Habkost
2020-10-09 16:01 ` [PATCH 09/12] netfilter: Use class properties Eduardo Habkost
2020-10-09 16:01 ` [PATCH 10/12] input: " Eduardo Habkost
2020-10-13 12:54 ` Gerd Hoffmann
2020-10-09 16:01 ` [PATCH 11/12] [RFC] qom: Property lock mechanism Eduardo Habkost
2020-10-09 16:01 ` [PATCH 12/12] [RFC] qom: Lock properties of all TYPE_USER_CREATABLE types Eduardo Habkost
2020-10-09 21:31 ` [PATCH] check-qom-proplist: Don't register instance props for user-creatable type Eduardo Habkost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eeb91413-2a1e-5c83-e756-11dbe3be1b6f@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=ehabkost@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).