From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SARcQ-0006x2-W2 for qemu-devel@nongnu.org; Wed, 21 Mar 2012 15:54:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SARcO-0005k7-DS for qemu-devel@nongnu.org; Wed, 21 Mar 2012 15:54:50 -0400 Received: from mail-bk0-f45.google.com ([209.85.214.45]:35473) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SARcO-0005jq-0j for qemu-devel@nongnu.org; Wed, 21 Mar 2012 15:54:48 -0400 Received: by bkcjg9 with SMTP id jg9so1491843bkc.4 for ; Wed, 21 Mar 2012 12:54:45 -0700 (PDT) Message-ID: <4F6A4015.1060808@gmail.com> Date: Wed, 21 Mar 2012 23:54:45 +0300 From: Igor Mitsyanko MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 14/36] vmstate: introduce VMSTATE_VARRAY_MULTIPLY Reply-To: i.mitsyanko@samsung.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org, d.solodkiy@samsung.com On 20.03.2012 1:57 AM, Juan Quintela wrote: > This allows to sent a partial array where the size is another > structure field multiplied by a constant. > > Signed-off-by: Juan Quintela > --- > savevm.c | 6 ++++++ > vmstate.h | 35 +++++++++++++++++++++++------------ > 2 files changed, 29 insertions(+), 12 deletions(-) > > diff --git a/savevm.c b/savevm.c > index 4c42076..17927f1 100644 > --- a/savevm.c > +++ b/savevm.c > @@ -1519,6 +1519,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, > } else if (field->flags& VMS_VARRAY_UINT8) { > n_elems = *(uint8_t *)(opaque+field->num_offset); > } > + if (field->flags& VMS_MULTIPLY_ELEMENTS) { > + n_elems *= field->num; > + } > if (field->flags& VMS_POINTER) { > base_addr = *(void **)base_addr + field->start; > } > @@ -1583,6 +1586,9 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, > } else if (field->flags& VMS_VARRAY_UINT8) { > n_elems = *(uint8_t *)(opaque+field->num_offset); > } > + if (field->flags& VMS_MULTIPLY_ELEMENTS) { > + n_elems *= field->num; > + } > if (field->flags& VMS_POINTER) { > base_addr = *(void **)base_addr + field->start; > } > diff --git a/vmstate.h b/vmstate.h > index b8ac2d0..b0225e9 100644 > --- a/vmstate.h > +++ b/vmstate.h > @@ -64,18 +64,19 @@ struct VMStateInfo { > }; > > enum VMStateFlags { > - VMS_SINGLE = 0x001, > - VMS_POINTER = 0x002, > - VMS_ARRAY = 0x004, > - VMS_STRUCT = 0x008, > - VMS_VARRAY_INT32 = 0x010, /* Array with size in int32_t field*/ > - VMS_BUFFER = 0x020, /* static sized buffer */ > - VMS_ARRAY_OF_POINTER = 0x040, > - VMS_VARRAY_UINT16 = 0x080, /* Array with size in uint16_t field */ > - VMS_VBUFFER = 0x100, /* Buffer with size in int32_t field */ > - VMS_MULTIPLY = 0x200, /* multiply "size" field by field_size */ > - VMS_VARRAY_UINT8 = 0x400, /* Array with size in uint8_t field*/ > - VMS_VARRAY_UINT32 = 0x800, /* Array with size in uint32_t field*/ > + VMS_SINGLE = 0x001, > + VMS_POINTER = 0x002, > + VMS_ARRAY = 0x004, > + VMS_STRUCT = 0x008, > + VMS_VARRAY_INT32 = 0x010, /* Array with size in int32_t field*/ > + VMS_BUFFER = 0x020, /* static sized buffer */ > + VMS_ARRAY_OF_POINTER = 0x040, > + VMS_VARRAY_UINT16 = 0x080, /* Array with size in uint16_t field */ > + VMS_VBUFFER = 0x100, /* Buffer with size in int32_t field */ > + VMS_MULTIPLY = 0x200, /* multiply "size" field by field_size */ > + VMS_VARRAY_UINT8 = 0x400, /* Array with size in uint8_t field*/ > + VMS_VARRAY_UINT32 = 0x800, /* Array with size in uint32_t field*/ > + VMS_MULTIPLY_ELEMENTS = 0x1000, /* multiply "size" field by field_size */ > }; > You forgot to change a comment here. > typedef struct { > @@ -200,6 +201,16 @@ extern const VMStateDescription vmstate_cpu; > .offset = vmstate_offset_array(_state, _field, _type, _num), \ > } > > +#define VMSTATE_VARRAY_MULTIPLY(_field, _state, _field_num, _multiply, _info, _type) { \ > + .name = (stringify(_field)), \ > + .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\ > + .num = (_multiply), \ > + .info =&(_info), \ > + .size = sizeof(_type), \ > + .flags = VMS_VARRAY_UINT32|VMS_MULTIPLY_ELEMENTS, \ > + .offset = offsetof(_state, _field), \ > +} > + Why just "VMSTATE_VARRAY_MULTIPLY" when you use VMS_VARRAY_UINT32 flag? Probably should be VMSTATE_VARRAY_UINT32_MULTIPLY > #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\ > .name = (stringify(_field)), \ > .field_exists = (_test), \