From nobody Sun Oct 5 17:26:05 2025 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 1519675491682753.0655048836478; Mon, 26 Feb 2018 12:04:51 -0800 (PST) Received: from localhost ([::1]:60143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqMA1-0007JO-Mn for importer@patchew.org; Mon, 26 Feb 2018 12:01:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqM5r-000453-26 for qemu-devel@nongnu.org; Mon, 26 Feb 2018 11:57:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqM5p-0008Ow-M9 for qemu-devel@nongnu.org; Mon, 26 Feb 2018 11:57:39 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55220 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eqM5k-0008Lb-MO; Mon, 26 Feb 2018 11:57:32 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F2AB81AEE3B; Mon, 26 Feb 2018 16:57:30 +0000 (UTC) Received: from red.redhat.com (ovpn-122-122.rdu2.redhat.com [10.10.122.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BC45111DCF7; Mon, 26 Feb 2018 16:57:29 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Mon, 26 Feb 2018 10:57:23 -0600 Message-Id: <20180226165723.17818-3-eblake@redhat.com> In-Reply-To: <20180226165723.17818-1-eblake@redhat.com> References: <1518702707-7077-1-git-send-email-vsementsov@virtuozzo.com> <20180226165723.17818-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 26 Feb 2018 16:57:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 26 Feb 2018 16:57:30 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eblake@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 2/2] nbd/client: fix error messages in nbd_handle_reply_err 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: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 1. NBD_REP_ERR_INVALID is not only about length, so, make message more general 2. hex format is not very good: it's hard to read something like "option a (set meta context)", so switch to dec. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <1518702707-7077-6-git-send-email-vsementsov@virtuozzo.com> [eblake: expand scope of patch: ALL uses of nbd_opt_lookup are now decimal, all uses of nbd_rep_lookup are prefixed hex] Signed-off-by: Eric Blake --- nbd/client.c | 20 ++++++++++---------- nbd/server.c | 4 ++-- nbd/trace-events | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/nbd/client.c b/nbd/client.c index 89f80f95905..756e110f895 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -180,22 +180,22 @@ static int nbd_handle_reply_err(QIOChannel *ioc, NBDO= ptionReply *reply, goto cleanup; case NBD_REP_ERR_POLICY: - error_setg(errp, "Denied by server for option %" PRIx32 " (%s)", + error_setg(errp, "Denied by server for option %" PRIu32 " (%s)", reply->option, nbd_opt_lookup(reply->option)); break; case NBD_REP_ERR_INVALID: - error_setg(errp, "Invalid data length for option %" PRIx32 " (%s)", + error_setg(errp, "Invalid parameters for option %" PRIu32 " (%s)", reply->option, nbd_opt_lookup(reply->option)); break; case NBD_REP_ERR_PLATFORM: - error_setg(errp, "Server lacks support for option %" PRIx32 " (%s)= ", + error_setg(errp, "Server lacks support for option %" PRIu32 " (%s)= ", reply->option, nbd_opt_lookup(reply->option)); break; case NBD_REP_ERR_TLS_REQD: - error_setg(errp, "TLS negotiation required before option %" PRIx32 + error_setg(errp, "TLS negotiation required before option %" PRIu32 " (%s)", reply->option, nbd_opt_lookup(reply->option)); break; @@ -204,17 +204,17 @@ static int nbd_handle_reply_err(QIOChannel *ioc, NBDO= ptionReply *reply, break; case NBD_REP_ERR_SHUTDOWN: - error_setg(errp, "Server shutting down before option %" PRIx32 " (= %s)", + error_setg(errp, "Server shutting down before option %" PRIu32 " (= %s)", reply->option, nbd_opt_lookup(reply->option)); break; case NBD_REP_ERR_BLOCK_SIZE_REQD: - error_setg(errp, "Server requires INFO_BLOCK_SIZE for option %" PR= Ix32 + error_setg(errp, "Server requires INFO_BLOCK_SIZE for option %" PR= Iu32 " (%s)", reply->option, nbd_opt_lookup(reply->option)); break; default: - error_setg(errp, "Unknown error code when asking for option %" PRI= x32 + error_setg(errp, "Unknown error code when asking for option %" PRI= u32 " (%s)", reply->option, nbd_opt_lookup(reply->option)); break; } @@ -378,8 +378,8 @@ static int nbd_opt_go(QIOChannel *ioc, const char *want= name, return 1; } if (reply.type !=3D NBD_REP_INFO) { - error_setg(errp, "unexpected reply type %" PRIx32 - " (%s), expected %x", + error_setg(errp, "unexpected reply type 0x%" PRIx32 + " (%s), expected 0x%x", reply.type, nbd_rep_lookup(reply.type), NBD_REP_INF= O); nbd_send_opt_abort(ioc); return -1; @@ -534,7 +534,7 @@ static int nbd_request_simple_option(QIOChannel *ioc, i= nt opt, Error **errp) if (reply.type !=3D NBD_REP_ACK) { error_setg(errp, "Server answered option %d (%s) with unexpected " - "reply %" PRIx32 " (%s)", opt, nbd_opt_lookup(opt), + "reply 0x%" PRIx32 " (%s)", opt, nbd_opt_lookup(opt), reply.type, nbd_rep_lookup(reply.type)); nbd_send_opt_abort(ioc); return -1; diff --git a/nbd/server.c b/nbd/server.c index 112e3f69dff..4990a5826e6 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -806,7 +806,7 @@ static int nbd_negotiate_options(NBDClient *client, uin= t16_t myflags, default: ret =3D nbd_opt_drop(client, NBD_REP_ERR_UNSUP, errp, - "Unsupported option 0x%" PRIx32 " (%s)", + "Unsupported option %" PRIu32 " (%s)", option, nbd_opt_lookup(option)); break; } @@ -822,7 +822,7 @@ static int nbd_negotiate_options(NBDClient *client, uin= t16_t myflags, errp); default: - error_setg(errp, "Unsupported option 0x%" PRIx32 " (%s)", + error_setg(errp, "Unsupported option %" PRIu32 " (%s)", option, nbd_opt_lookup(option)); return -EINVAL; } diff --git a/nbd/trace-events b/nbd/trace-events index 2b8268ce8c3..ac19a366aac 100644 --- a/nbd/trace-events +++ b/nbd/trace-events @@ -1,7 +1,7 @@ # nbd/client.c nbd_send_option_request(uint32_t opt, const char *name, uint32_t len) "Sen= ding option request %" PRIu32" (%s), len %" PRIu32 -nbd_receive_option_reply(uint32_t option, const char *optname, uint32_t ty= pe, const char *typename, uint32_t length) "Received option reply 0x%" PRIx= 32" (%s), type 0x%" PRIx32" (%s), len %" PRIu32 -nbd_reply_err_unsup(uint32_t option, const char *name) "server doesn't und= erstand request 0x%" PRIx32 " (%s), attempting fallback" +nbd_receive_option_reply(uint32_t option, const char *optname, uint32_t ty= pe, const char *typename, uint32_t length) "Received option reply %" PRIu32= " (%s), type 0x%" PRIx32" (%s), len %" PRIu32 +nbd_reply_err_unsup(uint32_t option, const char *name) "server doesn't und= erstand request %" PRIu32 " (%s), attempting fallback" nbd_opt_go_start(const char *name) "Attempting NBD_OPT_GO for export '%s'" nbd_opt_go_success(void) "Export is good to go" nbd_opt_go_info_unknown(int info, const char *name) "Ignoring unknown info= %d (%s)" @@ -33,7 +33,7 @@ nbd_receive_structured_reply_chunk(uint16_t flags, uint16= _t type, const char *na nbd_unknown_error(int err) "Squashing unexpected error %d to EINVAL" # nbd/server.c -nbd_negotiate_send_rep_len(uint32_t opt, const char *optname, uint32_t typ= e, const char *typename, uint32_t len) "Reply opt=3D0x%" PRIx32 " (%s), typ= e=3D0x%" PRIx32 " (%s), len=3D%" PRIu32 +nbd_negotiate_send_rep_len(uint32_t opt, const char *optname, uint32_t typ= e, const char *typename, uint32_t len) "Reply opt=3D%" PRIu32 " (%s), type= =3D0x%" PRIx32 " (%s), len=3D%" PRIu32 nbd_negotiate_send_rep_err(const char *msg) "sending error message \"%s\"" nbd_negotiate_send_rep_list(const char *name, const char *desc) "Advertisi= ng export name '%s' description '%s'" nbd_negotiate_handle_export_name(void) "Checking length" @@ -46,7 +46,7 @@ nbd_negotiate_handle_starttls(void) "Setting up TLS" nbd_negotiate_handle_starttls_handshake(void) "Starting TLS handshake" nbd_negotiate_options_flags(uint32_t flags) "Received client flags 0x%" PR= Ix32 nbd_negotiate_options_check_magic(uint64_t magic) "Checking opts magic 0x%= " PRIx64 -nbd_negotiate_options_check_option(uint32_t option, const char *name) "Che= cking option 0x%" PRIx32 " (%s)" +nbd_negotiate_options_check_option(uint32_t option, const char *name) "Che= cking option %" PRIu32 " (%s)" nbd_negotiate_begin(void) "Beginning negotiation" nbd_negotiate_old_style(uint64_t size, unsigned flags) "advertising size %= " PRIu64 " and flags 0x%x" nbd_negotiate_new_style_size_flags(uint64_t size, unsigned flags) "adverti= sing size %" PRIu64 " and flags 0x%x" --=20 2.14.3