From nobody Mon Sep 28 02:07:45 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1785365743; cv=none; d=zohomail.com; s=zohoarc; b=PrpXb9XvcEgFgJmwNf3TWEos8Jm9Wx3YJXNl+9ogCMmHP1MPMb6dG3bfKOrs1z8FoAsDL/RkH+WgwFV0AuNGhEe51+9iABUt/Gt5J5/QY4uQu25JKEh43NgZeNnUDNe9UOz33ahIYFqPSHwoBw+Q7SN1oCsXjxkhPTyUz6u8S2k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785365743; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AnalAhbGBk1bFCW5CpDW9Ri9s61QX63wo/zsXL9qxlM=; b=Thv9xYMEtoLXf7l1wt0xZPi0dD8yJaaSP/W0LrwhuSjKjUHmc0gp4va+XgxRbOcDIBsgauWNYvfqbeyslVz11BMyonKFsA04/oNmkfwWMJwDYPgoU5LepPca8rS7SCZYUGtZd0Yd29GQtBsd7qt8ZqSopQA2k31nj0tlFGpBv0o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178536574318015.143600115477398; Wed, 29 Jul 2026 15:55:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wpDAz-0002Vg-Gb; Wed, 29 Jul 2026 18:55:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wpDAy-0002VH-4l for qemu-devel@nongnu.org; Wed, 29 Jul 2026 18:55:00 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wpDAw-00041N-Ma for qemu-devel@nongnu.org; Wed, 29 Jul 2026 18:54:59 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6B9DB7CD3A; Wed, 29 Jul 2026 22:52:40 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 46915779B1; Wed, 29 Jul 2026 22:52:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id YDM5BjeEamqHFwAAD6G6ig (envelope-from ); Wed, 29 Jul 2026 22:52:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1785365564; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AnalAhbGBk1bFCW5CpDW9Ri9s61QX63wo/zsXL9qxlM=; b=UAg/WmhWM69krslibyXeVv/V6Hp//VqXk9RoV+hetydQZsHYutwrsyrYFJKp+9cy0QPLML PZIyScT8+PwJChr2NGe3HcnrGgGgIdmUh3onnMmVQslfyYKdwcrDjhdNTCIfVsSfG+i6CR WXWRgBITJHfkJ7qOBIyNGMGRVdU50PY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1785365564; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AnalAhbGBk1bFCW5CpDW9Ri9s61QX63wo/zsXL9qxlM=; b=ZyYImMIRI/XRUJxdOXG/4fn9q/r+VJVhSNasMKCUpg+sjgn8urtIWXdww2VoQ0yE8Lhdxz pQpXeFkzlNegIlDQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1785365560; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AnalAhbGBk1bFCW5CpDW9Ri9s61QX63wo/zsXL9qxlM=; b=BXq/RGlkPYa/+HfvLU02k+Vb7AaAUHM/hsZZJ5s8ekTgi0svlKxKnGkGKQjUppN2N6rdc3 tEIS5iejruprcwJPdDILPAX3216i0Vi7G+tPkErGRimvE4j9af39y1MG1TxvP1ywC18iUA 35J/3Y3U0wuIb3QrOIeTto2sKV0xCBg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1785365560; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AnalAhbGBk1bFCW5CpDW9Ri9s61QX63wo/zsXL9qxlM=; b=fu5Kmp/XSukEvJ+PQcYkzEX57azldaHAIQ50tHctZKNUlrhWej4D41RXe8D4FJwpKrxee9 EMI5p7r/uTaYYjAg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , "Michael S . Tsirkin" , Alexandr Moshkov Subject: [PATCH 1/4] migration: Remove VMSTATE_ARRAY_INT32_UNSAFE Date: Wed, 29 Jul 2026 19:52:24 -0300 Message-ID: <20260729225227.1170574-2-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260729225227.1170574-1-farosas@suse.de> References: <20260729225227.1170574-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.985]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email] X-Spam-Score: -2.80 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1785365745903158500 Content-Type: text/plain; charset="utf-8" The ARRAY_INT32_UNSAFE vmstate macro is not used anywhere. Remove it. Signed-off-by: Fabiano Rosas Reviewed-by: Vladimir Sementsov-Ogievskiy --- include/migration/vmstate.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 1b7f295417e..92a1a9fe98e 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -451,15 +451,6 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_sub_array(_state, _field, _type, _start= ), \ } =20 -#define VMSTATE_ARRAY_INT32_UNSAFE(_field, _state, _field_num, _info, _typ= e) {\ - .name =3D (stringify(_field)), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, int32_t), \ - .info =3D &(_info), \ - .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY_INT32, \ - .offset =3D vmstate_offset_varray(_state, _field, _type), \ -} - #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, = _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ --=20 2.53.0 From nobody Mon Sep 28 02:07:45 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1785365743; cv=none; d=zohomail.com; s=zohoarc; b=Pv2v5R4xXYNVI5fWBbGm1loBkX7BjQasM4a9iOrfUaHuwSiBmS+pp5vmoBHCX2ZLFItLmShV+hT+qoyKLbCh8vQZPAzc9M3I6KQ0pznUEWmrR3ze2h9IfUk8otT1LVt2pJZVSVOuN/Khx5EVqPYgM9f5cwTsY21YFesn2z5/wEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785365743; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Y1vMQLBWFnsvxQ6x4iYBi27Z8JurVugHxW5R/zgHrBo=; b=ll+ye4k+YDBNZBdsE5xnZjsinYSTa6wiwtitOwOPH0kHEVHnzCHhdb1wchJ2cThOjGnz1BGB5BMiZnQbKuLkQeA6lgT2IK+iaqWG+BnsTApPIMtFEQeAzG8/JyCpEypRokVHwLydgL5kQsehYH0AlSLJxrcg75sB9lcd4NOiu3s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178536574312455.421579396751326; Wed, 29 Jul 2026 15:55:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wpDB6-0002Z5-7D; Wed, 29 Jul 2026 18:55:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wpDB4-0002XD-9E for qemu-devel@nongnu.org; Wed, 29 Jul 2026 18:55:06 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wpDB1-000425-9J for qemu-devel@nongnu.org; Wed, 29 Jul 2026 18:55:06 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id F035E7CD3C; Wed, 29 Jul 2026 22:52:41 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CA4DB779B3; Wed, 29 Jul 2026 22:52:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id iEtgJjiEamqHFwAAD6G6ig (envelope-from ); Wed, 29 Jul 2026 22:52:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1785365566; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y1vMQLBWFnsvxQ6x4iYBi27Z8JurVugHxW5R/zgHrBo=; b=EpPPFnrEpJ6ZgEnzWudqxpfMFTcbOAPg8BlVCTU2JUgoHjfRIOEHaHr5QhOaqY+3V16x1t qEMJp8Yh5zPP0LX6K/htsv3lTAu83TEO9/+aRN/YwDP8HEhbqJm5UaHamnymRAjvRDBFYf tnjDZCeezhELXJg+5U9HJNcx35L7cPw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1785365566; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y1vMQLBWFnsvxQ6x4iYBi27Z8JurVugHxW5R/zgHrBo=; b=daX2GmGZughcpXVQE/qEl4347/z78muatm5c1VyqRtzbizubs1kRn+WD5TE3BOwy5+GXvn EWHL0vysVaWRg3Dw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1785365562; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y1vMQLBWFnsvxQ6x4iYBi27Z8JurVugHxW5R/zgHrBo=; b=QxvUoViv1v3J56C1yGH3NgrqNxchDoI9yHHMufgh58mKeUZB4De/QHq6oTY/ufIvYwrtcK UPbdTOAJw53kDXiV2tD4ve7ngJeL+FRIU7+aSB+G7YGGqJAs04Cgpnk84/HrZuKw0cGBF6 EQ7DqBLhqWidufXlPZj8v4HF/64Iumc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1785365562; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y1vMQLBWFnsvxQ6x4iYBi27Z8JurVugHxW5R/zgHrBo=; b=VPe3ZYRMv9LfLn7xIjKx4j+zn5/B9RaNlhlpRC6+Y+gqYrzyF52uQ6K2P0iKOpCsc6B3Ck +xChQkGVKF+tLZAA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , "Michael S . Tsirkin" , Alexandr Moshkov Subject: [PATCH 2/4] migration: Introduce VMStateOffset Date: Wed, 29 Jul 2026 19:52:25 -0300 Message-ID: <20260729225227.1170574-3-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260729225227.1170574-1-farosas@suse.de> References: <20260729225227.1170574-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.988]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1785365746099158500 Content-Type: text/plain; charset="utf-8" When migrating a buffer or array, the vmstate code needs to know the size of the buffer and the number of elements of the array. Today a vmstate writer can choose from a number of macros that take as last input the name of a struct member from where the size/num will be read. At load time, the code will access those value via an opaque pointer to the migrated data and therefore it needs to also know the size of the struct member at that offset. Currently that information is communicated by means of the VMS_VARRAY_* and VMS_VBUFFER_* flags, where each possible type is represented by a flag. So far, that's all fine, but since the vmstate code makes heavy use of macros, handling several types individually (i.e. by name: int, int32_t, etc) requires several versions of a same macro, one for each type. E.g: VMSTATE_VBUFFER_ALLOC_UINT32 ^ This creates a pattern where the vmstate writer has to match the macro name to the data type and has resulted in the code having a tendency of having one macro version for each type, for each type of vmstate. There is also some cognitive load to deal with, e.g. VMSTATE_VARRAY_INT32 doesn't hold an array of int32, it holds an array of something else and the number of elements for the array is stored in a variable of type int32. We're now dealing with the scenario where the code has been expecting int32_t at some places, but a uint64_t macro variant has been added without the code being updated. To address all these situations, introduce a new struct that will hold the offset of the struct members, but also their size, so the various extra macros can all be removed and the person writing the vmstate doesn't need to care about type-checking. Still, keep a minimum check that those fields are at least integers and fit into 64 bits. What changes: 1) type checking changes from individual types to a single check for all integers; 2) there are new ways to access the offsets; num_offset -> num_offset.off size_offset -> size_offset.off [new] num_offset.size [new] size_offset.size 2) reading the offsets goes from checking the VMS_VARRAY_* flags in an if/elseif block to comparing offset.size against the hardcoded sizes in bytes; 3) the VMS_VARRAY_* and VMS_VBUFFER_* flags become obsolete. Removed in the next patch; 4) memory usage increases +1 byte per vmstate; Signed-off-by: Fabiano Rosas --- include/migration/vmstate.h | 66 +++++++++++++++++++++++-------------- migration/savevm.c | 4 +-- migration/vmstate.c | 51 ++++++++++++++++++---------- 3 files changed, 76 insertions(+), 45 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 92a1a9fe98e..2ad3cc01371 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -31,6 +31,7 @@ =20 typedef struct VMStateInfo VMStateInfo; typedef struct VMStateField VMStateField; +typedef struct VMStateOffset VMStateOffset; =20 /* * VMStateInfo allows customized migration of objects that don't fit in @@ -187,6 +188,11 @@ typedef enum { MIG_PRI_MAX, } MigrationPriority; =20 +struct VMStateOffset { + uint32_t off; + uint8_t size; +}; + struct VMStateField { const char *name; size_t offset; @@ -205,11 +211,11 @@ struct VMStateField { * pointer point to. */ size_t size; - size_t size_offset; + VMStateOffset size_offset; =20 size_t start; int num; - size_t num_offset; + VMStateOffset num_offset; const VMStateInfo *info; enum VMStateFlags flags; const VMStateDescription *vmsd; @@ -328,6 +334,16 @@ extern const VMStateInfo vmstate_info_g_byte_array; (type_check(t1, typeof_elt_of_field(t2, f)) \ + QEMU_BUILD_BUG_ON_ZERO(!QEMU_IS_ARRAY(((t2 *)0)->f))) =20 +#define type_check_int64(t) \ + (((ptrdiff_t)0 * (ptrdiff_t)(~((t)0))) + \ + (0 * sizeof(char[(sizeof(t) <=3D sizeof(uint64_t)) ? 1 : -1]))) + +#define vmstate_field_offset(_state, _field) { \ + .off =3D (offsetof(_state, _field) + \ + type_check_int64(typeof_field(_state, _field))), \ + .size =3D sizeof(typeof_field(_state, _field)), \ +} + #define vmstate_offset_value(_state, _field, _type) \ (offsetof(_state, _field) + \ type_check(_type, typeof_field(_state, _field))) @@ -454,7 +470,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, = _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, int32_t), \ + .num_offset =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ .flags =3D VMS_VARRAY_INT32|VMS_POINTER, \ @@ -464,7 +480,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info,= _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t),\ + .num_offset =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ .flags =3D VMS_VARRAY_UINT32|VMS_POINTER, \ @@ -474,7 +490,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_VARRAY_INT32_ALLOC(_field, _state, _field_num, _version, _= info, _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, int32_t), \ + .num_offset =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ .flags =3D VMS_VARRAY_INT32 | VMS_POINTER | VMS_ALLOC, \ @@ -484,7 +500,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_VARRAY_UINT32_ALLOC(_field, _state, _field_num, _version, = _info, _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t),\ + .num_offset =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ .flags =3D VMS_VARRAY_UINT32|VMS_POINTER|VMS_ALLOC, \ @@ -494,7 +510,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_VARRAY_UINT16_ALLOC(_field, _state, _field_num, _version, = _info, _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint16_t),\ + .num_offset =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ .flags =3D VMS_VARRAY_UINT16 | VMS_POINTER | VMS_ALLOC, \ @@ -504,7 +520,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version,= _info, _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint16_t),\ + .num_offset =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ .flags =3D VMS_VARRAY_UINT16, \ @@ -583,7 +599,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; _field, _state, _field_num, _version, _vmsd, _type) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint8_t), \ + .num_offset =3D vmstate_field_offset(_state, _field_num), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ .flags =3D VMS_POINTER | VMS_VARRAY_UINT8 | \ @@ -596,7 +612,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; _field, _state, _field_num, _version, _vmsd, _type) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t), \ + .num_offset =3D vmstate_field_offset(_state, _field_num), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ .flags =3D VMS_POINTER | VMS_VARRAY_UINT32 | \ @@ -608,7 +624,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_VARRAY_OF_POINTER_UINT32(_field, _state, _field_num, _vers= ion, _info, _type) { \ .name =3D (stringify(_field)), = \ .version_id =3D (_version), = \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t), = \ + .num_offset =3D vmstate_field_offset(_state, _field_num), = \ .info =3D &(_info), = \ .flags =3D VMS_VARRAY_UINT32 | VMS_ARRAY_OF_POINTER | VMS_POINTER= , \ .offset =3D vmstate_offset_pointer(_state, _field, _type *), = \ @@ -650,7 +666,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; =20 #define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, = _vmsd, _type) { \ .name =3D (stringify(_field)), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint8_t), \ + .num_offset =3D vmstate_field_offset(_state, _field_num), \ .version_id =3D (_version), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ @@ -674,7 +690,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _v= msd, _type) { \ .name =3D (stringify(_field)), \ .version_id =3D 0, \ - .num_offset =3D vmstate_offset_value(_state, _field_num, int32_t), \ + .num_offset =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ .vmsd =3D &(_vmsd), \ .flags =3D VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \ @@ -684,7 +700,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _= vmsd, _type) { \ .name =3D (stringify(_field)), \ .version_id =3D 0, \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t),\ + .num_offset =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ .vmsd =3D &(_vmsd), \ .flags =3D VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \ @@ -694,7 +710,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _= vmsd, _type) { \ .name =3D (stringify(_field)), \ .version_id =3D 0, \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint16_t),\ + .num_offset =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ .vmsd =3D &(_vmsd), \ .flags =3D VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \ @@ -703,7 +719,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; =20 #define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, = _vmsd, _type) { \ .name =3D (stringify(_field)), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, int32_t), \ + .num_offset =3D vmstate_field_offset(_state, _field_num, int32_t), \ .version_id =3D (_version), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ @@ -713,7 +729,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; =20 #define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version,= _vmsd, _type) { \ .name =3D (stringify(_field)), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t), \ + .num_offset =3D vmstate_field_offset(_state, _field_num), \ .version_id =3D (_version), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ @@ -725,7 +741,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .vmsd =3D &(_vmsd), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, int32_t), \ + .num_offset =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ .flags =3D VMS_STRUCT|VMS_VARRAY_INT32|VMS_ALLOC|VMS_POINTER, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ @@ -746,7 +762,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .field_exists =3D (_test), \ - .size_offset =3D vmstate_offset_value(_state, _field_size, uint32_t),\ + .size_offset =3D vmstate_field_offset(_state, _field_size), \ .size =3D (_multiply), \ .info =3D &vmstate_info_buffer, \ .flags =3D VMS_VBUFFER|VMS_POINTER|VMS_MULTIPLY, \ @@ -757,7 +773,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .field_exists =3D (_test), \ - .size_offset =3D vmstate_offset_value(_state, _field_size, int32_t),\ + .size_offset =3D vmstate_field_offset(_state, _field_size), \ .info =3D &vmstate_info_buffer, \ .flags =3D VMS_VBUFFER|VMS_POINTER, \ .offset =3D offsetof(_state, _field), \ @@ -767,7 +783,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .field_exists =3D (_test), \ - .size_offset =3D vmstate_offset_value(_state, _field_size, uint32_t),\ + .size_offset =3D vmstate_field_offset(_state, _field_size), \ .info =3D &vmstate_info_buffer, \ .flags =3D VMS_VBUFFER|VMS_POINTER, \ .offset =3D offsetof(_state, _field), \ @@ -777,7 +793,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .field_exists =3D (_test), \ - .size_offset =3D vmstate_offset_value(_state, _field_size, uint64_t),\ + .size_offset =3D vmstate_field_offset(_state, _field_size), \ .info =3D &vmstate_info_buffer, \ .flags =3D VMS_VBUFFER | VMS_POINTER, \ .offset =3D offsetof(_state, _field), \ @@ -788,7 +804,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .field_exists =3D (_test), \ - .size_offset =3D vmstate_offset_value(_state, _field_size, uint32_t),\ + .size_offset =3D vmstate_field_offset(_state, _field_size), \ .info =3D &vmstate_info_buffer, \ .flags =3D VMS_VBUFFER|VMS_POINTER|VMS_ALLOC, \ .offset =3D offsetof(_state, _field), \ @@ -848,7 +864,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_UNUSED_VARRAY_UINT32(_state, _test, _version, _field_num, = _size) {\ .name =3D "unused", \ .field_exists =3D (_test), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t),\ + .num_offset =3D vmstate_field_offset(_state, _field_num), \ .version_id =3D (_version), \ .size =3D (_size), \ .info =3D &vmstate_info_unused_buffer, \ @@ -862,7 +878,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .name =3D (stringify(_field)), \ .field_exists =3D (_test), \ .version_id =3D (_version), \ - .size_offset =3D vmstate_offset_value(_state, _field_size, int32_t),\ + .size_offset =3D vmstate_field_offset(_state, _field_size), \ .info =3D &vmstate_info_bitmap, \ .flags =3D VMS_VBUFFER|VMS_POINTER, \ .offset =3D offsetof(_state, _field), \ diff --git a/migration/savevm.c b/migration/savevm.c index 34dd06f9f73..a272bcfd0b4 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -873,14 +873,14 @@ static void vmstate_check(const VMStateDescription *v= msd) * Size must be provided because dest QEMU needs that * info to know what to allocate */ - assert(field->size || field->size_offset); + assert(field->size || field->size_offset.size !=3D 0); } else { /* * Otherwise size info isn't useful (because it's * always the size of host pointer), detect accidental * setup of sizes in this case. */ - assert(field->size =3D=3D 0 && field->size_offset =3D= =3D 0); + assert(field->size =3D=3D 0 && field->size_offset.size= =3D=3D 0); } /* * VMS_ARRAY_OF_POINTER must be used only together with one diff --git a/migration/vmstate.c b/migration/vmstate.c index 50ebe378452..0a0b9faa20e 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -78,32 +78,45 @@ vmsd_init_ptr_marker_field(VMStateField *fake, const VM= StateField *field) }; } =20 -static int vmstate_n_elems(void *opaque, const VMStateField *field) +static uint64_t vmstate_read_from_offset(void *opaque, + const VMStateOffset *offset) { - int n_elems =3D 1; + uint8_t *ptr =3D (uint8_t *)opaque + offset->off; + + switch (offset->size) { + case 1: + return *(uint8_t *)ptr; + case 2: + return *(uint16_t *)ptr; + case 4: + return *(uint32_t *)ptr; + case 8: + return *(uint64_t *)ptr; + } + g_assert_not_reached(); +} + +static uint64_t vmstate_n_elems(void *opaque, const VMStateField *field) +{ + uint64_t n_elems =3D 1; =20 if (field->flags & VMS_ARRAY) { n_elems =3D field->num; - } else if (field->flags & VMS_VARRAY_INT32) { - n_elems =3D *(int32_t *)(opaque + field->num_offset); - } else if (field->flags & VMS_VARRAY_UINT32) { - n_elems =3D *(uint32_t *)(opaque + field->num_offset); - } else if (field->flags & VMS_VARRAY_UINT16) { - n_elems =3D *(uint16_t *)(opaque + field->num_offset); - } else if (field->flags & VMS_VARRAY_UINT8) { - n_elems =3D *(uint8_t *)(opaque + field->num_offset); + } else if (field->flags & (VMS_VARRAY_INT32 | VMS_VARRAY_UINT32 + | VMS_VARRAY_UINT16 | VMS_VARRAY_UINT8)) { + n_elems =3D vmstate_read_from_offset(opaque, &field->num_offset); } =20 trace_vmstate_n_elems(field->name, n_elems); return n_elems; } =20 -static int vmstate_size(void *opaque, const VMStateField *field) +static uint64_t vmstate_size(void *opaque, const VMStateField *field) { - int size; + uint64_t size; =20 if (field->flags & VMS_VBUFFER) { - size =3D *(int32_t *)(opaque + field->size_offset); + size =3D vmstate_read_from_offset(opaque, &field->size_offset); if (field->flags & VMS_MULTIPLY) { size *=3D field->size; } @@ -124,7 +137,7 @@ static void vmstate_handle_alloc(void *ptr, const VMSta= teField *field, void *opaque) { if (field->flags & VMS_POINTER && field->flags & VMS_ALLOC) { - gsize size =3D vmstate_size(opaque, field); + uint64_t size =3D vmstate_size(opaque, field); size *=3D vmstate_n_elems(opaque, field); if (size) { *(void **)ptr =3D g_malloc(size); @@ -335,8 +348,9 @@ bool vmstate_load_vmsd(QEMUFile *f, const VMStateDescri= ption *vmsd, =20 if (exists) { void *first_elem =3D opaque + field->offset; - int i, n_elems =3D vmstate_n_elems(opaque, field); - int size =3D vmstate_size(opaque, field); + int i; + uint64_t n_elems =3D vmstate_n_elems(opaque, field); + uint64_t size =3D vmstate_size(opaque, field); =20 vmstate_handle_alloc(first_elem, field, opaque); if (field->flags & VMS_POINTER) { @@ -650,8 +664,9 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMSt= ateDescription *vmsd, while (field->name) { if (vmstate_field_exists(vmsd, field, opaque, version_id)) { void *first_elem =3D opaque + field->offset; - int i, n_elems =3D vmstate_n_elems(opaque, field); - int size =3D vmstate_size(opaque, field); + int i; + uint64_t n_elems =3D vmstate_n_elems(opaque, field); + uint64_t size =3D vmstate_size(opaque, field); JSONWriter *vmdesc_loop =3D vmdesc; bool is_prev_null =3D false; /* --=20 2.53.0 From nobody Mon Sep 28 02:07:45 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1785365746; cv=none; d=zohomail.com; s=zohoarc; b=hkVSEZ+8For45pFSUDfqH5coMVDBP88vbIUaH5KXj6wsYB5Ji34YAUTfdeHMPjLe5qrZiRohjEVEKoQ6Lqmp5SRMILbRtBx8MB1kbW0W56rcwQHcT7incbolvKpFOoJ+iSDl7Cd87nIQUzqT/NXU1vwaESJrJr3NsiwPZy4g4Ww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785365746; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MyklkPx2ViyV3piAWBpC9GUIpLr53m89qDGL4pJzm1I=; b=M0nbMQZPOokG6Ap4ib9OwCprbz3/WVXeVo72RNF5KReac2XS8uz9czEQPbYZFJT26rjatZKK8Z8/9kV1VFLYP8WVz3wYivSuXJlomx0GhHyJXsJwMR24Y74MCS22DBQKln8MlV7j5mbt8TZLNA5RDnhJxxPmk7WaPR6LpUxuxe4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785365746837227.12187363289956; Wed, 29 Jul 2026 15:55:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wpDBE-0002fM-9q; Wed, 29 Jul 2026 18:55:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wpDBC-0002f6-Eu for qemu-devel@nongnu.org; Wed, 29 Jul 2026 18:55:14 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wpDB9-00047v-8x for qemu-devel@nongnu.org; Wed, 29 Jul 2026 18:55:14 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E0E5E7CD3D; Wed, 29 Jul 2026 22:52:43 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 61515779B7; Wed, 29 Jul 2026 22:52:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id wA7UDDqEamqHFwAAD6G6ig (envelope-from ); Wed, 29 Jul 2026 22:52:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1785365568; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MyklkPx2ViyV3piAWBpC9GUIpLr53m89qDGL4pJzm1I=; b=nEGIQ7o0jTZGvkJuzOq2j7NVmqdXMBD4PscOqA6DUMsoDjzX3yyS7nO7CDQa7pE7Pcc2Vr 8Pf9zchbNuBsTnkT/Dyx+BrQ2S6Ael4Xhz7wVUsOlE9xLYzum4HS6CbU7LuJjiTKSpNGf5 L/AYg3G/xNB/j7W8nCDNvNpgUq3QhEA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1785365568; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MyklkPx2ViyV3piAWBpC9GUIpLr53m89qDGL4pJzm1I=; b=KvkLzaMHjUB5BUStd4zAbvgUke1p9qa+odSplX3rj5g4+ig8NSmkfHf3m35btpV2C0mhKz P7pCJ020GSpLb9Aw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1785365563; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MyklkPx2ViyV3piAWBpC9GUIpLr53m89qDGL4pJzm1I=; b=SHOO2WgYN8vqNHCvdrM7IIR5L7CXRB/utFdZlU8933TNKO+mXu1MQ2xNzC3/mdSnyoJlv/ cCl4E6rH3CvWUgeR8cjd/msQgkj3ICmgua6EmRiwozeVtbEal/z9WThMPlg7zo7hlLVaip mEjgbdMGbE8RFFeqw8iFUcesSLy0wHY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1785365563; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MyklkPx2ViyV3piAWBpC9GUIpLr53m89qDGL4pJzm1I=; b=jN9DgeBLDqKqifeBjujds0hJ4up/28MZGh/qg9BkucXU/NWenjnFTf8MYGLIQeV3mg/CAu juhefpGhm5o1QkDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , "Michael S . Tsirkin" , Alexandr Moshkov , Manos Pitsidianakis Subject: [PATCH 3/4] migration: Remove redundant flags Date: Wed, 29 Jul 2026 19:52:26 -0300 Message-ID: <20260729225227.1170574-4-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260729225227.1170574-1-farosas@suse.de> References: <20260729225227.1170574-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.989]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1785365749053158500 Content-Type: text/plain; charset="utf-8" Remove the VMS_VARRAY and VMS_VBUFFER flags that became redundant due to the previous commit which stores the size of the vmstate offset variables along with the offset itself. Signed-off-by: Fabiano Rosas --- include/migration/vmstate.h | 76 ++++++++++++------------------ migration/savevm.c | 6 +-- migration/vmstate.c | 3 +- rust/bindings/migration-sys/lib.rs | 15 ++++-- rust/migration/src/vmstate.rs | 30 ++++++++++-- rust/tests/tests/vmstate_tests.rs | 30 ++++++------ 6 files changed, 83 insertions(+), 77 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 2ad3cc01371..c4fd036344d 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -69,8 +69,9 @@ enum VMStateFlags { * }). Dereference the pointer before using it as basis for * further pointer arithmetic (see e.g. VMS_ARRAY). Does not * affect the meaning of VMStateField.num_offset or - * VMStateField.size_offset; see VMS_VARRAY* and VMS_VBUFFER for - * those. */ + * VMStateField.size_offset; see VMS_VARRAY and VMS_VBUFFER for + * those. + */ VMS_POINTER =3D 0x002, =20 /* The field is an array of fixed size. VMStateField.num contains @@ -80,21 +81,22 @@ enum VMStateFlags { * VMS_MULTIPLY. Each array entry will be processed individually * (VMStateField.info.get()/put() if VMS_STRUCT is not set, * recursion into VMStateField.vmsd if VMS_STRUCT is set). May not - * be combined with VMS_VARRAY*. */ + * be combined with VMS_VARRAY. + */ VMS_ARRAY =3D 0x004, =20 /* The field is itself a struct, containing one or more * fields. Recurse into VMStateField.vmsd. Most useful in - * combination with VMS_ARRAY / VMS_VARRAY*, recursing into each + * combination with VMS_ARRAY / VMS_VARRAY, recursing into each * array entry. */ VMS_STRUCT =3D 0x008, =20 /* The field is an array of variable size. The int32_t at opaque + * VMStateField.num_offset contains the number of entries in the * array. See the VMS_ARRAY description regarding array handling - * in general. May not be combined with VMS_ARRAY or any other - * VMS_VARRAY*. */ - VMS_VARRAY_INT32 =3D 0x010, + * in general. May not be combined with VMS_ARRAY. + */ + VMS_VARRAY =3D 0x010, =20 /* Ignored */ VMS_BUFFER =3D 0x020, @@ -102,18 +104,12 @@ enum VMStateFlags { /* The field is a (fixed-size or variable-size) array of pointers * (e.g. struct a { uint8_t *b[]; }). Dereference each array entry * before using it. Note: Does not imply any one of VMS_ARRAY / - * VMS_VARRAY*; these need to be set explicitly. */ + * VMS_VARRAY; these need to be set explicitly. + */ VMS_ARRAY_OF_POINTER =3D 0x040, =20 - /* The field is an array of variable size. The uint16_t at opaque - * + VMStateField.num_offset - * contains the number of entries in the array. See the VMS_ARRAY - * description regarding array handling in general. May not be - * combined with VMS_ARRAY or any other VMS_VARRAY*. */ - VMS_VARRAY_UINT16 =3D 0x080, - /* The size of the individual entries (a single array entry if - * VMS_ARRAY or any of VMS_VARRAY* are set, or the field itself if + * VMS_ARRAY or VMS_VARRAY are set, or the field itself if * neither is set) is variable (i.e. not known at compile-time), * but the same for all entries. Use the int32_t at opaque + * VMStateField.size_offset (subject to VMS_MULTIPLY) to determine @@ -126,20 +122,6 @@ enum VMStateFlags { * allocated. Only valid in combination with VMS_VBUFFER. */ VMS_MULTIPLY =3D 0x200, =20 - /* The field is an array of variable size. The uint8_t at opaque + - * VMStateField.num_offset - * contains the number of entries in the array. See the VMS_ARRAY - * description regarding array handling in general. May not be - * combined with VMS_ARRAY or any other VMS_VARRAY*. */ - VMS_VARRAY_UINT8 =3D 0x400, - - /* The field is an array of variable size. The uint32_t at opaque - * + VMStateField.num_offset - * contains the number of entries in the array. See the VMS_ARRAY - * description regarding array handling in general. May not be - * combined with VMS_ARRAY or any other VMS_VARRAY*. */ - VMS_VARRAY_UINT32 =3D 0x800, - /* Fail loading the serialised VM state if this field is missing * from the input. */ VMS_MUST_EXIST =3D 0x1000, @@ -473,7 +455,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_offset =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY_INT32|VMS_POINTER, \ + .flags =3D VMS_VARRAY | VMS_POINTER, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -483,7 +465,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_offset =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY_UINT32|VMS_POINTER, \ + .flags =3D VMS_VARRAY | VMS_POINTER, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -493,7 +475,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_offset =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY_INT32 | VMS_POINTER | VMS_ALLOC, \ + .flags =3D VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -503,7 +485,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_offset =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY_UINT32|VMS_POINTER|VMS_ALLOC, \ + .flags =3D VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -513,7 +495,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_offset =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY_UINT16 | VMS_POINTER | VMS_ALLOC, \ + .flags =3D VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -523,7 +505,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_offset =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY_UINT16, \ + .flags =3D VMS_VARRAY, \ .offset =3D vmstate_offset_varray(_state, _field, _type), \ } =20 @@ -602,7 +584,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_offset =3D vmstate_field_offset(_state, _field_num), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ - .flags =3D VMS_POINTER | VMS_VARRAY_UINT8 | \ + .flags =3D VMS_POINTER | VMS_VARRAY | \ VMS_ARRAY_OF_POINTER | VMS_STRUCT | \ VMS_ARRAY_OF_POINTER_AUTO_ALLOC, \ .offset =3D vmstate_offset_pointer(_state, _field, _type *), \ @@ -615,7 +597,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_offset =3D vmstate_field_offset(_state, _field_num), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ - .flags =3D VMS_POINTER | VMS_VARRAY_UINT32 | \ + .flags =3D VMS_POINTER | VMS_VARRAY | \ VMS_ARRAY_OF_POINTER | VMS_STRUCT | \ VMS_ARRAY_OF_POINTER_AUTO_ALLOC, \ .offset =3D vmstate_offset_pointer(_state, _field, _type *), \ @@ -626,7 +608,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .version_id =3D (_version), = \ .num_offset =3D vmstate_field_offset(_state, _field_num), = \ .info =3D &(_info), = \ - .flags =3D VMS_VARRAY_UINT32 | VMS_ARRAY_OF_POINTER | VMS_POINTER= , \ + .flags =3D VMS_VARRAY | VMS_ARRAY_OF_POINTER | VMS_POINTER, = \ .offset =3D vmstate_offset_pointer(_state, _field, _type *), = \ } =20 @@ -670,7 +652,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .version_id =3D (_version), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ - .flags =3D VMS_STRUCT|VMS_VARRAY_UINT8, \ + .flags =3D VMS_STRUCT | VMS_VARRAY, \ .offset =3D vmstate_offset_varray(_state, _field, _type), \ } =20 @@ -693,7 +675,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_offset =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ .vmsd =3D &(_vmsd), \ - .flags =3D VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \ + .flags =3D VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -703,7 +685,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_offset =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ .vmsd =3D &(_vmsd), \ - .flags =3D VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \ + .flags =3D VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -713,7 +695,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_offset =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ .vmsd =3D &(_vmsd), \ - .flags =3D VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \ + .flags =3D VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -723,7 +705,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .version_id =3D (_version), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ - .flags =3D VMS_STRUCT|VMS_VARRAY_INT32, \ + .flags =3D VMS_STRUCT | VMS_VARRAY, \ .offset =3D vmstate_offset_varray(_state, _field, _type), \ } =20 @@ -733,7 +715,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .version_id =3D (_version), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ - .flags =3D VMS_STRUCT|VMS_VARRAY_UINT32, \ + .flags =3D VMS_STRUCT | VMS_VARRAY, \ .offset =3D vmstate_offset_varray(_state, _field, _type), \ } =20 @@ -743,7 +725,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .vmsd =3D &(_vmsd), \ .num_offset =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ - .flags =3D VMS_STRUCT|VMS_VARRAY_INT32|VMS_ALLOC|VMS_POINTER, \ + .flags =3D VMS_STRUCT | VMS_VARRAY | VMS_ALLOC | VMS_POINTER, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -868,7 +850,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .version_id =3D (_version), \ .size =3D (_size), \ .info =3D &vmstate_info_unused_buffer, \ - .flags =3D VMS_VARRAY_UINT32 | VMS_BUFFER, \ + .flags =3D VMS_VARRAY | VMS_BUFFER, \ } =20 /* _field_size should be a int32_t field in the _state struct giving the diff --git a/migration/savevm.c b/migration/savevm.c index a272bcfd0b4..0b4fbfc72bb 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -884,11 +884,9 @@ static void vmstate_check(const VMStateDescription *vm= sd) } /* * VMS_ARRAY_OF_POINTER must be used only together with one - * of VMS_(V)ARRAY* flags. + * of VMS_(V)ARRAY flags. */ - assert(field->flags & (VMS_ARRAY | VMS_VARRAY_INT32 | - VMS_VARRAY_UINT16 | VMS_VARRAY_UINT= 8 | - VMS_VARRAY_UINT32)); + assert(field->flags & (VMS_ARRAY | VMS_VARRAY)); } =20 if (field->flags & VMS_ARRAY_OF_POINTER_AUTO_ALLOC) { diff --git a/migration/vmstate.c b/migration/vmstate.c index 0a0b9faa20e..bc8eb3d3ca6 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -102,8 +102,7 @@ static uint64_t vmstate_n_elems(void *opaque, const VMS= tateField *field) =20 if (field->flags & VMS_ARRAY) { n_elems =3D field->num; - } else if (field->flags & (VMS_VARRAY_INT32 | VMS_VARRAY_UINT32 - | VMS_VARRAY_UINT16 | VMS_VARRAY_UINT8)) { + } else if (field->flags & VMS_VARRAY) { n_elems =3D vmstate_read_from_offset(opaque, &field->num_offset); } =20 diff --git a/rust/bindings/migration-sys/lib.rs b/rust/bindings/migration-s= ys/lib.rs index 9581481e421..75b8c1387c2 100644 --- a/rust/bindings/migration-sys/lib.rs +++ b/rust/bindings/migration-sys/lib.rs @@ -47,6 +47,7 @@ fn default() -> Self { unsafe impl Zeroable for VMStateFlags {} unsafe impl Zeroable for VMStateField {} unsafe impl Zeroable for VMStateDescription {} +unsafe impl Zeroable for VMStateOffset {} =20 // The following higher-level helpers could be in "migration" // crate when Rust has const trait impl. @@ -57,10 +58,7 @@ pub trait VMStateFlagsExt { =20 impl VMStateFlagsExt for VMStateFlags { const VMS_VARRAY_FLAGS: VMStateFlags =3D VMStateFlags( - VMStateFlags::VMS_VARRAY_INT32.0 - | VMStateFlags::VMS_VARRAY_UINT8.0 - | VMStateFlags::VMS_VARRAY_UINT16.0 - | VMStateFlags::VMS_VARRAY_UINT32.0, + VMStateFlags::VMS_VARRAY.0 ); } =20 @@ -115,3 +113,12 @@ pub const fn with_varray_flag(mut self, flag: VMStateF= lags) -> Self { self.with_varray_flag_unchecked(flag) } } + +impl VMStateOffset { + pub const fn new(off: usize, size: usize) -> Self { + Self { + off: off as u32, + size: size as u8, + } + } +} diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs index 63d78b4f275..7023ebd2c22 100644 --- a/rust/migration/src/vmstate.rs +++ b/rust/migration/src/vmstate.rs @@ -42,7 +42,7 @@ }; =20 use crate::bindings::{self, VMStateFlags}; -pub use crate::bindings::{MigrationPriority, VMStateField}; +pub use crate::bindings::{MigrationPriority, VMStateField, VMStateOffset}; =20 /// This macro is used to call a function with a generic argument bound /// to the type of a field. The function must take a @@ -120,6 +120,23 @@ pub const fn vmstate_varray_flag(_: Phanto= mData) -> VMStateFlags T::VARRAY_FLAG } =20 +pub const OPAQUE: &[u8; 1048576] =3D &[0; 1048576]; + +pub const fn size_of_ptr_type(_: *const T) -> usize { + ::core::mem::size_of::() +} + +#[macro_export] +macro_rules! size_of_field_type { + ($struct_name:ty, $($field_name:ident).+) =3D> { + $crate::vmstate::size_of_ptr_type(unsafe { + ::core::ptr::addr_of!( + (*$crate::vmstate::OPAQUE.as_ptr().cast::<$struct_name>())= .$($field_name).+ + ) + }) + }; +} + /// Return the `VMStateField` for a field of a struct. The field must be /// visible in the current scope. /// @@ -148,7 +165,10 @@ macro_rules! vmstate_of { .as_bytes() .as_ptr().cast::<::std::os::raw::c_char>(), offset: ::std::mem::offset_of!($struct_name, $($field_name).+), - $(num_offset: ::std::mem::offset_of!($struct_name, $($num).+),= )? + $(num_offset: $crate::vmstate::VMStateOffset { + off: ::std::mem::offset_of!($struct_name, $($num).+) as u3= 2, + size: $crate::size_of_field_type!($struct_name, $($num).+) as u8, + },)? $(field_exists: $crate::vmstate_exist_fn!($struct_name, $test_= fn),)? // The calls to `call_func_with_field!` are the magic that // computes most of the VMStateField from the type of the fiel= d. @@ -267,9 +287,9 @@ unsafe impl $crate::vmstate::VMState for $type { impl_vmstate_scalar!(vmstate_info_int16, i16); impl_vmstate_scalar!(vmstate_info_int32, i32); impl_vmstate_scalar!(vmstate_info_int64, i64); -impl_vmstate_scalar!(vmstate_info_uint8, u8, VMS_VARRAY_UINT8); -impl_vmstate_scalar!(vmstate_info_uint16, u16, VMS_VARRAY_UINT16); -impl_vmstate_scalar!(vmstate_info_uint32, u32, VMS_VARRAY_UINT32); +impl_vmstate_scalar!(vmstate_info_uint8, u8, VMS_VARRAY); +impl_vmstate_scalar!(vmstate_info_uint16, u16, VMS_VARRAY); +impl_vmstate_scalar!(vmstate_info_uint32, u32, VMS_VARRAY); impl_vmstate_scalar!(vmstate_info_uint64, u64); impl_vmstate_scalar!(vmstate_info_timer, util::timer::Timer); =20 diff --git a/rust/tests/tests/vmstate_tests.rs b/rust/tests/tests/vmstate_t= ests.rs index c2c12cfab52..c5baed4d40b 100644 --- a/rust/tests/tests/vmstate_tests.rs +++ b/rust/tests/tests/vmstate_tests.rs @@ -65,7 +65,7 @@ fn test_vmstate_uint16() { b"elem\0" ); assert_eq!(foo_fields[0].offset, 16); - assert_eq!(foo_fields[0].num_offset, 0); + assert_eq!(foo_fields[0].num_offset.size, 0); assert_eq!(foo_fields[0].info, unsafe { &vmstate_info_int8 }); assert_eq!(foo_fields[0].version_id, 0); assert_eq!(foo_fields[0].size, 1); @@ -86,7 +86,7 @@ fn test_vmstate_unused() { b"unused\0" ); assert_eq!(foo_fields[1].offset, 0); - assert_eq!(foo_fields[1].num_offset, 0); + assert_eq!(foo_fields[1].num_offset.size, 0); assert_eq!(foo_fields[1].info, unsafe { &vmstate_info_unused_buffer }); assert_eq!(foo_fields[1].version_id, 0); assert_eq!(foo_fields[1].size, 8); @@ -108,12 +108,12 @@ fn test_vmstate_varray_uint16_unsafe() { b"arr\0" ); assert_eq!(foo_fields[2].offset, 0); - assert_eq!(foo_fields[2].num_offset, 4); + assert_eq!(foo_fields[2].num_offset.off, 4); assert_eq!(foo_fields[2].info, unsafe { &vmstate_info_uint8 }); assert_eq!(foo_fields[2].version_id, 0); assert_eq!(foo_fields[2].size, 1); assert_eq!(foo_fields[2].num, 0); - assert_eq!(foo_fields[2].flags, VMStateFlags::VMS_VARRAY_UINT16); + assert_eq!(foo_fields[2].flags, VMStateFlags::VMS_VARRAY); assert!(foo_fields[2].vmsd.is_null()); assert!(foo_fields[2].field_exists.is_none()); } @@ -172,7 +172,7 @@ fn test_vmstate_bool_v() { b"val\0" ); assert_eq!(foo_fields[0].offset, 136); - assert_eq!(foo_fields[0].num_offset, 0); + assert_eq!(foo_fields[0].num_offset.size, 0); assert_eq!(foo_fields[0].info, unsafe { &vmstate_info_bool }); assert_eq!(foo_fields[0].version_id, 2); assert_eq!(foo_fields[0].size, 1); @@ -193,7 +193,7 @@ fn test_vmstate_uint64() { b"wrap\0" ); assert_eq!(foo_fields[1].offset, 128); - assert_eq!(foo_fields[1].num_offset, 0); + assert_eq!(foo_fields[1].num_offset.size, 0); assert_eq!(foo_fields[1].info, unsafe { &vmstate_info_uint64 }); assert_eq!(foo_fields[1].version_id, 0); assert_eq!(foo_fields[1].size, 8); @@ -215,14 +215,14 @@ fn test_vmstate_struct_varray_uint8() { b"arr_a\0" ); assert_eq!(foo_fields[2].offset, 0); - assert_eq!(foo_fields[2].num_offset, 60); + assert_eq!(foo_fields[2].num_offset.off, 60); assert!(foo_fields[2].info.is_null()); // VMSTATE_STRUCT_VARRAY_UINT8 = doesn't set info field. assert_eq!(foo_fields[2].version_id, 1); assert_eq!(foo_fields[2].size, 20); assert_eq!(foo_fields[2].num, 0); assert_eq!( foo_fields[2].flags.0, - VMStateFlags::VMS_STRUCT.0 | VMStateFlags::VMS_VARRAY_UINT8.0 + VMStateFlags::VMS_STRUCT.0 | VMStateFlags::VMS_VARRAY.0 ); assert_eq!(foo_fields[2].vmsd, VMSTATE_FOOA.as_ref()); assert!(foo_fields[2].field_exists.is_none()); @@ -240,7 +240,7 @@ fn test_vmstate_macro_array() { b"arr_i64\0" ); assert_eq!(foo_fields[4].offset, 144); - assert_eq!(foo_fields[4].num_offset, 0); + assert_eq!(foo_fields[4].num_offset.size, 0); assert_eq!(foo_fields[4].info, unsafe { &vmstate_info_int64 }); assert_eq!(foo_fields[4].version_id, 0); assert_eq!(foo_fields[4].size, 8); @@ -264,7 +264,7 @@ fn test_vmstate_struct_varray_uint8_wrapper() { unsafe { CStr::from_ptr(foo_fields[5].name) }.to_bytes_with_nul(), b"arr_a_wrap\0" ); - assert_eq!(foo_fields[5].num_offset, 228); + assert_eq!(foo_fields[5].num_offset.off, 228); assert!(unsafe { foo_fields[5].field_exists.unwrap()(foo_b_p, 0) }); =20 // The last VMStateField in VMSTATE_FOOB. @@ -316,7 +316,7 @@ fn test_vmstate_pointer() { b"ptr\0" ); assert_eq!(foo_fields[0].offset, 0); - assert_eq!(foo_fields[0].num_offset, 0); + assert_eq!(foo_fields[0].num_offset.size, 0); assert_eq!(foo_fields[0].info, unsafe { &vmstate_info_int32 }); assert_eq!(foo_fields[0].version_id, 2); assert_eq!(foo_fields[0].size, 4); @@ -341,7 +341,7 @@ fn test_vmstate_struct_pointer() { b"ptr_a\0" ); assert_eq!(foo_fields[1].offset, PTR_SIZE); - assert_eq!(foo_fields[1].num_offset, 0); + assert_eq!(foo_fields[1].num_offset.size, 0); assert_eq!(foo_fields[1].vmsd, VMSTATE_FOOA.as_ref()); assert_eq!(foo_fields[1].version_id, 0); assert_eq!(foo_fields[1].size, size_of::()); @@ -366,7 +366,7 @@ fn test_vmstate_macro_array_of_pointer() { b"arr_ptr\0" ); assert_eq!(foo_fields[2].offset, 2 * PTR_SIZE); - assert_eq!(foo_fields[2].num_offset, 0); + assert_eq!(foo_fields[2].num_offset.size, 0); assert_eq!(foo_fields[2].info, unsafe { &vmstate_info_uint8 }); assert_eq!(foo_fields[2].version_id, 0); assert_eq!(foo_fields[2].size, PTR_SIZE); @@ -391,7 +391,7 @@ fn test_vmstate_macro_array_of_pointer_wrapped() { b"arr_ptr_wrap\0" ); assert_eq!(foo_fields[3].offset, (FOO_ARRAY_MAX + 2) * PTR_SIZE); - assert_eq!(foo_fields[3].num_offset, 0); + assert_eq!(foo_fields[3].num_offset.size, 0); assert_eq!(foo_fields[3].info, unsafe { &vmstate_info_uint8 }); assert_eq!(foo_fields[3].version_id, 0); assert_eq!(foo_fields[3].size, PTR_SIZE); @@ -454,7 +454,7 @@ fn test_vmstate_validate() { b"foo_d_0\0" ); assert_eq!(foo_fields[0].offset, 0); - assert_eq!(foo_fields[0].num_offset, 0); + assert_eq!(foo_fields[0].num_offset.size, 0); assert!(foo_fields[0].info.is_null()); assert_eq!(foo_fields[0].version_id, 0); assert_eq!(foo_fields[0].size, 0); --=20 2.53.0 From nobody Mon Sep 28 02:07:45 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1785365743; cv=none; d=zohomail.com; s=zohoarc; b=LhGuqAnHLWMLnW+TC64kddqeznvFJ2QcBVnTB6+Xb0DHsDbTbo1ASeNRciyrw9Fl81GSUJ4vnSFIWZxwwZx1CThQPwYqclUsE+g9OFLyJSKgMvzvm9SN84m/pZAzzJ80cv/2go1ho5Hgh/mwDEBvmoney7fWP6ymLWkI8ybDaF8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785365743; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sdtdeNXBikH2S9GAny8nlHj8GAbM/kbRKfPkOJJo0SA=; b=Ty/v/iTxhzY07qxqLIVhTq3l/mpQlqGe6UF/3lVkVGCDSrswcGEXbxvDaxqVspHN6GvY9io84HbFqUFzrHRyAeBfHwGBi8feYW9m1o1wgCbM2eSMNKidT4F0t16Mv0bsP8es3lGG8i4CRVI46wS1ka74mg9VuEcetQ8MJhYEV1E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17853657434011013.8909554354287; Wed, 29 Jul 2026 15:55:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wpDAx-0002V3-SO; Wed, 29 Jul 2026 18:54:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wpDAw-0002Uu-5B for qemu-devel@nongnu.org; Wed, 29 Jul 2026 18:54:58 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wpDAt-0003uB-SF for qemu-devel@nongnu.org; Wed, 29 Jul 2026 18:54:57 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6B6733E01; Wed, 29 Jul 2026 22:52:45 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 467FC779B9; Wed, 29 Jul 2026 22:52:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 2NgvBjyEamqHFwAAD6G6ig (envelope-from ); Wed, 29 Jul 2026 22:52:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1785365569; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sdtdeNXBikH2S9GAny8nlHj8GAbM/kbRKfPkOJJo0SA=; b=IFkJ0/jX0zEfedS66mbBT9sKZK2IoD4takZJFx1zvCsIBdio458jPdQ7bAAiLf46dizDDS d50961nB5KDvBNFmJf8Qx4PzlzV3R+03tu9GB6KTQHQ0rUSPFLYO6ZVrmPxB54o+rMdFQu +dOdkSjVSSxWxqAjC+xCxrEalbJJ5lg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1785365569; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sdtdeNXBikH2S9GAny8nlHj8GAbM/kbRKfPkOJJo0SA=; b=tE5bobGl03zl/c7B6x9YgGlSPvF3d00RMgFrGRUdfY7ODyAQSX8L7WEPT8nBTS79pbfwyl p5IKKAuFroQci+Cw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1785365565; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sdtdeNXBikH2S9GAny8nlHj8GAbM/kbRKfPkOJJo0SA=; b=xY3RAjfISEkhDkMldsk4J5QuGsPoJZsmy0Ar9ypf9s7UJ3yTFVdUrpWJnKLMVn6Sojviih LwwwLuew60a268asAXBBxjncjF9XjTk1KP+5WPgXdgeasF0nCFjlFAL6/4mOlWb2Enm9Db WVpb309VglLVedjAmMqxUnj7+Z9EQ+w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1785365565; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sdtdeNXBikH2S9GAny8nlHj8GAbM/kbRKfPkOJJo0SA=; b=8HFPfVR4HqH1lVTjCIcJ4be+Zpzx+zEU+Jl50pSA1edVzfefA4uG7xcXkkZfkDCVtYrV1H S7bKboSfjgh/myDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , "Michael S . Tsirkin" , Alexandr Moshkov Subject: [PATCH 4/4] migration: Remove duplicate vmstate macros Date: Wed, 29 Jul 2026 19:52:27 -0300 Message-ID: <20260729225227.1170574-5-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260729225227.1170574-1-farosas@suse.de> References: <20260729225227.1170574-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.987]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid]; RCVD_TLS_ALL(0.00)[] Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1785365746019158500 Content-Type: text/plain; charset="utf-8" Now that type-checking is not being done per integer size anymore, various macros have duplicated bodies. Remove them. The original names are left the same so the device code can be altered per-subsystem in the next patches. Signed-off-by: Fabiano Rosas --- include/migration/vmstate.h | 136 ++++++++++-------------------------- 1 file changed, 36 insertions(+), 100 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index c4fd036344d..24631fd6782 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -449,7 +449,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_sub_array(_state, _field, _type, _start= ), \ } =20 -#define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, = _type) {\ +#define VMSTATE_VARRAY(_field, _state, _field_num, _version, _info, _type)= {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .num_offset =3D vmstate_field_offset(_state, _field_num), \ @@ -459,17 +459,10 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 -#define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info,= _type) {\ - .name =3D (stringify(_field)), \ - .version_id =3D (_version), \ - .num_offset =3D vmstate_field_offset(_state, _field_num), \ - .info =3D &(_info), \ - .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY | VMS_POINTER, \ - .offset =3D vmstate_offset_pointer(_state, _field, _type), \ -} +#define VMSTATE_VARRAY_INT32 VMSTATE_VARRAY +#define VMSTATE_VARRAY_UINT32 VMSTATE_VARRAY =20 -#define VMSTATE_VARRAY_INT32_ALLOC(_field, _state, _field_num, _version, _= info, _type) {\ +#define VMSTATE_VARRAY_ALLOC(_field, _state, _field_num, _version, _info, = _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .num_offset =3D vmstate_field_offset(_state, _field_num), \ @@ -479,27 +472,11 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 -#define VMSTATE_VARRAY_UINT32_ALLOC(_field, _state, _field_num, _version, = _info, _type) {\ - .name =3D (stringify(_field)), \ - .version_id =3D (_version), \ - .num_offset =3D vmstate_field_offset(_state, _field_num), \ - .info =3D &(_info), \ - .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \ - .offset =3D vmstate_offset_pointer(_state, _field, _type), \ -} - -#define VMSTATE_VARRAY_UINT16_ALLOC(_field, _state, _field_num, _version, = _info, _type) {\ - .name =3D (stringify(_field)), \ - .version_id =3D (_version), \ - .num_offset =3D vmstate_field_offset(_state, _field_num), \ - .info =3D &(_info), \ - .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \ - .offset =3D vmstate_offset_pointer(_state, _field, _type), \ -} +#define VMSTATE_VARRAY_INT32_ALLOC VMSTATE_VARRAY_ALLOC +#define VMSTATE_VARRAY_UINT32_ALLOC VMSTATE_VARRAY_ALLOC +#define VMSTATE_VARRAY_UINT16_ALLOC VMSTATE_VARRAY_ALLOC =20 -#define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version,= _info, _type) {\ +#define VMSTATE_VARRAY_UNSAFE(_field, _state, _field_num, _version, _info,= _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .num_offset =3D vmstate_field_offset(_state, _field_num), \ @@ -509,6 +486,8 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_varray(_state, _field, _type), \ } =20 +#define VMSTATE_VARRAY_UINT16_UNSAFE VMSTATE_VARRAY_UNSAFE + #define VMSTATE_VSTRUCT_TEST(_field, _state, _test, _version, _vmsd, _type= , _struct_version) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ @@ -577,7 +556,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; * _info: VMStateInfo for _type (when VMS_STRUCT is not set) * start: size of (_type) pointed to (for auto memory allocation) */ -#define VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT8_ALLOC(\ +#define VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_ALLOC( \ _field, _state, _field_num, _version, _vmsd, _type) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ @@ -590,20 +569,12 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_pointer(_state, _field, _type *), \ } =20 -#define VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT32_ALLOC(\ - _field, _state, _field_num, _version, _vmsd, _type) { \ - .name =3D (stringify(_field)), \ - .version_id =3D (_version), \ - .num_offset =3D vmstate_field_offset(_state, _field_num), \ - .vmsd =3D &(_vmsd), \ - .size =3D sizeof(_type), \ - .flags =3D VMS_POINTER | VMS_VARRAY | \ - VMS_ARRAY_OF_POINTER | VMS_STRUCT | \ - VMS_ARRAY_OF_POINTER_AUTO_ALLOC, \ - .offset =3D vmstate_offset_pointer(_state, _field, _type *), \ -} +#define VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT8_ALLOC \ + VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_ALLOC +#define VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT32_ALLOC \ + VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_ALLOC =20 -#define VMSTATE_VARRAY_OF_POINTER_UINT32(_field, _state, _field_num, _vers= ion, _info, _type) { \ +#define VMSTATE_VARRAY_OF_POINTER(_field, _state, _field_num, _version, _i= nfo, _type) { \ .name =3D (stringify(_field)), = \ .version_id =3D (_version), = \ .num_offset =3D vmstate_field_offset(_state, _field_num), = \ @@ -612,6 +583,8 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_pointer(_state, _field, _type *), = \ } =20 +#define VMSTATE_VARRAY_OF_POINTER_UINT32 VMSTATE_VARRAY_OF_POINTER + #define VMSTATE_STRUCT_SUB_ARRAY(_field, _state, _start, _num, _version, _= vmsd, _type) { \ .name =3D (stringify(_field)), = \ .version_id =3D (_version), = \ @@ -646,7 +619,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; _n1, _n2), \ } =20 -#define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, = _vmsd, _type) { \ +#define VMSTATE_STRUCT_VARRAY(_field, _state, _field_num, _version, _vmsd,= _type) { \ .name =3D (stringify(_field)), \ .num_offset =3D vmstate_field_offset(_state, _field_num), \ .version_id =3D (_version), \ @@ -655,6 +628,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .flags =3D VMS_STRUCT | VMS_VARRAY, \ .offset =3D vmstate_offset_varray(_state, _field, _type), \ } +#define VMSTATE_STRUCT_VARRAY_UINT8 VMSTATE_STRUCT_VARRAY =20 /* a variable length array (i.e. _type *_field) but we know the * length @@ -669,7 +643,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D offsetof(_state, _field), \ } =20 -#define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _v= msd, _type) { \ +#define VMSTATE_STRUCT_VARRAY_POINTER(_field, _state, _field_num, _vmsd, _= type) { \ .name =3D (stringify(_field)), \ .version_id =3D 0, \ .num_offset =3D vmstate_field_offset(_state, _field_num), \ @@ -678,38 +652,11 @@ extern const VMStateInfo vmstate_info_g_byte_array; .flags =3D VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } +#define VMSTATE_STRUCT_VARRAY_POINTER_INT32 VMSTATE_STRUCT_VARRAY_POINTER +#define VMSTATE_STRUCT_VARRAY_POINTER_UINT32 VMSTATE_STRUCT_VARRAY_POINTER +#define VMSTATE_STRUCT_VARRAY_POINTER_UINT16 VMSTATE_STRUCT_VARRAY_POINTER =20 -#define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _= vmsd, _type) { \ - .name =3D (stringify(_field)), \ - .version_id =3D 0, \ - .num_offset =3D vmstate_field_offset(_state, _field_num), \ - .size =3D sizeof(_type), \ - .vmsd =3D &(_vmsd), \ - .flags =3D VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \ - .offset =3D vmstate_offset_pointer(_state, _field, _type), \ -} - -#define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _= vmsd, _type) { \ - .name =3D (stringify(_field)), \ - .version_id =3D 0, \ - .num_offset =3D vmstate_field_offset(_state, _field_num), \ - .size =3D sizeof(_type), \ - .vmsd =3D &(_vmsd), \ - .flags =3D VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \ - .offset =3D vmstate_offset_pointer(_state, _field, _type), \ -} - -#define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, = _vmsd, _type) { \ - .name =3D (stringify(_field)), \ - .num_offset =3D vmstate_field_offset(_state, _field_num, int32_t), \ - .version_id =3D (_version), \ - .vmsd =3D &(_vmsd), \ - .size =3D sizeof(_type), \ - .flags =3D VMS_STRUCT | VMS_VARRAY, \ - .offset =3D vmstate_offset_varray(_state, _field, _type), \ -} - -#define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version,= _vmsd, _type) { \ +#define VMSTATE_STRUCT_VARRAY(_field, _state, _field_num, _version, _vmsd,= _type) { \ .name =3D (stringify(_field)), \ .num_offset =3D vmstate_field_offset(_state, _field_num), \ .version_id =3D (_version), \ @@ -718,6 +665,8 @@ extern const VMStateInfo vmstate_info_g_byte_array; .flags =3D VMS_STRUCT | VMS_VARRAY, \ .offset =3D vmstate_offset_varray(_state, _field, _type), \ } +#define VMSTATE_STRUCT_VARRAY_INT32 VMSTATE_STRUCT_VARRAY +#define VMSTATE_STRUCT_VARRAY_UINT32 VMSTATE_STRUCT_VARRAY =20 #define VMSTATE_STRUCT_VARRAY_ALLOC(_field, _state, _field_num, _version, = _vmsd, _type) {\ .name =3D (stringify(_field)), \ @@ -761,28 +710,11 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D offsetof(_state, _field), \ } =20 -#define VMSTATE_VBUFFER_UINT32(_field, _state, _version, _test, _field_siz= e) { \ - .name =3D (stringify(_field)), \ - .version_id =3D (_version), \ - .field_exists =3D (_test), \ - .size_offset =3D vmstate_field_offset(_state, _field_size), \ - .info =3D &vmstate_info_buffer, \ - .flags =3D VMS_VBUFFER|VMS_POINTER, \ - .offset =3D offsetof(_state, _field), \ -} +#define VMSTATE_VBUFFER_UINT32 VMSTATE_VBUFFER +#define VMSTATE_VBUFFER_UINT64 VMSTATE_VBUFFER =20 -#define VMSTATE_VBUFFER_UINT64(_field, _state, _version, _test, _field_siz= e) { \ - .name =3D (stringify(_field)), \ - .version_id =3D (_version), \ - .field_exists =3D (_test), \ - .size_offset =3D vmstate_field_offset(_state, _field_size), \ - .info =3D &vmstate_info_buffer, \ - .flags =3D VMS_VBUFFER | VMS_POINTER, \ - .offset =3D offsetof(_state, _field), \ -} - -#define VMSTATE_VBUFFER_ALLOC_UINT32(_field, _state, _version, \ - _test, _field_size) { \ +#define VMSTATE_VBUFFER_ALLOC(_field, _state, _version, \ + _test, _field_size) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .field_exists =3D (_test), \ @@ -792,6 +724,8 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D offsetof(_state, _field), \ } =20 +#define VMSTATE_VBUFFER_ALLOC_UINT32 VMSTATE_VBUFFER_ALLOC + #define VMSTATE_BUFFER_UNSAFE_INFO_TEST(_field, _state, _test, _version, _= info, _size) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ @@ -843,7 +777,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; } =20 /* Discard size * field_num bytes, where field_num is a uint32 member */ -#define VMSTATE_UNUSED_VARRAY_UINT32(_state, _test, _version, _field_num, = _size) {\ +#define VMSTATE_UNUSED_VARRAY(_state, _test, _version, _field_num, _size) = {\ .name =3D "unused", \ .field_exists =3D (_test), \ .num_offset =3D vmstate_field_offset(_state, _field_num), \ @@ -853,6 +787,8 @@ extern const VMStateInfo vmstate_info_g_byte_array; .flags =3D VMS_VARRAY | VMS_BUFFER, \ } =20 +#define VMSTATE_UNUSED_VARRAY_UINT32 VMSTATE_UNUSED_VARRAY + /* _field_size should be a int32_t field in the _state struct giving the * size of the bitmap _field in bits. */ --=20 2.53.0