From patchwork Mon Apr 21 14:40:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 341146 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3E7291400DF for ; Tue, 22 Apr 2014 13:22:13 +1000 (EST) Received: from localhost ([::1]:49348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcFfu-0002b7-Nc for incoming@patchwork.ozlabs.org; Mon, 21 Apr 2014 10:58:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcFQq-0004SP-M0 for qemu-devel@nongnu.org; Mon, 21 Apr 2014 10:42:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WcFQk-00044e-7p for qemu-devel@nongnu.org; Mon, 21 Apr 2014 10:42:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51209) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcFQj-00044Y-UB for qemu-devel@nongnu.org; Mon, 21 Apr 2014 10:42:46 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3LEgioE005196 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 21 Apr 2014 10:42:45 -0400 Received: from trasno.mitica (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3LEfi6m019220; Mon, 21 Apr 2014 10:42:43 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 21 Apr 2014 16:40:22 +0200 Message-Id: <1398091304-10677-43-git-send-email-quintela@redhat.com> In-Reply-To: <1398091304-10677-1-git-send-email-quintela@redhat.com> References: <1398091304-10677-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 042/124] vmstate: Test for VMSTATE_INT32_ARRAY{_TEST} X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Change only user of _V to _TEST. Signed-off-by: Juan Quintela --- hw/pci-host/piix.c | 4 ++-- include/migration/vmstate.h | 12 ++++++------ tests/test-vmstate.c | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index e0e0946..a6c6834 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -567,8 +567,8 @@ static const VMStateDescription vmstate_piix3 = { .pre_save = piix3_pre_save, .fields = (VMStateField[]) { VMSTATE_PCI_DEVICE(dev, PIIX3State), - VMSTATE_INT32_ARRAY_V(pci_irq_levels_vmstate, PIIX3State, - PIIX_NUM_PIRQS, 3), + VMSTATE_INT32_ARRAY_TEST(pci_irq_levels_vmstate, PIIX3State, + PIIX_NUM_PIRQS, vmstate_3_plus), VMSTATE_END_OF_LIST() }, .subsections = (VMStateSubsection[]) { diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index db8f295..49446a8 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -627,6 +627,12 @@ extern const VMStateInfo vmstate_info_bitmap; #define VMSTATE_INT16_ARRAY(_f, _s, _n) \ VMSTATE_ARRAY_TEST(_f, _s, _n, NULL, vmstate_info_int16, int16_t) +#define VMSTATE_INT32_ARRAY_TEST(_f, _s, _n, _t) \ + VMSTATE_ARRAY_TEST(_f, _s, _n, _t, vmstate_info_int32, int32_t) + +#define VMSTATE_INT32_ARRAY(_f, _s, _n) \ + VMSTATE_INT32_ARRAY_TEST(_f, _s, _n, NULL) + #define VMSTATE_UINT16_2DARRAY_V(_f, _s, _n1, _n2, _v) \ VMSTATE_2DARRAY(_f, _s, _n1, _n2, _v, vmstate_info_uint16, uint16_t) @@ -648,12 +654,6 @@ extern const VMStateInfo vmstate_info_bitmap; #define VMSTATE_UINT32_2DARRAY(_f, _s, _n1, _n2) \ VMSTATE_UINT32_2DARRAY_V(_f, _s, _n1, _n2, 0) -#define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t) - -#define VMSTATE_INT32_ARRAY(_f, _s, _n) \ - VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0) - #define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \ VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t) diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index c31d85f..d7f2223 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -520,6 +520,8 @@ typedef struct TestArray { uint64_t u64_1[VMSTATE_ARRAY_SIZE]; uint64_t u64_2[VMSTATE_ARRAY_SIZE]; int16_t i16_1[VMSTATE_ARRAY_SIZE]; + int32_t i32_1[VMSTATE_ARRAY_SIZE]; + int32_t i32_2[VMSTATE_ARRAY_SIZE]; } TestArray; TestArray obj_array = { @@ -534,6 +536,8 @@ TestArray obj_array = { .u64_1 = {31, 32, 33, 34, 35}, .u64_2 = {35, 34, 33, 32, 31}, .i16_1 = {41, 42, 43, 44, 45}, + .i32_1 = {51, 52, 53, 54, 55}, + .i32_2 = {55, 54, 53, 52, 51}, }; static const VMStateDescription vmstate_array_primitive = { @@ -549,6 +553,7 @@ static const VMStateDescription vmstate_array_primitive = { VMSTATE_UINT32_ARRAY(u32_1, TestArray, VMSTATE_ARRAY_SIZE), VMSTATE_UINT64_ARRAY(u64_1, TestArray, VMSTATE_ARRAY_SIZE), VMSTATE_INT16_ARRAY(i16_1, TestArray, VMSTATE_ARRAY_SIZE), + VMSTATE_INT32_ARRAY(i32_1, TestArray, VMSTATE_ARRAY_SIZE), VMSTATE_END_OF_LIST() } }; @@ -567,6 +572,9 @@ uint8_t wire_array_primitive[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, /* i16_1 */ 0x00, 0x29, 0x00, 0x2a, 0x00, 0x2b, 0x00, 0x2c, 0x00, 0x2d, + /* i32_1 */ 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x34, + 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x36, + 0x00, 0x00, 0x00, 0x37, QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */ }; @@ -589,6 +597,8 @@ static void obj_array_copy(void *arg1, void *arg2) target->u64_1[i] = source->u64_1[i]; target->u64_2[i] = source->u64_2[i]; target->i16_1[i] = source->i16_1[i]; + target->i32_1[i] = source->i32_1[i]; + target->i32_2[i] = source->i32_2[i]; } } @@ -623,6 +633,7 @@ static void test_array_primitive(void) ELEM_EQUAL(u32_1, i); ELEM_EQUAL(u64_1, i); ELEM_EQUAL(i16_1, i); + ELEM_EQUAL(i32_1, i); } } @@ -643,6 +654,10 @@ static const VMStateDescription vmstate_array_test = { test_true), VMSTATE_UINT64_ARRAY_TEST(u64_2, TestArray, VMSTATE_ARRAY_SIZE, test_false), + VMSTATE_INT32_ARRAY_TEST(i32_1, TestArray, VMSTATE_ARRAY_SIZE, + test_true), + VMSTATE_INT32_ARRAY_TEST(i32_2, TestArray, VMSTATE_ARRAY_SIZE, + test_false), VMSTATE_END_OF_LIST() } }; @@ -658,6 +673,9 @@ uint8_t wire_array_test[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, + /* i32_1 */ 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x34, + 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x36, + 0x00, 0x00, 0x00, 0x37, QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */ }; @@ -684,6 +702,8 @@ static void test_array_test(void) ELEM_NOT_EQUAL(u32_2, i); ELEM_EQUAL(u64_1, i); ELEM_NOT_EQUAL(u64_2, i); + ELEM_EQUAL(i32_1, i); + ELEM_NOT_EQUAL(i32_2, i); } } #undef FIELD_EQUAL