From nobody Thu Oct 30 15:33:06 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; dkim=fail; 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 15258183407141018.6912557396685; Tue, 8 May 2018 15:25:40 -0700 (PDT) Received: from localhost ([::1]:53562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGB3E-0004nI-0X for importer@patchew.org; Tue, 08 May 2018 18:25:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGAt9-00039J-11 for qemu-devel@nongnu.org; Tue, 08 May 2018 18:15:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGAt7-0001WD-TZ for qemu-devel@nongnu.org; Tue, 08 May 2018 18:15:15 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:36517) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGAt7-0001Vf-Mz for qemu-devel@nongnu.org; Tue, 08 May 2018 18:15:13 -0400 Received: by mail-wm0-x242.google.com with SMTP id n10-v6so24095195wmc.1 for ; Tue, 08 May 2018 15:15:13 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-189-60.clienti.tiscali.it. [78.12.189.60]) by smtp.gmail.com with ESMTPSA id c15-v6sm14020129edr.78.2018.05.08.15.15.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 15:15:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=zw0f3+4A41BgfMch57TnPr+s+lkv3JYJ3I32D9uuh5Q=; b=Ghy6HRnKp1cdWkFm9g5t3wtJvet/tvwtDv2CoWmKXY22QDr0tCEHcI9djwqjjzsATk rfwXEzDfAqdgBe1x5Y61wVzWMF7zBzYNqxNO1mSrzgSDd+5nE7Spx4yUgb9WarK1j7xk NEC8WHc3d+4dEfdzaUlbI1vZOjK+OGTOy/8NKlPflpTGFsOgPd5lrFSS5wl07W4cgXtZ UvN6Yx41zl+K/xBv1fHQXDRjKG52bATeRELDgs7bkYCnhfPPU2Tm95E+Wdrx0hXk1mfJ BT7yAirzY7/zzf7TRWb/o3ZV4raFFngVsg5aMvkb8ceRiXHwBiOYN/GVb8DVsPRastO8 b/+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=zw0f3+4A41BgfMch57TnPr+s+lkv3JYJ3I32D9uuh5Q=; b=mgdQk8OHcj8+4dB1Z3hop9VN3TTDTBZGZ9Bv9XEAzuey4S3aoYrI0/hvKolxpAh6Th b3wmw+TlHt5w2CCcyv5LGVz3vAUHIgpZ2hz+AENzLc6mc2LNpPmLMDFK7CFR9BqEZnIZ Zwi0y0n2Z6Z6/p+3Cmz166HjFEIzgeGg2I78W4I1q/7qQoxlvVKKrwgqjQ1seDqy0B2U mXs77XUzd4OQZmP4p8q1VdgxLvrYLj6UtA+GtZFZcR5rwsyX748CkaA+pt+ueQhapiA+ LfMSOcnWz4L6e0Hz54RS0QpsYxwtNzdUTaNjBAzGzVmbwxUhTlXqVAb8/kNmCIpp/Ucr qieg== X-Gm-Message-State: ALQs6tD1UFnRWhPhv05oZdwud9pxCkicIjep02XQ4dBO5mSEDcM7NbCf njFLYHNhL2247BluO1YU6/0Wz4UY X-Google-Smtp-Source: AB8JxZoSV1EyR2RBjng9o2G+lAu00iP/uj2iHu8hHzp2wW0vWLm87GEZT2YM3GlBY4AvxImfEX3K6w== X-Received: by 2002:a50:9b14:: with SMTP id o20-v6mr39857264edi.60.1525817712433; Tue, 08 May 2018 15:15:12 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 9 May 2018 00:14:36 +0200 Message-Id: <1525817687-34620-20-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1525817687-34620-1-git-send-email-pbonzini@redhat.com> References: <1525817687-34620-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 19/30] qemu-options: Bail out on unsupported options instead of silently ignoring them 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: Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth The dangling remainder of the -tdf option revealed a deficiency in our option parsing: Options that have been declared, but are not supported in the switch-case statement in vl.c and not handled in the OS-specifc os_parse_cmd_args() functions are currently silently ignored. We should rather tell the users that they specified something that we can not handle, so let's print an error message and exit instead. Reported-by: Markus Armbruster Signed-off-by: Thomas Huth Message-Id: <1525453270-23074-3-git-send-email-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- include/qemu-common.h | 2 +- os-posix.c | 6 +++++- os-win32.c | 4 ++-- vl.c | 5 ++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/qemu-common.h b/include/qemu-common.h index 8a4f63c..85f4749 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -137,7 +137,7 @@ char *qemu_find_file(int type, const char *name); /* OS specific functions */ void os_setup_early_signal_handling(void); char *os_find_datadir(void); -void os_parse_cmd_args(int index, const char *optarg); +int os_parse_cmd_args(int index, const char *optarg); =20 #include "qemu/module.h" =20 diff --git a/os-posix.c b/os-posix.c index 24eb700..9ce6f74 100644 --- a/os-posix.c +++ b/os-posix.c @@ -165,7 +165,7 @@ static bool os_parse_runas_uid_gid(const char *optarg) * Parse OS specific command line options. * return 0 if option handled, -1 otherwise */ -void os_parse_cmd_args(int index, const char *optarg) +int os_parse_cmd_args(int index, const char *optarg) { switch (index) { #ifdef CONFIG_SLIRP @@ -199,7 +199,11 @@ void os_parse_cmd_args(int index, const char *optarg) fips_set_state(true); break; #endif + default: + return -1; } + + return 0; } =20 static void change_process_uid(void) diff --git a/os-win32.c b/os-win32.c index 586a7c7..0674f94 100644 --- a/os-win32.c +++ b/os-win32.c @@ -93,9 +93,9 @@ void os_set_line_buffering(void) * Parse OS specific command line options. * return 0 if option handled, -1 otherwise */ -void os_parse_cmd_args(int index, const char *optarg) +int os_parse_cmd_args(int index, const char *optarg) { - return; + return -1; } =20 int qemu_create_pidfile(const char *filename) diff --git a/vl.c b/vl.c index b928e3e..a23acb2 100644 --- a/vl.c +++ b/vl.c @@ -4033,7 +4033,10 @@ int main(int argc, char **argv, char **envp) } break; default: - os_parse_cmd_args(popt->index, optarg); + if (os_parse_cmd_args(popt->index, optarg)) { + error_report("Option not supported in this build"); + exit(1); + } } } } --=20 1.8.3.1