From patchwork Fri Jul 3 11:28:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 491012 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 16CCD140775 for ; Fri, 3 Jul 2015 21:36:52 +1000 (AEST) Received: from localhost ([::1]:40486 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAzH0-0001of-3i for incoming@patchwork.ozlabs.org; Fri, 03 Jul 2015 07:36:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAzFb-0000VZ-Sx for qemu-devel@nongnu.org; Fri, 03 Jul 2015 07:35:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAzAG-00085w-7d for qemu-devel@nongnu.org; Fri, 03 Jul 2015 07:29:56 -0400 Received: from e23smtp02.au.ibm.com ([202.81.31.144]:58544) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAzAF-00081A-LK for qemu-devel@nongnu.org; Fri, 03 Jul 2015 07:29:52 -0400 Received: from /spool/local by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 3 Jul 2015 21:29:48 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp02.au.ibm.com (202.81.31.208) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 3 Jul 2015 21:29:46 +1000 X-Helo: d23dlp01.au.ibm.com X-MailFrom: aik@ozlabs.ru X-RcptTo: qemu-ppc@nongnu.org Received: from d23relay08.au.ibm.com (d23relay08.au.ibm.com [9.185.71.33]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 726472CE8052; Fri, 3 Jul 2015 21:29:44 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t63BTWEi55443478; Fri, 3 Jul 2015 21:29:42 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t63BT9dx020155; Fri, 3 Jul 2015 21:29:10 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t63BT9b3019546; Fri, 3 Jul 2015 21:29:09 +1000 Received: from bran.ozlabs.ibm.com (unknown [9.192.254.114]) by ozlabs.au.ibm.com (Postfix) with ESMTP id 897DFA0375; Fri, 3 Jul 2015 21:28:45 +1000 (AEST) Received: from ka1.ozlabs.ibm.com (ka1.ozlabs.ibm.com [10.61.145.11]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id 79B8DE38DF; Fri, 3 Jul 2015 21:28:45 +1000 (AEST) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Fri, 3 Jul 2015 21:28:31 +1000 Message-Id: <1435922923-10731-2-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 2.4.0.rc3.8.gfb3e7d5 In-Reply-To: <1435922923-10731-1-git-send-email-aik@ozlabs.ru> References: <1435922923-10731-1-git-send-email-aik@ozlabs.ru> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15070311-0005-0000-0000-00000208BAFF X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 202.81.31.144 Cc: Alexey Kardashevskiy , Alexander Graf , Gavin Shan , Alex Williamson , qemu-ppc@nongnu.org, David Gibson Subject: [Qemu-devel] [PATCH qemu v9 01/13] vmstate: Define VARRAY with VMS_ALLOC 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 This allows dynamic allocation for migrating arrays. Already existing VMSTATE_VARRAY_UINT32 requires an array to be pre-allocated, however there are cases when the size is not known in advance and there is no real need to enforce it. This defines another variant of VMSTATE_VARRAY_UINT32 with WMS_ALLOC flag which tells the receiving side to allocate memory for the array before receiving the data. The first user of it is a dynamic DMA window which existence and size are totally dynamic. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson --- include/migration/vmstate.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 0695d7c..5881d9f 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -295,6 +295,16 @@ extern const VMStateInfo vmstate_info_bitmap; .offset = vmstate_offset_pointer(_state, _field, _type), \ } +#define VMSTATE_VARRAY_UINT32_ALLOC(_field, _state, _field_num, _version, _info, _type) {\ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_VARRAY_UINT32|VMS_POINTER|VMS_ALLOC, \ + .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), \