From patchwork Tue Sep 29 20:48:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 34475 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 C0E07B7C04 for ; Wed, 30 Sep 2009 07:37:44 +1000 (EST) Received: from localhost ([127.0.0.1]:49431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MskOD-0000m2-QV for incoming@patchwork.ozlabs.org; Tue, 29 Sep 2009 17:37:41 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Msjdy-0005Gh-El for qemu-devel@nongnu.org; Tue, 29 Sep 2009 16:49:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Msjdt-00059Z-6L for qemu-devel@nongnu.org; Tue, 29 Sep 2009 16:49:52 -0400 Received: from [199.232.76.173] (port=55227 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Msjds-00059H-PS for qemu-devel@nongnu.org; Tue, 29 Sep 2009 16:49:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63513) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Msjdr-0002W7-NL for qemu-devel@nongnu.org; Tue, 29 Sep 2009 16:49:48 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8TKnkJA030703 for ; Tue, 29 Sep 2009 16:49:47 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8TKnHXv006885; Tue, 29 Sep 2009 16:49:46 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 29 Sep 2009 22:48:41 +0200 Message-Id: <8ba6f0a7748cfe29bdc92d6f3ef19ca745f51613.1254255997.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 22/49] vmstate: add support for arrays of pointers 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 We need this to send arrays of timers Signed-off-by: Juan Quintela --- hw/hw.h | 15 +++++++++++++++ savevm.c | 3 +++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/hw/hw.h b/hw/hw.h index c33d8d1..6f4d9eb 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -286,6 +286,7 @@ enum VMStateFlags { VMS_STRUCT = 0x008, VMS_VARRAY = 0x010, /* Array with size in another field */ VMS_BUFFER = 0x020, /* static sized buffer */ + VMS_ARRAY_OF_POINTER = 0x040, }; typedef struct { @@ -396,6 +397,17 @@ extern const VMStateInfo vmstate_info_buffer; + type_check(_type,typeof_field(_state, _field)) \ } +#define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .num = (_num), \ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \ + .offset = offsetof(_state, _field) \ + + type_check_array(_type,typeof_field(_state, _field),_num) \ +} + #define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) { \ .name = (stringify(_field)), \ .num = (_num), \ @@ -518,6 +530,9 @@ extern const VMStateDescription vmstate_i2c_slave; #define VMSTATE_TIMER(_f, _s) \ VMSTATE_TIMER_V(_f, _s, 0) +#define VMSTATE_TIMER_ARRAY(_f, _s, _n) \ + VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *) + #define VMSTATE_PTIMER_V(_f, _s, _v) \ VMSTATE_POINTER(_f, _s, _v, vmstate_info_ptimer, ptimer_state *) diff --git a/savevm.c b/savevm.c index fefde7c..11b331b 100644 --- a/savevm.c +++ b/savevm.c @@ -1070,6 +1070,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, for (i = 0; i < n_elems; i++) { void *addr = base_addr + field->size * i; + if (field->flags & VMS_ARRAY_OF_POINTER) { + addr = *(void **)addr; + } if (field->flags & VMS_STRUCT) { ret = vmstate_load_state(f, field->vmsd, addr, field->vmsd->version_id); } else {