From nobody Mon Apr 29 19:00:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538587280562195.8692578987724; Wed, 3 Oct 2018 10:21:20 -0700 (PDT) Received: from localhost ([::1]:50704 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7kpk-0000jE-09 for importer@patchew.org; Wed, 03 Oct 2018 13:21:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7koc-00008b-1W for qemu-devel@nongnu.org; Wed, 03 Oct 2018 13:20:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7koa-0001Vo-WB for qemu-devel@nongnu.org; Wed, 03 Oct 2018 13:20:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42442) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g7koV-0001TN-Ku; Wed, 03 Oct 2018 13:19:55 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A806E308213D; Wed, 3 Oct 2018 17:19:54 +0000 (UTC) Received: from red.redhat.com (ovpn-126-73.rdu2.redhat.com [10.10.126.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 572CD2010D7A; Wed, 3 Oct 2018 17:19:49 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 3 Oct 2018 12:19:47 -0500 Message-Id: <20181003171947.588103-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 03 Oct 2018 17:19:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] nbd: Flip qemu-nbd to prefer newstyle; add -O for old behavior X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , vsementsov@virtuozzo.com, "open list:Network Block Dev..." Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Oldstyle NBD negotiation cannot perform any of the extensions that we have recently been relying on. While you can always pass -x "" to get newstyle negotiation, these days, it is better to just default to newstyle (with an empty export name) and fall back to oldstyle only on an explicit request. For comparison: nbdkit 1.3 switched its default to newstyle (Jan 2018): https://github.com/libguestfs/nbdkit/commit/b2a8aecc https://github.com/libguestfs/nbdkit/commit/8158e773 nbd 3.10 dropped oldstyle long ago (Mar 2015): https://github.com/NetworkBlockDevice/nbd/commit/36940193 Signed-off-by: Eric Blake --- qemu-nbd.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/qemu-nbd.c b/qemu-nbd.c index 51b9d38c727..8571a4f93d8 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -86,6 +86,7 @@ static void usage(const char *name) " -v, --verbose display extra debugging information\n" " -x, --export-name=3DNAME expose export by name\n" " -D, --description=3DTEXT with -x, also export a human-readable descr= iption\n" +" -O, --oldstyle force oldstyle negotiation\n" "\n" "Exposing part of the image:\n" " -o, --offset=3DOFFSET offset into the image\n" @@ -529,6 +530,7 @@ int main(int argc, char **argv) { "object", required_argument, NULL, QEMU_NBD_OPT_OBJECT }, { "export-name", required_argument, NULL, 'x' }, { "description", required_argument, NULL, 'D' }, + { "oldstyle", no_argument, NULL, 'O' }, { "tls-creds", required_argument, NULL, QEMU_NBD_OPT_TLSCREDS }, { "image-opts", no_argument, NULL, QEMU_NBD_OPT_IMAGE_OPTS }, { "trace", required_argument, NULL, 'T' }, @@ -551,6 +553,7 @@ int main(int argc, char **argv) QDict *options =3D NULL; const char *export_name =3D NULL; const char *export_description =3D NULL; + bool oldstyle =3D false; const char *tlscredsid =3D NULL; bool imageOpts =3D false; bool writethrough =3D true; @@ -723,6 +726,9 @@ int main(int argc, char **argv) case 'D': export_description =3D optarg; break; + case 'O': + oldstyle =3D true; + break; case 'v': verbose =3D 1; break; @@ -799,7 +805,16 @@ int main(int argc, char **argv) } } + if (!oldstyle && !export_name) { + /* Set the default NBD protocol export name, to favor new style. */ + export_name =3D ""; + } + if (tlscredsid) { + if (oldstyle) { + error_report("TLS is incompatible with oldstyle"); + exit(EXIT_FAILURE); + } if (sockpath) { error_report("TLS is only supported with IPv4/IPv6"); exit(EXIT_FAILURE); @@ -808,11 +823,6 @@ int main(int argc, char **argv) error_report("TLS is not supported with a host device"); exit(EXIT_FAILURE); } - if (!export_name) { - /* Set the default NBD protocol export name, since - * we *must* use new style protocol for TLS */ - export_name =3D ""; - } tlscreds =3D nbd_get_tls_creds(tlscredsid, &local_err); if (local_err) { error_report("Failed to get TLS creds %s", @@ -1013,13 +1023,14 @@ int main(int argc, char **argv) error_report_err(local_err); exit(EXIT_FAILURE); } + if (oldstyle && (export_name || export_description)) { + error_report("oldstyle negotiation cannot set export details"); + exit(EXIT_FAILURE); + } if (export_name) { nbd_export_set_name(exp, export_name); nbd_export_set_description(exp, export_description); newproto =3D true; - } else if (export_description) { - error_report("Export description requires an export name"); - exit(EXIT_FAILURE); } if (device) { --=20 2.17.1