Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2221195/?format=api
{ "id": 2221195, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2221195/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260408021636.794794-2-eblake@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/1.1/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": "" }, "msgid": "<20260408021636.794794-2-eblake@redhat.com>", "date": "2026-04-08T02:16:33", "name": "qemu-nbd: Support -s and -l at the same time", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "b86d44e2fce33c4b37ad503d08ed6cc07364ceff", "submitter": { "id": 6591, "url": "http://patchwork.ozlabs.org/api/1.1/people/6591/?format=api", "name": "Eric Blake", "email": "eblake@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260408021636.794794-2-eblake@redhat.com/mbox/", "series": [ { "id": 499203, "url": "http://patchwork.ozlabs.org/api/1.1/series/499203/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=499203", "date": "2026-04-08T02:16:33", "name": "qemu-nbd: Support -s and -l at the same time", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/499203/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2221195/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2221195/checks/", "tags": {}, "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=XxwY1oYg;\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 (lists1p.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 4frYMw6CQJz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 05:41:16 +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 1wAYc8-0004wh-G5; Wed, 08 Apr 2026 15:31:00 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <eblake@redhat.com>) id 1wAYA1-0000gb-9u\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 15:01:57 -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 <eblake@redhat.com>) id 1wAITH-0004jo-Kt\n for qemu-devel@nongnu.org; Tue, 07 Apr 2026 22:16:49 -0400", "from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-336-jsNwypOKPeqbz4VomXJdWQ-1; Tue,\n 07 Apr 2026 22:16:43 -0400", "from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id B694D180044D; Wed, 8 Apr 2026 02:16:41 +0000 (UTC)", "from green.redhat.com (unknown [10.2.16.26])\n by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id BAFFB1800673; Wed, 8 Apr 2026 02:16:39 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1775614606;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=lLHbJbpbVpCc7ZPDfJzkupfRH4+Vp1i+3Y5xDT7n2Qg=;\n b=XxwY1oYgffl3coeecc1tYrqiXmoGE7U2ZBgkNI479Hr22QrgkqJG+TbpogMfiQMSE0GFtg\n db45ZeYlVwZo3eGZDeT8wNtIctdR3RmRt+ovBtDZKeXiu9fQZ1bMEPKot5Lp4f3QMeZzrt\n 0xn3zIyVlYlfO5Ew1NfjPryojyad24o=", "X-MC-Unique": "jsNwypOKPeqbz4VomXJdWQ-1", "X-Mimecast-MFC-AGG-ID": "jsNwypOKPeqbz4VomXJdWQ_1775614602", "From": "Eric Blake <eblake@redhat.com>", "To": "qemu-devel@nongnu.org", "Cc": "Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,\n Pierrick Bouvier <pierrick.bouvier@linaro.org>,\n Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>,\n qemu-block@nongnu.org (open list:Network Block Dev...)", "Subject": "[PATCH] qemu-nbd: Support -s and -l at the same time", "Date": "Tue, 7 Apr 2026 21:16:33 -0500", "Message-ID": "<20260408021636.794794-2-eblake@redhat.com>", "MIME-Version": "1.0", "Content-type": "text/plain", "Content-Transfer-Encoding": "8bit", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.93", "Received-SPF": "pass client-ip=170.10.133.124; envelope-from=eblake@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com", "X-Spam_score_int": "-25", "X-Spam_score": "-2.6", "X-Spam_bar": "--", "X-Spam_report": "(-2.6 / 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_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": "qemu-nbd already has the ability to wrap a read-write layer on top of\nthe export of a read-only image (-s) and the ability to export an\ninternal snapshot rather than the main image in a qcow2 file (-l\nSNAPID). But it gave a confusing error message when trying to mix the\ntwo, because the snapshot overlay created first no longer has access\nto the internal snapshots of the image being wrapped.\n\nWIth a bit of finesse, this useful scenario is now supported.\n\nhttps://gitlab.com/qemu-project/qemu/-/work_items/159\n\nSigned-off-by: Eric Blake <eblake@redhat.com>\n---\n docs/tools/qemu-nbd.rst | 7 +-\n qemu-nbd.c | 20 ++++-\n tests/qemu-iotests/tests/qemu-nbd-snapshots | 79 +++++++++++++++++++\n .../qemu-iotests/tests/qemu-nbd-snapshots.out | 34 ++++++++\n 4 files changed, 134 insertions(+), 6 deletions(-)\n create mode 100755 tests/qemu-iotests/tests/qemu-nbd-snapshots\n create mode 100644 tests/qemu-iotests/tests/qemu-nbd-snapshots.out", "diff": "diff --git a/docs/tools/qemu-nbd.rst b/docs/tools/qemu-nbd.rst\nindex f82ea5fd77b..336b4aa46e7 100644\n--- a/docs/tools/qemu-nbd.rst\n+++ b/docs/tools/qemu-nbd.rst\n@@ -95,9 +95,10 @@ driver options if :option:`--image-opts` is specified.\n\n .. option:: -l, --load-snapshot=SNAPSHOT_PARAM\n\n- Load an internal snapshot inside *filename* and export it\n- as an read-only device, SNAPSHOT_PARAM format is\n- ``snapshot.id=[ID],snapshot.name=[NAME]`` or ``[ID_OR_NAME]``\n+ Load an internal snapshot inside *filename* and export it.\n+ SNAPSHOT_PARAM format is ``snapshot.id=[ID],snapshot.name=[NAME]``\n+ or ``[ID_OR_NAME]``. The export is read-only unless ``-s`` is also\n+ in use.\n\n .. option:: --cache=CACHE\n\ndiff --git a/qemu-nbd.c b/qemu-nbd.c\nindex ed5895861bb..128486a0ec2 100644\n--- a/qemu-nbd.c\n+++ b/qemu-nbd.c\n@@ -534,6 +534,7 @@ int main(int argc, char **argv)\n {\n BlockBackend *blk;\n BlockDriverState *bs;\n+ BlockDriverState *orig_bs;\n uint64_t dev_offset = 0;\n bool readonly = false;\n bool disconnect = false;\n@@ -716,7 +717,7 @@ int main(int argc, char **argv)\n } else {\n sn_id_or_name = optarg;\n }\n- /* fall through */\n+ break;\n case 'r':\n readonly = true;\n flags &= ~BDRV_O_RDWR;\n@@ -1110,6 +1111,15 @@ int main(int argc, char **argv)\n bdrv_init();\n atexit(qemu_nbd_shutdown);\n\n+ /*\n+ * -s and -l can be used together to create read-write wrapper\n+ * around an internal snapshot. Otherwise, -l in isolation implies\n+ * read-only.\n+ */\n+ if ((sn_opts || sn_id_or_name) && (flags & BDRV_O_SNAPSHOT) == 0) {\n+ readonly = true;\n+ flags &= ~BDRV_O_RDWR;\n+ }\n opts.srcpath = argv[optind];\n if (imageOpts) {\n QemuOpts *o;\n@@ -1155,13 +1165,17 @@ int main(int argc, char **argv)\n\n blk_set_enable_write_cache(blk, !writethrough);\n\n+ orig_bs = bs;\n+ if (flags & BDRV_O_SNAPSHOT) {\n+ orig_bs = bs->backing->bs;\n+ }\n if (sn_opts) {\n- ret = bdrv_snapshot_load_tmp(bs,\n+ ret = bdrv_snapshot_load_tmp(orig_bs,\n qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID),\n qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME),\n &local_err);\n } else if (sn_id_or_name) {\n- ret = bdrv_snapshot_load_tmp_by_id_or_name(bs, sn_id_or_name,\n+ ret = bdrv_snapshot_load_tmp_by_id_or_name(orig_bs, sn_id_or_name,\n &local_err);\n }\n if (ret < 0) {\ndiff --git a/tests/qemu-iotests/tests/qemu-nbd-snapshots b/tests/qemu-iotests/tests/qemu-nbd-snapshots\nnew file mode 100755\nindex 00000000000..de405e43720\n--- /dev/null\n+++ b/tests/qemu-iotests/tests/qemu-nbd-snapshots\n@@ -0,0 +1,79 @@\n+#!/usr/bin/env bash\n+# group: rw quick\n+#\n+# Test qemu-nbd snapshot handling\n+#\n+# Copyright (C) Red Hat, Inc.\n+#\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+\n+seq=\"$(basename $0)\"\n+echo \"QA output created by $seq\"\n+\n+status=1 # failure is the default!\n+\n+_cleanup()\n+{\n+ _cleanup_test_img\n+ nbd_server_stop\n+}\n+trap \"_cleanup; exit \\$status\" 0 1 2 3 15\n+\n+# get standard environment, filters and checks\n+cd ..\n+. ./common.rc\n+. ./common.filter\n+. ./common.nbd\n+\n+_supported_fmt qcow2\n+_supported_proto file\n+_supported_os Linux\n+_require_command QEMU_NBD\n+\n+echo\n+echo \"=== Initial image setup ===\"\n+echo\n+\n+# Create qcow2 image with one internal snapshot\n+_make_test_img 10M\n+$QEMU_IO -c 'w -P 1 3M 1M' -f $IMGFMT \"$TEST_IMG\" | _filter_qemu_io\n+$QEMU_IMG snapshot -c snap -f $IMGFMT \"$TEST_IMG\" | _filter_qemu_img\n+$QEMU_IO -c 'w -P 2 3M 1M' -f $IMGFMT \"$TEST_IMG\" | _filter_qemu_io\n+\n+echo\n+echo \"=== Main image in snapshot mode ===\"\n+echo\n+\n+nbd_server_start_unix_socket -s -f qcow2 \"$TEST_IMG\"\n+$QEMU_IO -c 'r -P 2 3M 1M' -c 'w -P 3 3M 1M' -f raw \\\n+ nbd:unix:$nbd_unix_socket | _filter_qemu_io\n+nbd_server_stop\n+\n+echo\n+echo \"=== Read-only snapshot access ===\"\n+echo\n+\n+nbd_server_start_unix_socket -l snap -f qcow2 \"$TEST_IMG\"\n+$QEMU_IO -r -c 'r -P 1 3M 1M' -f raw \\\n+ nbd:unix:$nbd_unix_socket | _filter_qemu_io\n+nbd_server_stop\n+\n+echo\n+echo \"=== Combine -s and -l for read-write internal snapshot access ===\"\n+echo\n+\n+nbd_server_start_unix_socket -s -l snap -f qcow2 \"$TEST_IMG\"\n+$QEMU_IO -c 'r -P 1 3M 1M' -c 'w -P 3 3M 1M' -f raw \\\n+ nbd:unix:$nbd_unix_socket | _filter_qemu_io\n+nbd_server_stop\n+\n+echo\n+echo \"=== Check that original image is unchanged ===\"\n+echo\n+\n+$QEMU_IO -c 'r -P 2 3M 1M' -f $IMGFMT \"$TEST_IMG\" | _filter_qemu_io\n+\n+# success, all done\n+echo '*** done'\n+rm -f $seq.full\n+status=0\ndiff --git a/tests/qemu-iotests/tests/qemu-nbd-snapshots.out b/tests/qemu-iotests/tests/qemu-nbd-snapshots.out\nnew file mode 100644\nindex 00000000000..6bce9d90253\n--- /dev/null\n+++ b/tests/qemu-iotests/tests/qemu-nbd-snapshots.out\n@@ -0,0 +1,34 @@\n+QA output created by qemu-nbd-snapshots\n+\n+=== Initial image setup ===\n+\n+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=10485760\n+wrote 1048576/1048576 bytes at offset 3145728\n+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+wrote 1048576/1048576 bytes at offset 3145728\n+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+\n+=== Main image in snapshot mode ===\n+\n+read 1048576/1048576 bytes at offset 3145728\n+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+wrote 1048576/1048576 bytes at offset 3145728\n+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+\n+=== Read-only snapshot access ===\n+\n+read 1048576/1048576 bytes at offset 3145728\n+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+\n+=== Combine -s and -l for read-write internal snapshot access ===\n+\n+read 1048576/1048576 bytes at offset 3145728\n+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+wrote 1048576/1048576 bytes at offset 3145728\n+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+\n+=== Check that original image is unchanged ===\n+\n+read 1048576/1048576 bytes at offset 3145728\n+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)\n+*** done\n", "prefixes": [] }