From patchwork Wed Feb 21 21:46:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 774540 Delivered-To: patch@linaro.org Received: by 2002:a5d:6ac2:0:b0:33b:4db1:f5b3 with SMTP id u2csp469834wrw; Wed, 21 Feb 2024 13:50:46 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVIoq+xqNvtMe6J1umIiVmX6Wwko4FkN3WryEGE5x5QMGhiYlh1WmSImmF3bM6pqJkKcd1BOOXFd3j3P+y5h1E5 X-Google-Smtp-Source: AGHT+IEWstdOzmeYbe9Wm/qZrFzoNFDt8Y++fgD0CEHe+GkCSb6LfmELtt+B3s1Zg1UJRv6zdt/1 X-Received: by 2002:adf:f488:0:b0:33d:7f4:8ce4 with SMTP id l8-20020adff488000000b0033d07f48ce4mr11616510wro.59.1708552246531; Wed, 21 Feb 2024 13:50:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708552246; cv=none; d=google.com; s=arc-20160816; b=wowfJINg0fboIv7TQHBzbP2kh2VHvSNSuaDgwLTL1ZHE3/ixfPSOmMMaUBGvOTbBa5 SorE649aBXFl+xgMlLOYNqeM0Hxl+rTxE9NNujinKCp7jO1/szN7Z2e64TXSxpx+W4zJ Q36qd9659jyM34AzhjyGmvcTgkBada81Pd1NJDNyaitUUOKtyRaIRK+lWt3r5Pzr2T+y GiYQIVzo7B0EQiGaYW8FvyQ74epjfWvUJNMvvlrjMrTsgLgDOj9flkpPNwuqCobyICp8 azv4VhqseA0FVzzEoKAWnd+DuvP4EDZ09BHJB0CTHwqTGhelfhxhg+4tiHCqCTvPSUbC V1xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=dd4VPMD5bcmKKR+uhk/1VkTHR3DO4QhpG+XqEmTSX4Q=; fh=UBdS1C7FLmKCPlHt7AdVMWBqXU1mfm8RYRk8RNS2ZdY=; b=VVqnKAQYi0UWZ4A2K1YnFFgA6oqf6GRvCn4/9NCClprqyXZihB/SI5h2YDp1zpAP/e b8qnF85Koh1YE4ZufdQBdLjWLWASAJ4Ji7XWnRrjT0CWhr6hYKVzQUaDSh579wAb9siD OV2mv1V8tHg3D08rK1RdtHhmOUTjrzV6jN/npRXg+OsHUgnDdxP/82yCEZGr4Ngea3b8 yf5W+6Xkkk6MzayRMaD/6je/LMrOGxIiQhW2bm/ZbERPAalCq+24suGlZSV6mnY4gqht t/0yrlR1JkBKkTKAZYBuLx4EicF2uk8tzUU6Nz29AxVm1EwsNC17Xnolojoj/D5ZVa6m yqqw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t22-20020a7bc3d6000000b00411da6d82f9si7351230wmj.192.2024.02.21.13.50.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Feb 2024 13:50:46 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcuRG-0000sy-GG; Wed, 21 Feb 2024 16:47:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcuRF-0000ox-0R; Wed, 21 Feb 2024 16:47:37 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcuRD-0007LQ-71; Wed, 21 Feb 2024 16:47:36 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 44E694F861; Thu, 22 Feb 2024 00:47:46 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id E0545869E2; Thu, 22 Feb 2024 00:47:23 +0300 (MSK) Received: (nullmailer pid 2339838 invoked by uid 1000); Wed, 21 Feb 2024 21:47:23 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Maydell , Bohdan Kostiv , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , Richard Henderson , Michael Tokarev Subject: [Stable-7.2.10 05/33] system/vl.c: Fix handling of '-serial none -serial something' Date: Thu, 22 Feb 2024 00:46:48 +0300 Message-Id: <20240221214723.2339742-5-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Peter Maydell Currently if the user passes multiple -serial options on the command line, we mostly treat those as applying to the different serial devices in order, so that for example -serial stdio -serial file:filename will connect the first serial port to stdio and the second to the named file. The exception to this is the '-serial none' serial device type. This means "don't allocate this serial device", but a bug means that following -serial options are not correctly handled, so that -serial none -serial stdio has the unexpected effect that stdio is connected to the first serial port, not the second. This is a very long-standing bug that dates back at least as far as commit 998bbd74b9d81 from 2009. Make the 'none' serial type move forward in the indexing of serial devices like all the other serial types, so that any subsequent -serial options are correctly handled. Note that if your commandline mistakenly had a '-serial none' that was being overridden by a following '-serial something' option, you should delete the unnecessary '-serial none'. This will give you the same behaviour as before, on QEMU versions both with and without this bug fix. Cc: qemu-stable@nongnu.org Reported-by: Bohdan Kostiv Signed-off-by: Peter Maydell Reviewed-by: Daniel P. Berrangé Reviewed-by: Richard Henderson Message-id: 20240122163607.459769-2-peter.maydell@linaro.org Fixes: 998bbd74b9d81 ("default devices: core code & serial lines") Signed-off-by: Peter Maydell (cherry picked from commit d2019a9d0c34a4fdcb5b5df550d73040dc0637d9) Signed-off-by: Michael Tokarev diff --git a/softmmu/vl.c b/softmmu/vl.c index ce88869618..ab4394c53d 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1363,18 +1363,22 @@ static void qemu_create_default_devices(void) static int serial_parse(const char *devname) { int index = num_serial_hds; - char label[32]; - if (strcmp(devname, "none") == 0) - return 0; - snprintf(label, sizeof(label), "serial%d", index); serial_hds = g_renew(Chardev *, serial_hds, index + 1); - serial_hds[index] = qemu_chr_new_mux_mon(label, devname, NULL); - if (!serial_hds[index]) { - error_report("could not connect serial device" - " to character backend '%s'", devname); - return -1; + if (strcmp(devname, "none") == 0) { + /* Don't allocate a serial device for this index */ + serial_hds[index] = NULL; + } else { + char label[32]; + snprintf(label, sizeof(label), "serial%d", index); + + serial_hds[index] = qemu_chr_new_mux_mon(label, devname, NULL); + if (!serial_hds[index]) { + error_report("could not connect serial device" + " to character backend '%s'", devname); + return -1; + } } num_serial_hds++; return 0;