From patchwork Mon Oct 19 18:42:58 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 36404 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9E4AFB7B6F for ; Tue, 20 Oct 2009 06:07:34 +1100 (EST) Received: from localhost ([127.0.0.1]:39837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MzxZq-0000RK-HC for incoming@patchwork.ozlabs.org; Mon, 19 Oct 2009 15:07:30 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MzxDA-0006Bo-Pe for qemu-devel@nongnu.org; Mon, 19 Oct 2009 14:44:04 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MzxD3-00067J-Uw for qemu-devel@nongnu.org; Mon, 19 Oct 2009 14:44:02 -0400 Received: from [199.232.76.173] (port=49046 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MzxD3-00067D-RE for qemu-devel@nongnu.org; Mon, 19 Oct 2009 14:43:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59175) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MzxD3-0006KU-AH for qemu-devel@nongnu.org; Mon, 19 Oct 2009 14:43:57 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9JIhuuD001842 for ; Mon, 19 Oct 2009 14:43:56 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9JIhcC6012656; Mon, 19 Oct 2009 14:43:55 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 19 Oct 2009 20:42:58 +0200 Message-Id: <66e8b6066a781abf0831ec4eb8f959494a575062.1255976538.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 13/25] vmstate: add VMS_VARRAY_UINT16_UNSAFE (varrays with uint16 indexes) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org It don't check types. Signed-off-by: Juan Quintela --- hw/hw.h | 13 ++++++++++++- savevm.c | 4 ++++ 2 files changed, 16 insertions(+), 1 deletions(-) diff --git a/hw/hw.h b/hw/hw.h index 5edfff7..eb199fb 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -285,9 +285,10 @@ enum VMStateFlags { VMS_POINTER = 0x002, VMS_ARRAY = 0x004, VMS_STRUCT = 0x008, - VMS_VARRAY_INT32 = 0x010, /* Array with size in another field */ + 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 */ }; typedef struct { @@ -411,6 +412,16 @@ extern const VMStateInfo vmstate_info_buffer; .offset = vmstate_offset_pointer(_state, _field, _type), \ } +#define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_VARRAY_UINT16, \ + .offset = offsetof(_state, _field), \ +} + #define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) { \ .name = (stringify(_field)), \ .version_id = (_version), \ diff --git a/savevm.c b/savevm.c index ccbbae8..f377bfe 100644 --- a/savevm.c +++ b/savevm.c @@ -1086,6 +1086,8 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, n_elems = field->num; } else if (field->flags & VMS_VARRAY_INT32) { n_elems = *(int32_t *)(opaque+field->num_offset); + } else if (field->flags & VMS_VARRAY_UINT16) { + n_elems = *(uint16_t *)(opaque+field->num_offset); } if (field->flags & VMS_POINTER) { base_addr = *(void **)base_addr; @@ -1133,6 +1135,8 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, n_elems = field->num; } else if (field->flags & VMS_VARRAY_INT32) { n_elems = *(int32_t *)(opaque+field->num_offset); + } else if (field->flags & VMS_VARRAY_UINT16) { + n_elems = *(uint16_t *)(opaque+field->num_offset); } if (field->flags & VMS_POINTER) { base_addr = *(void **)base_addr;