From nobody Sun May 5 23:45:33 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622819976; cv=none; d=zohomail.com; s=zohoarc; b=WWiBVksip64Spnq1gTm6CBC5fqf8VptJ8nhuvoWpJoEX99TgXhWKXYCqM1PJ6NAiEunAjItQJpeKRGx41mNHexXha9TF9F8J0YPbT9oxi2oTiB4neOeAB4O/K+SXdqvYAEVgwMJUI6noCIQFt3A6eRz0By4Qy9PrIVvUzkre5OU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622819976; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PjUTCXCnxwAcJKYCDMyAMuStN1x2DBiriMNfDrPFCPg=; b=N3oBWlkUBIyDHqEGyrkyujZGLQTgnDgGalZg+bKYNjuAMVDehI/UpWqaTA/uwJxTFpcSmGKGVuvKRARF0ZswetO+Lc7pnongox9P+KaYIedrc4o64N6SyviXoY6Gt19OB58HUGEXjGxz2PA7+jTfXrQyb5YhX71vk1cRN+1kZ0o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1622819976453612.7242647362257; Fri, 4 Jun 2021 08:19:36 -0700 (PDT) Received: from localhost ([::1]:52962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpBbj-000296-7w for importer2@patchew.org; Fri, 04 Jun 2021 11:19:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpBa5-0007mP-Q2 for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:53 -0400 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]:34721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpBa3-0008DS-82 for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:53 -0400 Received: by mail-ed1-x534.google.com with SMTP id cb9so11615262edb.1 for ; Fri, 04 Jun 2021 08:17:49 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id w1sm2402451eds.37.2021.06.04.08.17.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 08:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PjUTCXCnxwAcJKYCDMyAMuStN1x2DBiriMNfDrPFCPg=; b=LeSCSxgBbCM/8lxCi6h8l7Y53wIESzK0wpCe33YliSU9fdLsRZqoCfGCoMKQvvYj4w Odqa2FolQjmO+PFxOm4wOFiwHnpPiHYGRGk9DwQaijU/doR2i0F/mBoSgSyhOCNYD1S3 cE7eq7wgir5WDBR1LdUp+a+ifxugelWmmXSebxsALb0Qfq13badvUh4SUMYv3T/pRxgs nGg9AnDwD3iASavD5xFVmQRjlsVTOHXzaowX5croDyckpJIOSkQM7TFDwAG4dhH9dM3W VVLmSHznjrrqtkm+sXWzCRP97mK4HT48V7Zjx0VoQIjpOjpb9ci3Vo+SCMyUMZ4Fjdct /KLg== 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:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=PjUTCXCnxwAcJKYCDMyAMuStN1x2DBiriMNfDrPFCPg=; b=jFEw9b73/DePjHIGOJp18TWduBICWp3bxD8SKasJEcay0Xioo9swym9DW4Mfs0hZMF gx1L5PCIw+JmOLdtP4rmaQs7wUS9lJ3f+D4JffcD1bta5P35pqx0RSMLmJU3ch25lp5s ZW4WlRzH8hd0EnjJxAMwyWs+6c349S7IAa82G7zX0xt2mcUrR5w0L882DIcwaBG2xQ1x yUB5Or3P6KImJEhnqmVcun9SWfpWkRCzG/y0CwvVEgjZpD7JNVdo2SdY7pGh7Z3b8sT7 uB4SRyB0JnheD5iwVoQKjotIFEKwtN+3tyyv5rfwUQULF6e3GPRK3EHhIjYYX82Fr/V/ EGvA== X-Gm-Message-State: AOAM530IL8iwieUlHcb4NgX6hXn6PieZG4WdAPqevtmy3m/MnA2zmxDJ WCqZDfgi+iwCXwntX21SW5tAfwioLxmtXA== X-Google-Smtp-Source: ABdhPJwgTljB7IZK8lGbWA2j7i0a+f0jBt2DjKOEoC3YxCJ1gvGVSho7hYSFRuZ2XQwrh6kJnwwhCA== X-Received: by 2002:a05:6402:1d38:: with SMTP id dh24mr5358474edb.18.1622819868124; Fri, 04 Jun 2021 08:17:48 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 01/13] meson: allow optional dependencies for block modules Date: Fri, 4 Jun 2021 17:17:33 +0200 Message-Id: <20210604151745.310318-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210604151745.310318-1-pbonzini@redhat.com> References: <20210604151745.310318-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x534.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Right now all dependencies for block modules are passed to module_ss.add(when: ...), so they are mandatory. In the next patch we will need to add a libm dependency to a module, but libm does not exist on all systems. So, modify the creation of module_ss and modsrc so that dependencies can also be passed to module_ss.add(if_true: ...). While touching the array, remove the useless dependency of the curl module on glib. glib is always linked in QEMU and in fact all other block modules also need it, but they don't have to specify it. Signed-off-by: Paolo Bonzini --- block/meson.build | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/block/meson.build b/block/meson.build index e687c54dbc..9e3388f633 100644 --- a/block/meson.build +++ b/block/meson.build @@ -71,19 +71,19 @@ block_modules =3D {} =20 modsrc =3D [] foreach m : [ - [curl, 'curl', [curl, glib], 'curl.c'], - [glusterfs, 'gluster', glusterfs, 'gluster.c'], - [libiscsi, 'iscsi', libiscsi, 'iscsi.c'], - [libnfs, 'nfs', libnfs, 'nfs.c'], - [libssh, 'ssh', libssh, 'ssh.c'], - [rbd, 'rbd', rbd, 'rbd.c'], + [curl, 'curl', files('curl.c')], + [glusterfs, 'gluster', files('gluster.c')], + [libiscsi, 'iscsi', files('iscsi.c')], + [libnfs, 'nfs', files('nfs.c')], + [libssh, 'ssh', files('ssh.c')], + [rbd, 'rbd', files('rbd.c')], ] if m[0].found() + module_ss =3D ss.source_set() + module_ss.add(when: m[0], if_true: m[2]) if enable_modules - modsrc +=3D files(m[3]) + modsrc +=3D module_ss.all_sources() endif - module_ss =3D ss.source_set() - module_ss.add(when: m[2], if_true: files(m[3])) block_modules +=3D {m[1] : module_ss} endif endforeach --=20 2.31.1 From nobody Sun May 5 23:45:33 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622819975; cv=none; d=zohomail.com; s=zohoarc; b=ibIAd5C0AfTkAvri5V2wDbJiirQXDRynUlVuFGFhRns/vJFJQYiI17h0978nJ+p3XuGQoYjederP/cMTf/a4Ci5AC92PBkYuTfgyga/M5Zbyxsycu5NMwBdrFt56PVUzQstgc/ZTOtrENb5rNL2GUNmG/jugdnctmhBvQ7hYsDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622819975; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qqYqnrlenFog4cY4zspWeuI8Xg7nEVqv+lvAE9Po+qM=; b=WpZ7u3r4XsJkTwrAddSMfxDjJmuqgSC/hxachHpcbfpaapvJzlCx7ZehGaqGryViNRU7T85gkUvoGaC9UnDTpSTuZJSb/eoVBHX4kTBBpwKoO9ubCrljeEqt6FkAdz9Oa4u4UyybLq93fxA7F8dSLegAlpJgcDW37tRnmFu7VUw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1622819975961932.6431580374018; Fri, 4 Jun 2021 08:19:35 -0700 (PDT) Received: from localhost ([::1]:52838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpBbi-00024a-RT for importer2@patchew.org; Fri, 04 Jun 2021 11:19:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpBa5-0007lt-1D for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:53 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]:38483) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpBa3-0008De-8K for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:52 -0400 Received: by mail-ed1-x52a.google.com with SMTP id o5so11605441edc.5 for ; Fri, 04 Jun 2021 08:17:49 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id w1sm2402451eds.37.2021.06.04.08.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 08:17:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qqYqnrlenFog4cY4zspWeuI8Xg7nEVqv+lvAE9Po+qM=; b=G5GygwHXh10kbJxn2Yj1BH6NFKy4/e7U8pe4gkh2iEvh1fKC4z2V9ppCvbGmIF45Ul 3JueG1fvQ5ja1rUTkAyP3JUEMiO+xAEYTgCWCDPrBC8pG0FqlhES3Qz7Xb2hmZ8mkl+z pmCkeih3aQq3PMv6vlDw8vvLIhYLp8TZBMT8yAKmHI7YzSeD2nJPyEsm3/sWoEgz/gMg Jt9b7w2TzcfqXvFpasTbav0un3kErIqzL92HTtwyB4orBVwMJeXOxQOKsAK7qZ5renE2 nKCZ3Bf60FqdZ4mnCJi5GdcRESQ35VRQ5CpTQqGNYNWA+2CYXUwbBuV2h7GU3aPQb318 vXWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=qqYqnrlenFog4cY4zspWeuI8Xg7nEVqv+lvAE9Po+qM=; b=p1AG3YfeB7h2i77V+NweNhOhehavu6h8M3UwjMuzbog+0Fo8gjpfyTiRHxm+w5x0pk cLgK7NtioxfDr1eyXZU1d/FAKVVaRXdknBFpkveWDB0P0EdgNj/KAYgFFKH3eYcMsrGV HWZBWMlys2xJquN1fxtVK4vmvasQMdK6Xc0HIHdJz9TI0g6WoduKpGLVmxyV10S+7N9M Nf4Td1QrNCDcLXHnp7Cs9BQfWFPLdnf3oKQ7sNGyD/WGql9tUfZ3/CgkXfUgO02/yuXM c7/YnXiANrWu/NXuuGEhteElbDwdKdlj/JHmdFlHQsB1mepWeG6YzeFt0YKHRnE16NyH rAYA== X-Gm-Message-State: AOAM531Ik8R+seSG2RE7UnSHSFQ4ulj2LCIkXOUN59qqCHv78zJZzP1Q yq9QROck6oGUyWHODHDgEzcrMQR93NAhlw== X-Google-Smtp-Source: ABdhPJwLAZCrDPcm9dDROFzuK8RhiXDfuZkUqH1sgGkk5EIGC7G5GUO9eFzLsGr9mNCtrynVdsurJQ== X-Received: by 2002:aa7:cfc7:: with SMTP id r7mr1992044edy.13.1622819868906; Fri, 04 Jun 2021 08:17:48 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 02/13] iscsi: link libm into the module Date: Fri, 4 Jun 2021 17:17:34 +0200 Message-Id: <20210604151745.310318-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210604151745.310318-1-pbonzini@redhat.com> References: <20210604151745.310318-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52a; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Yi Sun Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Depending on the configuration of QEMU, some binaries might not need libm at all. In that case libiscsi, which uses exp(), will fail to load. Link it in the module explicitly. Reported-by: Yi Sun Signed-off-by: Paolo Bonzini --- block/meson.build | 2 +- meson.build | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/block/meson.build b/block/meson.build index 9e3388f633..01861e1545 100644 --- a/block/meson.build +++ b/block/meson.build @@ -73,7 +73,7 @@ modsrc =3D [] foreach m : [ [curl, 'curl', files('curl.c')], [glusterfs, 'gluster', files('gluster.c')], - [libiscsi, 'iscsi', files('iscsi.c')], + [libiscsi, 'iscsi', [files('iscsi.c'), libm]], [libnfs, 'nfs', files('nfs.c')], [libssh, 'ssh', files('ssh.c')], [rbd, 'rbd', files('rbd.c')], diff --git a/meson.build b/meson.build index a45f1a844f..913cf2a41a 100644 --- a/meson.build +++ b/meson.build @@ -163,7 +163,7 @@ if targetos !=3D 'linux' and get_option('multiprocess')= .enabled() endif multiprocess_allowed =3D targetos =3D=3D 'linux' and not get_option('multi= process').disabled() =20 -m =3D cc.find_library('m', required: false) +libm =3D cc.find_library('m', required: false) util =3D cc.find_library('util', required: false) winmm =3D [] socket =3D [] @@ -1899,7 +1899,7 @@ util_ss.add_all(trace_ss) util_ss =3D util_ss.apply(config_all, strict: false) libqemuutil =3D static_library('qemuutil', sources: util_ss.sources() + stub_ss.sources(= ) + genh, - dependencies: [util_ss.dependencies(), m, gli= b, socket, malloc, pixman]) + dependencies: [util_ss.dependencies(), libm, = glib, socket, malloc, pixman]) qemuutil =3D declare_dependency(link_with: libqemuutil, sources: genh + version_res) =20 --=20 2.31.1 From nobody Sun May 5 23:45:33 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622819976; cv=none; d=zohomail.com; s=zohoarc; b=PFoks8Bk9Dz10SXmuTLptKN+Nci+7bzyKuCBGxtLUz81SK8Dtgv1QbBRs2moTcXnz7galB6pmWivckoXiMdJm+1PnLMCtQbGxU8RQGAZdmk6AmW6a7Sx1/w0PJ88TEkhYIqKvhgg+CAtPScqxB6sB8hKLPiL4SUyK2/6pfK2W/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622819976; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ihe8crglx1nLpv95xn3UDEekdzpDK8HSnF14CMFLhd0=; b=eFyCNaRdPA49otWPvhK6KuhY7eSktdQyV4MyG6B3KYjb274JO5DdoAPrTyx1nfxTGJemif5jwTJwONkExcjbFra2zv/3zoR1/Ep+0eUCTaLTz3CfUNVpUUJdfA1Zf0YpbN1H5nz9tzhlWKge3MT+tN3bmY1yjBPc6IRCboz7IeI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 162281997664777.2816205828965; Fri, 4 Jun 2021 08:19:36 -0700 (PDT) Received: from localhost ([::1]:52836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpBbi-00024S-V4 for importer2@patchew.org; Fri, 04 Jun 2021 11:19:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpBa5-0007lu-1a for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:53 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:40930) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpBa3-0008Do-8c for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:52 -0400 Received: by mail-ed1-x536.google.com with SMTP id t3so11567924edc.7 for ; Fri, 04 Jun 2021 08:17:50 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id w1sm2402451eds.37.2021.06.04.08.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 08:17:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ihe8crglx1nLpv95xn3UDEekdzpDK8HSnF14CMFLhd0=; b=Z2dpMQMUcNyNkLcmVQ64AdQgzUjADZb1+xMUvumukXpUjZi+E3cIi4THuEArrSrWS9 /w5t89z+RL5EQ6QhTPE1JgO6YXH9aCeXJ/Vz61OCjae2HEukdWFp19omrRIHs+NlycNF ixeHb8h7qz/GPRKEHPpiMNtF+ox74CRS9PlDw+anRIupF0tkFtQ/sUGaUGpGBTOsLYAl g5eLRlPyAfUtpQ43peCBCYl22bgZX2USjDywcouv0eYpd4Kp6ycsb4iiy6NRlenB3JTM CDC/o9IyUr8351Vv5DdohCx0osF3ltFcrqkiQyszrT+h3dqa6pqV/OxavkvI3NsSIF2t hxGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Ihe8crglx1nLpv95xn3UDEekdzpDK8HSnF14CMFLhd0=; b=o2c2WliGpBPU7RKrQs+gUyaQNq1BSaO0T7CeG9y9ysgZ9AsSXuVuvGKZ0H9Zkv8cVK Rb8mawJ4QlYXdwm6aZRCXGrgHSaoylm6jZ+XL3T+40wfl+c8dPriK0mrKQag0IVnV0mj ETgJhZAR0dBS1NbiBDTs2eHHaOIrF8XppT8Nykqo7xVLo/UWsaUewUhDnBQwbJNi9pxa MBLgOXRTlSFrE/KDFCx5gOUyTdqi6ZS3/xUsfuLywLOGRmV+UjHNdy162HB5+yd83lyt JK2rlDdlATGw1G8vtCgk5D2bH1hfUXEnmxTJBjf9xIVS8oFtDzXPdmA9uzkjgRr39lcP oW1A== X-Gm-Message-State: AOAM530mwYhwYQGssdGtv1fnl2j98+Dy6W59p1lt85RAum9EzkIJE3Zd n9e02mx0GUP/cfUwy7keOI+Ubkuf4ij/Cg== X-Google-Smtp-Source: ABdhPJySkMW9EvWw9jRQ7e7PPdux22DGh+UrkoJjEz8GWLhv7hw9OCPZNn+kqDsWI6o40kuqYVe/ew== X-Received: by 2002:a05:6402:845:: with SMTP id b5mr5178627edz.266.1622819869646; Fri, 04 Jun 2021 08:17:49 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 03/13] oslib-posix: Remove OpenBSD workaround for fcntl("/dev/null", F_SETFL, O_NONBLOCK) failure Date: Fri, 4 Jun 2021 17:17:35 +0200 Message-Id: <20210604151745.310318-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210604151745.310318-1-pbonzini@redhat.com> References: <20210604151745.310318-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x536.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Brad Smith Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Brad Smith OpenBSD prior to 6.3 required a workaround to utilize fcntl(F_SETFL) on mem= ory devices. Since modern verions of OpenBSD that are only officialy supported and build= able on do not have this issue I am garbage collecting this workaround. Signed-off-by: Brad Smith Message-Id: Signed-off-by: Paolo Bonzini --- util/oslib-posix.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 36820fec16..7b4bec1402 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -273,17 +273,6 @@ int qemu_try_set_nonblock(int fd) return -errno; } if (fcntl(fd, F_SETFL, f | O_NONBLOCK) =3D=3D -1) { -#ifdef __OpenBSD__ - /* - * Previous to OpenBSD 6.3, fcntl(F_SETFL) is not permitted on - * memory devices and sets errno to ENODEV. - * It's OK if we fail to set O_NONBLOCK on devices like /dev/null, - * because they will never block anyway. - */ - if (errno =3D=3D ENODEV) { - return 0; - } -#endif return -errno; } return 0; --=20 2.31.1 From nobody Sun May 5 23:45:33 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622820088; cv=none; d=zohomail.com; s=zohoarc; b=Vq2zL6WI8e0x0rN12vH24K+f2k13akl2wzrGmbN9WA/KTRTiur0Ke3wfmyW/5X+SaHyUkq4bbBymGTMEN1iogd+DCE6rJtcYxvskstXjH+Hgcb4Q1BjlvjQWif27ap+86I4eEWhK19qDZYf2jUg+CANleCzki0Tp5dPvyPIhux8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622820088; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GjSj1BvMv7SkGTnFgml+cFr3Qod8iyQlPdCz9aegSrI=; b=P4b0c6ZLChZiNbh+BQQmihKqAb2p1c1kgesxntT8JscFkcUv3m9cdplystC7RDMiQ3ZIuca7r7yf1nLqR0QGvmMQVe6IsFyfY+pjvt6s1QyQ+GePv5QNKlpRVH98vKsn01oOwvhgZQZtinCKnKDbbrDhTVph6WbR91oCGzQjG0I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1622820088244816.5824153184165; Fri, 4 Jun 2021 08:21:28 -0700 (PDT) Received: from localhost ([::1]:33084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpBdX-0007q3-62 for importer2@patchew.org; Fri, 04 Jun 2021 11:21:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpBa5-0007lv-2y for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:53 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:45844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpBa3-0008EQ-KH for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:52 -0400 Received: by mail-ed1-x535.google.com with SMTP id dg27so11548627edb.12 for ; Fri, 04 Jun 2021 08:17:51 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id w1sm2402451eds.37.2021.06.04.08.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 08:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GjSj1BvMv7SkGTnFgml+cFr3Qod8iyQlPdCz9aegSrI=; b=GWEVTHaR8Fcs9geqyVtIzcmgFPqFMYqz+IbtZPoN6505YtiGmrv+N1Wivj6KGJOLwZ odCxKRoJqm4yHaavI6RZgsLtoRl/4cNihcjzAJq70IC3UPfc6uW+mTLR/WENkt7UQ00t bO2941X7NdNvKvQgTlPWe2qNXWrhIlO6EhZuMFCqGpmQ/p8jSaMO2dZsNJ4NEegoYFjt TbF7CSPQAKzl7AhPmNViDDtHokOTP+9JkP240d80/p5LYBu6X0n2UFIzqUqaGDpXjxBg qCfIhPMB72ae7eV7KsS4gt6GbmbU/6VsUgAvJR/I+0FOvLxMgQ8iYnhQPUM388Q5M/SB 4iSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=GjSj1BvMv7SkGTnFgml+cFr3Qod8iyQlPdCz9aegSrI=; b=iHmUTwR9PNzZ9gK2y3PtBPNeV9cMVwsx+s954E1yUy+uKGXwCFFGk3+t/7nSTxFT0q c8ZAZV2FDAJVNtXnY1SU1Iz6drpDbhNwnXERnSPfZt2wTQ+ZhCbDfgJqoowKTg/shr28 kD7ijff/BLQPMCWRYV6WAffMhYtiPJ+KmpxDymJBqMW8fVaijiN3IYj1t/qa3bNZKMLr J03F4aar4djnAp7PWqrC2fZXqJrUGL/gi+Nl3u61FcCpSdQmIkv1Rzk1V4PsfSTts7jH tEOee0eWUJ8wkL3QEOkL09/8cHEojRzwg7qeGUfZQ7Av7+3nu+TwAeB+egNjaIpEYdUu Cu3w== X-Gm-Message-State: AOAM530DKsJIFcthR1/WRtcHWE/0bSZftRR5pj4j0p99X8ycgeHZWUbl mbUyVIoQdW/2WenVzraime03Fy/erDuFKQ== X-Google-Smtp-Source: ABdhPJw9qIN5tpMQG/DOus7qdL+TIc5J3RCfCj9IA+p+tTl8kYgWhZWJsw9QJRRxxcJUvAlwCskmKg== X-Received: by 2002:a05:6402:524b:: with SMTP id t11mr5192861edd.327.1622819870385; Fri, 04 Jun 2021 08:17:50 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 04/13] target/i386: tcg: fix segment register offsets for 16-bit TSS Date: Fri, 4 Jun 2021 17:17:36 +0200 Message-Id: <20210604151745.310318-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210604151745.310318-1-pbonzini@redhat.com> References: <20210604151745.310318-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x535.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Peter Maydell Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The TSS offsets in the manuals have only 2-byte slots for the segment registers. QEMU incorrectly uses 4-byte slots, so that SS overlaps the LDT selector. Resolves: #382 Reported-by: Peter Maydell Signed-off-by: Paolo Bonzini --- target/i386/tcg/seg_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index 2f6cdc8239..547b959689 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -281,7 +281,7 @@ static void switch_tss_ra(CPUX86State *env, int tss_sel= ector, retaddr) | 0xffff0000; } for (i =3D 0; i < 4; i++) { - new_segs[i] =3D cpu_lduw_kernel_ra(env, tss_base + (0x22 + i *= 4), + new_segs[i] =3D cpu_lduw_kernel_ra(env, tss_base + (0x22 + i *= 2), retaddr); } new_ldt =3D cpu_lduw_kernel_ra(env, tss_base + 0x2a, retaddr); @@ -349,7 +349,7 @@ static void switch_tss_ra(CPUX86State *env, int tss_sel= ector, cpu_stw_kernel_ra(env, env->tr.base + (0x12 + 6 * 2), env->regs[R_= ESI], retaddr); cpu_stw_kernel_ra(env, env->tr.base + (0x12 + 7 * 2), env->regs[R_= EDI], retaddr); for (i =3D 0; i < 4; i++) { - cpu_stw_kernel_ra(env, env->tr.base + (0x22 + i * 4), + cpu_stw_kernel_ra(env, env->tr.base + (0x22 + i * 2), env->segs[i].selector, retaddr); } } --=20 2.31.1 From nobody Sun May 5 23:45:33 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622820178; cv=none; d=zohomail.com; s=zohoarc; b=XxJtujbn0sJLTJDWFDuE46eg8wLxTJNDMV/dfkgkfC2Od8c3VeBO/JVVu94yeb9BPgpPgc8SL5e4fkAqkg4lKS6yQzewMZ/fnTMfmeC5PLUcpndaFDGxUyQ6LpEIRItEqZzqnENtbHZt/f3v/HGwW2F5ZItXWaUwJtG53vl6uZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622820178; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cMD/MQJK6RuY6kQefUquuNuGpcrRXIPINqzY23mVatU=; b=llR4ESW7/yEwwi0FMuM8bCkgT4sVwNwtaJZCCGxND98V/GI6BkUGtzv+RjNLqxL0JkQImgME3VJxVu73WHQePvA5qdHzZheMoP7wIB9dORs8L9yFKCLm5xnSj44R9jesPtoc1rNEFLzBO5F5Q7sbPXYsJfC41+ioqCZ0TJbdkgY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1622820178216219.64883611871483; Fri, 4 Jun 2021 08:22:58 -0700 (PDT) Received: from localhost ([::1]:40688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpBez-0004a8-6z for importer2@patchew.org; Fri, 04 Jun 2021 11:22:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpBa6-0007mj-6V for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:54 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:35413) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpBa4-0008EY-R0 for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:53 -0400 Received: by mail-ed1-x532.google.com with SMTP id ba2so9857094edb.2 for ; Fri, 04 Jun 2021 08:17:51 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id w1sm2402451eds.37.2021.06.04.08.17.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 08:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cMD/MQJK6RuY6kQefUquuNuGpcrRXIPINqzY23mVatU=; b=IKkFGxW+gAbEOez0Fzp2hQg+gzkuYQ2/sk7rr23eubSwCCS+YfbupkE08FEgY0Pzs3 LI9UQQGSJldEHCaA55NryZGmIp+tGDUZvucuzIhodwvaxGzvCHMmP/E4qFHSPG+MMyYo 2AWjzhSGbDsaRJogdjTluSbqfaKPmnS2hYyh93BBT3DPJgx0b644J+tKm4Xj+2XJJr51 dlOmGCMvXbI7eF6zjaX8hc9CCR/vmuzFh4lYT9bEKQQY3tblwDup51WIzkZ1Vk4Jsx9K YjAwk0OnkIEHYj4waixL7wx3PZFlD2TQy+23MQLtmufeMJ1KxQb3g2hkMO2e8gVhQ+ZJ bp0Q== 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:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=cMD/MQJK6RuY6kQefUquuNuGpcrRXIPINqzY23mVatU=; b=FgjZ4hv0YXr4HQh8z5RxWPC8zTylmK3aBRkTSAPB8MH3mNx7B0BZHAKr8fNhp8aq5x DyLjoXD43beVxTAjusFN9JSbHULwZNk/0ob7JwgSDpfML1t3KWmm0YfAQfBhoCNsFQu+ fgU6qQ4Y9jA3wVMie+5HiuvMJXkKf41rhQy3Cfa1mq0MQXshP+sGY5mwZjHKat14O5JT kEvlXT5/iMR2FO8eVEbucp2TcSJDQufkDuCAkm5CToRxsMWPeP9DrMMyYDWNTMGMZAng ICoQYjrzt8WvY9mlmCaMd0dqxuCj9aLHOF+DgTm9U2yYHQ9aNbs0wPjhvYlCA/DEylNS +j5A== X-Gm-Message-State: AOAM532Y98moHrU6MzzHzMT3IySV1U2b3Ry2cPNjlKJX7uaIGSMsFk0x 8v0V1bocDJO78VAaT3EurLRSnMjvNfU2sA== X-Google-Smtp-Source: ABdhPJy6sD9sAOao9e11LBu4Rm48m9/EjQYJI/faD0Xt/iv5zdOxo6TPjQlalSKC5/RXDYjRgQTWEA== X-Received: by 2002:a05:6402:5194:: with SMTP id q20mr5429369edd.356.1622819871084; Fri, 04 Jun 2021 08:17:51 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 05/13] target/i386: tcg: fix loading of registers from 16-bit TSS Date: Fri, 4 Jun 2021 17:17:37 +0200 Message-Id: <20210604151745.310318-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210604151745.310318-1-pbonzini@redhat.com> References: <20210604151745.310318-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" According to the manual, the high 16-bit of the registers are preserved when switching to a 16-bit task. Implement this in switch_tss_ra. Signed-off-by: Paolo Bonzini --- target/i386/tcg/seg_helper.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index 547b959689..2112c5fc51 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -277,8 +277,7 @@ static void switch_tss_ra(CPUX86State *env, int tss_sel= ector, new_eip =3D cpu_lduw_kernel_ra(env, tss_base + 0x0e, retaddr); new_eflags =3D cpu_lduw_kernel_ra(env, tss_base + 0x10, retaddr); for (i =3D 0; i < 8; i++) { - new_regs[i] =3D cpu_lduw_kernel_ra(env, tss_base + (0x12 + i *= 2), - retaddr) | 0xffff0000; + new_regs[i] =3D cpu_lduw_kernel_ra(env, tss_base + (0x12 + i *= 2), retaddr); } for (i =3D 0; i < 4; i++) { new_segs[i] =3D cpu_lduw_kernel_ra(env, tss_base + (0x22 + i *= 2), @@ -391,19 +390,17 @@ static void switch_tss_ra(CPUX86State *env, int tss_s= elector, env->eip =3D new_eip; eflags_mask =3D TF_MASK | AC_MASK | ID_MASK | IF_MASK | IOPL_MASK | VM_MASK | RF_MASK | NT_MASK; - if (!(type & 8)) { - eflags_mask &=3D 0xffff; + if (type & 8) { + cpu_load_eflags(env, new_eflags, eflags_mask); + for (i =3D 0; i < 8; i++) { + env->regs[i] =3D new_regs[i]; + } + } else { + cpu_load_eflags(env, new_eflags, eflags_mask & 0xffff); + for (i =3D 0; i < 8; i++) { + env->regs[i] =3D (env->regs[i] & 0xffff0000) | new_regs[i]; + } } - cpu_load_eflags(env, new_eflags, eflags_mask); - /* XXX: what to do in 16 bit case? */ - env->regs[R_EAX] =3D new_regs[0]; - env->regs[R_ECX] =3D new_regs[1]; - env->regs[R_EDX] =3D new_regs[2]; - env->regs[R_EBX] =3D new_regs[3]; - env->regs[R_ESP] =3D new_regs[4]; - env->regs[R_EBP] =3D new_regs[5]; - env->regs[R_ESI] =3D new_regs[6]; - env->regs[R_EDI] =3D new_regs[7]; if (new_eflags & VM_MASK) { for (i =3D 0; i < 6; i++) { load_seg_vm(env, i, new_segs[i]); --=20 2.31.1 From nobody Sun May 5 23:45:33 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622820258; cv=none; d=zohomail.com; s=zohoarc; b=Ku6/QmIw+dpkKY80anVNEH46yKLjzclFhTYkPgxDeKlkPwQsQR0rTiA5GgipLZbUm/ICB7MwSzTCyhMVrkD/8lR8zjwyjgEyQ3RQGu2G/B/wrnmO5EFNG/MZIo37eEWmxFfTaw6it5seiZyiF4WzIz1dmUiS1LNfWOkuxPt/qjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622820258; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eiNYKdEymzNvK37Wm5/uHgaRQxlBgWOvTJMeH6EfWJI=; b=RHPY7UR1Ih+vO7/f98//b7dC/lkCLXnW9FLqQ3c/AzJsufuuRCnyIcNu0mX2cuWK/wQt+oBvJ7i9akKesOzknypp9cLAiGVCs441hdIBA35jiYuvBsHDjEBTlT/MX0Ddf1tTyKZyzIXbGhRz11yfTl6zaEuey3rW9Ec1Oq5p+Ao= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1622820258602570.4084574485163; Fri, 4 Jun 2021 08:24:18 -0700 (PDT) Received: from localhost ([::1]:45954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpBgH-000855-Jc for importer2@patchew.org; Fri, 04 Jun 2021 11:24:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpBa6-0007oP-Su for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:54 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:43802) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpBa5-0008El-Dq for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:54 -0400 Received: by mail-ej1-x62d.google.com with SMTP id ci15so15031781ejc.10 for ; Fri, 04 Jun 2021 08:17:52 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id w1sm2402451eds.37.2021.06.04.08.17.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 08:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eiNYKdEymzNvK37Wm5/uHgaRQxlBgWOvTJMeH6EfWJI=; b=Mnfbe1FkriWov1Ka8xnjxJj5CwAJvdA3lMd4lk+RQZVjt427WzOWohp+93aQZVMjhG 3ihVQXCpujK6FJtQLlpMuUoCV0DbHw7u1g3nIlXEQxbLgfDWFpOryzQg5Wuup4CmNDfz ZRDo4HU9sG/DYk06tcT5MGPcjjxr2PAJyr0RzxngL+oA3kWXNYqPwmaevl2yUSyciS+B tIcLAp+GYv4r16d0XdIpg6vDZxvbTk9QAsFRhOqkAd3cQnHELWA+qi1ekHWoaj/Sdte7 ck8wZnyofH8Mt1r0E7zbpWBAI5C84XhtqOe8pzOHphzkJqqH1RILqtPMBcADXgIMpvjG U8Zw== 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:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=eiNYKdEymzNvK37Wm5/uHgaRQxlBgWOvTJMeH6EfWJI=; b=BrAuv/qwRRRYR/GXWgKJWNZAgDHj4iRImefjjmt7ayK6s9IZdbGog/6iQ9WlH/9Rfr 82rqZowyQ1/rgyC6bFm8F0O3w7bpQjuxE1kas0oYonicZQBpV2P/9AeTqKHjmoFeOc5D pszZvKN+RYduIPRp1l1b9oOhkeKoax1acgLNDYNgxzgVvG5wTke4us1G84+yyhWfZo+Q ev0cQrLAmcAITQM7AmfWJOpO2CTBKQ/KpVn3XEzN3IHejII3d0QoIyHNu155yLCJu1Uk Nif3D+nrl9d5RgEkvEuXsHNadP9fHC4+1IAYo9418HttWJeppx3NXBx7iAK1qNVJK5i3 1TRA== X-Gm-Message-State: AOAM531GynYSUnElr+R5vDzExxXENprVNtkH6w+T3D9eGr5BTh+hxXAF TwcK2ao5y2hTTbjkK4rZUNEF4wjpHdX/jQ== X-Google-Smtp-Source: ABdhPJzbbQyCpsNl2I5XmdeRjllnXXlSO+RxVoH0ka1Ott/ZWCINp7jPvJ/ctjPk46wp0UPFMChn1w== X-Received: by 2002:a17:906:606:: with SMTP id s6mr4602330ejb.206.1622819871768; Fri, 04 Jun 2021 08:17:51 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 06/13] target/i386: tcg: fix switching from 16-bit to 32-bit tasks or vice versa Date: Fri, 4 Jun 2021 17:17:38 +0200 Message-Id: <20210604151745.310318-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210604151745.310318-1-pbonzini@redhat.com> References: <20210604151745.310318-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62d.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The format of the task state segment is governed by bit 3 in the descriptor type field. On a task switch, the format for saving is given by the current value of TR's type field, while the format for loading is given by the new descriptor. Signed-off-by: Paolo Bonzini --- target/i386/tcg/seg_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index 2112c5fc51..3ed20ca31d 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -319,7 +319,7 @@ static void switch_tss_ra(CPUX86State *env, int tss_sel= ector, } =20 /* save the current state in the old TSS */ - if (type & 8) { + if (old_type & 8) { /* 32 bit */ cpu_stl_kernel_ra(env, env->tr.base + 0x20, next_eip, retaddr); cpu_stl_kernel_ra(env, env->tr.base + 0x24, old_eflags, retaddr); --=20 2.31.1 From nobody Sun May 5 23:45:33 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622820324; cv=none; d=zohomail.com; s=zohoarc; b=f/SEsxWOmOclF/D862VCvF9mjV0SJ9KbWVsRfsQMxCuFFAL0GMHDDHz/cd5RSDICNGce/kAfu6/Z3sl91K6rh9Yj+OzWlwEZ44rlwfj5XF/E2IrYyFqeE3JSNBmuJJbwHfOfYihvZ0u8N3W4657mvG3IMs3LGQjDt6pivQj0Qqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622820324; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nEr88gMBuvavyMpSy3KEuJq9doTqO0h81BlSUvT2wpg=; b=Jk+IdZCWPBJSU5jndsHefMotL1PwCT+Ee54gDRWNltT6CWzg/9nrlqtsH0ftz0eGHpvtI4pC/szfaFFHUubNDmcbNK3HS+r4gxUUSEleFt9mQX740TMVSXIGtkY3DVP4Yky64ZQeOs0Kk1ZczdADdXOgMvvlRzWhFfltkAumgPE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1622820324191806.9055433621111; Fri, 4 Jun 2021 08:25:24 -0700 (PDT) Received: from localhost ([::1]:48246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpBhL-0001Es-0R for importer2@patchew.org; Fri, 04 Jun 2021 11:25:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpBa7-0007qh-HI for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:55 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]:33520) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpBa5-0008Es-RP for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:55 -0400 Received: by mail-ej1-x630.google.com with SMTP id g20so15137864ejt.0 for ; Fri, 04 Jun 2021 08:17:53 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id w1sm2402451eds.37.2021.06.04.08.17.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 08:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nEr88gMBuvavyMpSy3KEuJq9doTqO0h81BlSUvT2wpg=; b=DC+Dk/PmlLRaDaqUaQPMBCaPerQIsf4Jw0xRPU/gPms4D8ltQPVvSS79UxPJ/fkhbP s3wbQuSGNiE6ffDuNxxWB9p2/ldebvOJNP1LEU/t779NXZhky9I6YViDdZkmqWiPP87A l+wtCqwYyDGR41gDH7PQpUld2BlK6xpONzqzjH6H+J1HPy5X7mxkhhSCjoWpZvv6TMVl EpWbl2G10ja2HFA/kDo0pDn5gdUuJCW3XUJOb7lWvcm4ifNF8RNwcqic6fw4SBPBtG13 10HkDFluNaV994E+t2LactJSUxok29q+aXZWzAT8cK6izwUXCHC1r8CpUFA+Dg6OvzQz XLUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=nEr88gMBuvavyMpSy3KEuJq9doTqO0h81BlSUvT2wpg=; b=pNDxvRVFy0lddDXplIvjwQWvX8eOoOVeUw8nv31WKVvByDhQB4zawbkYgbRHrEkT3N PDAOdcdrtcCPGQ1HDeETyxzokjaR2TXwB+MBCjUVlkQM/2wLm/ME8wdirLeJPak2yzMk KppALBV2LYcG4dX5zvw1e7QBNKLNQOvZHQ/G4XYMmq8sQ9O9vtkRJ7VjcwFArNFQmfFj btT83PFAPlgMCYOuzu8IIIxn+ore6nrFjCxXTuqWyJbnOt5QlC1pDLUevKLNBXXfaJef tcBTvn4CbpPAjVa9IXmIQWFjZFfqMy4XlyYOY13ClmV8gBCEyPopWG/Ec/QLfj0N/VXf qyFg== X-Gm-Message-State: AOAM531jUWSzjud9HR4TbC/eRrgLOMtpo0ZREG7V3c4JEsmZmc2la641 2H/VP/FD8WhMNC9joPW+AQiXOzMhQ/RuEQ== X-Google-Smtp-Source: ABdhPJzLxoMKCDxNK/OEOaq6Vakaw+jEt96b0UnZRuIUClPCHx8U0MSNzLho/NoWnNWs0IOw6z+msg== X-Received: by 2002:a17:906:a281:: with SMTP id i1mr4579252ejz.307.1622819872513; Fri, 04 Jun 2021 08:17:52 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 07/13] target/i386: Fix decode of cr8 Date: Fri, 4 Jun 2021 17:17:39 +0200 Message-Id: <20210604151745.310318-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210604151745.310318-1-pbonzini@redhat.com> References: <20210604151745.310318-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x630.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Richard Henderson Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Richard Henderson A recent cleanup did not recognize that there are two ways to encode cr8: one via the LOCK and the other via REX. Fixes: 7eff2e7c Resolves: https://gitlab.com/qemu-project/qemu/-/issues/380 Signed-off-by: Richard Henderson Message-Id: <20210602035511.96834-1-richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 834186bcae..a7f5c0c8f2 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -8091,6 +8091,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) case 2: case 3: case 4: + case 8: break; default: goto unknown_op; --=20 2.31.1 From nobody Sun May 5 23:45:33 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622820090; cv=none; d=zohomail.com; s=zohoarc; b=Fz1UobTADkhrU7EJrgJT7QimlesxnwGmkelwOebULKfFphipGdNKBlYJiarsvqIHEyH1vdgJ1h6O4lL/irkzX6rqvo8QNTnSPEV0OlC3iYnzPmIsVho/0GkdxAWCEnnl/ClmT/Nq8D0mWlZdkY7u3TE2ny4l3upbnCcfoZsqiZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622820090; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=K1tL+erQPidZ36ddRBBO4262j1mjJRCxWQU+9QCKKGQ=; b=f9e9rxT2MVmN0be+fpKFeqaXiuSehptYySrGQgVklH+KA45houoph0cG6ndzhoJs+sS5SBtrZVsFTLX4AYZJPUQA+BVIZzI9suR4lmfiV5dmkIQFlXexXfpGghnyZOkEgW9VRIojWjRzZow208p8UdkQIhNfuxVYr3m2sR25eI4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1622820090381748.2981474203051; Fri, 4 Jun 2021 08:21:30 -0700 (PDT) Received: from localhost ([::1]:33176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpBdZ-0007u0-Ac for importer2@patchew.org; Fri, 04 Jun 2021 11:21:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpBa8-0007tj-9b for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:56 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]:44924) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpBa6-0008Fo-GV for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:55 -0400 Received: by mail-ej1-x631.google.com with SMTP id c10so15018340eja.11 for ; Fri, 04 Jun 2021 08:17:54 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id w1sm2402451eds.37.2021.06.04.08.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 08:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K1tL+erQPidZ36ddRBBO4262j1mjJRCxWQU+9QCKKGQ=; b=a/NLM2AhJ15m16EdB1eYSIQ+wUpyG8BoVpeUanRPFF9CnlCoMpIdPJF4GKozAeUQJy y/HV6unNrYFFcFy2a5SuhlpOl1bAq4l3bTdUvjRIckFhKB++yEonvgZ3JbfIw+ukG/AN oTDkf8LPg3wMYnHGIplqnK5C/RX+qyshlxzqysxNmSLFR5+/FPDEVLz/8hgKx+lnhEz5 YxoDurSVYwp0/w3pjdDLgUgJyZuEexcnQlR+E+eYZbsseqWQE+kAU7AQL9E4m9NiHHeZ +B1eAwGyMn2sOrV9EbGdgfLOWUHOlSXQ46x8wKr6tz8zSflAkaR8trVOHyj8YEeRWHGY cgOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=K1tL+erQPidZ36ddRBBO4262j1mjJRCxWQU+9QCKKGQ=; b=RcLKb4X80fnmanfy5tQF+0tt9qWak9I6G7729xJl2u5ylYUjJvHq2BhIFtUEROKYN5 15vZsHziLlQ7sGQjyNq6UmUjoerlTub3F8tolIc+WJQCxQSicrl4fyE0TgwWWitHgBoa utKnBinoWnE+psY5zw7bmTnfujJLq8Dn0DK4i6d8gf4lw8ih7kX47a9x4cmlgC7bWiPm ynbv6BcJiYlMlVGtrxO0BptLgb04dzL4DLqyGaKrzLO4TXU6qGoRasrOaFWDwVqGJdbf uSPWaFqGWhOgT3JsfZ+Ln1Zsgfys8NNbfcFdBKDWi1+oG67gT+XuePRt8OT17coOb3NX w4Lg== X-Gm-Message-State: AOAM53082SFiyuyP28NqFxz9H+aJd0wyVbO53UU+Rf661LdImnUDRocq jXZbZAf3jmSmHSF8CLDTCaszgYjlv0whLg== X-Google-Smtp-Source: ABdhPJxfMOag6/CCgbNag4pw9+YYRGikLotVzmRmMMhWFDkl0uHOx/iZlpIjAt075xtZm/yn6i2YGg== X-Received: by 2002:a17:906:40ca:: with SMTP id a10mr4664362ejk.181.1622819873211; Fri, 04 Jun 2021 08:17:53 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 08/13] tests/qtest/virtio-scsi-test: add unmap large LBA with 4k blocks test Date: Fri, 4 Jun 2021 17:17:40 +0200 Message-Id: <20210604151745.310318-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210604151745.310318-1-pbonzini@redhat.com> References: <20210604151745.310318-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x631.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Kit Westneat Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Kit Westneat Add test for issue #345 Signed-off-by: Kit Westneat Message-Id: <20210603142022.676395-1-kit.westneat@gmail.com> Signed-off-by: Paolo Bonzini --- tests/qtest/virtio-scsi-test.c | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/qtest/virtio-scsi-test.c b/tests/qtest/virtio-scsi-test.c index 1b7ecc1c8f..8ceb12aacd 100644 --- a/tests/qtest/virtio-scsi-test.c +++ b/tests/qtest/virtio-scsi-test.c @@ -200,6 +200,42 @@ static void test_unaligned_write_same(void *obj, void = *data, qvirtio_scsi_pci_free(vs); } =20 +/* Test UNMAP with a large LBA, issue #345 */ +static void test_unmap_large_lba(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVirtioSCSI *scsi =3D obj; + QVirtioSCSIQueues *vs; + const uint8_t unmap[VIRTIO_SCSI_CDB_SIZE] =3D { + 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00 + }; + + /* + * Default null-co device size is 2**30 + * LBA 0x7fff is ~ 1/8 into device, with 4k blocks + * if check_lba_range incorrectly using 512 bytes, will trigger sense = error + */ + uint8_t unmap_params[0x18] =3D { + 0x00, 0x16, /* unmap data length */ + 0x00, 0x10, /* unmap block descriptor data length */ + 0x00, 0x00, 0x00, 0x00, /* reserved */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, /* LBA */ + 0x00, 0x00, 0x03, 0xff, /* sector count */ + 0x00, 0x00, 0x00, 0x00, /* reserved */ + }; + struct virtio_scsi_cmd_resp resp; + + alloc =3D t_alloc; + vs =3D qvirtio_scsi_init(scsi->vdev); + + virtio_scsi_do_command(vs, unmap, NULL, 0, unmap_params, + sizeof(unmap_params), &resp); + g_assert_cmphex(resp.response, =3D=3D, 0); + g_assert_cmphex(resp.status, !=3D, CHECK_CONDITION); + + qvirtio_scsi_pci_free(vs); +} + static void test_write_to_cdrom(void *obj, void *data, QGuestAllocator *t_alloc) { @@ -293,6 +329,17 @@ static void *virtio_scsi_setup(GString *cmd_line, void= *arg) return arg; } =20 +static void *virtio_scsi_setup_4k(GString *cmd_line, void *arg) +{ + g_string_append(cmd_line, + " -drive file=3Dblkdebug::null-co://," + "file.image.read-zeroes=3Don," + "if=3Dnone,id=3Ddr1,format=3Draw " + "-device scsi-hd,drive=3Ddr1,lun=3D0,scsi-id=3D1" + ",logical_block_size=3D4k,physical_block_size=3D4k"); + return arg; +} + static void *virtio_scsi_setup_cd(GString *cmd_line, void *arg) { g_string_append(cmd_line, @@ -323,6 +370,10 @@ static void register_virtio_scsi_test(void) qos_add_test("unaligned-write-same", "virtio-scsi", test_unaligned_write_same, &opts); =20 + opts.before =3D virtio_scsi_setup_4k; + qos_add_test("large-lba-unmap", "virtio-scsi", + test_unmap_large_lba, &opts); + opts.before =3D virtio_scsi_setup_cd; qos_add_test("write-to-cdrom", "virtio-scsi", test_write_to_cdrom, &op= ts); =20 --=20 2.31.1 From nobody Sun May 5 23:45:33 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622820410; cv=none; d=zohomail.com; s=zohoarc; b=WmmF75HvHlnI8HSQsv1bwNJlP5cX67DzH25EtDzOPEUPUZtj4/zM82DDnvtfNhdOz3z2PPwOzSbmpFxBlRoC6iWAigNtPCnkyAoEsMXwrC05bQtmHj+itCEicbVTXjsYw+Hguihik2UezCoZ8MbMPLnQTVXSOHmsHRDumVy/NaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622820410; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IhI5qK8fOj23ZCs+2zNQ+PPAqZm0E1FwU8STGeClWss=; b=JmYFkoaXqZTAumJdC+fjwKf4JBjAZJVolqSg13dPVqy/Q+897QAsjJW2maB43EWjmOdYbEzSTETIUnf4kQMeMArt4mdR8a7oXPLG/ymsSUE5kuetCXPmeSlAz6MKQJeyBab98ZrACzQSm6mTiQ+yFMOMuUwO8rozGxoECWf9C80= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 162282041091869.3047566057412; Fri, 4 Jun 2021 08:26:50 -0700 (PDT) Received: from localhost ([::1]:50430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpBij-0002ow-Rg for importer2@patchew.org; Fri, 04 Jun 2021 11:26:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpBa9-0007xq-Eo for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:57 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]:34716) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpBa7-0008Gs-Dj for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:57 -0400 Received: by mail-ed1-x52d.google.com with SMTP id cb9so11615612edb.1 for ; Fri, 04 Jun 2021 08:17:54 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id w1sm2402451eds.37.2021.06.04.08.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 08:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IhI5qK8fOj23ZCs+2zNQ+PPAqZm0E1FwU8STGeClWss=; b=GrWUsBre5wSvATEc5MW4mqTBHOBunAnIfsomYQn1fAIj1GdUie8vSc1axrMN1ouGbn cHbiFMrhd3ntQ8zSlQJErueaspm4WmYEKap4lv/LA/SUnS+jGo8bKk3rBPvr75bkgwYv njckqbyFsNa2unECeI+WgLovCzrClATlysAR9MmJDD4cDgmyHu1gshgU/JSEz884tBu1 flB65gu50gROoJs4azk1dpMuVEQAeEoAAmpXrrYKDeB9Gc+CeLFS5KGGYf60ovaqShzA dffg6rinKYRH/Aq0HfsyzdfEGoCxdqEDL20W7Wx+LYYuiuRvU0KQ8E320f3kfZCHOiu3 VjhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=IhI5qK8fOj23ZCs+2zNQ+PPAqZm0E1FwU8STGeClWss=; b=Xpzo+FpnK43aHRH8wX1bLpePoVpxnqSRqq3UlShc8ObcWkSYGfEwdBrwf/E8ZnRgnv vNptyuuNUmccjO7L46ibUMbPyXhb5s+JZbP6Vr4ysiKVjXlYOj00b5R0Y2ZqmpJYwzYL jZJkcH/576nAffdBU7wLRb2bDEADJLPjAdlc4HKiGzbaIuoIexJUaivLEZzWCjbtIKpU BS1grwV5NyO/2lWKuSE47G+nYSMj3ChWUMZ4Sp/kW3rXj0wmXexU87TwxSzS+4v+CUsp ZiyyXEgO3wxCzNnt8hds+ueN0SNw1T+uMbZy5+ag3EJuBo1f1gmVismN2kwc2fRZkGEB QZlQ== X-Gm-Message-State: AOAM532g7XXePBBcbpmHa75NqQArDzOgfulVfvSuadUiH78pGiDa7IH4 CeB5oCAoAXf2maGkl1TCvoY4XAqntvyAkg== X-Google-Smtp-Source: ABdhPJyg/lukOblbpbcYov7Bm9VR6mGZ+QkfwwYDJ+IrMgew4JoQZO6OXAqM3NR72ZB8tCI7RiZTBg== X-Received: by 2002:a05:6402:268f:: with SMTP id w15mr5083621edd.321.1622819874065; Fri, 04 Jun 2021 08:17:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 09/13] i386: reorder call to cpu_exec_realizefn Date: Fri, 4 Jun 2021 17:17:41 +0200 Message-Id: <20210604151745.310318-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210604151745.310318-1-pbonzini@redhat.com> References: <20210604151745.310318-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52d.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Vitaly Kuznetsov , Claudio Fontana , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Claudio Fontana i386 realizefn code is sensitive to ordering, and recent commits aimed at refactoring it, splitting accelerator-specific code, broke assumptions which need to be fixed. We need to: * process hyper-v enlightements first, as they assume features not to be expanded * only then, expand features * after expanding features, attempt to check them and modify them in the accel-specific realizefn code called by cpu_exec_realizefn(). * after the framework has been called via cpu_exec_realizefn, the code can check for what has or hasn't been set by accel-specific code, or extend its results, ie: - check and evenually set code_urev default - modify cpu->mwait after potentially being set from host CPUID. - finally check for phys_bits assuming all user and accel-specific adjustments have already been taken into account. Fixes: f5cc5a5c ("i386: split cpu accelerators from cpu.c"...) Fixes: 30565f10 ("cpu: call AccelCPUClass::cpu_realizefn in"...) Cc: Eduardo Habkost Cc: Vitaly Kuznetsov Cc: Paolo Bonzini Signed-off-by: Claudio Fontana Message-Id: <20210603123001.17843-2-cfontana@suse.de> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 79 +++++++++++++++++++++++++-------------- target/i386/kvm/kvm-cpu.c | 12 +++++- 2 files changed, 61 insertions(+), 30 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e0ba36cc23..9c47daa409 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6089,39 +6089,17 @@ static void x86_cpu_realizefn(DeviceState *dev, Err= or **errp) Error *local_err =3D NULL; static bool ht_warned; =20 - /* Process Hyper-V enlightenments */ - x86_cpu_hyperv_realize(cpu); - - cpu_exec_realizefn(cs, &local_err); - if (local_err !=3D NULL) { - error_propagate(errp, local_err); - return; - } - - if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { - g_autofree char *name =3D x86_cpu_class_get_model_name(xcc); - error_setg(&local_err, "CPU model '%s' requires KVM or HVF", name); - goto out; - } - - if (cpu->ucode_rev =3D=3D 0) { - /* The default is the same as KVM's. */ - if (IS_AMD_CPU(env)) { - cpu->ucode_rev =3D 0x01000065; - } else { - cpu->ucode_rev =3D 0x100000000ULL; - } - } - - /* mwait extended info: needed for Core compatibility */ - /* We always wake on interrupt even if host does not have the capabili= ty */ - cpu->mwait.ecx |=3D CPUID_MWAIT_EMX | CPUID_MWAIT_IBE; - if (cpu->apic_id =3D=3D UNASSIGNED_APIC_ID) { error_setg(errp, "apic-id property was not initialized properly"); return; } =20 + /* + * Process Hyper-V enlightenments. + * Note: this currently has to happen before the expansion of CPU feat= ures. + */ + x86_cpu_hyperv_realize(cpu); + x86_cpu_expand_features(cpu, &local_err); if (local_err) { goto out; @@ -6146,11 +6124,56 @@ static void x86_cpu_realizefn(DeviceState *dev, Err= or **errp) & CPUID_EXT2_AMD_ALIASES); } =20 + /* + * note: the call to the framework needs to happen after feature expan= sion, + * but before the checks/modifications to ucode_rev, mwait, phys_bits. + * These may be set by the accel-specific code, + * and the results are subsequently checked / assumed in this function. + */ + cpu_exec_realizefn(cs, &local_err); + if (local_err !=3D NULL) { + error_propagate(errp, local_err); + return; + } + + if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { + g_autofree char *name =3D x86_cpu_class_get_model_name(xcc); + error_setg(&local_err, "CPU model '%s' requires KVM or HVF", name); + goto out; + } + + if (cpu->ucode_rev =3D=3D 0) { + /* + * The default is the same as KVM's. Note that this check + * needs to happen after the evenual setting of ucode_rev in + * accel-specific code in cpu_exec_realizefn. + */ + if (IS_AMD_CPU(env)) { + cpu->ucode_rev =3D 0x01000065; + } else { + cpu->ucode_rev =3D 0x100000000ULL; + } + } + + /* + * mwait extended info: needed for Core compatibility + * We always wake on interrupt even if host does not have the capabili= ty. + * + * requires the accel-specific code in cpu_exec_realizefn to + * have already acquired the CPUID data into cpu->mwait. + */ + cpu->mwait.ecx |=3D CPUID_MWAIT_EMX | CPUID_MWAIT_IBE; + /* For 64bit systems think about the number of physical bits to presen= t. * ideally this should be the same as the host; anything other than ma= tching * the host can cause incorrect guest behaviour. * QEMU used to pick the magic value of 40 bits that corresponds to * consumer AMD devices but nothing else. + * + * Note that this code assumes features expansion has already been done + * (as it checks for CPUID_EXT2_LM), and also assumes that potential + * phys_bits adjustments to match the host have been already done in + * accel-specific code in cpu_exec_realizefn. */ if (env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM) { if (cpu->phys_bits && diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 5235bce8dc..00369c2000 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -26,10 +26,18 @@ static bool kvm_cpu_realizefn(CPUState *cs, Error **err= p) /* * The realize order is important, since x86_cpu_realize() checks if * nothing else has been set by the user (or by accelerators) in - * cpu->ucode_rev and cpu->phys_bits. + * cpu->ucode_rev and cpu->phys_bits, and updates the CPUID results in + * mwait.ecx. + * This accel realization code also assumes cpu features are already e= xpanded. * * realize order: - * kvm_cpu -> host_cpu -> x86_cpu + * + * x86_cpu_realize(): + * -> x86_cpu_expand_features() + * -> cpu_exec_realizefn(): + * -> accel_cpu_realizefn() + * kvm_cpu_realizefn() -> host_cpu_realizefn() + * -> check/update ucode_rev, phys_bits, mwait */ if (cpu->max_features) { if (enable_cpu_pm && kvm_has_waitpkg()) { --=20 2.31.1 From nobody Sun May 5 23:45:33 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622820090; cv=none; d=zohomail.com; s=zohoarc; b=VkA7Mrv5eZ/rFDlb+KiEeS0VAI4DBt7X6cKKPmNL5I+U5H+ws3x40O8x4hX/AXyTmGPoGTNgBX0kp6IPVF5pZb9tqxPGAtR62ZT3ZvRvJ7mwuwPUEWtfiR+x1yeIYsII94hM+UMb4VFA8dl+t0B/g5P/WDOP4AyS2b3gBxWZKhs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622820090; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5lZVa84k/MvyKy7frnCC2iZBSdkqkWY1cW0Ht1J4K5w=; b=cZvj7RaKQDO7F5mNRVh2x3Y2rTOvdChPT8Gv2jXJDxjcqSkVo7HUoMXwyvvHG4IE8QYq3sYOnr4Tr/GFxktzX0VxcMihsym/nEXh81q88bqAX5bfhYQrXWvudBFZkWNrG4dMdIgq8Ya1VWEAm/LT646d6QSqV5ysDudWtcWNipk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 16228200903185.07147265272431; Fri, 4 Jun 2021 08:21:30 -0700 (PDT) Received: from localhost ([::1]:33272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpBdY-0007xL-Rs for importer2@patchew.org; Fri, 04 Jun 2021 11:21:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpBa9-0007za-S7 for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:57 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:45828) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpBa8-0008Hi-7c for qemu-devel@nongnu.org; Fri, 04 Jun 2021 11:17:57 -0400 Received: by mail-ej1-x62d.google.com with SMTP id k7so15010299ejv.12 for ; Fri, 04 Jun 2021 08:17:55 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id w1sm2402451eds.37.2021.06.04.08.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 08:17:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5lZVa84k/MvyKy7frnCC2iZBSdkqkWY1cW0Ht1J4K5w=; b=VquZw9fy4QxVjLzRc9nqLnngYH8t+1oXdTDWrlLkcRgZYINiWBsO563tDilTLi9ARE y+5TlLyxUTMeDr8D4nIuFJsUwLiSkeKcixrI18CXgAWOPT0v/ydeHX0wcOl2arDwa+rW 1nj/cM57+sJvsJg7vJZevahtkGREz4E25YfsAC/J+jU8veT6y0Hg4OmXb7E92RJDtGZl QaDzWSyoWXp9R9soEOPxNP2iIoB4YhYbyeCI1egignNcQdkGMYa70F9nOr3l1c3mN4Xr wY7VpM2Nmnb8dH8jvyt3yeVZMlqGScasv9lMXdNq6cUvGh5D3qj6yIB1ub/kkY+kZRS3 FtfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=5lZVa84k/MvyKy7frnCC2iZBSdkqkWY1cW0Ht1J4K5w=; b=f7q1qK14fS8As7ibaitmamDjoFFd6hA5giORagwA9L8FQnri+x0Rb/l10J1Txjy7ld XnBAlppz7j1r6aQv7y9kO3WuOqkTxNk/fCTyN99ATLteEaRtr691Qtq7sNYvjpSaef7d Ez8inPxViAV+7GVYkb3Camq7AtDpFYC3/Dzws2vx1OTIkA+WVlg8DHTd0GSzGpCNN3pm GgJlXubZi2zHNQ9M8YQQQrRSr3sCgFfCMJrpp1+SnRIQiFGBFPJiHxsWyYgUbpImhJ1f oOZ2/GVxglKDGDmcE/aYVLTyL9dZsakvTI95JKAz+Q0wDN2s5NoK/IIWj7SjCC5AvIjZ Q9Nw== X-Gm-Message-State: AOAM533Pcj67w2+YyVkrl42gqZvh2hC0805N+HpHHOyFEsICYAFC1dsH p342Fp9Kd1VRxE70zf/JS3By76lT9MAbGQ== X-Google-Smtp-Source: ABdhPJx+KIMqF6lMxABNHR19XT7yhuKm60gWY+oSw9Gz7bqAkk6n3nQoZ4iJoOLCA5Z2WgRh41EK3g== X-Received: by 2002:a17:906:1401:: with SMTP id p1mr4562715ejc.526.1622819874848; Fri, 04 Jun 2021 08:17:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 10/13] i386: run accel_cpu_instance_init as post_init Date: Fri, 4 Jun 2021 17:17:42 +0200 Message-Id: <20210604151745.310318-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210604151745.310318-1-pbonzini@redhat.com> References: <20210604151745.310318-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62d.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Claudio Fontana , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Claudio Fontana This fixes host and max cpu initialization, by running the accel cpu initialization only after all instance init functions are called for all X86 cpu subclasses. The bug this is fixing is related to the "max" and "host" i386 cpu subclasses, which set cpu->max_features, which is then used at cpu realization time. In order to properly split the accel-specific max features code that needs to be executed at cpu instance initialization time, we cannot call the accel cpu initialization at the end of the x86 base class initialization, or we will have no way to specialize "max features" cpu behavior, overriding the "max" cpu class defaults, and checking for the "max features" flag itself. This patch moves the accel-specific cpu instance initialization to after all x86 cpu instance code has been executed, including subclasses, so that proper initialization of cpu "host" and "max" can be restored. Fixes: f5cc5a5c ("i386: split cpu accelerators from cpu.c,"...) Cc: Eduardo Habkost Cc: Paolo Bonzini Signed-off-by: Claudio Fontana Message-Id: <20210603123001.17843-3-cfontana@suse.de> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 9c47daa409..a9fe1662d3 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6401,6 +6401,11 @@ static void x86_cpu_register_feature_bit_props(X86CP= UClass *xcc, x86_cpu_register_bit_prop(xcc, name, w, bitnr); } =20 +static void x86_cpu_post_initfn(Object *obj) +{ + accel_cpu_instance_init(CPU(obj)); +} + static void x86_cpu_initfn(Object *obj) { X86CPU *cpu =3D X86_CPU(obj); @@ -6452,9 +6457,6 @@ static void x86_cpu_initfn(Object *obj) if (xcc->model) { x86_cpu_load_model(cpu, xcc->model); } - - /* if required, do accelerator-specific cpu initializations */ - accel_cpu_instance_init(CPU(obj)); } =20 static int64_t x86_cpu_get_arch_id(CPUState *cs) @@ -6799,6 +6801,8 @@ static const TypeInfo x86_cpu_type_info =3D { .parent =3D TYPE_CPU, .instance_size =3D sizeof(X86CPU), .instance_init =3D x86_cpu_initfn, + .instance_post_init =3D x86_cpu_post_initfn, + .abstract =3D true, .class_size =3D sizeof(X86CPUClass), .class_init =3D x86_cpu_common_class_init, --=20 2.31.1 From nobody Sun May 5 23:45:33 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622820091; cv=none; d=zohomail.com; s=zohoarc; b=L3KtsBABAPx+QZTg6lW6Vt4JefTWhz6sBpF2/ffx71WaalSBC70fg7FpvHZLavGOvh2HG+OVmniO8j+4ZqTL3sBR8JvP29KojszESBVqctN21Z6nkEYYiM6IbM3PhIm4AgunFCIfIYrRb2bTglEJ2tLMzK3Pa/HqmRBT45UIQYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622820091; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dNi3topMZw89OzAsrDsdP+OQx4KvSJzUkrYz+68S+zo=; b=gB23RCexA46j8wpS6de5ZSSckIIAANKgbTQMdMVb5vp5updjbNBf8dM0TIUeE5noetf4+I4TNwB/lFdrwy2cUhfWT+yTonbxs9zYBHYR+lRhxAVIWnR3PdEcjf6kG/hueHTvjNtb4QwC/rLrYBB57Yac38ZUZK11CtyoFw5Ffik= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1622820091492405.03894026744354; Fri, 4 Jun 2021 08:21:31 -0700 (PDT) Received: from localhost ([::1]:33236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpBda-0007wc-C7 for importer2@patchew.org; Fri, 04 Jun 2021 11:21:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpBaB-00086n-JO; Fri, 04 Jun 2021 11:17:59 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:34322) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpBa9-0008I2-Hs; Fri, 04 Jun 2021 11:17:59 -0400 Received: by mail-ej1-x633.google.com with SMTP id g8so15115021ejx.1; Fri, 04 Jun 2021 08:17:56 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id w1sm2402451eds.37.2021.06.04.08.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 08:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dNi3topMZw89OzAsrDsdP+OQx4KvSJzUkrYz+68S+zo=; b=egIoCINNjOFaIPWYMQLaL9uSqv+DrVt8GxjRRjsico6vpxwK26cWcEHJ0upKSYLkCX Fkuj3Qor25QbiFvvgUcmehUk/XmsGJCyK37WDtZN6IELOXja4ctR4lMcJ8fGk1VTpngu 5L1STtgeman2Uzt++id0uJk2koXIgAPmeEJt7LptT8t4lJ3L8Ftmx4sr57crO68d67oQ 2+gIg+OCueBAr1zlYRGoLDF8yEZ82Sxtsp/2rpWYu//LiCn2eRMy+Ls+qcN0IdUqMwFi YFt5K8FP6ooHP9x51e2QIWUjwhdWwTcMe2ppyVEZOx5nA7mPssSSJwoo2jvEKCmw5gPG oiqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=dNi3topMZw89OzAsrDsdP+OQx4KvSJzUkrYz+68S+zo=; b=lUl8j/lNEyZS6Mo+LhT+n/vPp3jIAqpJb1LylzxTzPqvmlYdduNRgEANVefnlwPIsE GZajeUQYvIsEE5xyBmhwI9A51rR6yvflnSBdGs1I0Ut2sKsU4TarUd65bxHLGjvx+64H V6TWUSCaCtZGZpKHt2n98ssPSBQ6X4omxlhl0NE2enNvfHsDHFVyoCux6Esm3F0AkjdX ZTqLvChkTNZiSg9Nc8nLs6ZpR8xBC4n8XBvIPimbN6aHMOk3Xn+WeoIOMEBkV+rvbDYf matKjiGxVl/2O3O+QPnX/A3rmv4fAwju18TkTns8/8CK/vToGh/igiVCmvaNdj0vsVbT 3gQA== X-Gm-Message-State: AOAM5316FGnpA4KhvJZbhFrQCuo455p2fKhL8RHuZDbq/6e7NZ+HYx2P KRJ0ZOHP2SCAFbbLBzKgcvmAEwGeo96smw== X-Google-Smtp-Source: ABdhPJwAIjKGegPhJuEpbac2FYu3CaVPP3+hWAJsGem1lCyJshktVlADmQZQy7V4mR7dWtqmU6ZQSg== X-Received: by 2002:a17:906:6dc5:: with SMTP id j5mr4572611ejt.364.1622819875803; Fri, 04 Jun 2021 08:17:55 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 11/13] qemu-config: parse configuration files to a QDict Date: Fri, 4 Jun 2021 17:17:43 +0200 Message-Id: <20210604151745.310318-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210604151745.310318-1-pbonzini@redhat.com> References: <20210604151745.310318-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x633.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Kevin Wolf , Markus Armbruster , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Change the parser to put the values into a QDict and pass them to a callback. qemu_config_parse's QemuOpts creation is itself turned into a callback function. This is useful for -readconfig to support keyval-based options; getting a QDict from the parser removes a roundtrip from QDict to QemuOpts and then back to QDict. Unfortunately there is a disadvantage in that semantic errors will point to the last line of the group, because the entries of the QDict do not have a location attached. Cc: Kevin Wolf Cc: Markus Armbruster Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini Message-Id: <20210524105752.3318299-2-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini --- include/qemu/config-file.h | 7 ++- softmmu/vl.c | 4 +- util/qemu-config.c | 98 ++++++++++++++++++++++++++------------ 3 files changed, 76 insertions(+), 33 deletions(-) diff --git a/include/qemu/config-file.h b/include/qemu/config-file.h index 0500b3668d..f605423321 100644 --- a/include/qemu/config-file.h +++ b/include/qemu/config-file.h @@ -1,6 +1,8 @@ #ifndef QEMU_CONFIG_FILE_H #define QEMU_CONFIG_FILE_H =20 +typedef void QEMUConfigCB(const char *group, QDict *qdict, void *opaque, E= rror **errp); + void qemu_load_module_for_opts(const char *group); QemuOptsList *qemu_find_opts(const char *group); QemuOptsList *qemu_find_opts_err(const char *group, Error **errp); @@ -14,7 +16,10 @@ void qemu_config_write(FILE *fp); int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname, Error **errp); =20 -int qemu_read_config_file(const char *filename, Error **errp); +/* A default callback for qemu_read_config_file(). */ +void qemu_config_do_parse(const char *group, QDict *qdict, void *opaque, E= rror **errp); + +int qemu_read_config_file(const char *filename, QEMUConfigCB *f, Error **e= rrp); =20 /* Parse QDict options as a replacement for a config file (allowing multip= le enumerated (0..(n-1)) configuration "sections") */ diff --git a/softmmu/vl.c b/softmmu/vl.c index 6054f6f0b9..47dfdd704f 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2133,7 +2133,7 @@ static void qemu_read_default_config_file(Error **err= p) int ret; g_autofree char *file =3D get_relocated_path(CONFIG_QEMU_CONFDIR "/qem= u.conf"); =20 - ret =3D qemu_read_config_file(file, errp); + ret =3D qemu_read_config_file(file, qemu_config_do_parse, errp); if (ret < 0) { if (ret =3D=3D -ENOENT) { error_free(*errp); @@ -3399,7 +3399,7 @@ void qemu_init(int argc, char **argv, char **envp) qemu_plugin_opt_parse(optarg, &plugin_list); break; case QEMU_OPTION_readconfig: - qemu_read_config_file(optarg, &error_fatal); + qemu_read_config_file(optarg, qemu_config_do_parse, &error= _fatal); break; case QEMU_OPTION_spice: olist =3D qemu_find_opts_err("spice", NULL); diff --git a/util/qemu-config.c b/util/qemu-config.c index 34974c4b47..374f3bc460 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -2,6 +2,7 @@ #include "block/qdict.h" /* for qdict_extract_subqdict() */ #include "qapi/error.h" #include "qapi/qapi-commands-misc.h" +#include "qapi/qmp/qerror.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qlist.h" #include "qemu/error-report.h" @@ -351,19 +352,19 @@ void qemu_config_write(FILE *fp) } =20 /* Returns number of config groups on success, -errno on error */ -int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname, E= rror **errp) +static int qemu_config_foreach(FILE *fp, QEMUConfigCB *cb, void *opaque, + const char *fname, Error **errp) { - char line[1024], group[64], id[64], arg[64], value[1024]; + char line[1024], prev_group[64], group[64], arg[64], value[1024]; Location loc; - QemuOptsList *list =3D NULL; Error *local_err =3D NULL; - QemuOpts *opts =3D NULL; + QDict *qdict =3D NULL; int res =3D -EINVAL, lno =3D 0; int count =3D 0; =20 loc_push_none(&loc); while (fgets(line, sizeof(line), fp) !=3D NULL) { - loc_set_file(fname, ++lno); + ++lno; if (line[0] =3D=3D '\n') { /* skip empty lines */ continue; @@ -372,39 +373,39 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists,= const char *fname, Error * /* comment */ continue; } - if (sscanf(line, "[%63s \"%63[^\"]\"]", group, id) =3D=3D 2) { - /* group with id */ - list =3D find_list(lists, group, &local_err); - if (local_err) { - error_propagate(errp, local_err); - goto out; + if (line[0] =3D=3D '[') { + QDict *prev =3D qdict; + if (sscanf(line, "[%63s \"%63[^\"]\"]", group, value) =3D=3D 2= ) { + qdict =3D qdict_new(); + qdict_put_str(qdict, "id", value); + count++; + } else if (sscanf(line, "[%63[^]]]", group) =3D=3D 1) { + qdict =3D qdict_new(); + count++; } - opts =3D qemu_opts_create(list, id, 1, NULL); - count++; - continue; - } - if (sscanf(line, "[%63[^]]]", group) =3D=3D 1) { - /* group without id */ - list =3D find_list(lists, group, &local_err); - if (local_err) { - error_propagate(errp, local_err); - goto out; + if (qdict !=3D prev) { + if (prev) { + cb(prev_group, prev, opaque, &local_err); + qobject_unref(prev); + if (local_err) { + error_propagate(errp, local_err); + goto out; + } + } + strcpy(prev_group, group); + continue; } - opts =3D qemu_opts_create(list, NULL, 0, &error_abort); - count++; - continue; } + loc_set_file(fname, lno); value[0] =3D '\0'; if (sscanf(line, " %63s =3D \"%1023[^\"]\"", arg, value) =3D=3D 2 = || sscanf(line, " %63s =3D \"\"", arg) =3D=3D 1) { /* arg =3D value */ - if (opts =3D=3D NULL) { + if (qdict =3D=3D NULL) { error_setg(errp, "no group defined"); goto out; } - if (!qemu_opt_set(opts, arg, value, errp)) { - goto out; - } + qdict_put_str(qdict, arg, value); continue; } error_setg(errp, "parse error"); @@ -417,11 +418,48 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists,= const char *fname, Error * } res =3D count; out: + if (qdict) { + cb(group, qdict, opaque, errp); + qobject_unref(qdict); + } loc_pop(&loc); return res; } =20 -int qemu_read_config_file(const char *filename, Error **errp) +void qemu_config_do_parse(const char *group, QDict *qdict, void *opaque, E= rror **errp) +{ + QemuOptsList **lists =3D opaque; + const char *id =3D qdict_get_try_str(qdict, "id"); + QemuOptsList *list; + QemuOpts *opts; + const QDictEntry *unrecognized; + + list =3D find_list(lists, group, errp); + if (!list) { + return; + } + + opts =3D qemu_opts_create(list, id, 1, errp); + if (!opts) { + return; + } + if (!qemu_opts_absorb_qdict(opts, qdict, errp)) { + qemu_opts_del(opts); + return; + } + unrecognized =3D qdict_first(qdict); + if (unrecognized) { + error_setg(errp, QERR_INVALID_PARAMETER, unrecognized->key); + qemu_opts_del(opts); + } +} + +int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname, E= rror **errp) +{ + return qemu_config_foreach(fp, qemu_config_do_parse, lists, fname, err= p); +} + +int qemu_read_config_file(const char *filename, QEMUConfigCB *cb, Error **= errp) { FILE *f =3D fopen(filename, "r"); int ret; @@ -431,7 +469,7 @@ int qemu_read_config_file(const char *filename, Error *= *errp) return -errno; } =20 - ret =3D qemu_config_parse(f, vm_config_groups, filename, errp); + ret =3D qemu_config_foreach(f, cb, vm_config_groups, filename, errp); fclose(f); return ret; } --=20 2.31.1 From nobody Sun May 5 23:45:33 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622820181; cv=none; d=zohomail.com; s=zohoarc; b=MBXrvogT1xoE/Jmw2WFsUl4Wlvd2FW9Pt8fhwxGmujUhgK+ilcU7FsXAau1YDeAwNb1syOoFV1zr5Unssn74GDaZLXkFSnfr/ZzheZOOweMvBptrUm58tqiUQ/ABD96bFVin64gAP0fkvyhGP5p2/2pzK2Fapn8ubhCtfQYaRgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622820181; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oFqBe5Si9TWJa68gmcXzEchOG2Rmu1HDBWLCVFaVceg=; b=POfEfzufK5p8n7wiTo4V1UaIn86cHerNvNHKw7F7J+dg6OdUUQR2ezVO/6i9s/k8gwGedn+9Ll/SQfAY4fYhO+eCJuK9UFUsq3Pq/zFRgbPPou3rgS5+PtSpoVOaSI3HYVRkAd+Bl7tsJNvW3q9t7geqtZ1vSlQcFKMiBKMEM68= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1622820181233217.85792382140767; Fri, 4 Jun 2021 08:23:01 -0700 (PDT) Received: from localhost ([::1]:40820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpBf1-0004ff-Vx for importer2@patchew.org; Fri, 04 Jun 2021 11:23:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpBaC-00089t-9v; Fri, 04 Jun 2021 11:18:00 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:37378) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpBaA-0008IQ-F6; Fri, 04 Jun 2021 11:17:59 -0400 Received: by mail-ed1-x535.google.com with SMTP id b11so11595020edy.4; Fri, 04 Jun 2021 08:17:57 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id w1sm2402451eds.37.2021.06.04.08.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 08:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oFqBe5Si9TWJa68gmcXzEchOG2Rmu1HDBWLCVFaVceg=; b=q3ROnY16FFDc3CiWg4wwZm67FAHLU+Mt+vKIuCcgvXPxHHLKRB4NoYdVTVsbvHxLGH sdCw4Dtif5FO2B/vsP1bdjxxILgQOLxRXmq6vooUoH61aSsE2B8k0z7IVZwzGajHuQgy bpecPeJVih/YliYeDqQfM7EREABwSj1+R1alXWDPQvRvXxHhAfh1rFZOvQCN/CMSQkDQ 8D0hB2jZXQ4/Wyk+Ly/hlUEHly9A4X4DVRx0eg1faY8Jhi7Je5GVrhQGzEIIecWjvz4s yEbxnzT3cZajVedyor8dmz/nkIzWkdBDzEs+/eVKhTB8kMvYyE7YwX4sBO//PmvQRl8z souQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=oFqBe5Si9TWJa68gmcXzEchOG2Rmu1HDBWLCVFaVceg=; b=MXFSneciv7/1JqhnFJt0qCdRhVYE+1iRdxVSJdoko07F3zkcqk3VN/m2Jocz4RoV3u KBRCEa/a/qTXwOP0EIEceQ/gDJX2IdUS8GXGwEOsAcV0wMlgEyfbMc+5vSXmRE/+I2p1 ikjjAeuSnbSzMT9K/1t4BmfBoTL95nbAv+/qIuQelVWQiae1takmCCoHh0SPkT5SCaFj aMf8sNrIfl5bqjEGYxEepuR9LDS3IhwJZWPtI/iXs7WBoOaXsc75K1kyCw4d/wRuPrua JOP95RcGeP14GW9UW8+2nFbxstq86e2VgfSsR0tiFps9SQqeHPmYzTfTpEgX0LfHenUS obKg== X-Gm-Message-State: AOAM5305wslCVCdeQ2ZtomYsOLAzmIPSb3gIJW6LeKOwOX60/0EA1tu/ dAnlz9Hpa+yViPY9m/75JcaHMfLTzTJR4w== X-Google-Smtp-Source: ABdhPJywkkZsEzm9G0kd/HMX7xZBgN8bm/QKEHY5AHFzrVio6ppN6IBM0kHQYx90pOSNVdo3FAA6ZQ== X-Received: by 2002:a05:6402:b17:: with SMTP id bm23mr5165308edb.236.1622819876729; Fri, 04 Jun 2021 08:17:56 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 12/13] vl: plumb keyval-based options into -readconfig Date: Fri, 4 Jun 2021 17:17:44 +0200 Message-Id: <20210604151745.310318-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210604151745.310318-1-pbonzini@redhat.com> References: <20210604151745.310318-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x535.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Kevin Wolf , Markus Armbruster , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Let -readconfig support parsing command line options into QDict or QemuOpts. This will be used to add back support for objects in -readconfig. Cc: Markus Armbruster Cc: qemu-stable@nongnu.org Reviewed-by: Kevin Wolf Signed-off-by: Paolo Bonzini Message-Id: <20210524105752.3318299-3-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini --- include/block/qdict.h | 2 - include/qapi/qmp/qdict.h | 3 ++ softmmu/vl.c | 83 ++++++++++++++++++++++++++++------------ 3 files changed, 62 insertions(+), 26 deletions(-) diff --git a/include/block/qdict.h b/include/block/qdict.h index d8cb502d7d..ced2acfb92 100644 --- a/include/block/qdict.h +++ b/include/block/qdict.h @@ -20,8 +20,6 @@ void qdict_join(QDict *dest, QDict *src, bool overwrite); void qdict_extract_subqdict(QDict *src, QDict **dst, const char *start); void qdict_array_split(QDict *src, QList **dst); int qdict_array_entries(QDict *src, const char *subqdict); -QObject *qdict_crumple(const QDict *src, Error **errp); -void qdict_flatten(QDict *qdict); =20 typedef struct QDictRenames { const char *from; diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index 9934539c1b..d5b5430e21 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -64,4 +64,7 @@ const char *qdict_get_try_str(const QDict *qdict, const c= har *key); =20 QDict *qdict_clone_shallow(const QDict *src); =20 +QObject *qdict_crumple(const QDict *src, Error **errp); +void qdict_flatten(QDict *qdict); + #endif /* QDICT_H */ diff --git a/softmmu/vl.c b/softmmu/vl.c index 47dfdd704f..5e8240b9d8 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -121,6 +121,7 @@ #include "qapi/qapi-commands-misc.h" #include "qapi/qapi-visit-qom.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "sysemu/iothread.h" #include "qemu/guest-random.h" @@ -2127,13 +2128,53 @@ static int global_init_func(void *opaque, QemuOpts = *opts, Error **errp) return 0; } =20 +/* + * Return whether configuration group @group is stored in QemuOpts, or + * recorded as one or more QDicts by qemu_record_config_group. + */ +static bool is_qemuopts_group(const char *group) +{ + return true; +} + +static void qemu_record_config_group(const char *group, QDict *dict, + bool from_json, Error **errp) +{ + abort(); +} + +/* + * Parse non-QemuOpts config file groups, pass the rest to + * qemu_config_do_parse. + */ +static void qemu_parse_config_group(const char *group, QDict *qdict, + void *opaque, Error **errp) +{ + QObject *crumpled; + if (is_qemuopts_group(group)) { + qemu_config_do_parse(group, qdict, opaque, errp); + return; + } + + crumpled =3D qdict_crumple(qdict, errp); + if (!crumpled) { + return; + } + if (qobject_type(crumpled) !=3D QTYPE_QDICT) { + assert(qobject_type(crumpled) =3D=3D QTYPE_QLIST); + error_setg(errp, "Lists cannot be at top level of a configuration = section"); + return; + } + qemu_record_config_group(group, qobject_to(QDict, crumpled), false, er= rp); +} + static void qemu_read_default_config_file(Error **errp) { ERRP_GUARD(); int ret; g_autofree char *file =3D get_relocated_path(CONFIG_QEMU_CONFDIR "/qem= u.conf"); =20 - ret =3D qemu_read_config_file(file, qemu_config_do_parse, errp); + ret =3D qemu_read_config_file(file, qemu_parse_config_group, errp); if (ret < 0) { if (ret =3D=3D -ENOENT) { error_free(*errp); @@ -2142,9 +2183,8 @@ static void qemu_read_default_config_file(Error **err= p) } } =20 -static int qemu_set_option(const char *str) +static void qemu_set_option(const char *str, Error **errp) { - Error *local_err =3D NULL; char group[64], id[64], arg[64]; QemuOptsList *list; QemuOpts *opts; @@ -2152,27 +2192,23 @@ static int qemu_set_option(const char *str) =20 rc =3D sscanf(str, "%63[^.].%63[^.].%63[^=3D]%n", group, id, arg, &off= set); if (rc < 3 || str[offset] !=3D '=3D') { - error_report("can't parse: \"%s\"", str); - return -1; - } - - list =3D qemu_find_opts(group); - if (list =3D=3D NULL) { - return -1; - } - - opts =3D qemu_opts_find(list, id); - if (!opts) { - error_report("there is no %s \"%s\" defined", - list->name, id); - return -1; + error_setg(errp, "can't parse: \"%s\"", str); + return; } =20 - if (!qemu_opt_set(opts, arg, str + offset + 1, &local_err)) { - error_report_err(local_err); - return -1; + if (!is_qemuopts_group(group)) { + error_setg(errp, "-set is not supported with %s", group); + } else { + list =3D qemu_find_opts_err(group, errp); + if (list) { + opts =3D qemu_opts_find(list, id); + if (!opts) { + error_setg(errp, "there is no %s \"%s\" defined", group, i= d); + return; + } + qemu_opt_set(opts, arg, str + offset + 1, errp); + } } - return 0; } =20 static void user_register_global_props(void) @@ -2766,8 +2802,7 @@ void qemu_init(int argc, char **argv, char **envp) } break; case QEMU_OPTION_set: - if (qemu_set_option(optarg) !=3D 0) - exit(1); + qemu_set_option(optarg, &error_fatal); break; case QEMU_OPTION_global: if (qemu_global_option(optarg) !=3D 0) @@ -3399,7 +3434,7 @@ void qemu_init(int argc, char **argv, char **envp) qemu_plugin_opt_parse(optarg, &plugin_list); break; case QEMU_OPTION_readconfig: - qemu_read_config_file(optarg, qemu_config_do_parse, &error= _fatal); + qemu_read_config_file(optarg, qemu_parse_config_group, &er= ror_fatal); break; case QEMU_OPTION_spice: olist =3D qemu_find_opts_err("spice", NULL); --=20 2.31.1 From nobody Sun May 5 23:45:33 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622820179; cv=none; d=zohomail.com; s=zohoarc; b=JeufeLfo0zvc88utWVUjmUNrQEko7N2QOBpc8i3WQR8ipl1YBtbOARcmZ+pIJ7YfRzM5gb0Tb+5y5w7ZDODcf2eJkrukT3BMISOHaMxz3z00Sl5jy/0Vh5THBNcG6xSG15RVrbOSiSRCegI3TGXvJCgp1xR4hzX/YsGOwOGi7WA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622820179; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hMO3rWRVi2QUNYgD6FmPDbeKJ7JN3j43s7wZ/c1R3mA=; b=iUIawBiVDs3/8U5hFi2oMcjosoPVj/IRRyq6w3pzttF42fLf8XQizVyc34GXvwROrmapPoEY2jgKUl+xZ1SBDtERKZT9FCIfINV5owxPn6C8hxg3u2g6RRiiJy92SHMcdTbM3P8FEHrLJTL4BgtAtThznbo2I6ViVFQePHwdmRc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1622820179531748.0564154681172; Fri, 4 Jun 2021 08:22:59 -0700 (PDT) Received: from localhost ([::1]:40742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpBf0-0004cm-IK for importer2@patchew.org; Fri, 04 Jun 2021 11:22:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpBaC-0008Cc-W4; Fri, 04 Jun 2021 11:18:01 -0400 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:41666) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpBaB-0008JW-9R; Fri, 04 Jun 2021 11:18:00 -0400 Received: by mail-ed1-x52f.google.com with SMTP id g18so9577804edq.8; Fri, 04 Jun 2021 08:17:58 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id w1sm2402451eds.37.2021.06.04.08.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 08:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hMO3rWRVi2QUNYgD6FmPDbeKJ7JN3j43s7wZ/c1R3mA=; b=DXuNSo0Xr1WW15NciK8cf88vpyFlbUCnDyqgXrzJaK4gp5/6f2vfaadBxH7lCGDu6X 4d9IiJVw1iErEhM2Kd3+9JUo87V4abDjCWbf6631Uru449D70PM4K4uWTnCkoUuqGqa0 gX6FqpQAZVgdHX2PPB2IhbaKeC+DloAX4BKZtqJAo0wVo6Pst3GefFxUExTS4CTsB/Gu qlpfW7tWJXNNEh4cN2NDH/pW+uL73GoSZR3/53hSpMMPJ05gk4r2WqamzD3IjOjkqD3W dQp4CgXYKos7xCWJnGBoDCezktbpCFkmUfrfaW6IJjzSpkFZedfOBazzttr+VlkNI3XT mKDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=hMO3rWRVi2QUNYgD6FmPDbeKJ7JN3j43s7wZ/c1R3mA=; b=KSZHn1Eo72jUgpRB2pt9h1DfhYGZfwYIEgiM+yy0ANxuUpRUgCTiZj+pMfDH2B2Y7N Fvtr8pIDgLm7du0DZovFAF0EuG0KkBcwy4+xFbDMiBtLTCLQgKw9KfB8PLgsNvoIMwwv f4tVG8ENXBCvxdsm2oBsfQbrvEWizPkJNDY0KKhQb6jcnYtA884Nz3Jn+7e3z//Gu/ZE E37vWlDuY/YeOx6D+2eNa9/j5oGDa8NQS9U9nRciJyjV5NGi5JtHpw45U2LQv/9jBNYc kVdI+Mlaj1kY3lGjcqEzxNDuuFFBXaKae+pXWEstEzs5SQPDJy5DFEPblTfdseCRbhlD kgaQ== X-Gm-Message-State: AOAM532QzzLcHUM0rSJzJC+OPogZ1qCzV2u3K1jLa4iE94noMnVw16pJ Y6Mr/gEeHmcxjc+J+uk4l8rfI41geErQjg== X-Google-Smtp-Source: ABdhPJyH/kRwBRNWsUIbbW0zt5q3gPMMDW/Yw6wFp9HpwaXc1spoJfqLWJmHOZnSix8X6RsOz+6/Hg== X-Received: by 2002:aa7:d14d:: with SMTP id r13mr5286111edo.212.1622819877591; Fri, 04 Jun 2021 08:17:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 13/13] vl: plug -object back into -readconfig Date: Fri, 4 Jun 2021 17:17:45 +0200 Message-Id: <20210604151745.310318-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210604151745.310318-1-pbonzini@redhat.com> References: <20210604151745.310318-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52f; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52f.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Kevin Wolf , Markus Armbruster , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Commit bc2f4fcb1d ("qom: move user_creatable_add_opts logic to vl.c and QAPIfy it", 2021-03-19) switched the creation of objects from qemu_opts_foreach to a bespoke QTAILQ in preparation for supporting JSON syntax in -object. Unfortunately in doing so it lost support for [object] stanzas in configuration files and also for "-set object.ID.KEY=3DVAL". The latter is hard to re-establish and probably best solved by deprecating -set. This patch uses the infrastructure introduced by the previous two patches in order to parse QOM objects correctly from configuration files. Cc: Markus Armbruster Cc: qemu-stable@nongnu.org Reviewed-by: Kevin Wolf Signed-off-by: Paolo Bonzini Message-Id: <20210524105752.3318299-4-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 5e8240b9d8..326c1e9080 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1722,9 +1722,15 @@ static void object_option_foreach_add(bool (*type_op= t_predicate)(const char *)) } } =20 +static void object_option_add_visitor(Visitor *v) +{ + ObjectOption *opt =3D g_new0(ObjectOption, 1); + visit_type_ObjectOptions(v, NULL, &opt->opts, &error_fatal); + QTAILQ_INSERT_TAIL(&object_opts, opt, next); +} + static void object_option_parse(const char *optarg) { - ObjectOption *opt; QemuOpts *opts; const char *type; Visitor *v; @@ -1752,11 +1758,8 @@ static void object_option_parse(const char *optarg) v =3D opts_visitor_new(opts); } =20 - opt =3D g_new0(ObjectOption, 1); - visit_type_ObjectOptions(v, NULL, &opt->opts, &error_fatal); + object_option_add_visitor(v); visit_free(v); - - QTAILQ_INSERT_TAIL(&object_opts, opt, next); } =20 /* @@ -2134,13 +2137,22 @@ static int global_init_func(void *opaque, QemuOpts = *opts, Error **errp) */ static bool is_qemuopts_group(const char *group) { + if (g_str_equal(group, "object")) { + return false; + } return true; } =20 static void qemu_record_config_group(const char *group, QDict *dict, bool from_json, Error **errp) { - abort(); + if (g_str_equal(group, "object")) { + Visitor *v =3D qobject_input_visitor_new_keyval(QOBJECT(dict)); + object_option_add_visitor(v); + visit_free(v); + } else { + abort(); + } } =20 /* --=20 2.31.1