From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575903869; cv=none; d=zohomail.com; s=zohoarc; b=Q84Dc6YhXK1QkJ2D3bM9LOTdeJF3XcGAGFPTsn1dKWnsr6NWmcIDMRo0gdZCrCJlhBjN+AEfn1f1YoiKOFvmk0VdD1qJyam1qXwRRObn3wzZaELWZcyzkvgWsPBgzdm2Gupe38lgav7hNDQff+eb0x106hSN+d2BTzdI77PLmeg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575903869; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aB/U/Tf7guynfrwJbWpfYI+QRcweDccxGqmzLn8iwE8=; b=c3E/NurWzw+/VXrI3hcSRxnR9EPfx/JJIsL1NZ41foyqKWtzdwBqNPqNVAemba84Q85JDSQvqvAJH9JiLOd7AQQW8CnisOBEFueJuI4HZzOJ17fpk03WfFcLohA+STKcaCB3r5Fdsg+XPnWy2M3U89U8q5aeVE/qxI6HkKZApHk= 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 1575903869716590.1932444604237; Mon, 9 Dec 2019 07:04:29 -0800 (PST) Received: from localhost ([::1]:41172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKaJ-0005El-3B for importer@patchew.org; Mon, 09 Dec 2019 10:04:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47018) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKXn-0003Kl-S0 for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKXm-0001Cj-SQ for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:51 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:52828) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKXm-0001CC-LQ for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:50 -0500 Received: by mail-wm1-x344.google.com with SMTP id p9so15826614wmc.2 for ; Mon, 09 Dec 2019 07:01:50 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.01.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:01:47 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=aB/U/Tf7guynfrwJbWpfYI+QRcweDccxGqmzLn8iwE8=; b=sk1JqgRjhOOTr/dRvGHkiH1p7uHgB+CVM18UIPOXrpZhbYnRlrbR7qYmXbJm+NqPh5 HOW7KUy+BTldeVw34HHJD4t5H41DSio7UNdj1dP6I84U0A8d641c5Em57lHw+nUhIP9l UwQ+Tf7gSymC86/GYraCe6iUrLEpwJr65S4gJPNHg0RzEXU/z4kYHcKCdNdI9bUDR2ve 2+Hg1EWjXJ1448TVrpezcLXX8nP25fqRqw97ABQOZHY6YLRrOhWbkcwC34Q9MlYazABe XfogqzsAWw0YVerOGgXFBrSHn++wfFLSPbTO875k28077a3VI1QpWg4ys7kCbjlpR7oW obZA== 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:mime-version:content-transfer-encoding; bh=aB/U/Tf7guynfrwJbWpfYI+QRcweDccxGqmzLn8iwE8=; b=o5JC25k4ShpkiwLXI37B+e4ibUHNm8veo+B6leYJDsz87LbDaQiT5ieshwQXHFdR4V i+ZeQ3LdCFXXjBb7xGMyiLdORu5eAX2Kge98pCIryu6fqfrV8CK+GZcjd67RGmDCUbbj yCg7agNKiNQnerSMua9RmsWSiBZnyuvP9z051jJ/ORRU+m7HLMlA7a536+ntFc3UUd08 isdeovKT4kHihBe6Is8gEot1QxiDUc6vnOJNZsehkyjYsetqzNqHJOYyyNNyiJUyE9LK wCbHoaDThIan3kHPPGJaTEQv6CBVLzWkqAOxYqO42z2O2vbizD4oRT+kaFcytJwN9w6p ZOxQ== X-Gm-Message-State: APjAAAV6Zdo/xNG7rBNj7gk8Mn0AUT4hs0o21iYnhbuFDpNE1lpLgH8s Nua8cKUkcDF9UaPLIOHOsyog+pA/ X-Google-Smtp-Source: APXvYqyQRF5WjfoEOlGUpyWr04KG4TTpEclG8hBiFJIoujG7eRKtcSBbMSGw79YhtW6i8GmzZiVs5A== X-Received: by 2002:a1c:750f:: with SMTP id o15mr25987309wmc.161.1575903708518; Mon, 09 Dec 2019 07:01:48 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 01/18] memory: do not look at current_machine->accel Date: Mon, 9 Dec 2019 16:01:28 +0100 Message-Id: <1575903705-12925-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) "info mtree -f" prints the wrong accelerator name if used with for example "-machine accel=3Dkvm:tcg". The right thing to do is to fetch the name from the AccelClass, which will also work nicely once current_machine->accel stops existing. Tested-by: Thomas Huth Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- memory.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/memory.c b/memory.c index 06484c2..6d79cf1 100644 --- a/memory.c +++ b/memory.c @@ -2979,7 +2979,6 @@ struct FlatViewInfo { bool dispatch_tree; bool owner; AccelClass *ac; - const char *ac_name; }; =20 static void mtree_print_flatview(gpointer key, gpointer value, @@ -3049,7 +3048,7 @@ static void mtree_print_flatview(gpointer key, gpoint= er value, if (fvi->ac->has_memory(current_machine, as, int128_get64(range->addr.start), MR_SIZE(range->addr.size) + 1)) { - qemu_printf(" %s", fvi->ac_name); + qemu_printf(" %s", fvi->ac->name); } } } @@ -3097,8 +3096,6 @@ void mtree_info(bool flatview, bool dispatch_tree, bo= ol owner) =20 if (ac->has_memory) { fvi.ac =3D ac; - fvi.ac_name =3D current_machine->accel ? current_machine->acce= l : - object_class_get_name(OBJECT_CLASS(ac)); } =20 /* Gather all FVs in one table */ --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575903872; cv=none; d=zohomail.com; s=zohoarc; b=hSQRJY0aqEtpbWtxcxZm/3KmxeQnMXCxOKmC3ddJvuw6dhEpofvPdxpoHD2Zraf/xN1Rdlzg2KLD7ScB9AhuI0VuHFsC+g1dThKLfUHribtkPN6Xxs3lNoMh3ZIImN4fEycVmV0z2vf3v0Ias4rqWCd+8fNAxXPFiPEpkKYayYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575903872; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cA2iDpQolGtGjsKYpqIIZsLwkl3s5m793VU3l0S5tY0=; b=Y9r5WQMtVQp8aSV1z06fyRJ9jOdhIUtfmAfeyq8S83UMgwiVEJTV1u2wA+eWL16Tu3LBIQmoaMbhEW92Z47RBvNjHm3p2NAuauOkW9AMfs2zLnQPN2AQULA/NF1wutzoTi1fsrb5FrFPi3Y0w8rH0CClZZALbWxdJ0Sch25YaTg= 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 1575903872444396.8917952911554; Mon, 9 Dec 2019 07:04:32 -0800 (PST) Received: from localhost ([::1]:41174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKaL-0005En-SZ for importer@patchew.org; Mon, 09 Dec 2019 10:04:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47031) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKXo-0003Kn-F2 for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKXn-0001D2-Be for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:52 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:34278) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKXn-0001CR-5M for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:51 -0500 Received: by mail-wm1-x343.google.com with SMTP id f4so94078wmj.1 for ; Mon, 09 Dec 2019 07:01:51 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.01.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:01:48 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=cA2iDpQolGtGjsKYpqIIZsLwkl3s5m793VU3l0S5tY0=; b=BjG0OV7KCOZquhmVDFRSgzJqTGOSGIwB3GKU0kpQqbnbGtu5oD2oFoCbhMl/wg9byc UidwY/BWjFJ9x5O7WmfBse6kIjJDpmo5wHpI6V2F5/wUxzUitm3GXqxqW5P/OsWPzASO Kfz2mG61/OGiHHPaW1bh1wB/CVRunklZ8f+JpuyGtMP7SnCm8Qy5qy/7vVml1zXijQfq DxDn4bcAww5wbaS8UWEAdLUHJAhm36x9MrzKqW3zgoMNgwKVVbNq36i+uDlHpTSBC6PR EHjaOQVQGS2aEAMhLY44PbTrY4+beio3I93cr6h4Q75fU0bDZ07bGtEGq2K4P95Bie8k aMQg== 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:mime-version:content-transfer-encoding; bh=cA2iDpQolGtGjsKYpqIIZsLwkl3s5m793VU3l0S5tY0=; b=uBQ7OVuUqUglAlTjky0f4AmtZzMZ/v+nCsVdgiGGa4twOoB2tT0nQVPru5ImUJAkQi kfQ02VQJc6ESyIbZuytmFtAGvuv4t1Z6TYdgL3FnytXCbIcQraCvYlOmD7qN84cm8h+R iGoQUwzrKC2AkI5WBMPmEUttWHLT2/6EK8xNdaCvMylmkoYrekd5LQSNvjKB/B5ElxUH nTVuQs4a8nIdF5HSRGq8riQSlemuuBH0z7su3TGla/8eKSC3A8GfiPu7+IVprJZl9Mda utfdL3ZuZEXd3mWhT3ofklJxfrvumZAGYvZcj1w535bDTTvege09JPXZqdrl5fe+U9MQ WLZg== X-Gm-Message-State: APjAAAXIdgDkl2ZM0Xsh8A9T6dupPfXt+8McqiJFGYpyLsdMi8vmqI4J NSfuxPbyJFgxzrNxvq9UwamC34KF X-Google-Smtp-Source: APXvYqz8fySJwzvZLlv5q/aAsgI5L59Bx7gaPgkw7B9IJChsbbKdoCg9S41b7EzTHsJdlUA22ik5Rw== X-Received: by 2002:a7b:c936:: with SMTP id h22mr24181637wml.115.1575903709437; Mon, 09 Dec 2019 07:01:49 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 02/18] vl: move icount configuration earlier Date: Mon, 9 Dec 2019 16:01:29 +0100 Message-Id: <1575903705-12925-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Once qemu_tcg_configure is turned into a QOM property setter, it will not be able to set a default value for mttcg_enabled. Setting the default will move to the TCG instance_init function, which currently runs before "-icoun= t" is processed. However, it is harmless to do configure_icount for all accelerators; we will just fail later if a non-TCG accelerator is selected. So do that. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- vl.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/vl.c b/vl.c index 6a65a64..f69fea1 100644 --- a/vl.c +++ b/vl.c @@ -2825,6 +2825,12 @@ static void user_register_global_props(void) global_init_func, NULL, NULL); } =20 +static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp) +{ + configure_icount(opts, errp); + return 0; +} + int main(int argc, char **argv, char **envp) { int i; @@ -4165,6 +4171,8 @@ int main(int argc, char **argv, char **envp) * Note: uses machine properties such as kernel-irqchip, must run * after machine_set_property(). */ + qemu_opts_foreach(qemu_find_opts("icount"), + do_configure_icount, NULL, &error_fatal); configure_accelerator(current_machine, argv[0]); =20 /* @@ -4250,13 +4258,9 @@ int main(int argc, char **argv, char **envp) qemu_spice_init(); =20 cpu_ticks_init(); - if (icount_opts) { - if (!tcg_enabled()) { - error_report("-icount is not allowed with hardware virtualizat= ion"); - exit(1); - } - configure_icount(icount_opts, &error_abort); - qemu_opts_del(icount_opts); + if (!tcg_enabled() && use_icount) { + error_report("-icount is not allowed with hardware virtualization"= ); + exit(1); } =20 if (tcg_enabled()) { --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575904098; cv=none; d=zohomail.com; s=zohoarc; b=XxIYWacI8hQ45fZhBMND9QVxnNS4HKVjXJO1h+svj5hNuPWSjwaaKqonU6m7ey8q28u6lWdrl2ZdmQrfMmB5r5p9lQTzdYRMvfgS0nwuYWxQSpqXdJ0nI26sWNoS/JNTCDczkV+8b8OEsIaxQ3IkYA5/ZifnTV/o0G9A1jC2LYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575904098; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=J6kmay0/CICTcqz3JkZsoWunBp9NRsOcVHRaHxwN+QQ=; b=glvZrqv4cOsxDOncQHrk4oPn0Hi7JdapD1spu22HTB+194p7k+ZvjddX96EY0chUmnjb7Y2lfBklldtCmTrj25czM1PGvTmXdhRHGVyoZP8F88pPXU2JcJWycvwCnQzgzC4aqxjD5o7AvqXt+tvTP49h3hlhK+lI6/QEFiNF9p8= 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 1575904098647956.297629788125; Mon, 9 Dec 2019 07:08:18 -0800 (PST) Received: from localhost ([::1]:41234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKe1-0001C3-73 for importer@patchew.org; Mon, 09 Dec 2019 10:08:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47126) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKXt-0003PP-Ok for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKXo-0001EA-Ad for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:57 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:53182) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKXo-0001D9-3T for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:52 -0500 Received: by mail-wm1-x32c.google.com with SMTP id p9so15826795wmc.2 for ; Mon, 09 Dec 2019 07:01:52 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.01.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:01:49 -0800 (PST) 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=J6kmay0/CICTcqz3JkZsoWunBp9NRsOcVHRaHxwN+QQ=; b=hGpl+q4/RP7Dqc4ZLKQ5/xAUtOtpQ4J3RLW/TAW0z2imj9oIwRED58EVuXVlUlINfE YN1w1Yul/1Sx/WPOAIGAk4afQpvxugbXeb3LnHvq/rLNm/bY/p80sNWAf9Kmf1rb3huR qj4lu2wGLTOwdr7RCPwd6tBZNYZ+RkB8YuUHp6QQyZFlYCg04+Ot+OG8EfzsYF0kOA0R 9f2kw+TjUjwVCjuu4AFI0xjpPICzG8VOP6WN3IJje+ASWkwuLpx2c3pl93gTh9pW8hWW 2cCOZREd/9Rglu28i+MAKPByhNrsNldADRxC3SRqVjXVL6dj9f/DCkeSM4WDya4o1jHk vc8w== 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=J6kmay0/CICTcqz3JkZsoWunBp9NRsOcVHRaHxwN+QQ=; b=UhXqrxOA9Y3ntLLtHEAh6MzerfECrm+a/k7AvQdVMGQ+6xBEubtvn99EOEh9Hf9o7y +BRlwZ6AGbEAMj+XA1WBzkDJoIUspNeuCQtf3XegGjHqMM4fcSmhep9xg2MC/k7Vq+AL 88lLP3OXlYBhD0O5LeyPZiK4gPOBsCXsgTaecHwWnhAGBwxmox+xk6JV9lXF3A+M1mZ3 k6pYmVYKIBPQ3M1XPiTKolcjosfiOV03wlrb85+JOXTU3XCtbLjiWJdeJuolhrOUO2fn GchTakwyWwbXTDlGqCJdWPk0yGT3C91iRjsaEiiFbbYO3B/Vni9G8DLW/hMOEFS+JAC9 4/Kg== X-Gm-Message-State: APjAAAUEpQf/RtcwbXsEhbKNdKbZSl7tIfpSl1nEhDWAxF6xrQf6XenZ on7K+/o/cr16Yx+A02G0Mjtlvv8g X-Google-Smtp-Source: APXvYqxIpDxn8fvpDsaqLTXTZE5YNnbVqWFc4rKrIq8k7OSM9Ux6CZcHkRGcfuLGp2NE937IYCaHUA== X-Received: by 2002:a05:600c:2509:: with SMTP id d9mr25863441wma.148.1575903710677; Mon, 09 Dec 2019 07:01:50 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 03/18] tcg: move qemu_tcg_configure to accel/tcg/tcg-all.c Date: Mon, 9 Dec 2019 16:01:30 +0100 Message-Id: <1575903705-12925-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-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:4864:20::32c 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Move everything related to mttcg_enabled in accel/tcg/tcg-all.c, which will make even more sense when "thread" becomes a QOM property. For now, initializing mttcg_enabled in the instance_init function prepares for the next patch, which will only invoke qemu_tcg_configure when the command line includes a -accel option. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- accel/tcg/tcg-all.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++= ++++ cpus.c | 72 --------------------------------------------- 2 files changed, 85 insertions(+), 72 deletions(-) diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index c59d5b0..78a0ab5 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -30,6 +30,11 @@ #include "cpu.h" #include "sysemu/cpus.h" #include "qemu/main-loop.h" +#include "tcg/tcg.h" +#include "include/qapi/error.h" +#include "include/qemu/error-report.h" +#include "include/hw/boards.h" +#include "qemu/option.h" =20 unsigned long tcg_tb_size; =20 @@ -58,6 +63,55 @@ static void tcg_handle_interrupt(CPUState *cpu, int mask) } } =20 +/* + * We default to false if we know other options have been enabled + * which are currently incompatible with MTTCG. Otherwise when each + * guest (target) has been updated to support: + * - atomic instructions + * - memory ordering primitives (barriers) + * they can set the appropriate CONFIG flags in ${target}-softmmu.mak + * + * Once a guest architecture has been converted to the new primitives + * there are two remaining limitations to check. + * + * - The guest can't be oversized (e.g. 64 bit guest on 32 bit host) + * - The host must have a stronger memory order than the guest + * + * It may be possible in future to support strong guests on weak hosts + * but that will require tagging all load/stores in a guest with their + * implicit memory order requirements which would likely slow things + * down a lot. + */ + +static bool check_tcg_memory_orders_compatible(void) +{ +#if defined(TCG_GUEST_DEFAULT_MO) && defined(TCG_TARGET_DEFAULT_MO) + return (TCG_GUEST_DEFAULT_MO & ~TCG_TARGET_DEFAULT_MO) =3D=3D 0; +#else + return false; +#endif +} + +static bool default_mttcg_enabled(void) +{ + if (use_icount || TCG_OVERSIZED_GUEST) { + return false; + } else { +#ifdef TARGET_SUPPORTS_MTTCG + return check_tcg_memory_orders_compatible(); +#else + return false; +#endif + } +} + +static void tcg_accel_instance_init(Object *obj) +{ + TCGState *s =3D TCG_STATE(obj); + + mttcg_enabled =3D default_mttcg_enabled(); +} + static int tcg_init(MachineState *ms) { tcg_exec_init(tcg_tb_size * 1024 * 1024); @@ -65,6 +119,36 @@ static int tcg_init(MachineState *ms) return 0; } =20 +void qemu_tcg_configure(QemuOpts *opts, Error **errp) +{ + const char *t =3D qemu_opt_get(opts, "thread"); + if (!t) { + return; + } + if (strcmp(t, "multi") =3D=3D 0) { + if (TCG_OVERSIZED_GUEST) { + error_setg(errp, "No MTTCG when guest word size > hosts"); + } else if (use_icount) { + error_setg(errp, "No MTTCG when icount is enabled"); + } else { +#ifndef TARGET_SUPPORTS_MTTCG + warn_report("Guest not yet converted to MTTCG - " + "you may get unexpected results"); +#endif + if (!check_tcg_memory_orders_compatible()) { + warn_report("Guest expects a stronger memory ordering " + "than the host provides"); + error_printf("This may cause strange/hard to debug errors\= n"); + } + mttcg_enabled =3D true; + } + } else if (strcmp(t, "single") =3D=3D 0) { + mttcg_enabled =3D false; + } else { + error_setg(errp, "Invalid 'thread' setting %s", t); + } +} + static void tcg_accel_class_init(ObjectClass *oc, void *data) { AccelClass *ac =3D ACCEL_CLASS(oc); @@ -78,6 +162,7 @@ static void tcg_accel_class_init(ObjectClass *oc, void *= data) static const TypeInfo tcg_accel_type =3D { .name =3D TYPE_TCG_ACCEL, .parent =3D TYPE_ACCEL, + .instance_init =3D tcg_accel_instance_init, .class_init =3D tcg_accel_class_init, }; =20 diff --git a/cpus.c b/cpus.c index 63bda15..b472378 100644 --- a/cpus.c +++ b/cpus.c @@ -166,78 +166,6 @@ typedef struct TimersState { static TimersState timers_state; bool mttcg_enabled; =20 -/* - * We default to false if we know other options have been enabled - * which are currently incompatible with MTTCG. Otherwise when each - * guest (target) has been updated to support: - * - atomic instructions - * - memory ordering primitives (barriers) - * they can set the appropriate CONFIG flags in ${target}-softmmu.mak - * - * Once a guest architecture has been converted to the new primitives - * there are two remaining limitations to check. - * - * - The guest can't be oversized (e.g. 64 bit guest on 32 bit host) - * - The host must have a stronger memory order than the guest - * - * It may be possible in future to support strong guests on weak hosts - * but that will require tagging all load/stores in a guest with their - * implicit memory order requirements which would likely slow things - * down a lot. - */ - -static bool check_tcg_memory_orders_compatible(void) -{ -#if defined(TCG_GUEST_DEFAULT_MO) && defined(TCG_TARGET_DEFAULT_MO) - return (TCG_GUEST_DEFAULT_MO & ~TCG_TARGET_DEFAULT_MO) =3D=3D 0; -#else - return false; -#endif -} - -static bool default_mttcg_enabled(void) -{ - if (use_icount || TCG_OVERSIZED_GUEST) { - return false; - } else { -#ifdef TARGET_SUPPORTS_MTTCG - return check_tcg_memory_orders_compatible(); -#else - return false; -#endif - } -} - -void qemu_tcg_configure(QemuOpts *opts, Error **errp) -{ - const char *t =3D qemu_opt_get(opts, "thread"); - if (t) { - if (strcmp(t, "multi") =3D=3D 0) { - if (TCG_OVERSIZED_GUEST) { - error_setg(errp, "No MTTCG when guest word size > hosts"); - } else if (use_icount) { - error_setg(errp, "No MTTCG when icount is enabled"); - } else { -#ifndef TARGET_SUPPORTS_MTTCG - warn_report("Guest not yet converted to MTTCG - " - "you may get unexpected results"); -#endif - if (!check_tcg_memory_orders_compatible()) { - warn_report("Guest expects a stronger memory ordering " - "than the host provides"); - error_printf("This may cause strange/hard to debug err= ors\n"); - } - mttcg_enabled =3D true; - } - } else if (strcmp(t, "single") =3D=3D 0) { - mttcg_enabled =3D false; - } else { - error_setg(errp, "Invalid 'thread' setting %s", t); - } - } else { - mttcg_enabled =3D default_mttcg_enabled(); - } -} =20 /* The current number of executed instructions is based on what we * originally budgeted minus the current state of the decrementing --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575904033; cv=none; d=zohomail.com; s=zohoarc; b=CI+SZ03H9caeBCWrEkhrIW/ocZyKdD44o6o/Z4HL+FX+gPm4avOlSaJCPYUV3yY3HnEAlgm6JkF7gjTldogtm2wogKZ48ULqhRHY+HDsKR8MdNBE1+dlBR9oBVbtKNkbLkwH3hdPntYX1P9rf8OPG42mC2GU7o1j9/3CrCojsvs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575904033; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=4/2rFG2uQPrnJ3NY/tRy/zI0rCDFvW24BIkyj5B4cS8=; b=nnYbPqYK1eSl0FzzqewG8dLntf+wjuSuixEandsPmwbOGr7lvcfxoScGjLQ5XfSJyi8PU7ErbgVoULdxT1GuoyQ4vRc0qN+OwF/A7iQjLAXMQZJFuITJpDbPSoPYqDlQL3xnau8zcETa4UBk5cdUH3TFVpyb5uOPhGFkyucBRLY= 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 1575904033178653.0219425888896; Mon, 9 Dec 2019 07:07:13 -0800 (PST) Received: from localhost ([::1]:41222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKcx-0000AK-Rq for importer@patchew.org; Mon, 09 Dec 2019 10:07:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47057) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKXq-0003L7-Ci for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKXp-0001Ey-A4 for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:54 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:51800) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKXp-0001EM-4H for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:53 -0500 Received: by mail-wm1-x342.google.com with SMTP id g206so15857664wme.1 for ; Mon, 09 Dec 2019 07:01:53 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.01.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:01:51 -0800 (PST) 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=4/2rFG2uQPrnJ3NY/tRy/zI0rCDFvW24BIkyj5B4cS8=; b=aVt1heXPjfklF8r5JXHDoRMl1pjQ+Qcg3kziIyQElXzTT6N3IgAOAbs71zqQMSORDI 6vr2nUdUdlAkzBmS9QddlhUB9HKS/2XuMjvD0jekW6C3Pe6zR/kwxYAi53HtX5jHI6Lo hKVNT1yh7E8zux9EFZT0ig2HP6QzaeEGgbJhAgBhFmxaPIWDeG7eLnY5GWGJSkFJdiXW FIYP6yxTTn1GLotZi75nO2pZQzmvidxDVZnyhnSx0s8w6u+d4pwnm4IpyshOhR+0nGNy bdYQSHKgBrA62ftD9tLaM15txlApqwRv2zw5j5UMyKS5s6Dx4ySC8iAM5IUNvDzkGgI7 im6Q== 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=4/2rFG2uQPrnJ3NY/tRy/zI0rCDFvW24BIkyj5B4cS8=; b=pmhmOqAIKrDapHase1Ij/6G7pE217vv18TnFbqtjkV2J8XG9KHdy4C8pWIdqBvSwB4 UEZ18PW0luFmXgbefOx4xMLJDj+Kj6sTD/oft23rToMDhlVbSNPYhXlqjPJGxT1o6GnG 74VEg9LcSK1Fhac/vdWj3M6qUVibCmoyU5M3OlAZc1IrjT5/OmkYh6Pr+udTZP1UuaV1 Bb2gN+uYs5oczBfQbEMSRh5/q8cLC3DT4hH21j6ngbcuxAkJfD/2i/kLXLFdRJMX9G0C 9BaqQZHwmTdQG/tHFev5u8+qXOcqXF3vWOR2iRoNLtKW0/6rl4ELgmj1w/OeuYehh0o/ mcmA== X-Gm-Message-State: APjAAAUQKAERLSjM40QgECLC22eaXKKl83Pu6KCptDJFttfJfr922wPA 5Ezz66hVkXjURhWuypNDWvKuezxz X-Google-Smtp-Source: APXvYqzzoTQHMLsSext7/G6Hc3Cyqw9mYv8UFHrMXvFldX0VkxQj2irJggTRYPjJwLQMZB8a+dutTA== X-Received: by 2002:a1c:dcd5:: with SMTP id t204mr26540735wmg.34.1575903711884; Mon, 09 Dec 2019 07:01:51 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 04/18] vl: extract accelerator option processing to a separate function Date: Mon, 9 Dec 2019 16:01:31 +0100 Message-Id: <1575903705-12925-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-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:4864:20::342 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As a first step towards supporting multiple "-accel" options, push the late processing of -icount and -accel into a new function, and use qemu_opts_foreach to retrieve -accel options instead of stashing them into globals. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- vl.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/vl.c b/vl.c index f69fea1..1ad6dfb 100644 --- a/vl.c +++ b/vl.c @@ -2831,6 +2831,25 @@ static int do_configure_icount(void *opaque, QemuOpt= s *opts, Error **errp) return 0; } =20 +static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **= errp) +{ + if (tcg_enabled()) { + qemu_tcg_configure(opts, &error_fatal); + } + return 0; +} + +static void configure_accelerators(void) +{ + qemu_opts_foreach(qemu_find_opts("accel"), + do_configure_accelerator, NULL, &error_fatal); + + if (!tcg_enabled() && use_icount) { + error_report("-icount is not allowed with hardware virtualization"= ); + exit(1); + } +} + int main(int argc, char **argv, char **envp) { int i; @@ -4258,14 +4277,7 @@ int main(int argc, char **argv, char **envp) qemu_spice_init(); =20 cpu_ticks_init(); - if (!tcg_enabled() && use_icount) { - error_report("-icount is not allowed with hardware virtualization"= ); - exit(1); - } - - if (tcg_enabled()) { - qemu_tcg_configure(accel_opts, &error_fatal); - } + configure_accelerators(); =20 if (default_net) { QemuOptsList *net =3D qemu_find_opts("net"); --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575903947; cv=none; d=zohomail.com; s=zohoarc; b=Nf7eSA2TlTJDxsw/Df3hI4/4vSuopC7gt121JrPbvw4aQXnu1sP3u0noH7Yfb2kosfrmmJwmsao8weTpZ2SI3WGFqIeMZ2PJGZQqf40EhF7QnYzdtx8jjMjNV9dCZHFAV7PQx5ilGP9KaTecE91ti41K7g2cLhQP2nELa5zpTRw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575903947; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+pQjQbRMpxB35JdVfbxTAM7nDnDf9lgOcGNlPo/9bpo=; b=F7t4bXPVYZnYIyCL9XI/yd/uh1gsCxk/PJGhO11pP2ImmlUkIU2S/ziL4us8HSu9M2bBQX+IPLpfO2zojkrJodjZufU+1/KLKlYqIhtxXa3+auY2bojMbbQzkW36X4cb5tYVtzsWzuCLEngLaPpHkVQ0rk9NaYlKd9ZTWPqom74= 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 1575903947730423.081286325531; Mon, 9 Dec 2019 07:05:47 -0800 (PST) Received: from localhost ([::1]:41178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKba-0006bY-2H for importer@patchew.org; Mon, 09 Dec 2019 10:05:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47100) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKXs-0003Nf-At for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKXq-0001Fp-H6 for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:56 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:35401) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKXq-0001FH-9n for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:54 -0500 Received: by mail-wm1-x342.google.com with SMTP id c20so13811130wmb.0 for ; Mon, 09 Dec 2019 07:01:54 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.01.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:01:52 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=+pQjQbRMpxB35JdVfbxTAM7nDnDf9lgOcGNlPo/9bpo=; b=qEMInZvESR61F7wpRO9Elc6hCzlsWTOpincnhlhPRuUYshqoZv01HDL/BeWP99sPFw glkhyDabPaguDfsqoIR+/GlHhAM5k2MsAnC5YB0tthDiPaTacRSD6khnFIRevbtp+MHO EiLrxq5OSd0CyndP6Yo05fw321gaMHBBKNs/tWkMzTqYebkTw27VijIiRXDp13AJTNh2 kd//w2X92yTkgVLpIMIUQEla169cruhsMG18AxQ/UBoMz8j67DlcKeCt0UU4ScOQdjfA grJQwA//QSx9twcsYTCpbj/NCCBpylqiN5LENSbnlNciSuuxUzOYDlra7tHgtsVWluFx 1SBQ== 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:mime-version:content-transfer-encoding; bh=+pQjQbRMpxB35JdVfbxTAM7nDnDf9lgOcGNlPo/9bpo=; b=l3X8dS4uWZiGtKYHqxV92gLQR38HUESDJwYM9Cvwzs001MxnQrC5cRF5IuijrGgHKy IwYDMcyPOd2b64Gh5gollYByQM+EOA/rHr700QvJKmViG1dn0RlHOXgUvjnsmRxyoqBW 2FY45JLfqY7/5+aBOPsF4L+Fe7J17DsrWOnY4BZuxjEEbFjK4ZSke95ZcNSdyOnrPfsU 5ty/Fs0GqiuX5N/L98CdnzlUkiiMLVNtxOBtOMfLG3JiaS5YRB3c23SI5VOW5GIv3Okz fFO23wZ6R2UemdaV1y1OrThxcjfB7SkFTRQKzAkUdOYGr/WwF8LL+jnGvdrMh478R4h9 mjFg== X-Gm-Message-State: APjAAAX+eEUxbLoOGTpvRKKFKvIsWluBdJ5bD7UVw+FdqOM3V+H24Vhp 6lVdFPbbqHlZsstk9oZEdwis+B29 X-Google-Smtp-Source: APXvYqyPopqIW8FbIpJyL0ONHG58o4zOlRvKMrspX828Jllzm8JDIGIx0/tN0PRPH84CBVccBtRBLw== X-Received: by 2002:a05:600c:2301:: with SMTP id 1mr19426021wmo.147.1575903712791; Mon, 09 Dec 2019 07:01:52 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 05/18] vl: merge -accel processing into configure_accelerators Date: Mon, 9 Dec 2019 16:01:32 +0100 Message-Id: <1575903705-12925-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The next step is to move the parsing of "-machine accel=3D..." into vl.c, unifying it with the configure_accelerators() function that has just been introduced. This way, we will be able to desugar it into multiple "-accel" options, without polluting accel/accel.c. The CONFIG_TCG and CONFIG_KVM symbols are not available in vl.c, but we can use accel_find instead to find their value at runtime. Once we know that the binary has one of TCG or KVM, the default accelerator can be expressed simply as "tcg:kvm", because TCG never fails to initialize. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- accel/accel.c | 69 ++--------------------------------------------= ---- include/sysemu/accel.h | 4 ++- vl.c | 64 ++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 64 insertions(+), 73 deletions(-) diff --git a/accel/accel.c b/accel/accel.c index 5fa3171..60c3827 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -28,13 +28,7 @@ #include "hw/boards.h" #include "sysemu/arch_init.h" #include "sysemu/sysemu.h" -#include "sysemu/kvm.h" -#include "sysemu/qtest.h" -#include "hw/xen/xen.h" #include "qom/object.h" -#include "qemu/error-report.h" -#include "qemu/option.h" -#include "qapi/error.h" =20 static const TypeInfo accel_type =3D { .name =3D TYPE_ACCEL, @@ -44,7 +38,7 @@ static const TypeInfo accel_type =3D { }; =20 /* Lookup AccelClass from opt_name. Returns NULL if not found */ -static AccelClass *accel_find(const char *opt_name) +AccelClass *accel_find(const char *opt_name) { char *class_name =3D g_strdup_printf(ACCEL_CLASS_NAME("%s"), opt_name); AccelClass *ac =3D ACCEL_CLASS(object_class_by_name(class_name)); @@ -52,7 +46,7 @@ static AccelClass *accel_find(const char *opt_name) return ac; } =20 -static int accel_init_machine(AccelClass *acc, MachineState *ms) +int accel_init_machine(AccelClass *acc, MachineState *ms) { ObjectClass *oc =3D OBJECT_CLASS(acc); const char *cname =3D object_class_get_name(oc); @@ -71,65 +65,6 @@ static int accel_init_machine(AccelClass *acc, MachineSt= ate *ms) return ret; } =20 -void configure_accelerator(MachineState *ms, const char *progname) -{ - const char *accel; - char **accel_list, **tmp; - int ret; - bool accel_initialised =3D false; - bool init_failed =3D false; - AccelClass *acc =3D NULL; - - accel =3D qemu_opt_get(qemu_get_machine_opts(), "accel"); - if (accel =3D=3D NULL) { - /* Select the default accelerator */ - int pnlen =3D strlen(progname); - if (pnlen >=3D 3 && g_str_equal(&progname[pnlen - 3], "kvm")) { - /* If the program name ends with "kvm", we prefer KVM */ - accel =3D "kvm:tcg"; - } else { -#if defined(CONFIG_TCG) - accel =3D "tcg"; -#elif defined(CONFIG_KVM) - accel =3D "kvm"; -#else - error_report("No accelerator selected and" - " no default accelerator available"); - exit(1); -#endif - } - } - - accel_list =3D g_strsplit(accel, ":", 0); - - for (tmp =3D accel_list; !accel_initialised && tmp && *tmp; tmp++) { - acc =3D accel_find(*tmp); - if (!acc) { - continue; - } - ret =3D accel_init_machine(acc, ms); - if (ret < 0) { - init_failed =3D true; - error_report("failed to initialize %s: %s", - acc->name, strerror(-ret)); - } else { - accel_initialised =3D true; - } - } - g_strfreev(accel_list); - - if (!accel_initialised) { - if (!init_failed) { - error_report("-machine accel=3D%s: No accelerator found", acce= l); - } - exit(1); - } - - if (init_failed) { - error_report("Back to %s accelerator", acc->name); - } -} - void accel_setup_post(MachineState *ms) { AccelState *accel =3D ms->accelerator; diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h index 8eb60b8..90b6213 100644 --- a/include/sysemu/accel.h +++ b/include/sysemu/accel.h @@ -66,7 +66,9 @@ typedef struct AccelClass { =20 extern unsigned long tcg_tb_size; =20 -void configure_accelerator(MachineState *ms, const char *progname); +AccelClass *accel_find(const char *opt_name); +int accel_init_machine(AccelClass *acc, MachineState *ms); + /* Called just before os_setup_post (ie just before drop OS privs) */ void accel_setup_post(MachineState *ms); =20 diff --git a/vl.c b/vl.c index 1ad6dfb..19c77b4 100644 --- a/vl.c +++ b/vl.c @@ -2839,8 +2839,65 @@ static int do_configure_accelerator(void *opaque, Qe= muOpts *opts, Error **errp) return 0; } =20 -static void configure_accelerators(void) +static void configure_accelerators(const char *progname) { + const char *accel; + char **accel_list, **tmp; + int ret; + bool accel_initialised =3D false; + bool init_failed =3D false; + AccelClass *acc =3D NULL; + + qemu_opts_foreach(qemu_find_opts("icount"), + do_configure_icount, NULL, &error_fatal); + + accel =3D qemu_opt_get(qemu_get_machine_opts(), "accel"); + if (accel =3D=3D NULL) { + /* Select the default accelerator */ + if (!accel_find("tcg") && !accel_find("kvm")) { + error_report("No accelerator selected and" + " no default accelerator available"); + exit(1); + } else { + int pnlen =3D strlen(progname); + if (pnlen >=3D 3 && g_str_equal(&progname[pnlen - 3], "kvm")) { + /* If the program name ends with "kvm", we prefer KVM */ + accel =3D "kvm:tcg"; + } else { + accel =3D "tcg:kvm"; + } + } + } + + accel_list =3D g_strsplit(accel, ":", 0); + + for (tmp =3D accel_list; !accel_initialised && tmp && *tmp; tmp++) { + acc =3D accel_find(*tmp); + if (!acc) { + continue; + } + ret =3D accel_init_machine(acc, current_machine); + if (ret < 0) { + init_failed =3D true; + error_report("failed to initialize %s: %s", + acc->name, strerror(-ret)); + } else { + accel_initialised =3D true; + } + } + g_strfreev(accel_list); + + if (!accel_initialised) { + if (!init_failed) { + error_report("-machine accel=3D%s: No accelerator found", acce= l); + } + exit(1); + } + + if (init_failed) { + error_report("Back to %s accelerator", acc->name); + } + qemu_opts_foreach(qemu_find_opts("accel"), do_configure_accelerator, NULL, &error_fatal); =20 @@ -4190,9 +4247,7 @@ int main(int argc, char **argv, char **envp) * Note: uses machine properties such as kernel-irqchip, must run * after machine_set_property(). */ - qemu_opts_foreach(qemu_find_opts("icount"), - do_configure_icount, NULL, &error_fatal); - configure_accelerator(current_machine, argv[0]); + configure_accelerators(argv[0]); =20 /* * Beware, QOM objects created before this point miss global and @@ -4277,7 +4332,6 @@ int main(int argc, char **argv, char **envp) qemu_spice_init(); =20 cpu_ticks_init(); - configure_accelerators(); =20 if (default_net) { QemuOptsList *net =3D qemu_find_opts("net"); --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575904180; cv=none; d=zohomail.com; s=zohoarc; b=IZ2uuzo6qhJPiROZZOZErYFiv7LkxgM8byfDgDWGQ3N6hucUUsdSlfj0oc3ZR+QDz2u0ZqF5gV4/PtiPiPSwecUs8G2ZY+NAnazd6Og6bI445tBW102x+C4VKLepcgm1Rt3qUeF4U4ASDxtnDO8b+AUrZlHHm8I7xYeGjCubolg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575904180; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=VmTQcO7MS7thh5/mwSJ+9wNSUM+noesb+aFJvdPNQwo=; b=OgAdPbyEbBOgrEiPtj+YE9+I1X0Gh2rSDpsfUdLRhpS4KEr4xfT4dJ2wcpua+Bzz6ntWYdNX84sFMS0DEq90PgDc2/UoxrKfQve5XSh/cfMFwgqTSq5Abcr7PL9jhvpLf57EGzPEpypJk6B8A3RYAqNxxVl31ToDiTMJWmhD21M= 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 1575904180569519.8869086948159; Mon, 9 Dec 2019 07:09:40 -0800 (PST) Received: from localhost ([::1]:41250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKfK-0002pU-Gx for importer@patchew.org; Mon, 09 Dec 2019 10:09:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47093) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKXr-0003NC-W3 for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKXq-0001Gt-TS for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:55 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:35402) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKXq-0001FU-NM for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:54 -0500 Received: by mail-wm1-x343.google.com with SMTP id c20so13811165wmb.0 for ; Mon, 09 Dec 2019 07:01:54 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.01.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:01:53 -0800 (PST) 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=VmTQcO7MS7thh5/mwSJ+9wNSUM+noesb+aFJvdPNQwo=; b=ELjMaPHe71zJLY3COqJF5T1dfV6q1rmHsTPfUtp29uxyKF02gDegWwENtj2AOkBrdF Sm1a8QSpfb2vzFf1/b2+2fnI94DKn2OxHqX1S5Gw3477qQuiNR5v/sEEq2QXkxaQf4GW agA2KmGds4CVpr/cOcZO1V7J4MjJPiU4hdr5cXLKOhEqdc2EGZYGAzngzD/kU/1qntSN IYjStShb8OgTsB7N+MUo0n+pPqZmSA4tey60YwaeGXHRS4fN1zUwJkY6OqDC54/3nURh 808AXO6yAVng657nX7gLypAuFKWhLRhgX8gYIh7kjp//mxxXSJR0K6Dc6dZ+dn6KUBU0 XyTg== 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=VmTQcO7MS7thh5/mwSJ+9wNSUM+noesb+aFJvdPNQwo=; b=bK9Cn3CHENSjT5moALxnqnlD4IsSCrM99zUdYhD3RyLsvw1r5E9iyXEHJE8s8KCcSO 0gO72WUc4rMZtb9FK2FFMU9FPgnrSpfl65GH6qOrCu5egQLdVw2vW3EsLZEie55p/SKP bsh7L3AXedD0GqGiQKiRZ6pNTglvw60zv7x+Qlrs+eTGsZ++RyVESrfxp7LC8NmFg3X/ lptBBxNVrjL8af19d4r1cZtsydXVKvSsJyy7NVyL7gQ9EOEerefU88KYockmBXGfSJzW e7ZkUpR40vVvl+6CrfSQEaKWtaO33NjwuQGQaDQfIw1Y3vAoHlcvEf/qOCMN84Q93VTW WeDQ== X-Gm-Message-State: APjAAAWYcttEDCB2ZmsjAURGP3HIAiD+trZmkzMhxYHUOPR4ooORIqQC A+6JVW1MnI3jhCoFgLSpJtywbkrZ X-Google-Smtp-Source: APXvYqwQyZxaHmRHVMZG1dAAwvbd8sx0qaZu3Q6zNRGu/p7U91JcROixvpfOPSq+2gFuq4Mij1wRHA== X-Received: by 2002:a1c:7911:: with SMTP id l17mr26235262wme.44.1575903713524; Mon, 09 Dec 2019 07:01:53 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 06/18] accel: compile accel/accel.c just once Date: Mon, 9 Dec 2019 16:01:33 +0100 Message-Id: <1575903705-12925-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-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:4864:20::343 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now that accel/accel.c does not use CONFIG_TCG or CONFIG_KVM anymore, it need not be compiled once for every softmmu target. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- Makefile.objs | 1 + accel/Makefile.objs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.objs b/Makefile.objs index 11ba1a3..b6fcbac 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -55,6 +55,7 @@ common-obj-$(CONFIG_POSIX) +=3D os-posix.o =20 common-obj-$(CONFIG_LINUX) +=3D fsdev/ =20 +common-obj-y +=3D accel/ common-obj-y +=3D migration/ =20 common-obj-y +=3D audio/ diff --git a/accel/Makefile.objs b/accel/Makefile.objs index 8b498d3..17e5ac6 100644 --- a/accel/Makefile.objs +++ b/accel/Makefile.objs @@ -1,4 +1,4 @@ -obj-$(CONFIG_SOFTMMU) +=3D accel.o +common-obj-$(CONFIG_SOFTMMU) +=3D accel.o obj-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_POSIX)) +=3D qtest.o obj-$(CONFIG_KVM) +=3D kvm/ obj-$(CONFIG_TCG) +=3D tcg/ --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575904314; cv=none; d=zohomail.com; s=zohoarc; b=LZqyTGl2n5SLYPXUIn4FFNdlZLKv4P0MeZe1kHMr7c6+4DAJOR+Pdr+49qVLmG/vFl48urBRx+q40NwW9PcDzkkIjBlqPY9gig/l+se9rdTZrFIp4EQIB9vLVk6GB73G2EIsmdJcFzd5oSx/4FpZ4HIKzIiNAh+tn6hs7zrTRfo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575904314; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=BhSHBEFiJOtlRUjScEEDImi8MRa01lSsuQLxl3Kz++4=; b=mJNHxWY0BEuSY2vJzaZk+d05z7onj/dh7+53Gp3v9XDYN+CrlDvLpYBvZNYWHaWKmmySnWFm/wVVaoDAtGYpo2Z/Hx/YPhkGdkBx5rYSupEOZuCy5EeDn8A2pCNESHAuZIX7FvdqsC5FayZgCcGV80cd9c/WBWLq0Qmrc/clfXE= 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 1575904314932830.4753062958689; Mon, 9 Dec 2019 07:11:54 -0800 (PST) Received: from localhost ([::1]:41294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKhV-0005eI-DN for importer@patchew.org; Mon, 09 Dec 2019 10:11:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47178) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKXx-0003Tj-4U for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKXr-0001Ij-St for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:01 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:53787) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKXr-0001HT-MA for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:55 -0500 Received: by mail-wm1-x343.google.com with SMTP id n9so15328520wmd.3 for ; Mon, 09 Dec 2019 07:01:55 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.01.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:01:53 -0800 (PST) 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=BhSHBEFiJOtlRUjScEEDImi8MRa01lSsuQLxl3Kz++4=; b=LuIxSO3bYcU2Nty96VfIdiXf3GsOVSAZiEAvnezWOa5QV+lle8aI3JybYXQNcBalSM SbP6zeammGoOFix9zTz1iulC4ebI23Spbaysdcdyako0Zdta1SgU+/EQdhASllSYvnxT nhnmErGd/4ADkZjzXOHO+XckYoTQvH1LQ8Pc6V+qnJfVpFy/Bv62tYQBxkaUH9keT9rS v6wD34l4aAcA6Ys5AgxC7ute9bwiHDlNiy8z/Dh31REm3O367XbNHMZ0+leSaMHfaVuB qhxKPJNiEAMX5wR54PuhTeIZaX5bRyO7pOav1rBGd1xa+L9zALndifzAJPLwsZxXEzA2 wJmw== 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=BhSHBEFiJOtlRUjScEEDImi8MRa01lSsuQLxl3Kz++4=; b=HYg7frqZlEtXedzUnwxCkVNZSUCerE3rt8mF5wma+wonKVlH0IuQeoJMeiDeF2ap8Y Pq0D0+au90erys//P4Dq+KwDNsFaH8M6GWqGq//FfPM2Js2IF2jp3DT+eklVUHuXtBGx QIaSuBSYOVxqi154Y5rESwz8VLpqdWldlSiXOj3L3nfzH3SfXBYL90FpYZiZ2571MvB9 LFtUsI0XfXuxdN0eB2ZLvLJ3J41aLNKb7gaW0e/NmDyrM7FuyJzvX/yPBQMd+xn+tLgQ 3qq6IZTmaDrHy4ECmn9l7C89LlBbhPGao0UY+MXqVYUXhZfJryVBkyo2sNGjbaEFUnB5 MGJg== X-Gm-Message-State: APjAAAWPspx0MoDf/tr5SC+Cp71n0NAUGj6I9Lz97U/WigEOkjC5WM7m Z7itVNCkTmuiVuxUBBpREslfhXmE X-Google-Smtp-Source: APXvYqz+X67ceED+6E8riqGQspBqDoCEED8Vu4bkqP+z72iY5N6KUQFry104KzvyO99rAFhSbt3JKw== X-Received: by 2002:a1c:8153:: with SMTP id c80mr24773899wmd.58.1575903714502; Mon, 09 Dec 2019 07:01:54 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 07/18] vl: introduce object_parse_property_opt Date: Mon, 9 Dec 2019 16:01:34 +0100 Message-Id: <1575903705-12925-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-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:4864:20::343 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We will reuse the parsing loop of machine_set_property soon for "-accel", but we do not want the "_" -> "-" conversion since "-accel" can just standardize on dashes. We will also add a bunch of legacy option handling to keep the QOM machine object clean. Extract the loop into a separate function, and keep the legacy handling in machine_set_property. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- vl.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/vl.c b/vl.c index 19c77b4..66dff1b 100644 --- a/vl.c +++ b/vl.c @@ -2615,27 +2615,17 @@ static MachineClass *select_machine(void) return machine_class; } =20 -static int machine_set_property(void *opaque, - const char *name, const char *value, - Error **errp) +static int object_parse_property_opt(Object *obj, + const char *name, const char *value, + const char *skip, Error **errp) { - Object *obj =3D OBJECT(opaque); Error *local_err =3D NULL; - char *p, *qom_name; =20 - if (strcmp(name, "type") =3D=3D 0) { + if (g_str_equal(name, skip)) { return 0; } =20 - qom_name =3D g_strdup(name); - for (p =3D qom_name; *p; p++) { - if (*p =3D=3D '_') { - *p =3D '-'; - } - } - - object_property_parse(obj, value, qom_name, &local_err); - g_free(qom_name); + object_property_parse(obj, value, name, &local_err); =20 if (local_err) { error_propagate(errp, local_err); @@ -2645,6 +2635,21 @@ static int machine_set_property(void *opaque, return 0; } =20 +static int machine_set_property(void *opaque, + const char *name, const char *value, + Error **errp) +{ + g_autofree char *qom_name =3D g_strdup(name); + char *p; + + for (p =3D qom_name; *p; p++) { + if (*p =3D=3D '_') { + *p =3D '-'; + } + } + + return object_parse_property_opt(opaque, name, value, "type", errp); +} =20 /* * Initial object creation happens before all other --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575904233; cv=none; d=zohomail.com; s=zohoarc; b=cqpEdaPkCSWYI354VRGGE0Jph9NoOjoATFuD8yofg/te3G7aFDgJ0nVQ0z9IVcRh9Ya03ycdakjBso9RteJ/kNVSsxOq3Tr6Gs8MYiX0EVcJYmWFMFiF13KVo2i5j9QNKcynhObViyvtidAznUVxmC/fKJX9yAtpaieQorfB7Jo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575904233; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=6IQuv/QEggSTXD+5GhFOi5TkstH1/qjSjpCg/fK/lgs=; b=hUMlDlKALABZEwtRMaHjBbZhk83HVIbPZbnthxnXCwNVYgEGsbrhJ01CIUjlQ4Nd8SzbbGiKnyFEUaZiS2/cMJ+Kindj3yEOCyDaMDghtaltWRlIZ22o+47Zr5LfaSADnPpHHzn974jLtYJyQo8iG4gaPpaCMHfJEOQ+duuBi64= 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 1575904233938489.9791138026728; Mon, 9 Dec 2019 07:10:33 -0800 (PST) Received: from localhost ([::1]:41258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKgC-0003rJ-DU for importer@patchew.org; Mon, 09 Dec 2019 10:10:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47155) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKXv-0003R8-5a for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKXt-0001Jz-Dq for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:59 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:39672) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKXt-0001J7-6U for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:57 -0500 Received: by mail-wr1-x42c.google.com with SMTP id y11so16539467wrt.6 for ; Mon, 09 Dec 2019 07:01:57 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.01.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:01:54 -0800 (PST) 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=6IQuv/QEggSTXD+5GhFOi5TkstH1/qjSjpCg/fK/lgs=; b=scP8W5E6glq3QUB92yLksNfs9+8/9k26QEWbV+cpR3fI9S+EqdlLgWrCd88NU1CD2t Wt7x5jvNPpLb98MQ1ZB1IeO2r6H/PWicZ5WD7nkyYAG7oUFE8nG8Mq4zURLJAe8/ya+6 /9wUitN7T7QBtir0FCOGLyn/xwNdaU5bo8kYELZieQIIfWxJv1T5nEk1+qAnPx/UxuXc 0AXaAK/zvWOoCvjJGgWQfUTAbGodTMNPZc8LRChymzpWl+Z7IdmzcHKX0neq6CXdmJWK txokCMgTBydwI8eCf1el2fgUoLm+iRFmBmj3Q2U3GP4sIC9uPyqguKVyZB861Rj+hwSX +Xuw== 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=6IQuv/QEggSTXD+5GhFOi5TkstH1/qjSjpCg/fK/lgs=; b=eyACpgLwm4Pg09tFcq/AGNBHD0VUNH1JXLKH50fxjbia3ZMNkK5HzQguUNxc4OROlk ahQRhWRL3d2VmTAwaHz3puj8UqnFi9IkZDy+TjE5yodfeTmZXKW74YZYZerp4+dzFWom KzzeFP7p+m9hRBr4PttGmwDHG02TQgyr1fNOOHH/w7GQeRWkzpN8W10X8mDadL/XoI6o /UUvrpMEnNDwbsj/aDBogwAJuhd4uzRwA7mWSF4VwZbV1/TN1BIppq7D6SIO+RJP2EkK Ijtde3jM6cFFnnd3kLOiCwlLcnqKuKu1xdCa3cga+90jWFzP3vEzT23bq4OUApo3RSVB /zag== X-Gm-Message-State: APjAAAX380Nk0/W0FxRf5Uh8rgGAB20lssBsfqYQJdCgrFwNhxgPzRmx esePGN9if/5pVWa8QGj4bZ4mRu/Z X-Google-Smtp-Source: APXvYqwU/uIILuKXgbKQb7W6X/T6WDky9Lk6RB7jaN/pwGCDodHISn1BeVXV8rfPUiciDvK0rExLcw== X-Received: by 2002:adf:e3c7:: with SMTP id k7mr2837035wrm.80.1575903715756; Mon, 09 Dec 2019 07:01:55 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 08/18] vl: configure accelerators from -accel options Date: Mon, 9 Dec 2019 16:01:35 +0100 Message-Id: <1575903705-12925-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-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:4864:20::42c 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Drop the "accel" property from MachineState, and instead desugar "-machine accel=3D" to a list of "-accel" options. This has a semantic change due to removing merge_lists from -accel. For example: - "-accel kvm -accel tcg" all but ignored "-accel kvm". This is a bugfix. - "-accel kvm -accel thread=3Dsingle" ignored "thread=3Dsingle", since it applied the option to KVM. Now it fails due to not specifying the accelerator on "-accel thread=3Dsingle". - "-accel tcg -accel thread=3Dsingle" chose single-threaded TCG, while now it will fail due to not specifying the accelerator on "-accel thread=3Dsingle". Also, "-machine accel" and "-accel" become incompatible. Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 21 ------------ include/hw/boards.h | 1 - vl.c | 93 +++++++++++++++++++++++++++++++------------------= ---- 3 files changed, 54 insertions(+), 61 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 1689ad3..45ddfb6 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -173,21 +173,6 @@ GlobalProperty hw_compat_2_1[] =3D { }; const size_t hw_compat_2_1_len =3D G_N_ELEMENTS(hw_compat_2_1); =20 -static char *machine_get_accel(Object *obj, Error **errp) -{ - MachineState *ms =3D MACHINE(obj); - - return g_strdup(ms->accel); -} - -static void machine_set_accel(Object *obj, const char *value, Error **errp) -{ - MachineState *ms =3D MACHINE(obj); - - g_free(ms->accel); - ms->accel =3D g_strdup(value); -} - static void machine_set_kernel_irqchip(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -808,11 +793,6 @@ static void machine_class_init(ObjectClass *oc, void *= data) mc->numa_mem_align_shift =3D 23; mc->numa_auto_assign_ram =3D numa_default_auto_assign_ram; =20 - object_class_property_add_str(oc, "accel", - machine_get_accel, machine_set_accel, &error_abort); - object_class_property_set_description(oc, "accel", - "Accelerator list", &error_abort); - object_class_property_add(oc, "kernel-irqchip", "on|off|split", NULL, machine_set_kernel_irqchip, NULL, NULL, &error_abort); @@ -971,7 +951,6 @@ static void machine_finalize(Object *obj) { MachineState *ms =3D MACHINE(obj); =20 - g_free(ms->accel); g_free(ms->kernel_filename); g_free(ms->initrd_filename); g_free(ms->kernel_cmdline); diff --git a/include/hw/boards.h b/include/hw/boards.h index de45087..36fcbda 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -275,7 +275,6 @@ struct MachineState { =20 /*< public >*/ =20 - char *accel; bool kernel_irqchip_allowed; bool kernel_irqchip_required; bool kernel_irqchip_split; diff --git a/vl.c b/vl.c index 66dff1b..f0cb438 100644 --- a/vl.c +++ b/vl.c @@ -294,7 +294,6 @@ 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 { { .name =3D "accel", @@ -2648,6 +2647,11 @@ static int machine_set_property(void *opaque, } } =20 + /* Legacy options do not correspond to MachineState properties. */ + if (g_str_equal(qom_name, "accel")) { + return 0; + } + return object_parse_property_opt(opaque, name, value, "type", errp); } =20 @@ -2838,74 +2842,88 @@ static int do_configure_icount(void *opaque, QemuOp= ts *opts, Error **errp) =20 static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **= errp) { + bool *p_init_failed =3D opaque; + const char *acc =3D qemu_opt_get(opts, "accel"); + AccelClass *ac =3D accel_find(acc); + int ret; + + if (!ac) { + return 0; + } + ret =3D accel_init_machine(ac, current_machine); + if (ret < 0) { + *p_init_failed =3D true; + error_report("failed to initialize %s: %s", + acc, strerror(-ret)); + return 0; + } + if (tcg_enabled()) { qemu_tcg_configure(opts, &error_fatal); } - return 0; + return 1; } =20 static void configure_accelerators(const char *progname) { const char *accel; char **accel_list, **tmp; - int ret; bool accel_initialised =3D false; bool init_failed =3D false; - AccelClass *acc =3D NULL; =20 qemu_opts_foreach(qemu_find_opts("icount"), do_configure_icount, NULL, &error_fatal); =20 accel =3D qemu_opt_get(qemu_get_machine_opts(), "accel"); - if (accel =3D=3D NULL) { - /* Select the default accelerator */ - if (!accel_find("tcg") && !accel_find("kvm")) { - error_report("No accelerator selected and" - " no default accelerator available"); - exit(1); - } else { - int pnlen =3D strlen(progname); - if (pnlen >=3D 3 && g_str_equal(&progname[pnlen - 3], "kvm")) { - /* If the program name ends with "kvm", we prefer KVM */ - accel =3D "kvm:tcg"; + if (QTAILQ_EMPTY(&qemu_accel_opts.head)) { + if (accel =3D=3D NULL) { + /* Select the default accelerator */ + if (!accel_find("tcg") && !accel_find("kvm")) { + error_report("No accelerator selected and" + " no default accelerator available"); + exit(1); } else { - accel =3D "tcg:kvm"; + int pnlen =3D strlen(progname); + if (pnlen >=3D 3 && g_str_equal(&progname[pnlen - 3], "kvm= ")) { + /* If the program name ends with "kvm", we prefer KVM = */ + accel =3D "kvm:tcg"; + } else { + accel =3D "tcg:kvm"; + } } } - } =20 - accel_list =3D g_strsplit(accel, ":", 0); + accel_list =3D g_strsplit(accel, ":", 0); =20 - for (tmp =3D accel_list; !accel_initialised && tmp && *tmp; tmp++) { - acc =3D accel_find(*tmp); - if (!acc) { - continue; + for (tmp =3D accel_list; !accel_initialised && tmp && *tmp; tmp++)= { + /* + * Filter invalid accelerators here, to prevent obscenities + * such as "-machine accel=3Dtcg,,thread=3Dsingle". + */ + if (accel_find(*tmp)) { + qemu_opts_parse_noisily(qemu_find_opts("accel"), *tmp, tru= e); + } } - ret =3D accel_init_machine(acc, current_machine); - if (ret < 0) { - init_failed =3D true; - error_report("failed to initialize %s: %s", - acc->name, strerror(-ret)); - } else { - accel_initialised =3D true; + } else { + if (accel !=3D NULL) { + error_report("The -accel and \"-machine accel=3D\" options are= incompatible"); + exit(1); } } - g_strfreev(accel_list); =20 - if (!accel_initialised) { + if (!qemu_opts_foreach(qemu_find_opts("accel"), + do_configure_accelerator, &init_failed, &error_= fatal)) { if (!init_failed) { - error_report("-machine accel=3D%s: No accelerator found", acce= l); + error_report("no accelerator found"); } exit(1); } =20 if (init_failed) { - error_report("Back to %s accelerator", acc->name); + AccelClass *ac =3D ACCEL_GET_CLASS(current_machine->accelerator); + error_report("Back to %s accelerator", ac->name); } =20 - qemu_opts_foreach(qemu_find_opts("accel"), - do_configure_accelerator, NULL, &error_fatal); - if (!tcg_enabled() && use_icount) { error_report("-icount is not allowed with hardware virtualization"= ); exit(1); @@ -3616,9 +3634,6 @@ int main(int argc, char **argv, char **envp) "use -M accel=3D... for now instead"); exit(1); } - opts =3D qemu_opts_create(qemu_find_opts("machine"), NULL, - false, &error_abort); - qemu_opt_set(opts, "accel", optarg, &error_abort); break; case QEMU_OPTION_usb: olist =3D qemu_find_opts("machine"); --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575903885; cv=none; d=zohomail.com; s=zohoarc; b=DTaGqNV3diHi27d0hA8r59EUfuGMFOWmjaSkbI+lE8pQofnCo4/k8l+HLNAivea3vyBFc0Y4LvbjMJjztGzPHOhsPX5lJEtADAbi3QcL0ZJpuvNANDAfSLUiozseqQLTpDQn4/TNUFzkf4XwJ+O2/JjjPe0F2hsZ8yyEpN0CoUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575903885; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ao+CKbm0NQNbGegskrGYo8y8CuAn4vbfunlF0Syx/cM=; b=fsub/kn6k4c9D+k2zccRO5qQ8T0PhrkKqBFtZEFpPuGnPhTP9sJC49oyuPimu5Rk4TmWDUGt0L2y2crV+s2ATP4sTQDXg7U7Wg1uDA8t3eNcwtRLEjNHpNqTL9FaMFS3k586pa5SsIWa70BQQ+dt93wT7131lXw0xFiGWlpMMo8= 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 1575903885104602.5570085975597; Mon, 9 Dec 2019 07:04:45 -0800 (PST) Received: from localhost ([::1]:41176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKaZ-0005Z6-D6 for importer@patchew.org; Mon, 09 Dec 2019 10:04:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47156) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKXv-0003R9-6B for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKXu-0001LO-41 for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:59 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:51803) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKXt-0001Jh-T5 for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:01:58 -0500 Received: by mail-wm1-x342.google.com with SMTP id g206so15858045wme.1 for ; Mon, 09 Dec 2019 07:01:57 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.01.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:01:56 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=Ao+CKbm0NQNbGegskrGYo8y8CuAn4vbfunlF0Syx/cM=; b=d3+G7rP0lWhKEOvGVFGS42Smio2d6mWODdRa4p89XmAkmd14rHSEgH43uqbrhF3EG2 uzqo3NqVCCCewGxfc4ylTxALG9qzdGMVhHjn6aAohz4wtX6RBoeDsUaPCAZhQEVb+Jb9 0L+wSB561BwQ6GZ05NmKzluLyyKcK/+CzjlxhfqQ5Ly5KYnkQCu3UF5v12cVFMtpNq8f XKf/V5gWNViQes+x63z/O41FD7DC5ACw2WEZz18ANxzSbTgcrXk0YmuGxkVdL1+dHQS4 fVuj/SQG63CVTp2+EvpJ4RgcDYuj3TPH3vCoIw3MQSal6stVmd7TYr+GOXljqskwDFKH Pq4Q== 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:mime-version:content-transfer-encoding; bh=Ao+CKbm0NQNbGegskrGYo8y8CuAn4vbfunlF0Syx/cM=; b=T9m3vuNVIBsODq3eNgjoZmcWyIS1xK1v6eQT3WKKBoVSAxECB9pa9lrbl8eTnNMSh3 WW+GT05m5MsOOpqw1MzKntOvUt9qF/ca9YWYVHxNiaktGCq/QRMVFaYSW+W43FZaiy/Y N0RrTCzEJd0pMZvn9Q85bCKIH2UXr8n9tvIxE1HamvP19Ymt1wlnvDIk6Xot7hzA8XIj d4smGlKPuHUaAEpImJJNJU+452eGQs6uMQrvz97Zj7qn3USBQD1MxI73tdA3IbmANeKg O9TlCq98zULsJkZsaaNS91JmZgyTbjf7YJjW3V08c0RlOeA7dBhc0OsLaeQAM/hG3Yp6 D4Pg== X-Gm-Message-State: APjAAAXjujhZ8CeXZEEqAz02hVkMGzgxXbg5npWZcfmzjt09m7cm6SNU vz9qpvCZBgwc084C6SyGH2jEnCqh X-Google-Smtp-Source: APXvYqwrtK077Y9tfRzN7DJHYQFIOmAyRcECmdZ9rE0hwHbhOKTeP2u/q2KflY6s3w8dJhpcHvjEfA== X-Received: by 2002:a05:600c:2383:: with SMTP id m3mr13037613wma.32.1575903716730; Mon, 09 Dec 2019 07:01:56 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 09/18] vl: warn for unavailable accelerators, clarify messages Date: Mon, 9 Dec 2019 16:01:36 +0100 Message-Id: <1575903705-12925-10-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) So far, specifying an accelerator that was not compiled in did not result in an error; fix that. While at it, clarify the mysterious "Back to TCG" message. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini --- vl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vl.c b/vl.c index f0cb438..58aad4f 100644 --- a/vl.c +++ b/vl.c @@ -2848,6 +2848,8 @@ static int do_configure_accelerator(void *opaque, Qem= uOpts *opts, Error **errp) int ret; =20 if (!ac) { + *p_init_failed =3D true; + error_report("invalid accelerator %s", acc); return 0; } ret =3D accel_init_machine(ac, current_machine); @@ -2902,6 +2904,9 @@ static void configure_accelerators(const char *progna= me) */ if (accel_find(*tmp)) { qemu_opts_parse_noisily(qemu_find_opts("accel"), *tmp, tru= e); + } else { + init_failed =3D true; + error_report("invalid accelerator %s", *tmp); } } } else { @@ -2921,7 +2926,7 @@ static void configure_accelerators(const char *progna= me) =20 if (init_failed) { AccelClass *ac =3D ACCEL_GET_CLASS(current_machine->accelerator); - error_report("Back to %s accelerator", ac->name); + error_report("falling back to %s", ac->name); } =20 if (!tcg_enabled() && use_icount) { --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575904308; cv=none; d=zohomail.com; s=zohoarc; b=H115WNati/CVFTuhuWbFaNsCOgTKiLB3UdRTqfXeqUXsrLMgPskuViIARMWRD8mWtFOt8H29SFpJCt9aoFJ4FIaJCFV8RvZ5aTW8bUQp1aKcWxe1RHT+SkUJxz0lGWjaOy36Jl9Elm2GIdP81Ws7yS8c0NjKfi68oML89g0hL/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575904308; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Ft7K9jTEk6HhMYPt6hQBBzpDQMmZcbUpSDG664CJFNU=; b=e3rwTUo662dHoUfU4cgP85Xz63fW5GvNIzIICkvtLC5PlKYk0GhcZfgag8lKl9eivjtUdEub6Hw1dPOWZ9YCYDQSBd24nbJRI0F4MS9N0Sucxa22wJFxQWyAfIK8d0dbIfxp/9tL16rBOOYdnWJPLR7u/A+aHw+RJuhbufsf68w= 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 15759043080771007.2423196256344; Mon, 9 Dec 2019 07:11:48 -0800 (PST) Received: from localhost ([::1]:41288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKhO-0005Ug-Gx for importer@patchew.org; Mon, 09 Dec 2019 10:11:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47265) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKY2-0003ZB-GX for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKXx-0001OO-3x for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:06 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:35402) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKXw-0001Nt-Sy for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:01 -0500 Received: by mail-wm1-x342.google.com with SMTP id c20so13811563wmb.0 for ; Mon, 09 Dec 2019 07:02:00 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.01.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:01:58 -0800 (PST) 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=Ft7K9jTEk6HhMYPt6hQBBzpDQMmZcbUpSDG664CJFNU=; b=Vm2s9QvEcWz3gO44MeWeq47IPkeOVYMKi20q2MB/rwXIeL5xYBy1D3j6hkxz5w8InU MA+7fvyItnGwsw6aAvomdAe1uEmTo+ZbGfierBImcs09dhBWhAq+gaWi15AvKYMwf/6R UHEkz6TvMNr9N8nQXX2jq6JUgxbJUd19Iy6lltXnoSFeQ+kqbf5rcDuoWroyUq2KboAL DGX5Nmv5fae1QNcVcszcS8h4GmohHvF347TCjGcNk7tjM6Hwv9sL0FwFD3gqGAcb7Mfb mmlM0DUqU2/3EZtpQ73/WlksHspv6bkl/GzA198wulsZJ13yX4gOLlYTAZZ71LVd3rLm AD8A== 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=Ft7K9jTEk6HhMYPt6hQBBzpDQMmZcbUpSDG664CJFNU=; b=XpeYXUWDyiHcF7KvjDSLsz/uIWCbqHHiTu/JO0Q1l4ET3p65aJAQN8qxM0YiO5EvHs ZTdv8YQ0i21hAaUrPZ6LVlZ6UY71LvTNiJq5EB04e00caLD9wUiM6wRAEb6R+I1rwbIi gCqoy3snGCfMNRKiYgPmX0Q0K4GFi4ytkX5cOlM1tT0VjvFY+hWrEkJ8w5fVVLOvGrxJ zbjVde3nRfRpyGR/VPEAnOfj/SDPaZPReTerYcoHtENVVJ2Nk5FO407Wr5RLfQOGGldK PYs8mh1mEenwk8jeG/NpqQNfadcrDZ73gJ17HFFg2ht7YSk6MFP5kAkDCKgPpman29Xf xnCQ== X-Gm-Message-State: APjAAAVzfYBD8vq0m9gcyfOoKViicKfUXRF32R+dMRw9tHdO+hNeyops dNSog43OwKLwJs1eHmy7X2w7qLZ9 X-Google-Smtp-Source: APXvYqy7OFL5C+heQGi721sNwZ3M5HBb8w6yHIXPjw0rmWNKwoiK1KU9Fzb6RicvHKveOdyGsGVIww== X-Received: by 2002:a7b:c0d8:: with SMTP id s24mr26650801wmh.30.1575903719051; Mon, 09 Dec 2019 07:01:59 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 10/18] qom: introduce object_register_sugar_prop Date: Mon, 9 Dec 2019 16:01:37 +0100 Message-Id: <1575903705-12925-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-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:4864:20::342 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Similar to the existing "-rtc driftfix" option, we will convert some legacy "-machine" command line options to global properties on accelerators. Because accelerators are not devices, we cannot use qdev_prop_register_glob= al. Instead, provide a slot in the generic object_compat_props arrays for command line syntactic sugar. Signed-off-by: Paolo Bonzini Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/qom/object.h | 1 + qom/object.c | 23 +++++++++++++++++++++-- vl.c | 10 +++------- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 128d00c..230b18f 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -679,6 +679,7 @@ void object_apply_global_props(Object *obj, const GPtrA= rray *props, Error **errp); void object_set_machine_compat_props(GPtrArray *compat_props); void object_set_accelerator_compat_props(GPtrArray *compat_props); +void object_register_sugar_prop(const char *driver, const char *prop, cons= t char *value); void object_apply_compat_props(Object *obj); =20 /** diff --git a/qom/object.c b/qom/object.c index d51b57f..bfb4413 100644 --- a/qom/object.c +++ b/qom/object.c @@ -414,10 +414,29 @@ void object_apply_global_props(Object *obj, const GPt= rArray *props, Error **errp * Global property defaults * Slot 0: accelerator's global property defaults * Slot 1: machine's global property defaults + * Slot 2: global properties from legacy command line option * Each is a GPtrArray of of GlobalProperty. * Applied in order, later entries override earlier ones. */ -static GPtrArray *object_compat_props[2]; +static GPtrArray *object_compat_props[3]; + +/* + * Retrieve @GPtrArray for global property defined with options + * other than "-global". These are generally used for syntactic + * sugar and legacy command line options. + */ +void object_register_sugar_prop(const char *driver, const char *prop, cons= t char *value) +{ + GlobalProperty *g; + if (!object_compat_props[2]) { + object_compat_props[2] =3D g_ptr_array_new(); + } + g =3D g_new(GlobalProperty, 1); + g->driver =3D g_strdup(driver); + g->property =3D g_strdup(prop); + g->value =3D g_strdup(value); + g_ptr_array_add(object_compat_props[2], g); +} =20 /* * Set machine's global property defaults to @compat_props. @@ -445,7 +464,7 @@ void object_apply_compat_props(Object *obj) =20 for (i =3D 0; i < ARRAY_SIZE(object_compat_props); i++) { object_apply_global_props(obj, object_compat_props[i], - &error_abort); + i =3D=3D 2 ? &error_fatal : &error_abort= ); } } =20 diff --git a/vl.c b/vl.c index 58aad4f..d6c77bc 100644 --- a/vl.c +++ b/vl.c @@ -897,13 +897,9 @@ static void configure_rtc(QemuOpts *opts) value =3D qemu_opt_get(opts, "driftfix"); if (value) { if (!strcmp(value, "slew")) { - static GlobalProperty slew_lost_ticks =3D { - .driver =3D "mc146818rtc", - .property =3D "lost_tick_policy", - .value =3D "slew", - }; - - qdev_prop_register_global(&slew_lost_ticks); + object_register_sugar_prop("mc146818rtc", + "lost_tick_policy", + "slew"); } else if (!strcmp(value, "none")) { /* discard is default */ } else { --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575904190; cv=none; d=zohomail.com; s=zohoarc; b=bTFdPwQX6GJIKchvgXnrCsSmWlrHFeLBuUARLuJQGAki2yCc8EOynowOqPXdyNmPw1q+otMxQxsVm5/mrNmtcXz7kNYmfNTuXYjaYIDiww6nEonkoSASStT4Mnv47TnAsDq5gQeSb0ESeh/9ypSVFCB1zMvPyJ8z+CQCIn6LKP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575904190; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6qXoUB/YRk1ySecNiPXq+1y/hNOC/soS4r9Rs8Dke6E=; b=AvevTMYuAMpF9RhQmuvQXiS25VT++z7/UwF0OTfING02AG5FWB5YU5Uo8gjyjpXFW/SrMxHEi8adjFEN6VsK09UVNRZstPAP529m750pdgpr/D9zspQG2qM/a+0EL+XLLDdDaHQXnu47Fo6xk7UDppQezDG3R7yNld5HBNE/yMQ= 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 15759041908718.392074090493225; Mon, 9 Dec 2019 07:09:50 -0800 (PST) Received: from localhost ([::1]:41252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKfV-0002sp-FG for importer@patchew.org; Mon, 09 Dec 2019 10:09:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47202) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKXy-0003Uy-RY for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKXx-0001P9-Ev for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:02 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:44400) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKXx-0001O2-7j for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:01 -0500 Received: by mail-wr1-x442.google.com with SMTP id q10so16552802wrm.11 for ; Mon, 09 Dec 2019 07:02:01 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.01.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:01:59 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=6qXoUB/YRk1ySecNiPXq+1y/hNOC/soS4r9Rs8Dke6E=; b=X0W5Ep70jUlMGedUun6qCWcddOQsPjHk/ig5Xpw8Zr3ipLMvyB6smrh6quF4LZfDuP bu9phFUTJlHV322N+e9RtykFVt2GLDoame53IQj3d2uVouoV3SfdBr/O2h1SlqKIAObQ BchFR3LeQUrQMpGoMk0lZZrJBBSXJZPlvKSA2+mWzCTL6dOIL1aErIavBuBN+WKEW5rP p01Cb+PS1mkRimmyvJpV28gIW8naXjY8arCimgXkBtZM0tz/yXqXuvCA2HvpdHpVa/mr V19SCmsHJnHK94qgvnb4XGOs4gJ04Axi+dotc70bDVIZm/+8JGM2bDy+5vbs2o2f1uUD akCQ== 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:mime-version:content-transfer-encoding; bh=6qXoUB/YRk1ySecNiPXq+1y/hNOC/soS4r9Rs8Dke6E=; b=aPnhu8easGoedVofgBMDKgkXoAHbuaTyw6b9rUyH1TywRX6aRP83t0AyD08y9ySSDL H0QQEQ2Z2p1tAOWLbYQV1E2JlrI/TAoS9djkv0RN+mSr8EMRtxdIzVw7VtR1BQZnJMAm uHPbV7LNL4VrY8ub/bW/bbhafu83byMQzjOxHqLYs57cuZjbGm41BGYotQu0t7Je6T8Y 3vj/f6BjXThBM2blMoKnAWkRyet0DHY2qsUm0gkqTbrbscGGzAhGBfgV0vSdMeEfwuvP npquaDjyEhsC82eXUt3Qw3HEjT0DiB6mZUmDVC+J7XZk/ZLt9Z/nenT5qq6VEOzGYp/o ZO1Q== X-Gm-Message-State: APjAAAX9sJbTEpM7GqFHqJ+SE9pays5ctwj3os2gwYh9jP+S4d8H9Rv3 PI1LA/NMC8Mswkhr7VXsLUIs2SnV X-Google-Smtp-Source: APXvYqxUS7GlGTm4Siwz3xa6EhUWMblKv88ZPrCyZt//UQDimR5+xUhQ6tV5Ea/+gTs+383L+5pG+w== X-Received: by 2002:adf:dc86:: with SMTP id r6mr2859529wrj.68.1575903719949; Mon, 09 Dec 2019 07:01:59 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 11/18] qom: add object_new_with_class Date: Mon, 9 Dec 2019 16:01:38 +0100 Message-Id: <1575903705-12925-12-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Similar to CPU and machine classes, "-accel" class names are mangled, so we have to first get a class via accel_find and then instantiate it. Provide a new function to instantiate a class without going through object_class_get_name, and use it for CPUs and machines already. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- accel/accel.c | 4 +--- include/qom/object.h | 12 ++++++++++++ qom/object.c | 5 +++++ target/i386/cpu.c | 8 ++++---- target/s390x/cpu_models.c | 4 ++-- vl.c | 3 +-- 6 files changed, 25 insertions(+), 11 deletions(-) diff --git a/accel/accel.c b/accel/accel.c index 60c3827..dd38a46 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -48,9 +48,7 @@ AccelClass *accel_find(const char *opt_name) =20 int accel_init_machine(AccelClass *acc, MachineState *ms) { - ObjectClass *oc =3D OBJECT_CLASS(acc); - const char *cname =3D object_class_get_name(oc); - AccelState *accel =3D ACCEL(object_new(cname)); + AccelState *accel =3D ACCEL(object_new_with_class(OBJECT_CLASS(acc))); int ret; ms->accelerator =3D accel; *(acc->allowed) =3D true; diff --git a/include/qom/object.h b/include/qom/object.h index 230b18f..f9ad692 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -593,6 +593,18 @@ struct InterfaceClass __FILE__, __LINE__, __func__)) =20 /** + * object_new_with_class: + * @klass: The class to instantiate. + * + * This function will initialize a new object using heap allocated memory. + * The returned object has a reference count of 1, and will be freed when + * the last reference is dropped. + * + * Returns: The newly allocated and instantiated object. + */ +Object *object_new_with_class(ObjectClass *klass); + +/** * object_new: * @typename: The name of the type of the object to instantiate. * diff --git a/qom/object.c b/qom/object.c index bfb4413..bc444d3 100644 --- a/qom/object.c +++ b/qom/object.c @@ -658,6 +658,11 @@ static Object *object_new_with_type(Type type) return obj; } =20 +Object *object_new_with_class(ObjectClass *klass) +{ + return object_new_with_type(klass->type); +} + Object *object_new(const char *typename) { TypeImpl *ti =3D type_get_by_name(typename); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 69f518a..a044078 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4640,7 +4640,7 @@ static void x86_cpu_class_check_missing_features(X86C= PUClass *xcc, return; } =20 - xc =3D X86_CPU(object_new(object_class_get_name(OBJECT_CLASS(xcc)))); + xc =3D X86_CPU(object_new_with_class(OBJECT_CLASS(xcc))); =20 x86_cpu_expand_features(xc, &err); if (err) { @@ -4711,7 +4711,7 @@ static GSList *get_sorted_cpu_model_list(void) =20 static char *x86_cpu_class_get_model_id(X86CPUClass *xc) { - Object *obj =3D object_new(object_class_get_name(OBJECT_CLASS(xc))); + Object *obj =3D object_new_with_class(OBJECT_CLASS(xc)); char *r =3D object_property_get_str(obj, "model-id", &error_abort); object_unref(obj); return r; @@ -5092,7 +5092,7 @@ static X86CPU *x86_cpu_from_model(const char *model, = QDict *props, Error **errp) goto out; } =20 - xc =3D X86_CPU(object_new(object_class_get_name(OBJECT_CLASS(xcc)))); + xc =3D X86_CPU(object_new_with_class(OBJECT_CLASS(xcc))); if (props) { object_apply_props(OBJECT(xc), props, &err); if (err) { @@ -5936,7 +5936,7 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error **= errp) APICCommonState *apic; ObjectClass *apic_class =3D OBJECT_CLASS(apic_get_class()); =20 - cpu->apic_state =3D DEVICE(object_new(object_class_get_name(apic_class= ))); + cpu->apic_state =3D DEVICE(object_new_with_class(apic_class)); =20 object_property_add_child(OBJECT(cpu), "lapic", OBJECT(cpu->apic_state), &error_abort); diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 7e92fb2..72cf48b 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -440,7 +440,7 @@ static void create_cpu_model_list(ObjectClass *klass, v= oid *opaque) if (cpu_list_data->model) { Object *obj; S390CPU *sc; - obj =3D object_new(object_class_get_name(klass)); + obj =3D object_new_with_class(klass); sc =3D S390_CPU(obj); if (sc->model) { info->has_unavailable_features =3D true; @@ -501,7 +501,7 @@ static void cpu_model_from_info(S390CPUModel *model, co= nst CpuModelInfo *info, error_setg(errp, "The CPU definition '%s' requires KVM", info->nam= e); return; } - obj =3D object_new(object_class_get_name(oc)); + obj =3D object_new_with_class(oc); cpu =3D S390_CPU(obj); =20 if (!cpu->model) { diff --git a/vl.c b/vl.c index d6c77bc..f18b26b 100644 --- a/vl.c +++ b/vl.c @@ -3989,8 +3989,7 @@ int main(int argc, char **argv, char **envp) cleanup_add_fd, NULL, &error_fatal); #endif =20 - current_machine =3D MACHINE(object_new(object_class_get_name( - OBJECT_CLASS(machine_class)))); + current_machine =3D MACHINE(object_new_with_class(OBJECT_CLASS(machine= _class))); if (machine_help_func(qemu_get_machine_opts(), current_machine)) { exit(0); } --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575904359; cv=none; d=zohomail.com; s=zohoarc; b=ILA0Im5rLpAskDAkWx77c3osI7ckbdqbI5gakifHZ6k0HYxA7gLP88VPO4SsSI+Wy4RR7Ou/SF7gWfTmJG0Gs82vVM/xNHB0EE4KEj/YZ35O31ydGJuaCx7ICeGEkK1prhIHBzvk8fNMNFjWN7O7kySJbcQZFB3F9VkUTVK9WHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575904359; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=53drGG/4V0NylixgL3iQIcLKYE+QBnEUf/GWyCKPtTs=; b=lN3oq0bNMI9EZCPMctwnIdBRlBsrNv7rbMWltApVmCuxBFhFruRWNXIurntWU3XbQKQNwMowOKYf2ME3rbyTUFXwepR28six11JfsgHYBz4kb3KbLMAIyihek5SpFVE8bvRLFVnMt661x0Is+5fYpvfYLzS7P/p2HfslcpyIwfk= 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 1575904359011390.2182219257363; Mon, 9 Dec 2019 07:12:39 -0800 (PST) Received: from localhost ([::1]:41298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKiD-0006bO-FT for importer@patchew.org; Mon, 09 Dec 2019 10:12:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47220) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKY0-0003WQ-1c for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKXy-0001Sd-R1 for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:03 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:35403) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKXy-0001Pe-IR for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:02 -0500 Received: by mail-wm1-x342.google.com with SMTP id c20so13811675wmb.0 for ; Mon, 09 Dec 2019 07:02:02 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.02.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:02:00 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=53drGG/4V0NylixgL3iQIcLKYE+QBnEUf/GWyCKPtTs=; b=jr5dUEfWqZWGuVQP0ushn49uADQ6CKq9GI2D2Ot3F9/RlzXrS33s2rucjwq2CAW0oe Y54HSOc1rJ3vM5FHErklLh7EOHQ+JUuk0RUZYOyH60tHB2jX8kDOeZso7scia3d3lh77 YDfyiP2Q3VIt2oYjt+tGHZ3GgHh+fg9h7wIDqmVaQ14MR+FA2imjtu/tHbJCm+rFnWJD zEQ909duDpSoMFF8xm3pzM338N+kmrxtF0JMsfzRkCjJwmwmbQ9zXAE+B3utm5+/nQFJ JMw7y4hfSCw4mF/O+hSL7BbBB6UWKgF6zexfbhy1kmwTSD38Kr9eKF1bg11AbkqOnjyR AYrw== 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:mime-version:content-transfer-encoding; bh=53drGG/4V0NylixgL3iQIcLKYE+QBnEUf/GWyCKPtTs=; b=lswx4Kifke909SVaKapjzPcU5KjrA6JAYU/znOSL8Tp+13wx2oEVXpxXpzFEGs9R2V BuEV4SPzOu0CPOi0hWf8sDJhGKfq85KEQemUgEWkpAcdKMcQWDIfZj4fy/3o2HvimWaq 7+SU00k55iQFgjMh11W1tzrnV/Z7zygFbsDxbM2FhRVRYEHKvfOB3RaZRPBLZPEzM5iW gu5kVFj3i8uGAEfABj99POWxQpbJ9ur4InDLwr5fmsbuqb1G63PqCLgPrwqhuSqQwF5x e6r9rkHcO5hMYeVGIjXHGm14fgaH8I0asibFN7v3cwQMXDMwlnG+M7/R8JHUfH7uafeG L37g== X-Gm-Message-State: APjAAAUicWZy2/KTbuxQTC7/Fmr0QwxUP0D3ss5rgQV1qLn9MI7wpN4h IVybm6pIHqnOpE36gf/qaruct2U8 X-Google-Smtp-Source: APXvYqxwQZEegqIDm4mke6EArHQ0ixXjxMtLERoY9pm7vA8ziCkRL8Kp+FEiWwI7iEGUarGcJTbyjQ== X-Received: by 2002:a1c:2705:: with SMTP id n5mr26671754wmn.68.1575903720906; Mon, 09 Dec 2019 07:02:00 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 12/18] accel: pass object to accel_init_machine Date: Mon, 9 Dec 2019 16:01:39 +0100 Message-Id: <1575903705-12925-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We will have to set QOM properties before accel_init_machine, based on the options provided to -accel. Construct the object outside it so that it will be possible to iterate on properties between object_new_with_class and accel_init_machine. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini --- accel/accel.c | 4 ++-- include/sysemu/accel.h | 2 +- vl.c | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/accel/accel.c b/accel/accel.c index dd38a46..1c5c3a6 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -46,9 +46,9 @@ AccelClass *accel_find(const char *opt_name) return ac; } =20 -int accel_init_machine(AccelClass *acc, MachineState *ms) +int accel_init_machine(AccelState *accel, MachineState *ms) { - AccelState *accel =3D ACCEL(object_new_with_class(OBJECT_CLASS(acc))); + AccelClass *acc =3D ACCEL_GET_CLASS(accel); int ret; ms->accelerator =3D accel; *(acc->allowed) =3D true; diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h index 90b6213..22cac0f 100644 --- a/include/sysemu/accel.h +++ b/include/sysemu/accel.h @@ -67,7 +67,7 @@ typedef struct AccelClass { extern unsigned long tcg_tb_size; =20 AccelClass *accel_find(const char *opt_name); -int accel_init_machine(AccelClass *acc, MachineState *ms); +int accel_init_machine(AccelState *accel, MachineState *ms); =20 /* Called just before os_setup_post (ie just before drop OS privs) */ void accel_setup_post(MachineState *ms); diff --git a/vl.c b/vl.c index f18b26b..078ab7a 100644 --- a/vl.c +++ b/vl.c @@ -2841,6 +2841,7 @@ static int do_configure_accelerator(void *opaque, Qem= uOpts *opts, Error **errp) bool *p_init_failed =3D opaque; const char *acc =3D qemu_opt_get(opts, "accel"); AccelClass *ac =3D accel_find(acc); + AccelState *accel; int ret; =20 if (!ac) { @@ -2848,7 +2849,8 @@ static int do_configure_accelerator(void *opaque, Qem= uOpts *opts, Error **errp) error_report("invalid accelerator %s", acc); return 0; } - ret =3D accel_init_machine(ac, current_machine); + accel =3D ACCEL(object_new_with_class(OBJECT_CLASS(ac))); + ret =3D accel_init_machine(accel, current_machine); if (ret < 0) { *p_init_failed =3D true; error_report("failed to initialize %s: %s", --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575904518; cv=none; d=zohomail.com; s=zohoarc; b=byAgTI72KMOKZUZZwX51cyf+kfwXeto1rxmqW2d+EsdRg9+PlYXqbkMiDtOCexy7V211ciqRbg8cvi/7QSFzg2xZdOi2pqC/phaq8tbIln0i/h5WIrCKpq1Sq3kKyoRSjOq2AlZwIRAHOOmxPz94iybUPGNvZv6hLsu+EW0+qbI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575904518; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZyE5O5JAEITvx4NuqnX21tFQPYz9WQOu6fuX5qbaGbg=; b=VbjChAwN742kNBClHNMGEhY8sXVgxOLtqrw224tzmUqU+FJ6YjkbQynj0NAhf0287r10LwG48ZYEgZ6cMBWAVhBZCh0rdAnvKes0TRwmtTK1iVHnVY8mEUMzxm/aEBtYBHjcpik7yYHurFOALsznKFfq41vtKoTYoMPxBoQREzI= 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 1575904518659994.2180292244584; Mon, 9 Dec 2019 07:15:18 -0800 (PST) Received: from localhost ([::1]:41332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKkm-0001BX-Qj for importer@patchew.org; Mon, 09 Dec 2019 10:15:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47236) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKY0-0003XT-Us for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKXz-0001UB-AJ for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:04 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:53788) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKXz-0001RI-17 for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:03 -0500 Received: by mail-wm1-x343.google.com with SMTP id n9so15329102wmd.3 for ; Mon, 09 Dec 2019 07:02:02 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.02.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:02:01 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=ZyE5O5JAEITvx4NuqnX21tFQPYz9WQOu6fuX5qbaGbg=; b=Wb00X+YMD1KYN/d0ocuLnKKN901g3qFCF6qwRai4I8cwijtUQPh111Sy9Fx8RxGU0I O5CDDGZppZb9q/IYe3wHU64yI9yqtNlYaIdJ5vDb0Mi80BJ5ZEuylNtVffu4TqQ+1KjO WzOY71f+IATfeB4X1HI1LjeAkkZfVlVPUiGsv87pLy5HAlsiCKWeKcT3vjLpk1VIT+r+ Dvi7UN+qPjIyBrN1GaARlt20xLudW6C87v7So6b7kfBv0yW5Db+a9QGsCUc3Bsp+ivmw BZp+LiMeZdozkZ0OY2ZkOnq+BVUjAP6WTzxVe9IprNkjvQtgBo4iE8scJK84PYIrrr9Z x07A== 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:mime-version:content-transfer-encoding; bh=ZyE5O5JAEITvx4NuqnX21tFQPYz9WQOu6fuX5qbaGbg=; b=VT13wIAv8bgFd+rOZbeJRs/NtBjwKq+QALEgJJ/O2TRFiORxOQ5MfmQZhzKbtBomPX JiWXGC9TbiLgWnI0wwlUS8SAgU//1+my2voUvx/eim860P69E37PNFT8d8A76hoQjDKh ikqDfzmLK5A06xcWQoNcNkbAjNB4NcPmO2qs7FV6qwarJMhEpyAomXFmA5Bdh6LBw23C WUnp3cDTaSHOf+tLgmdY+bTsnzwlfyC88731Edl55wIlNUy+yftRG11SDMlrjb4cZ34c 3AKoySLlGHSZ2kv/4lAxx1xbby72CfefmKD/530EqZbIuqB1oVzCnEpa3D4zwy382Dq1 p8Bw== X-Gm-Message-State: APjAAAU9iOnznsHsbArURIFvgwqBwdPmZ8tqut7dtR4VqbZGW5dZpZca ERRVEBPDM9l9Yvdbdozci7Ciptf1 X-Google-Smtp-Source: APXvYqyP2EARTK8tctjseidflj3T0tn4xfwh4KRnY80EQy0LkgPyuzEfpbYIIU//azfBmM+2IObTiw== X-Received: by 2002:a1c:6255:: with SMTP id w82mr26596787wmb.20.1575903721806; Mon, 09 Dec 2019 07:02:01 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 13/18] tcg: convert "-accel threads" to a QOM property Date: Mon, 9 Dec 2019 16:01:40 +0100 Message-Id: <1575903705-12925-14-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Replace the ad-hoc qemu_tcg_configure with generic code invoking QOM property getters and setters. More properties (and thus more valid -accel suboptions) will be added in the next patches, which will move accelerator-related "-machine" options to accelerators. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- accel/tcg/tcg-all.c | 50 ++++++++++++++++++++++++++++++++++++-----------= --- include/sysemu/cpus.h | 2 -- vl.c | 32 +++++++++++++++++--------------- 3 files changed, 53 insertions(+), 31 deletions(-) diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index 78a0ab5..7829f02 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -34,7 +34,17 @@ #include "include/qapi/error.h" #include "include/qemu/error-report.h" #include "include/hw/boards.h" -#include "qemu/option.h" + +typedef struct TCGState { + AccelState parent_obj; + + bool mttcg_enabled; +} TCGState; + +#define TYPE_TCG_ACCEL ACCEL_CLASS_NAME("tcg") + +#define TCG_STATE(obj) \ + OBJECT_CHECK(TCGState, (obj), TYPE_TCG_ACCEL) =20 unsigned long tcg_tb_size; =20 @@ -109,23 +119,31 @@ static void tcg_accel_instance_init(Object *obj) { TCGState *s =3D TCG_STATE(obj); =20 - mttcg_enabled =3D default_mttcg_enabled(); + s->mttcg_enabled =3D default_mttcg_enabled(); } =20 static int tcg_init(MachineState *ms) { + TCGState *s =3D TCG_STATE(current_machine->accelerator); + tcg_exec_init(tcg_tb_size * 1024 * 1024); cpu_interrupt_handler =3D tcg_handle_interrupt; + mttcg_enabled =3D s->mttcg_enabled; return 0; } =20 -void qemu_tcg_configure(QemuOpts *opts, Error **errp) +static char *tcg_get_thread(Object *obj, Error **errp) { - const char *t =3D qemu_opt_get(opts, "thread"); - if (!t) { - return; - } - if (strcmp(t, "multi") =3D=3D 0) { + TCGState *s =3D TCG_STATE(obj); + + return g_strdup(s->mttcg_enabled ? "multi" : "single"); +} + +static void tcg_set_thread(Object *obj, const char *value, Error **errp) +{ + TCGState *s =3D TCG_STATE(obj); + + if (strcmp(value, "multi") =3D=3D 0) { if (TCG_OVERSIZED_GUEST) { error_setg(errp, "No MTTCG when guest word size > hosts"); } else if (use_icount) { @@ -140,12 +158,12 @@ void qemu_tcg_configure(QemuOpts *opts, Error **errp) "than the host provides"); error_printf("This may cause strange/hard to debug errors\= n"); } - mttcg_enabled =3D true; + s->mttcg_enabled =3D true; } - } else if (strcmp(t, "single") =3D=3D 0) { - mttcg_enabled =3D false; + } else if (strcmp(value, "single") =3D=3D 0) { + s->mttcg_enabled =3D false; } else { - error_setg(errp, "Invalid 'thread' setting %s", t); + error_setg(errp, "Invalid 'thread' setting %s", value); } } =20 @@ -155,15 +173,19 @@ static void tcg_accel_class_init(ObjectClass *oc, voi= d *data) ac->name =3D "tcg"; ac->init_machine =3D tcg_init; ac->allowed =3D &tcg_allowed; -} =20 -#define TYPE_TCG_ACCEL ACCEL_CLASS_NAME("tcg") + object_class_property_add_str(oc, "thread", + tcg_get_thread, + tcg_set_thread, + NULL); +} =20 static const TypeInfo tcg_accel_type =3D { .name =3D TYPE_TCG_ACCEL, .parent =3D TYPE_ACCEL, .instance_init =3D tcg_accel_instance_init, .class_init =3D tcg_accel_class_init, + .instance_size =3D sizeof(TCGState), }; =20 static void register_accel_types(void) diff --git a/include/sysemu/cpus.h b/include/sysemu/cpus.h index 32c05f2..3c1da6a 100644 --- a/include/sysemu/cpus.h +++ b/include/sysemu/cpus.h @@ -40,6 +40,4 @@ extern int smp_threads; =20 void list_cpus(const char *optarg); =20 -void qemu_tcg_configure(QemuOpts *opts, Error **errp); - #endif diff --git a/vl.c b/vl.c index 078ab7a..b6c23d1 100644 --- a/vl.c +++ b/vl.c @@ -295,17 +295,12 @@ static QemuOptsList qemu_accel_opts =3D { .implied_opt_name =3D "accel", .head =3D QTAILQ_HEAD_INITIALIZER(qemu_accel_opts.head), .desc =3D { - { - .name =3D "accel", - .type =3D QEMU_OPT_STRING, - .help =3D "Select the type of accelerator", - }, - { - .name =3D "thread", - .type =3D QEMU_OPT_STRING, - .help =3D "Enable/disable multi-threaded TCG", - }, - { /* end of list */ } + /* + * no elements =3D> accept any + * sanity checking will happen later + * when setting accelerator properties + */ + { } }, }; =20 @@ -2836,6 +2831,13 @@ static int do_configure_icount(void *opaque, QemuOpt= s *opts, Error **errp) return 0; } =20 +static int accelerator_set_property(void *opaque, + const char *name, const char *value, + Error **errp) +{ + return object_parse_property_opt(opaque, name, value, "accel", errp); +} + static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **= errp) { bool *p_init_failed =3D opaque; @@ -2850,6 +2852,10 @@ static int do_configure_accelerator(void *opaque, Qe= muOpts *opts, Error **errp) return 0; } accel =3D ACCEL(object_new_with_class(OBJECT_CLASS(ac))); + qemu_opt_foreach(opts, accelerator_set_property, + accel, + &error_fatal); + ret =3D accel_init_machine(accel, current_machine); if (ret < 0) { *p_init_failed =3D true; @@ -2857,10 +2863,6 @@ static int do_configure_accelerator(void *opaque, Qe= muOpts *opts, Error **errp) acc, strerror(-ret)); return 0; } - - if (tcg_enabled()) { - qemu_tcg_configure(opts, &error_fatal); - } return 1; } =20 --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575904686; cv=none; d=zohomail.com; s=zohoarc; b=FvSZTVmUME0V98qS2AgVPcv6tyKZk0v455u/RHz2Hm7NSMjufNUJj7JLbQtFnNhNZBUIRk7xyIXYrTf4Kt0BRm/kWlLa9zRxJSkADvXRooL6Ctx0ONK9XagBH52G9VpwjNRSyqwfTfdVlsxu0EXR7vqbjaL3/niu7U5geH+ed+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575904686; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=6G+yRJhQoOCW2slm7RNaCHxgek5OcRgkFOCnJMrl/qg=; b=JgYhoi7pwVANqtLW7B8VmqOlKqoDkYIrNkUFnTUXms+yS0NIf/z2xsW+fGUQkrymtVohkk/4J4QILCsiLUR6FrA3tckl//mBYfxg7+2XvQVUf5RT8i5/DKKxx/A9v7Mg9KrVt2euOb4edaSsRr0dnN5VuPo+YI+wrBhje2UJ5QU= 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 1575904686679782.5888744506042; Mon, 9 Dec 2019 07:18:06 -0800 (PST) Received: from localhost ([::1]:41384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKnV-0003i0-7t for importer@patchew.org; Mon, 09 Dec 2019 10:18:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47261) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKY2-0003Yx-2T for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKY0-0001V8-Da for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:05 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:42591) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKY0-0001UQ-6S for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:04 -0500 Received: by mail-wr1-x443.google.com with SMTP id a15so16529964wrf.9 for ; Mon, 09 Dec 2019 07:02:04 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.02.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:02:02 -0800 (PST) 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=6G+yRJhQoOCW2slm7RNaCHxgek5OcRgkFOCnJMrl/qg=; b=rN9AHL1QRjxZ+OtsAQ3yN/5C16/iifMaLaS1arnFpY/iO4sH+6xHj7FfnXRZ4T/Rad xQQGAUwjRDKKDwSv6+8bMW00PgKnA+TFlcdh6vlXz1ZjP42eTCB6/5suXxqNke7Sxcxz LgnF2UXYGoBnNJiNl2975a3K9BbEOtxIIMmSsJ3tebkGqPnt2BSO5od2/seyfySoS41s oWmSj/kUirtwBl3vrH/J3f6rPIHkDvab9KWBsraCC8ncPh9T8jxcR51YgWXp8OmUbYga C5d7y7s4Al/0gakJWb/VVetJUx5K/pjU7g2pkQf9q5ZYaTB2IOX4wLOxzNYRo7s1imaH V0+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=6G+yRJhQoOCW2slm7RNaCHxgek5OcRgkFOCnJMrl/qg=; b=oO5Rc8/RFcujGvTnaGvfs1ezCogtDcRKKkq1U+Qw15yB648jxzlj7FC82L4lx/92Xb FCDJi0SInNHzXURFSc8qJfht/ScZPupnDiZfVUg30luQb1nSC9lRrHTMa2kfTpGK7qNE xHDUq/trwJN6JAdyfslh1Qpif3EMNNo+XCOJcq/2SyHGZ5btIf9YvLunifD1iDOUndKR RJKtYueI9Vf/VS2LBKvaz2gd+SlKPJmSuhZcSx82ZI1flTI6k4i2qo2Khw2p8UBrsmEd NYEkQ+W+hEHdDa8iFpr1IZZsDkusfYk0D4Y7rXhEU8I+L/iNGuUNNx6N4AiMM8Ws0hKM sUiQ== X-Gm-Message-State: APjAAAWolI6ZbVKdJYLCiEjyXWwGxS0ONRN8Mn2WERDuvVaeTQXm8zTp haSsFSanKvJy+X33fm8mAob9iJ7K X-Google-Smtp-Source: APXvYqzTv/7BfIN+Drz8syjX9peHWZMYoDim/iuwSrdY8I3MkCwsNiSE/z/4w+Vv3AMxUmjjGwJkMw== X-Received: by 2002:a5d:4c8c:: with SMTP id z12mr2662907wrs.222.1575903722859; Mon, 09 Dec 2019 07:02:02 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 14/18] tcg: add "-accel tcg, tb-size" and deprecate "-tb-size" Date: Mon, 9 Dec 2019 16:01:41 +0100 Message-Id: <1575903705-12925-15-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-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:4864:20::443 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" -tb-size fits nicely in the new framework for accelerator-specific options.= It is a very niche option, so insta-deprecate it. Signed-off-by: Paolo Bonzini Reviewed-by: Marc-Andr=C3=A9 Lureau --- accel/tcg/tcg-all.c | 40 +++++++++++++++++++++++++++++++++++++--- include/sysemu/accel.h | 2 -- qemu-deprecated.texi | 6 ++++++ qemu-options.hx | 8 ++++++-- vl.c | 8 ++++---- 5 files changed, 53 insertions(+), 11 deletions(-) diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index 7829f02..1dc384c 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -34,11 +34,13 @@ #include "include/qapi/error.h" #include "include/qemu/error-report.h" #include "include/hw/boards.h" +#include "qapi/qapi-builtin-visit.h" =20 typedef struct TCGState { AccelState parent_obj; =20 bool mttcg_enabled; + unsigned long tb_size; } TCGState; =20 #define TYPE_TCG_ACCEL ACCEL_CLASS_NAME("tcg") @@ -46,8 +48,6 @@ typedef struct TCGState { #define TCG_STATE(obj) \ OBJECT_CHECK(TCGState, (obj), TYPE_TCG_ACCEL) =20 -unsigned long tcg_tb_size; - /* mask must never be zero, except for A20 change call */ static void tcg_handle_interrupt(CPUState *cpu, int mask) { @@ -126,7 +126,7 @@ static int tcg_init(MachineState *ms) { TCGState *s =3D TCG_STATE(current_machine->accelerator); =20 - tcg_exec_init(tcg_tb_size * 1024 * 1024); + tcg_exec_init(s->tb_size * 1024 * 1024); cpu_interrupt_handler =3D tcg_handle_interrupt; mttcg_enabled =3D s->mttcg_enabled; return 0; @@ -167,6 +167,33 @@ static void tcg_set_thread(Object *obj, const char *va= lue, Error **errp) } } =20 +static void tcg_get_tb_size(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + TCGState *s =3D TCG_STATE(obj); + uint32_t value =3D s->tb_size; + + visit_type_uint32(v, name, &value, errp); +} + +static void tcg_set_tb_size(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + TCGState *s =3D TCG_STATE(obj); + Error *error =3D NULL; + uint32_t value; + + visit_type_uint32(v, name, &value, &error); + if (error) { + error_propagate(errp, error); + return; + } + + s->tb_size =3D value; +} + static void tcg_accel_class_init(ObjectClass *oc, void *data) { AccelClass *ac =3D ACCEL_CLASS(oc); @@ -178,6 +205,13 @@ static void tcg_accel_class_init(ObjectClass *oc, void= *data) tcg_get_thread, tcg_set_thread, NULL); + + object_class_property_add(oc, "tb-size", "int", + tcg_get_tb_size, tcg_set_tb_size, + NULL, NULL, &error_abort); + object_class_property_set_description(oc, "tb-size", + "TCG translation block cache size", &error_abort); + } =20 static const TypeInfo tcg_accel_type =3D { diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h index 22cac0f..d4c1429 100644 --- a/include/sysemu/accel.h +++ b/include/sysemu/accel.h @@ -64,8 +64,6 @@ typedef struct AccelClass { #define ACCEL_GET_CLASS(obj) \ OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL) =20 -extern unsigned long tcg_tb_size; - AccelClass *accel_find(const char *opt_name); int accel_init_machine(AccelState *accel, MachineState *ms); =20 diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index 4b4b742..487d2b4 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -147,6 +147,12 @@ QEMU 4.1 has three options, please migrate to one of t= hese three: to do is specify the kernel they want to boot with the -kernel option 3. ``-bios `` - Tells QEMU to load the specified file as the firmwr= ae. =20 +@subsection -tb-size option (since 5.0) + +QEMU 5.0 introduced an alternative syntax to specify the size of the trans= lation +block cache, @option{-accel tcg,tb-size=3D}. The new syntax deprecates the +previously available @option{-tb-size} option. + @section QEMU Machine Protocol (QMP) commands =20 @subsection change (since 2.5.0) diff --git a/qemu-options.hx b/qemu-options.hx index 65c9473..9775258 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -118,8 +118,9 @@ Select CPU model (@code{-cpu help} for list and additio= nal feature selection) ETEXI =20 DEF("accel", HAS_ARG, QEMU_OPTION_accel, - "-accel [accel=3D]accelerator[,thread=3Dsingle|multi]\n" + "-accel [accel=3D]accelerator[,prop[=3Dvalue][,...]]\n" " select accelerator (kvm, xen, hax, hvf, whpx or tcg; = use 'help' for a list)\n" + " tb-size=3Dn (TCG translation block cache size)\n" " thread=3Dsingle|multi (enable multi-threaded TCG)\n",= QEMU_ARCH_ALL) STEXI @item -accel @var{name}[,prop=3D@var{value}[,...]] @@ -129,6 +130,8 @@ kvm, xen, hax, hvf, whpx or tcg can be available. By de= fault, tcg is used. If th more than one accelerator specified, the next one is used if the previous = one fails to initialize. @table @option +@item tb-size=3D@var{n} +Controls the size (in MiB) of the TCG translation block cache. @item thread=3Dsingle|multi Controls number of TCG threads. When the TCG is multi-threaded there will = be one thread per vCPU therefor taking advantage of additional host cores. The de= fault @@ -4012,7 +4015,8 @@ DEF("tb-size", HAS_ARG, QEMU_OPTION_tb_size, \ STEXI @item -tb-size @var{n} @findex -tb-size -Set TB size. +Set TCG translation block cache size. Deprecated, use @samp{-accel tcg,tb= -size=3D@var{n}} +instead. ETEXI =20 DEF("incoming", HAS_ARG, QEMU_OPTION_incoming, \ diff --git a/vl.c b/vl.c index b6c23d1..e6ff56b 100644 --- a/vl.c +++ b/vl.c @@ -2852,6 +2852,7 @@ static int do_configure_accelerator(void *opaque, Qem= uOpts *opts, Error **errp) return 0; } accel =3D ACCEL(object_new_with_class(OBJECT_CLASS(ac))); + object_apply_compat_props(OBJECT(accel)); qemu_opt_foreach(opts, accelerator_set_property, accel, &error_fatal); @@ -2863,6 +2864,7 @@ static int do_configure_accelerator(void *opaque, Qem= uOpts *opts, Error **errp) acc, strerror(-ret)); return 0; } + return 1; } =20 @@ -3745,10 +3747,8 @@ int main(int argc, char **argv, char **envp) error_report("TCG is disabled"); exit(1); #endif - if (qemu_strtoul(optarg, NULL, 0, &tcg_tb_size) < 0) { - error_report("Invalid argument to -tb-size"); - exit(1); - } + warn_report("The -tb-size option is deprecated, use -accel= tcg,tb-size instead"); + object_register_sugar_prop(ACCEL_CLASS_NAME("tcg"), "tb-si= ze", optarg); break; case QEMU_OPTION_icount: icount_opts =3D qemu_opts_parse_noisily(qemu_find_opts("ic= ount"), --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575904451; cv=none; d=zohomail.com; s=zohoarc; b=DVQ/tQrEHcu7ebXVADY5nld+9XqqW1aA2wkgxEAorBVl0fx3vYHlRQPBbXha2eG3uCchoS2/w3axEomqIjX6HuP4ZAsCeERU1v83ARvpQ3DQ56uSk2R135aCm++rvIpVHgV094mairevonGQR5m9QtlxIrzVqysM2z6NkAK/j0M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575904451; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=FD2f+Nbu9tSiCoNEXPrgDf5vOFg7Yixed0iiSTqFeNk=; b=Ruv7azoI804drsfbraux1k1XwK8hYbwXpGFhT75wEbmJElcRvcGlcSAEUPi40RaIYDtVM11DtZ09JctEW1YE6QybHeYU56AHSOpjYr24SdOeyGN7AvAfScltpedndKQ67EKlsQwWybYfhjYSjQGTqtcT1DFlNtEhSO120+zg1mU= 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 1575904451806862.075680226914; Mon, 9 Dec 2019 07:14:11 -0800 (PST) Received: from localhost ([::1]:41330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKji-0008MH-Dd for importer@patchew.org; Mon, 09 Dec 2019 10:14:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47286) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKY3-0003bA-N6 for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKY1-0001Wh-Ir for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:07 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:40765) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKY1-0001Vg-BX for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:05 -0500 Received: by mail-wr1-x442.google.com with SMTP id c14so16555923wrn.7 for ; Mon, 09 Dec 2019 07:02:05 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.02.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:02:03 -0800 (PST) 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=FD2f+Nbu9tSiCoNEXPrgDf5vOFg7Yixed0iiSTqFeNk=; b=K/fFKf25PiwDzxOrE6hxBDYmqGgXKHetDM0qyCmWRC6Kbho2bO4msh4gr7cjoLaR9Z +GW3kjLByTTofFSruYR8MCqcjCS+RGdmGlJDnxKuLWSgsAxVkzsPiAOwNumYcVcQ12CX kGQ2ffDQoUvzPr7W349ff7gMX1ujyn7Ex30Irwx5px7u9nby1/mzLrfb3CwJPPzJi+VJ RpQoz1VhbQD7IEi9MvBkXVgdyFdJl8OmBnCSKOneCa1+L9Fe26IgYJb6+jrRPzBBvs7G NcCAfkG+FkENew5EqiSuFzvkK6ap2J6RUYj7YG8wJthPG7JHViE3pgA9DIe3Yyy/wYpf S4fw== 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=FD2f+Nbu9tSiCoNEXPrgDf5vOFg7Yixed0iiSTqFeNk=; b=e8+VduZZA8a2CLf/Xy38D0AyOuKwAIG7LbkDzvAkV7tVDbJZC/X2rDeDvLS8EoSKxr hRtHZT2YfbCCqfsClmON7mgCdP+KQ4d0Ji8i0ITvE3Y6e0WH9J66U16yxzlbWbFcls2a qaJDMlMUNAsD3mNO3jXzyAFZ2W1GF+Q4x9MXuX9kt0FpMh6U1PFQNfNgbOaZ6kdM2ETh ElqvteiRXdEpeOICMUL3iYDpEQzC9pv6WEgASJ9+s5ws9vElACy+Hu1MIDrlEZO7A8Dw oC4RwUGGTuNf4bDnN2QCJ0xeTnpfVALmLFCTU21qqVD3TZBoO9IrYI+a6aoYv04nF8ih MJCQ== X-Gm-Message-State: APjAAAXD2O/HBWNkV/tY5/IL6fN9ybq8PemarMJZAqHnFUP+NLxkEFH6 vr4DoE+oPsHdSv0XIVjyld7oURNq X-Google-Smtp-Source: APXvYqz0eHB2vK8To2G/mhdArXpaB8A2XVPmEi3NdF7T7layEb5BIr1zkqhe+2Ts2PZ3w/9MV2Zr8Q== X-Received: by 2002:a5d:66c3:: with SMTP id k3mr2514645wrw.370.1575903724017; Mon, 09 Dec 2019 07:02:04 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 15/18] xen: convert "-machine igd-passthru" to an accelerator property Date: Mon, 9 Dec 2019 16:01:42 +0100 Message-Id: <1575903705-12925-16-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-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:4864:20::442 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The first machine property to fall is Xen's Intel integrated graphics passthrough. The "-machine igd-passthru" option does not set anymore a property on the machine object, but desugars to a GlobalProperty on accelerator objects. The setter is very simple, since the value ends up in a global variable, so this patch also provides an example before the more complicated cases that follow it. Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 20 -------------------- hw/xen/xen-common.c | 16 ++++++++++++++++ include/hw/boards.h | 1 - qemu-options.hx | 7 ++++--- vl.c | 14 ++++---------- 5 files changed, 24 insertions(+), 34 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 45ddfb6..d7a0356 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -412,20 +412,6 @@ static void machine_set_graphics(Object *obj, bool val= ue, Error **errp) ms->enable_graphics =3D value; } =20 -static bool machine_get_igd_gfx_passthru(Object *obj, Error **errp) -{ - MachineState *ms =3D MACHINE(obj); - - return ms->igd_gfx_passthru; -} - -static void machine_set_igd_gfx_passthru(Object *obj, bool value, Error **= errp) -{ - MachineState *ms =3D MACHINE(obj); - - ms->igd_gfx_passthru =3D value; -} - static char *machine_get_firmware(Object *obj, Error **errp) { MachineState *ms =3D MACHINE(obj); @@ -862,12 +848,6 @@ static void machine_class_init(ObjectClass *oc, void *= data) object_class_property_set_description(oc, "graphics", "Set on/off to enable/disable graphics emulation", &error_abort); =20 - object_class_property_add_bool(oc, "igd-passthru", - machine_get_igd_gfx_passthru, machine_set_igd_gfx_passthru, - &error_abort); - object_class_property_set_description(oc, "igd-passthru", - "Set on/off to enable/disable igd passthrou", &error_abort); - object_class_property_add_str(oc, "firmware", machine_get_firmware, machine_set_firmware, &error_abort); diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c index 5284b0d..6cba30c 100644 --- a/hw/xen/xen-common.c +++ b/hw/xen/xen-common.c @@ -124,6 +124,16 @@ static void xen_change_state_handler(void *opaque, int= running, } } =20 +static bool xen_get_igd_gfx_passthru(Object *obj, Error **errp) +{ + return has_igd_gfx_passthru; +} + +static void xen_set_igd_gfx_passthru(Object *obj, bool value, Error **errp) +{ + has_igd_gfx_passthru =3D value; +} + static void xen_setup_post(MachineState *ms, AccelState *accel) { int rc; @@ -177,6 +187,12 @@ static void xen_accel_class_init(ObjectClass *oc, void= *data) ac->compat_props =3D g_ptr_array_new(); =20 compat_props_add(ac->compat_props, compat, G_N_ELEMENTS(compat)); + + object_class_property_add_bool(oc, "igd-passthru", + xen_get_igd_gfx_passthru, xen_set_igd_gfx_passthru, + &error_abort); + object_class_property_set_description(oc, "igd-passthru", + "Set on/off to enable/disable igd passthrou", &error_abort); } =20 #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen") diff --git a/include/hw/boards.h b/include/hw/boards.h index 36fcbda..cdcf481 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -287,7 +287,6 @@ struct MachineState { bool mem_merge; bool usb; bool usb_disabled; - bool igd_gfx_passthru; char *firmware; bool iommu; bool suppress_vmdesc; diff --git a/qemu-options.hx b/qemu-options.hx index 9775258..6f12b31 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -37,7 +37,6 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " kvm_shadow_mem=3Dsize of KVM shadow MMU in bytes\n" " dump-guest-core=3Don|off include guest memory in a co= re dump (default=3Don)\n" " mem-merge=3Don|off controls memory merge support (def= ault: on)\n" - " igd-passthru=3Don|off controls IGD GFX passthrough su= pport (default=3Doff)\n" " aes-key-wrap=3Don|off controls support for AES key wr= apping (default=3Don)\n" " dea-key-wrap=3Don|off controls support for DEA key wr= apping (default=3Don)\n" " suppress-vmdesc=3Don|off disables self-describing mig= ration (default=3Doff)\n" @@ -71,8 +70,6 @@ more than one accelerator specified, the next one is used= if the previous one fails to initialize. @item kernel_irqchip=3Don|off Controls in-kernel irqchip support for the chosen accelerator when availab= le. -@item gfx_passthru=3Don|off -Enables IGD GFX passthrough support for the chosen machine when available. @item vmport=3Don|off|auto Enables emulation of VMWare IO port, for vmmouse etc. auto says to select = the value based on accel. For accel=3Dxen the default is off otherwise the def= ault @@ -120,6 +117,7 @@ ETEXI DEF("accel", HAS_ARG, QEMU_OPTION_accel, "-accel [accel=3D]accelerator[,prop[=3Dvalue][,...]]\n" " select accelerator (kvm, xen, hax, hvf, whpx or tcg; = use 'help' for a list)\n" + " igd-passthru=3Don|off (enable Xen integrated Intel gr= aphics passthrough, default=3Doff)\n" " tb-size=3Dn (TCG translation block cache size)\n" " thread=3Dsingle|multi (enable multi-threaded TCG)\n",= QEMU_ARCH_ALL) STEXI @@ -130,6 +128,9 @@ kvm, xen, hax, hvf, whpx or tcg can be available. By de= fault, tcg is used. If th more than one accelerator specified, the next one is used if the previous = one fails to initialize. @table @option +@item igd-passthru=3Don|off +When Xen is in use, this option controls whether Intel integrated graphics +devices can be passed through to the guest (default=3Doff) @item tb-size=3D@var{n} Controls the size (in MiB) of the TCG translation block cache. @item thread=3Dsingle|multi diff --git a/vl.c b/vl.c index e6ff56b..ee872f2 100644 --- a/vl.c +++ b/vl.c @@ -1257,13 +1257,6 @@ static void configure_msg(QemuOpts *opts) } =20 =20 -/* Now we still need this for compatibility with XEN. */ -bool has_igd_gfx_passthru; -static void igd_gfx_passthru(void) -{ - has_igd_gfx_passthru =3D current_machine->igd_gfx_passthru; -} - /***********************************************************/ /* USB devices */ =20 @@ -2642,6 +2635,10 @@ static int machine_set_property(void *opaque, if (g_str_equal(qom_name, "accel")) { return 0; } + if (g_str_equal(qom_name, "igd-passthru")) { + object_register_sugar_prop(ACCEL_CLASS_NAME("xen"), qom_name, valu= e); + return 0; + } =20 return object_parse_property_opt(opaque, name, value, "type", errp); } @@ -4456,9 +4453,6 @@ int main(int argc, char **argv, char **envp) exit(1); } =20 - /* Check if IGD GFX passthrough. */ - igd_gfx_passthru(); - /* init generic devices */ rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE); qemu_opts_foreach(qemu_find_opts("device"), --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575904914; cv=none; d=zohomail.com; s=zohoarc; b=ljeHJ4UqDgzLfqnfoSZnqk+TBRXEO/RogPe6O2XwoQNOChhhJ1gzWoGUfrja8N2kXhvrF/D5a1ZWNNFmWx5FD8lw2EVqydLKLepSbNKl5zJyJQ14jJAbnw5EE4v4X9LlxRx9u0G07Y0ZhorzHSnBDodZBfW/Gwuhl7ox6PGteyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575904914; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ylzcvlP2ozbD0HAsIyPi1y+3NrZwIrQQ1hXTxu0zBY0=; b=OlxliK/dpqxRjkSqCEQ7FCx5IDpXam6+Q3qe5qnL6XHJ7/nEj1/dmcO924+o+0+iidChyVs7alQS3VEUroJCuU9qU4lyC/rQEtfYAFkVduWjw8XrFaoAx95nmZfqAoex+a7r2xI6TBpkl9CejpBDVScBBpwyJurqPpwx2IhMjMQ= 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 1575904914352765.0286328139385; Mon, 9 Dec 2019 07:21:54 -0800 (PST) Received: from localhost ([::1]:41452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKrB-0007Y4-4z for importer@patchew.org; Mon, 09 Dec 2019 10:21:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47298) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKY4-0003cu-US for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKY3-0001ZS-3T for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:08 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:53187) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKY2-0001YW-Sf for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:07 -0500 Received: by mail-wm1-x32e.google.com with SMTP id p9so15827962wmc.2 for ; Mon, 09 Dec 2019 07:02:06 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.02.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:02:04 -0800 (PST) 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=ylzcvlP2ozbD0HAsIyPi1y+3NrZwIrQQ1hXTxu0zBY0=; b=bl4Yk6rXeyOFlqEEvxiUoO400Rtp0gyFUxoJwSD4M7bn7ubT+599lu4X7PIoJHT/XR PJwZaC4Ni0MNuUTjgZERaua2xMLYrusxwoBGEhGM3aUFN3oh5IPA4eSJ2tdq5pGMgtz9 5NC9QuHNEY+caHL8/nb8mI+oh6qqalP2b97R7mSLxYejRdpEbFNOdM7+PlYObZLZ2dla EdWEaX8ZU90IUxoGF10FXpKicwK/ouWRlq6SZaurGgc5ORwIkeLIUhLpORYt8c9yhWl7 0uAvo+V3j52p8lxXGyk5CpWWvszX7I9Ja6sJi6dh5xq5RiXoTndawzDqHwPONwIfarKJ yCYQ== 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=ylzcvlP2ozbD0HAsIyPi1y+3NrZwIrQQ1hXTxu0zBY0=; b=qRHH9VlmqNI+ncpu8Z3tjOibGElcjoIheS+dIxMd2B3S2VTaG70dez4bIz6KakdCc9 1g1OU6NWvIwL0w1c+LZxEjB/bDINrQwhZPdzEUaJs/jvXTO4FXCVWF6iuLBCEx6uy7o8 ANKRCGfyNJO+E2g67qTg9UxzsJWr61dGJWInsaR3wg3H+/Xji8LdAhv5ZvRE2rJbnmJy l2GyNSHC2eab5WxuiUZJpzGRMzdu/IRg04+GWClixkXOCwo6IRa0OSLE9YKJH17YqeKx 0/tHLMMKyLU9CToZgArKC3/dMv1zYIWsjAV0OBSSs6yaJZ76YCscC0T1U6poupEWPnZJ z7Ww== X-Gm-Message-State: APjAAAXZub30apdjxm/5zvO+COgJliN3sBJbU7DKXoTr2v0DLJzFvnwm vAXBF4xo7oolpHX/rye4suwB50fb X-Google-Smtp-Source: APXvYqw9upMJ3R4hmA5nEZslrDr+7wNW9+sVYWfVPPjrgoL0wyFYuFAgs5MTHG5BsnH/ncIGg8IT3g== X-Received: by 2002:a1c:8153:: with SMTP id c80mr24775007wmd.58.1575903725108; Mon, 09 Dec 2019 07:02:05 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 16/18] kvm: convert "-machine kvm_shadow_mem" to an accelerator property Date: Mon, 9 Dec 2019 16:01:43 +0100 Message-Id: <1575903705-12925-17-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-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:4864:20::32e 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- accel/kvm/kvm-all.c | 43 +++++++++++++++++++++++++++++++++++++++++++ hw/core/machine.c | 39 --------------------------------------- include/hw/boards.h | 2 -- qemu-options.hx | 6 +++--- target/i386/kvm.c | 2 +- vl.c | 4 ++++ 6 files changed, 51 insertions(+), 45 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index ca00daa..f0b9294 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -41,6 +41,7 @@ #include "hw/irq.h" #include "sysemu/sev.h" #include "sysemu/balloon.h" +#include "qapi/visitor.h" =20 #include "hw/boards.h" =20 @@ -92,6 +93,7 @@ struct KVMState int max_nested_state_len; int many_ioeventfds; int intx_set_mask; + int kvm_shadow_mem; bool sync_mmu; bool manual_dirty_log_protect; /* The man page (and posix) say ioctl numbers are signed int, but @@ -2940,6 +2942,40 @@ static bool kvm_accel_has_memory(MachineState *ms, A= ddressSpace *as, return false; } =20 +static void kvm_get_kvm_shadow_mem(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + KVMState *s =3D KVM_STATE(obj); + int64_t value =3D s->kvm_shadow_mem; + + visit_type_int(v, name, &value, errp); +} + +static void kvm_set_kvm_shadow_mem(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + KVMState *s =3D KVM_STATE(obj); + Error *error =3D NULL; + int64_t value; + + visit_type_int(v, name, &value, &error); + if (error) { + error_propagate(errp, error); + return; + } + + s->kvm_shadow_mem =3D value; +} + +static void kvm_accel_instance_init(Object *obj) +{ + KVMState *s =3D KVM_STATE(obj); + + s->kvm_shadow_mem =3D -1; +} + static void kvm_accel_class_init(ObjectClass *oc, void *data) { AccelClass *ac =3D ACCEL_CLASS(oc); @@ -2947,11 +2983,18 @@ static void kvm_accel_class_init(ObjectClass *oc, v= oid *data) ac->init_machine =3D kvm_init; ac->has_memory =3D kvm_accel_has_memory; ac->allowed =3D &kvm_allowed; + + object_class_property_add(oc, "kvm-shadow-mem", "int", + kvm_get_kvm_shadow_mem, kvm_set_kvm_shadow_mem, + NULL, NULL, &error_abort); + object_class_property_set_description(oc, "kvm-shadow-mem", + "KVM shadow MMU size", &error_abort); } =20 static const TypeInfo kvm_accel_type =3D { .name =3D TYPE_KVM_ACCEL, .parent =3D TYPE_ACCEL, + .instance_init =3D kvm_accel_instance_init, .class_init =3D kvm_accel_class_init, .instance_size =3D sizeof(KVMState), }; diff --git a/hw/core/machine.c b/hw/core/machine.c index d7a0356..bfb5f6f 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -211,33 +211,6 @@ static void machine_set_kernel_irqchip(Object *obj, Vi= sitor *v, } } =20 -static void machine_get_kvm_shadow_mem(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) -{ - MachineState *ms =3D MACHINE(obj); - int64_t value =3D ms->kvm_shadow_mem; - - visit_type_int(v, name, &value, errp); -} - -static void machine_set_kvm_shadow_mem(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) -{ - MachineState *ms =3D MACHINE(obj); - Error *error =3D NULL; - int64_t value; - - visit_type_int(v, name, &value, &error); - if (error) { - error_propagate(errp, error); - return; - } - - ms->kvm_shadow_mem =3D value; -} - static char *machine_get_kernel(Object *obj, Error **errp) { MachineState *ms =3D MACHINE(obj); @@ -785,12 +758,6 @@ static void machine_class_init(ObjectClass *oc, void *= data) object_class_property_set_description(oc, "kernel-irqchip", "Configure KVM in-kernel irqchip", &error_abort); =20 - object_class_property_add(oc, "kvm-shadow-mem", "int", - machine_get_kvm_shadow_mem, machine_set_kvm_shadow_mem, - NULL, NULL, &error_abort); - object_class_property_set_description(oc, "kvm-shadow-mem", - "KVM shadow MMU size", &error_abort); - object_class_property_add_str(oc, "kernel", machine_get_kernel, machine_set_kernel, &error_abort); object_class_property_set_description(oc, "kernel", @@ -892,7 +859,6 @@ static void machine_initfn(Object *obj) =20 ms->kernel_irqchip_allowed =3D true; ms->kernel_irqchip_split =3D mc->default_kernel_irqchip_split; - ms->kvm_shadow_mem =3D -1; ms->dump_guest_core =3D true; ms->mem_merge =3D true; ms->enable_graphics =3D true; @@ -963,11 +929,6 @@ bool machine_kernel_irqchip_split(MachineState *machin= e) return machine->kernel_irqchip_split; } =20 -int machine_kvm_shadow_mem(MachineState *machine) -{ - return machine->kvm_shadow_mem; -} - int machine_phandle_start(MachineState *machine) { return machine->phandle_start; diff --git a/include/hw/boards.h b/include/hw/boards.h index cdcf481..46119eb 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -66,7 +66,6 @@ bool machine_usb(MachineState *machine); bool machine_kernel_irqchip_allowed(MachineState *machine); bool machine_kernel_irqchip_required(MachineState *machine); bool machine_kernel_irqchip_split(MachineState *machine); -int machine_kvm_shadow_mem(MachineState *machine); int machine_phandle_start(MachineState *machine); bool machine_dump_guest_core(MachineState *machine); bool machine_mem_merge(MachineState *machine); @@ -278,7 +277,6 @@ struct MachineState { bool kernel_irqchip_allowed; bool kernel_irqchip_required; bool kernel_irqchip_split; - int kvm_shadow_mem; char *dtb; char *dumpdtb; int phandle_start; diff --git a/qemu-options.hx b/qemu-options.hx index 6f12b31..779c8af 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -34,7 +34,6 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " supported accelerators are kvm, xen, hax, hvf, whpx o= r tcg (default: tcg)\n" " kernel_irqchip=3Don|off|split controls accelerated ir= qchip support (default=3Doff)\n" " vmport=3Don|off|auto controls emulation of vmport (de= fault: auto)\n" - " kvm_shadow_mem=3Dsize of KVM shadow MMU in bytes\n" " dump-guest-core=3Don|off include guest memory in a co= re dump (default=3Don)\n" " mem-merge=3Don|off controls memory merge support (def= ault: on)\n" " aes-key-wrap=3Don|off controls support for AES key wr= apping (default=3Don)\n" @@ -74,8 +73,6 @@ Controls in-kernel irqchip support for the chosen acceler= ator when available. Enables emulation of VMWare IO port, for vmmouse etc. auto says to select = the value based on accel. For accel=3Dxen the default is off otherwise the def= ault is on. -@item kvm_shadow_mem=3Dsize -Defines the size of the KVM shadow MMU. @item dump-guest-core=3Don|off Include guest memory in a core dump. The default is on. @item mem-merge=3Don|off @@ -118,6 +115,7 @@ DEF("accel", HAS_ARG, QEMU_OPTION_accel, "-accel [accel=3D]accelerator[,prop[=3Dvalue][,...]]\n" " select accelerator (kvm, xen, hax, hvf, whpx or tcg; = use 'help' for a list)\n" " igd-passthru=3Don|off (enable Xen integrated Intel gr= aphics passthrough, default=3Doff)\n" + " kvm-shadow-mem=3Dsize of KVM shadow MMU in bytes\n" " tb-size=3Dn (TCG translation block cache size)\n" " thread=3Dsingle|multi (enable multi-threaded TCG)\n",= QEMU_ARCH_ALL) STEXI @@ -131,6 +129,8 @@ fails to initialize. @item igd-passthru=3Don|off When Xen is in use, this option controls whether Intel integrated graphics devices can be passed through to the guest (default=3Doff) +@item kvm-shadow-mem=3Dsize +Defines the size of the KVM shadow MMU. @item tb-size=3D@var{n} Controls the size (in MiB) of the TCG translation block cache. @item thread=3Dsingle|multi diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 1d10046..62ce681 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -2163,7 +2163,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } qemu_register_reset(kvm_unpoison_all, NULL); =20 - shadow_mem =3D machine_kvm_shadow_mem(ms); + shadow_mem =3D object_property_get_int(OBJECT(s), "kvm-shadow-mem", &e= rror_abort); if (shadow_mem !=3D -1) { shadow_mem /=3D 4096; ret =3D kvm_vm_ioctl(s, KVM_SET_NR_MMU_PAGES, shadow_mem); diff --git a/vl.c b/vl.c index ee872f2..3678522 100644 --- a/vl.c +++ b/vl.c @@ -2639,6 +2639,10 @@ static int machine_set_property(void *opaque, object_register_sugar_prop(ACCEL_CLASS_NAME("xen"), qom_name, valu= e); return 0; } + if (g_str_equal(qom_name, "kvm-shadow-mem")) { + object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), qom_name, valu= e); + return 0; + } =20 return object_parse_property_opt(opaque, name, value, "type", errp); } --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575904810; cv=none; d=zohomail.com; s=zohoarc; b=LWIqXKHV5fV1ydGFnQgXwSMsirFaTFOgOtlSlwza/YujlKVr1D4NMEs4qDstD7ZRCXW2Q8SsmQ04thHl9gn/1p9GeK4GSJdUHPCa6tDN8WG+253OLzXWoBTyeVstBL+9VuWm94qXi8NAPqdk5OvD+c7Lhu0ybySbcgXZzKSOXjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575904810; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=2obtCf3Vea6+0Qq3n8fYhTNc8P7aN6TGdrLYdh2+Zcc=; b=gSwUx3Set8w30cin59lSE1taLG2Ql3kw/cknjmzHVSvXjfkf28HNmhOx584ikihCJVmmS6YVgX4fuJ2f2JTZ0jLdqKD0KrIJA1CzVcKKj/QDNr7kcOi0G9vac6R04Eedg1m/l/GX9vLz3jG99dtiF/v141IDUa6lIRj/fcgzFHY= 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 1575904810682631.3521627550466; Mon, 9 Dec 2019 07:20:10 -0800 (PST) Received: from localhost ([::1]:41422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKpV-0005eN-Gf for importer@patchew.org; Mon, 09 Dec 2019 10:20:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47306) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKY5-0003di-4Y for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKY3-0001aC-Ee for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:09 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:43663) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKY3-0001Z7-6m for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:07 -0500 Received: by mail-wr1-x442.google.com with SMTP id d16so16529010wre.10 for ; Mon, 09 Dec 2019 07:02:07 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.02.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:02:05 -0800 (PST) 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=2obtCf3Vea6+0Qq3n8fYhTNc8P7aN6TGdrLYdh2+Zcc=; b=UL9W1/hBlvr0O21n2ShBLrfqzvB/KcZiCn/d2ClZ6PyMXUDPID76gtGixDzuG6KmWu 9vozsF6dMiCoHTVl+Ymb0f33kUoYtDNGT1LQcbSgKovvpviJP/zjscqCQLGFZYvFV4j/ hGRj25ZTHBAyDOYQ2TZL+tiG+efA4XeQCHeV8kngEDGkq3jtKvtqT4/Yjrn9VvQ1W49D +ESlTse551KUMQzHstHb1V1bqOloelpaMnTbBUt++cnTfTiLlJ7L4Q02G9yX8N9WsqU0 h2nyqsr9IQ6MjQMXlrAuudlWeTio6PCTsg4sHRzVwXD3tGodcvntZIfqMCDJRXBievvJ VJOA== 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=2obtCf3Vea6+0Qq3n8fYhTNc8P7aN6TGdrLYdh2+Zcc=; b=ZX5LGV07EPRx6XECq62BF+rU0OEONKCaF4/360euX/S7zW2zvglq7Ez5UWZU0iFhu+ DAIBc9tEw2TN4eRj160LY03tBEpeO693CEHYRTd/HhQ2l3bhmFPaj0n915exE9EktYo+ 1a24jSEiUC+4gIX1PgraPPCUKIxpQSMgq21KYQp0QlIlLlnv03XNJEkQhMGj6s3QU+JM pTjuhniPdawKNEd5tIPQFxo5HmiclIp6h9Xp6vEPy8372qrlaAZOPRS4kcx0nw3RdYgk vnu4gyPPbU8Ri1hdwMBk0zTkcn7LwChpJoUHCO9S9m/uumefgk01UN5AHnsD/68NjZZG V2uA== X-Gm-Message-State: APjAAAVWfcYI75LrwX5/BHONL5VkWW6xsaDu/pva+v6Dr+KjtnnQNM8F l8uiMM+UuwC/2O/gL4Ra+Nx1GqK8 X-Google-Smtp-Source: APXvYqwEX7FD0SY2L3zjoQMM7924kawAnuVbvALn1044sRnzwC/Yt66txa/IQsvIprx2x1IgDg4OIw== X-Received: by 2002:adf:e40f:: with SMTP id g15mr2761553wrm.223.1575903725987; Mon, 09 Dec 2019 07:02:05 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 17/18] kvm: introduce kvm_kernel_irqchip_* functions Date: Mon, 9 Dec 2019 16:01:44 +0100 Message-Id: <1575903705-12925-18-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-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:4864:20::442 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The KVMState struct is opaque, so provide accessors for the fields that will be moved from current_machine to the accelerator. For now they just forward to the machine object, but this will change. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- accel/kvm/kvm-all.c | 23 +++++++++++++++++++---- hw/ppc/e500.c | 4 ++-- hw/ppc/spapr_irq.c | 10 +++++----- include/sysemu/kvm.h | 7 +++++-- target/arm/kvm.c | 8 ++++---- target/i386/kvm.c | 4 ++-- target/mips/kvm.c | 2 +- target/ppc/kvm.c | 2 +- target/s390x/kvm.c | 2 +- 9 files changed, 40 insertions(+), 22 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index f0b9294..c0a6351 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1760,7 +1760,7 @@ void kvm_irqchip_set_qemuirq_gsi(KVMState *s, qemu_ir= q irq, int gsi) g_hash_table_insert(s->gsimap, irq, GINT_TO_POINTER(gsi)); } =20 -static void kvm_irqchip_create(MachineState *machine, KVMState *s) +static void kvm_irqchip_create(KVMState *s) { int ret; =20 @@ -1778,9 +1778,9 @@ static void kvm_irqchip_create(MachineState *machine,= KVMState *s) =20 /* First probe and see if there's a arch-specific hook to create the * in-kernel irqchip for us */ - ret =3D kvm_arch_irqchip_create(machine, s); + ret =3D kvm_arch_irqchip_create(s); if (ret =3D=3D 0) { - if (machine_kernel_irqchip_split(machine)) { + if (kvm_kernel_irqchip_split()) { perror("Split IRQ chip mode not supported."); exit(1); } else { @@ -2052,7 +2052,7 @@ static int kvm_init(MachineState *ms) } =20 if (machine_kernel_irqchip_allowed(ms)) { - kvm_irqchip_create(ms, s); + kvm_irqchip_create(s); } =20 if (kvm_eventfds_allowed) { @@ -2969,6 +2969,21 @@ static void kvm_set_kvm_shadow_mem(Object *obj, Visi= tor *v, s->kvm_shadow_mem =3D value; } =20 +bool kvm_kernel_irqchip_allowed(void) +{ + return machine_kernel_irqchip_allowed(current_machine); +} + +bool kvm_kernel_irqchip_required(void) +{ + return machine_kernel_irqchip_required(current_machine); +} + +bool kvm_kernel_irqchip_split(void) +{ + return machine_kernel_irqchip_split(current_machine); +} + static void kvm_accel_instance_init(Object *obj) { KVMState *s =3D KVM_STATE(obj); diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 91cd4c2..928efaa 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -801,10 +801,10 @@ static DeviceState *ppce500_init_mpic(PPCE500MachineS= tate *pms, if (kvm_enabled()) { Error *err =3D NULL; =20 - if (machine_kernel_irqchip_allowed(machine)) { + if (kvm_kernel_irqchip_allowed()) { dev =3D ppce500_init_mpic_kvm(pmc, irqs, &err); } - if (machine_kernel_irqchip_required(machine) && !dev) { + if (kvm_kernel_irqchip_required() && !dev) { error_reportf_err(err, "kernel_irqchip requested but unavailable: "= ); exit(1); diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index d6bb7fd..c3f8870 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -77,9 +77,9 @@ int spapr_irq_init_kvm(int (*fn)(SpaprInterruptController= *, Error **), MachineState *machine =3D MACHINE(qdev_get_machine()); Error *local_err =3D NULL; =20 - if (kvm_enabled() && machine_kernel_irqchip_allowed(machine)) { + if (kvm_enabled() && kvm_kernel_irqchip_allowed()) { if (fn(intc, &local_err) < 0) { - if (machine_kernel_irqchip_required(machine)) { + if (kvm_kernel_irqchip_required()) { error_prepend(&local_err, "kernel_irqchip requested but unavailable: "= ); error_propagate(errp, local_err); @@ -184,7 +184,7 @@ static int spapr_irq_check(SpaprMachineState *spapr, Er= ror **errp) */ if (kvm_enabled() && spapr->irq =3D=3D &spapr_irq_dual && - machine_kernel_irqchip_required(machine) && + kvm_kernel_irqchip_required() && xics_kvm_has_broken_disconnect(spapr)) { error_setg(errp, "KVM is too old to support ic-mode=3Ddual,kernel-= irqchip=3Don"); return -1; @@ -290,12 +290,12 @@ void spapr_irq_init(SpaprMachineState *spapr, Error *= *errp) MachineState *machine =3D MACHINE(spapr); SpaprMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); =20 - if (machine_kernel_irqchip_split(machine)) { + if (kvm_enabled() && kvm_kernel_irqchip_split()) { error_setg(errp, "kernel_irqchip split mode not supported on pseri= es"); return; } =20 - if (!kvm_enabled() && machine_kernel_irqchip_required(machine)) { + if (!kvm_enabled() && kvm_kernel_irqchip_required()) { error_setg(errp, "kernel_irqchip requested but only available with KVM"); return; diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 9fe233b..aaf2a50 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -519,10 +519,13 @@ void kvm_pc_gsi_handler(void *opaque, int n, int leve= l); void kvm_pc_setup_irq_routing(bool pci_enabled); void kvm_init_irq_routing(KVMState *s); =20 +bool kvm_kernel_irqchip_allowed(void); +bool kvm_kernel_irqchip_required(void); +bool kvm_kernel_irqchip_split(void); + /** * kvm_arch_irqchip_create: * @KVMState: The KVMState pointer - * @MachineState: The MachineState pointer * * Allow architectures to create an in-kernel irq chip themselves. * @@ -530,7 +533,7 @@ void kvm_init_irq_routing(KVMState *s); * 0: irq chip was not created * > 0: irq chip was created */ -int kvm_arch_irqchip_create(MachineState *ms, KVMState *s); +int kvm_arch_irqchip_create(KVMState *s); =20 /** * kvm_set_one_reg - set a register value in KVM via KVM_SET_ONE_REG ioctl diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 5b82cef..b87b59a 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -741,11 +741,11 @@ void kvm_arch_init_irq_routing(KVMState *s) { } =20 -int kvm_arch_irqchip_create(MachineState *ms, KVMState *s) +int kvm_arch_irqchip_create(KVMState *s) { - if (machine_kernel_irqchip_split(ms)) { - perror("-machine kernel_irqchip=3Dsplit is not supported on ARM."= ); - exit(1); + if (kvm_kernel_irqchip_split()) { + perror("-machine kernel_irqchip=3Dsplit is not supported on ARM."); + exit(1); } =20 /* If we can create the VGIC using the newer device control API, we diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 62ce681..ef63f3a 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -4494,10 +4494,10 @@ void kvm_arch_init_irq_routing(KVMState *s) } } =20 -int kvm_arch_irqchip_create(MachineState *ms, KVMState *s) +int kvm_arch_irqchip_create(KVMState *s) { int ret; - if (machine_kernel_irqchip_split(ms)) { + if (kvm_kernel_irqchip_split()) { ret =3D kvm_vm_enable_cap(s, KVM_CAP_SPLIT_IRQCHIP, 0, 24); if (ret) { error_report("Could not enable split irqchip mode: %s", diff --git a/target/mips/kvm.c b/target/mips/kvm.c index 578bc14..de3e26e 100644 --- a/target/mips/kvm.c +++ b/target/mips/kvm.c @@ -57,7 +57,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) return 0; } =20 -int kvm_arch_irqchip_create(MachineState *ms, KVMState *s) +int kvm_arch_irqchip_create(KVMState *s) { return 0; } diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index c77f984..461dc6d 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -152,7 +152,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) return 0; } =20 -int kvm_arch_irqchip_create(MachineState *ms, KVMState *s) +int kvm_arch_irqchip_create(KVMState *s) { return 0; } diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 0c9d14b..f3a742b 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -374,7 +374,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) return 0; } =20 -int kvm_arch_irqchip_create(MachineState *ms, KVMState *s) +int kvm_arch_irqchip_create(KVMState *s) { return 0; } --=20 1.8.3.1 From nobody Sun May 19 20:29:55 2024 Delivered-To: importer@patchew.org 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; 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=1575904636; cv=none; d=zohomail.com; s=zohoarc; b=OSzgQDpPL47f2sOkmp/ImK33YXdD+AfzKQz9L2noNUidVxI+MxWq53WgOyuW3vu4nmyJL8YTFjPYZhd46jHSjMex9qorrCC0ZWHLYQe4v6LLm7v0exEl+AOMFzCLakAKr3nLMQIRS/hHL02czMSPH68kDv7HSsa/atYzy2i7NmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575904636; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=mFgHc+JDuXDRL4Rz8NUQw8m1MBq1/vn5MhUlSU0rwJU=; b=iTdMLvdb1An3WOsAoitQDn/22G3o2szesidIbYq6JtbbPteJ+TaCgzjL+cgt7dyIrx9RlhbLVS2RucsBWbDZox2r/wt7yrS9XxVN9GFbXLkI6hXCre/OfLhCUT4gjhD6KdbG12cPCk33VICLmCqakIdfO05YVs5/1/XHuqNqs+I= 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 1575904636979142.81849909023458; Mon, 9 Dec 2019 07:17:16 -0800 (PST) Received: from localhost ([::1]:41376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKmh-0002t2-6b for importer@patchew.org; Mon, 09 Dec 2019 10:17:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47333) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieKY7-0003h2-3b for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieKY4-0001ek-UJ for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:10 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:37503) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieKY4-0001bD-Mz for qemu-devel@nongnu.org; Mon, 09 Dec 2019 10:02:08 -0500 Received: by mail-wr1-x441.google.com with SMTP id w15so16631910wru.4 for ; Mon, 09 Dec 2019 07:02:08 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g9sm27219371wro.67.2019.12.09.07.02.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 07:02:06 -0800 (PST) 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=mFgHc+JDuXDRL4Rz8NUQw8m1MBq1/vn5MhUlSU0rwJU=; b=BEDuB581sdgUZ/R9eFjJUBAJMj9FuM59jwpaDq4JrJhPyBsjtJND3h8upPF5/GZGu9 U1U4wh2q5UapanBkFy1BvzTDIwIX2ACnYl6S7ATxLDM++NtT9mdNlOD2A2Zt6RxXWXXp V43P5LcCHpeNeAPYTCcqnKC6aJxzv3pnfv8xcZIE0ep371vAf+f4hgBybblftrPfYbK9 xKZUhNlVKnPPbEy4GcvqhAXw0beU5SAA3a8n8h+2yN56IhMYNaZc6iODqOwiSmJZPS/M BYKQC6RODr6t14jxyBVyYw4CVKRHu6qNhD9GGzLh+HTRcfeUZH76cCGbb72bhMiSwrWa ayUQ== 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=mFgHc+JDuXDRL4Rz8NUQw8m1MBq1/vn5MhUlSU0rwJU=; b=DnOSS9mZDg7SSfp5KfFf6FQI6L9wYcgYw0hT5iDB18FJwXMDFviTFhQjN1DG7MGRmU w5cGJAizJJyNcBaipZDKWf19QERLSHNiSmbX8dmFg7FydtFn5NRv0yCfmrKIiaZl7mD+ SBIAFjtA0h4KiJS3INEalcI1fSpf04c69fSJ4Di4+iGgDR9D1MsXAfRlO5M01MHyvTBh KfejIKwRik2nq6qqE/CEE7CwapuAhormUj4sbQWkBVQ+tAYLyFmpJgI/0B6clk5YFY/g mMGAbMHTNcJ6R4o5C80Eo2Cz7EPOcOdhjAYsbZb1ktdly8Fp8zK50UvCNIxWX4t2TisU DK4A== X-Gm-Message-State: APjAAAVJvYXUM7W8vCyVuAislFwqEF3Ez9ZSpRS1JP/JOpT5/1HbWxHX asbGZK/EFLRIfLz1aBSnI9/iVj8n X-Google-Smtp-Source: APXvYqwKG93ATrpqtnnw8hL0X9SkTta9jInIjnq/mYqgupXruXlld92MudpS5QW0sIBnSsj9i+OFIQ== X-Received: by 2002:adf:d0c1:: with SMTP id z1mr2679096wrh.371.1575903727022; Mon, 09 Dec 2019 07:02:07 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH v2 18/18] kvm: convert "-machine kernel_irqchip" to an accelerator property Date: Mon, 9 Dec 2019 16:01:45 +0100 Message-Id: <1575903705-12925-19-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575903705-12925-1-git-send-email-pbonzini@redhat.com> References: <1575903705-12925-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:4864:20::441 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: thuth@redhat.com, elmarco@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- accel/kvm/kvm-all.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++---= -- hw/core/machine.c | 61 -------------------------------------------------= ---- include/hw/boards.h | 3 --- qemu-options.hx | 9 +++++--- vl.c | 3 ++- 5 files changed, 62 insertions(+), 73 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index c0a6351..b0adbb2 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -42,6 +42,8 @@ #include "sysemu/sev.h" #include "sysemu/balloon.h" #include "qapi/visitor.h" +#include "qapi/qapi-types-common.h" +#include "qapi/qapi-visit-common.h" =20 #include "hw/boards.h" =20 @@ -94,6 +96,9 @@ struct KVMState int many_ioeventfds; int intx_set_mask; int kvm_shadow_mem; + bool kernel_irqchip_allowed; + bool kernel_irqchip_required; + bool kernel_irqchip_split; bool sync_mmu; bool manual_dirty_log_protect; /* The man page (and posix) say ioctl numbers are signed int, but @@ -1780,7 +1785,7 @@ static void kvm_irqchip_create(KVMState *s) * in-kernel irqchip for us */ ret =3D kvm_arch_irqchip_create(s); if (ret =3D=3D 0) { - if (kvm_kernel_irqchip_split()) { + if (s->kernel_irqchip_split) { perror("Split IRQ chip mode not supported."); exit(1); } else { @@ -2051,7 +2056,7 @@ static int kvm_init(MachineState *ms) goto err; } =20 - if (machine_kernel_irqchip_allowed(ms)) { + if (s->kernel_irqchip_allowed) { kvm_irqchip_create(s); } =20 @@ -2969,19 +2974,57 @@ static void kvm_set_kvm_shadow_mem(Object *obj, Vis= itor *v, s->kvm_shadow_mem =3D value; } =20 +static void kvm_set_kernel_irqchip(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + Error *err =3D NULL; + KVMState *s =3D KVM_STATE(obj); + OnOffSplit mode; + + visit_type_OnOffSplit(v, name, &mode, &err); + if (err) { + error_propagate(errp, err); + return; + } else { + switch (mode) { + case ON_OFF_SPLIT_ON: + s->kernel_irqchip_allowed =3D true; + s->kernel_irqchip_required =3D true; + s->kernel_irqchip_split =3D false; + break; + case ON_OFF_SPLIT_OFF: + s->kernel_irqchip_allowed =3D false; + s->kernel_irqchip_required =3D false; + s->kernel_irqchip_split =3D false; + break; + case ON_OFF_SPLIT_SPLIT: + s->kernel_irqchip_allowed =3D true; + s->kernel_irqchip_required =3D true; + s->kernel_irqchip_split =3D true; + break; + default: + /* The value was checked in visit_type_OnOffSplit() above. If + * we get here, then something is wrong in QEMU. + */ + abort(); + } + } +} + bool kvm_kernel_irqchip_allowed(void) { - return machine_kernel_irqchip_allowed(current_machine); + return kvm_state->kernel_irqchip_allowed; } =20 bool kvm_kernel_irqchip_required(void) { - return machine_kernel_irqchip_required(current_machine); + return kvm_state->kernel_irqchip_required; } =20 bool kvm_kernel_irqchip_split(void) { - return machine_kernel_irqchip_split(current_machine); + return kvm_state->kernel_irqchip_split; } =20 static void kvm_accel_instance_init(Object *obj) @@ -2999,6 +3042,12 @@ static void kvm_accel_class_init(ObjectClass *oc, vo= id *data) ac->has_memory =3D kvm_accel_has_memory; ac->allowed =3D &kvm_allowed; =20 + object_class_property_add(oc, "kernel-irqchip", "on|off|split", + NULL, kvm_set_kernel_irqchip, + NULL, NULL, &error_abort); + object_class_property_set_description(oc, "kernel-irqchip", + "Configure KVM in-kernel irqchip", &error_abort); + object_class_property_add(oc, "kvm-shadow-mem", "int", kvm_get_kvm_shadow_mem, kvm_set_kvm_shadow_mem, NULL, NULL, &error_abort); diff --git a/hw/core/machine.c b/hw/core/machine.c index bfb5f6f..c1cad2c 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -173,44 +173,6 @@ GlobalProperty hw_compat_2_1[] =3D { }; const size_t hw_compat_2_1_len =3D G_N_ELEMENTS(hw_compat_2_1); =20 -static void machine_set_kernel_irqchip(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) -{ - Error *err =3D NULL; - MachineState *ms =3D MACHINE(obj); - OnOffSplit mode; - - visit_type_OnOffSplit(v, name, &mode, &err); - if (err) { - error_propagate(errp, err); - return; - } else { - switch (mode) { - case ON_OFF_SPLIT_ON: - ms->kernel_irqchip_allowed =3D true; - ms->kernel_irqchip_required =3D true; - ms->kernel_irqchip_split =3D false; - break; - case ON_OFF_SPLIT_OFF: - ms->kernel_irqchip_allowed =3D false; - ms->kernel_irqchip_required =3D false; - ms->kernel_irqchip_split =3D false; - break; - case ON_OFF_SPLIT_SPLIT: - ms->kernel_irqchip_allowed =3D true; - ms->kernel_irqchip_required =3D true; - ms->kernel_irqchip_split =3D true; - break; - default: - /* The value was checked in visit_type_OnOffSplit() above. If - * we get here, then something is wrong in QEMU. - */ - abort(); - } - } -} - static char *machine_get_kernel(Object *obj, Error **errp) { MachineState *ms =3D MACHINE(obj); @@ -752,12 +714,6 @@ static void machine_class_init(ObjectClass *oc, void *= data) mc->numa_mem_align_shift =3D 23; mc->numa_auto_assign_ram =3D numa_default_auto_assign_ram; =20 - object_class_property_add(oc, "kernel-irqchip", "on|off|split", - NULL, machine_set_kernel_irqchip, - NULL, NULL, &error_abort); - object_class_property_set_description(oc, "kernel-irqchip", - "Configure KVM in-kernel irqchip", &error_abort); - object_class_property_add_str(oc, "kernel", machine_get_kernel, machine_set_kernel, &error_abort); object_class_property_set_description(oc, "kernel", @@ -857,8 +813,6 @@ static void machine_initfn(Object *obj) MachineState *ms =3D MACHINE(obj); MachineClass *mc =3D MACHINE_GET_CLASS(obj); =20 - ms->kernel_irqchip_allowed =3D true; - ms->kernel_irqchip_split =3D mc->default_kernel_irqchip_split; ms->dump_guest_core =3D true; ms->mem_merge =3D true; ms->enable_graphics =3D true; @@ -914,21 +868,6 @@ bool machine_usb(MachineState *machine) return machine->usb; } =20 -bool machine_kernel_irqchip_allowed(MachineState *machine) -{ - return machine->kernel_irqchip_allowed; -} - -bool machine_kernel_irqchip_required(MachineState *machine) -{ - return machine->kernel_irqchip_required; -} - -bool machine_kernel_irqchip_split(MachineState *machine) -{ - return machine->kernel_irqchip_split; -} - int machine_phandle_start(MachineState *machine) { return machine->phandle_start; diff --git a/include/hw/boards.h b/include/hw/boards.h index 46119eb..b42fedd 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -63,9 +63,6 @@ extern MachineState *current_machine; =20 void machine_run_board_init(MachineState *machine); bool machine_usb(MachineState *machine); -bool machine_kernel_irqchip_allowed(MachineState *machine); -bool machine_kernel_irqchip_required(MachineState *machine); -bool machine_kernel_irqchip_split(MachineState *machine); int machine_phandle_start(MachineState *machine); bool machine_dump_guest_core(MachineState *machine); bool machine_mem_merge(MachineState *machine); diff --git a/qemu-options.hx b/qemu-options.hx index 779c8af..945fc4a 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -32,7 +32,6 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " selects emulated machine ('-machine help' for list)\n" " property accel=3Daccel1[:accel2[:...]] selects accele= rator\n" " supported accelerators are kvm, xen, hax, hvf, whpx o= r tcg (default: tcg)\n" - " kernel_irqchip=3Don|off|split controls accelerated ir= qchip support (default=3Doff)\n" " vmport=3Don|off|auto controls emulation of vmport (de= fault: auto)\n" " dump-guest-core=3Don|off include guest memory in a co= re dump (default=3Don)\n" " mem-merge=3Don|off controls memory merge support (def= ault: on)\n" @@ -67,8 +66,6 @@ This is used to enable an accelerator. Depending on the t= arget architecture, kvm, xen, hax, hvf, whpx or tcg can be available. By default, tcg is used.= If there is more than one accelerator specified, the next one is used if the previous = one fails to initialize. -@item kernel_irqchip=3Don|off -Controls in-kernel irqchip support for the chosen accelerator when availab= le. @item vmport=3Don|off|auto Enables emulation of VMWare IO port, for vmmouse etc. auto says to select = the value based on accel. For accel=3Dxen the default is off otherwise the def= ault @@ -115,6 +112,7 @@ DEF("accel", HAS_ARG, QEMU_OPTION_accel, "-accel [accel=3D]accelerator[,prop[=3Dvalue][,...]]\n" " select accelerator (kvm, xen, hax, hvf, whpx or tcg; = use 'help' for a list)\n" " igd-passthru=3Don|off (enable Xen integrated Intel gr= aphics passthrough, default=3Doff)\n" + " kernel-irqchip=3Don|off|split controls accelerated ir= qchip support (default=3Don)\n" " kvm-shadow-mem=3Dsize of KVM shadow MMU in bytes\n" " tb-size=3Dn (TCG translation block cache size)\n" " thread=3Dsingle|multi (enable multi-threaded TCG)\n",= QEMU_ARCH_ALL) @@ -129,6 +127,11 @@ fails to initialize. @item igd-passthru=3Don|off When Xen is in use, this option controls whether Intel integrated graphics devices can be passed through to the guest (default=3Doff) +@item kernel-irqchip=3Don|off|split +Controls KVM in-kernel irqchip support. The default is full acceleration = of the +interrupt controllers. On x86, split irqchip reduces the kernel attack +surface, at a performance cost for non-MSI interrupts. Disabling the in-k= ernel +irqchip completely is not recommended except for debugging purposes. @item kvm-shadow-mem=3Dsize Defines the size of the KVM shadow MMU. @item tb-size=3D@var{n} diff --git a/vl.c b/vl.c index 3678522..53e4ff6 100644 --- a/vl.c +++ b/vl.c @@ -2639,7 +2639,8 @@ static int machine_set_property(void *opaque, object_register_sugar_prop(ACCEL_CLASS_NAME("xen"), qom_name, valu= e); return 0; } - if (g_str_equal(qom_name, "kvm-shadow-mem")) { + if (g_str_equal(qom_name, "kvm-shadow-mem") || + g_str_equal(qom_name, "kernel-irqchip")) { object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), qom_name, valu= e); return 0; } --=20 1.8.3.1