From nobody Wed Nov 19 03:02:45 2025 Delivered-To: importer@patchew.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 ARC-Seal: i=1; a=rsa-sha256; t=1614337479; cv=none; d=zohomail.com; s=zohoarc; b=IeRktJ2AMkcJXXw6/HjZ8W6clQlss9ZgaXYkT9bXculqwkY1Zd/6VnQAw2Gq1/F7WzhYcc7DkxpOTlU28zOQY1TSZcBpaAHbtIAZs5dNs48CZRPXTuoZ+O2Ie3i5d19/YvaPYGAyzMIcA9fgDiHeaJqbzLJG0PxdvWPWguVJhwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614337479; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=c95UZzOO+bd7RHRebXBGDm3oNT/sRfsB6wbRQIVjT+4=; b=VGv7gWHNyD8iB/48k40eFrjPbK5UBC0lqx//JIhPzmc+3IDdkjzZyMDWqFRirEo0uR4qjR89YBsSDasxou7y+wWVfGqGcLfTzXSr2RX4uXN61XkvSMwoDYSPYpzqo/2wBRwHTR88l1OL4S2wYxIrIuAT1XRA1KEjK9g/rU/9DIQ= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614337479492571.2856628560417; Fri, 26 Feb 2021 03:04:39 -0800 (PST) Received: from localhost ([::1]:38720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lFavF-0002NB-A2 for importer@patchew.org; Fri, 26 Feb 2021 06:04:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lFau1-0001lG-Ow for qemu-devel@nongnu.org; Fri, 26 Feb 2021 06:03:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52107) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lFaty-0005L8-0P for qemu-devel@nongnu.org; Fri, 26 Feb 2021 06:03:21 -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-555-MHxAMlqbMxiUdteqK0fVrg-1; Fri, 26 Feb 2021 06:03:14 -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 4E2A480196C; Fri, 26 Feb 2021 11:03:13 +0000 (UTC) Received: from virtlab511.virt.lab.eng.bos.redhat.com (virtlab511.virt.lab.eng.bos.redhat.com [10.19.152.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC1AA5D9D2; Fri, 26 Feb 2021 11:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614337396; 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; bh=c95UZzOO+bd7RHRebXBGDm3oNT/sRfsB6wbRQIVjT+4=; b=MDSP2hvm4429YJCqxvR22d5g/OYR10aKRD9V+paDyfJ7KsPa0OTEYXhRuKdFZTxfj5S3NZ nYaY4+xmnHqfi/vlnfaczDMcCZ66kJ3vzKUuRUEZ2ACjS7I+Px86fgoim67avkYxb8WLsE 9Igi1gSZqWMaNRGQvaJYawuAVycYjaM= X-MC-Unique: MHxAMlqbMxiUdteqK0fVrg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH] storage-daemon: include current command line option in the errors Date: Fri, 26 Feb 2021 06:03:12 -0500 Message-Id: <20210226110312.157645-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-block@nongnu.org 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" Use the location management facilities that the emulator uses, so that the current command line option appears in the error message. Before: $ storage-daemon/qemu-storage-daemon --nbd key..=3D qemu-storage-daemon: Invalid parameter 'key..' After: $ storage-daemon/qemu-storage-daemon --nbd key..=3D qemu-storage-daemon: --nbd key..=3D: Invalid parameter 'key..' Signed-off-by: Paolo Bonzini Reviewed-by: Eric Blake --- storage-daemon/qemu-storage-daemon.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-sto= rage-daemon.c index 9021a46b3a..a8f8d83f6f 100644 --- a/storage-daemon/qemu-storage-daemon.c +++ b/storage-daemon/qemu-storage-daemon.c @@ -152,6 +152,20 @@ static void init_qmp_commands(void) qmp_marshal_qmp_capabilities, QCO_ALLOW_PRECONFIG= ); } =20 +static int getopt_set_loc(int argc, char **argv, const char *optstring, + const struct option *longopts) +{ + int c, save_index; + + optarg =3D NULL; + save_index =3D optind; + c =3D getopt_long(argc, argv, optstring, longopts, NULL); + if (optarg) { + loc_set_cmdline(argv, save_index, MAX(1, optind - save_index)); + } + return c; +} + static void process_options(int argc, char *argv[]) { int c; @@ -174,7 +188,7 @@ static void process_options(int argc, char *argv[]) * they are given on the command lines. This means that things must be * defined first before they can be referenced in another option. */ - while ((c =3D getopt_long(argc, argv, "hT:V", long_options, NULL)) != =3D -1) { + while ((c =3D getopt_set_loc(argc, argv, "hT:V", long_options)) !=3D -= 1) { switch (c) { case '?': exit(EXIT_FAILURE); @@ -283,6 +297,7 @@ static void process_options(int argc, char *argv[]) error_report("Unexpected argument: %s", argv[optind]); exit(EXIT_FAILURE); } + loc_set_none(); } =20 int main(int argc, char *argv[]) --=20 2.26.2