From patchwork Wed Feb 21 08:19:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 774494 Delivered-To: patch@linaro.org Received: by 2002:a5d:6ac2:0:b0:33b:4db1:f5b3 with SMTP id u2csp145231wrw; Wed, 21 Feb 2024 00:21:38 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUkGvMIW4+MN76YpQhkQp1dV4851WOaGYFNzsnRu9T5cyU4vbjDLR+wOvHU1OHbZT5eDdH3rv7ut4aKDBj6CmGL X-Google-Smtp-Source: AGHT+IHIrZFC5my9Jxw3pRYZpWJh21dUEXP0AZQ7AzSNWpkrX3usPOgM8661pNwVqxK3ZarsDrdT X-Received: by 2002:a0c:aa5c:0:b0:68f:a78f:bf1d with SMTP id e28-20020a0caa5c000000b0068fa78fbf1dmr634986qvb.39.1708503698385; Wed, 21 Feb 2024 00:21:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708503698; cv=none; d=google.com; s=arc-20160816; b=ED2KvrEQHlfBlQSBYwLUHtVnGn2k+/NOpsD+7gY9/ZvG3t5Dtxb+z+vRzaUQG6ZB2G TUMLL+i27cK6gaMts5LWsLCGnLX/+xAaGJ7/yPS3uGq3QcpRP7ihX4GnZWug631DgRc/ Xrs1gDJIzMbf4aKQp1gP7WKFipn0lLDtGXH8Bn+w5mYNs8/Kh4X+yF5LzxJ1I6Vwg24g Maz8EUbIjBMkHS0AlLBdKYUAWnZprFlDzYFNHjKZzurK/OFYZzvuX/XnaIP7PG3FX2+6 kOyfXxWD6WTMjR5jK4NyfjW7NXWZz01olLxpYs/0rZGXlAidDE9Igw9jxhXt9+mtKy07 ypqw== 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=W4r0RhRi6766sVoCuUGM0aM/W/jKaxM9F5PFTVDARx8=; fh=UBdS1C7FLmKCPlHt7AdVMWBqXU1mfm8RYRk8RNS2ZdY=; b=pnxSY1j/wrFUctj5khWNeOz0ZSV+/5giGUT9Fy8QaHNAHbKKWld6d8N50qKL/Sw8mG RTG96c6XAyqm8JjEGnYDfCjhER7pItcx45+n6j0msDlDgc05czsSgKLpsCVDOODdFrMh KZkS1WqbRH9JB+13/RWNOiRx4+lVla8oPWsWebF28BZ8BY1UKnBtXsaQ6ekVod2GfeaP Jwx/rZ0R9sSuTm69aNRxIxOnI3zTFiBe2/w6s5CwNAACPk/LE8mh8Oak5GyCQhpOEdcg E5vrI+FjQpW8qCve6a3l546/UPZyid3Y36Si3E9L8PxTpUql/A1SF4wy5lv8mRAQbTrg pBgg==; 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 jr5-20020a0562142a8500b00683699d4df8si10338995qvb.139.2024.02.21.00.21.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Feb 2024 00:21:38 -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 1rchr5-0001Ek-Hh; Wed, 21 Feb 2024 03:21:27 -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 1rchqw-00015U-6P; Wed, 21 Feb 2024 03:21:18 -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 1rchqu-0002Au-I2; Wed, 21 Feb 2024 03:21:17 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 657C04F3C6; Wed, 21 Feb 2024 11:21:20 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 2ED37860A5; Wed, 21 Feb 2024 11:20:59 +0300 (MSK) Received: (nullmailer pid 2142010 invoked by uid 1000); Wed, 21 Feb 2024 08:20:58 -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-8.2.2 08/60] system/vl.c: Fix handling of '-serial none -serial something' Date: Wed, 21 Feb 2024 11:19:56 +0300 Message-Id: <20240221082058.2141850-8-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/system/vl.c b/system/vl.c index 6b87bfa32c..938b7b5acc 100644 --- a/system/vl.c +++ b/system/vl.c @@ -1440,18 +1440,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;