From nobody Sun Oct 5 19:25:04 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1580994493933653.8258874599047; Thu, 6 Feb 2020 05:08:13 -0800 (PST) Received: from localhost ([::1]:38580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1izgtA-00021J-Gm for importer@patchew.org; Thu, 06 Feb 2020 08:08:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58147) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1izge6-00051A-SS for qemu-devel@nongnu.org; Thu, 06 Feb 2020 07:52:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1izge4-00042R-EP for qemu-devel@nongnu.org; Thu, 06 Feb 2020 07:52:38 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:42585 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1izge4-00040z-Au for qemu-devel@nongnu.org; Thu, 06 Feb 2020 07:52:36 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-151-UcY89iJVPkG_gFi0wDm6yg-1; Thu, 06 Feb 2020 07:52:30 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A6216800D54; Thu, 6 Feb 2020 12:52:29 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-181.phx2.redhat.com [10.3.116.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id 026EA5DA7C; Thu, 6 Feb 2020 12:52:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580993554; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q7wux+wTHX0FdahFdVQMvw9ct0piSALKAkVkc8PnqIc=; b=JagYwE+5nhxtQ2+VDyhdQ/RE+AO4+sdkbDktXwpRmoBJsZoBKHLArw7TWja66o7wixvTPt B1Ut9X78dZPCtAlq0VF6qB8jnkDvt7H0WdxsYJGZNC7LpZ6yY/qtL8Vax+FfH+kmiJOtjd 6NvDBcW9CSVcJJaMWiaZFDHov8crNlk= From: Eric Blake To: qemu-devel@nongnu.org Subject: [PULL 1/3] nbd: Allow description when creating NBD blockdev Date: Thu, 6 Feb 2020 06:52:22 -0600 Message-Id: <20200206125224.3819972-2-eblake@redhat.com> In-Reply-To: <20200206125224.3819972-1-eblake@redhat.com> References: <20200206125224.3819972-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: UcY89iJVPkG_gFi0wDm6yg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , "open list:Network Block Dev..." , Markus Armbruster , Max Reitz , Maxim Levitsky , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Allow blockdevs to match the feature already present in qemu-nbd -D. Enhance iotest 223 to cover it. Signed-off-by: Eric Blake Reviewed-by: Maxim Levitsky Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20191114024635.11363-5-eblake@redhat.com> --- blockdev-nbd.c | 9 ++++++++- monitor/hmp-cmds.c | 4 ++-- qapi/block.json | 9 ++++++--- tests/qemu-iotests/223 | 2 +- tests/qemu-iotests/223.out | 6 ++++-- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 8c20baa4a4b9..de2f2ff71320 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -144,6 +144,7 @@ void qmp_nbd_server_start(SocketAddressLegacy *addr, } void qmp_nbd_server_add(const char *device, bool has_name, const char *nam= e, + bool has_description, const char *description, bool has_writable, bool writable, bool has_bitmap, const char *bitmap, Error **errp) { @@ -167,6 +168,11 @@ void qmp_nbd_server_add(const char *device, bool has_n= ame, const char *name, return; } + if (has_description && strlen(description) > NBD_MAX_STRING_SIZE) { + error_setg(errp, "description '%s' too long", description); + return; + } + if (nbd_export_find(name)) { error_setg(errp, "NBD server already has export named '%s'", name); return; @@ -195,7 +201,8 @@ void qmp_nbd_server_add(const char *device, bool has_na= me, const char *name, writable =3D false; } - exp =3D nbd_export_new(bs, 0, len, name, NULL, bitmap, !writable, !wri= table, + exp =3D nbd_export_new(bs, 0, len, name, description, bitmap, + !writable, !writable, NULL, false, on_eject_blk, errp); if (!exp) { goto out; diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index d0e0af893a66..558fe06b8f7c 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -2351,7 +2351,7 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *= qdict) continue; } - qmp_nbd_server_add(info->value->device, false, NULL, + qmp_nbd_server_add(info->value->device, false, NULL, false, NULL, true, writable, false, NULL, &local_err); if (local_err !=3D NULL) { @@ -2373,7 +2373,7 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qd= ict) bool writable =3D qdict_get_try_bool(qdict, "writable", false); Error *local_err =3D NULL; - qmp_nbd_server_add(device, !!name, name, true, writable, + qmp_nbd_server_add(device, !!name, name, false, NULL, true, writable, false, NULL, &local_err); hmp_handle_error(mon, local_err); } diff --git a/qapi/block.json b/qapi/block.json index 145c268bb646..7898104dae42 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -250,9 +250,12 @@ # @name: Export name. If unspecified, the @device parameter is used as the # export name. (Since 2.12) # +# @description: Free-form description of the export, up to 4096 bytes. +# (Since 5.0) +# # @writable: Whether clients should be able to write to the device via the # NBD connection (default false). - +# # @bitmap: Also export the dirty bitmap reachable from @device, so the # NBD client can use NBD_OPT_SET_META_CONTEXT with # "qemu:dirty-bitmap:NAME" to inspect the bitmap. (since 4.0) @@ -263,8 +266,8 @@ # Since: 1.3.0 ## { 'command': 'nbd-server-add', - 'data': {'device': 'str', '*name': 'str', '*writable': 'bool', - '*bitmap': 'str' } } + 'data': {'device': 'str', '*name': 'str', '*description': 'str', + '*writable': 'bool', '*bitmap': 'str' } } ## # @NbdServerRemoveMode: diff --git a/tests/qemu-iotests/223 b/tests/qemu-iotests/223 index ea69cd4b8b5e..56fbc5fb09a0 100755 --- a/tests/qemu-iotests/223 +++ b/tests/qemu-iotests/223 @@ -153,7 +153,7 @@ _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add= ", "bitmap":"b3"}}' "error" # Missing bitmap _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add", "arguments":{"device":"n", "name":"n2", "writable":true, - "bitmap":"b2"}}' "return" + "description":"some text", "bitmap":"b2"}}' "return" $QEMU_NBD_PROG -L -k "$SOCK_DIR/nbd" echo diff --git a/tests/qemu-iotests/223.out b/tests/qemu-iotests/223.out index f17559880268..80c0cf65095b 100644 --- a/tests/qemu-iotests/223.out +++ b/tests/qemu-iotests/223.out @@ -50,7 +50,7 @@ exports available: 0 {"error": {"class": "GenericError", "desc": "Enabled bitmap 'b2' incompati= ble with readonly export"}} {"execute":"nbd-server-add", "arguments":{"device":"n", "name":"n2", "bitm= ap":"b3"}} {"error": {"class": "GenericError", "desc": "Bitmap 'b3' is not found"}} -{"execute":"nbd-server-add", "arguments":{"device":"n", "name":"n2", "writ= able":true, "bitmap":"b2"}} +{"execute":"nbd-server-add", "arguments":{"device":"n", "name":"n2", "writ= able":true, "description":"some text", "bitmap":"b2"}} {"return": {}} exports available: 2 export: 'n' @@ -63,6 +63,7 @@ exports available: 2 base:allocation qemu:dirty-bitmap:b export: 'n2' + description: some text size: 4194304 flags: 0xced ( flush fua trim zeroes df cache fast-zero ) min block: 1 @@ -130,7 +131,7 @@ exports available: 0 {"error": {"class": "GenericError", "desc": "Enabled bitmap 'b2' incompati= ble with readonly export"}} {"execute":"nbd-server-add", "arguments":{"device":"n", "name":"n2", "bitm= ap":"b3"}} {"error": {"class": "GenericError", "desc": "Bitmap 'b3' is not found"}} -{"execute":"nbd-server-add", "arguments":{"device":"n", "name":"n2", "writ= able":true, "bitmap":"b2"}} +{"execute":"nbd-server-add", "arguments":{"device":"n", "name":"n2", "writ= able":true, "description":"some text", "bitmap":"b2"}} {"return": {}} exports available: 2 export: 'n' @@ -143,6 +144,7 @@ exports available: 2 base:allocation qemu:dirty-bitmap:b export: 'n2' + description: some text size: 4194304 flags: 0xced ( flush fua trim zeroes df cache fast-zero ) min block: 1 --=20 2.24.1 From nobody Sun Oct 5 19:25:04 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580993564486249.6228847315831; Thu, 6 Feb 2020 04:52:44 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-r4OLHulAMyGQmeiSKiN6pQ-1; Thu, 06 Feb 2020 07:52:40 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9C3A81005513; Thu, 6 Feb 2020 12:52:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ECDE61001B09; Thu, 6 Feb 2020 12:52:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8505B18089C8; Thu, 6 Feb 2020 12:52:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 016CqWOG020428 for ; Thu, 6 Feb 2020 07:52:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id B3ABC5DA7D; Thu, 6 Feb 2020 12:52:32 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-181.phx2.redhat.com [10.3.116.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2AFB5DA7C; Thu, 6 Feb 2020 12:52:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580993563; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=j1xHCl3bAQTKcUDUesP+Yco3K4wfG9fRT60EVRDWWEY=; b=FDSKxKig9wWm2/bG2u1ofjOnrffQ1eWx/gjkgXFTgtGEu/WKOHwU1juW2kMYyYpgP6YvZi O5jQW9of2DhMFmxTT3uW5+84uVFh/WvCD6lAXmpCq4xqINd7zmRTGpBrAurb/lwb7tN9Xf wiIXpj0mYWoHBYBfAcnLlS9HQCVakJI= From: Eric Blake To: qemu-devel@nongnu.org Subject: [PULL 2/3] docs: Fix typo in qemu-nbd -P replacement Date: Thu, 6 Feb 2020 06:52:23 -0600 Message-Id: <20200206125224.3819972-3-eblake@redhat.com> In-Reply-To: <20200206125224.3819972-1-eblake@redhat.com> References: <20200206125224.3819972-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: "reviewer:Incompatible changes" , =?UTF-8?q?J=C3=A1n=20Tomko?= , Max Reitz X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: r4OLHulAMyGQmeiSKiN6pQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The suggested replacement for the deprecated 'qemu-nbd -P' refers to 'file.backing.opt' instead of 'file.file.opt'; using the example verbatim results in: qemu-nbd: Failed to blk_new_open 'driver=3Draw,offset=3D1m,size=3D100m,file= .driver=3Dqcow2,file.backing.driver=3Dfile,file.backing.filename=3Dfile4': = A block device must be specified for "file" Correct this text, prior to actually finishing the deprecation process. Fixes: 0ae2d54645eb Reported-by: Max Reitz Signed-off-by: Eric Blake Message-Id: <20200123164650.1741798-2-eblake@redhat.com> Reviewed-by: J=C3=A1n Tomko --- qemu-deprecated.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index ea3e10bde398..c8ee68a4663a 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -329,7 +329,7 @@ top of any other existing blockdev. For example, if par= tition 1 is can be rewritten as: -@code{qemu-nbd -t --image-opts driver=3Draw,offset=3D1M,size=3D100M,file.d= river=3Dqcow2,file.backing.driver=3Dfile,file.backing.filename=3Dfile.qcow2} +@code{qemu-nbd -t --image-opts driver=3Draw,offset=3D1M,size=3D100M,file.d= river=3Dqcow2,file.file.driver=3Dfile,file.file.filename=3Dfile.qcow2} Alternatively, the @code{nbdkit} project provides a more powerful partition filter on top of its nbd plugin, which can be used to select --=20 2.24.1 From nobody Sun Oct 5 19:25:04 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580993564895796.2664806893132; Thu, 6 Feb 2020 04:52:44 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-333-RzIWR3X6NaadIAIxCXyFhw-1; Thu, 06 Feb 2020 07:52:41 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BA4F48C2FE0; Thu, 6 Feb 2020 12:52:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8ECA460BF7; Thu, 6 Feb 2020 12:52:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 70F2D866A5; Thu, 6 Feb 2020 12:52:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 016CqXW2020433 for ; Thu, 6 Feb 2020 07:52:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 554AA5DA7D; Thu, 6 Feb 2020 12:52:33 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-181.phx2.redhat.com [10.3.116.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id E94C65DA7C; Thu, 6 Feb 2020 12:52:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580993563; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Ylt9B6KkolSopSPg4W926X84sQkXAhpxVfm0bYj9/qk=; b=N81EzHTYk3eFmbe+4Lw+Fe5ZCnwijuzpy7cXbGgay+MYyB3IwyYvTiGcOGDrI4/qB4SsCA uc7/O+b6FtAzUZuNMhMs6cOCRgAyV715kacINlTedcyt1vrIiQfAQH2LnrkqDPjvrNdA2f HMjUGBNs5PmHtXH9T41zZrtFMnhhLyw= From: Eric Blake To: qemu-devel@nongnu.org Subject: [PULL 3/3] qemu-nbd: Removed deprecated --partition option Date: Thu, 6 Feb 2020 06:52:24 -0600 Message-Id: <20200206125224.3819972-4-eblake@redhat.com> In-Reply-To: <20200206125224.3819972-1-eblake@redhat.com> References: <20200206125224.3819972-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: "reviewer:Incompatible changes" , =?UTF-8?q?J=C3=A1n=20Tomko?= , "open list:Network Block Dev..." X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: RzIWR3X6NaadIAIxCXyFhw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The option was deprecated in 4.0.0 (commit 0ae2d546); it's now been long enough with no complaints to follow through with that process. Signed-off-by: Eric Blake Message-Id: <20200123164650.1741798-3-eblake@redhat.com> Reviewed-by: J=C3=A1n Tomko --- docs/interop/qemu-nbd.rst | 15 ++--- qemu-deprecated.texi | 49 ++++++-------- qemu-nbd.c | 133 +------------------------------------- 3 files changed, 24 insertions(+), 173 deletions(-) diff --git a/docs/interop/qemu-nbd.rst b/docs/interop/qemu-nbd.rst index df7b6b9d0d60..e54840310056 100644 --- a/docs/interop/qemu-nbd.rst +++ b/docs/interop/qemu-nbd.rst @@ -72,13 +72,6 @@ driver options if ``--image-opts`` is specified. Export the disk as read-only. -.. option:: -P, --partition=3DNUM - - Deprecated: Only expose MBR partition *NUM*. Understands physical - partitions 1-4 and logical partition 5. New code should instead use - :option:`--image-opts` with the raw driver wrapping a subset of the - original image. - .. option:: -B, --bitmap=3DNAME If *filename* has a qcow2 persistent bitmap *NAME*, expose @@ -224,14 +217,14 @@ a 1 megabyte subset of a raw file, using the export n= ame 'subset': -t -x subset -p 10810 \ --image-opts driver=3Draw,offset=3D1M,size=3D1M,file.driver=3Dfile,fil= e.filename=3Dfile.raw -Serve a read-only copy of just the first MBR partition of a guest -image over a Unix socket with as many as 5 simultaneous readers, with -a persistent process forked as a daemon: +Serve a read-only copy of a guest image over a Unix socket with as +many as 5 simultaneous readers, with a persistent process forked as a +daemon: :: qemu-nbd --fork --persistent --shared=3D5 --socket=3D/path/to/sock \ - --partition=3D1 --read-only --format=3Dqcow2 file.qcow2 + --read-only --format=3Dqcow2 file.qcow2 Expose the guest-visible contents of a qcow2 file via a block device /dev/nbd0 (and possibly creating /dev/nbd0p1 and friends for diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index c8ee68a4663a..2634e00ec826 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -313,37 +313,6 @@ The above, converted to the current supported format: @section Related binaries -@subsection qemu-nbd --partition (since 4.0.0) - -The ``qemu-nbd --partition $digit'' code (also spelled @option{-P}) -can only handle MBR partitions, and has never correctly handled -logical partitions beyond partition 5. If you know the offset and -length of the partition (perhaps by using @code{sfdisk} within the -guest), you can achieve the effect of exporting just that subset of -the disk by use of the @option{--image-opts} option with a raw -blockdev using the @code{offset} and @code{size} parameters layered on -top of any other existing blockdev. For example, if partition 1 is -100MiB long starting at 1MiB, the old command: - -@code{qemu-nbd -t -P 1 -f qcow2 file.qcow2} - -can be rewritten as: - -@code{qemu-nbd -t --image-opts driver=3Draw,offset=3D1M,size=3D100M,file.d= river=3Dqcow2,file.file.driver=3Dfile,file.file.filename=3Dfile.qcow2} - -Alternatively, the @code{nbdkit} project provides a more powerful -partition filter on top of its nbd plugin, which can be used to select -an arbitrary MBR or GPT partition on top of any other full-image NBD -export. Using this to rewrite the above example results in: - -@code{qemu-nbd -t -k /tmp/sock -f qcow2 file.qcow2 &} -@code{nbdkit -f --filter=3Dpartition nbd socket=3D/tmp/sock partition=3D1} - -Note that if you are exposing the export via /dev/nbd0, it is easier -to just export the entire image and then mount only /dev/nbd0p1 than -it is to reinvoke @command{qemu-nbd -c /dev/nbd0} limited to just a -subset of the image. - @subsection qemu-img convert -n -o (since 4.2.0) All options specified in @option{-o} are image creation options, so @@ -400,3 +369,21 @@ trouble after a recent upgrade. The "autoload" parameter has been ignored since 2.12.0. All bitmaps are automatically loaded from qcow2 images. + +@section Related binaries + +@subsection qemu-nbd --partition (removed in 5.0.0) + +The ``qemu-nbd --partition $digit'' code (also spelled @option{-P}) +could only handle MBR partitions, and never correctly handled logical +partitions beyond partition 5. Exporting a partition can still be +done by utilizing the @option{--image-opts} option with a raw blockdev +using the @code{offset} and @code{size} parameters layered on top of +any other existing blockdev. For example, if partition 1 is 100MiB +long starting at 1MiB, the old command: + +@code{qemu-nbd -t -P 1 -f qcow2 file.qcow2} + +can be rewritten as: + +@code{qemu-nbd -t --image-opts driver=3Draw,offset=3D1M,size=3D100M,file.d= river=3Dqcow2,file.file.driver=3Dfile,file.file.filename=3Dfile.qcow2} diff --git a/qemu-nbd.c b/qemu-nbd.c index db29a0d0ed25..4aa005004ebd 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -100,7 +100,6 @@ static void usage(const char *name) "\n" "Exposing part of the image:\n" " -o, --offset=3DOFFSET offset into the image\n" -" -P, --partition=3DNUM only expose partition NUM\n" " -B, --bitmap=3DNAME expose a persistent dirty bitmap\n" "\n" "General purpose options:\n" @@ -156,96 +155,6 @@ QEMU_COPYRIGHT "\n" , name); } -struct partition_record -{ - uint8_t bootable; - uint8_t start_head; - uint32_t start_cylinder; - uint8_t start_sector; - uint8_t system; - uint8_t end_head; - uint8_t end_cylinder; - uint8_t end_sector; - uint32_t start_sector_abs; - uint32_t nb_sectors_abs; -}; - -static void read_partition(uint8_t *p, struct partition_record *r) -{ - r->bootable =3D p[0]; - r->start_head =3D p[1]; - r->start_cylinder =3D p[3] | ((p[2] << 2) & 0x0300); - r->start_sector =3D p[2] & 0x3f; - r->system =3D p[4]; - r->end_head =3D p[5]; - r->end_cylinder =3D p[7] | ((p[6] << 2) & 0x300); - r->end_sector =3D p[6] & 0x3f; - - r->start_sector_abs =3D ldl_le_p(p + 8); - r->nb_sectors_abs =3D ldl_le_p(p + 12); -} - -static int find_partition(BlockBackend *blk, int partition, - uint64_t *offset, uint64_t *size) -{ - struct partition_record mbr[4]; - uint8_t data[MBR_SIZE]; - int i; - int ext_partnum =3D 4; - int ret; - - ret =3D blk_pread(blk, 0, data, sizeof(data)); - if (ret < 0) { - error_report("error while reading: %s", strerror(-ret)); - exit(EXIT_FAILURE); - } - - if (data[510] !=3D 0x55 || data[511] !=3D 0xaa) { - return -EINVAL; - } - - for (i =3D 0; i < 4; i++) { - read_partition(&data[446 + 16 * i], &mbr[i]); - - if (!mbr[i].system || !mbr[i].nb_sectors_abs) { - continue; - } - - if (mbr[i].system =3D=3D 0xF || mbr[i].system =3D=3D 0x5) { - struct partition_record ext[4]; - uint8_t data1[MBR_SIZE]; - int j; - - ret =3D blk_pread(blk, mbr[i].start_sector_abs * MBR_SIZE, - data1, sizeof(data1)); - if (ret < 0) { - error_report("error while reading: %s", strerror(-ret)); - exit(EXIT_FAILURE); - } - - for (j =3D 0; j < 4; j++) { - read_partition(&data1[446 + 16 * j], &ext[j]); - if (!ext[j].system || !ext[j].nb_sectors_abs) { - continue; - } - - if ((ext_partnum + j + 1) =3D=3D partition) { - *offset =3D (uint64_t)ext[j].start_sector_abs << 9; - *size =3D (uint64_t)ext[j].nb_sectors_abs << 9; - return 0; - } - } - ext_partnum +=3D 4; - } else if ((i + 1) =3D=3D partition) { - *offset =3D (uint64_t)mbr[i].start_sector_abs << 9; - *size =3D (uint64_t)mbr[i].nb_sectors_abs << 9; - return 0; - } - } - - return -ENOENT; -} - static void termsig_handler(int signum) { atomic_cmpxchg(&state, RUNNING, TERMINATE); @@ -617,7 +526,7 @@ int main(int argc, char **argv) int64_t fd_size; QemuOpts *sn_opts =3D NULL; const char *sn_id_or_name =3D NULL; - const char *sopt =3D "hVb:o:p:rsnP:c:dvk:e:f:tl:x:T:D:B:L"; + const char *sopt =3D "hVb:o:p:rsnc:dvk:e:f:tl:x:T:D:B:L"; struct option lopt[] =3D { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, @@ -626,7 +535,6 @@ int main(int argc, char **argv) { "socket", required_argument, NULL, 'k' }, { "offset", required_argument, NULL, 'o' }, { "read-only", no_argument, NULL, 'r' }, - { "partition", required_argument, NULL, 'P' }, { "bitmap", required_argument, NULL, 'B' }, { "connect", required_argument, NULL, 'c' }, { "disconnect", no_argument, NULL, 'd' }, @@ -657,7 +565,6 @@ int main(int argc, char **argv) int ch; int opt_ind =3D 0; int flags =3D BDRV_O_RDWR; - int partition =3D 0; int ret =3D 0; bool seen_cache =3D false; bool seen_discard =3D false; @@ -789,15 +696,6 @@ int main(int argc, char **argv) readonly =3D true; flags &=3D ~BDRV_O_RDWR; break; - case 'P': - warn_report("The '-P' option is deprecated; use --image-opts w= ith " - "a raw device wrapper for subset exports instead"); - if (qemu_strtoi(optarg, NULL, 0, &partition) < 0 || - partition < 1 || partition > 8) { - error_report("Invalid partition '%s'", optarg); - exit(EXIT_FAILURE); - } - break; case 'B': bitmap =3D optarg; break; @@ -894,7 +792,7 @@ int main(int argc, char **argv) error_report("List mode is incompatible with a file name"); exit(EXIT_FAILURE); } - if (export_name || export_description || dev_offset || partition || + if (export_name || export_description || dev_offset || device || disconnect || fmt || sn_id_or_name || bitmap || seen_aio || seen_discard || seen_cache) { error_report("List mode is incompatible with per-device settin= gs"); @@ -1158,33 +1056,6 @@ int main(int argc, char **argv) } fd_size -=3D dev_offset; - if (partition) { - uint64_t limit; - - if (dev_offset) { - error_report("Cannot request partition and offset together"); - exit(EXIT_FAILURE); - } - ret =3D find_partition(blk, partition, &dev_offset, &limit); - if (ret < 0) { - error_report("Could not find partition %d: %s", partition, - strerror(-ret)); - exit(EXIT_FAILURE); - } - /* - * MBR partition limits are (32-bit << 9); this assert lets - * the compiler know that we can't overflow 64 bits. - */ - assert(dev_offset + limit >=3D dev_offset); - if (dev_offset + limit > fd_size) { - error_report("Discovered partition %d at offset %" PRIu64 - " size %" PRIu64 ", but size exceeds file length = %" - PRId64, partition, dev_offset, limit, fd_size); - exit(EXIT_FAILURE); - } - fd_size =3D limit; - } - export =3D nbd_export_new(bs, dev_offset, fd_size, export_name, export_description, bitmap, readonly, shared >= 1, nbd_export_closed, writethrough, NULL, --=20 2.24.1