Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2216586/?format=api
{ "id": 2216586, "url": "http://patchwork.ozlabs.org/api/patches/2216586/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260326210532.379027-8-peterx@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "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": "<20260326210532.379027-8-peterx@redhat.com>", "list_archive_url": null, "date": "2026-03-26T21:05:28", "name": "[RFC,v2,07/11] vmstate: Allow vmstate_info_nullptr to emit non-NULL markers", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "b6d28a6d8b6dcd972c013a526f9dde223b4da696", "submitter": { "id": 67717, "url": "http://patchwork.ozlabs.org/api/people/67717/?format=api", "name": "Peter Xu", "email": "peterx@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260326210532.379027-8-peterx@redhat.com/mbox/", "series": [ { "id": 497651, "url": "http://patchwork.ozlabs.org/api/series/497651/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=497651", "date": "2026-03-26T21:05:22", "name": "vmstate: Implement VMS_ARRAY_OF_POINTER_AUTO_ALLOC", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/497651/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2216586/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2216586/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=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=gCshdkB7;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=google header.b=bmD0M9zm;\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)" ], "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 4fhbvD5pZnz1yFx\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 27 Mar 2026 08:07:20 +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 1w5rtr-0004AM-Nt; Thu, 26 Mar 2026 17:05:55 -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 <peterx@redhat.com>) id 1w5rtm-00048d-TU\n for qemu-devel@nongnu.org; Thu, 26 Mar 2026 17:05:51 -0400", "from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <peterx@redhat.com>) id 1w5rtk-00037M-Ky\n for qemu-devel@nongnu.org; Thu, 26 Mar 2026 17:05:50 -0400", "from mail-qk1-f199.google.com (mail-qk1-f199.google.com\n [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-628-3vcvptPhM3iQ_7TlSJOigA-1; Thu, 26 Mar 2026 17:05:46 -0400", "by mail-qk1-f199.google.com with SMTP id\n af79cd13be357-8cfc61fc9b8so392397385a.1\n for <qemu-devel@nongnu.org>; Thu, 26 Mar 2026 14:05:46 -0700 (PDT)", "from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id\n af79cd13be357-8d00e4fa7d9sm353479785a.32.2026.03.26.14.05.44\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 26 Mar 2026 14:05:44 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1774559148;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=drzSSQlOSjoFXZvAA8C13NBR1l8WjpxMK8cEocL7tFk=;\n b=gCshdkB7ghR2AhJ+umAT8Pnart6ak7znr5w37awV6yY4TYK0UjlxNNG4Wc9jOQObh5cr67\n XM1qSBd20bUFLTJEd5Tw6Lq+OisfTQaveedIUFSx+pkNKdLH/+xHDuP3ffe59Jihut9jQf\n nvux7i4qGsGoYDOfCyXt/wK3thyE/w0=", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1774559146; x=1775163946; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=drzSSQlOSjoFXZvAA8C13NBR1l8WjpxMK8cEocL7tFk=;\n b=bmD0M9zm67szEcrqC5BBWxcb4YipPB0z9bxfNzo/FWopx2oFPHaJJAmNmSPWP1Mzws\n K+m4vpKbotd4RCaYaKUkQlRcxUpOaN35ZEHQNCtEGq8lfaB0026lXRkiXy870RAlyaAy\n EcrSs7B004KAAuCZ69tlWu0n9z5eC/CuMt808BXgQMVm96NORHDymGgsLMOyalQB2unh\n qDk+ZuF+CAXtJ1N6KbA6NSkYTpw7p3k6OftCVMgQ9PttD/nuIa8Az5miuaFrv1bvSJ8L\n yEF2QurBzCEcEe/OKc531/yBmjiTPRnTE8SE8vf7tN6mZGl9sLV37oNQEAJNDnwRYTHc\n QzkA==" ], "X-MC-Unique": "3vcvptPhM3iQ_7TlSJOigA-1", "X-Mimecast-MFC-AGG-ID": "3vcvptPhM3iQ_7TlSJOigA_1774559146", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774559146; x=1775163946;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=drzSSQlOSjoFXZvAA8C13NBR1l8WjpxMK8cEocL7tFk=;\n b=I8lreW0MooP+niLBP+cElV8GdwX4J57KSgYVQbTZN3c0OYMJY1amS658iHgqxYN02L\n 3grOl5Zrr18PhoS3vy+SUK0SzDvbVmZrfO7TyjK5qXqLoSVj/7zx1Jg08W+Bf45FMfXv\n zcipUl8qNF/EksGLqvxbUwuQdVq/W3jtvfO4T9Rg3o6UlAJhrmalfTepgevr/djcFOol\n c7oe2nFzzoOMAVYl+pJbkmLdEwIp6wmHtlWdtt48QWxNUQ2hxKpWNy0ViKik4M0oC/Bq\n AGF/0I5x5tJrpy/bHFpqLe28YS2JPbTrKXecPwoi4w9PDvc549x1HF+1EuRp/uW2DPKo\n Tllg==", "X-Gm-Message-State": "AOJu0Yzd1f8Te6bySNvFfc+syhL9BvyKygASXUhuSHaQj7RPsj6FON2H\n HW1No2QW895W3Gd2Npv41hc577J4CNNRS6rijI0qPTX3bJvHEi/prAJUsRMZzI2cijZHzdIksmq\n HcGEVtMI1W4EPmO4uTQtRf1Xdl0JxHgZfTxexma45MPNKMPVp6AyhY902Cy8kIc9hM7iqN3smll\n aS4F2Hju5HmJfFmDFFnS/YkiRZZBxx7TldKOGCKg==", "X-Gm-Gg": "ATEYQzyvJgfN/8jQfmf0nzhFHGYCDMXkjGTCnm/gXLdQqFYryWkfKRBgV8+DOdEy302\n 74Jyjb9skkRfxgIppMwhJ0Gxdp/oizBuIv8B9tYHwEDKenqhuf01KkU0IzwFx2dtmrdH2RUEStx\n /lC+MHLT4hg2Sdr7/xThIrAIz0rPothfP+npQm3EQ/PcqMdSx3TaaskYyp3tLJEr3TshAuAXESP\n KN5+MPeeSpPQLqSyZDuQWWIr1rWjVeD6ghuV/wBGXizKE59qU+tTPhVJxKFOD96cGdBIzhwPOeV\n 0wH8t0T+UQLv4iuAJakxnQqa9PWVl66rLixCymtvDfrIY1nqbxYZOv1fFi6pD+ZA274xj1aDhTv\n Afo5Fobwztfk=", "X-Received": [ "by 2002:a05:620a:46aa:b0:8cf:ed8d:20a3 with SMTP id\n af79cd13be357-8d0010f03a6mr1401551885a.42.1774559145591;\n Thu, 26 Mar 2026 14:05:45 -0700 (PDT)", "by 2002:a05:620a:46aa:b0:8cf:ed8d:20a3 with SMTP id\n af79cd13be357-8d0010f03a6mr1401544585a.42.1774559144888;\n Thu, 26 Mar 2026 14:05:44 -0700 (PDT)" ], "From": "Peter Xu <peterx@redhat.com>", "To": "qemu-devel@nongnu.org", "Cc": "Alexander Mikhalitsyn <alexander@mihalicyn.com>, peterx@redhat.com,\n Fabiano Rosas <farosas@suse.de>, Juraj Marcin <jmarcin@redhat.com>", "Subject": "[PATCH RFC v2 07/11] vmstate: Allow vmstate_info_nullptr to emit\n non-NULL markers", "Date": "Thu, 26 Mar 2026 17:05:28 -0400", "Message-ID": "<20260326210532.379027-8-peterx@redhat.com>", "X-Mailer": "git-send-email 2.50.1", "In-Reply-To": "<20260326210532.379027-1-peterx@redhat.com>", "References": "<20260326210532.379027-1-peterx@redhat.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com", "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, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,\n SPF_HELO_PASS=-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 <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": "We used to have one vmstate called \"nullptr\" which is only used to generate\none-byte hint to say one pointer is NULL.\n\nLet's extend its use so that it will generate another byte to say the\npointer is non-NULL.\n\nWith that, the name of the info struct (or functions) do not apply anymore.\nUpdate correspondingly.\n\nUpdate analyze-migration.py to work with the new layout.\n\nNo functional change intended yet.\n\nSigned-off-by: Peter Xu <peterx@redhat.com>\n---\n include/migration/vmstate.h | 9 +++++++--\n migration/vmstate-types.c | 34 ++++++++++++++++------------------\n migration/vmstate.c | 25 +++++++++++++------------\n scripts/analyze-migration.py | 22 ++++++++++++----------\n 4 files changed, 48 insertions(+), 42 deletions(-)", "diff": "diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h\nindex 092e8f7e9a..2e51b5ea04 100644\n--- a/include/migration/vmstate.h\n+++ b/include/migration/vmstate.h\n@@ -282,9 +282,14 @@ extern const VMStateInfo vmstate_info_uint32;\n extern const VMStateInfo vmstate_info_uint64;\n extern const VMStateInfo vmstate_info_fd;\n \n-/** Put this in the stream when migrating a null pointer.*/\n+/*\n+ * Put this in the stream when migrating a pointer to reflect either a NULL\n+ * or valid pointer.\n+ */\n #define VMS_MARKER_PTR_NULL (0x30U) /* '0' */\n-extern const VMStateInfo vmstate_info_nullptr;\n+#define VMS_MARKER_PTR_VALID (0x31U) /* '1' */\n+\n+extern const VMStateInfo vmstate_info_ptr_marker;\n \n extern const VMStateInfo vmstate_info_cpudouble;\n \ndiff --git a/migration/vmstate-types.c b/migration/vmstate-types.c\nindex 7622cf8f01..b31689fc3c 100644\n--- a/migration/vmstate-types.c\n+++ b/migration/vmstate-types.c\n@@ -359,36 +359,34 @@ const VMStateInfo vmstate_info_fd = {\n .save = save_fd,\n };\n \n-static bool load_nullptr(QEMUFile *f, void *pv, size_t size,\n- const VMStateField *field, Error **errp)\n+static bool load_ptr_marker(QEMUFile *f, void *pv, size_t size,\n+ const VMStateField *field, Error **errp)\n \n {\n- if (qemu_get_byte(f) == VMS_MARKER_PTR_NULL) {\n+ int byte = qemu_get_byte(f);\n+\n+ if (byte == VMS_MARKER_PTR_NULL || byte == VMS_MARKER_PTR_VALID) {\n+ /* TODO: process PTR_VALID case */\n return true;\n }\n \n- error_setg(errp, \"vmstate: load_nullptr expected VMS_NULLPTR_MARKER\");\n+ error_setg(errp, \"%s: unexpected ptr marker: %d\", __func__, byte);\n return false;\n }\n \n-static bool save_nullptr(QEMUFile *f, void *pv, size_t size,\n- const VMStateField *field, JSONWriter *vmdesc,\n- Error **errp)\n+static bool save_ptr_marker(QEMUFile *f, void *pv, size_t size,\n+ const VMStateField *field, JSONWriter *vmdesc,\n+ Error **errp)\n \n {\n- if (pv == NULL) {\n- qemu_put_byte(f, VMS_MARKER_PTR_NULL);\n- return true;\n- }\n-\n- error_setg(errp, \"vmstate: save_nullptr must be called with pv == NULL\");\n- return false;\n+ qemu_put_byte(f, pv ? VMS_MARKER_PTR_VALID : VMS_MARKER_PTR_NULL);\n+ return true;\n }\n \n-const VMStateInfo vmstate_info_nullptr = {\n- .name = \"nullptr\",\n- .load = load_nullptr,\n- .save = save_nullptr,\n+const VMStateInfo vmstate_info_ptr_marker = {\n+ .name = \"ptr-marker\",\n+ .load = load_ptr_marker,\n+ .save = save_ptr_marker,\n };\n \n /* 64 bit unsigned int. See that the received value is the same than the one\ndiff --git a/migration/vmstate.c b/migration/vmstate.c\nindex b274204e66..b333aa1744 100644\n--- a/migration/vmstate.c\n+++ b/migration/vmstate.c\n@@ -55,12 +55,12 @@ vmstate_field_exists(const VMStateDescription *vmsd, const VMStateField *field,\n }\n \n /*\n- * Create a fake nullptr field when there's a NULL pointer detected in the\n+ * Create a ptr marker field when there's a NULL pointer detected in the\n * array of a VMS_ARRAY_OF_POINTER VMSD field. It's needed because we\n * can't dereference the NULL pointer.\n */\n static const VMStateField *\n-vmsd_create_fake_nullptr_field(const VMStateField *field)\n+vmsd_create_ptr_marker_field(const VMStateField *field)\n {\n VMStateField *fake = g_new0(VMStateField, 1);\n \n@@ -71,12 +71,12 @@ vmsd_create_fake_nullptr_field(const VMStateField *field)\n fake->name = field->name;\n fake->version_id = field->version_id;\n \n- /* Do not need \"field_exists\" check as it always exists (which is null) */\n+ /* Do not need \"field_exists\" check as it always exists */\n fake->field_exists = NULL;\n \n- /* See vmstate_info_nullptr - use 1 byte to represent nullptr */\n+ /* See vmstate_info_ptr_marker - use 1 byte to represent ptr status */\n fake->size = 1;\n- fake->info = &vmstate_info_nullptr;\n+ fake->info = &vmstate_info_ptr_marker;\n fake->flags = VMS_SINGLE;\n \n /* All the rest fields shouldn't matter.. */\n@@ -278,7 +278,7 @@ bool vmstate_load_vmsd(QEMUFile *f, const VMStateDescription *vmsd,\n * an array of pointers), use null placeholder and do\n * not follow.\n */\n- inner_field = vmsd_create_fake_nullptr_field(field);\n+ inner_field = vmsd_create_ptr_marker_field(field);\n } else {\n inner_field = field;\n }\n@@ -583,26 +583,27 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMStateDescription *vmsd,\n for (i = 0; i < n_elems; i++) {\n void *curr_elem = first_elem + size * i;\n const VMStateField *inner_field;\n- bool is_null;\n /* maximum number of elements to compress in the JSON blob */\n int max_elems = vmsd_can_compress(field) ? (n_elems - i) : 1;\n+ bool use_marker_field, is_null;\n \n if (field->flags & VMS_ARRAY_OF_POINTER) {\n assert(curr_elem);\n curr_elem = *(void **)curr_elem;\n }\n \n- if (!curr_elem && size) {\n+ is_null = !curr_elem && size;\n+ use_marker_field = is_null;\n+\n+ if (use_marker_field) {\n /*\n * If null pointer found (which should only happen in\n * an array of pointers), use null placeholder and do\n * not follow.\n */\n- inner_field = vmsd_create_fake_nullptr_field(field);\n- is_null = true;\n+ inner_field = vmsd_create_ptr_marker_field(field);\n } else {\n inner_field = field;\n- is_null = false;\n }\n \n /*\n@@ -638,7 +639,7 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMStateDescription *vmsd,\n i, max_elems, errp);\n \n /* If we used a fake temp field.. free it now */\n- if (is_null) {\n+ if (use_marker_field) {\n g_clear_pointer((gpointer *)&inner_field, g_free);\n }\n \ndiff --git a/scripts/analyze-migration.py b/scripts/analyze-migration.py\nindex e81deab8f9..1771ff781b 100755\n--- a/scripts/analyze-migration.py\n+++ b/scripts/analyze-migration.py\n@@ -469,26 +469,26 @@ def __init__(self, desc, file):\n super(VMSDFieldIntLE, self).__init__(desc, file)\n self.dtype = '<i%d' % self.size\n \n-class VMSDFieldNull(VMSDFieldGeneric):\n+class VMSDFieldPtrMarker(VMSDFieldGeneric):\n NULL_PTR_MARKER = b'0'\n+ VALID_PTR_MARKER = b'1'\n \n def __init__(self, desc, file):\n- super(VMSDFieldNull, self).__init__(desc, file)\n+ super(VMSDFieldPtrMarker, self).__init__(desc, file)\n \n def __repr__(self):\n- # A NULL pointer is encoded in the stream as a '0' to\n- # disambiguate from a mere 0x0 value and avoid consumers\n- # trying to follow the NULL pointer. Displaying '0', 0x30 or\n- # 0x0 when analyzing the JSON debug stream could become\n+ # A NULL / non-NULL pointer may be encoded in the stream as a\n+ # '0'/'1' to represent the status of the pointer. Displaying '0',\n+ # 0x30 or 0x0 when analyzing the JSON debug stream could become\n # confusing, so use an explicit term instead.\n- return \"nullptr\"\n+ return \"null-ptr\" if self.data == self.NULL_PTR_MARKER else \"valid-ptr\"\n \n def __str__(self):\n return self.__repr__()\n \n def read(self):\n- super(VMSDFieldNull, self).read()\n- assert(self.data == self.NULL_PTR_MARKER)\n+ super(VMSDFieldPtrMarker, self).read()\n+ assert(self.data in [self.NULL_PTR_MARKER, self.VALID_PTR_MARKER])\n return self.data\n \n class VMSDFieldBool(VMSDFieldGeneric):\n@@ -642,7 +642,9 @@ def getDict(self):\n \"bitmap\" : VMSDFieldGeneric,\n \"struct\" : VMSDFieldStruct,\n \"capability\": VMSDFieldCap,\n- \"nullptr\": VMSDFieldNull,\n+ # Keep the old nullptr for old binaries\n+ \"nullptr\": VMSDFieldPtrMarker,\n+ \"ptr-marker\": VMSDFieldPtrMarker,\n \"unknown\" : VMSDFieldGeneric,\n }\n \n", "prefixes": [ "RFC", "v2", "07/11" ] }