Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2218751/?format=api
{ "id": 2218751, "url": "http://patchwork.ozlabs.org/api/patches/2218751/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260401202844.673494-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": "<20260401202844.673494-8-peterx@redhat.com>", "list_archive_url": null, "date": "2026-04-01T20:28:40", "name": "[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/20260401202844.673494-8-peterx@redhat.com/mbox/", "series": [ { "id": 498385, "url": "http://patchwork.ozlabs.org/api/series/498385/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=498385", "date": "2026-04-01T20:28:34", "name": "vmstate: Implement VMS_ARRAY_OF_POINTER_AUTO_ALLOC", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/498385/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2218751/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2218751/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=Za/0jEkl;\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=SIdvczq9;\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 4fmGnp6Spwz1yCs\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 02 Apr 2026 07:30:22 +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 1w82BU-0004Ma-Ho; Wed, 01 Apr 2026 16:29:04 -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 1w82BR-0004Kr-TB\n for qemu-devel@nongnu.org; Wed, 01 Apr 2026 16:29:01 -0400", "from us-smtp-delivery-124.mimecast.com ([170.10.129.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 1w82BP-000399-Ux\n for qemu-devel@nongnu.org; Wed, 01 Apr 2026 16:29:01 -0400", "from mail-qv1-f71.google.com (mail-qv1-f71.google.com\n [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-7-Qk5rW2sLOGKTXKNWN_VLxA-1; Wed, 01 Apr 2026 16:28:57 -0400", "by mail-qv1-f71.google.com with SMTP id\n 6a1803df08f44-89ce2a7fef6so7143646d6.1\n for <qemu-devel@nongnu.org>; Wed, 01 Apr 2026 13:28:57 -0700 (PDT)", "from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id\n af79cd13be357-8d2a548a4efsm68194085a.8.2026.04.01.13.28.55\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 01 Apr 2026 13:28:55 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1775075339;\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=n1cYzTfIInVG4krmJT8uaa40fyNhORGhPZ9F1/mWMbo=;\n b=Za/0jEklxfZWkYP+VP6bmiVv9L/GOzGCW+soh1OkLbDKIQJ8uCvZtkTqYzlPbsxD0xY0L0\n svK1rFNQ4sddz/e9LsDXQXyuOt08qihxnO7QBhCmctrjaanhglGs20FkL89AxOnVOj2C3n\n KWpl4r0mS+mqWs8HYUnp8u20tqcJlUQ=", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1775075336; x=1775680136; 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=n1cYzTfIInVG4krmJT8uaa40fyNhORGhPZ9F1/mWMbo=;\n b=SIdvczq9dFQwH1lQL4oh7ZK1pvguWDFiteDHMCS9eAxyq1q073Ak05lV43ottgbaC4\n 69FUeKhgADdklAJiRAuxzDPGCZ5/AyEJT7WypVeIUAncLDR0ncdJid5Fkr2bHZ+cyvl5\n zfonby1f0yU5dPBTdI9DjYR1adZSx2bva9fVYkIXzegPxG2F3jHJ7KYehfP+f8Sj4ixh\n ChtBtG6aiD4riSA/h8myiYT7STJhr12rM3vZI3X9JaQe+06lHlMamV6jbADfpzVz/cRU\n vwzm5M2r37ZEEzdY7suB1ku94xUmTcx9bD8nulpGjoL3pJ8ss6rDNgWoPj4CibUWIhSt\n 5RRQ==" ], "X-MC-Unique": "Qk5rW2sLOGKTXKNWN_VLxA-1", "X-Mimecast-MFC-AGG-ID": "Qk5rW2sLOGKTXKNWN_VLxA_1775075337", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775075336; x=1775680136;\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=n1cYzTfIInVG4krmJT8uaa40fyNhORGhPZ9F1/mWMbo=;\n b=cY8ePseij8zxiy7THc9ovYn5L7t8AWcwwgWNbJmf9g204tiFl2exEKdNWnSwzkp89J\n BuThbahzzf482eRDCKXJagBiDnl640HfEUt/TqqrFsov0CXnhkp47mTa6PLDrYsKyANy\n aB91hvylv+T1y9pKf2vSIsbUryN5LOlepddZA9bWDMCqfsfKIxkpINGXxcTOJZu2WRVt\n HKq6ZbDubOBZbfvYcNDB1zhBnEj9q88FSrqbfymoy9WYcxWfui5Bqug0Nv+WFdVs5uh3\n 3cURItirbkv9phWT7u/P5cf1iyLb01PVaqqGSp/wFyRbadFoDI5kXVYQGbkB4ApcCOlT\n TgvQ==", "X-Gm-Message-State": "AOJu0YzpT+FZYWc/hOso70hUbvbyhXm9GxmvDFEHJpF3n7Bc2Q3TyMiU\n WsL40d2ylMwl5Nat+is9UOgfQtceuEk0y8j/RjTirNWKKnJp0nCLtxSx5bOi513OglHwr8MZnbZ\n e0uhGN43YuhHeFqOX9yS+vke5Gg4is9WToJVmfrPRY/ueb6RDrkRloQV7M0SfdnrvGbOnWn3Kt+\n wbrQrKwm2x/a1v3I3rvk7R5aeNxD+pgigJcSkAQQ==", "X-Gm-Gg": "ATEYQzw6JM+I8jPTHThXTz4fFxMW1BJqpTT17QagpUrhZ3mJyL1759N0fSq6cflhihO\n OQfuzanC9DxNIQN+4jO9QvOZJc4I0KzXJ/QJeI/2IeZEGtqN4WwlKSdadzQeBNlJyIaCuxK3hiI\n /1TBwWjgUGk5mFWfs2QFL4TaN7y+3huvKNUbrTIkRG+EaPB+332PnjYuhKDcvXdtY2Z9MAcBBVw\n EANOMpQ6zItUaCCsbTpm2TwCSCEyDcpi1O7WZHtFgdG9Q2T9Q19P7CQLKfOFfgpKPySV49t1wxS\n mp76zgwfjVeJ7gLnCyLL69dmYeLQyGymla2bLzIqPuAI7H0GYd5/yAGYehFzfnaD6Sm+OotCRCo\n fmhHwZxSBcW+uciaj5XoxQUXBpvOoUCnWr6OJTwH1scU=", "X-Received": [ "by 2002:a05:620a:404c:b0:8cb:9975:cba8 with SMTP id\n af79cd13be357-8d1b5c5782cmr818803185a.62.1775075336434;\n Wed, 01 Apr 2026 13:28:56 -0700 (PDT)", "by 2002:a05:620a:404c:b0:8cb:9975:cba8 with SMTP id\n af79cd13be357-8d1b5c5782cmr818797985a.62.1775075335852;\n Wed, 01 Apr 2026 13:28:55 -0700 (PDT)" ], "From": "Peter Xu <peterx@redhat.com>", "To": "qemu-devel@nongnu.org", "Cc": "Juraj Marcin <jmarcin@redhat.com>,\n Alexander Mikhalitsyn <alexander@mihalicyn.com>,\n Fabiano Rosas <farosas@suse.de>, Peter Xu <peterx@redhat.com>,\n Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>", "Subject": "[PATCH 07/11] vmstate: Allow vmstate_info_nullptr to emit non-NULL\n markers", "Date": "Wed, 1 Apr 2026 16:28:40 -0400", "Message-ID": "<20260401202844.673494-8-peterx@redhat.com>", "X-Mailer": "git-send-email 2.50.1", "In-Reply-To": "<20260401202844.673494-1-peterx@redhat.com>", "References": "<20260401202844.673494-1-peterx@redhat.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com", "X-Spam_score_int": "-6", "X-Spam_score": "-0.7", "X-Spam_bar": "/", "X-Spam_report": "(-0.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54,\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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01,\n RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1, RCVD_IN_VALIDITY_RPBL_BLOCKED=1,\n SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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\nReviewed-by: Fabiano Rosas <farosas@suse.de>\nReviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>\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 7396e38531..492069b8d2 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": [ "07/11" ] }