From: Jianjun Duan <duanj@linux.vnet.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: quintela@redhat.com, mdroth@linux.vnet.ibm.com,
qemu-ppc@nongnu.org, amit.shah@redhat.com,
david@gibson.dropbear.id.au
Subject: Re: [Qemu-devel] [QEMU RFC PATCH v2 4/6] Migration: migrate QTAILQ
Date: Wed, 25 May 2016 09:37:59 -0700 [thread overview]
Message-ID: <5745D4E7.2000003@linux.vnet.ibm.com> (raw)
In-Reply-To: <a4362038-0d6d-505e-7dca-14fea89aa338@redhat.com>
On 05/25/2016 01:14 AM, Paolo Bonzini wrote:
>
>
> On 24/05/2016 19:55, Jianjun Duan wrote:
>> +/*
>> + * Offsets of layout of a tail queue head.
>> + */
>> +#define QTAILQ_FIRST_OFFSET(head_type) \
>> + ((size_t) ((char *) &((head_type *)0)->tqh_first - (char *)0))
>> +
>> +#define QTAILQ_LAST_OFFSET(head_type) \
>> + ((size_t) ((char *) &((head_type *)0)->tqh_last - (char *)0))
>> +
>> +/*
>> + * Offsets of layout of a tail queue element.
>> + */
>> +#define QTAILQ_NEXT_OFFSET(ele_type, field) \
>> + ((size_t) ((char *) &((ele_type *)0)->field.tqe_next - \
>> + (char *) &((ele_type *)0)->field))
>> +
>> +#define QTAILQ_PREV_OFFSET(ele_type, field) \
>> + ((size_t) ((char *) &((ele_type *)0)->field.tqe_prev - \
>> + (char *) &((ele_type *)0)->field))
>
> Please use offsetof.
OK.
>
>> + /*
>> + * Following 3 fields are for VMStateField which needs customized handling,
>> + * such as QTAILQ in qemu/queue.h, lists, and tree.
>> + */
>> + const void *meta_data;
>> + int (*extend_get)(QEMUFile *f, const void *metadata, void *opaque);
>> + void (*extend_put)(QEMUFile *f, const void *metadata, void *opaque,
>> + QJSON *vmdesc);
>> } VMStateField;
>
> Do not add these two function pointers to VMStateField, instead add
> QJSON* and VMStateField* arguments as needed to VMStateInfo's get and put.
>
That is definitely the ideal way. However, VMStateInfo's get/put are
already used extensively. If I change them, I need change all the
calling sites of them. Not very sure about whether it will be welcomed.
>> +#define VMSTATE_QTAILQ_METADATA(_field, _state, _type, _next, _vmsd) { \
>> + .first = QTAILQ_FIRST_OFFSET(typeof_field(_state, _field)), \
>> + .last = QTAILQ_LAST_OFFSET(typeof_field(_state, _field)), \
>> + .next = QTAILQ_NEXT_OFFSET(_type, _next), \
>> + .prev = QTAILQ_PREV_OFFSET(_type, _next), \
>> + .entry = offsetof(_type, _next), \
>> + .size = sizeof(_type), \
>> + .vmsd = &(_vmsd), \
>> +}
>
> .last and .prev are unnecessary, since they come just after .first and
> .next (and their use is hidden behind QTAILQ_RAW_*). .first and .next
> can be placed in .offset and .num_offset respectively. So you don't
> really need an extra metadata struct.
>
> If you prefer you could have something like
>
> union {
> size_t num_offset; /* VMS_VARRAY */
> size_t size_offset; /* VMS_VBUFFER */
> size_t next_offset; /* VMS_TAILQ */
> } offsets;
>
Actually I explored the approach in which I use a VMSD to encode all the
information. But a VMSD describes actual memory layout. Interpreting it
another way could be confusing.
One of the assumption about QTAILQ is that we can only use the
interfaces defined in queue.h to access it. I intend not to depend on
its actually layout. From this perspective, these 6 parameters are
needed.
> Thanks,
>
> Paolo
>
Thanks,
Jianjun
next prev parent reply other threads:[~2016-05-25 16:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-24 17:55 [Qemu-devel] [QEMU RFC PATCH v2 0/6] Migration: ensure hotplug and migration work together Jianjun Duan
2016-05-24 17:55 ` [Qemu-devel] [QEMU RFC PATCH v2 1/6] spapr: ensure device trees are always associated with DRC Jianjun Duan
2016-05-25 5:20 ` David Gibson
2016-05-24 17:55 ` [Qemu-devel] [QEMU RFC PATCH v2 2/6] Migration: Defined VMStateDescription struct for spapr_drc Jianjun Duan
2016-05-24 17:55 ` [Qemu-devel] [QEMU RFC PATCH v2 3/6] vmstate: Define VARRAY with VMS_ALLOC Jianjun Duan
2016-05-24 17:55 ` [Qemu-devel] [QEMU RFC PATCH v2 4/6] Migration: migrate QTAILQ Jianjun Duan
2016-05-25 5:38 ` David Gibson
2016-05-25 8:14 ` Paolo Bonzini
2016-05-25 16:37 ` Jianjun Duan [this message]
2016-05-25 17:51 ` Paolo Bonzini
2016-05-25 18:30 ` Jianjun Duan
2016-05-25 19:22 ` Paolo Bonzini
2016-05-25 20:17 ` Jianjun Duan
2016-05-26 7:11 ` Paolo Bonzini
2016-05-26 16:43 ` Jianjun Duan
2016-05-26 16:52 ` Paolo Bonzini
2016-05-24 17:55 ` [Qemu-devel] [QEMU RFC PATCH v2 5/6] Migration: migrate ccs_list in spapr state Jianjun Duan
2016-05-24 17:55 ` [Qemu-devel] [QEMU RFC PATCH v2 6/6] Migration: migrate pending_events of " Jianjun Duan
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=5745D4E7.2000003@linux.vnet.ibm.com \
--to=duanj@linux.vnet.ibm.com \
--cc=amit.shah@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=quintela@redhat.com \
/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).