From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=46732 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q2DpF-0004Gv-7d for qemu-devel@nongnu.org; Tue, 22 Mar 2011 22:29:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q2DpE-0007wS-8X for qemu-devel@nongnu.org; Tue, 22 Mar 2011 22:29:33 -0400 Received: from mail-gw0-f45.google.com ([74.125.83.45]:32768) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q2DpE-0007wK-1F for qemu-devel@nongnu.org; Tue, 22 Mar 2011 22:29:32 -0400 Received: by gwb19 with SMTP id 19so3827269gwb.4 for ; Tue, 22 Mar 2011 19:29:31 -0700 (PDT) Message-ID: <4D895B03.8050004@codemonkey.ws> Date: Tue, 22 Mar 2011 21:29:23 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 03/11] vmstate: for vmstate types that reuse the same field, make sure name is unique References: <1300839376-22520-1-git-send-email-aliguori@us.ibm.com> <1300839376-22520-4-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1300839376-22520-4-git-send-email-aliguori@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Kiszka , qemu-devel@nongnu.org, Juan Quintela On 03/22/2011 07:16 PM, Anthony Liguori wrote: > For a schema to work, we need to make sure that each field name is unique. We > have a number of derivative types today that reuse the base name. This patch > fixes this. > > Signed-off-by: Anthony Liguori > --- > hw/hw.h | 16 +++++++++++++--- > 1 files changed, 13 insertions(+), 3 deletions(-) > > diff --git a/hw/hw.h b/hw/hw.h > index 81bbd7a..9a9012f 100644 > --- a/hw/hw.h > +++ b/hw/hw.h > @@ -390,6 +390,16 @@ extern const VMStateInfo vmstate_info_unused_buffer; > .offset = vmstate_offset_value(_state, _field, _type), \ > } > > +#define VMSTATE_SINGLE_TEST_HACK(_field, _state, _test, _version, _info, _type) { \ > + .name = (stringify(_field) "-hack"), \ > + .version_id = (_version), \ > + .field_exists = (_test), \ > + .size = sizeof(_type), \ > + .info =&(_info), \ > + .flags = VMS_SINGLE, \ > + .offset = vmstate_offset_value(_state, _field, _type), \ > +} > + > #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \ > .name = (stringify(_field)), \ > .version_id = (_version), \ > @@ -419,7 +429,7 @@ extern const VMStateInfo vmstate_info_unused_buffer; > } > > #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\ > - .name = (stringify(_field)), \ > + .name = (stringify(_field) "-" stringify(_test)), \ > .field_exists = (_test), \ > .num = (_num), \ > .info =&(_info), \ > @@ -429,7 +439,7 @@ extern const VMStateInfo vmstate_info_unused_buffer; > } > > #define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \ > - .name = (stringify(_field)), \ > + .name = (stringify(_field) "[" stringify(_start) "]"), \ > .version_id = (_version), \ > .num = (_num), \ > .info =&(_info), \ > @@ -621,7 +631,7 @@ extern const VMStateInfo vmstate_info_unused_buffer; > } > > #define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \ > - .name = "unused", \ > + .name = "unused" stringify(__LINE__), \ Why this does generate a unique name, it does not generate a stable name. We need to add a name argument to this macro and all its derivatives. I'll update tomorrow. If the test suite fails saying you added a new field labelled "unusedXXXX", this is why. Regards, Anthony Liguori > .field_exists = (_test), \ > .version_id = (_version), \ > .size = (_size), \