get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2080605/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2080605,
    "url": "http://patchwork.ozlabs.org/api/patches/2080605/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20250503075858.277375-2-pbonzini@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": "<20250503075858.277375-2-pbonzini@redhat.com>",
    "list_archive_url": null,
    "date": "2025-05-03T07:58:46",
    "name": "[PULL,01/13] rust/vmstate: Add support for field_exists checks",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "a0731ee5d409c219da5b78815895dda43c977f4c",
    "submitter": {
        "id": 2701,
        "url": "http://patchwork.ozlabs.org/api/people/2701/?format=api",
        "name": "Paolo Bonzini",
        "email": "pbonzini@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20250503075858.277375-2-pbonzini@redhat.com/mbox/",
    "series": [
        {
            "id": 455199,
            "url": "http://patchwork.ozlabs.org/api/series/455199/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=455199",
            "date": "2025-05-03T07:58:51",
            "name": "[PULL,01/13] rust/vmstate: Add support for field_exists checks",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/455199/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2080605/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2080605/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=i5IxafJ4;\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 4ZqKvD2MBnz1yNY\n\tfor <incoming@patchwork.ozlabs.org>; Sat,  3 May 2025 17:59:34 +1000 (AEST)",
            "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 1uB7mF-000831-0W; Sat, 03 May 2025 03:59:15 -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 <pbonzini@redhat.com>)\n id 1uB7mB-00082c-PO\n for qemu-devel@nongnu.org; Sat, 03 May 2025 03:59:11 -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 <pbonzini@redhat.com>)\n id 1uB7m9-0006c3-5M\n for qemu-devel@nongnu.org; Sat, 03 May 2025 03:59:11 -0400",
            "from mail-wr1-f72.google.com (mail-wr1-f72.google.com\n [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-263-otg2MYVZOk-XBuu9a7xl0A-1; Sat, 03 May 2025 03:59:05 -0400",
            "by mail-wr1-f72.google.com with SMTP id\n ffacd0b85a97d-39126c3469fso779849f8f.3\n for <qemu-devel@nongnu.org>; Sat, 03 May 2025 00:59:05 -0700 (PDT)",
            "from [192.168.10.48] ([151.95.54.106])\n by smtp.gmail.com with ESMTPSA id\n ffacd0b85a97d-3a099ae3ccdsm4211887f8f.38.2025.05.03.00.59.01\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sat, 03 May 2025 00:59:01 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1746259146;\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=u7aiabvalma8/ssAKdGg3gUinofOerC+pA/wzQHL28g=;\n b=i5IxafJ48RZPpqiSsQ9uCjl8GYH17BrWh3ta+2lQIoFXBJCHJyhrpvumdSXLRI+s5QlCU4\n XF7O4ZkQqOrkOLldfb9Ur7cqrg8JvXX6Yc3uTyqH0NzQ7hYIy/Lxh062L71Qct9l3MCLhE\n EhyzFOZXSz2Ic6dGliwaKGGs0bR/sYk=",
        "X-MC-Unique": "otg2MYVZOk-XBuu9a7xl0A-1",
        "X-Mimecast-MFC-AGG-ID": "otg2MYVZOk-XBuu9a7xl0A_1746259144",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1746259142; x=1746863942;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=u7aiabvalma8/ssAKdGg3gUinofOerC+pA/wzQHL28g=;\n b=Q4RCYnGSegvOE/R+Bfwh/zu7p48dyyY+A3rLU2EtVEIGvggBMyVXLah1Ny5U8zKYAy\n 8jLNG/93hLu7kzbibWSVTUKceNnuLh5dKOE3jhvqPpY5+rJI40P1fZ9Vd/Gn1Vno1zYB\n lxYmgkbfoaLzbIdomkMysXmgGJPacvlK2AEteMdEhRxNd68QOVYq+pm6jEt6XXkg5UXS\n s2F9SvqWOUZh0iyjUkj2h/oLxYVl5w2oE5XviZM7Xkamx60Q8LAqCRJZ+rlTw11dFiT4\n O5GNwxkBXUUKu3ERCfFfSMPX4AULpi/IEp4NWL8RYe6fqfQUld2n6z/tePxefrIcFGIu\n cflw==",
        "X-Gm-Message-State": "AOJu0YysekUHuZIGMkZ69YE1GafeGrJvBlPfNBz6qkdVIkDNs9gHv3lc\n 4g+dnqLBNLOw1Z4ynsq3lN0EeGQ9LxloN4rJnD+siGcRWo5jE1cvtH0Y7VGysZdLT4smS2CtW+I\n kGN3mq2Cte+eSeHA1K1RXr30OpeUDKx42urnQHsgnagxGDiT3iF5f1mApVAcoQRljIIbdcO952Y\n TdINjOaWNXE+zbujwg1sU6N8Qjg/kWkLY7JkRc",
        "X-Gm-Gg": "ASbGncvOLojQIeOf6AMBjwFH4CjBzMtzhonwMKdvA1sHf4Os9Rw9ZR+EE44c5kMP10d\n ZuHQBtNNG8CZnn4Tx3HfCj6vEAro8h/bhL0cwl8bnffJbZcuo6oQjcIp2oAJQcp1+9Ioa2OG14H\n u5sSZ5+ySqUdpmx85R59Es4zjtui7T9dusLXiUJbL12eDlIGnzPXsvlYU4PCw/3WQ61/YioNMHf\n sUMeIGcW+38dOA1OHM9eZ3b1F/Vo747fWh38ZopxeS461BjDyCQ/JslrQgm4/euU96RieR3ZlBr\n JYKDK2nADgxQBJc=",
        "X-Received": [
            "by 2002:a05:6000:240b:b0:3a0:8020:c5c5 with SMTP id\n ffacd0b85a97d-3a099aef8e6mr4176870f8f.58.1746259142470;\n Sat, 03 May 2025 00:59:02 -0700 (PDT)",
            "by 2002:a05:6000:240b:b0:3a0:8020:c5c5 with SMTP id\n ffacd0b85a97d-3a099aef8e6mr4176853f8f.58.1746259142008;\n Sat, 03 May 2025 00:59:02 -0700 (PDT)"
        ],
        "X-Google-Smtp-Source": "\n AGHT+IHDMeYvmICphnYKVr5xX1J98nvgeO4cjNuU9mY++NKd/jXoM4l4DBIdfwJy0qQAKfNIOFBzUQ==",
        "From": "Paolo Bonzini <pbonzini@redhat.com>",
        "To": "qemu-devel@nongnu.org",
        "Cc": "Zhao Liu <zhao1.liu@intel.com>",
        "Subject": "[PULL 01/13] rust/vmstate: Add support for field_exists checks",
        "Date": "Sat,  3 May 2025 09:58:46 +0200",
        "Message-ID": "<20250503075858.277375-2-pbonzini@redhat.com>",
        "X-Mailer": "git-send-email 2.49.0",
        "In-Reply-To": "<20250503075858.277375-1-pbonzini@redhat.com>",
        "References": "<20250503075858.277375-1-pbonzini@redhat.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Received-SPF": "pass client-ip=170.10.129.124;\n envelope-from=pbonzini@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com",
        "X-Spam_score_int": "-26",
        "X-Spam_score": "-2.7",
        "X-Spam_bar": "--",
        "X-Spam_report": "(-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.644,\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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,\n SPF_HELO_NONE=0.001, SPF_PASS=-0.001,\n T_FILL_THIS_FORM_SHORT=0.01 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-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": "From: Zhao Liu <zhao1.liu@intel.com>\n\nUnfortunately, at present it's not possible to have a const\n\"with_exist_check\" method to append test_fn after vmstate_struct (due\nto error on \"constant functions cannot evaluate destructors\" for `F`).\n\nBefore the vmstate builder, the only way to support \"test_fn\" is to\nextend vmstate_struct macro to add the such new optional member (and\nfortunately, Rust can still parse the current expansion!).\n\nAbstract the previous callback implementation of vmstate_validate into\na separate macro, and moves it before vmstate_struct for vmstate_struct\nto call.\n\nNote that there's no need to add any extra flag for a new test_fn added\nin the VMStateField.\n\nSigned-off-by: Zhao Liu <zhao1.liu@intel.com>\nLink: https://lore.kernel.org/r/20250414144943.1112885-2-zhao1.liu@intel.com\nSigned-off-by: Paolo Bonzini <pbonzini@redhat.com>\n---\n rust/qemu-api/src/vmstate.rs | 70 +++++++++++++++++++-----------------\n 1 file changed, 37 insertions(+), 33 deletions(-)",
    "diff": "diff --git a/rust/qemu-api/src/vmstate.rs b/rust/qemu-api/src/vmstate.rs\nindex 1b2b12eadd6..8c4a5bee3c1 100644\n--- a/rust/qemu-api/src/vmstate.rs\n+++ b/rust/qemu-api/src/vmstate.rs\n@@ -200,13 +200,14 @@ pub const fn vmstate_varray_flag<T: VMState>(_: PhantomData<T>) -> VMStateFlags\n /// and [`impl_vmstate_forward!`](crate::impl_vmstate_forward) help with this.\n #[macro_export]\n macro_rules! vmstate_of {\n-    ($struct_name:ty, $field_name:ident $([0 .. $num:ident $(* $factor:expr)?])? $(,)?) => {\n+    ($struct_name:ty, $field_name:ident $([0 .. $num:ident $(* $factor:expr)?])? $(, $test_fn:expr)? $(,)?) => {\n         $crate::bindings::VMStateField {\n             name: ::core::concat!(::core::stringify!($field_name), \"\\0\")\n                 .as_bytes()\n                 .as_ptr() as *const ::std::os::raw::c_char,\n             offset: $crate::offset_of!($struct_name, $field_name),\n             $(num_offset: $crate::offset_of!($struct_name, $num),)?\n+            $(field_exists: $crate::vmstate_exist_fn!($struct_name, $test_fn),)?\n             // The calls to `call_func_with_field!` are the magic that\n             // computes most of the VMStateField from the type of the field.\n             info: $crate::info_enum_to_ref!($crate::call_func_with_field!(\n@@ -435,6 +436,38 @@ macro_rules! vmstate_unused {\n     }};\n }\n \n+pub extern \"C\" fn rust_vms_test_field_exists<T, F: for<'a> FnCall<(&'a T, u8), bool>>(\n+    opaque: *mut c_void,\n+    version_id: c_int,\n+) -> bool {\n+    // SAFETY: the opaque was passed as a reference to `T`.\n+    let owner: &T = unsafe { &*(opaque.cast::<T>()) };\n+    let version: u8 = version_id.try_into().unwrap();\n+    F::call((owner, version))\n+}\n+\n+pub type VMSFieldExistCb = unsafe extern \"C\" fn(\n+    opaque: *mut std::os::raw::c_void,\n+    version_id: std::os::raw::c_int,\n+) -> bool;\n+\n+#[macro_export]\n+macro_rules! vmstate_exist_fn {\n+    ($struct_name:ty, $test_fn:expr) => {{\n+        const fn test_cb_builder__<T, F: for<'a> $crate::callbacks::FnCall<(&'a T, u8), bool>>(\n+            _phantom: ::core::marker::PhantomData<F>,\n+        ) -> $crate::vmstate::VMSFieldExistCb {\n+            let _: () = F::ASSERT_IS_SOME;\n+            $crate::vmstate::rust_vms_test_field_exists::<T, F>\n+        }\n+\n+        const fn phantom__<T>(_: &T) -> ::core::marker::PhantomData<T> {\n+            ::core::marker::PhantomData\n+        }\n+        Some(test_cb_builder__::<$struct_name, _>(phantom__(&$test_fn)))\n+    }};\n+}\n+\n // FIXME: including the `vmsd` field in a `const` is not possible without\n // the const_refs_static feature (stabilized in Rust 1.83.0).  Without it,\n // it is not possible to use VMS_STRUCT in a transparent manner using\n@@ -445,7 +478,7 @@ macro_rules! vmstate_unused {\n #[doc(alias = \"VMSTATE_STRUCT\")]\n #[macro_export]\n macro_rules! vmstate_struct {\n-    ($struct_name:ty, $field_name:ident $([0 .. $num:ident $(* $factor:expr)?])?, $vmsd:expr, $type:ty $(,)?) => {\n+    ($struct_name:ty, $field_name:ident $([0 .. $num:ident $(* $factor:expr)?])?, $vmsd:expr, $type:ty $(, $test_fn:expr)? $(,)?) => {\n         $crate::bindings::VMStateField {\n             name: ::core::concat!(::core::stringify!($field_name), \"\\0\")\n                 .as_bytes()\n@@ -458,6 +491,7 @@ macro_rules! vmstate_struct {\n             size: ::core::mem::size_of::<$type>(),\n             flags: $crate::bindings::VMStateFlags::VMS_STRUCT,\n             vmsd: $vmsd,\n+            $(field_exists: $crate::vmstate_exist_fn!($struct_name, $test_fn),)?\n             ..$crate::zeroable::Zeroable::ZERO\n          } $(.with_varray_flag_unchecked(\n                   $crate::call_func_with_field!(\n@@ -514,43 +548,13 @@ macro_rules! vmstate_fields {\n     }}\n }\n \n-pub extern \"C\" fn rust_vms_test_field_exists<T, F: for<'a> FnCall<(&'a T, u8), bool>>(\n-    opaque: *mut c_void,\n-    version_id: c_int,\n-) -> bool {\n-    let owner: &T = unsafe { &*(opaque.cast::<T>()) };\n-    let version: u8 = version_id.try_into().unwrap();\n-    // SAFETY: the opaque was passed as a reference to `T`.\n-    F::call((owner, version))\n-}\n-\n-pub type VMSFieldExistCb = unsafe extern \"C\" fn(\n-    opaque: *mut std::os::raw::c_void,\n-    version_id: std::os::raw::c_int,\n-) -> bool;\n-\n #[doc(alias = \"VMSTATE_VALIDATE\")]\n #[macro_export]\n macro_rules! vmstate_validate {\n     ($struct_name:ty, $test_name:expr, $test_fn:expr $(,)?) => {\n         $crate::bindings::VMStateField {\n             name: ::std::ffi::CStr::as_ptr($test_name),\n-            field_exists: {\n-                const fn test_cb_builder__<\n-                    T,\n-                    F: for<'a> $crate::callbacks::FnCall<(&'a T, u8), bool>,\n-                >(\n-                    _phantom: ::core::marker::PhantomData<F>,\n-                ) -> $crate::vmstate::VMSFieldExistCb {\n-                    let _: () = F::ASSERT_IS_SOME;\n-                    $crate::vmstate::rust_vms_test_field_exists::<T, F>\n-                }\n-\n-                const fn phantom__<T>(_: &T) -> ::core::marker::PhantomData<T> {\n-                    ::core::marker::PhantomData\n-                }\n-                Some(test_cb_builder__::<$struct_name, _>(phantom__(&$test_fn)))\n-            },\n+            field_exists: $crate::vmstate_exist_fn!($struct_name, $test_fn),\n             flags: $crate::bindings::VMStateFlags(\n                 $crate::bindings::VMStateFlags::VMS_MUST_EXIST.0\n                     | $crate::bindings::VMStateFlags::VMS_ARRAY.0,\n",
    "prefixes": [
        "PULL",
        "01/13"
    ]
}