get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2026294,
    "url": "http://patchwork.ozlabs.org/api/patches/2026294/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20241220104220.2007786-15-npiggin@gmail.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": "<20241220104220.2007786-15-npiggin@gmail.com>",
    "list_archive_url": null,
    "date": "2024-12-20T10:42:16",
    "name": "[14/17] async: add debugging assertions for record/replay in bh APIs",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "8105613fcbaf7f748291269a026567e3f9cccb19",
    "submitter": {
        "id": 69518,
        "url": "http://patchwork.ozlabs.org/api/people/69518/?format=api",
        "name": "Nicholas Piggin",
        "email": "npiggin@gmail.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20241220104220.2007786-15-npiggin@gmail.com/mbox/",
    "series": [
        {
            "id": 437728,
            "url": "http://patchwork.ozlabs.org/api/series/437728/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=437728",
            "date": "2024-12-20T10:42:02",
            "name": "replay: Fixes and avocado test updates",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/437728/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2026294/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2026294/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 (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20230601 header.b=g8nmJoop;\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 4YF3vT5qJjz1ySC\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 20 Dec 2024 21:44:37 +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 1tOaUf-0000Cd-L7; Fri, 20 Dec 2024 05:44:29 -0500",
            "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 <npiggin@gmail.com>)\n id 1tOaUd-0008VK-Eq; Fri, 20 Dec 2024 05:44:27 -0500",
            "from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <npiggin@gmail.com>)\n id 1tOaUa-0005SS-R3; Fri, 20 Dec 2024 05:44:27 -0500",
            "by mail-pl1-x62c.google.com with SMTP id\n d9443c01a7336-2163dc5155fso15854415ad.0;\n Fri, 20 Dec 2024 02:44:24 -0800 (PST)",
            "from wheely.local0.net (14-200-18-130.tpgi.com.au. [14.200.18.130])\n by smtp.gmail.com with ESMTPSA id\n 98e67ed59e1d1-2f2ee06dfd3sm5376942a91.32.2024.12.20.02.44.15\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 20 Dec 2024 02:44:22 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20230601; t=1734691462; x=1735296262; 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=Wu+GL4+vvCQpuAOpV7VcZuV6PKMa6EXzctMojFuS3jU=;\n b=g8nmJoopduObIxSCzsD1/+ag+d1xNQlQj9VY16XOOSqu5uPa2g3CgUXAAVSRvKtNmH\n DqJ4kG/rDNm+InpiSHqGKktpvzNy0EU/sWgghJ48j9D2bqfxGT5/rzs48mNWPetI2HHM\n 0Z7l/VuLb3/npq+3v6R5FfqePX8cSJz/QuNqfOfbrW0XssNmbN3JTpFobnPdOZ9ikwyE\n 33SJke5ZkjdbxzKVywdp817SzKNqHIW8EkjdAdbCvQaiM6PmQJSJrMdt1eyoCKP2QV23\n MGm20yDEh6lR9le0w0nKg46ItBHrsv6MXnypNihUHAc+Pa3cHuzivulSRdA9TLhGcVJc\n yR2g==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1734691462; x=1735296262;\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=Wu+GL4+vvCQpuAOpV7VcZuV6PKMa6EXzctMojFuS3jU=;\n b=p+3DnTFC0c+6G4O/f4SYCqoCEZYU3IMNmFxDxkGyLi2vtHGpXt2b7VX+pKMnjqR+4R\n mcDvSHLIFLx6IRr/6Vm3LycxDdJHCI4/mSUYwDwJjKOLiawooAdSEYHxE8hBcPyRsYgf\n FuG1LHwEnFOmLR1AmT4N7ILYD3g5ON8YrgEjVm5KrI9cOdtAF1vcvpRGETBAi1lDhPhc\n pYZRLT/cl5Vy+7qh0L3FD5z38S29hlMESOU2iXr3mjvhtZGWV4kzK3JBSt9Kk7NPNWpr\n a7reB4tkuU/0m98i7ykan6zypJjjG6r4fEhvwZ9ulqPB5aCmkoOdQ9r7TEhTEeIHddpp\n F94g==",
        "X-Forwarded-Encrypted": "i=1;\n AJvYcCWoy4EloHvCbLiu8E46LU3g1QzBuok0nTgARK2o87gi1OinEJ1dJKak6P3MfTtHiDjtXImxl4Ki4WOi@nongnu.org",
        "X-Gm-Message-State": "AOJu0YxubPC7pfiejFxK4YEd4pjMythhLGgJWEuMnNWsOCU39cYXScAR\n qU63FQINAJPGgZdEosrJjK1rFJ0AJm1Lxfr/2PlTUloY4N8MKuCXffucug==",
        "X-Gm-Gg": "ASbGnctO4+TWsi6mlwKTp5Q57dt842qm8Bzl34RCYw4ktg+CK7zXd0xBF1JzAZPm/iB\n YIYNMPQhG+KhCudmYkdpglWYdIJPi+H8wM7uldSels0BxFXUW2AXcrcoW6oMCLrukP9PsBN/HDY\n CCoXxleBIbUzks42BBzxEvXk2oBdnFZ2osZbjdX/VHkjrMBVX6HUg/nm05hLI/EB4SIQabGFhJI\n kuyMgFwVc0OVl3Zhek/nc7fAxTM5h3jmF6E3++QvyIcFb+PwLW2g8f2Di2ALuPWsKU8SQFsopti\n krAHOjIkiw==",
        "X-Google-Smtp-Source": "\n AGHT+IH8c/AWBwB0fOu47PM6NedBBLoYnyCAzWnEUS+m31wqpGtz3tPAybi9eDUQLAzIWKxjcC8uuw==",
        "X-Received": "by 2002:a17:90b:53c5:b0:2ee:74a1:fb92 with SMTP id\n 98e67ed59e1d1-2f452dfd236mr3611190a91.6.1734691462603;\n Fri, 20 Dec 2024 02:44:22 -0800 (PST)",
        "From": "Nicholas Piggin <npiggin@gmail.com>",
        "To": "qemu-devel@nongnu.org",
        "Cc": "Nicholas Piggin <npiggin@gmail.com>, qemu-block@nongnu.org, =?utf-8?q?Al?=\n\t=?utf-8?q?ex_Benn=C3=A9e?= <alex.bennee@linaro.org>,\n Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>,\n Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>,\n Paolo Bonzini <pbonzini@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>,\n Fam Zheng <fam@euphon.net>, Ronnie Sahlberg <ronniesahlberg@gmail.com>,\n John Snow <jsnow@redhat.com>, \"Michael S. Tsirkin\" <mst@redhat.com>,\n Jason Wang <jasowang@redhat.com>,\n Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,\n Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>,\n \"Dr. David Alan Gilbert\" <dave@treblig.org>,\n Markus Armbruster <armbru@redhat.com>, Michael Roth <michael.roth@amd.com>,\n Wainer dos Santos Moschetta <wainersm@redhat.com>",
        "Subject": "[PATCH 14/17] async: add debugging assertions for record/replay in bh\n APIs",
        "Date": "Fri, 20 Dec 2024 20:42:16 +1000",
        "Message-ID": "<20241220104220.2007786-15-npiggin@gmail.com>",
        "X-Mailer": "git-send-email 2.45.2",
        "In-Reply-To": "<20241220104220.2007786-1-npiggin@gmail.com>",
        "References": "<20241220104220.2007786-1-npiggin@gmail.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Received-SPF": "pass client-ip=2607:f8b0:4864:20::62c;\n envelope-from=npiggin@gmail.com; helo=mail-pl1-x62c.google.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, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,\n TVD_PH_BODY_ACCOUNTS_PRE=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-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": "Code using old bh APIs must be updated to account for whether the\nbh is related to the target machine model or host QEMU operation,\nin order for record/replay to work properly.\n\nAdd some assertions in the old APIs to catch unconverted code when\nrecord/replay is active.\n\nThis caught the IDE bug when running replay_linux.py avocado test\nwith the x86-64 q35 non-virtio machine.\n\nSigned-off-by: Nicholas Piggin <npiggin@gmail.com>\n---\n include/block/aio.h    |  2 +-\n replay/replay-events.c | 20 ++++++++------------\n util/async.c           | 29 +++++++++++++++++++++++++++++\n 3 files changed, 38 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/include/block/aio.h b/include/block/aio.h\nindex 26859bd0b93..991aaae707d 100644\n--- a/include/block/aio.h\n+++ b/include/block/aio.h\n@@ -309,7 +309,7 @@ void aio_bh_schedule_oneshot_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque,\n  */\n #define aio_bh_schedule_oneshot(ctx, cb, opaque) \\\n     aio_bh_schedule_oneshot_full((ctx), (cb), (opaque), (stringify(cb)), \\\n-                                 QEMU_CLOCK_REALTIME)\n+                                 QEMU_CLOCK_MAX)\n \n /**\n  * aio_bh_new_full: Allocate a new bottom half structure.\ndiff --git a/replay/replay-events.c b/replay/replay-events.c\nindex 6a7c27cac1e..0b3dbfd46b9 100644\n--- a/replay/replay-events.c\n+++ b/replay/replay-events.c\n@@ -123,23 +123,19 @@ void replay_add_event(ReplayAsyncEventKind event_kind,\n \n void replay_bh_schedule_event(QEMUBH *bh)\n {\n-    if (events_enabled) {\n-        uint64_t id = replay_get_current_icount();\n-        replay_add_event(REPLAY_ASYNC_EVENT_BH, bh, NULL, id);\n-    } else {\n-        qemu_bh_schedule(bh);\n-    }\n+    uint64_t id;\n+    g_assert(events_enabled);\n+    id = replay_get_current_icount();\n+    replay_add_event(REPLAY_ASYNC_EVENT_BH, bh, NULL, id);\n }\n \n void replay_bh_oneshot_event(AioContext *ctx,\n     QEMUBHFunc *cb, void *opaque)\n {\n-    if (events_enabled) {\n-        uint64_t id = replay_get_current_icount();\n-        replay_add_event(REPLAY_ASYNC_EVENT_BH_ONESHOT, cb, opaque, id);\n-    } else {\n-        aio_bh_schedule_oneshot(ctx, cb, opaque);\n-    }\n+    uint64_t id;\n+    g_assert(events_enabled);\n+    id = replay_get_current_icount();\n+    replay_add_event(REPLAY_ASYNC_EVENT_BH_ONESHOT, cb, opaque, id);\n }\n \n void replay_add_input_event(struct InputEvent *event)\ndiff --git a/util/async.c b/util/async.c\nindex 5d2c76dec08..72a9eccffbe 100644\n--- a/util/async.c\n+++ b/util/async.c\n@@ -58,6 +58,9 @@ enum {\n \n     /* Schedule periodically when the event loop is idle */\n     BH_IDLE      = (1 << 4),\n+\n+    /* BH being handled by replay machinery */\n+    BH_REPLAY    = (1 << 4),\n };\n \n struct QEMUBH {\n@@ -145,6 +148,17 @@ void aio_bh_schedule_oneshot_full(AioContext *ctx, QEMUBHFunc *cb,\n                                   void *opaque, const char *name,\n                                   QEMUClockType clock_type)\n {\n+    if (clock_type == QEMU_CLOCK_MAX) {\n+        /*\n+         * aio_bh_schedule_oneshot() uses QEMU_CLOCK_MAX to say it does not\n+         * know about clock context to use. It will not work in record/replay.\n+         * Callers should be converted to aio_bh_schedule_oneshot_event()\n+         * then this can be removed when the old API goes away.\n+         */\n+        g_assert(replay_mode == REPLAY_MODE_NONE);\n+        clock_type = QEMU_CLOCK_REALTIME;\n+    }\n+\n     switch (clock_type) {\n     case QEMU_CLOCK_VIRTUAL:\n     case QEMU_CLOCK_VIRTUAL_RT:\n@@ -178,6 +192,12 @@ void aio_bh_call(QEMUBH *bh)\n {\n     bool last_engaged_in_io = false;\n \n+    if (bh->flags & BH_REPLAY) {\n+        g_assert(!(bh->flags & BH_SCHEDULED));\n+        g_assert(!(bh->flags & BH_DELETED));\n+        g_assert(!(bh->flags & BH_PENDING));\n+        bh->flags &= ~BH_REPLAY;\n+    }\n     /* Make a copy of the guard-pointer as cb may free the bh */\n     MemReentrancyGuard *reentrancy_guard = bh->reentrancy_guard;\n     if (reentrancy_guard) {\n@@ -252,6 +272,7 @@ void qemu_bh_schedule_event(QEMUBH *bh, QEMUClockType clock_type)\n     case QEMU_CLOCK_VIRTUAL_RT:\n         if (replay_mode != REPLAY_MODE_NONE) {\n             /* Record/replay must intercept bh events */\n+            qatomic_fetch_or(&bh->flags, BH_REPLAY);\n             replay_bh_schedule_event(bh);\n             break;\n         }\n@@ -268,11 +289,15 @@ void qemu_bh_schedule_event_noreplay(QEMUBH *bh)\n \n void qemu_bh_schedule_idle(QEMUBH *bh)\n {\n+    /* No mechanism for scheduling idle replay-scheduled bh at the moment */\n+    g_assert(replay_mode == REPLAY_MODE_NONE);\n     aio_bh_enqueue(bh, BH_SCHEDULED | BH_IDLE);\n }\n \n void qemu_bh_schedule(QEMUBH *bh)\n {\n+    /* Callers should be converted to use qemu_bh_schedule_event */\n+    g_assert(replay_mode == REPLAY_MODE_NONE);\n     aio_bh_enqueue(bh, BH_SCHEDULED);\n }\n \n@@ -280,6 +305,8 @@ void qemu_bh_schedule(QEMUBH *bh)\n  */\n void qemu_bh_cancel(QEMUBH *bh)\n {\n+    /* No mechanism for canceling replay-scheduled bh at the moment */\n+    g_assert(!(bh->flags & BH_REPLAY));\n     qatomic_and(&bh->flags, ~BH_SCHEDULED);\n }\n \n@@ -288,6 +315,8 @@ void qemu_bh_cancel(QEMUBH *bh)\n  */\n void qemu_bh_delete(QEMUBH *bh)\n {\n+    /* No mechanism for deleting replay-scheduled bh at the moment */\n+    g_assert(!(bh->flags & BH_REPLAY));\n     aio_bh_enqueue(bh, BH_DELETED);\n }\n \n",
    "prefixes": [
        "14/17"
    ]
}