From nobody Fri Oct 18 05:19:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1719840725; cv=none; d=zohomail.com; s=zohoarc; b=F9X0Sv2eiocwWaGcxTNzL3pigW3TLl04teYdPRkw11oEFZfvK+nkkq11gddj5BTGU+OY/lZ1y5Fkar/JW6vRp9VCa8rnHpzT6JvChtF3vQHW8WaRdjVAcmZBCJlyEBPPFlTneJyF2es9pWyxWJseaMg/0on1kMuJoWSP2KSWNWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719840725; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6TUzEiTYDYxtoBN8a40dqDmyHQkViHYBXJaMnTel9nE=; b=X+oOa2TY7tnf5G1GQBAXLBc8v49FZTd9St7fZkNCh3PxfRzJR3i/r68PUiEbVugmJWgLocqVQ5wDU1wMbjYNCx2l9E8adseIsgrBvwlaFUk9TXgI6euClav2Xcw0UhARSLRW7KQM2f8EndKz2p5coUiKHRpBWe2oBRkmdnpieV4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719840725571567.464086855603; Mon, 1 Jul 2024 06:32:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sOH7w-0008Ih-Ko; Mon, 01 Jul 2024 09:31:30 -0400 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 1sOH7n-0008HR-TQ for qemu-devel@nongnu.org; Mon, 01 Jul 2024 09:31:20 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOH7l-0005Na-Ke for qemu-devel@nongnu.org; Mon, 01 Jul 2024 09:31:19 -0400 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-713fa1aea36so965400a12.1 for ; Mon, 01 Jul 2024 06:31:17 -0700 (PDT) Received: from grind.. ([179.193.8.43]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c91d3eb34bsm6736935a91.56.2024.07.01.06.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 06:30:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1719840675; x=1720445475; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6TUzEiTYDYxtoBN8a40dqDmyHQkViHYBXJaMnTel9nE=; b=WtQ5EsllbhugFLS8ZniB2sQG3owiA3gnZkk46tXBHz17P3OBVQCURbUGeAKzkQSKp5 QTONWFzv2sayT+o3z9x878vkfF66j/1do8T+Rv/eMEpigCM+P22awpvXM/WGgNfQpJHP GCmpIgRafKfyFHN1WSHX1hByzOsmcB/L0VVlICaVSXDaR14Y3mAhoAkCDDk7ZQ5bbNix KYZot3aO5BqvrkEu/K2jZ5IQNcFc/yX/u0wz9avRIupzJfYUt/YLTLnXCCIcbKglKO4i lgnHndrbrDoMdGGuOrDB+CGvr1NFkE/u0FWRXhxmVODUVlMGXC/OUjOnviitG2ZESWTT OYZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719840675; x=1720445475; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6TUzEiTYDYxtoBN8a40dqDmyHQkViHYBXJaMnTel9nE=; b=UzhDEj5l4rgo6JiIpabSk9rqklBOShv2UurKmXFh9NzQXRMB14pCkkdFjbluxAtHS5 x8PjfvXU4txXP4cozdjaaYfsJ95hm9RpywIDLUktN7Mb9MYCp1YB82OgPKBXx/KoqSaQ oE64KG9KC7I5FG2m2GocVh2W8du8JxZI6Tm2XvNaH+68cG/XorVlENoAPHrDYPJVmn9L e+AW+DpX0a6yPH13MCrF9CZi8XQixiV8GVOugy8jCD8sDgtG8eSlG0/nlr//WHBNjC7f hDFvqrZ0ts7V3GKitt9YZlcg0AoKUPN21S8xe1IQlp8f0pHIAqwDjX0oAIu96KLxFcZm h61w== X-Gm-Message-State: AOJu0YzCIIZS+OV+GpH4rk6c9/on2Q6GWIQFVRIA1ZHItGAEtGGZW3fF FTZLYRaJ1feO08qhH8gtv6GRCHTsTlBXvkZ0jyXpZUdF6X7HmGfU3DkgZkwT/WJm8tidpUoBccP 9 X-Google-Smtp-Source: AGHT+IEibPnWg6v0pK2ZYjMH2dhvG2gANOz+c4zEmlVhpqdeWggaPjihKJCPJBLGPhK7fSPIzzmV3w== X-Received: by 2002:a17:90b:4c8f:b0:2c8:820:71c4 with SMTP id 98e67ed59e1d1-2c93d71f424mr2787188a91.29.1719840651800; Mon, 01 Jul 2024 06:30:51 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: ajones@ventanamicro.com, Daniel Henrique Barboza , Paolo Bonzini , Thomas Huth Subject: [PATCH 1/2] system/vl.c: do not allow mixed -accel opts Date: Mon, 1 Jul 2024 10:30:37 -0300 Message-ID: <20240701133038.1489043-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240701133038.1489043-1-dbarboza@ventanamicro.com> References: <20240701133038.1489043-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 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=2607:f8b0:4864:20::532; envelope-from=dbarboza@ventanamicro.com; helo=mail-pg1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1719840726222100001 Content-Type: text/plain; charset="utf-8" We're allowing multiple -accel options to be used with different accelerators, even though we don't have any machine that supports mixed acceleration. In fact, it will only parse the first occurence of -accel and, aside from a help option (e.g. -accel help) that will always cause the process to print the help text, it will accept every other accel option regardless of being correct or not. E.g. this: qemu-system-x86_64 -accel kvm -accel tcg -accel IamNotAnAccel (...) will happily boot a x86_64 KVM guest. Do not allow for different accelerators to be used when multiple instances of -accel are present. Cc: Paolo Bonzini Cc: Thomas Huth Signed-off-by: Daniel Henrique Barboza --- system/vl.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/system/vl.c b/system/vl.c index bdd2f6ecf6..32602e68b7 100644 --- a/system/vl.c +++ b/system/vl.c @@ -3318,10 +3318,22 @@ void qemu_init(int argc, char **argv) } break; } - case QEMU_OPTION_accel: + case QEMU_OPTION_accel: { + QemuOptsList *list =3D qemu_find_opts("accel"); + const char *prev_accel =3D qemu_opt_get(QTAILQ_LAST(&list-= >head), + "accel"); + accel_opts =3D qemu_opts_parse_noisily(qemu_find_opts("acc= el"), optarg, true); optarg =3D qemu_opt_get(accel_opts, "accel"); + + if (prev_accel && optarg && strcmp(prev_accel, optarg)) { + printf("Unable to mix accelerators with multiple " + "-accel options (have: '%s' and '%s')\n", + prev_accel, optarg); + exit(1); + } + if (!optarg || is_help_option(optarg)) { printf("Accelerators supported in QEMU binary:\n"); GSList *el, *accel_list =3D object_class_get_list(TYPE= _ACCEL, @@ -3343,6 +3355,7 @@ void qemu_init(int argc, char **argv) exit(0); } break; + } case QEMU_OPTION_usb: qdict_put_str(machine_opts_dict, "usb", "on"); break; --=20 2.45.2 From nobody Fri Oct 18 05:19:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1719840715; cv=none; d=zohomail.com; s=zohoarc; b=f7XJFSytg4ZTIjNrtGJ+weGffEPdWILaMfMn1dDyFJmf+pcv1ge+LJeApunscM71Qal3ANQMS/0rsq53eWQPrDubKOaHH8maYD4SiZEjes+cMzFFse4D1QYBD7uNW/x/EHqTpsuyvYRV2vM7xZjwl3sHtWAx1FlTPW4vf87Zqr8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719840715; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=t1RryP+60mMhkO8WnO7FIMUxhiFZxnyyH7/OPgo3rZg=; b=UY7AQ1L6Xikqy+y3nCdBNdm5ICaBJDK6tDxuREE+g36cBOsLNJQofd/hHObeZHuPBsZC/RTvH2j2CkiTA2+a79VYCU5UxZefX9BZPww2+XdFAH0QkW3+mUO1x0K6nAM0bNmOMwkcGahjC0yd73wQxzZDqpM4ZOyWf2kZTKsiCuw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719840715077881.6465408766288; Mon, 1 Jul 2024 06:31:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sOH86-0008Pq-Gx; Mon, 01 Jul 2024 09:31:38 -0400 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 1sOH7q-0008I6-6O for qemu-devel@nongnu.org; Mon, 01 Jul 2024 09:31:22 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOH7o-0005O3-GT for qemu-devel@nongnu.org; Mon, 01 Jul 2024 09:31:21 -0400 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2c86e3fb6e7so1744260a91.1 for ; Mon, 01 Jul 2024 06:31:20 -0700 (PDT) Received: from grind.. ([179.193.8.43]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c91d3eb34bsm6736935a91.56.2024.07.01.06.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 06:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1719840679; x=1720445479; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t1RryP+60mMhkO8WnO7FIMUxhiFZxnyyH7/OPgo3rZg=; b=V6P7FiAhJM39OZUOFKjcmBxysuuAtLzBLNm3ghqcHHP3qg6YSj6OF+XHz8kwE4tr2t EYWiJljwr1Hu0yEPoQ+yPOQHlG8uH+OmD3PutB4X8GpqxPmZVEBeFA1291btvrdkJD+c Bt6o3QJNxltZyHTgrjNc9oq90Y4HnHx0sGuKdyaK9brA+0LthRAHrdik4Z3sYr3OiMIZ 59sP0/7i9bOi+wEy3J02ogp6IraLHDGnv/mQ9gJmBpLYDxVNrIFwWQ4oN8FYRDWeozsH 6abJHIxzwcUNsarK84U9X0ziypOBdAumGkYn/t/pbJfKjN0aE2MjpbPSsubxUTDYhF5m 6Enw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719840679; x=1720445479; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t1RryP+60mMhkO8WnO7FIMUxhiFZxnyyH7/OPgo3rZg=; b=NPlLozpBR0Y5EHkgOjz/sIedxnt5dvw56nHtZ/JEUGYiWyQcdCrTFJ21gxHgRWBNpO +Iuw5RaC9322UIxoJV9n7unkLttxoSYtb6Hi65ctD2kidM4Z9K2EyHuNySmRdnmEEUxu brGppQv6sKXJ7EZxK5ANHy4qqUKzfxBj8pfrnQRwpJIjkGjJ2Xb6HMUerY2ZitZ9omkc KpGrw3S61mXiamDTXfOO7PHWGFEInsJC0MQbeakg5faMegh5OSiP3NEL3urexOTBUkN6 Rvt24ptFeVFGVRrhAiaVziO5P2C7XIUU8EnsQFIgyXWsWeYjjMVr9K2JRnNv4R+mhvz9 5Xag== X-Gm-Message-State: AOJu0YxAdOaLCezWzFt8c6UZbgRAAb4bAX6RmJDI9ILozQeL5ijuGQDS W6av3dpOEtXgUiyLLp3guYcMUtFlKoTpTYVL4wIv2rEpeCqITWj21+lFBhYl/6xQtOjhe/tDYhE j X-Google-Smtp-Source: AGHT+IH1R72NCHWtyvT6cjF3994QPDwvLOpV5wTHL4TprLIAx7QRrwQpRwu4I+azK0yqLdUKiuo5OA== X-Received: by 2002:a17:90a:bd86:b0:2c8:7564:7fab with SMTP id 98e67ed59e1d1-2c93d72e239mr2543406a91.27.1719840678414; Mon, 01 Jul 2024 06:31:18 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: ajones@ventanamicro.com, Daniel Henrique Barboza , Paolo Bonzini , Thomas Huth Subject: [PATCH 2/2] system/vl.c: parse all -accel options Date: Mon, 1 Jul 2024 10:30:38 -0300 Message-ID: <20240701133038.1489043-3-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240701133038.1489043-1-dbarboza@ventanamicro.com> References: <20240701133038.1489043-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 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=2607:f8b0:4864:20::1034; envelope-from=dbarboza@ventanamicro.com; helo=mail-pj1-x1034.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1719840716223100003 Content-Type: text/plain; charset="utf-8" We're not honouring KVM options that are provided by any -accel option aside from the first. In this example: qemu-system-riscv64 -accel kvm,riscv-aia=3Demul (...) \ -accel kvm,riscv-aia=3Dhwaccel 'riscv-aia' will be set to 'emul', ignoring the last occurrence of the option that set 'riscv-aia' to 'hwaccel'. The previous change guarantees that we'll not have mixed accelerators in the command line, and now it's safe to activate 'merge_lists' for 'qemu_accel_opts'. This will merge all accel options in the same list, allowing the 'qemu_opt_foreach()' callback in do_configure_accelerator() to apply each one of them in the Accel class. Reported-by: Andrew Jones Cc: Paolo Bonzini Cc: Thomas Huth Signed-off-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- system/vl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/system/vl.c b/system/vl.c index 32602e68b7..5ed9a9229f 100644 --- a/system/vl.c +++ b/system/vl.c @@ -259,6 +259,7 @@ static QemuOptsList qemu_accel_opts =3D { .name =3D "accel", .implied_opt_name =3D "accel", .head =3D QTAILQ_HEAD_INITIALIZER(qemu_accel_opts.head), + .merge_lists =3D true, .desc =3D { /* * no elements =3D> accept any --=20 2.45.2