{"id":2215591,"url":"http://patchwork.ozlabs.org/api/patches/2215591/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260324194333.30004-14-farosas@suse.de/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260324194333.30004-14-farosas@suse.de>","list_archive_url":null,"date":"2026-03-24T19:43:28","name":"[RFC,v1,13/17] vmstate: Drop VMS_ARRAY_OF_POINTER_AUTO_ALLOC","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"7142292033fc0801e45b438ac14c2f40e272794a","submitter":{"id":85343,"url":"http://patchwork.ozlabs.org/api/people/85343/?format=json","name":"Fabiano Rosas","email":"farosas@suse.de"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260324194333.30004-14-farosas@suse.de/mbox/","series":[{"id":497339,"url":"http://patchwork.ozlabs.org/api/series/497339/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=497339","date":"2026-03-24T19:43:16","name":"migration: vmstate_save|load changes for peterx","version":1,"mbox":"http://patchwork.ozlabs.org/series/497339/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2215591/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2215591/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256\n header.s=susede2_rsa header.b=SG+MIn1u;\n\tdkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=nlPayM8p;\n\tdkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de\n header.a=rsa-sha256 header.s=susede2_rsa header.b=SG+MIn1u;\n\tdkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=nlPayM8p;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)","smtp-out1.suse.de;\n\tnone"],"Received":["from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fgL8d554mz1yG1\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 06:44:33 +1100 (AEDT)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1w57ft-0003R7-LF; Tue, 24 Mar 2026 15:44:25 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <farosas@suse.de>) id 1w57fs-0003P7-15\n for qemu-devel@nongnu.org; Tue, 24 Mar 2026 15:44:24 -0400","from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <farosas@suse.de>) id 1w57fq-0008H4-An\n for qemu-devel@nongnu.org; Tue, 24 Mar 2026 15:44:23 -0400","from imap1.dmz-prg2.suse.org (unknown [10.150.64.97])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by smtp-out1.suse.de (Postfix) with ESMTPS id 0371B4D2D7;\n Tue, 24 Mar 2026 19:43:57 +0000 (UTC)","from imap1.dmz-prg2.suse.org (localhost [127.0.0.1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D097543FE4;\n Tue, 24 Mar 2026 19:43:55 +0000 (UTC)","from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167])\n by imap1.dmz-prg2.suse.org with ESMTPSA id 6PajJ3vpwmlkMQAAD6G6ig\n (envelope-from <farosas@suse.de>); Tue, 24 Mar 2026 19:43:55 +0000"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1774381437;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=CKGmz+lKmXdFvQ91j7EaHfHSLwUO7DpcItY8Bz2/bO0=;\n b=SG+MIn1ujA8J03/2tK3CgElz6d4fQBTORqaGA5QX0uHCzFWL/6zLwCvF08hCJXZCPfu5of\n tK+asjnku9MLSeT48qjXVDfUpVpqpe3PB1EYag3lu4A1CotxXv2NOawxRO1fPkBUQrkVJL\n CdHtd+FRD1ouumsBQMA5qwnfCbuftmg=","v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1774381437;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=CKGmz+lKmXdFvQ91j7EaHfHSLwUO7DpcItY8Bz2/bO0=;\n b=nlPayM8pI51QIJeluhDW03aZYIxWpK6p0GtV0CF6hwYSy9kIH0c6jARU7CoUE05AumlHdh\n hssoq/kQ/yxYoIBw==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1774381437;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=CKGmz+lKmXdFvQ91j7EaHfHSLwUO7DpcItY8Bz2/bO0=;\n b=SG+MIn1ujA8J03/2tK3CgElz6d4fQBTORqaGA5QX0uHCzFWL/6zLwCvF08hCJXZCPfu5of\n tK+asjnku9MLSeT48qjXVDfUpVpqpe3PB1EYag3lu4A1CotxXv2NOawxRO1fPkBUQrkVJL\n CdHtd+FRD1ouumsBQMA5qwnfCbuftmg=","v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1774381437;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=CKGmz+lKmXdFvQ91j7EaHfHSLwUO7DpcItY8Bz2/bO0=;\n b=nlPayM8pI51QIJeluhDW03aZYIxWpK6p0GtV0CF6hwYSy9kIH0c6jARU7CoUE05AumlHdh\n hssoq/kQ/yxYoIBw=="],"From":"Fabiano Rosas <farosas@suse.de>","To":"qemu-devel@nongnu.org","Cc":"Peter Xu <peterx@redhat.com>,\n Alexander Mikhalitsyn <alexander@mihalicyn.com>,\n Juraj Marcin <jmarcin@redhat.com>","Subject":"[RFC PATCH v1 13/17] vmstate: Drop VMS_ARRAY_OF_POINTER_AUTO_ALLOC","Date":"Tue, 24 Mar 2026 16:43:28 -0300","Message-ID":"<20260324194333.30004-14-farosas@suse.de>","X-Mailer":"git-send-email 2.51.0","In-Reply-To":"<20260324194333.30004-1-farosas@suse.de>","References":"<20260324194333.30004-1-farosas@suse.de>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Spam-Score":"-2.80","X-Spamd-Result":"default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%];\n NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[];\n R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000];\n MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[];\n FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+];\n TO_DN_SOME(0.00)[];\n DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email];\n RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[];\n RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com];\n DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[]","Received-SPF":"pass client-ip=2a07:de40:b251:101:10:150:64:1;\n 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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,\n 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 <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"The semantics of the VMS_ARRAY_OF_POINTER_AUTO_ALLOC of allocating\nmemory dynamically for an array of pointers could be thought to be the\nsame as the currently non-existent combination of VMS_ARRAY_OF_POINTER\n| VMS_ALLOC. The code is now able to handle such invalid combination,\nso drop the new flag and enable the VMS_ARRAY_OF_POINTER | VMS_ALLOC\ncombo.\n\nNote: I don't quite understand why we cannot allocate the first\nelement of the array with VMS_ARRAY_OF_POINTER_AUTO_ALLOC, so I\navoided that case when using the other flags as well.\n\nSigned-off-by: Fabiano Rosas <farosas@suse.de>\n---\n include/migration/vmstate.h | 21 +++++----------------\n migration/savevm.c          | 28 ++++++++++++----------------\n migration/vmstate.c         | 12 +++++++-----\n 3 files changed, 24 insertions(+), 37 deletions(-)","diff":"diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h\nindex 70bebc60ed..bf12df66e2 100644\n--- a/include/migration/vmstate.h\n+++ b/include/migration/vmstate.h\n@@ -146,8 +146,8 @@ enum VMStateFlags {\n     /* When loading serialised VM state, allocate memory for the\n      * (entire) field. Only valid in combination with\n      * VMS_POINTER. Note: Not all combinations with other flags are\n-     * currently supported, e.g. VMS_ALLOC|VMS_ARRAY_OF_POINTER won't\n-     * cause the individual entries to be allocated. */\n+     * currently supported.\n+     */\n     VMS_ALLOC            = 0x2000,\n \n     /* Multiply the number of entries given by the integer at opaque +\n@@ -161,19 +161,8 @@ enum VMStateFlags {\n      * structure we are referencing to use. */\n     VMS_VSTRUCT           = 0x8000,\n \n-    /*\n-     * This is a sub-flag for VMS_ARRAY_OF_POINTER, so VMS_ARRAY_OF_POINTER\n-     * must be set altogether.  When set, it means array elements can\n-     * contain either valid or NULL pointers, vmstate core will sync it\n-     * between the two QEMU instances via the stream protocol.  When it's a\n-     * valid pointer, the vmstate core will be responsible to do the proper\n-     * memory allocations.  It also means user of this flag must prepare\n-     * the array to be all NULLs otherwise memory may leak.\n-     */\n-    VMS_ARRAY_OF_POINTER_AUTO_ALLOC = 0x10000,\n-\n     /* Marker for end of list */\n-    VMS_END                         = 0x20000,\n+    VMS_END                         = 0x10000,\n };\n \n typedef enum {\n@@ -610,7 +599,7 @@ extern const VMStateInfo vmstate_info_qlist;\n     .size       = sizeof(_type),                                     \\\n     .flags      = VMS_POINTER | VMS_VARRAY_UINT8 |                   \\\n                   VMS_ARRAY_OF_POINTER | VMS_STRUCT |                \\\n-                  VMS_ARRAY_OF_POINTER_AUTO_ALLOC,                   \\\n+                  VMS_ALLOC,                                         \\\n     .offset     = vmstate_offset_pointer(_state, _field, _type *),   \\\n }\n \n@@ -623,7 +612,7 @@ extern const VMStateInfo vmstate_info_qlist;\n     .size       = sizeof(_type),                                      \\\n     .flags      = VMS_POINTER | VMS_VARRAY_UINT32 |                   \\\n                   VMS_ARRAY_OF_POINTER | VMS_STRUCT |                 \\\n-                  VMS_ARRAY_OF_POINTER_AUTO_ALLOC,                    \\\n+                  VMS_ALLOC,                                          \\\n     .offset     = vmstate_offset_pointer(_state, _field, _type *),    \\\n }\n \ndiff --git a/migration/savevm.c b/migration/savevm.c\nindex db0721996c..5170928d87 100644\n--- a/migration/savevm.c\n+++ b/migration/savevm.c\n@@ -869,7 +869,8 @@ static void vmstate_check(const VMStateDescription *vmsd)\n     if (field) {\n         while (field->name) {\n             if (field->flags & VMS_ARRAY_OF_POINTER) {\n-                if (field->flags & VMS_ARRAY_OF_POINTER_AUTO_ALLOC) {\n+                if (field->flags & VMS_ARRAY_OF_POINTER &&\n+                    field->flags & VMS_ALLOC) {\n                     /*\n                      * Size must be provided because dest QEMU needs that\n                      * info to know what to allocate\n@@ -882,22 +883,17 @@ static void vmstate_check(const VMStateDescription *vmsd)\n                      * setup of sizes in this case.\n                      */\n                     assert(field->size == 0 && field->size_offset == 0);\n+\n+                    /*\n+                     * Without VMS_ALLOC, VMS_ARRAY_OF_POINTER must be\n+                     * used only together with one of VMS_(V)ARRAY*\n+                     * flags.\n+                     */\n+                    assert(field->flags & (VMS_ARRAY | VMS_VARRAY_INT32 |\n+                                           VMS_VARRAY_UINT16 |\n+                                           VMS_VARRAY_UINT8 |\n+                                           VMS_VARRAY_UINT32));\n                 }\n-                /*\n-                 * VMS_ARRAY_OF_POINTER must be used only together with one\n-                 * of VMS_(V)ARRAY* flags.\n-                 */\n-                assert(field->flags & (VMS_ARRAY | VMS_VARRAY_INT32 |\n-                                       VMS_VARRAY_UINT16 | VMS_VARRAY_UINT8 |\n-                                       VMS_VARRAY_UINT32));\n-            }\n-\n-            /*\n-             * When VMS_ARRAY_OF_POINTER_ALLOW_NULL is used, we must have\n-             * VMS_ARRAY_OF_POINTER set too.\n-             */\n-            if (field->flags & VMS_ARRAY_OF_POINTER_AUTO_ALLOC) {\n-                assert(field->flags & VMS_ARRAY_OF_POINTER);\n             }\n \n             if (field->flags & (VMS_STRUCT | VMS_VSTRUCT)) {\ndiff --git a/migration/vmstate.c b/migration/vmstate.c\nindex c1ad0ef9a5..8f0f9383e2 100644\n--- a/migration/vmstate.c\n+++ b/migration/vmstate.c\n@@ -115,7 +115,7 @@ static void *vmstate_first(void *opaque, const VMStateField *field,\n {\n     void **first = opaque + field->offset;\n \n-    if (alloc) {\n+    if (alloc && field->flags & VMS_ALLOC) {\n         return vmstate_handle_alloc(first, size, n);\n     }\n \n@@ -142,7 +142,7 @@ static void *vmstate_next(void **first, const VMStateField *field,\n     next = *array_elem;\n \n     if (alloc) {\n-        if (!next || field->flags & VMS_ARRAY_OF_POINTER_AUTO_ALLOC) {\n+        if (!next || field->flags & VMS_ALLOC) {\n             /*\n              * NOTE: do not use vmstate_size() here, because we\n              * need the object size, not entry size of the\n@@ -291,7 +291,7 @@ bool vmstate_load_vmsd(QEMUFile *f, const VMStateDescription *vmsd,\n             int size = vmstate_size(opaque, field);\n \n             head = vmstate_first(opaque, field, size, n_elems,\n-                                 field->flags & VMS_ALLOC);\n+                                 !(field->flags & VMS_ARRAY_OF_POINTER));\n \n             for (i = 0; i < n_elems; i++) {\n                 /* If we will process the load of field? */\n@@ -408,7 +408,8 @@ static bool vmsd_can_compress(const VMStateField *field)\n         return false;\n     }\n \n-    if (field->flags & VMS_ARRAY_OF_POINTER_AUTO_ALLOC) {\n+    if (field->flags & VMS_ARRAY_OF_POINTER &&\n+        field->flags & VMS_ALLOC) {\n         /*\n          * This may involve two VMSD fields to be dumped, one for the\n          * marker to show if the pointer is NULL, followed by the real\n@@ -659,7 +660,8 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMStateDescription *vmsd,\n                      * marker first for each element saying if it's populated.\n                      */\n                     use_dynamic_array =\n-                        field->flags & VMS_ARRAY_OF_POINTER_AUTO_ALLOC;\n+                        field->flags & VMS_ARRAY_OF_POINTER &&\n+                        field->flags & VMS_ALLOC;\n \n                     use_marker_field = use_dynamic_array || is_null;\n \n","prefixes":["RFC","v1","13/17"]}