From nobody Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656071; cv=none; d=zoho.com; s=zohoarc; b=gpUNTF4dw0WNLD/5jDv+Xp3GqK6WGJ/aTrzQAtrusz6Jk8toIVtHCgDBp0OxQx8bsLvpmJvbnaRTsoRAvRvyz2Xf04Ex0Mwt0mml7p40mFf6WkQGxHCHjJN2k87QeYUWAsCslgbIWsnRzEWf93qKWpQ9T7RwByUndWFvGHQAe9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656071; 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=A6oEcaqPLdIen2KQ+hFkGKCCjU/abr6ShDeleTCaBkU=; b=Lb1LaohHgNaMkw5MERud1fTLRJX+I9YMctLyr9hV569ti1YJDWje53erz+WxF2DTurx2EoabQfDxmUsTpzbMe1Z4gv2RA94AM6vjpUQPcxT5UzsMG7udiaLUCwLVAbH60/AUtGPCHLUPGrIrZAIskXMQjAk5Zw8K5lgXLG9IqPU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 157365607181172.97710668636171; Wed, 13 Nov 2019 06:41:11 -0800 (PST) Received: from localhost ([::1]:45634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtpR-0007Ue-2L for importer@patchew.org; Wed, 13 Nov 2019 09:41:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54431) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtna-0005hr-M3 for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtnZ-0006I0-OP for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:10 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:51123) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtnZ-0006Hd-Gf for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:09 -0500 Received: by mail-wm1-x341.google.com with SMTP id l17so2257136wmh.0 for ; Wed, 13 Nov 2019 06:39:09 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:07 -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=A6oEcaqPLdIen2KQ+hFkGKCCjU/abr6ShDeleTCaBkU=; b=tSmlikXA203u3g/yuMGzzTotMPASusVpWmln/GIQNQS1CcRX88upPTIiD/FYwV/xzq +t3SK0p80TVXPBgQNAvJhNb0mdHm21+FZHNQC1y4UQBy1f/6nEIj8NRbvmpAmsO0yOJu b3tjsDSi8JZGrdrVsaLHzwKO4PfcYPoRRwvuP9dEusegGHIFD2c8hX8APCQcvKao6lJu Sv+PqONvmKIvGxJnm22wlYyYiOIFYiLouUAA1etlIyKjmqqjCNKhdRzThbNj/AAPXRTp 5c3MMq3bz5KRJG1ZKsYExbfricJV6gqSXt4VT+y+KOm4q7xZ/+sOPWIL2jq5cIlnKXTr pZvQ== 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=A6oEcaqPLdIen2KQ+hFkGKCCjU/abr6ShDeleTCaBkU=; b=mXfmI461WegX6Bts4oJnGZP2OUT+pw8qtH6847ZoSb+XnFuOjRaWQ6TiMaTysR/rC/ /+v7r4rG1gY8LPabDsxR4kZBuAW/f4Jd7XiixCdhTaZhRMe9vlSDujACdyRv23FsuQow 4yTtzOotnhbCa95mzSemq0x1Kj0ukWZx9LWbVDpDbyiyT89SR4citmo+azfjnJzWVexm nl2We/YMlToL70Da35bdpLf1QywqW7dZEBoqJWHr2dZUT9ILr/dvxrAYijyBEnC+AIY6 0IaO9iFjEs5aAyqjR9MlAX5GhEVtalLdIzT6T0qIO+1NFnFPoG+OFV/m4vVzRD3z2aAZ Mb9A== X-Gm-Message-State: APjAAAXrSO3SfVlqb7lZGyEn5DHHXY7+aGyb/kcOXGD1+b0R8OM+mJmA GZUQNvCDRF7li7Yq2EQmCR4OZMwk X-Google-Smtp-Source: APXvYqyxa9PcRKBCqP/ys4NoVCshVqh87sQ3wECxMg6baWVpJKr9MJFb0fxqLHZ3DzozUKa4rQoJsw== X-Received: by 2002:a05:600c:2058:: with SMTP id p24mr2865406wmg.134.1573655948065; Wed, 13 Nov 2019 06:39:08 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 01/16] memory: do not look at current_machine->accel Date: Wed, 13 Nov 2019 15:38:50 +0100 Message-Id: <1573655945-14912-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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::341 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, armbru@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" "info mtree" 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. Signed-off-by: Paolo Bonzini Reviewed-by: Marc-Andr=C3=A9 Lureau Tested-by: Thomas Huth --- memory.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/memory.c b/memory.c index c952eab..1764af8 100644 --- a/memory.c +++ b/memory.c @@ -2986,7 +2986,6 @@ struct FlatViewInfo { bool dispatch_tree; bool owner; AccelClass *ac; - const char *ac_name; }; =20 static void mtree_print_flatview(gpointer key, gpointer value, @@ -3056,7 +3055,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); } } } @@ -3104,8 +3103,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 Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656070; cv=none; d=zoho.com; s=zohoarc; b=bNffLO4tbI9R2tHy+rD6UaeFxSdrPw4SfCSyledOlb/pPP6t2Y2/qxvl1TC2mfUfgoJV8eoFZtorX/KI82URNY617RrqXJPzG/yMl6PwtX/dOep+IUlYMULcb7lSOPMRNcufRYuIN0F3UnoaUb8HvnUmj/1ddfNo+ZcR64sYKVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656070; 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=wetGOwL6w9T5KqZky8gH8g8gUVnF2w1GmxQs/cFXJ4g=; b=MQnv4fuhWHP4nUPi8R2wcyy00uA6WPd4w/MmWpXvONG3MLELp/hd0hxGwEY4LTIlRsvWdsE65XDnbUWW8yPeuH68HATDIo+1oD3/J0GNNfaNBQJXgV9i5W9fIKxFhNWit72IyKMmwXImcoRXxNm1cXSq558f28RBth1UoU3Gi9E= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 157365607089857.483806044358744; Wed, 13 Nov 2019 06:41:10 -0800 (PST) Received: from localhost ([::1]:45638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtpS-0007Yj-GC for importer@patchew.org; Wed, 13 Nov 2019 09:41:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54457) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtnb-0005i5-P2 for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtna-0006IX-Mo for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:11 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:35909) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtna-0006I4-Gg for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:10 -0500 Received: by mail-wr1-x443.google.com with SMTP id r10so2658770wrx.3 for ; Wed, 13 Nov 2019 06:39:10 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:08 -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=wetGOwL6w9T5KqZky8gH8g8gUVnF2w1GmxQs/cFXJ4g=; b=JA/121bL7xwyBhWiY7Vz+uiS9W1+Qdz7XpsqwRfsuE7oH61I8EQUwuhwsKW17uNac2 WJmDbffmVIklxgVWG6XYdSR5btBVlyRn/1FqMyPL5g6/+yneMvtewa3AtmTQNC63NO2a VJSpbk4wVMrhSwe8vJissyhH0IFtwMARVO8NntgqM7OL4iw0bpKWHidjy9YE8aRPpkiQ cV4vWjopJoUDXWyLqjkUToxJoLm93MkRiwMaJUEeVHtAVYztmU5KWpG2/c7T8W994itB 9OhgEDsne1J0iRfFZ1uzTR40aBDWMtp5cWw7vMpeSdhpiO1p5GCTU7L0YqvtD8sAgiIa 02KQ== 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=wetGOwL6w9T5KqZky8gH8g8gUVnF2w1GmxQs/cFXJ4g=; b=BwW49CUd6DK0J2itkoPEz+ieEIjDuHTIfedr8CTjayjmy1LoQLKMPX1OupU7+04jqH qBsI1IOZjwKPsbL2RJ4XlDoyKvOijYlgOSEMVT6aiFvImbCwGaWdVXo81E/KsJVUzQD/ wpFVh5FA6yGJnrMKet2shVAo7YuFSUZJp9dIW5tA3BsPdeSWv0DpjIEc6oOU+qX7vjg2 GH2A6jvI4H5F1W26MknVN5eEiw9cE3c62qlH97eKM80IahG9ohPujl6Bpp1Y0VKbe9A6 18IHzo8OxVl/F4WT0PVsxs8fvDMe7E5gVa4u4O97CISqZnuTbO7Oz8eCyQfudkPj27N7 8Lig== X-Gm-Message-State: APjAAAVYUxFkKNdrcfWo+NtZ+40EpODeuwWcwSDwwo/0eWeLknEZG74Q EGeUgjzyIg//ICxqKlUBE28AVCE2 X-Google-Smtp-Source: APXvYqxo3kzQoLQTYvCv8BpHpYI37fs/h410Vy/RCwpcVTgwAjjJG7fhY4j+wSq9m3e8IFLmoXuy7g== X-Received: by 2002:a5d:526f:: with SMTP id l15mr3077923wrc.169.1573655949155; Wed, 13 Nov 2019 06:39:09 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 02/16] vl: extract accelerator option processing to a separate function Date: Wed, 13 Nov 2019 15:38:51 +0100 Message-Id: <1573655945-14912-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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, armbru@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 -icount and -accel semantics into a new function, and use qemu_opts_foreach to retrieve the key/value lists instead of stashing them into globals. Signed-off-by: Paolo Bonzini --- vl.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/vl.c b/vl.c index 841fdae..5367f23 100644 --- a/vl.c +++ b/vl.c @@ -2827,6 +2827,33 @@ static void user_register_global_props(void) global_init_func, NULL, NULL); } =20 +static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp) +{ + if (tcg_enabled()) { + configure_icount(opts, errp); + } else { + error_setg(errp, "-icount is not allowed with hardware virtualizat= ion"); + } + return 0; +} + +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("icount"), + do_configure_icount, NULL, &error_fatal); + + qemu_opts_foreach(qemu_find_opts("accel"), + do_configure_accelerator, NULL, &error_fatal); +} + int main(int argc, char **argv, char **envp) { int i; @@ -4241,18 +4268,7 @@ 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()) { - 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 Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656280; cv=none; d=zoho.com; s=zohoarc; b=GxOlZswwh7rQnvOJkWWVRPeso4u3iAKx7X/aw0Oo5FzTdGdzkwxqVLRoxVeHpGfz7J5Kf8RDCNstaAJOfchQ41W5NXnUJem6UuVMWIjBsG1aWltJ4CD/UVGQVSYfs5e/kg6cTFllR48wnD+L7mGCU0kcKOH8JXFB6fQ7i7b1Ut4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656280; 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=iszTbD52Pp95pGi+D6mfWjcoYn8y4e0DUxu7sGpWVv8=; b=eeXjOunWqfsg/4dT58tyUx7tk9jfsFscljFEVxzk6Xt9GcA/NFo9JHbMYT+5Y2AcW/vVpsmJwOBLDx4beT6jb57RQNTQ/MvGxD68Fc3ZQKzC4wYiHqHKSDjcdPXSY1BCdSTEEVWp/VliY3TQnpquQVSjaXhNlRpElTAmEUI3D6w= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1573656280038432.41886278259767; Wed, 13 Nov 2019 06:44:40 -0800 (PST) Received: from localhost ([::1]:45682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtsr-0003e9-Gu for importer@patchew.org; Wed, 13 Nov 2019 09:44:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54481) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtnd-0005ia-T8 for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtnc-0006JK-EY for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:13 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:41953) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtnc-0006Ix-8F for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:12 -0500 Received: by mail-wr1-x42e.google.com with SMTP id b18so1155319wrj.8 for ; Wed, 13 Nov 2019 06:39:12 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:09 -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=iszTbD52Pp95pGi+D6mfWjcoYn8y4e0DUxu7sGpWVv8=; b=ocU7YEdcWgUInMs8QTjOwNa8tyyTVUcEPaSdeDA0Gw0R6QO47jYGY9uKTHZXgiOjY8 wG54mQQPoXOR/Wc/4Wse30XbZCtOBzgCdzpLU6Xe+mdibwFxyv8vZbVOXMR797QDrYyS tSn1Lt+oijU98DeHU0G9oQGy8hi3vU7H0Jr9aIscVF4pKKp0hcRllLdsiSt1G98122Ib 8ChCmm9hc9tiGcz35d/1ssbvx0xo8XTo3S/BHY1cO6CtPv8ZonexA/RHocxORFnRSKi+ VEMYB59VBBGya2V9jDiUL60R/hRE64COG53cbJs90MDnapW3c80PvC+hFOOVCI8a2Pcd xm7A== 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=iszTbD52Pp95pGi+D6mfWjcoYn8y4e0DUxu7sGpWVv8=; b=Vc1KiL4G6ynNndssIWtRfaRuIVVn57KuTZhXvUObFnSLqaQAojZ9f3YjkymOM33b3d Zwk3zXIVeDJzV+wL559q975ZKPAiBT25jzJG9N6VDlcYwk8fh6/TMMQT1UxrqZr+LW/O hlsRFzJi2DjjyAd6fXxjJcTKivTw5mHiV99TJMNobAKx1yFxiL+XR7SAUeo6A4o8lGYH 7wxdROSB5lYJKLok89AAzQ7FtwQT5fXRm0w1CDMgu2H3gzekJLlEblmijB0g2C9VSDxQ f0s8BeDCWtavk2ZYgRQrQB3Cg6t7C549ALn4ZQTJhYXpP12FR4ueQC0sUG6mK729sIJ/ AAbA== X-Gm-Message-State: APjAAAX94X8EYCTr9wBeWq7zNlplNqLTQVOzyLQIY+2UsRaVn2qjfEL2 oKYR/P3ksgTmIVTMgKJpMnZubXhW X-Google-Smtp-Source: APXvYqwgMc+uvpb87z7h625e7xXIKMo3AkkxR3VPORNOPV09LQS88OHOfNz+fEykqzkLkjU+HDGErw== X-Received: by 2002:a5d:48c8:: with SMTP id p8mr3336952wrs.318.1573655950228; Wed, 13 Nov 2019 06:39:10 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 03/16] vl: merge -accel processing into configure_accelerators Date: Wed, 13 Nov 2019 15:38:52 +0100 Message-Id: <1573655945-14912-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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::42e 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, armbru@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 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. Signed-off-by: Paolo Bonzini Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Wainer dos Santos Moschetta --- accel/accel.c | 63 ++--------------------------------------------= ---- include/sysemu/accel.h | 4 +++- vl.c | 62 +++++++++++++++++++++++++++++++++++++++++++++-= --- 3 files changed, 62 insertions(+), 67 deletions(-) diff --git a/accel/accel.c b/accel/accel.c index 5fa3171..74eda68 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -44,7 +44,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 +52,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 +71,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 5367f23..fc9e70f 100644 --- a/vl.c +++ b/vl.c @@ -2845,8 +2845,62 @@ 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; + + 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("icount"), do_configure_icount, NULL, &error_fatal); =20 @@ -4183,7 +4237,8 @@ int main(int argc, char **argv, char **envp) * Note: uses machine properties such as kernel-irqchip, must run * after machine_set_property(). */ - configure_accelerator(current_machine, argv[0]); + cpu_ticks_init(); + configure_accelerators(argv[0]); =20 /* * Beware, QOM objects created before this point miss global and @@ -4267,9 +4322,6 @@ int main(int argc, char **argv, char **envp) /* spice needs the timers to be initialized by this point */ qemu_spice_init(); =20 - cpu_ticks_init(); - configure_accelerators(); - if (default_net) { QemuOptsList *net =3D qemu_find_opts("net"); qemu_opts_set(net, NULL, "type", "nic", &error_abort); --=20 1.8.3.1 From nobody Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656296; cv=none; d=zoho.com; s=zohoarc; b=O5RO5ZJJt9/oqJBtVT4icKgw+8mtYEaU0ydu88kd2gFYmTtWjr6eyIqhm1m3493EfwFN6zZbT7P0A1nOc9/bpDZyRvIa109yksAwXSnyVKJvslcYWQbT43EiFSd3J5YdOyVCzH3MPK0zv/D8YF0K+zpGWZiOpyJOeqO42egBczk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656296; 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=BMoj3pLYyIvpZE90nhRpNRgweOStTA6dPJpbWeqyIqQ=; b=E0EKwkOdy8h1BxEC/8O+MATVzvneyUY0wYk0fYGTrV3L+xDQjDdS9WZdSO10S1XOqY1BB5V5nJPeB8Vk9y9HoTOvOGWr4KFo3nbm61WjBqBm7elLSCZGiu0Kp2h4lxMpgz5dW6VeI1WEHoo6qIB8bXafFwvYMesoVKOeQzyj8uA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1573656296526689.1813103580363; Wed, 13 Nov 2019 06:44:56 -0800 (PST) Received: from localhost ([::1]:45684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtt9-00048T-1b for importer@patchew.org; Wed, 13 Nov 2019 09:44:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54483) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtnd-0005ih-WF for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtnc-0006JU-Vk for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:13 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:33032) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtnc-0006JB-OX for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:12 -0500 Received: by mail-wr1-x441.google.com with SMTP id w9so2667432wrr.0 for ; Wed, 13 Nov 2019 06:39:12 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:10 -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=BMoj3pLYyIvpZE90nhRpNRgweOStTA6dPJpbWeqyIqQ=; b=TnFge3x3+IgpnvnFjoTBzC6C4TgEH73eBp9JvzN1Z+Log2Wks1dYzLUXF4qbkO0V0W Qh+SfD6hrwB69FBBj4r3gpD7VsGpnRYY/+yLZQ5WM/uG/jVAICo933BuzltwN3tdIi+g OOe9+bzfeTW1XgqlpE0mqNVX5uxNrc3OylpzHns2+5GFMRmUsXs+mxHfuSBVljt7U4qX XkQNi1T1R5Bg0ZuuCHuAlRdCzu0UAeKWO+yE0JDp975/gPjSJGPr7b31GKS+ghniuIVx 5p6zoZfEbbMM6J2p3CA77ulnPe+glSfrXw5eOiz70nOa3PSreb3tilY60dpA7WJFyWwE ixZw== 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=BMoj3pLYyIvpZE90nhRpNRgweOStTA6dPJpbWeqyIqQ=; b=r3em8jgcnZKCtf9gBk12MGvhQARflrD/JhXxNOjnET1XTW1o2taCnaQ0tHpKfCTWoF MY0n6GVGZ0C2PG2egzjlEzlKnMP3HigJQGbEXd8kLJjflEnxS8bCrangiawjvqP1nF2K Q0sb+Hqzy4HUbEA9uVOYkxXLE1VLTPgz2id7WyqGwvL6ovbe5qCrhoiZDCP7lOiP/EM4 Rg3hj0nWxpaivUMRxWHUdksxyDO53INLVbqkF9ik5yxeJ1Z8b+cKh621OgELMj01Ul51 Ly6itNXoFfybS5iN5n112Na43fAaXBMZLOtjwEiNKrIJhgf7+WPaITYM1L6jixLEaP7e FIng== X-Gm-Message-State: APjAAAVFUN8agImoWV+7w/BQra0yerg7TtnKCvP2CXaKaHQti6ceI6Dn VOJ/w5hzgU/98R/KiCKblx+N9+8S X-Google-Smtp-Source: APXvYqyU5bACf/fUSCh/UMDpw/ZTXwjkL+n/6PZA6pDio2/uZlRNeM/6FAkz70Qmrlte2HILhEAplw== X-Received: by 2002:adf:fa0b:: with SMTP id m11mr3365936wrr.279.1573655951103; Wed, 13 Nov 2019 06:39:11 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 04/16] vl: move icount configuration earlier Date: Wed, 13 Nov 2019 15:38:53 +0100 Message-Id: <1573655945-14912-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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, armbru@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" 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 init_machine method, which currently runs after "-icount" is processed. However, it is harmless to do configure_icount for all accelerators; we will just fail later if a non-TCG accelerator being selected. So do that. Signed-off-by: Paolo Bonzini Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Thomas Huth --- vl.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/vl.c b/vl.c index fc9e70f..dbc99d7 100644 --- a/vl.c +++ b/vl.c @@ -2829,11 +2829,7 @@ static void user_register_global_props(void) =20 static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp) { - if (tcg_enabled()) { - configure_icount(opts, errp); - } else { - error_setg(errp, "-icount is not allowed with hardware virtualizat= ion"); - } + configure_icount(opts, errp); return 0; } =20 @@ -2854,6 +2850,9 @@ static void configure_accelerators(const char *progna= me) bool init_failed =3D false; AccelClass *acc =3D NULL; =20 + 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 */ @@ -2901,11 +2900,13 @@ static void configure_accelerators(const char *prog= name) error_report("Back to %s accelerator", acc->name); } =20 - qemu_opts_foreach(qemu_find_opts("icount"), - do_configure_icount, NULL, &error_fatal); - 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); + } } =20 int main(int argc, char **argv, char **envp) --=20 1.8.3.1 From nobody Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656234; cv=none; d=zoho.com; s=zohoarc; b=GnptqX20VmaWe0aXVFZtj43tlsoIn9VDqi6DFHxOs8jiYkcl6PMY9Oe7gFdVDur1qP7uDKShs8xXsVCZTYXq0dChv+mDNywqsX97ZeMyr5ls26RNpGI4RONAExqummR9kOUN+RDoDO7fRmpuakXDABSN1cv/gcDFvo3PhDWQyu8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656234; 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=6wm1YNSrTob9W5VNPA38HVv/k6LxUe96COGHHCY161w=; b=CtcnIfq8iAwsp2y/hzu98NjZ6QSgifup2qTmZeKnrV8RZIuym8p2ldE+lyDk4K/rpNV8oOYi8hjRyDtXmBKNRwhnJJ+q/6YGpMavU5/MuO+BmaE0fgQipcywyIbQaPmfl6GhHx4Y238p6F2kxTjFdVjLSuKfaoyiAbtHXQ0tGUw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1573656234229946.9379957056781; Wed, 13 Nov 2019 06:43:54 -0800 (PST) Received: from localhost ([::1]:45678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUts8-0002p5-VM for importer@patchew.org; Wed, 13 Nov 2019 09:43:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54508) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtnf-0005lN-Da for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtne-0006K9-8e for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:15 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:33034) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtne-0006Jh-1r for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:14 -0500 Received: by mail-wr1-x443.google.com with SMTP id w9so2667517wrr.0 for ; Wed, 13 Nov 2019 06:39:13 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:11 -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=6wm1YNSrTob9W5VNPA38HVv/k6LxUe96COGHHCY161w=; b=oPFBJoL38PVR1ol2az3KUBrpbiNr9VgxBSksE9oSOCnavSy/r7o4LRgsNlCjTWKRlK kLGV3z7TzTQ3NhihFeh89C2OW2tQpbChnFEDpKkhyikzsSyrjPiI/YbCF1Ioe2HP9DdF Pz/hypjBfAB/wkO7HF1ogFp+Wv7gqzl7SqILiJzUrOBo0Vy0oZE1jOFk/UXTyU8NX/+u x7CZ8SrE/KIf1LUtgwhrAn3OZUuw7zGaRauLD35cn6zhW3SkFfwQ7z4b9H6AaOPp2gNw IFvT1/AXBYEs0UjGtIAxXFAFgA8Qctmi8/ykbMa93i3qj6zUw+jc9I9Pq6eB2z9EHZy4 ZCwQ== 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=6wm1YNSrTob9W5VNPA38HVv/k6LxUe96COGHHCY161w=; b=YuSWJTLFUXEM+r0AjhXqIhp+SCZVqTb+xlFPewkRho/AsiiCNMQflCthVsvGTRoqeH KXaz+9xY0ACS9jK505E3vrZ7W7g9f5czxoxiMfUfFnrm3XYGFEb8mwX4jMWJ2V9B7gzF K4VkbxjRY8oNzWEr5qbZprhvvCCkM4FefsSeShMpQtrPg/n/256co2dcUsUjvWXUOa6f 0LWvZRHasghu/xhNGdc7znsqmOHWfCVb4GEbYOtsNdzrxWIfBFsLeoEs8Y1WujXLLHiw A2rUYBzN8pUIXH80QpvGcmnZlBVMQYa6YkfKPGW8h4FoB7WZJtBB0EcdAfsgHL7p3Ow8 BnpQ== X-Gm-Message-State: APjAAAVc24HPzFNvdOCWnv6BREAtGMvk9VVszML6lwg7VVnt6PyIZo8s VgllYpySI+64BKzqQgjIJ5EQDNu9 X-Google-Smtp-Source: APXvYqzUrmONQ+8hhQE0/fVsVs9ymd4Sk37dNFmBesDoEUank1GzRxH6yMZXs9ZMZsdhWdJL4ABomw== X-Received: by 2002:a5d:4a45:: with SMTP id v5mr3368543wrs.288.1573655951866; Wed, 13 Nov 2019 06:39:11 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 05/16] vl: introduce object_parse_property_opt Date: Wed, 13 Nov 2019 15:38:54 +0100 Message-Id: <1573655945-14912-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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, armbru@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 --- vl.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/vl.c b/vl.c index dbc99d7..b93217d 100644 --- a/vl.c +++ b/vl.c @@ -2617,27 +2617,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); @@ -2647,6 +2637,24 @@ 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) +{ + char *qom_name =3D g_strdup(name); + char *p; + int r; + + for (p =3D qom_name; *p; p++) { + if (*p =3D=3D '_') { + *p =3D '-'; + } + } + + r =3D object_parse_property_opt(opaque, name, value, "type", errp); + g_free(qom_name); + return r; +} =20 /* * Initial object creation happens before all other --=20 1.8.3.1 From nobody Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656241; cv=none; d=zoho.com; s=zohoarc; b=ne60/pkBzDwcImGQYX9/Q+VuEx3Gza8xq/LWrqlRzHZQ5ggtxMGXYK5Kecz8ygmGO1iiyXJqVoVYhXs8aApL7dY8Y4TBCxZNBRwXqVlbsKDjMc3je6vFeX3ldizf9ommnyZCPIt1dQ07/I3Vxb3Pkh/Kq6wJB/k4VDTvFoD6ggk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656241; 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=Na0X6tD4ZljnoxlrSDpoo7TALwUaYoZx+hQdqFyPXBw=; b=lBgH9BKy+C6zoTDYnxp805SQpfumu+7Lh+iHRUKIo5hI4F3NdDWr9d7Fdpys+kIfvtpBq9mH0wh+j0JELafFcjtlV/A8Jqwmrcp3D56v4gA5SCmmpXK6ESne1FB5HVDXyNOO5tn2NrOpjjhWnUOCLJ7LYnxhI7EIlVMT3DHqhls= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1573656241061346.6819542143652; Wed, 13 Nov 2019 06:44:01 -0800 (PST) Received: from localhost ([::1]:45680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtsF-00031J-Fy for importer@patchew.org; Wed, 13 Nov 2019 09:43:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54514) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtnf-0005mB-SD for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtne-0006K4-8D for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:15 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:35732) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtne-0006Jf-0w for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:14 -0500 Received: by mail-wr1-x42f.google.com with SMTP id s5so2661129wrw.2 for ; Wed, 13 Nov 2019 06:39:13 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:12 -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=Na0X6tD4ZljnoxlrSDpoo7TALwUaYoZx+hQdqFyPXBw=; b=upyJIbbJgtqHoBCNVXlzbW5HD2N2Q0jIgByquHlV1B+k1WiZdz3Z3xn66KsFcgzMd4 gn4XYDNL9pu0LDNsSmLepJSuYq/HGwMYLKjf1LOAJqTKkb8uJTCI+vxL9dVl7N/8701N +vZDMhPsCo/jWj2SeHtGvAXE4eRwfqpp/+yntQeuFNWF7QubKWLSWDtWpjFODFBLmm5I 9fUxhpuGbN7JHCm1g80xOasIAyCNJRO9YKkIMvtoBnaTGsFfBDyM9xaE0CPZV0u5wmgr KMU7EIcOohCl8Bio3f9TzStefbytdM0AdmD9dT1sCXiwGqB76k0XXhHonnytEJTWlK0K 9tiA== 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=Na0X6tD4ZljnoxlrSDpoo7TALwUaYoZx+hQdqFyPXBw=; b=COzqY8RLhGfch63KNl8KfP34hIqrbs1oscJr2E+34vOhannePUiHMxmFeWZ7WUlQVC k2EJa2xu7KQS81bS2IZGpQziCkSbUmAH6LiE6c4QbjsROdniAeaAu56FyD+g2HwCPyAt JiJSCtdjrDyTQAaO8lJQxkxE1HqVEldj46vJrY+hppCfTPb+0LYRFDn6o7OunyLpIleo tv+EG5JCHtpmNCzyMeuClQPA0LcLNEb3RZ9u8idqfeTT9p5nCCDZYDZW/Pj86JVOdZok 8YMfT9a3a+/UFs2JJETeMWB8rm4c4GoSK9roWPfUPJX61kiPBQXsjwUcaEKjTDGwxQx1 zD9w== X-Gm-Message-State: APjAAAVJy2Ed8BW5FGkm65BBslSdcWr62RPyMgIx8fIICTZKYL2G6ghL Zsj4gR71ETAvo9ZQ3RwjfrZ+1Zik X-Google-Smtp-Source: APXvYqya0qtv7PNmHngS7cmFYAVcWFcrNzyk9qJREnNmNVVHyEqpmYYIOGBZyLmplb9y4hxosqF1XA== X-Received: by 2002:adf:f18e:: with SMTP id h14mr3300376wro.348.1573655952596; Wed, 13 Nov 2019 06:39:12 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 06/16] vl: configure accelerators from -accel options Date: Wed, 13 Nov 2019 15:38:55 +0100 Message-Id: <1573655945-14912-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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::42f 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, armbru@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 b93217d..dd895db 100644 --- a/vl.c +++ b/vl.c @@ -293,7 +293,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", @@ -2651,6 +2650,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; + } + r =3D object_parse_property_opt(opaque, name, value, "type", errp); g_free(qom_name); return r; @@ -2843,74 +2847,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); @@ -3618,9 +3636,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 Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656076; cv=none; d=zoho.com; s=zohoarc; b=Zd4Y62CxS8ka6BrELE0rnUCxgG/eGWUXhnvbldSZoZFKatDneS1tFBCuRtLwxu1wkyRon3wXvgIVlzCLyE8VYAKpYrgu89HHHX5NDyuwwmuCviapbnO8hKiMQOwJxXAPxaNYgKk0GrZCRtarAXt06kZDXv5/XY+faxon8RdreJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656076; 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=04DgeNC9vfzASWfCYcrOuTaV0nl4hE4YtksZoBBJzpM=; b=Es5lKACHSA9PcItI/wj8xn2+prYJJuB1jTOXqK745BpG0/25kVPzavsCkXHMSWjckZhws87VGTJy0ogvDm+f9T3dekpBNaGICRUgbWL29IUOGks3wBgahlmUi2ZMCFujUWYJFUfNHfaTXHT+evCwn1ibUwetmKdlvRUgyjy8oCQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1573656076081361.1107255565249; Wed, 13 Nov 2019 06:41:16 -0800 (PST) Received: from localhost ([::1]:45640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtpX-0007jv-Ra for importer@patchew.org; Wed, 13 Nov 2019 09:41:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54511) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtnf-0005m1-OG for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtne-0006KH-Jv for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:15 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:35908) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtne-0006Jt-Dj for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:14 -0500 Received: by mail-wr1-x441.google.com with SMTP id r10so2659016wrx.3 for ; Wed, 13 Nov 2019 06:39:14 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:12 -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=04DgeNC9vfzASWfCYcrOuTaV0nl4hE4YtksZoBBJzpM=; b=mFgVDQT0R2WoA2hwT/zTC4fqohWKyBeYrk+M9RZ8g8/ggUav/aBzcVRDWXMnMGr8Tv pqLOMzepX+E2hDjvoh/T7oXyPIl3f7tkE5//gNauYYyhSy1etsVVlHF2YwzHNg2+zcMF iRlVNwHmiHqKP7GRaVJ7uRL6FoHYZ/kDhtzGR/HrTi2Newr80Eb1whTByOefV4icYadT EEraEB5e/15S1xeYPUnVT9DamTA8m8ApoGVKNUHOoWhUXRJ8hlqfsuc8zmQ9KuHt4I8p /qNBHySWE3ZkTkAkqKb7nJGB+R/dUu99orFznU2cB0Nve6n0Se07I68aYVikEDf8zwnz 9Z2A== 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=04DgeNC9vfzASWfCYcrOuTaV0nl4hE4YtksZoBBJzpM=; b=AzkYQXGk1EQcozzJ2ziiHDFCVpNFIJi7sCrdKz/v+Uhlk1gUPJ033GNLiyDRONLhfA HHtFFrVZTPpowDgNmrEkkwL0PUe+kIUuIqu9FyETJP5wAeuNlDmg/+jFbh8UxEl9NO7R hMlJhU+cxmfj34gulKSL5xwaU55MjhlbTSIAMhfic/U2TSGSv+GB67rxxvfClvQnMyWP Qcrxnfn4C6tkrHcpP9BWVBsMvsZKLzxbvcaDmbgbn6OE5wLCCFRXt/Dc08FD3yGo8OFh Kx3f2jWR2S63JW2FwtFbLbMdZBNZGk6SwMf7bkZdxlY8/DDdstFUKd/GwSYwuVTlwa39 18Pg== X-Gm-Message-State: APjAAAWcdQBF6XGzkbMrRdgOrj0NLEPRpjlT+Wo0NnBKTs76tqpwhOpT s9uw3QOrjE6lXaAugR/tIIs/wCgA X-Google-Smtp-Source: APXvYqzkbdvF6nahA7MzSMxfnYw7Ty4nmru8yvnOHdhpihtJz7hNUa8rB6FNoc01SXiWvwJHziPkxw== X-Received: by 2002:a5d:4810:: with SMTP id l16mr3010699wrq.127.1573655953255; Wed, 13 Nov 2019 06:39:13 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 07/16] vl: warn for unavailable accelerators, clarify messages Date: Wed, 13 Nov 2019 15:38:56 +0100 Message-Id: <1573655945-14912-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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, armbru@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" 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. Signed-off-by: Paolo Bonzini Reviewed-by: Marc-Andr=C3=A9 Lureau --- vl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vl.c b/vl.c index dd895db..843b263 100644 --- a/vl.c +++ b/vl.c @@ -2853,6 +2853,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); @@ -2907,6 +2909,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 { @@ -2926,7 +2931,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 Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656480; cv=none; d=zoho.com; s=zohoarc; b=oO5IzeWLYw5DxbPYI5K7gGPQqQS/iTUl5GkcLJGgYWgUEPP59/BxffrRPNQkKAoHGyCLUZ4v9jQ072m4cope+JpzU4ye2zzmkdCwHKiXCVxX1abP01IEZrNiBnXcUGyzOrntMlqZq36UhmsvuerGVYsdbJnScHMdLoVkFthyAp0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656480; 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=cIfZoKMkbTbdhoYje0A8wEbwWm6iqWmZiic8eSGDlZA=; b=E7nYe4lqCno0vdqZdPQXZT489hV1wJyQYx7OOLjPhBZ2lTdulgAO2Nkp2KTBA09hfRWSdnsl+ZrFlM2b2WSeAvpQdLJFi+thuDGbYXjmdF60gXquoY0vpHCa0M6azU6UPwLEIJa0KHDrtykMPZrLSRBnSOb/C8qJH/CZppvnRgY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1573656480084177.03378564098057; Wed, 13 Nov 2019 06:48:00 -0800 (PST) Received: from localhost ([::1]:45728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtw3-0007XW-6f for importer@patchew.org; Wed, 13 Nov 2019 09:47:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54537) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtnh-0005pK-Im for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtng-0006Kw-A3 for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:17 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:38344) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtng-0006Ke-26 for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:16 -0500 Received: by mail-wr1-x444.google.com with SMTP id i12so2648269wro.5 for ; Wed, 13 Nov 2019 06:39:16 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:13 -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=cIfZoKMkbTbdhoYje0A8wEbwWm6iqWmZiic8eSGDlZA=; b=QCS/BAheEgIiJ/pn0fdSoGjEWMUcqw1/81Df3vGJxN8iLKCn3uPm20N5Kk0ruRJDBy YsDtWVWjzHG6qWd9oEek/Fxu2O2dtkHWGvBFtSZJNdipdPEWFFH1gq2zeQUIZSh1JWA/ yi1SnLFDLU64YUBU82n+qK8EPDTllIv7HdkBWv3iSv3PgN8tRHdcgZsZuOwgDe6KWpPj vtkWg46mdpHccuQ+BhOaEWCF196e+dr8hZZ0ULCJ2ZrEE/k0qGRoyWkF50VBR/xoWBBn FSJw4JdSylnYjso67r9TBGrmnDCwnCGmR/yaKVOaL8V5q4A/UQBpzGcsG5ipaU3c3ZEo z/JA== 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=cIfZoKMkbTbdhoYje0A8wEbwWm6iqWmZiic8eSGDlZA=; b=tbQgHvXYzKBQuh8zMz1cnX4SihgGvzQem1zRaBbD/CFfZz5YGsJrAlZv4TaItTI2B9 sYix2RbcwucWIZ2DllotgPqcjFEVkJyb43SHWXcKJh6quvFD3oJf8H8/MlYWFUr54hMi nRXbDj/ShrWn+RGqSKPA8/eG4dqj2iwhI231aTjooYkp629hZJBjhYCO+3o8VVHpUMrx /NPbrw3aHKEAMIjvrS3BrikG/K/9200PeClb8P0c4RT/qr5FOtCGkFt4sVzIAIzrshRo 6sGckcdTlBDQSpgO33ZiOYu6kTf4OcSY7TbK5f74hXkdyEXFNbDt9DQkJqeSKj9uEPkP 2RZQ== X-Gm-Message-State: APjAAAWbAIyTEExA8roccKMVgAQgU2HYQ/EcXP4WUY17H2fPgTCDHp8f uI5DcUr9/A6W8//f8n08gbQUSO3N X-Google-Smtp-Source: APXvYqwAzcMj54Zgb/yKGGEvENL1FyL4ReJ86GIwaA9v8vPLPCgp2rOpbMHLL1fnV+IG3cmc+lfQTw== X-Received: by 2002:adf:9ec7:: with SMTP id b7mr3181836wrf.221.1573655954119; Wed, 13 Nov 2019 06:39:14 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 08/16] qom: introduce object_register_sugar_prop Date: Wed, 13 Nov 2019 15:38:57 +0100 Message-Id: <1573655945-14912-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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::444 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, armbru@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 --- 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 6fa9c61..c7825dd 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 843b263..cb993dd 100644 --- a/vl.c +++ b/vl.c @@ -896,13 +896,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 Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656593; cv=none; d=zoho.com; s=zohoarc; b=X+mOhFsFRFpBzi6mKEu4ayrObYn+xn2m3KLfP9jkKhV5/7Vw7Quyf9bTJrI9Kw8052TWR6M7f7I9ydXQdq8ogm8FAFgaCzXm5rCGYxxa4RjVoeB5xXpl0c5YarZtkNQRnWB3cW311yflDpeAlUcsybefr7mHbeBicUGRZlDBtZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656593; 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=WlKrofDa4j3N22AYaGt218mSvCaVNbM8UKHCQuejvbk=; b=MwYhjRfzLxa3o9Xc6LWNQgwIQqsQQR6/hQxlbB4HUflp3er9/y71KuPumgawURuXfG6uYcJUc5CT+oc6Un1HozK+VcmIoa13JtCg+Mp2p3kcQ05OgBulUsexlDJBTvsbMaJ7m7Qz3UZO64AmeHnk5rQNIlXiHO5GnJvCH4ZaYWs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1573656593815984.1640612601749; Wed, 13 Nov 2019 06:49:53 -0800 (PST) Received: from localhost ([::1]:45752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtxw-0000vd-6M for importer@patchew.org; Wed, 13 Nov 2019 09:49:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54542) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtnh-0005q7-VC for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtng-0006L2-Jp for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:17 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:37638) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtng-0006Kn-Dd for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:16 -0500 Received: by mail-wm1-x342.google.com with SMTP id b17so2280425wmj.2 for ; Wed, 13 Nov 2019 06:39:16 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:14 -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=WlKrofDa4j3N22AYaGt218mSvCaVNbM8UKHCQuejvbk=; b=oEmLid5CyqiWpYA7YnLFodz5JRkBBt6E2FSEOuJlUIwaQYzuyPjU9cTsfNoSLn1EJn A30ii760z3VHk3SfbQB28jR0uwdAbRitOboycqF7qrsc3V2djwwuld3dI52wREzCQH/1 V6/YYEew5D28Q2+F7/ySFOp6Pk9S25d2050mhtexfxiJ+tktIXRF2s2TWi+D9INjRqvi OWK5n3fMqb8w+oUneo4w1QQA9tt7hTeHXHsvxisO/lVb7iohNy55F4dBSm8GFBITmAEr qCtHGOQwVouzEvdG0B5wPlrvFlgZmFULHRIN77Uo5F7X8RqGRFFOu/jtsZd2G2UWkYLq zl8A== 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=WlKrofDa4j3N22AYaGt218mSvCaVNbM8UKHCQuejvbk=; b=HwrfNtAMyXUlKR0hk8BvvGiMhLLZJk+zS5SYeUY3XesBY5dZRUvKnhVdgZku8u+gfI BLf+TUyuUK9LrFUbYE8RMCQl2W1kmH5LGy4k99SEPlPBcgHIvzuqrW4gvLisa84KW3lc co3heNB38v96OaeZp+4/0/pv/o4h0zoJeaGusyF2zFhlpVX8fZu6D4ByW5upyrwT49q8 lMYQ4VGjcR6KsFGuHC3drb0ImgqCHuCNU8MNmZ1Z3uhDJw2Y1lOS6WKut2a9Hg20mdbP fq/nfAWdjaCLKyVf0Nj5CbSLQd+DPgfn1tUtU0RsMwbZ3dIMZnjZ/pYyn43rcvqxFloP WIYQ== X-Gm-Message-State: APjAAAUnel/7itPhBqli/fiZYwgPyLFTlplV71DyN9hJJaEVCS4qtENr UEt8dPxC6mRzMMN6wNCeog3iVrtO X-Google-Smtp-Source: APXvYqzrqEoZm9SIpdGzJInDCEHXo5WV9uklireTeOJNgI+dKw3xVZ3G/ENSYKMbjiMNUU+eXibRCw== X-Received: by 2002:a1c:1fca:: with SMTP id f193mr2874305wmf.173.1573655955073; Wed, 13 Nov 2019 06:39:15 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 09/16] qom: add object_new_with_class Date: Wed, 13 Nov 2019 15:38:58 +0100 Message-Id: <1573655945-14912-10-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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, armbru@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 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. Signed-off-by: Paolo Bonzini Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/qom/object.h | 12 ++++++++++++ qom/object.c | 5 +++++ target/i386/cpu.c | 8 ++++---- target/s390x/cpu_models.c | 4 ++-- vl.c | 3 +-- 5 files changed, 24 insertions(+), 8 deletions(-) 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 c7825dd..ee7708e 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 a624163..4742a0e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3881,7 +3881,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) { @@ -3952,7 +3952,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; @@ -4333,7 +4333,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) { @@ -5177,7 +5177,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 cb993dd..6e406d4 100644 --- a/vl.c +++ b/vl.c @@ -3988,8 +3988,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 Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656452; cv=none; d=zoho.com; s=zohoarc; b=nrqi4vPTiBe/5sUv4O7Cg5JAijs2OOSIsHijAk8GAJoHpQIYKmcAyvxooZlPkHOScxkh7dqt+clCc94dNjIiajrqmvr5T/Kcjz4dKFhGN0LYxNkORkWoGxuh21EXQ7C/icKp2S+5Y4t0C4tB5+E4PVvc7x1HPs36o1GLyi1EsTE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656452; 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=pQu82Uaslki9sDRmDSEOZxkk8VrP+Tw6ygHKYigroK8=; b=TkENImIISz8Id4KPHNgA+BjebKbDdhXIqMetR8GGuULbMiYbqFI+w8pjdUyZWmWusGntGbPm+Q5Govry9awE+YLZRv9tlSsV/DqOp6ABvheCukO+Fhnox8wLzMQT2JEerMzIWPrtpIV2cj1NPWvy+jOTHJ3BZEl6+X9GWNc/ilA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1573656452842528.9335887548531; Wed, 13 Nov 2019 06:47:32 -0800 (PST) Received: from localhost ([::1]:45718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtvf-0007BG-4Q for importer@patchew.org; Wed, 13 Nov 2019 09:47:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54555) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtni-0005ro-TV for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtnh-0006LM-Ll for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:18 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:53331) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtnh-0006L7-FL for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:17 -0500 Received: by mail-wm1-x32a.google.com with SMTP id u18so2263335wmc.3 for ; Wed, 13 Nov 2019 06:39:17 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:15 -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=pQu82Uaslki9sDRmDSEOZxkk8VrP+Tw6ygHKYigroK8=; b=PZgtqet8mzO3nGNaugWE73kPl8iRDG/esg7WFCgCdi76+ckXLd2MwTUO+7hDSG8iD/ lDx+K1FrRpYVsogjZWbEg38ERtyNCLCJ1zs0vJlAB6WelSdT8Bcny8+poI0BuFaRCkjL fiL5GWsDL3vNYnMqmC7LqyPbBBy4g43iQVzVxjfRnTDFKKfckNecQTo92WfJQyhOpHaG YecI6AfJRDWVcgfeLW1UlmG8ib0KhcMki70ZXImTSbYlY6cKqNqEPRVlw2CJoT3P/nb/ t2E/6UR5GdeOtJ6cGNAWOHqeKcJSvvofnGoU0fej5dSY33bZI1zyPuRAmw31+XdKwdyN 1Obg== 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=pQu82Uaslki9sDRmDSEOZxkk8VrP+Tw6ygHKYigroK8=; b=ZlNzEw0IMeg5Bn/Om15uXrH6OxuMoyugeTev6gqPX/EwWZx1KASujXc8ugRRpmGzAP NLgwPeemvLd/MkRMS+uLyH11630MwooaNeUlGRn9bngPQDNzkXlih7RIRkjh+ubdRiPB v4CBP0/vvY4PX8V2hj15bdCkPkW6aQnD9r19D5aYlcJA6l/RmnAoML3/KbUL7t/6OGTN ZZFR4LLaEJch601zt5wkYjx/QnNn8DzxtGqaNmgYbmsz7G+iNS2c3zov5sqKgkzTaN8N vIVtt/7dVVLZn0XsxhF4CixpoXCIfpntTNsoAY8Wd2Nu1tBcVReEdXLZ/pSsK4EBrvCq U56g== X-Gm-Message-State: APjAAAXNVIEsMIYZqNOHxT5EZ6vH71vRlGS+GpM3eRpYGq4JkLTJBb2t yVPoNwAglpPZLVNWDRi/MNGtm90x X-Google-Smtp-Source: APXvYqxdivET+mj2LzU/MpeGr0KuGjnoFF3cIxLRZpJTT1yPpIwUnMenw9yVkGeAyASutRZraGwMNw== X-Received: by 2002:a1c:96d5:: with SMTP id y204mr2993846wmd.63.1573655956177; Wed, 13 Nov 2019 06:39:16 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 10/16] accel: pass object to accel_init_machine Date: Wed, 13 Nov 2019 15:38:59 +0100 Message-Id: <1573655945-14912-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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::32a 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, armbru@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 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 insert the iteration between object_new_with_class and accel_init_machine. Signed-off-by: Paolo Bonzini Reviewed-by: Marc-Andr=C3=A9 Lureau --- accel/accel.c | 6 ++---- include/sysemu/accel.h | 2 +- vl.c | 4 +++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/accel/accel.c b/accel/accel.c index 74eda68..822e945 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -52,11 +52,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) { - ObjectClass *oc =3D OBJECT_CLASS(acc); - const char *cname =3D object_class_get_name(oc); - AccelState *accel =3D ACCEL(object_new(cname)); + 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 6e406d4..c8ec906 100644 --- a/vl.c +++ b/vl.c @@ -2846,6 +2846,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) { @@ -2853,7 +2854,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 Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656645; cv=none; d=zoho.com; s=zohoarc; b=PORL5cgcI1Fr5M0l0PiL7+a8hD+4CT6lZ5vKAGgy8p8qsPUnzHKnk0QJ8SCQkOD1zEhin4LrJqj9poveyjuvm6pbYdV5iHVamyslJJrfsQBpf3AbAHPzG7VVqQMoogaEkl+GDbZ0Drh4Yxn4LEI8w013F75boSiUcCLOxyJKekM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656645; 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=Y+16lVLuNcBNpTOJq/xCtuQdbLbwB1u4ci4+zWS4pdw=; b=cKs9Xf/Aya/74cxsNWsMiDrC0jFo8bUEWtwCF6+Qx8vOvCrvrIE6Isf+LFgtDjLE73osk5HVIUUBeD8YjOmE+6M1N1RDVFGUgo/rtJDqoQy9oChYOLvY79IG2aWdinoiiNczKTEvwV3ANLabUe5pwiGvY4YUA1SG3/LwYPgkWDQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1573656645224336.066673582289; Wed, 13 Nov 2019 06:50:45 -0800 (PST) Received: from localhost ([::1]:45758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtyl-00023C-Ji for importer@patchew.org; Wed, 13 Nov 2019 09:50:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54575) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtnl-0005wJ-FW for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtnj-0006M3-Lb for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:21 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:54749) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtnj-0006Li-EU for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:19 -0500 Received: by mail-wm1-x342.google.com with SMTP id z26so2251302wmi.4 for ; Wed, 13 Nov 2019 06:39:19 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:16 -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=Y+16lVLuNcBNpTOJq/xCtuQdbLbwB1u4ci4+zWS4pdw=; b=MYixFIYjArAN4hDypeka4NMayAR15LwczewDBWt0t+x98jWLFupXWBQv6VCgVm8aRF kAxX5WysQXyNYtHJgqq4CsQdNTLEphjwGyuCgLwv2dVE3SAFWL9vonUUALv+bOr3ATwi U9dWYpmFlKhYkJCU4lYZOm2lLIojFZDbD/SyKmpNwGzn+sdxVAApwSHvNLb+PsnroOyO ZFImwUFUfQAIHOsHKlleUqN1ENAnKpM+OMo7k8CY/TZ1DaEc1pOyDnl7IjpgQ7LKp71e wFlLdhzYGBEjoyfdhg7eToWdG6O41op05PS+HYIoiy3T75MD08kliw8++nFr6cUi0uxk NPEQ== 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=Y+16lVLuNcBNpTOJq/xCtuQdbLbwB1u4ci4+zWS4pdw=; b=UyJpWQmU7rSUIFeuYvw/BJsAozLz4hxcYq/A9XFW7CyDdoBkO8x8oBAp8xM9tdZ9pL ygZvR+7EcX04V1rHFcHrztlL+eatm8UJLRc+nQ90braLWqAe3GCGplUkDptGgn1tAmwy HvNYbqhch9L0rYiPZrAKKSrP83k0eSpaHdAUIsqtSa1z7KT5f94gtEHnE7yUM+KII7ic /cwF5bBFC6Xd8V2tpz4uRI4z0l0/sRsVtiT38om4Q3BpraPsQxRdFR2S0I+KbWywQnvE HjMIDJ4v8z5GbyoqqaNx+cfgXOYjpiDcPda6GavALYNqw/VgRiAcom4gVd35fovpI2Re tCBQ== X-Gm-Message-State: APjAAAU+qW4H+TTpfMJF0vmlLazn/66bQ99OAKgw0wL/ihAjtbCno448 p5JfzlhHuqkfreQGKhkVBQzymC81 X-Google-Smtp-Source: APXvYqwv2S71mFbxxTNOzi3H25bI8Y1JX/i3hMuVEEDndOqFqc26A4P7EXU4zwMPNt4nrlEGGrnDUg== X-Received: by 2002:a1c:7209:: with SMTP id n9mr2735545wmc.9.1573655957158; Wed, 13 Nov 2019 06:39:17 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 11/16] tcg: convert "-accel threads" to a QOM property Date: Wed, 13 Nov 2019 15:39:00 +0100 Message-Id: <1573655945-14912-12-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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, armbru@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" Replace the ad-hoc qemu_tcg_configure with generic code invoking QOM property getters and setters. This will be extended in the next patches, which will turn accelerator-related "-machine" options into QOM properties as well. Signed-off-by: Paolo Bonzini Reviewed-by: Marc-Andr=C3=A9 Lureau --- accel/tcg/tcg-all.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++= +++- cpus.c | 72 -------------------------------- include/sysemu/cpus.h | 2 - vl.c | 32 ++++++++------- 4 files changed, 126 insertions(+), 91 deletions(-) diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index c59d5b0..7829f02 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -30,6 +30,21 @@ #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" + +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 @@ -58,27 +73,119 @@ static void tcg_handle_interrupt(CPUState *cpu, int ma= sk) } } =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); + + s->mttcg_enabled =3D default_mttcg_enabled(); +} + 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 +static char *tcg_get_thread(Object *obj, Error **errp) +{ + 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) { + 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"); + } + s->mttcg_enabled =3D true; + } + } else if (strcmp(value, "single") =3D=3D 0) { + s->mttcg_enabled =3D false; + } else { + error_setg(errp, "Invalid 'thread' setting %s", value); + } +} + static void tcg_accel_class_init(ObjectClass *oc, void *data) { AccelClass *ac =3D ACCEL_CLASS(oc); 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/cpus.c b/cpus.c index fabbeca..69d4f6a 100644 --- a/cpus.c +++ b/cpus.c @@ -165,78 +165,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 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 c8ec906..2ea94c7 100644 --- a/vl.c +++ b/vl.c @@ -294,17 +294,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 @@ -2841,6 +2836,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; @@ -2855,6 +2857,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; @@ -2862,10 +2868,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 Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656725; cv=none; d=zoho.com; s=zohoarc; b=bFYfSDOFjFF8b9celMDHicXAAJ3F3t7zYjguSHBo12aYeNkv4Zcf4NRgpEIhQsOJlnQDtygcEiDhR0x2VGHeO98rc0MvlRMwRvrP6QxLbQMNM9LOSp3yB+0phcxBR0yxkKfGU3giqKDozCiOPfjKfBkAuxK9ExdoeT2hukN6fI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656725; 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=WMkY/N7ZGoVwQ6hEN+rLJ67VQGFFDvx1r2Y94rAjGB8=; b=k0vz4Qod+BNN1gs8ket0bnvt8tLK9weLJCh6it6d9gM8CrMFD5HfaJ6gazTC+SWRmO1BT2AscPIibTX+Xebj+zNjRewRGB7rN5YhDPlLD5JvALuuFMFNVKwI1ZFmf3Hp4BtUrlQtR1MH9K7twhPk08Q0WEflp0haGth5klLE4Vw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1573656725784209.23125722480552; Wed, 13 Nov 2019 06:52:05 -0800 (PST) Received: from localhost ([::1]:45814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUu04-00044p-Jc for importer@patchew.org; Wed, 13 Nov 2019 09:52:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54572) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtnl-0005vj-6w for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtnj-0006Lx-Gn for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:21 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:38467) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtnj-0006LZ-A0 for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:19 -0500 Received: by mail-wr1-x429.google.com with SMTP id i12so2648466wro.5 for ; Wed, 13 Nov 2019 06:39:19 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:17 -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=WMkY/N7ZGoVwQ6hEN+rLJ67VQGFFDvx1r2Y94rAjGB8=; b=ODHF6XW2I0qGDs8TYRVugRrz6B7UMTYs7DGFqHj9PNNJlLvXC/aEGMXwhwWmL827zn RbENAty7l1dMKMdUdQsv3pY7ZHXZfoYhqx1EqNRUzGE+XH28dLXCTU5Lz+/Z10fGPWxp Bc8rTUWBxRsNfvJwOnZEdYFnk9hEckRSSfnwEbeYWBH5eEQRA9YNWxKrTBXMdWDhXKLk EqkQoklveb0CDArtuJRJy0WF9x2XbEjAevZEiaGs11dPS8WmgPZMwstlNrx2mzWNMKAf aMkQJLrKbi6X18LHr9s4Z9S9fX4Sqwp6KMWA4swm2MW697Lb2DBYSlebZkVMsdyqlMus 2RCw== 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=WMkY/N7ZGoVwQ6hEN+rLJ67VQGFFDvx1r2Y94rAjGB8=; b=O9OX+q8b0tQtW0hwJ9MOFre73raMGBeB2Wm5TK4REX8pSQhvqU2O+pOHgLvKo4m/CQ xaa45mT3Rgb4F0QxrrardHb8ik6gv+LQFRrNtlzTSdT6MRpLfsyjNIJqrdCiUGfaoxIf w0bWYZUL1siSorI0RVLHmeVbNvI0oMCv+qC2nAHWVF+EpiZYGkzisIfSrzvviMZ2uRQ1 pf/vIDN0PE7YjS/YdbRSiyNJ+y8oOVuWLJGoVcqLU5+4HZOCJ4ROOgcuaIOCHCCtsIYQ WL0zbmf2Oxe/KUL5LT0mt/P2uEwtc0dwoKBmL0Z9bInnlq0u7IOFwBCbNtNQM1/2yDKp AqaA== X-Gm-Message-State: APjAAAWUu3tLgoQ3A0FczZh2QtZg6YufAx5hIJZN6m1gdU+3gKMQOxyI DO0tTC9J002+//vnK5I463T0gDxd X-Google-Smtp-Source: APXvYqwS9/CRyYh5LlOtdae5q503rYEbhjBK0ZZT5LIt6fvfkbdV3fN3V5fynyRz5clxtLK20WMQPQ== X-Received: by 2002:a05:6000:1612:: with SMTP id u18mr1257782wrb.306.1573655957925; Wed, 13 Nov 2019 06:39:17 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 12/16] tcg: add "-accel tcg,tb-size" and deprecate "-tb-size" Date: Wed, 13 Nov 2019 15:39:01 +0100 Message-Id: <1573655945-14912-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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::429 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, armbru@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 the old version. Signed-off-by: Paolo Bonzini --- accel/tcg/tcg-all.c | 40 +++++++++++++++++++++++++++++++++++++--- include/sysemu/accel.h | 2 -- qemu-deprecated.texi | 6 ++++++ qemu-options.hx | 6 +++++- vl.c | 8 ++++---- 5 files changed, 52 insertions(+), 10 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 7239e09..6ca5f80 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 query-block result field dirty-bitmaps[i].status (since 4.0) diff --git a/qemu-options.hx b/qemu-options.hx index b95bf9f..3931f90 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -120,6 +120,7 @@ ETEXI DEF("accel", HAS_ARG, QEMU_OPTION_accel, "-accel [accel=3D]accelerator[,thread=3Dsingle|multi]\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 @@ -3995,7 +3998,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 2ea94c7..06c6ad9 100644 --- a/vl.c +++ b/vl.c @@ -2857,6 +2857,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); @@ -2868,6 +2869,7 @@ static int do_configure_accelerator(void *opaque, Qem= uOpts *opts, Error **errp) acc, strerror(-ret)); return 0; } + return 1; } =20 @@ -3747,10 +3749,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 Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656799; cv=none; d=zoho.com; s=zohoarc; b=D1Oa/T2FZNiFbubVMQsOrQr7SHxn8eJXry+b+d5OePOBHG9Q8ZuO1F1nrE/tN4yMUGkhA4qDJQYT4a3P/cdD73TXtNvMkdKqyDT9Q0rdcC7qbr5Qj2M2TkM3T2wWzGIgJQCJwql9bXp//t0z3cNTZQlCwMT8K/uhWNn2qKwLp5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656799; 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=ULr1B88jivXzON/4AKL4KiqnRt3/UYg4HZ/1tAz45Yc=; b=Dbnmd0/IQ0OCjZoL7CvFT6rqs4PqBT/W//TnA/2HmmAJG3spVddSn5vxoTd3inVE2iQpHg0HTlvyItWf+YEQsNbambQ080/SQTka0L3TfXUAYFVk8j/sjIHSGrx+/fmj42HexsWN/ix2xtPqbU6xgTtMbO27QF/LmBj/8Ajle/E= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1573656799646897.8262453016807; Wed, 13 Nov 2019 06:53:19 -0800 (PST) Received: from localhost ([::1]:45866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUu1E-0005lB-O3 for importer@patchew.org; Wed, 13 Nov 2019 09:53:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54585) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtnm-0005xq-Cs for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtnk-0006MF-NC for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:22 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:55764) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtnk-0006MB-Gm for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:20 -0500 Received: by mail-wm1-x344.google.com with SMTP id b11so2251772wmb.5 for ; Wed, 13 Nov 2019 06:39:20 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:18 -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=ULr1B88jivXzON/4AKL4KiqnRt3/UYg4HZ/1tAz45Yc=; b=GNR9J2DTrfJiHkoRzNc5hkVnZVwBpXY7KA9uFMIdVPuMkqhczZ3QIzNhumhA3NlMtW O3a5E7AwjojSg4H8LB9dutY39Zz9lFqBQV8AriI6qDd5Ngn59zQhmNxgY8mfuvlKvydB ja5DYN8fucuvanRceqwFZLNL28Es7Me/f3BBGU7pSk2c0bbC3LrrGb1IuNNud+w3noOE hk5KU7zF3yEFpzPmZYD0OZgx9jeje5xIlkG60y+GaRNGlln5b550SOoq7e+MBomKBAvM CjbI9TCCWwWYQx09nGMlo8r60OYh2CmzGuc64xgALBI15nr0MFJOb5koHIYrCy8iOPYH 691g== 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=ULr1B88jivXzON/4AKL4KiqnRt3/UYg4HZ/1tAz45Yc=; b=hhEOSNWHyqxRtIgp8RU3eH/GujCf1YUeixOlL44/BcIIJ+rfnmXjl+zaVUFbcrYQOR P5HSOwROAM8W05JKd+fu0Y9Zi3rmman45nTdNG054QPnTMTobVovpbJR7xfuMIm+CEzs PQujkS+0EV25psFqyqWNfFMA7iQ5F+jUPeNRCVOy2B3Q4U4OjMH2IzfNNWVmWKnJXJrf dsjzjAPSnvWAu13JD9q4cxULl82GTbFa2ZANQ9wphvmfiBcOdqpd4GGZ/5qF3RmSaqLD W1AhA2T5FKvTrQ4qBxJ4fUTBA5wrKuU0JkfjcWmRwLL8qahu8tblihTGgTqSr1WjNSeb NjEg== X-Gm-Message-State: APjAAAXPAf2K3DGoTFlWVXcwO3R+I/FRyiFRkprKf7ffDSuP0fNvP8Or u1bMLKz870DD7NVe/u2uB+Jhb6kg X-Google-Smtp-Source: APXvYqy3bLdOAgl4z1iaCxKqubrOMFCyOUuaD55ryMBEw2//tET2W15bxZdM/tr4BPon+f5GZasApg== X-Received: by 2002:a1c:7d47:: with SMTP id y68mr3062538wmc.157.1573655958603; Wed, 13 Nov 2019 06:39:18 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 13/16] xen: convert "-machine igd-passthru" to an accelerator property Date: Wed, 13 Nov 2019 15:39:02 +0100 Message-Id: <1573655945-14912-14-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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::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, armbru@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 Reviewed-by: Thomas Huth --- hw/core/machine.c | 20 -------------------- hw/xen/xen-common.c | 16 ++++++++++++++++ include/hw/boards.h | 1 - qemu-options.hx | 9 +++++---- vl.c | 14 ++++---------- 5 files changed, 25 insertions(+), 35 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 3931f90..5b43a83 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 @@ -118,8 +115,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" + " 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 06c6ad9..7d8fed1 100644 --- a/vl.c +++ b/vl.c @@ -1256,13 +1256,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 @@ -2645,6 +2638,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 r =3D object_parse_property_opt(opaque, name, value, "type", errp); g_free(qom_name); @@ -4449,9 +4446,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 Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656859; cv=none; d=zoho.com; s=zohoarc; b=ktmfAdVIOOTy6ikOiVtZ/x+t0J3cjMGwwsC/pHrHzlN/z5TrdwWiDkTuX1esZFcD7DP/dlABxNvUXwSHfrxwbGybVYnNJvH0Y086INWm2Yne5/DzOrN4wBtOv2GMyA8tD8sTT2XPTmjD9kGReRqaQcxufmP+/oqkCwOcS1dNHgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656859; 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=PGYMUDTg2D6rpcuWlf2brnz7lYfBlkB5vPdneLDV4o0=; b=HfRR0Li1Ojv8f20ZelMOZF+S2WnO6CP/sKZGL/yOhWMAJJFhW1Y2thrwsSCTJpBfY5lLsxmuHGOdDVQRcmkFPhL3s6K5hagyP5v2t33rybvX7m5lW3UDN3YZS7nJe07PCMxePZx2n7RjUyE7XtVGgxW0r26QEcfpQUUO2gP1LIM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1573656859592927.5789666565398; Wed, 13 Nov 2019 06:54:19 -0800 (PST) Received: from localhost ([::1]:45916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUu2D-0006jx-Kp for importer@patchew.org; Wed, 13 Nov 2019 09:54:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54602) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtnn-0005zl-Dw for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtnl-0006Mx-LS for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:23 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:42081) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtnl-0006MJ-E4 for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:21 -0500 Received: by mail-wr1-x430.google.com with SMTP id a15so2631387wrf.9 for ; Wed, 13 Nov 2019 06:39:21 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:18 -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=PGYMUDTg2D6rpcuWlf2brnz7lYfBlkB5vPdneLDV4o0=; b=PwardcY/zM62i9zeajrD6uIul+k+z+dgZ0AqJ9h7QWp06UqYLNuircOpRpTM1JEoNW lEiQPYg05vpPSvTmTrL1qVNPJP/gqebIeEE0jp9yQelLhlRZrIjEwgIMTn01nB4syPDH nxZuY/u/z6NGswXz9AJbB8sn5q0cwhDEChgjedBw8JswHpTyTImiEL5dR33KWOMI/k+9 +W9nocjVD2NoXDg6NLyFCZTMwh5oZfWekWXAnGSjd39e18G7pqL7pDk82Usy9neS9c1X 1G0zXimDuT5aNtmJkVOlgTkx9Phs2InhzO1R8zw+qTi+GLd3T7tv3Yec8uFES4ZdWEJx 93Xg== 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=PGYMUDTg2D6rpcuWlf2brnz7lYfBlkB5vPdneLDV4o0=; b=bOgxuid+eH6D4r8iaCTdaKcI5njAANor067VmXunrSW/Dtta6P90tGyTLIoEKYpCU8 uDLtEdl4QrF2Cz0n3ptEavSwC/cJnF16v5uJNi0F78RFCYE0K1gKzoEXfLUH5C9B9Rl+ 7CoIhtRVN2rw0J6rI5nO5ZO7AicZcut3qkK4FWMnxfpm72pB/1jmH5N2+id2wP+XHIq2 PpeFmIXBapGrox7ojs0Li0/Z8vn9jL0/wfzQjWdSaJzK5pyV0IrGtyeMBRaCGDUuAgpL 3r4I0NaUZ8uNo8387cBgt/RCHdpYIdFJNa846Zyz+TcfDjERAW96rnKmiY7dGzEbPxab lusQ== X-Gm-Message-State: APjAAAU6lyfG6C5kUZBru549X6aV6WlexUZq5nm65Z2/NX6r512k9tSa CA7T5ui2g6LbOEisbMVGPiUq/EZb X-Google-Smtp-Source: APXvYqyPEY2SE8d+ZI00rGKDuA4QxAx6UABo0NsLw0p6sHSrisLxmPCALWuvd91mZgHlZXKeK4Y38g== X-Received: by 2002:adf:c50a:: with SMTP id q10mr3358769wrf.374.1573655959543; Wed, 13 Nov 2019 06:39:19 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 14/16] kvm: convert "-machine kvm_shadow_mem" to an accelerator property Date: Wed, 13 Nov 2019 15:39:03 +0100 Message-Id: <1573655945-14912-15-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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::430 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, armbru@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 --- 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 140b0bd..c016319 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 @@ -2922,6 +2924,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); @@ -2929,11 +2965,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 5b43a83..ae56eca 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 bfd09bd..7dc05c6 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -2159,7 +2159,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 7d8fed1..1d799b6 100644 --- a/vl.c +++ b/vl.c @@ -2642,6 +2642,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 r =3D object_parse_property_opt(opaque, name, value, "type", errp); g_free(qom_name); --=20 1.8.3.1 From nobody Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656747; cv=none; d=zoho.com; s=zohoarc; b=WAiNjC5Y0U+Mw9g/joFhl57mzVkiTipPeA+eUsjmbZBghf4QTxZrBVpAF5uXubgLwxfBbieyj05JD3dNT1dOXo+4FD+2XgE9LSOBWN2Af4QJdNS/QuW7V9XvzF43yGyROc48x9RG8mHEdKUYhbQPFqD/xQJRSSS7P0G7ZFmscLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656747; 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=KGzEFsoR5Ne9dc3BBeXqX8dzJn/ffqjieOFhjVDRthY=; b=VssB6jo/wnGlxo4MXxLgS5J2o6EhI0bW7kCwF1DkPfUf7xr+ZWcCxaWKAmE1QapM/pp0ttUVYNf1+8BzhAQ2jkpO5yd4zFWJwqWn/sYb+8ZvTl9cbY0FMip7gvch9v7y3yB3tIrqYoFJW38+Au08KtSMa+dLLtaqC1Wh4wZslas= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 15736567474191011.7712060698256; Wed, 13 Nov 2019 06:52:27 -0800 (PST) Received: from localhost ([::1]:45840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUu0Q-0004eE-9K for importer@patchew.org; Wed, 13 Nov 2019 09:52:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54610) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtno-00060c-02 for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtnm-0006NY-Ck for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:23 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:35619) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtnm-0006Mt-5f for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:22 -0500 Received: by mail-wm1-x344.google.com with SMTP id 8so2283473wmo.0 for ; Wed, 13 Nov 2019 06:39:22 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:19 -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=KGzEFsoR5Ne9dc3BBeXqX8dzJn/ffqjieOFhjVDRthY=; b=efW/GEOnrwhahfd4461bZXJaLHNXb1y0YfZIqa5msGDz/8eL2+9YAIpzbTFC6tLHY0 m6YQz3Jilil08mLM2e7/CvwIGNts8lh3qLGM1paA4DRmBMnSy7Lfq0Pnzzyd10R17TCP sqqywo5miSUhyeuQE1aT18EjgVL2OHVIe3Sf16hfyxdAVPyYPDi6MhaaxrX17mlVYHbH qIhPsV8TfVrTsGeSQylYF8FYLDUFDou/JR166XfmPkqg5TLWMacWC8oFwRaasmOnJWVf hpwHGKl7w6gWqV5mfedVPEBVsY5YQ0abG77NMD7a9EvBJR0hxnsSM70QSaTtTy0pTO68 5FuQ== 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=KGzEFsoR5Ne9dc3BBeXqX8dzJn/ffqjieOFhjVDRthY=; b=Q1MVpkr2sUEgw0pKfOvGLnsjLGzfri8EXA7EBD00j2A6gFpjaS22K1d5A+t6nFeg3J bZs+UFZ8SaPcW4oZI2+e88YA+y2f6WJa7chBo+nFJhTK+dTTLRnKFOaaxE6uF4rRSYkP ZG4vPDa1lm9PIRKDtjbV3CUjNjUv2U+LoTSg2liJq78wvBd/8Zc6jbZ+nrtpbwTDE1/u AnXShauAMk8p1/uAh46wOsEPL9NOWRUcSU4jyTpUM6u54vZf6d+yirJuErIc/zKuKFXe hJkdFjEK/9Znv+WYPQjorgYmXjHS8aZRNg3gSQaiztlIZ+kR0QebhxBCakFoOHZQr4xb iLWA== X-Gm-Message-State: APjAAAXleNXx6d8l9dEmsWHw0mnp/PAytEHEDloVmlxwKvYnqxjAqWaB qXL2CQMjYsCdwFhAPkKHxUq2w2Al X-Google-Smtp-Source: APXvYqyxflYY4ybjQHjeU+g3F3TG7P/JNRlSy903Rwk495iaL0nmgQs4bTQlhlstvwWE2tYqSYw1oA== X-Received: by 2002:a1c:6405:: with SMTP id y5mr3288827wmb.175.1573655960320; Wed, 13 Nov 2019 06:39:20 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 15/16] kvm: introduce kvm_kernel_irqchip_* functions Date: Wed, 13 Nov 2019 15:39:04 +0100 Message-Id: <1573655945-14912-16-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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::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, armbru@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: Thomas Huth --- 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 c016319..a1c3b78 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1742,7 +1742,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 @@ -1760,9 +1760,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 { @@ -2034,7 +2034,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) { @@ -2951,6 +2951,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 b941608..8b66eb9 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; @@ -276,12 +276,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 9d14328..46a9f18 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -514,10 +514,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. * @@ -525,7 +528,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 b473c63..d10383c 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -726,11 +726,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 7dc05c6..72bb215 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -4473,10 +4473,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 7d2e896..02face1 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 Wed May 15 14:46:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1573656678; cv=none; d=zoho.com; s=zohoarc; b=Bz5eznfL7T+YSs/LS7br+rundGQ6MVOcXpIRGLDCx0CROS2K6Dgegue1DCU8bQvWDTJj65EVt/NGh9hrDkjKTip4DGdLvx355uHSDwT85dikFO68JJssvvCeN41jNrIDWR473FO2Q5xcNrhI2PBLhf7ikV4J9+cIPGs+khWQ+bQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656678; 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=qFLsSUjwnZ5T0gnZBN4YkiTxK/NBsyMgO20lnXbmbDY=; b=l0B+0llycLRo7YfJn2OnPocCx+DV90bNes98Dh+A3cEgP+2le5BMfjALoZDIkm5LKBvoli2SGG55atQ1KCFq2SjZtq7es+ZwR1fcFLPgmPGhIDyR0KlU63bTtq4wIIKBGFmHknFRF/crVQb5ELyXn4q6M3r6nNFKbBMvQXAPC/Q= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1573656678371931.1590158754535; Wed, 13 Nov 2019 06:51:18 -0800 (PST) Received: from localhost ([::1]:45760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtzI-0002XX-Ra for importer@patchew.org; Wed, 13 Nov 2019 09:51:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54617) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtno-00061v-KJ for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtnm-0006O1-OC for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:24 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:47066) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtnm-0006N1-HW for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:22 -0500 Received: by mail-wr1-x443.google.com with SMTP id b3so2611651wrs.13 for ; Wed, 13 Nov 2019 06:39:22 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:20 -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=qFLsSUjwnZ5T0gnZBN4YkiTxK/NBsyMgO20lnXbmbDY=; b=Y0McW5qPX6IVng0KLkin9rTK2YCsfI9rT4cPbOvArDU7WR34rzRdy4Uw89wMScu95y Q7ItR78m/ypVab75C8ZJQi7dP35IC8Q8t6/IB73spkaDXTq+m01zY//RXXLl0wwZTqSS c3OjPjK65f/3q1G1PhE7kY+TnB8deQB58mNs1EuOMvwQuEi/aUMxBjAvyb6FtHoa97uR 2nOJClyKIE80x6oR/BuBZqodJGT1W+r5zX/VH2YKyEnpDmFPlM+J8jILrOFcZt03CiGX kujoDGyQD7RuwY0Gbed1+hs6Ix1+VLZLi8gH4Do7oC9ofWXmmiVMy+fOzouvH/m3JSBm ymHQ== 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=qFLsSUjwnZ5T0gnZBN4YkiTxK/NBsyMgO20lnXbmbDY=; b=tRgbnh7Xko0e5wbu/zuyu57IYr/5H7eg449TrLddU3panfjCSfQbJNegC/ZUoCs+w9 Frz743hELBtsy2b6OENqfR1nthcFmwn6tg5U+9THb+hBmuSn4evCzcQlAK/Rw+cFamWY ky1YQxnoib1FDsAqJcaKbyQSkz6AoUNtrIwMYJf/UuL6S0CWaCeMP+ZGOcfHDWqW0aXE tyShpH6gb5UimIM2Xh4tm7WofrEQ8vATnNs5bYiF+pKhCRsuvMzVq1PYgv92fXoxzlQY IlMY8Vvu7Ps+JVYNlkCIyiPY/GJybChWruu25JdZ7sQiqaCaIGi2V9Dze4krTC+QLKyp 5UyA== X-Gm-Message-State: APjAAAV7nUWkB0RRqod3KPDZDEu2ad2bM39xv0SKhBW9JQ2njsN0xDpV UD7TFPtXknvU8j0w/GzAIimz0x/G X-Google-Smtp-Source: APXvYqz0WclCtxV+GB9bT9fL/GqnnvxUmPn+fS8gGaObKlZ1/OluGChRAmWtKntd4pBj/psdsOOd5g== X-Received: by 2002:adf:f50b:: with SMTP id q11mr3131924wro.343.1573655961229; Wed, 13 Nov 2019 06:39:21 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 16/16] kvm: convert "-machine kernel_irqchip" to an accelerator property Date: Wed, 13 Nov 2019 15:39:05 +0100 Message-Id: <1573655945-14912-17-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-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, armbru@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 --- 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 a1c3b78..a0bb4f5 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 @@ -1762,7 +1767,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 { @@ -2033,7 +2038,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 @@ -2951,19 +2956,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) @@ -2981,6 +3024,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 ae56eca..7bb58a1 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 1d799b6..aaca7bf 100644 --- a/vl.c +++ b/vl.c @@ -2642,7 +2642,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