From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624630949228340.40711181236554; Fri, 25 Jun 2021 07:22:29 -0700 (PDT) Received: from localhost ([::1]:37846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmiy-000355-3l for importer@patchew.org; Fri, 25 Jun 2021 10:22:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmf7-0002r6-FU for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:29 -0400 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]:34791) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmf5-00037g-72 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:29 -0400 Received: by mail-ej1-x62a.google.com with SMTP id hz1so15401287ejc.1 for ; Fri, 25 Jun 2021 07:18:26 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:24 -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=nv0ACy0+Eum8qUTT1PI/Lvp1yQqi/xZRGLjc430QOSY=; b=udDyx2JNrDKXoGqenNS8ya2t4SQNFMP1D1udgDF0T4oLw6duBkcD03szO75sDeQ2nH c6oDfjdnVdL0H3asTO2a6MTc4OLoKqajLhgXmjxm2jv85pKI95AJeeGOwUm8AMwg5fJn qLM2kyVaYsT/2d0f57iocCLALPqXNOMFoc8HCxsJa5c9+JwKXeCx1pmIgTNp2G6lXFr6 cQePEEICdn4DewLTBtICLm1LMQJXV6bUcCvsIN4lf5JRs/U+vtywCrKCkC/vuOJGP6ZK 96cpJxVcmq5eh5vUj3iWHoyGp0TwrzuSZzkNBRh/wYGRYtSU27IN5t6/Otu1dJuYd6rx tRTA== 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=nv0ACy0+Eum8qUTT1PI/Lvp1yQqi/xZRGLjc430QOSY=; b=hNDrzzsSOayE0DMWZ7TXyyNOYKuQAjx1n25NjTnoFQvK25KrPo3JhqompEW6Na95LE Xf1VohWYLiLmMIVh0nMyRT22QGr2K6qx+SAnogX8/LQYpW1HRSmEtonAJJoPyHDm59lc 4QTKDbD2kJ6+tqnAKZwXpuwfIaN8IzJWNK5t/HvBuERfQFNdMBiOd0yXSyERKYPXgNph n+cAz6ty7aFAeqMcNBtWSStfamJNNOWoH+Yi32Ggr/NpFwPb89aKDbczSdGEx3GM1XLe f6z5Fp3m8MwKNdtMEzZdrcLr9t/oxGvx+iorevbKq3xE0fL6XUPL3/W1YJQZA3OwyNpU d08g== X-Gm-Message-State: AOAM532Vo53pmdKJcQ8EJs9vB2m13/f3RMiPxz1OPkk8+aEbzfa3WGiy Jl0Byu6WUJNRGLy3aXMNb358+s6Yr/A= X-Google-Smtp-Source: ABdhPJwnlzj1zzk2IBZS61ROvKTe3YW+wC2dN9e5qa/ju8Ae6jgVDRKU2aYO7086B5cqFauaYUtGGg== X-Received: by 2002:a17:906:dbd8:: with SMTP id yc24mr11178881ejb.55.1624630704926; Fri, 25 Jun 2021 07:18:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 01/28] target/i386: kvm: add support for TSC scaling Date: Fri, 25 Jun 2021 16:17:55 +0200 Message-Id: <20210625141822.1368639-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62a.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Linux 5.14 will add support for nested TSC scaling. Add the corresponding feature in QEMU; to keep support for existing kernels, do not add it to any processor yet. The handling of the VMCS enumeration MSR is ugly; once we have more than one case, we may want to add a table to check VMX features against. Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 2 +- target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 12 ++++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index a9fe1662d3..d8f3ab3192 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1031,7 +1031,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { "vmx-invpcid-exit", "vmx-vmfunc", "vmx-shadow-vmcs", "vmx-encl= s-exit", "vmx-rdseed-exit", "vmx-pml", NULL, NULL, "vmx-xsaves", NULL, NULL, NULL, - NULL, NULL, NULL, NULL, + NULL, "vmx-tsc-scaling", NULL, NULL, NULL, NULL, NULL, NULL, }, .msr =3D { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 1e11071d81..f7fa5870b1 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -972,6 +972,7 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS]; #define VMX_SECONDARY_EXEC_RDSEED_EXITING 0x00010000 #define VMX_SECONDARY_EXEC_ENABLE_PML 0x00020000 #define VMX_SECONDARY_EXEC_XSAVES 0x00100000 +#define VMX_SECONDARY_EXEC_TSC_SCALING 0x02000000 =20 #define VMX_PIN_BASED_EXT_INTR_MASK 0x00000001 #define VMX_PIN_BASED_NMI_EXITING 0x00000008 diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index ad950c3c27..04e4ec063f 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2700,8 +2700,6 @@ static uint64_t make_vmx_msr_value(uint32_t index, ui= nt32_t features) return must_be_one | (((uint64_t)can_be_one) << 32); } =20 -#define VMCS12_MAX_FIELD_INDEX (0x17) - static void kvm_msr_entry_add_vmx(X86CPU *cpu, FeatureWordArray f) { uint64_t kvm_vmx_basic =3D @@ -2791,8 +2789,14 @@ static void kvm_msr_entry_add_vmx(X86CPU *cpu, Featu= reWordArray f) CR0_PE_MASK | CR0_PG_MASK | CR0_NE_MASK); kvm_msr_entry_add(cpu, MSR_IA32_VMX_CR4_FIXED0, CR4_VMXE_MASK); - kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, - VMCS12_MAX_FIELD_INDEX << 1); + + if (f[FEAT_VMX_SECONDARY_CTLS] & VMX_SECONDARY_EXEC_TSC_SCALING) { + /* TSC multiplier (0x2032). */ + kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x32); + } else { + /* Preemption timer (0x482E). */ + kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x2E); + } } =20 static void kvm_msr_entry_add_perf(X86CPU *cpu, FeatureWordArray f) --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624630812342654.7109084681639; Fri, 25 Jun 2021 07:20:12 -0700 (PDT) Received: from localhost ([::1]:57736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmgk-0005XQ-La for importer@patchew.org; Fri, 25 Jun 2021 10:20:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmf7-0002r4-12 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:29 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]:34792) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmf5-000381-FO for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:28 -0400 Received: by mail-ej1-x62b.google.com with SMTP id hz1so15401364ejc.1 for ; Fri, 25 Jun 2021 07:18:26 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:25 -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=NaoA/Gz5B3VaHjNe4o2mJuay6G0a5kmwmmXcYmBXU30=; b=s0v4rUTxS4ShvtlUiGZ5gwYgXvQ+/p3ttV0CSeTDRjjofHsAM/xEgxyEXTdE5fhSbM r9JjOlPdfxQBf1Z0ymPNvHKLBL15+b5CKSvA6YTdAVViDVdowc3KYwyuZ1fZ5yoJ1ev0 5+wIHdQT7XyyHbH8GUv4PSRpxAYcjItdyGmJwDpCebwy+5qumxiUH1Jb0gHzygVXpNmi w6UL3YxLaSxt59BFWBUpj1trTc/KgG1Dqtd030diaObtJrZzxhq+iEbBpxcIwPWl6Ovm tJsEkke5Q3faw6URlRo6hNxdP/qGm13iroG72uNeJJjNVlFbZp3h0QPi5vuszIzhWkbt 99wA== 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=NaoA/Gz5B3VaHjNe4o2mJuay6G0a5kmwmmXcYmBXU30=; b=fcx1kwl56ZQT0XkzD8vGeoLgmxVrTbo9IJ/nKyVut1nvGXqM4glboMf8KW1vS6to1/ Jfb6OTuB8O855sFHCO1wIistva2E/v0dRjvoTEWIknOVyc/HdhdkffBuCI46kn8/RyRr GhaM9AcL9+FIs8R7nPYCRff8cb87UJ8+WqN39mizxX6pQk4osoIL3VN0iMP00LI2OzKg V9qk73+L6jag/VCj6hOV03ZMSSCpAQe6nxyKhVNSF+Ah2/CVmUVI8Ia+IJOnaWRs2pnU 5suAGLfUaYS+NF6sF39+AdCpa+Om7TBxdzp0bM+Fs7A9r/w00a3O+01JWmjPXmQ7JPeK 7BJg== X-Gm-Message-State: AOAM533d/nAy7sAin4nPq60i0YvldUxEGd8MOQIFrjK8hEVNggeS2zIZ 7JYFImjk3/k9lJ8gjyF3cKeI6ihXxw8= X-Google-Smtp-Source: ABdhPJxvRDfpBqmtNHlU+Mz8It6z1eApSuadzcrR2q5A2ZqTfryveTar+TE9aL8yh8t5RYw3x2NpCg== X-Received: by 2002:a17:906:49ce:: with SMTP id w14mr11195016ejv.273.1624630705719; Fri, 25 Jun 2021 07:18:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 02/28] meson: drop unused CONFIG_GCRYPT_HMAC Date: Fri, 25 Jun 2021 16:17:56 +0200 Message-Id: <20210625141822.1368639-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62b.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) CONFIG_GCRYPT_HMAC has been removed now that all supported distros have it. Reviewed-by: Richard Henderson Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/meson.build b/meson.build index d8a92666fb..87147a5f3f 100644 --- a/meson.build +++ b/meson.build @@ -2664,7 +2664,6 @@ summary_info +=3D {'GNUTLS support': config_host.h= as_key('CONFIG_GNUTLS')} # TODO: add back version summary_info +=3D {'libgcrypt': config_host.has_key('CONFIG_GCRYPT= ')} if config_host.has_key('CONFIG_GCRYPT') - summary_info +=3D {' hmac': config_host.has_key('CONFIG_GCR= YPT_HMAC')} summary_info +=3D {' XTS': not config_host.has_key('CONFIG= _QEMU_PRIVATE_XTS')} endif # TODO: add back version --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624630949270582.7286343039483; Fri, 25 Jun 2021 07:22:29 -0700 (PDT) Received: from localhost ([::1]:37672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmix-0002xp-5o for importer@patchew.org; Fri, 25 Jun 2021 10:22:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmf7-0002r5-9S for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:29 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]:35337) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmf5-00038P-Si for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:29 -0400 Received: by mail-ed1-x52a.google.com with SMTP id df12so13653262edb.2 for ; Fri, 25 Jun 2021 07:18:27 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:26 -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=VP9s5JyOxdlmVpItLUdNGhW5j1cHS9B8ambxVV+LEbo=; b=cxIus2mGi5r1g8z1dLxv5GR090xMmwf81kAWXXYiMqtrBOqbGtkoCZWAoRg96vfP7u vERxXnxJorTk6kme1KsiNmhG74Tpi07uW4mlYROqOMTQU13ygi6ZhLLfjXxjKcdyK5Rg j+6DoexH0lNsxbJvD6yCEIRqFR5yHRklmy1vzLb4O7r13e8v4EVk1hQTD14y4g5EEIZQ tQQmSn6/Pt732fDpIjmoskXtLvZMe33waQG9e244Q0kwmQyf+wFuIsq03Q7mIl9M0wX4 xj7tJu8fZabSUXPztUkxq/d74AogVlnaNbEbKK3k1/mSNlq9BRcuxqODS7NflHYRty7t 2lKw== 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=VP9s5JyOxdlmVpItLUdNGhW5j1cHS9B8ambxVV+LEbo=; b=X7Lv21+a+anU4AL2ilesfaGqwahzJFcEfLSTqYlxKtqWY5qQw+fuvvD8nZeb9aAeL3 emqf0kr9yW+TR36C+wJ/iBEXlB140hLoGSoae2OAGp/H2O3QPnpDfp291L2Ku30iDYnT Mos6d03l9uIOonKNb3pPokzGXKEzjylwjjyKSrZSPCrv0qQjgodU9zcv2s2A+EFtmFLK trsqcCAwB3UR2gVCffQLHzU5dhX2lhhEHNsYT8M7JItNLfh54X518whiG7AOtoo/Vpzb z65iVHdwsazXB3ekEDqva9Zk/+YGCusBL2Aq1sQF1rzbAW8mO2oHKAHEKX+IvMfCwPCB z/aQ== X-Gm-Message-State: AOAM530hAcmBtWjfsLYM2r/UAy/DZ13kCH5633WVBX46i0G+FdlMO0LP S2GTnH5sCIC131E+VJbICRGmyejn59U= X-Google-Smtp-Source: ABdhPJx8pneiXTUE/ORKHdMkj3iW/Z6Ip7d/2AC426r5U20EV8XhuUFiAp9dVjpwE02pTP/R/7KsDw== X-Received: by 2002:aa7:c614:: with SMTP id h20mr14949706edq.67.1624630706533; Fri, 25 Jun 2021 07:18:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 03/28] configure: drop unused variables for xts Date: Fri, 25 Jun 2021 16:17:57 +0200 Message-Id: <20210625141822.1368639-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) All XTS configuration uses qemu_private_xts. Drop other variables as they have only ever been used to generate the summary (which has since been moved to meson.build). Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- configure | 4 ---- 1 file changed, 4 deletions(-) diff --git a/configure b/configure index 38704b4e11..00e7dd749a 100755 --- a/configure +++ b/configure @@ -406,9 +406,7 @@ gtk=3D"auto" tls_priority=3D"NORMAL" gnutls=3D"$default_feature" nettle=3D"$default_feature" -nettle_xts=3D"no" gcrypt=3D"$default_feature" -gcrypt_xts=3D"no" qemu_private_xts=3D"yes" auth_pam=3D"$default_feature" vte=3D"$default_feature" @@ -2897,7 +2895,6 @@ int main(void) { } EOF if compile_prog "$nettle_cflags" "$nettle_libs" ; then - nettle_xts=3Dyes qemu_private_xts=3Dno fi fi @@ -2938,7 +2935,6 @@ int main(void) { } EOF if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then - gcrypt_xts=3Dyes qemu_private_xts=3Dno fi elif test "$gcrypt" =3D "yes"; then --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624631170838267.7461940975436; Fri, 25 Jun 2021 07:26:10 -0700 (PDT) Received: from localhost ([::1]:46106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmmX-0000Lk-Jz for importer@patchew.org; Fri, 25 Jun 2021 10:26:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmf9-0002s2-PH for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:31 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:46733) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmf6-00038c-ME for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:30 -0400 Received: by mail-ej1-x633.google.com with SMTP id he7so15317949ejc.13 for ; Fri, 25 Jun 2021 07:18:28 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:26 -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=89nOTmh6DcrB7ef5TmzMI2kJ0TGNno4c7shX8+Dmj50=; b=vYntWh1j93IORr3iaAp1bldEJ8F3jqVwzLF5kCdiqp800CPnBTZjeUGw8I/TRLmb/r gdkOLLsejp6L0M3aJY6UwjvtzkPbVx9QivgJcJiteznMA+SYshUlB5EpqVEVLHpLszAP +EnpUWEfc9wnvblm3SDwmt6BDKm8OyyEWY2nAhSeD77hTJ03YwznD5RzAhwSX938Nr0Y aDGv9TzzQb/fN1UM5FCP9seCUpoPBxeyIUEmqXPbUP7CTifPcDOvD4IrAXaJpSMzxkdD eQzXGbxI1Vulwks+sQwMIhUxPKfFMEukL/a3D+oIHhPtV3Z7Le4X2kik4DI2Y1vwByjA ZD3w== 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=89nOTmh6DcrB7ef5TmzMI2kJ0TGNno4c7shX8+Dmj50=; b=IWK3t0YFinL3nZihRDbDpStdgtRJ+H6eCfFsLcUm9cAprQ+CW2zOAa7F5v6qdywlVs tCrDQLnvbM2mq4RDK5DF6taIK45tXU1z77aryfKoN5MziLHJt+inrc370o3eYKljcHMs AzNWUeQXBBiN6Nnnfimjgk5wmikYBTTcW3WgzfP0T4DmcI50sMGwhWfdYSAmYkiqHSN9 YnaCSBqVyxPQlD0C9ATz92u7aWFceZAbDCyPmIGJcWpqh870s2nSTxFlhIRrnfGHGOdp VUSywI2FzNzMr/UlOO09C8SH42Lh7r6LHHe8NlF7dFEDYSQwpHG4i8YdVR76I4QBQ1/z 4elQ== X-Gm-Message-State: AOAM530D1M6+Rs55yoSKxe4gzoY9nj7jkJTPRHZFzQqANj0q90cmu19r 4eGF+XnLwWv97LjstvOivENeXu3ytvI= X-Google-Smtp-Source: ABdhPJwOxRL93nkkG0sk0CsQ6nAK36hMpOotwWjU0uBoyZiTUMEYw19u3ajDBm1hWsZPtAsxDoQ5Vg== X-Received: by 2002:a17:906:31c6:: with SMTP id f6mr2306816ejf.386.1624630707350; Fri, 25 Jun 2021 07:18:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 04/28] meson: remove preadv from summary Date: Fri, 25 Jun 2021 16:17:58 +0200 Message-Id: <20210625141822.1368639-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Meson is more verbose than the configure script; the outcome of the preadv = test can be found in its output and it is not worth including it again in the su= mmary. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/meson.build b/meson.build index 87147a5f3f..3809f51f7f 100644 --- a/meson.build +++ b/meson.build @@ -2565,7 +2565,6 @@ summary_info +=3D {'PIE': get_option('b= _pie')} summary_info +=3D {'static build': config_host.has_key('CONFIG_STATIC= ')} summary_info +=3D {'malloc trim support': has_malloc_trim} summary_info +=3D {'membarrier': config_host.has_key('CONFIG_MEMBAR= RIER')} -summary_info +=3D {'preadv support': config_host_data.get('CONFIG_PREAD= V')} summary_info +=3D {'fdatasync': config_host.has_key('CONFIG_FDATAS= YNC')} summary_info +=3D {'madvise': config_host.has_key('CONFIG_MADVIS= E')} summary_info +=3D {'posix_madvise': config_host.has_key('CONFIG_POSIX_= MADVISE')} --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624630816690673.85180195318; Fri, 25 Jun 2021 07:20:16 -0700 (PDT) Received: from localhost ([::1]:58128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmgp-0005oj-Kq for importer@patchew.org; Fri, 25 Jun 2021 10:20:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfB-0002vS-De for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:33 -0400 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]:39838) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmf7-00038q-V3 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:33 -0400 Received: by mail-ed1-x533.google.com with SMTP id c7so13612807edn.6 for ; Fri, 25 Jun 2021 07:18:29 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:28 -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=VArWV/JYlPRB+ITaKgwursWuWO5skwybUaAhhu6OsTQ=; b=TnyiuFapzs2RR6Zl6mz6v/u5As+m85c6fs2InT1X6Y0QiVJRnzwvrulDPmmlsXym89 v8luZAFQkdjfUZWKSk6Cc5Wh/WDt4dw5LrJ+XG9++oFIXouv7CxxR1kOU6P7l0jUNMet qbfTZGIUP+vRjG37CaYwomYkcQaTI/bhiWhL9KgE64QCdRXrM75QwsqFfNfo2GE5JOSN oiPonz93LVoVAAbjZoRFpy2CEAQkwkWC2MPS3pB5XfBJAWe5OKRtiRWiYcPj4jp9i/dg SYOZbcv0UdOe0scyvEOEmKSoyGJr+zho3ePFiS/1n1tb1Mrxyfc6WDwXGc919wOdKtVV femw== 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=VArWV/JYlPRB+ITaKgwursWuWO5skwybUaAhhu6OsTQ=; b=Klzko6LyjJRV/IFjhOAewAucYo158oQlci0nJ2Lh/sirjuvqU1iXhApprsaCwq8ijT m0SiC4NJSbagVE4TlKb6poKCSXn++3gU7Z0yBJfdfON8tbA+35mz18f0QupjpWkHfs5N 0JfOrv4P7u3ulUBeV2dA0brz5CgCxukI2z1bFsTgLyXVVLjM+/UqFdljx3Y8cxgKBgEO WCDSkv5bazwlFVLkLEntdGq0w9qmxRm5A2JE7zPHLu5Ep6+M4kvZYzRV9RSnwfZI+Z+4 vI/W1PZF/aAXCpIljHNOfHD+RgB8nVP2eu+8JQmZ7Hp+tpW6oD7zw0ckSnv/4O0ttF3F CkSw== X-Gm-Message-State: AOAM5326Z9UHw6QBqUuvjTPC7rHzPXXEBSDXXc+OLE5ipzuTuQf1Ss3f UFJzC1JAWOXaJwzlW+77dmReBMzteiU= X-Google-Smtp-Source: ABdhPJx8NxGLmRQEQVIlQSqQnSjagM6JAhjw1JCILONWMXbx0OEpQkZKtEZDTfxWLvzR65QJ3TDYNQ== X-Received: by 2002:a50:9b06:: with SMTP id o6mr15166296edi.284.1624630708613; Fri, 25 Jun 2021 07:18:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 05/28] tests: remove QCRYPTO_HAVE_TLS_TEST_SUPPORT Date: Fri, 25 Jun 2021 16:17:59 +0200 Message-Id: <20210625141822.1368639-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x533.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) meson.build already decides whether it is possible to build the TLS test suite. There is no need to include that in the source as well. The dummy tests in fact are broken because they do not produce valid TAP output (empty output is rejected by scripts/tap-driver.pl). Cc: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- tests/unit/crypto-tls-psk-helpers.c | 6 ------ tests/unit/crypto-tls-psk-helpers.h | 4 ---- tests/unit/crypto-tls-x509-helpers.c | 4 ---- tests/unit/crypto-tls-x509-helpers.h | 11 +---------- tests/unit/pkix_asn1_tab.c | 3 --- tests/unit/test-crypto-tlscredsx509.c | 12 ------------ tests/unit/test-crypto-tlssession.c | 12 ------------ tests/unit/test-io-channel-tls.c | 12 ------------ 8 files changed, 1 insertion(+), 63 deletions(-) diff --git a/tests/unit/crypto-tls-psk-helpers.c b/tests/unit/crypto-tls-ps= k-helpers.c index a8395477c3..7f8a488961 100644 --- a/tests/unit/crypto-tls-psk-helpers.c +++ b/tests/unit/crypto-tls-psk-helpers.c @@ -20,14 +20,10 @@ =20 #include "qemu/osdep.h" =20 -/* Include this first because it defines QCRYPTO_HAVE_TLS_TEST_SUPPORT */ #include "crypto-tls-x509-helpers.h" - #include "crypto-tls-psk-helpers.h" #include "qemu/sockets.h" =20 -#ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT - void test_tls_psk_init(const char *pskfile) { FILE *fp; @@ -46,5 +42,3 @@ void test_tls_psk_cleanup(const char *pskfile) { unlink(pskfile); } - -#endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */ diff --git a/tests/unit/crypto-tls-psk-helpers.h b/tests/unit/crypto-tls-ps= k-helpers.h index 5aa9951cb6..faa645c629 100644 --- a/tests/unit/crypto-tls-psk-helpers.h +++ b/tests/unit/crypto-tls-psk-helpers.h @@ -23,11 +23,7 @@ =20 #include =20 -#ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT - void test_tls_psk_init(const char *keyfile); void test_tls_psk_cleanup(const char *keyfile); =20 -#endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */ - #endif diff --git a/tests/unit/crypto-tls-x509-helpers.c b/tests/unit/crypto-tls-x= 509-helpers.c index 97658592a2..fc609b3fd4 100644 --- a/tests/unit/crypto-tls-x509-helpers.c +++ b/tests/unit/crypto-tls-x509-helpers.c @@ -24,8 +24,6 @@ #include "crypto/init.h" #include "qemu/sockets.h" =20 -#ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT - /* * This stores some static data that is needed when * encoding extensions in the x509 certs @@ -504,5 +502,3 @@ void test_tls_discard_cert(QCryptoTLSTestCertReq *req) unlink(req->filename); } } - -#endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */ diff --git a/tests/unit/crypto-tls-x509-helpers.h b/tests/unit/crypto-tls-x= 509-helpers.h index 8fcd7785ab..cf6329e653 100644 --- a/tests/unit/crypto-tls-x509-helpers.h +++ b/tests/unit/crypto-tls-x509-helpers.h @@ -23,14 +23,7 @@ =20 #include #include - -#if !(defined WIN32) && \ - defined(CONFIG_TASN1) -# define QCRYPTO_HAVE_TLS_TEST_SUPPORT -#endif - -#ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT -# include +#include =20 =20 /* @@ -127,6 +120,4 @@ void test_tls_cleanup(const char *keyfile); =20 extern const asn1_static_node pkix_asn1_tab[]; =20 -#endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */ - #endif diff --git a/tests/unit/pkix_asn1_tab.c b/tests/unit/pkix_asn1_tab.c index 15397cf77a..89521408a1 100644 --- a/tests/unit/pkix_asn1_tab.c +++ b/tests/unit/pkix_asn1_tab.c @@ -6,8 +6,6 @@ #include "qemu/osdep.h" #include "crypto-tls-x509-helpers.h" =20 -#ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT - const asn1_static_node pkix_asn1_tab[] =3D { {"PKIX1", 536875024, 0}, {0, 1073741836, 0}, @@ -1105,4 +1103,3 @@ const asn1_static_node pkix_asn1_tab[] =3D { {0, 1048586, "2"}, {0, 0, 0} }; -#endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */ diff --git a/tests/unit/test-crypto-tlscredsx509.c b/tests/unit/test-crypto= -tlscredsx509.c index f487349c32..aab4149b56 100644 --- a/tests/unit/test-crypto-tlscredsx509.c +++ b/tests/unit/test-crypto-tlscredsx509.c @@ -25,8 +25,6 @@ #include "qapi/error.h" #include "qemu/module.h" =20 -#ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT - #define WORKDIR "tests/test-crypto-tlscredsx509-work/" #define KEYFILE WORKDIR "key-ctx.pem" =20 @@ -706,13 +704,3 @@ int main(int argc, char **argv) =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } - -#else /* ! QCRYPTO_HAVE_TLS_TEST_SUPPORT */ - -int -main(void) -{ - return EXIT_SUCCESS; -} - -#endif /* ! QCRYPTO_HAVE_TLS_TEST_SUPPORT */ diff --git a/tests/unit/test-crypto-tlssession.c b/tests/unit/test-crypto-t= lssession.c index 8b2453fa79..5f0da9192c 100644 --- a/tests/unit/test-crypto-tlssession.c +++ b/tests/unit/test-crypto-tlssession.c @@ -31,8 +31,6 @@ #include "qemu/sockets.h" #include "authz/list.h" =20 -#ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT - #define WORKDIR "tests/test-crypto-tlssession-work/" #define PSKFILE WORKDIR "keys.psk" #define KEYFILE WORKDIR "key-ctx.pem" @@ -648,13 +646,3 @@ int main(int argc, char **argv) =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } - -#else /* ! QCRYPTO_HAVE_TLS_TEST_SUPPORT */ - -int -main(void) -{ - return EXIT_SUCCESS; -} - -#endif /* ! QCRYPTO_HAVE_TLS_TEST_SUPPORT */ diff --git a/tests/unit/test-io-channel-tls.c b/tests/unit/test-io-channel-= tls.c index ad7554c534..f6fb988c01 100644 --- a/tests/unit/test-io-channel-tls.c +++ b/tests/unit/test-io-channel-tls.c @@ -34,8 +34,6 @@ #include "authz/list.h" #include "qom/object_interfaces.h" =20 -#ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT - #define WORKDIR "tests/test-io-channel-tls-work/" #define KEYFILE WORKDIR "key-ctx.pem" =20 @@ -334,13 +332,3 @@ int main(int argc, char **argv) =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } - -#else /* ! QCRYPTO_HAVE_TLS_TEST_SUPPORT */ - -int -main(void) -{ - return EXIT_SUCCESS; -} - -#endif /* ! QCRYPTO_HAVE_TLS_TEST_SUPPORT */ --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624631378228919.3745800875466; Fri, 25 Jun 2021 07:29:38 -0700 (PDT) Received: from localhost ([::1]:54748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmpr-0006Gp-BX for importer@patchew.org; Fri, 25 Jun 2021 10:29:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfB-0002wf-Sv for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:33 -0400 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]:37771) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmf9-00039g-HU for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:33 -0400 Received: by mail-ed1-x533.google.com with SMTP id i24so13617505edx.4 for ; Fri, 25 Jun 2021 07:18:30 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:29 -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=GLj4HwwMombY8CaOsQjh5wwXRLnVD6SOn+E3r9+SCmQ=; b=FgO9KbCxhKL3pxFONWN8QZRN+EN2+HQnfTBsn9eun1CAa5JxvFGljZQfrjAoWMYpaE fYNCUD0OoDD6YaehaDIbyU0UGD5hlauZj8caS5RhKMeOJtcsl0iJ3VA1aRWyhfWytU5n Glrn4OwMUkZj5nwEjPpN2h1MBy/2uKws+PkvnHOUgML757yJXN9SrHsJCAGQvfxQYVvm WT5lbf8WFiFVKxLheacHbn/qMNOuxe5Pzfgej3y0LbaW9CoLFD1Q66HdiNSPtfx+9ak1 wnHnDtsIVj8DRM/CWLJbg89sJ6ZsNwf/1CpmDjUayprIYP2Iyt2ItV6KiIlcHdKXpsCC 0BnA== 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=GLj4HwwMombY8CaOsQjh5wwXRLnVD6SOn+E3r9+SCmQ=; b=dtY7oSp89ucSVYBa+9doW3QGLmz+GOyiwGRIBCBcfEY/7oKnWMLWRyvqEf3Tu39qDx S1r2hEbilLljKF5WnW6UmQgakCY2R4/gO8rbzgnmilrDumlIGvFTuXITachvd2RRvWhV lbug+fw/68SO6qDYV9C3tgRv6VZQK57+j6PaxBUQXYx64QyJsJUo4AigOSxaMCD0Br+p 5vcLFMpx+YRh7LCWdJBj4id0/F2RMs5NXMNvYbsBrD3A14U2tLV8Vh4UNuSYoCX73I8+ 8zExlaL96vhEr3TqzJApsNiliEUnYZFf+8A1/SlCj0Olx+xjG+/Pa1XJ4B/Lzj9B6jOY ck6Q== X-Gm-Message-State: AOAM5317hdCK7DPuFn4fRL9y8kenjjwTRn1sUAz02LQpBDYkXDtjnavg TngMbWhE4JMc5+sbWNkBQCt1sCo1R6w= X-Google-Smtp-Source: ABdhPJwaMtGe/zJYF3Jz6T7LQPSRt3ynK1jIEfxp9hQW0e9ZACbNwED40S8Z1Vfzxpp3V33mmPD3fw== X-Received: by 2002:aa7:d6d6:: with SMTP id x22mr14784625edr.224.1624630709437; Fri, 25 Jun 2021 07:18:29 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 06/28] configure, meson: convert crypto detection to meson Date: Fri, 25 Jun 2021 16:18:00 +0200 Message-Id: <20210625141822.1368639-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x533.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Reviewed-by: Richard Henderson Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- configure | 188 +++-------------------------------------- crypto/meson.build | 41 +++------ meson.build | 81 +++++++++++++----- meson_options.txt | 6 ++ tests/unit/meson.build | 6 +- 5 files changed, 90 insertions(+), 232 deletions(-) diff --git a/configure b/configure index 00e7dd749a..897e968e02 100755 --- a/configure +++ b/configure @@ -404,10 +404,9 @@ seccomp=3D"auto" glusterfs=3D"auto" gtk=3D"auto" tls_priority=3D"NORMAL" -gnutls=3D"$default_feature" -nettle=3D"$default_feature" -gcrypt=3D"$default_feature" -qemu_private_xts=3D"yes" +gnutls=3D"auto" +nettle=3D"auto" +gcrypt=3D"auto" auth_pam=3D"$default_feature" vte=3D"$default_feature" virglrenderer=3D"$default_feature" @@ -1372,17 +1371,17 @@ for opt do ;; --tls-priority=3D*) tls_priority=3D"$optarg" ;; - --disable-gnutls) gnutls=3D"no" + --disable-gnutls) gnutls=3D"disabled" ;; - --enable-gnutls) gnutls=3D"yes" + --enable-gnutls) gnutls=3D"enabled" ;; - --disable-nettle) nettle=3D"no" + --disable-nettle) nettle=3D"disabled" ;; - --enable-nettle) nettle=3D"yes" + --enable-nettle) nettle=3D"enabled" ;; - --disable-gcrypt) gcrypt=3D"no" + --disable-gcrypt) gcrypt=3D"disabled" ;; - --enable-gcrypt) gcrypt=3D"yes" + --enable-gcrypt) gcrypt=3D"enabled" ;; --disable-auth-pam) auth_pam=3D"no" ;; @@ -2800,156 +2799,6 @@ EOF fi fi =20 -########################################## -# GNUTLS probe - -if test "$gnutls" !=3D "no"; then - pass=3D"no" - if $pkg_config --exists "gnutls >=3D 3.5.18"; then - gnutls_cflags=3D$($pkg_config --cflags gnutls) - gnutls_libs=3D$($pkg_config --libs gnutls) - # Packaging for the static libraries is not always correct. - # At least ubuntu 18.04 ships only shared libraries. - write_c_skeleton - if compile_prog "" "$gnutls_libs" ; then - pass=3D"yes" - fi - fi - if test "$pass" =3D "no" && test "$gnutls" =3D "yes"; then - feature_not_found "gnutls" "Install gnutls devel >=3D 3.1.18" - else - gnutls=3D"$pass" - fi -fi - - -# If user didn't give a --disable/enable-gcrypt flag, -# then mark as disabled if user requested nettle -# explicitly -if test -z "$gcrypt" -then - if test "$nettle" =3D "yes" - then - gcrypt=3D"no" - fi -fi - -# If user didn't give a --disable/enable-nettle flag, -# then mark as disabled if user requested gcrypt -# explicitly -if test -z "$nettle" -then - if test "$gcrypt" =3D "yes" - then - nettle=3D"no" - fi -fi - -has_libgcrypt() { - if ! has "libgcrypt-config" - then - return 1 - fi - - if test -n "$cross_prefix" - then - host=3D$(libgcrypt-config --host) - if test "$host-" !=3D $cross_prefix - then - return 1 - fi - fi - - maj=3D`libgcrypt-config --version | awk -F . '{print $1}'` - min=3D`libgcrypt-config --version | awk -F . '{print $2}'` - - if test $maj !=3D 1 || test $min -lt 8 - then - return 1 - fi - - return 0 -} - - -if test "$nettle" !=3D "no"; then - pass=3D"no" - if $pkg_config --exists "nettle >=3D 3.4"; then - nettle_cflags=3D$($pkg_config --cflags nettle) - nettle_libs=3D$($pkg_config --libs nettle) - # Link test to make sure the given libraries work (e.g for static). - write_c_skeleton - if compile_prog "" "$nettle_libs" ; then - if test -z "$gcrypt"; then - gcrypt=3D"no" - fi - pass=3D"yes" - fi - fi - if test "$pass" =3D "yes" - then - cat > $TMPC << EOF -#include -int main(void) { - return 0; -} -EOF - if compile_prog "$nettle_cflags" "$nettle_libs" ; then - qemu_private_xts=3Dno - fi - fi - if test "$pass" =3D "no" && test "$nettle" =3D "yes"; then - feature_not_found "nettle" "Install nettle devel >=3D 2.7.1" - else - nettle=3D"$pass" - fi -fi - -if test "$gcrypt" !=3D "no"; then - pass=3D"no" - if has_libgcrypt; then - gcrypt_cflags=3D$(libgcrypt-config --cflags) - gcrypt_libs=3D$(libgcrypt-config --libs) - # Debian has removed -lgpg-error from libgcrypt-config - # as it "spreads unnecessary dependencies" which in - # turn breaks static builds... - if test "$static" =3D "yes" - then - gcrypt_libs=3D"$gcrypt_libs -lgpg-error" - fi - - # Link test to make sure the given libraries work (e.g for static). - write_c_skeleton - if compile_prog "" "$gcrypt_libs" ; then - pass=3D"yes" - fi - fi - if test "$pass" =3D "yes"; then - gcrypt=3D"yes" - cat > $TMPC << EOF -#include -int main(void) { - gcry_cipher_hd_t handle; - gcry_cipher_open(&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_XTS, 0); - return 0; -} -EOF - if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then - qemu_private_xts=3Dno - fi - elif test "$gcrypt" =3D "yes"; then - feature_not_found "gcrypt" "Install gcrypt devel >=3D 1.5.0" - else - gcrypt=3D"no" - fi -fi - - -if test "$gcrypt" =3D "yes" && test "$nettle" =3D "yes" -then - error_exit "Only one of gcrypt & nettle can be enabled" -fi - ########################################## # libtasn1 - only for the TLS creds/session test suite =20 @@ -5705,24 +5554,6 @@ if test "$gdbus_codegen" !=3D "" ; then echo "GDBUS_CODEGEN=3D$gdbus_codegen" >> $config_host_mak fi echo "CONFIG_TLS_PRIORITY=3D\"$tls_priority\"" >> $config_host_mak -if test "$gnutls" =3D "yes" ; then - echo "CONFIG_GNUTLS=3Dy" >> $config_host_mak - echo "GNUTLS_CFLAGS=3D$gnutls_cflags" >> $config_host_mak - echo "GNUTLS_LIBS=3D$gnutls_libs" >> $config_host_mak -fi -if test "$gcrypt" =3D "yes" ; then - echo "CONFIG_GCRYPT=3Dy" >> $config_host_mak - echo "GCRYPT_CFLAGS=3D$gcrypt_cflags" >> $config_host_mak - echo "GCRYPT_LIBS=3D$gcrypt_libs" >> $config_host_mak -fi -if test "$nettle" =3D "yes" ; then - echo "CONFIG_NETTLE=3Dy" >> $config_host_mak - echo "NETTLE_CFLAGS=3D$nettle_cflags" >> $config_host_mak - echo "NETTLE_LIBS=3D$nettle_libs" >> $config_host_mak -fi -if test "$qemu_private_xts" =3D "yes" ; then - echo "CONFIG_QEMU_PRIVATE_XTS=3Dy" >> $config_host_mak -fi if test "$tasn1" =3D "yes" ; then echo "CONFIG_TASN1=3Dy" >> $config_host_mak fi @@ -6439,6 +6270,7 @@ if test "$skip_meson" =3D no; then -Dcurl=3D$curl -Dglusterfs=3D$glusterfs -Dbzip2=3D$bzip2 -Dlibiscs= i=3D$libiscsi \ -Dlibnfs=3D$libnfs -Diconv=3D$iconv -Dcurses=3D$curses -Dlibudev= =3D$libudev\ -Drbd=3D$rbd -Dlzo=3D$lzo -Dsnappy=3D$snappy -Dlzfse=3D$lzfse \ + -Dgnutls=3D$gnutls -Dnettle=3D$nettle -Dgcrypt=3D$gcrypt \ -Dzstd=3D$zstd -Dseccomp=3D$seccomp -Dvirtfs=3D$virtfs -Dcap_ng=3D= $cap_ng \ -Dattr=3D$attr -Ddefault_devices=3D$default_devices \ -Ddocs=3D$docs -Dsphinx_build=3D$sphinx_build -Dinstall_blobs=3D$b= lobs \ diff --git a/crypto/meson.build b/crypto/meson.build index af7e80c6f6..7cbf1a6ba7 100644 --- a/crypto/meson.build +++ b/crypto/meson.build @@ -22,48 +22,31 @@ crypto_ss.add(files( 'tlssession.c', )) =20 -if 'CONFIG_NETTLE' in config_host - crypto_ss.add(files('hash-nettle.c', 'hmac-nettle.c', 'pbkdf-nettle.c')) -elif 'CONFIG_GCRYPT' in config_host - crypto_ss.add(files('hash-gcrypt.c', 'pbkdf-gcrypt.c')) - crypto_ss.add(files('hmac-gcrypt.c')) +if nettle.found() + crypto_ss.add(nettle, files('hash-nettle.c', 'hmac-nettle.c', 'pbkdf-net= tle.c')) +elif gcrypt.found() + crypto_ss.add(gcrypt, files('hash-gcrypt.c', 'hmac-gcrypt.c', 'pbkdf-gcr= ypt.c')) else crypto_ss.add(files('hash-glib.c', 'hmac-glib.c', 'pbkdf-stub.c')) endif +if xts =3D=3D 'private' + crypto_ss.add(files('xts.c')) +endif =20 crypto_ss.add(when: 'CONFIG_SECRET_KEYRING', if_true: files('secret_keyrin= g.c')) -crypto_ss.add(when: 'CONFIG_QEMU_PRIVATE_XTS', if_true: files('xts.c')) crypto_ss.add(when: 'CONFIG_AF_ALG', if_true: files('afalg.c', 'cipher-afa= lg.c', 'hash-afalg.c')) -crypto_ss.add(when: 'CONFIG_GNUTLS', if_true: files('tls-cipher-suites.c')) - -if 'CONFIG_NETTLE' in config_host - crypto_ss.add(nettle) -elif 'CONFIG_GCRYPT' in config_host - crypto_ss.add(gcrypt) -endif - -if 'CONFIG_GNUTLS' in config_host - crypto_ss.add(gnutls) -endif - +crypto_ss.add(when: gnutls, if_true: files('tls-cipher-suites.c')) =20 util_ss.add(files('aes.c')) util_ss.add(files('init.c')) =20 -if 'CONFIG_GCRYPT' in config_host - util_ss.add(files('random-gcrypt.c')) -elif 'CONFIG_GNUTLS' in config_host - util_ss.add(files('random-gnutls.c')) +if gcrypt.found() + util_ss.add(gcrypt, files('random-gcrypt.c')) +elif gnutls.found() + util_ss.add(gnutls, files('random-gnutls.c')) elif 'CONFIG_RNG_NONE' in config_host util_ss.add(files('random-none.c')) else util_ss.add(files('random-platform.c')) endif =20 -if 'CONFIG_GCRYPT' in config_host - util_ss.add(gcrypt) -endif - -if 'CONFIG_GNUTLS' in config_host - util_ss.add(gnutls) -endif diff --git a/meson.build b/meson.build index 3809f51f7f..286b37aecb 100644 --- a/meson.build +++ b/meson.build @@ -320,21 +320,6 @@ urcubp =3D not_found if 'CONFIG_TRACE_UST' in config_host urcubp =3D declare_dependency(link_args: config_host['URCU_BP_LIBS'].spl= it()) endif -gcrypt =3D not_found -if 'CONFIG_GCRYPT' in config_host - gcrypt =3D declare_dependency(compile_args: config_host['GCRYPT_CFLAGS']= .split(), - link_args: config_host['GCRYPT_LIBS'].split(= )) -endif -nettle =3D not_found -if 'CONFIG_NETTLE' in config_host - nettle =3D declare_dependency(compile_args: config_host['NETTLE_CFLAGS']= .split(), - link_args: config_host['NETTLE_LIBS'].split(= )) -endif -gnutls =3D not_found -if 'CONFIG_GNUTLS' in config_host - gnutls =3D declare_dependency(compile_args: config_host['GNUTLS_CFLAGS']= .split(), - link_args: config_host['GNUTLS_LIBS'].split(= )) -endif pixman =3D not_found if have_system or have_tools pixman =3D dependency('pixman-1', required: have_system, version:'>=3D0.= 21.8', @@ -829,6 +814,54 @@ if 'CONFIG_OPENGL' in config_host link_args: config_host['OPENGL_LIBS'].split(= )) endif =20 +gnutls =3D not_found +if not get_option('gnutls').auto() or have_system + gnutls =3D dependency('gnutls', version: '>=3D3.5.18', + method: 'pkg-config', + required: get_option('gnutls'), + kwargs: static_kwargs) +endif + +# Nettle has priority over gcrypt +gcrypt =3D not_found +nettle =3D not_found +xts =3D 'private' +if get_option('nettle').enabled() and get_option('gcrypt').enabled() + error('Only one of gcrypt & nettle can be enabled') +elif (not get_option('nettle').auto() or have_system) and not get_option('= gcrypt').enabled() + nettle =3D dependency('nettle', version: '>=3D3.4', + method: 'pkg-config', + required: get_option('nettle'), + kwargs: static_kwargs) + if nettle.found() and cc.has_header('nettle/xts.h', dependencies: nettle) + xts =3D 'nettle' + endif +endif +if (not get_option('gcrypt').auto() or have_system) and not nettle.found() + gcrypt =3D dependency('libgcrypt', version: '>=3D1.5', + method: 'config-tool', + required: get_option('gcrypt'), + kwargs: static_kwargs) + if gcrypt.found() and cc.compiles(''' + #include + int main(void) { + gcry_cipher_hd_t handle; + gcry_cipher_open(&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_XTS, 0); + return 0; + } + ''', dependencies: gcrypt) + xts =3D 'gcrypt' + endif + # Debian has removed -lgpg-error from libgcrypt-config + # as it "spreads unnecessary dependencies" which in + # turn breaks static builds... + if gcrypt.found() and enable_static + gcrypt =3D declare_dependency(dependencies: [ + gcrypt, + cc.find_library('gpg-error', required: true, kwargs: static_kwargs)]) + endif +endif + gtk =3D not_found gtkx11 =3D not_found if not get_option('gtk').auto() or (have_system and not cocoa.found()) @@ -1165,6 +1198,10 @@ config_host_data.set('CONFIG_VIRTFS', have_virtfs) config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found()) config_host_data.set('CONFIG_KEYUTILS', keyutils.found()) config_host_data.set('CONFIG_GETTID', has_gettid) +config_host_data.set('CONFIG_GNUTLS', gnutls.found()) +config_host_data.set('CONFIG_GCRYPT', gcrypt.found()) +config_host_data.set('CONFIG_NETTLE', nettle.found()) +config_host_data.set('CONFIG_QEMU_PRIVATE_XTS', xts =3D=3D 'private') config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim) config_host_data.set('CONFIG_STATX', has_statx) config_host_data.set('CONFIG_ZSTD', zstd.found()) @@ -2659,16 +2696,16 @@ summary(summary_info, bool_yn: true, section: 'Bloc= k layer support') # Crypto summary_info =3D {} summary_info +=3D {'TLS priority': config_host['CONFIG_TLS_PRIORITY']} -summary_info +=3D {'GNUTLS support': config_host.has_key('CONFIG_GNUTLS= ')} +summary_info +=3D {'GNUTLS support': gnutls.found()} # TODO: add back version -summary_info +=3D {'libgcrypt': config_host.has_key('CONFIG_GCRYPT= ')} -if config_host.has_key('CONFIG_GCRYPT') - summary_info +=3D {' XTS': not config_host.has_key('CONFIG= _QEMU_PRIVATE_XTS')} +summary_info +=3D {'libgcrypt': gcrypt.found()} +if gcrypt.found() + summary_info +=3D {' XTS': xts !=3D 'private'} endif # TODO: add back version -summary_info +=3D {'nettle': config_host.has_key('CONFIG_NETTLE= ')} -if config_host.has_key('CONFIG_NETTLE') - summary_info +=3D {' XTS': not config_host.has_key('CONFIG= _QEMU_PRIVATE_XTS')} +summary_info +=3D {'nettle': nettle.found()} +if nettle.found() + summary_info +=3D {' XTS': xts !=3D 'private'} endif summary_info +=3D {'crypto afalg': config_host.has_key('CONFIG_AF_ALG= ')} summary_info +=3D {'rng-none': config_host.has_key('CONFIG_RNG_NO= NE')} diff --git a/meson_options.txt b/meson_options.txt index 3d304cac96..343ffffb7c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -76,6 +76,12 @@ option('iconv', type : 'feature', value : 'auto', description: 'Font glyph conversion support') option('curses', type : 'feature', value : 'auto', description: 'curses UI') +option('gnutls', type : 'feature', value : 'auto', + description: 'GNUTLS cryptography support') +option('nettle', type : 'feature', value : 'auto', + description: 'nettle cryptography support') +option('gcrypt', type : 'feature', value : 'auto', + description: 'libgcrypt cryptography support') option('libudev', type : 'feature', value : 'auto', description: 'Use libudev to enumerate host devices') option('lzfse', type : 'feature', value : 'auto', diff --git a/tests/unit/meson.build b/tests/unit/meson.build index b3bc2109da..fcf6ed2ef5 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -83,7 +83,7 @@ if have_block 'test-crypto-afsplit': [io], 'test-crypto-block': [io], } - if 'CONFIG_GNUTLS' in config_host and \ + if gnutls.found() and \ 'CONFIG_TASN1' in config_host and \ 'CONFIG_POSIX' in config_host tests +=3D { @@ -97,7 +97,7 @@ if have_block if 'CONFIG_AUTH_PAM' in config_host tests +=3D {'test-authz-pam': [authz]} endif - if 'CONFIG_QEMU_PRIVATE_XTS' in config_host + if xts =3D=3D 'private' tests +=3D {'test-crypto-xts': [crypto, io]} endif if 'CONFIG_POSIX' in config_host @@ -106,7 +106,7 @@ if have_block if 'CONFIG_REPLICATION' in config_host tests +=3D {'test-replication': [testblock]} endif - if 'CONFIG_NETTLE' in config_host or 'CONFIG_GCRYPT' in config_host + if nettle.found() or gcrypt.found() tests +=3D {'test-crypto-pbkdf': [io]} endif if 'CONFIG_EPOLL_CREATE1' in config_host --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624630818766493.31373917797225; Fri, 25 Jun 2021 07:20:18 -0700 (PDT) Received: from localhost ([::1]:58256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmgr-0005tW-Ov for importer@patchew.org; Fri, 25 Jun 2021 10:20:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfC-0002yc-SV for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:34 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:41549) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmf9-00039k-Hj for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:34 -0400 Received: by mail-ej1-x633.google.com with SMTP id ot9so14370688ejb.8 for ; Fri, 25 Jun 2021 07:18:31 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:29 -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=7ElfB3hCixBdlT6W7KW1tRrgymRkAv9P5WGy6JvpRnA=; b=BMjLSZ9i0fCFP53QD4qN35R8f8XMAEjAsDmQ+kKEiBh78Cds5s6bF6hHNGFx7YQvVH PpOKcvjHAwHV3qblccil7VfKL3hCz/OcFei6YFS8EijRoAb1+lkLmpRqg0HXbcz+dkAL Nic8UDMkUs1hLwQD8unpJM1q4HVUiLfmWfnF18AhMNcxoNCLFqZBfme4RPSakwJUsV9h B67h131uf5YTMTQFsy7DZh7WlOOcMiLZLC17GDnSjhKKcTBTybnAkZ6+TxABXR0Qqv79 JNQUzQ2TqAFQDVPbqqOftnWjXjjgHptRdc5xpm7NKt5A+1F/f3jOrKVElpohF8pntZQH ko4Q== 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=7ElfB3hCixBdlT6W7KW1tRrgymRkAv9P5WGy6JvpRnA=; b=jfUYNLycWsZfF7w+OfSLwlWmKWzAzojRJ7yZOLXTgYYfeXFL/YuOYlo/ED2nNbZyJI hGNi3WKu2Hj7d6v+yLS3UIkq58Dbs3yIjLLs4JnWFZdYapfNDnSJ2QX+fA/HV+LnKrFH Zq0UyjuORcitRjec6bmYdPLRUf0fQEQTn+7JXLHWmqJf8zhFTMPGoIN9RvFHWrnOwcqU X5SyKL5vlEBUkkksV4wQstMkUzxG/1Wb+9wbtdltd4HrWpxEnfS+HMIk9NC3w8sqZ82I zJc1SVKzYlQB6+2jU/EsweVbGOidz+enfJ5E9JBozji02i/RlFg2L1ugjUp/v7wMIOpR VNEg== X-Gm-Message-State: AOAM533SvRq+eTgBUjHBPAfG73C/7+/HT6h0ghdhQgE9s3/to+U0i9QS 7KfRC6Ohg9YUKj+Asoo8tLJSW8eiB3U= X-Google-Smtp-Source: ABdhPJwuTfrIOYezezstjqYe0nSKr6B2VdoQxFAv7tfa225+ZkrOBgsSbBgIyzeYJj39v+i61N3VeQ== X-Received: by 2002:a17:906:3b87:: with SMTP id u7mr11213809ejf.330.1624630710204; Fri, 25 Jun 2021 07:18:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 07/28] configure, meson: convert libtasn1 detection to meson Date: Fri, 25 Jun 2021 16:18:01 +0200 Message-Id: <20210625141822.1368639-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Make it depend on gnutls too, since it is only used as part of gnutls tests. Reviewed-by: Richard Henderson Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- configure | 19 ------------------- meson.build | 9 +++++---- tests/unit/meson.build | 2 +- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/configure b/configure index 897e968e02..3d36eea55f 100755 --- a/configure +++ b/configure @@ -2799,20 +2799,6 @@ EOF fi fi =20 -########################################## -# libtasn1 - only for the TLS creds/session test suite - -tasn1=3Dyes -tasn1_cflags=3D"" -tasn1_libs=3D"" -if $pkg_config --exists "libtasn1"; then - tasn1_cflags=3D$($pkg_config --cflags libtasn1) - tasn1_libs=3D$($pkg_config --libs libtasn1) -else - tasn1=3Dno -fi - - ########################################## # PAM probe =20 @@ -5554,9 +5540,6 @@ if test "$gdbus_codegen" !=3D "" ; then echo "GDBUS_CODEGEN=3D$gdbus_codegen" >> $config_host_mak fi echo "CONFIG_TLS_PRIORITY=3D\"$tls_priority\"" >> $config_host_mak -if test "$tasn1" =3D "yes" ; then - echo "CONFIG_TASN1=3Dy" >> $config_host_mak -fi if test "$auth_pam" =3D "yes" ; then echo "CONFIG_AUTH_PAM=3Dy" >> $config_host_mak fi @@ -6017,8 +6000,6 @@ echo "LD_I386_EMULATION=3D$ld_i386_emulation" >> $con= fig_host_mak echo "EXESUF=3D$EXESUF" >> $config_host_mak echo "HOST_DSOSUF=3D$HOST_DSOSUF" >> $config_host_mak echo "LIBS_QGA=3D$libs_qga" >> $config_host_mak -echo "TASN1_LIBS=3D$tasn1_libs" >> $config_host_mak -echo "TASN1_CFLAGS=3D$tasn1_cflags" >> $config_host_mak if test "$gcov" =3D "yes" ; then echo "CONFIG_GCOV=3Dy" >> $config_host_mak fi diff --git a/meson.build b/meson.build index 286b37aecb..d4ce2ca57b 100644 --- a/meson.build +++ b/meson.build @@ -985,9 +985,10 @@ if 'CONFIG_LIBDAXCTL' in config_host libdaxctl =3D declare_dependency(link_args: config_host['LIBDAXCTL_LIBS'= ].split()) endif tasn1 =3D not_found -if 'CONFIG_TASN1' in config_host - tasn1 =3D declare_dependency(compile_args: config_host['TASN1_CFLAGS'].s= plit(), - link_args: config_host['TASN1_LIBS'].split()) +if gnutls.found() + tasn1 =3D dependency('libtasn1', + method: 'pkg-config', + kwargs: static_kwargs) endif keyutils =3D dependency('libkeyutils', required: false, method: 'pkg-config', kwargs: static_kwargs) @@ -2727,7 +2728,7 @@ summary_info +=3D {'pixman': pixman.found(= )} summary_info +=3D {'VTE support': config_host.has_key('CONFIG_VTE')} # TODO: add back version summary_info +=3D {'slirp support': slirp_opt =3D=3D 'disabled' ? fals= e : slirp_opt} -summary_info +=3D {'libtasn1': config_host.has_key('CONFIG_TASN1'= )} +summary_info +=3D {'libtasn1': tasn1.found()} summary_info +=3D {'PAM': config_host.has_key('CONFIG_AUTH_P= AM')} summary_info +=3D {'iconv support': iconv.found()} summary_info +=3D {'curses support': curses.found()} diff --git a/tests/unit/meson.build b/tests/unit/meson.build index fcf6ed2ef5..4c1ebc06ac 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -84,7 +84,7 @@ if have_block 'test-crypto-block': [io], } if gnutls.found() and \ - 'CONFIG_TASN1' in config_host and \ + tasn1.found() and \ 'CONFIG_POSIX' in config_host tests +=3D { 'test-crypto-tlscredsx509': ['crypto-tls-x509-helpers.c', 'pkix_asn1= _tab.c', --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624630955868796.3275755968748; Fri, 25 Jun 2021 07:22:35 -0700 (PDT) Received: from localhost ([::1]:38426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmj4-0003Tn-Pz for importer@patchew.org; Fri, 25 Jun 2021 10:22:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfD-0002zi-En for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:35 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:34714) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfA-00039r-6I for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:34 -0400 Received: by mail-ed1-x535.google.com with SMTP id i5so13665485eds.1 for ; Fri, 25 Jun 2021 07:18:31 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:30 -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=oNmFc5T9/k0otEtR3qm/FZnb2sg+M16mGXNNskOAfzI=; b=Mdlsuj5dJtktT6PTbCE06gqVFMP5X9PnKaCPFBYi0hpCU79r4K3DSoRDmRU60LJvvP l7VFkCkqU+Z2LaCr8mVFY2UpG1A+Buvx7F3QwfRd9zoVly93qrICYEGScHPBiPWdRSZ+ vbM7Zs0DXQxMpVTIliLL5dT1YUS2LH6683hQ1WlfZawOe1f4a0K23ZilbewtWg0LLPUZ 4aOSbeHVyPr+7YyIJXZap2pud3sOQlDRXtOqOAxXvdrCNPEpRFAB8HSmEblLkhw5qY1n tvKdJNbB651ILSV9+WDpBRVOEOJnTSfehSmrVhTAGs0UWoRLiFmfyh0D3k8ZMDHSNFsm mMOw== 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=oNmFc5T9/k0otEtR3qm/FZnb2sg+M16mGXNNskOAfzI=; b=ks9cJiR8+vQm+nuJ2loanZKv/4sOynRImZF2daZCQl1zWn6q5SPao9wgGWb3I6tfxr qcY/Q8kM1ZHJLrXg1l0naBghFcL18X/CArSS2PXS1JcYGih64B90o1+TteW6NahBRggl o3RGiDZrcumZVQTMjRmVQMIphKNLQIoIomT/jyElBW6dg2uGASMKhc3yNK8UZTV145ZK iDLkLXpovt2svBId5KGVqpDVF1dmPDkqFilom72NCtcew8OkkAEi0cGwRQzl3UjZKeev wRKuq9N2gi5MeQ52h5WLg6oOGtnD7e+QWc62xi+DD7tskVlC4LZjVx9hoqN70k3g3RGE 7heg== X-Gm-Message-State: AOAM530YlACmPnLY/LK4KzGiiklXeUFuhwCfJuwZtuq85C20ATgw4xfI l/OPBPY8t5fY1MH6N8FMmcXpw3DCo+0= X-Google-Smtp-Source: ABdhPJw7NP/zo/AkFZ+a6CFHIF9hMNDm0C67deLFXekiEtyFMpEp6LSLcVvGOyVNrfo1J4uvqRxTlw== X-Received: by 2002:aa7:db03:: with SMTP id t3mr14892494eds.153.1624630710940; Fri, 25 Jun 2021 07:18:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 08/28] configure, meson: convert pam detection to meson Date: Fri, 25 Jun 2021 16:18:02 +0200 Message-Id: <20210625141822.1368639-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- authz/meson.build | 2 +- configure | 38 ++++---------------------------------- meson.build | 31 ++++++++++++++++++++++++++----- meson_options.txt | 2 ++ tests/unit/meson.build | 2 +- 5 files changed, 34 insertions(+), 41 deletions(-) diff --git a/authz/meson.build b/authz/meson.build index 88fa7769cb..42a1ec0ff6 100644 --- a/authz/meson.build +++ b/authz/meson.build @@ -6,4 +6,4 @@ authz_ss.add(files( 'simple.c', )) =20 -authz_ss.add(when: ['CONFIG_AUTH_PAM', pam], if_true: files('pamacct.c')) +authz_ss.add(when: pam, if_true: files('pamacct.c')) diff --git a/configure b/configure index 3d36eea55f..237e99c3d0 100755 --- a/configure +++ b/configure @@ -407,7 +407,7 @@ tls_priority=3D"NORMAL" gnutls=3D"auto" nettle=3D"auto" gcrypt=3D"auto" -auth_pam=3D"$default_feature" +auth_pam=3D"auto" vte=3D"$default_feature" virglrenderer=3D"$default_feature" tpm=3D"$default_feature" @@ -1383,9 +1383,9 @@ for opt do ;; --enable-gcrypt) gcrypt=3D"enabled" ;; - --disable-auth-pam) auth_pam=3D"no" + --disable-auth-pam) auth_pam=3D"disabled" ;; - --enable-auth-pam) auth_pam=3D"yes" + --enable-auth-pam) auth_pam=3D"enabled" ;; --enable-rdma) rdma=3D"yes" ;; @@ -2799,33 +2799,6 @@ EOF fi fi =20 -########################################## -# PAM probe - -if test "$auth_pam" !=3D "no"; then - cat > $TMPC < -#include -int main(void) { - const char *service_name =3D "qemu"; - const char *user =3D "frank"; - const struct pam_conv pam_conv =3D { 0 }; - pam_handle_t *pamh =3D NULL; - pam_start(service_name, user, &pam_conv, &pamh); - return 0; -} -EOF - if compile_prog "" "-lpam" ; then - auth_pam=3Dyes - else - if test "$auth_pam" =3D "yes"; then - feature_not_found "PAM" "Install PAM development package" - else - auth_pam=3Dno - fi - fi -fi - ########################################## # VTE probe =20 @@ -5540,9 +5513,6 @@ if test "$gdbus_codegen" !=3D "" ; then echo "GDBUS_CODEGEN=3D$gdbus_codegen" >> $config_host_mak fi echo "CONFIG_TLS_PRIORITY=3D\"$tls_priority\"" >> $config_host_mak -if test "$auth_pam" =3D "yes" ; then - echo "CONFIG_AUTH_PAM=3Dy" >> $config_host_mak -fi if test "$have_broken_size_max" =3D "yes" ; then echo "HAVE_BROKEN_SIZE_MAX=3Dy" >> $config_host_mak fi @@ -6251,7 +6221,7 @@ if test "$skip_meson" =3D no; then -Dcurl=3D$curl -Dglusterfs=3D$glusterfs -Dbzip2=3D$bzip2 -Dlibiscs= i=3D$libiscsi \ -Dlibnfs=3D$libnfs -Diconv=3D$iconv -Dcurses=3D$curses -Dlibudev= =3D$libudev\ -Drbd=3D$rbd -Dlzo=3D$lzo -Dsnappy=3D$snappy -Dlzfse=3D$lzfse \ - -Dgnutls=3D$gnutls -Dnettle=3D$nettle -Dgcrypt=3D$gcrypt \ + -Dgnutls=3D$gnutls -Dnettle=3D$nettle -Dgcrypt=3D$gcrypt -Dauth_pa= m=3D$auth_pam \ -Dzstd=3D$zstd -Dseccomp=3D$seccomp -Dvirtfs=3D$virtfs -Dcap_ng=3D= $cap_ng \ -Dattr=3D$attr -Ddefault_devices=3D$default_devices \ -Ddocs=3D$docs -Dsphinx_build=3D$sphinx_build -Dinstall_blobs=3D$b= lobs \ diff --git a/meson.build b/meson.build index d4ce2ca57b..d3025e05fc 100644 --- a/meson.build +++ b/meson.build @@ -325,10 +325,6 @@ if have_system or have_tools pixman =3D dependency('pixman-1', required: have_system, version:'>=3D0.= 21.8', method: 'pkg-config', kwargs: static_kwargs) endif -pam =3D not_found -if 'CONFIG_AUTH_PAM' in config_host - pam =3D cc.find_library('pam') -endif libaio =3D cc.find_library('aio', required: false) zlib =3D dependency('zlib', required: true, kwargs: static_kwargs) linux_io_uring =3D not_found @@ -907,6 +903,31 @@ if get_option('vnc').enabled() endif endif =20 +pam =3D not_found +if not get_option('auth_pam').auto() or have_system + pam =3D cc.find_library('pam', has_headers: ['security/pam_appl.h'], + required: get_option('auth_pam'), + kwargs: static_kwargs) +endif +if pam.found() and not cc.links(''' + #include + #include + int main(void) { + const char *service_name =3D "qemu"; + const char *user =3D "frank"; + const struct pam_conv pam_conv =3D { 0 }; + pam_handle_t *pamh =3D NULL; + pam_start(service_name, user, &pam_conv, &pamh); + return 0; + }''', dependencies: pam) + pam =3D not_found + if get_option('auth_pam').enabled() + error('could not link libpam') + else + warning('could not link libpam, disabling') + endif +endif + snappy =3D not_found if not get_option('snappy').auto() or have_system snappy =3D cc.find_library('snappy', has_headers: ['snappy-c.h'], @@ -2729,7 +2750,7 @@ summary_info +=3D {'VTE support': config_host.h= as_key('CONFIG_VTE')} # TODO: add back version summary_info +=3D {'slirp support': slirp_opt =3D=3D 'disabled' ? fals= e : slirp_opt} summary_info +=3D {'libtasn1': tasn1.found()} -summary_info +=3D {'PAM': config_host.has_key('CONFIG_AUTH_P= AM')} +summary_info +=3D {'PAM': pam.found()} summary_info +=3D {'iconv support': iconv.found()} summary_info +=3D {'curses support': curses.found()} # TODO: add back version diff --git a/meson_options.txt b/meson_options.txt index 343ffffb7c..ac6e90da07 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -52,6 +52,8 @@ option('multiprocess', type: 'feature', value: 'auto', =20 option('attr', type : 'feature', value : 'auto', description: 'attr/xattr support') +option('auth_pam', type : 'feature', value : 'auto', + description: 'PAM access control') option('brlapi', type : 'feature', value : 'auto', description: 'brlapi character device driver') option('bzip2', type : 'feature', value : 'auto', diff --git a/tests/unit/meson.build b/tests/unit/meson.build index 4c1ebc06ac..3e0504dd21 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -94,7 +94,7 @@ if have_block 'test-io-channel-tls': ['io-channel-helpers.c', 'crypto-tls-x509-hel= pers.c', 'pkix_asn1_tab.c', tasn1, io, crypto, gnutls]} endif - if 'CONFIG_AUTH_PAM' in config_host + if pam.found() tests +=3D {'test-authz-pam': [authz]} endif if xts =3D=3D 'private' --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624631578124245.1928620067713; Fri, 25 Jun 2021 07:32:58 -0700 (PDT) Received: from localhost ([::1]:35164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmt6-0003jW-Ui for importer@patchew.org; Fri, 25 Jun 2021 10:32:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfD-0002z8-A5 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:35 -0400 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]:37623) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfA-0003AJ-W0 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:34 -0400 Received: by mail-ej1-x62f.google.com with SMTP id o11so2223504ejd.4 for ; Fri, 25 Jun 2021 07:18:32 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:31 -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=Xs9h6JVvEzIMS5Kp/ZSehjw8VqtorUSKIK1nTr/EzMM=; b=AigWCR7U8GmDuRneXJjhm111zMfyZgEZN277tSuxHFmMsbp6swxAP/yctgYBWWfOGg cRrhhwpwVp48DwY/4Ul1ryTIgNnDj8oH+gAEqHHT9VBXJMjICNkf+FF1nYikiAuDulDj svbkpmgY/MT9iBFIkxyyJpFdjP9ugyyT0KCVdqzZEHgNGQ5zCSIj0Tj9CtJ4tgpoBCgL qusSEj2hKDboPyBYbq/MoKUBkxhtPz7I9LSYBatRhBjrpQE0yydR1EQ2nQ7Lw70jgitL Bv0jim0goC1qgZ0z8sQstuEV5B8ef12juP95kPh1o5QmaEAGvWB7I2fu50FIXvUC25p7 HJIg== 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=Xs9h6JVvEzIMS5Kp/ZSehjw8VqtorUSKIK1nTr/EzMM=; b=EqDcelgWqzZaZdIsRxFcB+aCqTwMzR76AJlBPg+W2fPruKzyupgLex6xRQBGxLuQv2 eqDiX99s2UAXsXVEUe3OKllyMBVvWPIV9+MdXEXz7Sso5X9iijZdQDun4xhMzqF66BS7 OQJnQfpSMIh7mJluFoadnjVrAglu4pGS1oa2AtDrzs/QWBTVhbnYywnOHekiDN21zAtJ 4EHpiXxBUB/SNM7vS6wy8a2DjA9E7N3NU7sBzp3AXRyi/4RMOlocJWeKEgFj+ov4rUB3 iKeDopwR89X9sERtlqN9UF2175iuWsvE37H/V+2csW2l49zcVOA2NYk4RS3wBr+Wuz4x /s/Q== X-Gm-Message-State: AOAM531mHoCcvdW0JZPUsLEx0ol8zow5K09kJsNxOscg01Wh/dpVFwfu zHZpfg8vzWCcKLCVKo1FQiLeH5FlPM8= X-Google-Smtp-Source: ABdhPJzAbPofI186io/sUrHdpHe0K9BW5uS7bq+soczPpsqFwZUctvruL/Abx5SK0XRtcJvjB61UcQ== X-Received: by 2002:a17:906:2c43:: with SMTP id f3mr10874405ejh.505.1624630711693; Fri, 25 Jun 2021 07:18:31 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 09/28] configure, meson: convert libusb detection to meson Date: Fri, 25 Jun 2021 16:18:03 +0200 Message-Id: <20210625141822.1368639-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62f.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- configure | 27 ++++----------------------- hw/usb/meson.build | 2 +- meson.build | 11 +++++++---- meson_options.txt | 2 ++ 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/configure b/configure index 237e99c3d0..e54d06b99e 100755 --- a/configure +++ b/configure @@ -374,7 +374,7 @@ spice_protocol=3D"auto" rbd=3D"auto" smartcard=3D"$default_feature" u2f=3D"auto" -libusb=3D"$default_feature" +libusb=3D"auto" usb_redir=3D"$default_feature" opengl=3D"$default_feature" cpuid_h=3D"no" @@ -1285,9 +1285,9 @@ for opt do ;; --enable-u2f) u2f=3D"enabled" ;; - --disable-libusb) libusb=3D"no" + --disable-libusb) libusb=3D"disabled" ;; - --enable-libusb) libusb=3D"yes" + --enable-libusb) libusb=3D"enabled" ;; --disable-usb-redir) usb_redir=3D"no" ;; @@ -3994,20 +3994,6 @@ if test "$smartcard" !=3D "no"; then fi fi =20 -# check for libusb -if test "$libusb" !=3D "no" ; then - if $pkg_config --atleast-version=3D1.0.13 libusb-1.0; then - libusb=3D"yes" - libusb_cflags=3D$($pkg_config --cflags libusb-1.0) - libusb_libs=3D$($pkg_config --libs libusb-1.0) - else - if test "$libusb" =3D "yes"; then - feature_not_found "libusb" "Install libusb devel >=3D 1.0.13" - fi - libusb=3D"no" - fi -fi - # check for usbredirparser for usb network redirection support if test "$usb_redir" !=3D "no" ; then if $pkg_config --atleast-version=3D0.6 libusbredirparser-0.5; then @@ -5631,12 +5617,6 @@ if test "$smartcard" =3D "yes" ; then echo "SMARTCARD_LIBS=3D$libcacard_libs" >> $config_host_mak fi =20 -if test "$libusb" =3D "yes" ; then - echo "CONFIG_USB_LIBUSB=3Dy" >> $config_host_mak - echo "LIBUSB_CFLAGS=3D$libusb_cflags" >> $config_host_mak - echo "LIBUSB_LIBS=3D$libusb_libs" >> $config_host_mak -fi - if test "$usb_redir" =3D "yes" ; then echo "CONFIG_USB_REDIR=3Dy" >> $config_host_mak echo "USB_REDIR_CFLAGS=3D$usb_redir_cflags" >> $config_host_mak @@ -6215,6 +6195,7 @@ if test "$skip_meson" =3D no; then -Dkvm=3D$kvm -Dhax=3D$hax -Dwhpx=3D$whpx -Dhvf=3D$hvf -Dnvmm=3D$nv= mm \ -Dxen=3D$xen -Dxen_pci_passthrough=3D$xen_pci_passthrough -Dtcg=3D= $tcg \ -Dcocoa=3D$cocoa -Dgtk=3D$gtk -Dmpath=3D$mpath -Dsdl=3D$sdl -Dsdl_= image=3D$sdl_image \ + -Dlibusb=3D$libusb \ -Dvnc=3D$vnc -Dvnc_sasl=3D$vnc_sasl -Dvnc_jpeg=3D$vnc_jpeg -Dvnc_p= ng=3D$vnc_png \ -Dgettext=3D$gettext -Dxkbcommon=3D$xkbcommon -Du2f=3D$u2f -Dvirti= ofsd=3D$virtiofsd \ -Dcapstone=3D$capstone -Dslirp=3D$slirp -Dfdt=3D$fdt -Dbrlapi=3D$b= rlapi \ diff --git a/hw/usb/meson.build b/hw/usb/meson.build index f357270d0b..bd3f8735b9 100644 --- a/hw/usb/meson.build +++ b/hw/usb/meson.build @@ -72,7 +72,7 @@ if config_host.has_key('CONFIG_USB_REDIR') endif =20 # usb pass-through -softmmu_ss.add(when: ['CONFIG_USB', 'CONFIG_USB_LIBUSB', libusb], +softmmu_ss.add(when: ['CONFIG_USB', libusb], if_true: files('host-libusb.c'), if_false: files('host-stub.c')) softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('host-stub.c')) diff --git a/meson.build b/meson.build index d3025e05fc..0b4b55b9da 100644 --- a/meson.build +++ b/meson.build @@ -992,10 +992,12 @@ if 'CONFIG_USB_REDIR' in config_host link_args: config_host['USB_REDIR_LIBS'].s= plit()) endif libusb =3D not_found -if 'CONFIG_USB_LIBUSB' in config_host - libusb =3D declare_dependency(compile_args: config_host['LIBUSB_CFLAGS']= .split(), - link_args: config_host['LIBUSB_LIBS'].split(= )) +if not get_option('libusb').auto() or have_system + libusb =3D dependency('libusb-1.0', required: get_option('libusb'), + version: '>=3D1.0.13', method: 'pkg-config', + kwargs: static_kwargs) endif + libpmem =3D not_found if 'CONFIG_LIBPMEM' in config_host libpmem =3D declare_dependency(compile_args: config_host['LIBPMEM_CFLAGS= '].split(), @@ -1211,6 +1213,7 @@ config_host_data.set('CONFIG_SDL', sdl.found()) config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found()) config_host_data.set('CONFIG_SECCOMP', seccomp.found()) config_host_data.set('CONFIG_SNAPPY', snappy.found()) +config_host_data.set('CONFIG_USB_LIBUSB', libusb.found()) config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_s= erver) config_host_data.set('CONFIG_VNC', vnc.found()) config_host_data.set('CONFIG_VNC_JPEG', jpeg.found()) @@ -2780,7 +2783,7 @@ summary_info +=3D {'rbd support': rbd.found()} summary_info +=3D {'xfsctl support': config_host.has_key('CONFIG_XFS')} summary_info +=3D {'smartcard support': config_host.has_key('CONFIG_SMARTC= ARD')} summary_info +=3D {'U2F support': u2f.found()} -summary_info +=3D {'libusb': config_host.has_key('CONFIG_USB_LI= BUSB')} +summary_info +=3D {'libusb': libusb.found()} summary_info +=3D {'usb net redir': config_host.has_key('CONFIG_USB_RE= DIR')} summary_info +=3D {'OpenGL support': config_host.has_key('CONFIG_OPENGL= ')} summary_info +=3D {'GBM': config_host.has_key('CONFIG_GBM')} diff --git a/meson_options.txt b/meson_options.txt index ac6e90da07..02c14d4751 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -86,6 +86,8 @@ option('gcrypt', type : 'feature', value : 'auto', description: 'libgcrypt cryptography support') option('libudev', type : 'feature', value : 'auto', description: 'Use libudev to enumerate host devices') +option('libusb', type : 'feature', value : 'auto', + description: 'libusb support for USB passthrough') option('lzfse', type : 'feature', value : 'auto', description: 'lzfse support for DMG images') option('lzo', type : 'feature', value : 'auto', --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624630955343832.2433010743008; Fri, 25 Jun 2021 07:22:35 -0700 (PDT) Received: from localhost ([::1]:38412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmj4-0003TI-BD for importer@patchew.org; Fri, 25 Jun 2021 10:22:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60708) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfD-0002zu-IC for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:35 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:43754) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfB-0003Ay-OX for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:35 -0400 Received: by mail-ed1-x536.google.com with SMTP id s6so13576985edu.10 for ; Fri, 25 Jun 2021 07:18:33 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:32 -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=/NJW9B47FFiAWRRAuH2I9olXcKoFv5w9OJzC75jNnJo=; b=llvwrV9IJ+yinfTUH+eNGhCqgXOvN6QI7kpP4K2D9nHYjrQ2hJVRlMCud7tzj0Lb5Z guQFW1bUmdBWQxY2nTvYilBX2+su0Fuz7NvqXI9PlSf8gy5LkdxgvTglWHDK09Ab7eTi FWDqXP/y8MIBjMb0+RJOd0+nbCcN+tX8jmnOgfMRW3FkKzzxbobHyKALkVAUX8yHNJLE iXu59fcM9sQ2wCLTQPAoV7ki+Ee31xxoD9pZKZCC7NP8PaIPkLrhXxFWU+CuOIdvnRh6 sBUgMu7ua6+qifei2Lguj16v8o+pgLCRpdBFJWroMYlInuNqCKZE+K816TAlUyrI2jL8 9qCQ== 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=/NJW9B47FFiAWRRAuH2I9olXcKoFv5w9OJzC75jNnJo=; b=XDLuStVxSOHQYWUkxBvdGamE4XcxB/QFkQAciwSf1spNPNcq+HxpevqPrVLUIc8Zf+ 7Xj72aYI4udZYd8h5G2gi9j47OHuKSdn2YR9Ei9B6Z4vBE1Yu5VKImcErdGJkwjIq+29 qfHQy29bRhDvosxPRnJn4fGMkVAisxEgqGNWc3U3vVhq00tTyJMF9Gt6VLEsVKBuvmJ8 ekeFXu/jGIhuTJyttGVN4FGWiZ1Yvg9dCH0YKU3Tqkle08AL1mUcoY6XdkHDi51w5xi7 ir+iG97lEyc7ACuiTlMoLv/FUpOOMjBYfhg55NXjjDkRt6+H9HskQ2bioxqWs1W2hugD c4Iw== X-Gm-Message-State: AOAM531a6MBKo4aNfZXP5S818fTfyxVxap4EcQlEWqPQkAKj4crWEMgy 0xeK31t4Las6eaOnoOs58DwiL1Iyd+c= X-Google-Smtp-Source: ABdhPJwgUFIvE53eFDmETqRKl/mwMxZyAq4Lzn/Vt2wd8K1LLzbdpERBaQon8V94Jp2zQRybAA9nSA== X-Received: by 2002:aa7:c799:: with SMTP id n25mr14627046eds.16.1624630712389; Fri, 25 Jun 2021 07:18:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 10/28] configure, meson: convert libcacard detection to meson Date: Fri, 25 Jun 2021 16:18:04 +0200 Message-Id: <20210625141822.1368639-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- configure | 28 ++++------------------------ hw/usb/meson.build | 2 +- meson.build | 9 +++++---- meson_options.txt | 2 ++ 4 files changed, 12 insertions(+), 29 deletions(-) diff --git a/configure b/configure index e54d06b99e..02b0acc1f5 100755 --- a/configure +++ b/configure @@ -372,7 +372,7 @@ trace_file=3D"trace" spice=3D"$default_feature" spice_protocol=3D"auto" rbd=3D"auto" -smartcard=3D"$default_feature" +smartcard=3D"auto" u2f=3D"auto" libusb=3D"auto" usb_redir=3D"$default_feature" @@ -1277,9 +1277,9 @@ for opt do ;; --enable-xfsctl) xfs=3D"yes" ;; - --disable-smartcard) smartcard=3D"no" + --disable-smartcard) smartcard=3D"disabled" ;; - --enable-smartcard) smartcard=3D"yes" + --enable-smartcard) smartcard=3D"enabled" ;; --disable-u2f) u2f=3D"disabled" ;; @@ -3980,20 +3980,6 @@ EOF fi fi =20 -# check for smartcard support -if test "$smartcard" !=3D "no"; then - if $pkg_config --atleast-version=3D2.5.1 libcacard; then - libcacard_cflags=3D$($pkg_config --cflags libcacard) - libcacard_libs=3D$($pkg_config --libs libcacard) - smartcard=3D"yes" - else - if test "$smartcard" =3D "yes"; then - feature_not_found "smartcard" "Install libcacard devel" - fi - smartcard=3D"no" - fi -fi - # check for usbredirparser for usb network redirection support if test "$usb_redir" !=3D "no" ; then if $pkg_config --atleast-version=3D0.6 libusbredirparser-0.5; then @@ -5611,12 +5597,6 @@ if test "$spice" =3D "yes" ; then echo "SPICE_LIBS=3D$spice_libs" >> $config_host_mak fi =20 -if test "$smartcard" =3D "yes" ; then - echo "CONFIG_SMARTCARD=3Dy" >> $config_host_mak - echo "SMARTCARD_CFLAGS=3D$libcacard_cflags" >> $config_host_mak - echo "SMARTCARD_LIBS=3D$libcacard_libs" >> $config_host_mak -fi - if test "$usb_redir" =3D "yes" ; then echo "CONFIG_USB_REDIR=3Dy" >> $config_host_mak echo "USB_REDIR_CFLAGS=3D$usb_redir_cflags" >> $config_host_mak @@ -6195,7 +6175,7 @@ if test "$skip_meson" =3D no; then -Dkvm=3D$kvm -Dhax=3D$hax -Dwhpx=3D$whpx -Dhvf=3D$hvf -Dnvmm=3D$nv= mm \ -Dxen=3D$xen -Dxen_pci_passthrough=3D$xen_pci_passthrough -Dtcg=3D= $tcg \ -Dcocoa=3D$cocoa -Dgtk=3D$gtk -Dmpath=3D$mpath -Dsdl=3D$sdl -Dsdl_= image=3D$sdl_image \ - -Dlibusb=3D$libusb \ + -Dlibusb=3D$libusb -Dsmartcard=3D$smartcard \ -Dvnc=3D$vnc -Dvnc_sasl=3D$vnc_sasl -Dvnc_jpeg=3D$vnc_jpeg -Dvnc_p= ng=3D$vnc_png \ -Dgettext=3D$gettext -Dxkbcommon=3D$xkbcommon -Du2f=3D$u2f -Dvirti= ofsd=3D$virtiofsd \ -Dcapstone=3D$capstone -Dslirp=3D$slirp -Dfdt=3D$fdt -Dbrlapi=3D$b= rlapi \ diff --git a/hw/usb/meson.build b/hw/usb/meson.build index bd3f8735b9..df9effbb10 100644 --- a/hw/usb/meson.build +++ b/hw/usb/meson.build @@ -49,7 +49,7 @@ softmmu_ss.add(when: ['CONFIG_POSIX', 'CONFIG_USB_STORAGE= _MTP'], if_true: files( # smartcard softmmu_ss.add(when: 'CONFIG_USB_SMARTCARD', if_true: files('dev-smartcard= -reader.c')) =20 -if config_host.has_key('CONFIG_SMARTCARD') +if cacard.found() usbsmartcard_ss =3D ss.source_set() usbsmartcard_ss.add(when: 'CONFIG_USB_SMARTCARD', if_true: [cacard, files('ccid-card-emulated.c', 'cci= d-card-passthru.c')]) diff --git a/meson.build b/meson.build index 0b4b55b9da..afcfcb8c57 100644 --- a/meson.build +++ b/meson.build @@ -976,9 +976,10 @@ if 'CONFIG_XEN_BACKEND' in config_host link_args: config_host['XEN_LIBS'].split()) endif cacard =3D not_found -if 'CONFIG_SMARTCARD' in config_host - cacard =3D declare_dependency(compile_args: config_host['SMARTCARD_CFLAG= S'].split(), - link_args: config_host['SMARTCARD_LIBS'].spl= it()) +if not get_option('smartcard').auto() or have_system + cacard =3D dependency('libcacard', required: get_option('smartcard'), + version: '>=3D2.5.1', method: 'pkg-config', + kwargs: static_kwargs) endif u2f =3D not_found if have_system @@ -2781,7 +2782,7 @@ summary_info +=3D {'bpf support': libbpf.found()} summary_info +=3D {'spice support': config_host.has_key('CONFIG_SPICE'= )} summary_info +=3D {'rbd support': rbd.found()} summary_info +=3D {'xfsctl support': config_host.has_key('CONFIG_XFS')} -summary_info +=3D {'smartcard support': config_host.has_key('CONFIG_SMARTC= ARD')} +summary_info +=3D {'smartcard support': cacard.found()} summary_info +=3D {'U2F support': u2f.found()} summary_info +=3D {'libusb': libusb.found()} summary_info +=3D {'usb net redir': config_host.has_key('CONFIG_USB_RE= DIR')} diff --git a/meson_options.txt b/meson_options.txt index 02c14d4751..cd9374384e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -102,6 +102,8 @@ option('sdl_image', type : 'feature', value : 'auto', description: 'SDL Image support for icons') option('seccomp', type : 'feature', value : 'auto', description: 'seccomp support') +option('smartcard', type : 'feature', value : 'auto', + description: 'CA smartcard emulation support') option('snappy', type : 'feature', value : 'auto', description: 'snappy compression support') option('u2f', type : 'feature', value : 'auto', --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624631820510652.2364190882736; Fri, 25 Jun 2021 07:37:00 -0700 (PDT) Received: from localhost ([::1]:46772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmx1-0003BP-EQ for importer@patchew.org; Fri, 25 Jun 2021 10:36:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfE-00033M-Rf for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:36 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:46735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfD-0003Bb-05 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:36 -0400 Received: by mail-ej1-x633.google.com with SMTP id he7so15318422ejc.13 for ; Fri, 25 Jun 2021 07:18:34 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:33 -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=Q0BrjeX003f4H8n7HgbRfeuIihV2tjbzl35CC2wo30o=; b=t8lOowhhxPakUVfLDkeFhecRBpk/xC5YYzQnppz0+0yrqYxhTxnFztdLq2wK3LsdVw 1LUrEga7v/J5weNkYKC6O0WCYbXVwStqkFO+JdGu8MaWqcLUR5EcDBZbKSp+4uj6UrFa xj2ZfDgaHDmGETZ6soGvX/RBrQpEfiHJLU2+X7jonD3WEM+Z5sWTZwfCtVDVMDgAZDDZ sw5rqZreF8A9tWOF1KLvgwjxTxe4ogQIHG3DSiVCQnsQLaGvLRBLl0BNyRc9+e/n+Wfd Kzr6FIxgE+8ZbAviM56Qm9P8kuIGmyij+AGqZSUgAiIaXldp3FukVzsQjZswNh7XSW58 x26w== 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=Q0BrjeX003f4H8n7HgbRfeuIihV2tjbzl35CC2wo30o=; b=tjo2bgNGs3ttFtmaHOfh6ad/MDTGvnI1QBfDK+AyKQSOveZ6RwHxEkEQ8rcltLcDFv m18pGb6N2n5g2R8wk+m9r4a92czf8ELbBHNrTukCfEXhMBZJVbfTdWOylqYcs4H1kZX8 Aw96GdxfnEAzyYHbgA/CCD4+rGfHLp8VUQFoW00mcNqrgCf3WgQQ86ORKKEmlUdXJ4L8 TQg2j1Yq6EFTXoCXsY7Z6IJGC7dWxHnmkXHb64yPtVzct6bkeOxIFADXtYe1Wr8i0ypi h9lpeLdihr/Rhv1066NqtXkonnRHLjxrrSw18XCSXOsMxpuetEjYWldOOkP/yVZz8yzf cdDg== X-Gm-Message-State: AOAM5324DaUxcxCR/TVe8DtO2csh6ospdrlKt3U2QfgV81evD+bxAtRR Qt00RCCHFBOyU1KjklmALUQ84IXtPqE= X-Google-Smtp-Source: ABdhPJydoZKdc8O0xhSzKAthNzuvSyNASN3OsnA+NHTzOkGp4ibv2KPNenxdCa5xAAnTbDwgb043gA== X-Received: by 2002:a17:906:606:: with SMTP id s6mr11093789ejb.206.1624630713597; Fri, 25 Jun 2021 07:18:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 11/28] configure, meson: convert libusbredir detection to meson Date: Fri, 25 Jun 2021 16:18:05 +0200 Message-Id: <20210625141822.1368639-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- configure | 28 ++++------------------------ hw/usb/meson.build | 2 +- meson.build | 9 +++++---- meson_options.txt | 2 ++ 4 files changed, 12 insertions(+), 29 deletions(-) diff --git a/configure b/configure index 02b0acc1f5..e799d908a3 100755 --- a/configure +++ b/configure @@ -375,7 +375,7 @@ rbd=3D"auto" smartcard=3D"auto" u2f=3D"auto" libusb=3D"auto" -usb_redir=3D"$default_feature" +usb_redir=3D"auto" opengl=3D"$default_feature" cpuid_h=3D"no" avx2_opt=3D"$default_feature" @@ -1289,9 +1289,9 @@ for opt do ;; --enable-libusb) libusb=3D"enabled" ;; - --disable-usb-redir) usb_redir=3D"no" + --disable-usb-redir) usb_redir=3D"disabled" ;; - --enable-usb-redir) usb_redir=3D"yes" + --enable-usb-redir) usb_redir=3D"enabled" ;; --disable-zlib-test) ;; @@ -3980,20 +3980,6 @@ EOF fi fi =20 -# check for usbredirparser for usb network redirection support -if test "$usb_redir" !=3D "no" ; then - if $pkg_config --atleast-version=3D0.6 libusbredirparser-0.5; then - usb_redir=3D"yes" - usb_redir_cflags=3D$($pkg_config --cflags libusbredirparser-0.5) - usb_redir_libs=3D$($pkg_config --libs libusbredirparser-0.5) - else - if test "$usb_redir" =3D "yes"; then - feature_not_found "usb-redir" "Install usbredir devel" - fi - usb_redir=3D"no" - fi -fi - ########################################## # check if we have VSS SDK headers for win =20 @@ -5597,12 +5583,6 @@ if test "$spice" =3D "yes" ; then echo "SPICE_LIBS=3D$spice_libs" >> $config_host_mak fi =20 -if test "$usb_redir" =3D "yes" ; then - echo "CONFIG_USB_REDIR=3Dy" >> $config_host_mak - echo "USB_REDIR_CFLAGS=3D$usb_redir_cflags" >> $config_host_mak - echo "USB_REDIR_LIBS=3D$usb_redir_libs" >> $config_host_mak -fi - if test "$opengl" =3D "yes" ; then echo "CONFIG_OPENGL=3Dy" >> $config_host_mak echo "OPENGL_CFLAGS=3D$opengl_cflags" >> $config_host_mak @@ -6175,7 +6155,7 @@ if test "$skip_meson" =3D no; then -Dkvm=3D$kvm -Dhax=3D$hax -Dwhpx=3D$whpx -Dhvf=3D$hvf -Dnvmm=3D$nv= mm \ -Dxen=3D$xen -Dxen_pci_passthrough=3D$xen_pci_passthrough -Dtcg=3D= $tcg \ -Dcocoa=3D$cocoa -Dgtk=3D$gtk -Dmpath=3D$mpath -Dsdl=3D$sdl -Dsdl_= image=3D$sdl_image \ - -Dlibusb=3D$libusb -Dsmartcard=3D$smartcard \ + -Dlibusb=3D$libusb -Dsmartcard=3D$smartcard -Dusb_redir=3D$usb_red= ir \ -Dvnc=3D$vnc -Dvnc_sasl=3D$vnc_sasl -Dvnc_jpeg=3D$vnc_jpeg -Dvnc_p= ng=3D$vnc_png \ -Dgettext=3D$gettext -Dxkbcommon=3D$xkbcommon -Du2f=3D$u2f -Dvirti= ofsd=3D$virtiofsd \ -Dcapstone=3D$capstone -Dslirp=3D$slirp -Dfdt=3D$fdt -Dbrlapi=3D$b= rlapi \ diff --git a/hw/usb/meson.build b/hw/usb/meson.build index df9effbb10..4f24b5274d 100644 --- a/hw/usb/meson.build +++ b/hw/usb/meson.build @@ -64,7 +64,7 @@ if u2f.found() endif =20 # usb redirect -if config_host.has_key('CONFIG_USB_REDIR') +if usbredir.found() usbredir_ss =3D ss.source_set() usbredir_ss.add(when: 'CONFIG_USB', if_true: [usbredir, files('redirect.c', 'quirks.c')]) diff --git a/meson.build b/meson.build index afcfcb8c57..64e23175ab 100644 --- a/meson.build +++ b/meson.build @@ -988,9 +988,10 @@ if have_system kwargs: static_kwargs) endif usbredir =3D not_found -if 'CONFIG_USB_REDIR' in config_host - usbredir =3D declare_dependency(compile_args: config_host['USB_REDIR_CFL= AGS'].split(), - link_args: config_host['USB_REDIR_LIBS'].s= plit()) +if not get_option('usb_redir').auto() or have_system + usbredir =3D dependency('libusbredirparser-0.5', required: get_option('u= sb_redir'), + version: '>=3D0.6', method: 'pkg-config', + kwargs: static_kwargs) endif libusb =3D not_found if not get_option('libusb').auto() or have_system @@ -2785,7 +2786,7 @@ summary_info +=3D {'xfsctl support': config_host.h= as_key('CONFIG_XFS')} summary_info +=3D {'smartcard support': cacard.found()} summary_info +=3D {'U2F support': u2f.found()} summary_info +=3D {'libusb': libusb.found()} -summary_info +=3D {'usb net redir': config_host.has_key('CONFIG_USB_RE= DIR')} +summary_info +=3D {'usb net redir': usbredir.found()} summary_info +=3D {'OpenGL support': config_host.has_key('CONFIG_OPENGL= ')} summary_info +=3D {'GBM': config_host.has_key('CONFIG_GBM')} summary_info +=3D {'libiscsi support': libiscsi.found()} diff --git a/meson_options.txt b/meson_options.txt index cd9374384e..f7ec9bee27 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -108,6 +108,8 @@ option('snappy', type : 'feature', value : 'auto', description: 'snappy compression support') option('u2f', type : 'feature', value : 'auto', description: 'U2F emulation support') +option('usb_redir', type : 'feature', value : 'auto', + description: 'libusbredir support') option('vnc', type : 'feature', value : 'enabled', description: 'VNC server') option('vnc_jpeg', type : 'feature', value : 'auto', --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624631169149991.4309859004761; Fri, 25 Jun 2021 07:26:09 -0700 (PDT) Received: from localhost ([::1]:46030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmmV-0000Ic-GH for importer@patchew.org; Fri, 25 Jun 2021 10:26:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfF-00034j-Ag for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:37 -0400 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]:35565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfD-0003Bk-Mh for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:37 -0400 Received: by mail-ej1-x62f.google.com with SMTP id gn32so15427179ejc.2 for ; Fri, 25 Jun 2021 07:18:35 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:33 -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=Q0ZN4n/dtFMRMepbnfjzMN5tAEFeuoYDClHc1sps4os=; b=BvA2sa9AXHBTzWQ/x4oAmT2IsEmoyGBVG+qCup6YekPCSzpGS0swRM6PIrsFskM54j j3ehNiXecn3URf8uWhFeBbKRHoy8URW+QAHLPZvQ8sHpPh2+ZSw4rT52vZqPo3AQRp+0 GZqgkBwWmi84uSlB+nHEL0fwX6fGPJxovHXjQmPubFPx7UzKqNPYrNV7hh4WaKzkn6SW LpmF1Mg6OBJ/81iik6aIGSVJk8bLr2ovunu8g2QHEppNYYunIkAq3ed1BuuFokLC3SwR Yjl3QxoD4LY1odSFbey23fKEB50SIWMRPuXBxArv8ukl82ww/ROkuhw4d0TI4aPzqIkz tUWg== 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=Q0ZN4n/dtFMRMepbnfjzMN5tAEFeuoYDClHc1sps4os=; b=i+JG0AkxhtOBQTE0sKHzTHsFy6AxWoy0vpAovO+khZW1nAKOWjkLtXzEJktbHD6SRE FQr2Wy9lmBsdoxB5iH3gkgk7wS9kmCoDbe4r/yVpaUXyltYqg+9sBuPLlG7Sxz97Wy+i RRMl9qtKvYCVxJ5ZKvQN/Vhj8aUQIHEvUhLx6WB0LLvk1nmR0u2qt6oJbXyMmGyQwbAF lSHs3tqMhE34AuihSAMTGK1VyI+OSC2FgTLcvD5K7zuTQeWGf6Bt6E//aRkZQcO3mebp IKQg0WusvUpTlrWZEcXtIqAzEazHIh+B3MlDSKfYMqA0DiIDcMogqlXcCYdmChbYgbiB AKKg== X-Gm-Message-State: AOAM531faFYGoXmjhyQMTGscEnbK84kn5CiRs857WcXvzzimhEAGymC3 qWlX+7t5Y3w8vbQw6XbXoO/dZ7fd83I= X-Google-Smtp-Source: ABdhPJzwvFQ7RgW6DZ0rJywrROR3UAxsKGMlzaPVQLzjMb0U/H1dwz4ygUzhJlkQpKYZ30LGn1fDLw== X-Received: by 2002:a17:907:384:: with SMTP id ss4mr11150613ejb.120.1624630714413; Fri, 25 Jun 2021 07:18:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 12/28] KVM: Fix dirty ring mmap incorrect size due to renaming accident Date: Fri, 25 Jun 2021 16:18:06 +0200 Message-Id: <20210625141822.1368639-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62f.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: Hyman Huang , "Dr . David Alan Gilbert" , Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Peter Xu Found this when I wanted to try the per-vcpu dirty rate series out, then I found that it's not really working and it can quickly hang death a guest. I found strange errors (e.g. guest crash after migration) happens even without the per-vcpu dirty rate series. When merging dirty ring, probably no one notice that the trivial renaming d= iff [1] missed two existing references of kvm_dirty_ring_sizes; they do matter since otherwise we'll mmap() a shorter range of memory after the renaming. I think it didn't SIGBUS for me easily simply because some other stuff with= in qemu mmap()ed right after the dirty rings (e.g. when testing 4096 slots, it aligned with one small page on x86), so when we access the rings we've been reading/writting to random memory elsewhere of qemu. Fix the two sizes when map/unmap the shared dirty gfn memory. [1] https://lore.kernel.org/qemu-devel/dac5f0c6-1bca-3daf-e5d2-6451dbbaca93= @redhat.com/ Cc: Hyman Huang Cc: Paolo Bonzini Cc: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20210609014355.217110-1-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index c7ec538850..e5b10dd129 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -411,7 +411,7 @@ static int do_kvm_destroy_vcpu(CPUState *cpu) } =20 if (cpu->kvm_dirty_gfns) { - ret =3D munmap(cpu->kvm_dirty_gfns, s->kvm_dirty_ring_size); + ret =3D munmap(cpu->kvm_dirty_gfns, s->kvm_dirty_ring_bytes); if (ret < 0) { goto err; } @@ -495,7 +495,7 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp) =20 if (s->kvm_dirty_ring_size) { /* Use MAP_SHARED to share pages with the kernel */ - cpu->kvm_dirty_gfns =3D mmap(NULL, s->kvm_dirty_ring_size, + cpu->kvm_dirty_gfns =3D mmap(NULL, s->kvm_dirty_ring_bytes, PROT_READ | PROT_WRITE, MAP_SHARED, cpu->kvm_fd, PAGE_SIZE * KVM_DIRTY_LOG_PAGE_OFFSET); --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16246320010992.9345204300700516; Fri, 25 Jun 2021 07:40:01 -0700 (PDT) Received: from localhost ([::1]:55350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmzw-0000Sg-1I for importer@patchew.org; Fri, 25 Jun 2021 10:40:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfI-0003Ee-S0 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:40 -0400 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]:46728) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfH-0003DU-9q for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:40 -0400 Received: by mail-ej1-x62a.google.com with SMTP id he7so15318753ejc.13 for ; Fri, 25 Jun 2021 07:18:38 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:34 -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=GjCZXEAAw7qiNbzDIiyL4DTYii0HnblTscfX7SsNJa4=; b=M9IOQKpKAR0FvTblWAwjs/P7/R797OtDX8uMSX5QLo2gbW5dG2Dnw2j/9QwfllBmC0 rz/paPDgjkXXlfioIkJ69Rz9eaYN4R39UIvPGghdGYSPIW0Tq/jxaNVUdZYU6jjb/0B3 0wlHd9W3C/WScaAZXoQ5KUaSUdFBzjy5YqF1QIrGea4GNmN8COVnfMnX2ZhTBzC0SbX9 yJjTdv3ngiA+CA8VAWXPqrijdyBPM1F+MQiSTo4oawe3pyvrc1C5xbsX210Y/5s0R4bN lG4lYNAjxQpeW2r4/z20JQi+KsB4/f/+VAO0SZAskUJm9WKWe25oX6xmBCPtHM+JoXLf J0PA== 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=GjCZXEAAw7qiNbzDIiyL4DTYii0HnblTscfX7SsNJa4=; b=MprDj3jD415l42rF2V3eK6joR5NRXsv9Le4QqRgBEtd8XOarzc3ndqnDpPtubavG03 JOzjfD7Iv9IqYvjiFE7PEY6bf4280mOjow0JvbzfWizfrZFMJPYJ4dGit92o2rPnr9Q+ luGvlczyuVCd3HBG7gwFJVphGEPFciVl1jCLBezvpavvoVZKuqxtSksMYOX78W8eDO6Z LjdkEvKkYtYmLG/yCkBhiL+sZDg/eWPV1zCljv8O981KcprcFvBqaOuJRhCpaX2Fo0DG Krqrl+AQ3YkmyspOLd7C8O1TfCa0tCI0S2e16dbQ02CUVwK1xvQPzUNbaEgA9U7H9LSj NXLA== X-Gm-Message-State: AOAM5334wRwcfIySL5lIH6FoavcwbGsG+akJshybb0mvedij2hhTol3L vbZCLd/EUVlMDv0UgqridquM9GHbM/Y= X-Google-Smtp-Source: ABdhPJxO7iZN7BNyGeRZ+nEFdtmQhZ3MCCFk+BJ/qCTciXK8dDk4TXsWkbRQ1ADXBJ1N5dBhO7zeRw== X-Received: by 2002:a17:907:8329:: with SMTP id mq41mr11038782ejc.319.1624630715143; Fri, 25 Jun 2021 07:18:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 13/28] file-posix: fix max_iov for /dev/sg devices Date: Fri, 25 Jun 2021 16:18:07 +0200 Message-Id: <20210625141822.1368639-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62a.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Even though it was only called for devices that have bs->sg set (which must be character devices), sg_get_max_segments looked at /sys/dev/block which only works for block devices. On Linux the sg driver has its own way to provide the maximum number of iovecs in a scatter/gather list, so add support for it. The block device path is kept because it will be reinstated in the next patches. Signed-off-by: Paolo Bonzini Reviewed-by: Max Reitz --- block/file-posix.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/block/file-posix.c b/block/file-posix.c index b3fbb9bd63..b8dc19ce1a 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1178,6 +1178,17 @@ static int sg_get_max_segments(int fd) goto out; } =20 + if (S_ISCHR(st.st_mode)) { + if (ioctl(fd, SG_GET_SG_TABLESIZE, &ret) =3D=3D 0) { + return ret; + } + return -ENOTSUP; + } + + if (!S_ISBLK(st.st_mode)) { + return -ENOTSUP; + } + sysfspath =3D g_strdup_printf("/sys/dev/block/%u:%u/queue/max_segments= ", major(st.st_rdev), minor(st.st_rdev)); sysfd =3D open(sysfspath, O_RDONLY); --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624631191617589.9679964846002; Fri, 25 Jun 2021 07:26:31 -0700 (PDT) Received: from localhost ([::1]:46760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmms-0000nn-Fx for importer@patchew.org; Fri, 25 Jun 2021 10:26:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfJ-0003Gq-II for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:41 -0400 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]:42573) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfI-0003Dp-0U for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:41 -0400 Received: by mail-ed1-x531.google.com with SMTP id m14so13622372edp.9 for ; Fri, 25 Jun 2021 07:18:39 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:38 -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=oBy2rWBfxuFWeS2NQNlXhg91jwIz3LB5M14uVRp5Bzc=; b=g1BMS5Gl/DSFMP3wslBn8/Mdb5F2T8aVULnRn4SFWmPoAHZUzwknKjJdmVK9hHqx9D LQ8889rgBHsuGNoWnV8taKTBak/viDeCU3yVu+XHUKIOGfTdE5oc6kkil2GQAp4lbWmd v5F7UYaCC4sSbLRPT7Xw517kAHUYXDIBi3e89fmo5oCo05RzuOHoM4HH9k/rJro1vDfn dSJEr+xlyuYNnSETyfdUvZgR/WRM7lQ6eadqEw7wheYbPFdd1FeIkm/F91T+/T/1teeC eQpWVEudWkkkvhSBNm46gZS1rX321MTXTwbHz7ViPtbqOEEluModqFKzzRr+EvBKll0m cR6Q== 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=oBy2rWBfxuFWeS2NQNlXhg91jwIz3LB5M14uVRp5Bzc=; b=LyXEx49wRA18DaSkXf4tM5LB73XchnHSWfBNudKhGnKZlOz68ClUcQW+WyQ3VQzEMO AAtYdUxb5b281U6FqeVju/jruPUWohTtBP46uQsJ5emn7AJlJari/gsjwyN/Bbw59H/n 4ZuQ4/z1qCxg6Dtj+LTZsf449qwU5iTo4YiGF+9l3AEt09Uo7/3IImmUYeVC31OT3And mTby6FnxkJl/X9aHMib1ac+T9KD2QvHCkgYJJyqFyxSV7pQ0uNqUyEvyjuai0JnI1L2H vdFLiouifu1vzg3u2ZxBW9ZhK2gsxzHAMeDZ3uIzQrp5J8ZRpFL5E3+o5c+SiDkBsV7f mW2A== X-Gm-Message-State: AOAM5322VMIbnW0jru78bFoZXyUmeNM1UhSyyAJEuSQfITCGlBfCRx4Y H3ABf7GhWaBCmpb69CGCoCSDFCnugmw= X-Google-Smtp-Source: ABdhPJz6lsLJ7t1fbpRNust1bRvlk+IwQZONwarxt4+5rtRZXhUjnBUNdYxzYw/Ii9yBmvXJswVNGg== X-Received: by 2002:a05:6402:944:: with SMTP id h4mr14610303edz.76.1624630718623; Fri, 25 Jun 2021 07:18:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 14/28] scsi-generic: pass max_segments via max_iov field in BlockLimits Date: Fri, 25 Jun 2021 16:18:08 +0200 Message-Id: <20210625141822.1368639-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x531.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" I/O to a disk via read/write is not limited by the number of segments allow= ed by the host adapter; the kernel can split requests if needed, and the limit imposed by the host adapter can be very low (256k or so) to avoid that SG_IO returns EINVAL if memory is heavily fragmented. Since this value is only interesting for SG_IO-based I/O, do not include it in the max_transfer and only take it into account when patching the block limits VPD page in the scsi-generic device. Signed-off-by: Paolo Bonzini Reviewed-by: Max Reitz --- block/file-posix.c | 3 +-- hw/scsi/scsi-generic.c | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index b8dc19ce1a..6db690baf2 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1237,8 +1237,7 @@ static void raw_refresh_limits(BlockDriverState *bs, = Error **errp) =20 ret =3D sg_get_max_segments(s->fd); if (ret > 0) { - bs->bl.max_transfer =3D MIN(bs->bl.max_transfer, - ret * qemu_real_host_page_size); + bs->bl.max_iov =3D ret; } } =20 diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index 40e039864f..b6c4143dc7 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -179,10 +179,12 @@ static int scsi_handle_inquiry_reply(SCSIGenericReq *= r, SCSIDevice *s, int len) (r->req.cmd.buf[1] & 0x01)) { page =3D r->req.cmd.buf[2]; if (page =3D=3D 0xb0) { - uint32_t max_transfer =3D - blk_get_max_transfer(s->conf.blk) / s->blocksize; + uint32_t max_transfer =3D blk_get_max_transfer(s->conf.blk); + uint32_t max_iov =3D blk_get_max_iov(s->conf.blk); =20 assert(max_transfer); + max_transfer =3D MIN_NON_ZERO(max_transfer, max_iov * qemu_rea= l_host_page_size) + / s->blocksize; stl_be_p(&r->buf[8], max_transfer); /* Also take care of the opt xfer len. */ stl_be_p(&r->buf[12], --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624631370544658.6893165428644; Fri, 25 Jun 2021 07:29:30 -0700 (PDT) Received: from localhost ([::1]:54642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmpl-0006CY-IF for importer@patchew.org; Fri, 25 Jun 2021 10:29:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfK-0003JJ-7P for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:42 -0400 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]:43548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfI-0003Ep-Jc for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:41 -0400 Received: by mail-ej1-x632.google.com with SMTP id nb6so15364314ejc.10 for ; Fri, 25 Jun 2021 07:18:40 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:38 -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=GNN3PKGCrmEv1egmkbcKJ78YTkUsB3DLKlu9c2s2Q9Y=; b=SDawVslL8U2T3cqpgFD4moIXEhvIRIUP9jUv/u9jwug3+tuhScbxWsS3DU9HGltonz WR8GePGsJbSjJUdyH7Au0Urh9nDP/E3gKzzNl9RR/8Rxj4lUihj3ElejK/XIoJN9fJtC h9fORT/s7TBqCzODkdGue6SXYbJc4T9ObcVh1wMmkawjDgY8XCC2NtA6psMFuwlbGGNG Uor3hJNsgNbzKoB/YFeFGhzovkMYDVehxa55rQ2/UAMmQqr7v3YHdr09ZCFFEvBq+1wO 042ouAD3D0IsqE/fcmVHBIdz6mz49lRHXblZxmyEa/kT1jsxQ4Ws9NjcJcGyrSDdwRHz RgDw== 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=GNN3PKGCrmEv1egmkbcKJ78YTkUsB3DLKlu9c2s2Q9Y=; b=h7+c8dv/kYVIt5N5v+Wk5QsDIvrxnrG0SII4U8vrozsiVh3Ts/0tfe0zoCJFwyXKFG u+zZzhbz9TWz/YxWQlf3NCD9KfyA45R/YLFOnCVcqbniSGXl6DjWg/4iPc7pknj0OOzC Hfg1Eh90rAPO6IfWtDwT7ECzlSV5OKJb6KjIRRtBK1LZnBD4DTKGGUGJO3LjaXgqT7fh uZZKBjrJfPj5ISjADQOEuuOrYkq54UpeLMkI1+rnyWFDOBo617jHToYoPEugUiN4vxay 2Ff3fuQlsO7vH/DrGVH3PGs767duvBWty8JhEtBVE22U3NAEzTXTLsJE53jiS4DR6PJV VPtA== X-Gm-Message-State: AOAM531wuUiaKSYWLHCclBlClENGvYl+weN4L2x3Z7g4H7vbDz6gfwbn uIKcbcfM74AZcnZqTZbKjbDLm5l1b6Q= X-Google-Smtp-Source: ABdhPJwQXDflJpWbtWiTOmgMcbG51cMATsdujMtsQ9fCJYJxaTvSReLAyU9smW/lMgXWgi6kLGMnDA== X-Received: by 2002:a17:906:2bd9:: with SMTP id n25mr11233122ejg.513.1624630719267; Fri, 25 Jun 2021 07:18:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 15/28] osdep: provide ROUND_DOWN macro Date: Fri, 25 Jun 2021 16:18:09 +0200 Message-Id: <20210625141822.1368639-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::632; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x632.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" osdep.h provides a ROUND_UP macro to hide bitwise operations for the purpose of rounding a number up to a power of two; add a ROUND_DOWN macro that does the same with truncation towards zero. While at it, change the formatting of some comments. Signed-off-by: Paolo Bonzini Reviewed-by: Max Reitz Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu/osdep.h | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 0a54bf7be8..c3656b755a 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -319,11 +319,16 @@ extern "C" { }) #endif =20 -/* Round number down to multiple */ +/* + * Round number down to multiple. Safe when m is not a power of 2 (see + * ROUND_DOWN for a faster version when a power of 2 is guaranteed). + */ #define QEMU_ALIGN_DOWN(n, m) ((n) / (m) * (m)) =20 -/* Round number up to multiple. Safe when m is not a power of 2 (see - * ROUND_UP for a faster version when a power of 2 is guaranteed) */ +/* + * Round number up to multiple. Safe when m is not a power of 2 (see + * ROUND_UP for a faster version when a power of 2 is guaranteed). + */ #define QEMU_ALIGN_UP(n, m) QEMU_ALIGN_DOWN((n) + (m) - 1, (m)) =20 /* Check if n is a multiple of m */ @@ -340,11 +345,22 @@ extern "C" { /* Check if pointer p is n-bytes aligned */ #define QEMU_PTR_IS_ALIGNED(p, n) QEMU_IS_ALIGNED((uintptr_t)(p), (n)) =20 -/* Round number up to multiple. Requires that d be a power of 2 (see +/* + * Round number down to multiple. Requires that d be a power of 2 (see * QEMU_ALIGN_UP for a safer but slower version on arbitrary - * numbers); works even if d is a smaller type than n. */ + * numbers); works even if d is a smaller type than n. + */ +#ifndef ROUND_DOWN +#define ROUND_DOWN(n, d) ((n) & -(0 ? (n) : (d))) +#endif + +/* + * Round number up to multiple. Requires that d be a power of 2 (see + * QEMU_ALIGN_UP for a safer but slower version on arbitrary + * numbers); works even if d is a smaller type than n. + */ #ifndef ROUND_UP -#define ROUND_UP(n, d) (((n) + (d) - 1) & -(0 ? (n) : (d))) +#define ROUND_UP(n, d) ROUND_DOWN((n) + (d) - 1, (d)) #endif =20 #ifndef DIV_ROUND_UP --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624632136317230.57367579658796; Fri, 25 Jun 2021 07:42:16 -0700 (PDT) Received: from localhost ([::1]:35690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwn27-0006Ga-7S for importer@patchew.org; Fri, 25 Jun 2021 10:42:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfK-0003LW-QW for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:42 -0400 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]:33714) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfJ-0003F2-84 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:42 -0400 Received: by mail-ed1-x529.google.com with SMTP id w13so7641048edc.0 for ; Fri, 25 Jun 2021 07:18:40 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:39 -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=qpjBRyyTP4cjVVNX0Br2C9CiFX8IHvmV4kWlXQxiCsA=; b=jCGCwDW6AqI+9Krkho8arWdBi0a0ZVQaQVi5zJn3yLKOsnLPaYaZKV/10GH1rO5PrW WFDEKv3BLJzmDnQCITlKRWjgadCCSwADF69EV/SNdZcO3t7kN5naLMIKt5gYL42+uCwd mzQJ7PN7kb4jMz6eIIBEsc0zPfcwuoAslbiyvnRi7gKzu2d9so4AAnbszGnt91VTlbue 4ZF668IHm/k46erNkzAORbimRkUYERoiiEhY5jY1JEfbtNslrw/FqrXWmlSQrZ4Kok+/ lJNDtQMZopfdCGZDHMz4UWzP+PCdl+vI9LcP84jZ9kkTsPtJB5hIsf5IHzbtn3aO/yBx KXzw== 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=qpjBRyyTP4cjVVNX0Br2C9CiFX8IHvmV4kWlXQxiCsA=; b=VONhXnxflgqyjudykLYmweRvggG59WnBSWz7kfIphR6h4BH2/3uMHnomtzE51d8Ov3 dxVmsVSNbdW8vOpzeFmZJYTyYpLIxjq4nu1zUbyH6PC2LjvLthfL/B3nj31by5eQfN8P 5LO2HiL7IIxeaOG0Sn7vzRjx0A0oWLCoG5uVHGKEeXe61z/KD8YOLSjC/A8eERK1x8E2 Tu7qJCqlnxyQXQ7LJV+iOmh6VeD5fvluiCS3/Ix/C1Ddvou1p8u1lh+kjpO0KKBG9+8N Q0rMt3dvGh3QmWtmVMDF3EE/vg/9sbYWA4X9wRtEZxOcST/YZztJRtxi6h+wK8IgubDj xnVA== X-Gm-Message-State: AOAM533xP02VjBYlFdh0cqSbISHoXPRdB5dD1Jl0jt2HfJsXhIlJ9+c0 KX+m1wDNg2w2F1T14vYN9ceRlDoYH9s= X-Google-Smtp-Source: ABdhPJy9AWr9bXKKdgKVDoxDOshryv2Y7dxjVQHezoR8e4J7PSyskMi0QOKjHeBecVZX0Mspguct9Q== X-Received: by 2002:a50:bf0f:: with SMTP id f15mr14705436edk.205.1624630719902; Fri, 25 Jun 2021 07:18:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 16/28] block-backend: align max_transfer to request alignment Date: Fri, 25 Jun 2021 16:18:10 +0200 Message-Id: <20210625141822.1368639-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x529.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Block device requests must be aligned to bs->bl.request_alignment. It makes sense for drivers to align bs->bl.max_transfer the same way; however when there is no specified limit, blk_get_max_transfer just returns INT_MAX. Since the contract of the function does not specify that INT_MAX means "no maximum", just align the outcome of the function (whether INT_MAX or bs->bl.max_transfer) before returning it. Signed-off-by: Paolo Bonzini --- block/block-backend.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 15f1ea4288..6e37582740 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1957,12 +1957,12 @@ uint32_t blk_get_request_alignment(BlockBackend *bl= k) uint32_t blk_get_max_transfer(BlockBackend *blk) { BlockDriverState *bs =3D blk_bs(blk); - uint32_t max =3D 0; + uint32_t max =3D INT_MAX; =20 if (bs) { - max =3D bs->bl.max_transfer; + max =3D MIN_NON_ZERO(max, bs->bl.max_transfer); } - return MIN_NON_ZERO(max, INT_MAX); + return ROUND_DOWN(max, blk_get_request_alignment(blk)); } =20 int blk_get_max_iov(BlockBackend *blk) --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16246315747571019.8538163659696; Fri, 25 Jun 2021 07:32:54 -0700 (PDT) Received: from localhost ([::1]:34920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmt3-0003ZX-7W for importer@patchew.org; Fri, 25 Jun 2021 10:32:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfM-0003RA-8W for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:44 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]:44957) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfK-0003FL-FG for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:44 -0400 Received: by mail-ej1-x630.google.com with SMTP id n2so4244431eju.11 for ; Fri, 25 Jun 2021 07:18:42 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:40 -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=XzrbbkEGL9DUDKoP6G9+FXKiRtPajUq/O5vyZRD1tS4=; b=Vz/20QPSnuOYRRtRMi2zbQCKshn+OHe47lZSdfta53ZVFUSb63sRvTO20djQtAA3UZ cReoXwAb5N6klXMH1cAL6h/KcoHENoPOvLRDQaCrSnSocWY58hQ9bVI0+vUbSbZBtG2L ZjErTM0uVicDe7rut6ZNC/1eIvbvvLS4ZkesA4FCeAFTUgsseRV3gAgxS4SC/BOIv2bt JthFDXeoUuFz7EEjLcy3SNhyVv7CrXcmGG0HQloWE7vRhU39u+nYl+sj8DnwV1Y/fKmE s53DXV1yMD5RfuNKtoTaTg1ZLKG/Tfzu1m8exEZQ6mc0KnlfaShB/q0WTo9cjqXA/bbi /jhA== 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=XzrbbkEGL9DUDKoP6G9+FXKiRtPajUq/O5vyZRD1tS4=; b=ZUzZ50zDbgmxOGWqcdh6njObpcyMX/WAkp+DhUpU5mg9FSRRR2+HVVCob402IZIt8M j2sRkZg8UDaVbpOzTz6Lwr2lQbDZSpXIW4DZbz/EwJI7xBySMsCGsJjpvBTm10hMYkxh N8Sli1eGm31fJDEmTMTeXv7nUP/jk7QtMT9nW8IxKzT6odl2brV2Ur4/ZBhMcYIuYS2K rGLHXPZDpEB0ut3Bh5y03RWfd+30Jc7jzZ8ZBNAbbPZRF956Tf6a95h8uBQLwAinPQXp sY5Q/6FjFLdTPvp/guA5891Efh324WvTwh7/B9A/KOaTTHK8LKgthsm4HlE3H4mBJjnc CegA== X-Gm-Message-State: AOAM530lk/NSfwCa9kzetDmKcDPqcRJ65221otlY2l/6i2pluVMNNgKb xmKU5sqMhqyp8X8lvbaCkQYP9E8EDPk= X-Google-Smtp-Source: ABdhPJymfd6xnnf9yZ0LJiJM+SyLoJGVEixILNKE6WDPOoBw/waBb2NTXgmIr0BvsEFNpYqH2ngsgg== X-Received: by 2002:a17:906:e03:: with SMTP id l3mr10901963eji.6.1624630721009; Fri, 25 Jun 2021 07:18:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 17/28] block: add max_hw_transfer to BlockLimits Date: Fri, 25 Jun 2021 16:18:11 +0200 Message-Id: <20210625141822.1368639-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-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+importer=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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" For block host devices, I/O can happen through either the kernel file descriptor I/O system calls (preadv/pwritev, io_submit, io_uring) or the SCSI passthrough ioctl SG_IO. In the latter case, the size of each transfer can be limited by the HBA, while for file descriptor I/O the kernel is able to split and merge I/O in smaller pieces as needed. Applying the HBA limits to file descriptor I/O results in more system calls and suboptimal performance, so this patch splits the max_transfer limit in two: max_transfer remains valid and is used in general, while max_hw_transfer is limited to the maximum hardware size. max_hw_transfer can then be included by the scsi-generic driver in the block limits page, to ensure that the stricter hardware limit is used. Signed-off-by: Paolo Bonzini --- block/block-backend.c | 13 +++++++++++++ block/file-posix.c | 2 +- block/io.c | 2 ++ hw/scsi/scsi-generic.c | 2 +- include/block/block_int.h | 7 +++++++ include/sysemu/block-backend.h | 1 + 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 6e37582740..deb55c272e 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1953,6 +1953,19 @@ uint32_t blk_get_request_alignment(BlockBackend *blk) return bs ? bs->bl.request_alignment : BDRV_SECTOR_SIZE; } =20 +/* Returns the maximum hardware transfer length, in bytes; guaranteed nonz= ero */ +uint64_t blk_get_max_hw_transfer(BlockBackend *blk) +{ + BlockDriverState *bs =3D blk_bs(blk); + uint64_t max =3D INT_MAX; + + if (bs) { + max =3D MIN_NON_ZERO(max, bs->bl.max_hw_transfer); + max =3D MIN_NON_ZERO(max, bs->bl.max_transfer); + } + return ROUND_DOWN(max, blk_get_request_alignment(blk)); +} + /* Returns the maximum transfer length, in bytes; guaranteed nonzero */ uint32_t blk_get_max_transfer(BlockBackend *blk) { diff --git a/block/file-posix.c b/block/file-posix.c index 6db690baf2..88e58d2863 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1232,7 +1232,7 @@ static void raw_refresh_limits(BlockDriverState *bs, = Error **errp) int ret =3D sg_get_max_transfer_length(s->fd); =20 if (ret > 0 && ret <=3D BDRV_REQUEST_MAX_BYTES) { - bs->bl.max_transfer =3D pow2floor(ret); + bs->bl.max_hw_transfer =3D pow2floor(ret); } =20 ret =3D sg_get_max_segments(s->fd); diff --git a/block/io.c b/block/io.c index 323854d063..dd93364258 100644 --- a/block/io.c +++ b/block/io.c @@ -127,6 +127,8 @@ static void bdrv_merge_limits(BlockLimits *dst, const B= lockLimits *src) { dst->opt_transfer =3D MAX(dst->opt_transfer, src->opt_transfer); dst->max_transfer =3D MIN_NON_ZERO(dst->max_transfer, src->max_transfe= r); + dst->max_hw_transfer =3D MIN_NON_ZERO(dst->max_hw_transfer, + src->max_hw_transfer); dst->opt_mem_alignment =3D MAX(dst->opt_mem_alignment, src->opt_mem_alignment); dst->min_mem_alignment =3D MAX(dst->min_mem_alignment, diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index b6c4143dc7..665baf900e 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -179,7 +179,7 @@ static int scsi_handle_inquiry_reply(SCSIGenericReq *r,= SCSIDevice *s, int len) (r->req.cmd.buf[1] & 0x01)) { page =3D r->req.cmd.buf[2]; if (page =3D=3D 0xb0) { - uint32_t max_transfer =3D blk_get_max_transfer(s->conf.blk); + uint64_t max_transfer =3D blk_get_max_hw_transfer(s->conf.blk); uint32_t max_iov =3D blk_get_max_iov(s->conf.blk); =20 assert(max_transfer); diff --git a/include/block/block_int.h b/include/block/block_int.h index 057d88b1fc..f1a54db0f8 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -695,6 +695,13 @@ typedef struct BlockLimits { * clamped down. */ uint32_t max_transfer; =20 + /* Maximal hardware transfer length in bytes. Applies whenever + * transfers to the device bypass the kernel I/O scheduler, for + * example with SG_IO. If larger than max_transfer or if zero, + * blk_get_max_hw_transfer will fall back to max_transfer. + */ + uint64_t max_hw_transfer; + /* memory alignment, in bytes so that no bounce buffer is needed */ size_t min_mem_alignment; =20 diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 5423e3d9c6..9ac5f7bbd3 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -208,6 +208,7 @@ void blk_eject(BlockBackend *blk, bool eject_flag); int blk_get_flags(BlockBackend *blk); uint32_t blk_get_request_alignment(BlockBackend *blk); uint32_t blk_get_max_transfer(BlockBackend *blk); +uint64_t blk_get_max_hw_transfer(BlockBackend *blk); int blk_get_max_iov(BlockBackend *blk); void blk_set_guest_block_size(BlockBackend *blk, int align); void *blk_try_blockalign(BlockBackend *blk, size_t size); --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624631754583698.9902487212331; Fri, 25 Jun 2021 07:35:54 -0700 (PDT) Received: from localhost ([::1]:43524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmvw-0000tV-18 for importer@patchew.org; Fri, 25 Jun 2021 10:35:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfM-0003Sa-Lt for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:44 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]:33370) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfL-0003FS-14 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:44 -0400 Received: by mail-ej1-x634.google.com with SMTP id bu12so15473182ejb.0 for ; Fri, 25 Jun 2021 07:18:42 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:41 -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=d05PnkwnuDECdWXUS+gfsGR0SVTVhh2B+agXt5vsNfs=; b=qKybzW8UTWTBlL7mMnlOb9xLKBBvCIktVl7LZ6RPp476EiuuDtDZ9Nm8705LrVCXT5 DQlhYwX0Gqqdyvp7dNuLdPp8TpXhS4SPurEUy5IT2kV3TADfhNyCFR4t6pCLQlsMui6R 8yxddqUpnLZpReY8vpC2i2H/vuL9DCt3iumpDPuwqP7UtLkG0lwz9G+5HeP0UguLPRW6 ieZRn6CoaUOngFJNW5D1RSoh+2XMOlmGoMwh3M+pebPVACJb4jcUnEDhnxz8XdJMsNw7 UwbgHiQeQo5+qktb3FVqkPtRo8lqwCP9jGqHu74PEz4tZUAbGdV+SXvV9/ejyTOFwsWl E8ag== 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=d05PnkwnuDECdWXUS+gfsGR0SVTVhh2B+agXt5vsNfs=; b=AAhsaqiTEjfaIBwi5QjZ3BWCbUwy+1PVxkrYGftaXPIg1aUct6AV7NSHxPpNJr6RZH nha91WpRrdRX8eQXKF4pbYGh09jwL5XVeHHvN6FCHsCa10K7gIXZelQ4+FCMWBdgZRu3 5Dz+fDODBKjjzkl98k7GH5hib6C0zOsW85rLLEJcXHjChS4pIhp/rwBSYgjNn7gWcT1G e5Dk/aJYURrBZsm41UnugeiX5IE7uthEG/dL1s5IO9U4fuzV4xUAX3C6DuT6OVJb36yo UerE3lvAcboF0M+atH1PPKnnT7+nMGomEQbmCbXOuVJm4hjNu3L9f9QwLHcSDOKaFinY iIYw== X-Gm-Message-State: AOAM532PjUNGCP9khwAA7xmfHHgvM/dt56Fhes6enrL4Sz5eDi5pw4Pz xtxZZKXswky6XcgRajd0HNm40GUIq0E= X-Google-Smtp-Source: ABdhPJxc0B4SYWXdYW8tKhHhCCvc/d0ipDJS+jCXfKlOhDWbVQRXWCK4aFOKr/cnY5XpALNi7UytLQ== X-Received: by 2002:a17:906:3845:: with SMTP id w5mr11121374ejc.466.1624630721628; Fri, 25 Jun 2021 07:18:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 18/28] file-posix: try BLKSECTGET on block devices too, do not round to power of 2 Date: Fri, 25 Jun 2021 16:18:12 +0200 Message-Id: <20210625141822.1368639-19-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x634.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" bs->sg is only true for character devices, but block devices can also be used with scsi-block and scsi-generic. Unfortunately BLKSECTGET returns bytes in an int for /dev/sgN devices, and sectors in a short for block devices, so account for that in the code. The maximum transfer also need not be a power of 2 (for example I have seen disks with 1280 KiB maximum transfer) so there's no need to pass the result through pow2floor. Signed-off-by: Paolo Bonzini --- block/file-posix.c | 67 ++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 88e58d2863..ea102483b0 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1147,22 +1147,27 @@ static void raw_reopen_abort(BDRVReopenState *state) s->reopen_state =3D NULL; } =20 -static int sg_get_max_transfer_length(int fd) +static int hdev_get_max_hw_transfer(int fd, struct stat *st) { #ifdef BLKSECTGET - int max_bytes =3D 0; - - if (ioctl(fd, BLKSECTGET, &max_bytes) =3D=3D 0) { - return max_bytes; + if (S_ISBLK(st->st_mode)) { + unsigned short max_sectors =3D 0; + if (ioctl(fd, BLKSECTGET, &max_sectors) =3D=3D 0) { + return max_sectors * 512; + } } else { - return -errno; + int max_bytes =3D 0; + if (ioctl(fd, BLKSECTGET, &max_bytes) =3D=3D 0) { + return max_bytes; + } } + return -errno; #else return -ENOSYS; #endif } =20 -static int sg_get_max_segments(int fd) +static int hdev_get_max_segments(int fd, struct stat *st) { #ifdef CONFIG_LINUX char buf[32]; @@ -1171,26 +1176,20 @@ static int sg_get_max_segments(int fd) int ret; int sysfd =3D -1; long max_segments; - struct stat st; =20 - if (fstat(fd, &st)) { - ret =3D -errno; - goto out; - } - - if (S_ISCHR(st.st_mode)) { + if (S_ISCHR(st->st_mode)) { if (ioctl(fd, SG_GET_SG_TABLESIZE, &ret) =3D=3D 0) { return ret; } return -ENOTSUP; } =20 - if (!S_ISBLK(st.st_mode)) { + if (!S_ISBLK(st->st_mode)) { return -ENOTSUP; } =20 sysfspath =3D g_strdup_printf("/sys/dev/block/%u:%u/queue/max_segments= ", - major(st.st_rdev), minor(st.st_rdev)); + major(st->st_rdev), minor(st->st_rdev)); sysfd =3D open(sysfspath, O_RDONLY); if (sysfd =3D=3D -1) { ret =3D -errno; @@ -1227,23 +1226,33 @@ out: static void raw_refresh_limits(BlockDriverState *bs, Error **errp) { BDRVRawState *s =3D bs->opaque; - - if (bs->sg) { - int ret =3D sg_get_max_transfer_length(s->fd); - - if (ret > 0 && ret <=3D BDRV_REQUEST_MAX_BYTES) { - bs->bl.max_hw_transfer =3D pow2floor(ret); - } - - ret =3D sg_get_max_segments(s->fd); - if (ret > 0) { - bs->bl.max_iov =3D ret; - } - } + struct stat st; =20 raw_probe_alignment(bs, s->fd, errp); bs->bl.min_mem_alignment =3D s->buf_align; bs->bl.opt_mem_alignment =3D MAX(s->buf_align, qemu_real_host_page_siz= e); + + /* + * Maximum transfers are best effort, so it is okay to ignore any + * errors. That said, based on the man page errors in fstat would be + * very much unexpected; the only possible case seems to be ENOMEM. + */ + if (fstat(s->fd, &st)) { + return; + } + + if (bs->sg || S_ISBLK(st.st_mode)) { + int ret =3D hdev_get_max_hw_transfer(s->fd, &st); + + if (ret > 0 && ret <=3D BDRV_REQUEST_MAX_BYTES) { + bs->bl.max_hw_transfer =3D ret; + } + + ret =3D hdev_get_max_segments(s->fd, &st); + if (ret > 0) { + bs->bl.max_iov =3D ret; + } + } } =20 static int check_for_dasd(int fd) --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624631197517548.2953925365766; Fri, 25 Jun 2021 07:26:37 -0700 (PDT) Received: from localhost ([::1]:46856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmmt-0000rv-UH for importer@patchew.org; Fri, 25 Jun 2021 10:26:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfN-0003VL-8t for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:45 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:41552) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfL-0003Gc-Ey for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:44 -0400 Received: by mail-ej1-x633.google.com with SMTP id ot9so14371657ejb.8 for ; Fri, 25 Jun 2021 07:18:43 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:41 -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=arX+811Fkq+PDjksSN+JOqKo9fQXt3s9scD5oPGpotw=; b=Z/7cxK60AirNIf9fVaUacbOI4UxnqXPGQlre50BoiCl/P8+CRBNH15qgYaLx6HQ2j5 p+0Wm2aVYyAWGNLl+uv97Glcq8TF0uZA0jACjvLEpuZB9QNohFvj5uVt8tLV8vGjtuh/ CJIl12kwC4WaIwQj6+cq2LcBMV/un++R/iQ4Ei3HRkAUupGyfyB4NwVtdUNgxnpdWtC3 2jCoE7yV4CdE5xXCwQlOGCxqX0xJEuTW0JGwmZge1RY7U2BLzMsYHT9fcB0hX3d8bBCY Jhuom5SW5cO4Po73K4kL15dwcDAqe2xtfKxt83aa7ZAbEPcym1kUnSF8zML8J7RCL2iP zXtg== 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=arX+811Fkq+PDjksSN+JOqKo9fQXt3s9scD5oPGpotw=; b=E3F2ltVvAPIsyTY4l1vuBHzjLFtvvCYaykFf3p2arNfGMUQD0EWme2cOV7FQjXsmYH Cfo5AJK40hfmoSwnbSTrdCHEL7OMjw1QAVSUr35rXtIYg8p6BwGChuNuM9sAsls1X7Ia jcHFG9ewmI6ebwMZnpX+WEko+n/bd1rgXM/cO7wde+IftqSjdNcg+dxvK70CLmFIa6Hk hPNcraQ6plo1p6/CwIYT+Swy7qPDgt/p1oNxkuJNcUHvNYE4Z4B8e1naWQjM/799A6Ec yDwg4F7BlKiwp2qcfq6JxVdyTaHJACKZHAQ99dLxCbhcx8kYepnBp+DVefwDE5IvjQkl GyAw== X-Gm-Message-State: AOAM532+XPBFZNqnRI2KkNHmBi96C5wqpCLjTgvu/9W4oSiu/HUql1si ngwAStXWWnbbeFme5rEW2pv7Cqvlwdc= X-Google-Smtp-Source: ABdhPJxuJh8l069fwWjFwwFeasBzbHeDSoXq2juK3H0JXSEQrEPwOgNY2MX0I9S8OxuND0HRbKGAFQ== X-Received: by 2002:a17:907:2637:: with SMTP id aq23mr11398613ejc.17.1624630722293; Fri, 25 Jun 2021 07:18:42 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 19/28] block: feature detection for host block support Date: Fri, 25 Jun 2021 16:18:13 +0200 Message-Id: <20210625141822.1368639-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-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+importer=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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: Joelle van Dyne Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Joelle van Dyne On Darwin (iOS), there are no system level APIs for directly accessing host block devices. We detect this at configure time. Signed-off-by: Joelle van Dyne Message-Id: <20210315180341.31638-2-j@getutm.app> Signed-off-by: Paolo Bonzini --- block/file-posix.c | 33 ++++++++++++++++++++++----------- meson.build | 6 +++++- qapi/block-core.json | 14 ++++++++++---- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index ea102483b0..e56bb491a1 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -42,6 +42,8 @@ #include "scsi/constants.h" =20 #if defined(__APPLE__) && (__MACH__) +#include +#if defined(HAVE_HOST_BLOCK_DEVICE) #include #include #include @@ -52,6 +54,7 @@ //#include #include #include +#endif /* defined(HAVE_HOST_BLOCK_DEVICE) */ #endif =20 #ifdef __sun__ @@ -178,7 +181,17 @@ typedef struct BDRVRawReopenState { bool check_cache_dropped; } BDRVRawReopenState; =20 -static int fd_open(BlockDriverState *bs); +static int fd_open(BlockDriverState *bs) +{ + BDRVRawState *s =3D bs->opaque; + + /* this is just to ensure s->fd is sane (its called by io ops) */ + if (s->fd >=3D 0) { + return 0; + } + return -EIO; +} + static int64_t raw_getlength(BlockDriverState *bs); =20 typedef struct RawPosixAIOData { @@ -3033,6 +3046,7 @@ static BlockStatsSpecific *raw_get_specific_stats(Blo= ckDriverState *bs) return stats; } =20 +#if defined(HAVE_HOST_BLOCK_DEVICE) static BlockStatsSpecific *hdev_get_specific_stats(BlockDriverState *bs) { BlockStatsSpecific *stats =3D g_new(BlockStatsSpecific, 1); @@ -3042,6 +3056,7 @@ static BlockStatsSpecific *hdev_get_specific_stats(Bl= ockDriverState *bs) =20 return stats; } +#endif /* HAVE_HOST_BLOCK_DEVICE */ =20 static QemuOptsList raw_create_opts =3D { .name =3D "raw-create-opts", @@ -3257,6 +3272,8 @@ BlockDriver bdrv_file =3D { /***********************************************/ /* host device */ =20 +#if defined(HAVE_HOST_BLOCK_DEVICE) + #if defined(__APPLE__) && defined(__MACH__) static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char *bsdPath, CFIndex maxPathSize, int flags); @@ -3549,16 +3566,6 @@ hdev_co_ioctl(BlockDriverState *bs, unsigned long in= t req, void *buf) } #endif /* linux */ =20 -static int fd_open(BlockDriverState *bs) -{ - BDRVRawState *s =3D bs->opaque; - - /* this is just to ensure s->fd is sane (its called by io ops) */ - if (s->fd >=3D 0) - return 0; - return -EIO; -} - static coroutine_fn int hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) { @@ -3882,6 +3889,8 @@ static BlockDriver bdrv_host_cdrom =3D { }; #endif /* __FreeBSD__ */ =20 +#endif /* HAVE_HOST_BLOCK_DEVICE */ + static void bdrv_file_init(void) { /* @@ -3889,6 +3898,7 @@ static void bdrv_file_init(void) * registered last will get probed first. */ bdrv_register(&bdrv_file); +#if defined(HAVE_HOST_BLOCK_DEVICE) bdrv_register(&bdrv_host_device); #ifdef __linux__ bdrv_register(&bdrv_host_cdrom); @@ -3896,6 +3906,7 @@ static void bdrv_file_init(void) #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) bdrv_register(&bdrv_host_cdrom); #endif +#endif /* HAVE_HOST_BLOCK_DEVICE */ } =20 block_init(bdrv_file_init); diff --git a/meson.build b/meson.build index 64e23175ab..6419d4ee41 100644 --- a/meson.build +++ b/meson.build @@ -183,7 +183,7 @@ if targetos =3D=3D 'windows' include_directories: include_directo= ries('.')) elif targetos =3D=3D 'darwin' coref =3D dependency('appleframeworks', modules: 'CoreFoundation') - iokit =3D dependency('appleframeworks', modules: 'IOKit') + iokit =3D dependency('appleframeworks', modules: 'IOKit', required: fals= e) elif targetos =3D=3D 'sunos' socket =3D [cc.find_library('socket'), cc.find_library('nsl'), @@ -1148,6 +1148,9 @@ if get_option('cfi') add_global_link_arguments(cfi_flags, native: false, language: ['c', 'cpp= ', 'objc']) endif =20 +have_host_block_device =3D (targetos !=3D 'darwin' or + cc.has_header('IOKit/storage/IOMedia.h')) + ################# # config-host.h # ################# @@ -1247,6 +1250,7 @@ config_host_data.set('HAVE_PTY_H', cc.has_header('pty= .h')) config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h')) config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h')) config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', pre= fix: '#include ')) +config_host_data.set('HAVE_HOST_BLOCK_DEVICE', have_host_block_device) =20 config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#= include ')) =20 diff --git a/qapi/block-core.json b/qapi/block-core.json index 2ea294129e..a54f37dbef 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -897,7 +897,8 @@ 'discriminator': 'driver', 'data': { 'file': 'BlockStatsSpecificFile', - 'host_device': 'BlockStatsSpecificFile', + 'host_device': { 'type': 'BlockStatsSpecificFile', + 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' }, 'nvme': 'BlockStatsSpecificNvme' } } =20 ## @@ -2814,7 +2815,10 @@ { 'enum': 'BlockdevDriver', 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs', 'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ft= ps', - 'gluster', 'host_cdrom', 'host_device', 'http', 'https', 'iscs= i', + 'gluster', + {'name': 'host_cdrom', 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)'= }, + {'name': 'host_device', 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)= ' }, + 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallel= s', 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd', { 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' }, @@ -3995,8 +3999,10 @@ 'ftp': 'BlockdevOptionsCurlFtp', 'ftps': 'BlockdevOptionsCurlFtps', 'gluster': 'BlockdevOptionsGluster', - 'host_cdrom': 'BlockdevOptionsFile', - 'host_device':'BlockdevOptionsFile', + 'host_cdrom': { 'type': 'BlockdevOptionsFile', + 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' }, + 'host_device': { 'type': 'BlockdevOptionsFile', + 'if': 'defined(HAVE_HOST_BLOCK_DEVICE)' }, 'http': 'BlockdevOptionsCurlHttp', 'https': 'BlockdevOptionsCurlHttps', 'iscsi': 'BlockdevOptionsIscsi', --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624631903174953.8874037345583; Fri, 25 Jun 2021 07:38:23 -0700 (PDT) Received: from localhost ([::1]:52046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmyL-0006gu-Pl for importer@patchew.org; Fri, 25 Jun 2021 10:38:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfN-0003XQ-Us for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:46 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]:37627) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfM-0003I5-Ap for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:45 -0400 Received: by mail-ej1-x630.google.com with SMTP id o11so2224401ejd.4 for ; Fri, 25 Jun 2021 07:18:43 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:42 -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=SDfMHDSuKxMkZiFUP2o6GnGmA2A8MNufC6YTUOx3lYw=; b=rcFpB4Yb5JV8Fx3aYGr807kt/lOyvBbaSBvrPfWmREvjMbtvZjy2eCaplbsGk0Pt3n v1QlZXo9uQbKT59meejw4QgJqo9efn4HOvQAOV3qmaoFqh2xgte4HOAEvMiX6SqA0Ija sfUMJKKTxShf8wpGBQ0+UNmG6SCO9gdD2wqH69xdvmL7NpW4zSBF09T7DOyrV6PuJ8Y3 9ddMpgui2HbziHJ/TfMh9mSH8vxJfrNY8kZ6fFW0OVMtbFmekjjVcKy0WSxOrbxrVIzM GJhPOplNFg4dxWAtDArsDm6IrtokqRGR6Jmfx8c8s6ciS41iz7lG1Xc4S668ts6BAPmn b4hg== 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=SDfMHDSuKxMkZiFUP2o6GnGmA2A8MNufC6YTUOx3lYw=; b=s2LPBzVN5Wbx/9YhLZzoYuRzGhaKfGWp2WckW0wjGJyj8tfnc0EPip5Qw8IvxL3nR4 2D8MPgAlAAw/uqBk19lXkguedy+FC1iZ1AyEk5BEf0HSbN/pmdFc/i3vL9k6BPkRejRU 4vJZ8m6nyINGFueQpdcHuGTO1ZYmYWx2eBO4U9+bQmfB+sNPQ5ddJnE2prdTBwCklh95 GnPN+MB67/XkpR/u6xOsGXqksbGB5nPU0CvQeSM47ybuGXDcLfBuWWogYdRaTaT8gGjR R5rBE0zHcNP6/4ZiXOoVlw3w6MRgYXTSMLMkXxmz04IJnym9lDFzf0SV5ieYbIbvimhM FASA== X-Gm-Message-State: AOAM531XF1dtHPREgkVm4fKdCIvGNV4WLhYIYdRBAqZ3cpiKsTyVh39D 4tFk/Xowd/r9wA2TGGcttGoNKZ3zy4E= X-Google-Smtp-Source: ABdhPJy3mA9yZG0xf6qCY42j5njvbqGF2lk5gpROnTD64Jo1ILCLrdz3iLLayEFeMqqFGn44DTau8A== X-Received: by 2002:a17:906:3c4a:: with SMTP id i10mr10937210ejg.372.1624630723101; Fri, 25 Jun 2021 07:18:43 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 20/28] block: check for sys/disk.h Date: Fri, 25 Jun 2021 16:18:14 +0200 Message-Id: <20210625141822.1368639-21-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joelle van Dyne , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Joelle van Dyne Some BSD platforms do not have this header. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Joelle van Dyne Message-Id: <20210315180341.31638-3-j@getutm.app> Reviewed-by: Max Reitz Signed-off-by: Paolo Bonzini --- block.c | 2 +- meson.build | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 3f456892d0..1d37f133a8 100644 --- a/block.c +++ b/block.c @@ -54,7 +54,7 @@ #ifdef CONFIG_BSD #include #include -#ifndef __DragonFly__ +#if defined(HAVE_SYS_DISK_H) #include #endif #endif diff --git a/meson.build b/meson.build index 6419d4ee41..144456426c 100644 --- a/meson.build +++ b/meson.build @@ -1251,6 +1251,7 @@ config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_head= er('sys/ioccom.h')) config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h')) config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', pre= fix: '#include ')) config_host_data.set('HAVE_HOST_BLOCK_DEVICE', have_host_block_device) +config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h')) =20 config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#= include ')) =20 --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624632290352587.4042570296604; Fri, 25 Jun 2021 07:44:50 -0700 (PDT) Received: from localhost ([::1]:44422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwn4b-0003cX-7Y for importer@patchew.org; Fri, 25 Jun 2021 10:44:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfO-0003bE-Um for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:46 -0400 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]:33715) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfN-0003IH-CC for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:46 -0400 Received: by mail-ed1-x529.google.com with SMTP id w13so7641341edc.0 for ; Fri, 25 Jun 2021 07:18:44 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:43 -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=1inmLhcVq0aSD320zpWtlTjRRoDETw4S+Ab6hL0QjO8=; b=JDzWR4qxco4TdjVmZvUi7KPsUPitzzTRlcy+jPMCa0k9sTYPOVqwwRB3DByeH4qqaO T0cVljP4DQqVJpoE49ihypekfjnazoCQYX6i23z50qb6GlfyWKM/4YHWibX0D36ojkqM RQWEMCtjACabOo4wz5GVJbn11oR5hQoJUh4DgrqOHqLRCsst6Mv1S+K6J1MGEW4YL70W vD9KizmFvIfVCb06unVXHHYRVB/E4gZzM3Ah20RnKyhaDq5QTpu5bUgnmgNdwqF9eNL9 0ajJ7rTViDJ8fnAAAI3mFXaw2O03CyPmQNkie1Z9Ua6mrmEvC8K34kbUSXkuf7wXiqZ5 y7RQ== 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=1inmLhcVq0aSD320zpWtlTjRRoDETw4S+Ab6hL0QjO8=; b=AgLqWGQqfMK//jJePo2JBhT4Bt9TyT3YC6BOjmMPJwe6nTO9rcufWQcQMGbJbYer+k KxEQ1H5w3IlJsA9ll7AFSFX6NcOtsFoGteJldA11+kcRUwP6PeyjDxjL0FsTpfO5Lv2D qqkN5oaYaLuT1U+VpVVDZCQ7gQH0OBaKCPW1L7jJk7F4MlvJSDoGO/T04Kic2mcEFoHT R39bBc/r5GDxBfKPLfTPpf/VpcfVHkNPIJDKaICtTl+8jhtWSGlMjMAm+itmh00Mfkxc xCIzWqNeB4MUtFwinP4uIpM5eYvpbkXM9CcfV+ZvJ+G/lWBiWItXj7vmEg0TMaIS4nol hrHA== X-Gm-Message-State: AOAM531ILYQcktyQo53z+hyBhnxFIctYoL3r7+/G7js9l4kc/KS57EgZ 2OUmRIr53fGI6KDpJNLbrL6GbDslwD0= X-Google-Smtp-Source: ABdhPJwupxpLL+usnwEKICgDrxGP2hM9xkHsDUbAGCaUTBKhVWYaRIEF/3s4N74vVBjQG2OtAcccnQ== X-Received: by 2002:a05:6402:12d4:: with SMTP id k20mr15176035edx.344.1624630723968; Fri, 25 Jun 2021 07:18:43 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 21/28] block: try BSD disk size ioctls one after another Date: Fri, 25 Jun 2021 16:18:15 +0200 Message-Id: <20210625141822.1368639-22-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x529.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Try all the possible ioctls for disk size as long as they are supported, to keep the #if ladder simple. Extracted and cleaned up from a patch by Joelle van Dyne and Warner Losh. Signed-off-by: Paolo Bonzini --- block/file-posix.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index e56bb491a1..f16d987c07 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2327,39 +2327,37 @@ static int64_t raw_getlength(BlockDriverState *bs) again: #endif if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) { + size =3D 0; #ifdef DIOCGMEDIASIZE - if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size)) -#elif defined(DIOCGPART) - { - struct partinfo pi; - if (ioctl(fd, DIOCGPART, &pi) =3D=3D 0) - size =3D pi.media_size; - else - size =3D 0; + if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size)) { + size =3D 0; + } +#endif +#ifdef DIOCGPART + if (size =3D=3D 0) { + struct partinfo pi; + if (ioctl(fd, DIOCGPART, &pi) =3D=3D 0) { + size =3D pi.media_size; + } } - if (size =3D=3D 0) #endif #if defined(__APPLE__) && defined(__MACH__) - { + if (size =3D=3D 0) { uint64_t sectors =3D 0; uint32_t sector_size =3D 0; =20 if (ioctl(fd, DKIOCGETBLOCKCOUNT, §ors) =3D=3D 0 && ioctl(fd, DKIOCGETBLOCKSIZE, §or_size) =3D=3D 0) { size =3D sectors * sector_size; - } else { - size =3D lseek(fd, 0LL, SEEK_END); - if (size < 0) { - return -errno; - } } } -#else - size =3D lseek(fd, 0LL, SEEK_END); +#endif + if (size =3D=3D 0) { + size =3D lseek(fd, 0LL, SEEK_END); + } if (size < 0) { return -errno; } -#endif #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) switch(s->type) { case FTYPE_CD: --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624631391500160.48500538230053; Fri, 25 Jun 2021 07:29:51 -0700 (PDT) Received: from localhost ([::1]:55390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmq5-0006iZ-Vx for importer@patchew.org; Fri, 25 Jun 2021 10:29:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfP-0003dd-IQ for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:48 -0400 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]:39840) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfO-0003IX-3s for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:47 -0400 Received: by mail-ed1-x531.google.com with SMTP id c7so13614066edn.6 for ; Fri, 25 Jun 2021 07:18:45 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:44 -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=BevMjojoz4Zbbmnx7q+o91aCSPbNgcWVWrT6Beq1/n0=; b=j/t3NaFlb05cyTxwmTLGxPUCyPxVg3ekrPPBddyaXECjzmUvvO687mw9T5Goc9jtsK Lwp4IBmaEjzDD2otZtNLyMsBF8rpOVqe2clDb8ST8yQ8C67LkHuYhtB2J1SCgsENtWaJ xN46pyITVLL+GPej/u4C3qAFAOTdlReEpu9IsFSXVpeqT1k350xILAmXZp8gX7ZnfNl7 xlBS3QAoxfHr9qd2OSsLfiUsEY9xOgeJkcMh/iis/SGkBrgsNYSgMo2SjXS1Db5BrivW gBTehwffXK4rbjdtmGclK/YqDyA9k1SnX+XcOJXS/4EFodZ+KL5WWk5TDDHs4zENWk+y rkIw== 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=BevMjojoz4Zbbmnx7q+o91aCSPbNgcWVWrT6Beq1/n0=; b=WrW84vO/14uKuY8AfDN74op7NUlsE7ZsECK/AfCZqUR9mal5l+WNaWivfARujAL+ky 1fEnJtn/UHqil5+0D/CoxJjbuJnFMhVfAIDcRh/IauBjMbuB3l02l6AI8wrnCFKp+2b2 oWsWVq7PwBDXujqYUC2epP2suCFUPlEzs/mzFLlw0DIOwnzLrkuLnL71MNXf5oZPcLw0 5K3qCo8Fh/YfpTqa0fpkoKktvwTPj2O2UuQPqGgUK2l/ZN0Jlal/YLAJng69Qusf5o6p jvzHEEuCrLMOG+ctZKJz5y3FTvhjCFZvCoAjTpGSjWafqKXlfiuzCBz1GqkJ8F6uebsq cSrA== X-Gm-Message-State: AOAM533I4v2ukpF/M4KiuHoFuFt9Kp9T4NbGGHEvhu3JnEnh2gwe/Kem KPZl/Bb/KiAVGuzhd5RZnSIj96psb98= X-Google-Smtp-Source: ABdhPJw6N3SrpKNEWIoWBnGldEAK/UyFPWmCJN8qgE3kbV7bpI3V6oOKii9bgxGkCzkXVWPFyJntMw== X-Received: by 2002:a05:6402:348d:: with SMTP id v13mr5633568edc.119.1624630724868; Fri, 25 Jun 2021 07:18:44 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 22/28] block: detect DKIOCGETBLOCKCOUNT/SIZE before use Date: Fri, 25 Jun 2021 16:18:16 +0200 Message-Id: <20210625141822.1368639-23-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x531.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: Joelle van Dyne , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Joelle van Dyne iOS hosts do not have these defined so we fallback to the default behaviour. Co-authored-by: Warner Losh Signed-off-by: Joelle van Dyne Signed-off-by: Paolo Bonzini --- block/file-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index f16d987c07..74b8216077 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2341,7 +2341,7 @@ again: } } #endif -#if defined(__APPLE__) && defined(__MACH__) +#if defined(DKIOCGETBLOCKCOUNT) && defined(DKIOCGETBLOCKSIZE) if (size =3D=3D 0) { uint64_t sectors =3D 0; uint32_t sector_size =3D 0; --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624631583360959.8324555279428; Fri, 25 Jun 2021 07:33:03 -0700 (PDT) Received: from localhost ([::1]:35664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmtB-00043Z-Te for importer@patchew.org; Fri, 25 Jun 2021 10:33:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfQ-0003fL-HO for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:48 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]:42572) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfP-0003JK-4D for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:48 -0400 Received: by mail-ed1-x52e.google.com with SMTP id m14so13622878edp.9 for ; Fri, 25 Jun 2021 07:18:46 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:45 -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=wJvWsUqGOQTva1vOWOjj4YQ10DwGdZUCbC7uWnekL7s=; b=eCxQlIdMRXTg4PhCey4xhR9/kK8L+UT7ueMVhmu/G6GSEczaMFZpnDEDgJ56xwwScD HqAIysoxO2JnyAKImUzY5Vk9HkH7i2DC79BQrFja7YMNFN6qlQtXb9JMJsIcUdwZ1mzw VogRZsdZV6JJorviwLOOYZ0Im+6A+lxK1azuj8naiNHA9Rm6NmMLBEFPuBiea8bZ/KZK 55UchIIKm0JlZjt1C8tfwLFpdYBliUBbQXWV21G1ym8pXsvD909xwolGeY4VPcPouz/j r20l81kFk4WCrO8lhBYwVWGjZj7eTE5fHQKQJDwXw2yBcZaOPQeYqPWkbT0yNsrrqLwq LKxg== 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=wJvWsUqGOQTva1vOWOjj4YQ10DwGdZUCbC7uWnekL7s=; b=Y5eIIXrDTAHpgQ4CZdu1ST0HHiuZXSvSU0yO18RdtIwCcW9LKgNh6HbrOemkHr5mFG Gs7YUBkea8uy0vZ5ioia9m3Tb7hxlzx5Mn6nCspCLSNbYK/ld37OTsNbtouFWFO0N/+P zVBJCWIrFT8HgUHgeWtwED4zYOfBHTVGOBwexi4ItQ1hfCRshhKq6tOy/VF5JEhRYjxa oRXEiEmb6Q7lLhiKJv3tgt8k1PnBrR00B86WMY+aZ0orrxrJj7dQsnURA1JSu79H+MXu 0TpjdmkVihbyAxPxExZbfccoGZlIQV4vJ5EXdA7qeDTKtzBItsFX8IF7QcDNTFtxr1yI WeRQ== X-Gm-Message-State: AOAM5313YoMkTHCEt+1bnGvFWMzGzGdD8MS8A8FEYAq5kCbHyzKCcM1G y8GyobpGhAVrSWdVCMeeYHRS4RjF/Kw= X-Google-Smtp-Source: ABdhPJzakt1aWsMAZU9+RDJYt7Yz3WUBWfYiZlWkzDifPXDj4gueRqV+pjQFklaeVPfi/oDHMlNv9Q== X-Received: by 2002:a50:fc90:: with SMTP id f16mr15164610edq.254.1624630725827; Fri, 25 Jun 2021 07:18:45 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 23/28] file-posix: handle EINTR during ioctl Date: Fri, 25 Jun 2021 16:18:17 +0200 Message-Id: <20210625141822.1368639-24-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52e.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: Gordon Watson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Similar to other handle_aiocb_* functions, handle_aiocb_ioctl needs to cater for the possibility that ioctl is interrupted by a signal. Otherwise, the I/O is incorrectly reported as a failure to the guest. Reported-by: Gordon Watson Signed-off-by: Paolo Bonzini --- block/file-posix.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index 74b8216077..a26eab0ac3 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1347,7 +1347,9 @@ static int handle_aiocb_ioctl(void *opaque) RawPosixAIOData *aiocb =3D opaque; int ret; =20 - ret =3D ioctl(aiocb->aio_fildes, aiocb->ioctl.cmd, aiocb->ioctl.buf); + do { + ret =3D ioctl(aiocb->aio_fildes, aiocb->ioctl.cmd, aiocb->ioctl.bu= f); + } while (ret =3D=3D -1 && errno =3D=3D EINTR); if (ret =3D=3D -1) { return -errno; } --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624632452379981.4014460432504; Fri, 25 Jun 2021 07:47:32 -0700 (PDT) Received: from localhost ([::1]:50550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwn7D-0007oT-7R for importer@patchew.org; Fri, 25 Jun 2021 10:47:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfR-0003jP-Qu for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:49 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]:35343) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfQ-0003Jk-0n for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:49 -0400 Received: by mail-ed1-x52c.google.com with SMTP id df12so13654703edb.2 for ; Fri, 25 Jun 2021 07:18:47 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:46 -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=QGL0PM6rhXFoTSl/VhJ0skxnKohdr8LQl81X8lWdfZU=; b=ZMPkjXvAqSEcyrrRYNIEKnA8Tsu9UFYF251+0mJpGKfvui1af6KmzUIAn7UPZpR1L/ 3cKSod5YB6sBie5ccCOiOsTXJix8XqakMjdMMAnenG3WCGchQW4Kh1c9+j4ZP8c2L5Kd t1j1eZW3EIsKXYMpWAnvL4i3phrEkRAVLnlMu4elrwvhPcAdTpw7Bs494bgFSwOn7DH8 mQ+KqW7SgRQx+AlfH8SByFyLUCIt8deJIxms0qxEoq9We8hj+Wx5nDzg0gook9HahgA+ DQmBYGoqkzuyhUwSEQQ5AqoTefNy1ESiOQgMbZoQbSUnEzqH/WDStqbCvAaMJotQ05DR GDVg== 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=QGL0PM6rhXFoTSl/VhJ0skxnKohdr8LQl81X8lWdfZU=; b=Ce5rctstgJYoXWhY/GHgriFqc2st3Yw8CjXj/ZHeiIC7RiDXQSHyGtOFFOOC0e9DPQ KvbQCk3X0uHTa1vM9+jUNVIZs9FRYjyAiULxIJdDlvFwwm7AD1J23/K74DxuWqHuueWl rQ8mAWpTv+j5xDrYukmXNla6P5f73GKAbbI6MYy2S7mKQlP9tL+OjEvGP3Z8MPgcYGxV e4ZyhQMl4ZuAmOZHEAC6eoDon68Hp1buBTvBsX2VgiCchAWlUwMjbh/yxI2+cQXzJF+C 29HyV6OWjFaT3JyIy2tXKTFLIDCcApAlXAmCme6bFzJU9iDLC3FhxazqbhM2HDOUZls+ Dn4g== X-Gm-Message-State: AOAM532A4o9JYu25b7F8y24jW5JcZH6+FaaJk6KHGj4T+Eh6RiOaX4FT cFTHvlDa6L4vgpMklPkRJ1tYX1YTcPE= X-Google-Smtp-Source: ABdhPJxRYnx/MjN2B22rbtW9wooDmNI81PRTQjXEB9DJiAJ5v8c89jydqOJTGLKGbJMFy+mMJksNzg== X-Received: by 2002:a05:6402:220d:: with SMTP id cq13mr14710228edb.214.1624630726582; Fri, 25 Jun 2021 07:18:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 24/28] machine: move dies from X86MachineState to CpuTopology Date: Fri, 25 Jun 2021 16:18:18 +0200 Message-Id: <20210625141822.1368639-25-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52c.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) In order to make SMP configuration a Machine property, we need a getter as well as a setter. To simplify the implementation put everything that the getter needs in the CpuTopology struct. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini Message-Id: <20210617155308.928754-7-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 1 + hw/i386/pc.c | 4 +--- hw/i386/x86.c | 15 +++++++-------- include/hw/boards.h | 1 + include/hw/i386/pc.h | 1 - include/hw/i386/x86.h | 1 - 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 55b9bc7817..d776c8cf20 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -970,6 +970,7 @@ static void machine_initfn(Object *obj) ms->smp.cpus =3D mc->default_cpus; ms->smp.max_cpus =3D mc->default_cpus; ms->smp.cores =3D 1; + ms->smp.dies =3D 1; ms->smp.threads =3D 1; ms->smp.sockets =3D 1; } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c6d8d0d84d..92958e9ad7 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -712,8 +712,6 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int l= evel) */ void pc_smp_parse(MachineState *ms, QemuOpts *opts) { - X86MachineState *x86ms =3D X86_MACHINE(ms); - if (opts) { unsigned cpus =3D qemu_opt_get_number(opts, "cpus", 0); unsigned sockets =3D qemu_opt_get_number(opts, "sockets", 0); @@ -769,7 +767,7 @@ void pc_smp_parse(MachineState *ms, QemuOpts *opts) ms->smp.cores =3D cores; ms->smp.threads =3D threads; ms->smp.sockets =3D sockets; - x86ms->smp_dies =3D dies; + ms->smp.dies =3D dies; } =20 if (ms->smp.cpus > 1) { diff --git a/hw/i386/x86.c b/hw/i386/x86.c index d30cf27e29..00448ed55a 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -64,7 +64,7 @@ inline void init_topo_info(X86CPUTopoInfo *topo_info, { MachineState *ms =3D MACHINE(x86ms); =20 - topo_info->dies_per_pkg =3D x86ms->smp_dies; + topo_info->dies_per_pkg =3D ms->smp.dies; topo_info->cores_per_die =3D ms->smp.cores; topo_info->threads_per_core =3D ms->smp.threads; } @@ -293,7 +293,7 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, =20 init_topo_info(&topo_info, x86ms); =20 - env->nr_dies =3D x86ms->smp_dies; + env->nr_dies =3D ms->smp.dies; =20 /* * If APIC ID is not set, @@ -301,13 +301,13 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, */ if (cpu->apic_id =3D=3D UNASSIGNED_APIC_ID) { int max_socket =3D (ms->smp.max_cpus - 1) / - smp_threads / smp_cores / x86ms->smp_dies; + smp_threads / smp_cores / ms->smp.dies; =20 /* * die-id was optional in QEMU 4.0 and older, so keep it optional * if there's only one die per socket. */ - if (cpu->die_id < 0 && x86ms->smp_dies =3D=3D 1) { + if (cpu->die_id < 0 && ms->smp.dies =3D=3D 1) { cpu->die_id =3D 0; } =20 @@ -322,9 +322,9 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, if (cpu->die_id < 0) { error_setg(errp, "CPU die-id is not set"); return; - } else if (cpu->die_id > x86ms->smp_dies - 1) { + } else if (cpu->die_id > ms->smp.dies - 1) { error_setg(errp, "Invalid CPU die-id: %u must be in range 0:%u= ", - cpu->die_id, x86ms->smp_dies - 1); + cpu->die_id, ms->smp.dies - 1); return; } if (cpu->core_id < 0) { @@ -477,7 +477,7 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineS= tate *ms) &topo_info, &topo_ids); ms->possible_cpus->cpus[i].props.has_socket_id =3D true; ms->possible_cpus->cpus[i].props.socket_id =3D topo_ids.pkg_id; - if (x86ms->smp_dies > 1) { + if (ms->smp.dies > 1) { ms->possible_cpus->cpus[i].props.has_die_id =3D true; ms->possible_cpus->cpus[i].props.die_id =3D topo_ids.die_id; } @@ -1269,7 +1269,6 @@ static void x86_machine_initfn(Object *obj) =20 x86ms->smm =3D ON_OFF_AUTO_AUTO; x86ms->acpi =3D ON_OFF_AUTO_AUTO; - x86ms->smp_dies =3D 1; x86ms->pci_irq_mask =3D ACPI_BUILD_PCI_IRQS; x86ms->oem_id =3D g_strndup(ACPI_BUILD_APPNAME6, 6); x86ms->oem_table_id =3D g_strndup(ACPI_BUILD_APPNAME8, 8); diff --git a/include/hw/boards.h b/include/hw/boards.h index 3d55d2bd62..87ae5cc300 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -282,6 +282,7 @@ typedef struct DeviceMemoryState { */ typedef struct CpuTopology { unsigned int cpus; + unsigned int dies; unsigned int cores; unsigned int threads; unsigned int sockets; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 1522a3359a..4c2ca6d36a 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -19,7 +19,6 @@ * PCMachineState: * @acpi_dev: link to ACPI PM device that performs ACPI hotplug handling * @boot_cpus: number of present VCPUs - * @smp_dies: number of dies per one package */ typedef struct PCMachineState { /*< private >*/ diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index 25a1f16f01..6e9244a82c 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -62,7 +62,6 @@ struct X86MachineState { unsigned pci_irq_mask; unsigned apic_id_limit; uint16_t boot_cpus; - unsigned smp_dies; =20 OnOffAuto smm; OnOffAuto acpi; --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16246325965991021.3442362249796; Fri, 25 Jun 2021 07:49:56 -0700 (PDT) Received: from localhost ([::1]:54724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwn9X-0002Eb-6E for importer@patchew.org; Fri, 25 Jun 2021 10:49:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60920) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfS-0003mP-Jw for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:50 -0400 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]:38486) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfQ-0003KF-LD for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:50 -0400 Received: by mail-ed1-x534.google.com with SMTP id q14so13621994eds.5 for ; Fri, 25 Jun 2021 07:18:48 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:46 -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=/bIWGO6QOwJ/Qr0480AkBxbVNABvwpA6wvZiD7P+Log=; b=ps2eEkP+oYBBMZHDI7NExvvKjkAbYXnDOwun45HSQK+qSz4ZiCZMTmKhwBs4eJLu5A Zb6e8Tb7TXAbQHLc8k56Cc/fkBRjc6B+HpHqINXhUW+HyRcVa4s1/GLzxWINOIt1SOE9 eJVG9lTlduaJ8KccKQC8JVutFOwV025eEY4gBSMs0SzUiEvXrMyHDQtgy3MI1RL3SPYc 7jEWTHBwcfVsYOJK08RiSxXvQfn9i0lR//YIGxyIVVzekMz0iWW5P1VQuMzuRCGYMhZv 8d24Fgm0CcLhNkaUcTmji5ZDoWhCsB3Hc7ZZVIfz8eOBFlemN92nX1WYd3zph0hok+GS dMiw== 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=/bIWGO6QOwJ/Qr0480AkBxbVNABvwpA6wvZiD7P+Log=; b=lI2+hfNi7NVbyFiJb4yLHh/bxWlxl5t7Js/AEXG89NxLMcqYy+pMdsDo8R1yt5PqP4 doF7TpgdkWvE2xG9WuI89wd1ntH0FFuRkGnK11CyfXz6eUM8Qvy0pTAebbXTAzTyKlzt 0uKpMgBZdRILC/X3ZToJkkSviNKDFcZw1ZPMhzCPXfZZ5TOrzCUQ7zsdP7prjw8k0REf UED0FuBYjHi+7y0lhZbll/v4e2V9hmF42zrQ+rK5iYTR++UB6xB4TzKETg89mrz2ROqP rbIlvEmGzLf+ced16ADzTTMV5dxLXApLrfs5+0TKFNJfxtAKd3DoBGDQDMsNCZ9o5s43 Sufw== X-Gm-Message-State: AOAM533HF5zmMgsugtgASAHUUc0xNLTqnkx4euJqkmPbMX+aM8z7dVRA o2OqFq12F6pSZK+1DbkdyxqT5jM6h/k= X-Google-Smtp-Source: ABdhPJzYu1PvEpFtCBl+RdJEtoVRps1vgVIlvzwch1vRWRcd1seZ1TaLnFGjauUYEFUip4jexqeh3A== X-Received: by 2002:a05:6402:4393:: with SMTP id o19mr14853432edc.263.1624630727322; Fri, 25 Jun 2021 07:18:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 25/28] machine: move common smp_parse code to caller Date: Fri, 25 Jun 2021 16:18:19 +0200 Message-Id: <20210625141822.1368639-26-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-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+importer=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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Most of smp_parse and pc_smp_parse is guarded by an "if (opts)" conditional, and the rest is common to both function. Move the conditional and the common code to the caller, machine_smp_parse. Move the replay_add_blocker call after all errors are checked for. Signed-off-by: Paolo Bonzini Message-Id: <20210617155308.928754-8-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 114 +++++++++++++++++++++++----------------------- hw/i386/pc.c | 108 ++++++++++++++++++++----------------------- 2 files changed, 107 insertions(+), 115 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index d776c8cf20..1016ec9e1c 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -741,67 +741,59 @@ void machine_set_cpu_numa_node(MachineState *machine, =20 static void smp_parse(MachineState *ms, QemuOpts *opts) { - if (opts) { - unsigned cpus =3D qemu_opt_get_number(opts, "cpus", 0); - unsigned sockets =3D qemu_opt_get_number(opts, "sockets", 0); - unsigned cores =3D qemu_opt_get_number(opts, "cores", 0); - unsigned threads =3D qemu_opt_get_number(opts, "threads", 0); + unsigned cpus =3D qemu_opt_get_number(opts, "cpus", 0); + unsigned sockets =3D qemu_opt_get_number(opts, "sockets", 0); + unsigned cores =3D qemu_opt_get_number(opts, "cores", 0); + unsigned threads =3D qemu_opt_get_number(opts, "threads", 0); =20 - /* compute missing values, prefer sockets over cores over threads = */ - if (cpus =3D=3D 0 || sockets =3D=3D 0) { - cores =3D cores > 0 ? cores : 1; - threads =3D threads > 0 ? threads : 1; - if (cpus =3D=3D 0) { - sockets =3D sockets > 0 ? sockets : 1; - cpus =3D cores * threads * sockets; - } else { - ms->smp.max_cpus =3D - qemu_opt_get_number(opts, "maxcpus", cpus); - sockets =3D ms->smp.max_cpus / (cores * threads); - } - } else if (cores =3D=3D 0) { - threads =3D threads > 0 ? threads : 1; - cores =3D cpus / (sockets * threads); - cores =3D cores > 0 ? cores : 1; - } else if (threads =3D=3D 0) { - threads =3D cpus / (cores * sockets); - threads =3D threads > 0 ? threads : 1; - } else if (sockets * cores * threads < cpus) { - error_report("cpu topology: " - "sockets (%u) * cores (%u) * threads (%u) < " - "smp_cpus (%u)", - sockets, cores, threads, cpus); - exit(1); + /* compute missing values, prefer sockets over cores over threads */ + if (cpus =3D=3D 0 || sockets =3D=3D 0) { + cores =3D cores > 0 ? cores : 1; + threads =3D threads > 0 ? threads : 1; + if (cpus =3D=3D 0) { + sockets =3D sockets > 0 ? sockets : 1; + cpus =3D cores * threads * sockets; + } else { + ms->smp.max_cpus =3D + qemu_opt_get_number(opts, "maxcpus", cpus); + sockets =3D ms->smp.max_cpus / (cores * threads); } - - ms->smp.max_cpus =3D - qemu_opt_get_number(opts, "maxcpus", cpus); - - if (ms->smp.max_cpus < cpus) { - error_report("maxcpus must be equal to or greater than smp"); - exit(1); - } - - if (sockets * cores * threads !=3D ms->smp.max_cpus) { - error_report("Invalid CPU topology: " - "sockets (%u) * cores (%u) * threads (%u) " - "!=3D maxcpus (%u)", - sockets, cores, threads, - ms->smp.max_cpus); - exit(1); - } - - ms->smp.cpus =3D cpus; - ms->smp.cores =3D cores; - ms->smp.threads =3D threads; - ms->smp.sockets =3D sockets; + } else if (cores =3D=3D 0) { + threads =3D threads > 0 ? threads : 1; + cores =3D cpus / (sockets * threads); + cores =3D cores > 0 ? cores : 1; + } else if (threads =3D=3D 0) { + threads =3D cpus / (cores * sockets); + threads =3D threads > 0 ? threads : 1; + } else if (sockets * cores * threads < cpus) { + error_report("cpu topology: " + "sockets (%u) * cores (%u) * threads (%u) < " + "smp_cpus (%u)", + sockets, cores, threads, cpus); + exit(1); } =20 - if (ms->smp.cpus > 1) { - Error *blocker =3D NULL; - error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp"); - replay_add_blocker(blocker); + ms->smp.max_cpus =3D + qemu_opt_get_number(opts, "maxcpus", cpus); + + if (ms->smp.max_cpus < cpus) { + error_report("maxcpus must be equal to or greater than smp"); + exit(1); } + + if (sockets * cores * threads !=3D ms->smp.max_cpus) { + error_report("Invalid CPU topology: " + "sockets (%u) * cores (%u) * threads (%u) " + "!=3D maxcpus (%u)", + sockets, cores, threads, + ms->smp.max_cpus); + exit(1); + } + + ms->smp.cpus =3D cpus; + ms->smp.cores =3D cores; + ms->smp.threads =3D threads; + ms->smp.sockets =3D sockets; } =20 static void machine_class_init(ObjectClass *oc, void *data) @@ -1135,7 +1127,9 @@ bool machine_smp_parse(MachineState *ms, QemuOpts *op= ts, Error **errp) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); =20 - mc->smp_parse(ms, opts); + if (opts) { + mc->smp_parse(ms, opts); + } =20 /* sanity-check smp_cpus and max_cpus against mc */ if (ms->smp.cpus < mc->min_cpus) { @@ -1151,6 +1145,12 @@ bool machine_smp_parse(MachineState *ms, QemuOpts *o= pts, Error **errp) mc->name, mc->max_cpus); return false; } + + if (ms->smp.cpus > 1) { + Error *blocker =3D NULL; + error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp"); + replay_add_blocker(blocker); + } return true; } =20 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 92958e9ad7..e206ac85f3 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -712,69 +712,61 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int= level) */ void pc_smp_parse(MachineState *ms, QemuOpts *opts) { - if (opts) { - unsigned cpus =3D qemu_opt_get_number(opts, "cpus", 0); - unsigned sockets =3D qemu_opt_get_number(opts, "sockets", 0); - unsigned dies =3D qemu_opt_get_number(opts, "dies", 1); - unsigned cores =3D qemu_opt_get_number(opts, "cores", 0); - unsigned threads =3D qemu_opt_get_number(opts, "threads", 0); + unsigned cpus =3D qemu_opt_get_number(opts, "cpus", 0); + unsigned sockets =3D qemu_opt_get_number(opts, "sockets", 0); + unsigned dies =3D qemu_opt_get_number(opts, "dies", 1); + unsigned cores =3D qemu_opt_get_number(opts, "cores", 0); + unsigned threads =3D qemu_opt_get_number(opts, "threads", 0); =20 - /* compute missing values, prefer sockets over cores over threads = */ - if (cpus =3D=3D 0 || sockets =3D=3D 0) { - cores =3D cores > 0 ? cores : 1; - threads =3D threads > 0 ? threads : 1; - if (cpus =3D=3D 0) { - sockets =3D sockets > 0 ? sockets : 1; - cpus =3D cores * threads * dies * sockets; - } else { - ms->smp.max_cpus =3D - qemu_opt_get_number(opts, "maxcpus", cpus); - sockets =3D ms->smp.max_cpus / (cores * threads * dies); - } - } else if (cores =3D=3D 0) { - threads =3D threads > 0 ? threads : 1; - cores =3D cpus / (sockets * dies * threads); - cores =3D cores > 0 ? cores : 1; - } else if (threads =3D=3D 0) { - threads =3D cpus / (cores * dies * sockets); - threads =3D threads > 0 ? threads : 1; - } else if (sockets * dies * cores * threads < cpus) { - error_report("cpu topology: " - "sockets (%u) * dies (%u) * cores (%u) * threads = (%u) < " - "smp_cpus (%u)", - sockets, dies, cores, threads, cpus); - exit(1); + /* compute missing values, prefer sockets over cores over threads */ + if (cpus =3D=3D 0 || sockets =3D=3D 0) { + cores =3D cores > 0 ? cores : 1; + threads =3D threads > 0 ? threads : 1; + if (cpus =3D=3D 0) { + sockets =3D sockets > 0 ? sockets : 1; + cpus =3D cores * threads * dies * sockets; + } else { + ms->smp.max_cpus =3D + qemu_opt_get_number(opts, "maxcpus", cpus); + sockets =3D ms->smp.max_cpus / (cores * threads * dies); } - - ms->smp.max_cpus =3D - qemu_opt_get_number(opts, "maxcpus", cpus); - - if (ms->smp.max_cpus < cpus) { - error_report("maxcpus must be equal to or greater than smp"); - exit(1); - } - - if (sockets * dies * cores * threads !=3D ms->smp.max_cpus) { - error_report("Invalid CPU topology deprecated: " - "sockets (%u) * dies (%u) * cores (%u) * threads = (%u) " - "!=3D maxcpus (%u)", - sockets, dies, cores, threads, - ms->smp.max_cpus); - exit(1); - } - - ms->smp.cpus =3D cpus; - ms->smp.cores =3D cores; - ms->smp.threads =3D threads; - ms->smp.sockets =3D sockets; - ms->smp.dies =3D dies; + } else if (cores =3D=3D 0) { + threads =3D threads > 0 ? threads : 1; + cores =3D cpus / (sockets * dies * threads); + cores =3D cores > 0 ? cores : 1; + } else if (threads =3D=3D 0) { + threads =3D cpus / (cores * dies * sockets); + threads =3D threads > 0 ? threads : 1; + } else if (sockets * dies * cores * threads < cpus) { + error_report("cpu topology: " + "sockets (%u) * dies (%u) * cores (%u) * threads (= %u) < " + "smp_cpus (%u)", + sockets, dies, cores, threads, cpus); + exit(1); } =20 - if (ms->smp.cpus > 1) { - Error *blocker =3D NULL; - error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp"); - replay_add_blocker(blocker); + ms->smp.max_cpus =3D + qemu_opt_get_number(opts, "maxcpus", cpus); + + if (ms->smp.max_cpus < cpus) { + error_report("maxcpus must be equal to or greater than smp"); + exit(1); } + + if (sockets * dies * cores * threads !=3D ms->smp.max_cpus) { + error_report("Invalid CPU topology deprecated: " + "sockets (%u) * dies (%u) * cores (%u) * threads (= %u) " + "!=3D maxcpus (%u)", + sockets, dies, cores, threads, + ms->smp.max_cpus); + exit(1); + } + + ms->smp.cpus =3D cpus; + ms->smp.cores =3D cores; + ms->smp.threads =3D threads; + ms->smp.sockets =3D sockets; + ms->smp.dies =3D dies; } =20 static --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624631389818219.35969536683922; Fri, 25 Jun 2021 07:29:49 -0700 (PDT) Received: from localhost ([::1]:55222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmq4-0006b6-O9 for importer@patchew.org; Fri, 25 Jun 2021 10:29:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfT-0003pp-E5 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:51 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]:44959) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfR-0003KT-Hj for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:51 -0400 Received: by mail-ej1-x630.google.com with SMTP id n2so4245030eju.11 for ; Fri, 25 Jun 2021 07:18:49 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:47 -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=urD9bcWBtakTOzRVsOR6rO1xdKgztkuvnTLHzYt41Aw=; b=QsGpSHoUYQYo73XaCg8AJJD6b4ewtwH8pRBCKP9WH1W3q0Q0Yr3IWLgUirlQcZItjk yh/mjyzl9s1H0n1SNAHe3kk06VrPaoXkGtgVCIOC7Cq40PJV++MZ7d4R1ZdG7c38Io6a aYU9S2MACzIxKLhjLRzERToDCovH9a7MyhLjmlrN+OuT0AaW9Bl7iWEzUjot1Qxp/tpy uUTvEZbCryUBuXKYhuA26c8y72QD53b/eU6vFZ0QC+xIrKNKN014dMOM6HrRhPsbi/Wr CK3FxG1aMXJfingFY2b0bkYUQxrYvJmtLx960wj3fi6XKgMxeruvgvxeLtoft9g1yn4l P0qA== 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=urD9bcWBtakTOzRVsOR6rO1xdKgztkuvnTLHzYt41Aw=; b=QfgnkGp8uaEZsfgUoEY2fvTlTFIZOUOJ6XsK2x2YgWgtXVTipTI3N0AOyauQ9V+m/W k2nliL68yH+VvMgG3FXqIj03TU2DZlRo7QG7cIx4Jx5q+mGRTu/+srNYwrSfuoxsluFr Z9xjfht5zxOrLu5T1Zh4UYeg7o7JyZDcthXiK5P7271TOWUUDsUKf5OZ1WgH6av8GJfU 8BBAkipmhrJOrrQ2OLVgR+nhJnwseyriqT6xgpBxeactSOYcfzW5sgljfqV43c88NbRz I4t2oeCp2GbX5ASnBvkx8GoskauCY8JFjEy/rPqvzrI40wHINuHyFC4blC5dXrFCnJHq XRsg== X-Gm-Message-State: AOAM533COe48op31rvNjIQwl/bNahiUTnFDbxa55YC484EapUDVbBVCI 759NLhH8I215XRljkWZ5SAfDScYoZBg= X-Google-Smtp-Source: ABdhPJxeJ5uFZ+KlWXuRhjU8baE44hb1p97iMqL5PQUJwsMKfuobxeqcZ/ZZVnI86xWjru5a1HnmcQ== X-Received: by 2002:a17:907:264c:: with SMTP id ar12mr11081729ejc.391.1624630728114; Fri, 25 Jun 2021 07:18:48 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 26/28] machine: add error propagation to mc->smp_parse Date: Fri, 25 Jun 2021 16:18:20 +0200 Message-Id: <20210625141822.1368639-27-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Clean up the smp_parse functions to use Error** instead of exiting. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini Message-Id: <20210617155308.928754-9-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 34 +++++++++++++++++++--------------- hw/i386/pc.c | 28 ++++++++++++++-------------- include/hw/boards.h | 2 +- include/hw/i386/pc.h | 2 -- 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 1016ec9e1c..5a9c97ccc5 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -739,7 +739,7 @@ void machine_set_cpu_numa_node(MachineState *machine, } } =20 -static void smp_parse(MachineState *ms, QemuOpts *opts) +static void smp_parse(MachineState *ms, QemuOpts *opts, Error **errp) { unsigned cpus =3D qemu_opt_get_number(opts, "cpus", 0); unsigned sockets =3D qemu_opt_get_number(opts, "sockets", 0); @@ -766,28 +766,28 @@ static void smp_parse(MachineState *ms, QemuOpts *opt= s) threads =3D cpus / (cores * sockets); threads =3D threads > 0 ? threads : 1; } else if (sockets * cores * threads < cpus) { - error_report("cpu topology: " - "sockets (%u) * cores (%u) * threads (%u) < " - "smp_cpus (%u)", - sockets, cores, threads, cpus); - exit(1); + error_setg(errp, "cpu topology: " + "sockets (%u) * cores (%u) * threads (%u) < " + "smp_cpus (%u)", + sockets, cores, threads, cpus); + return; } =20 ms->smp.max_cpus =3D qemu_opt_get_number(opts, "maxcpus", cpus); =20 if (ms->smp.max_cpus < cpus) { - error_report("maxcpus must be equal to or greater than smp"); - exit(1); + error_setg(errp, "maxcpus must be equal to or greater than smp"); + return; } =20 if (sockets * cores * threads !=3D ms->smp.max_cpus) { - error_report("Invalid CPU topology: " - "sockets (%u) * cores (%u) * threads (%u) " - "!=3D maxcpus (%u)", - sockets, cores, threads, - ms->smp.max_cpus); - exit(1); + error_setg(errp, "Invalid CPU topology: " + "sockets (%u) * cores (%u) * threads (%u) " + "!=3D maxcpus (%u)", + sockets, cores, threads, + ms->smp.max_cpus); + return; } =20 ms->smp.cpus =3D cpus; @@ -1126,9 +1126,13 @@ MemoryRegion *machine_consume_memdev(MachineState *m= achine, bool machine_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); + ERRP_GUARD(); =20 if (opts) { - mc->smp_parse(ms, opts); + mc->smp_parse(ms, opts, errp); + if (*errp) { + return false; + } } =20 /* sanity-check smp_cpus and max_cpus against mc */ diff --git a/hw/i386/pc.c b/hw/i386/pc.c index e206ac85f3..cce275dcb1 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -710,7 +710,7 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int l= evel) * This function is very similar to smp_parse() * in hw/core/machine.c but includes CPU die support. */ -void pc_smp_parse(MachineState *ms, QemuOpts *opts) +static void pc_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp) { unsigned cpus =3D qemu_opt_get_number(opts, "cpus", 0); unsigned sockets =3D qemu_opt_get_number(opts, "sockets", 0); @@ -738,28 +738,28 @@ void pc_smp_parse(MachineState *ms, QemuOpts *opts) threads =3D cpus / (cores * dies * sockets); threads =3D threads > 0 ? threads : 1; } else if (sockets * dies * cores * threads < cpus) { - error_report("cpu topology: " - "sockets (%u) * dies (%u) * cores (%u) * threads (= %u) < " - "smp_cpus (%u)", - sockets, dies, cores, threads, cpus); - exit(1); + error_setg(errp, "cpu topology: " + "sockets (%u) * dies (%u) * cores (%u) * threads (%u) <= " + "smp_cpus (%u)", + sockets, dies, cores, threads, cpus); + return; } =20 ms->smp.max_cpus =3D qemu_opt_get_number(opts, "maxcpus", cpus); =20 if (ms->smp.max_cpus < cpus) { - error_report("maxcpus must be equal to or greater than smp"); - exit(1); + error_setg(errp, "maxcpus must be equal to or greater than smp"); + return; } =20 if (sockets * dies * cores * threads !=3D ms->smp.max_cpus) { - error_report("Invalid CPU topology deprecated: " - "sockets (%u) * dies (%u) * cores (%u) * threads (= %u) " - "!=3D maxcpus (%u)", - sockets, dies, cores, threads, - ms->smp.max_cpus); - exit(1); + error_setg(errp, "Invalid CPU topology deprecated: " + "sockets (%u) * dies (%u) * cores (%u) * threads (%u) " + "!=3D maxcpus (%u)", + sockets, dies, cores, threads, + ms->smp.max_cpus); + return; } =20 ms->smp.cpus =3D cpus; diff --git a/include/hw/boards.h b/include/hw/boards.h index 87ae5cc300..0483d6af86 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -210,7 +210,7 @@ struct MachineClass { void (*reset)(MachineState *state); void (*wakeup)(MachineState *state); int (*kvm_type)(MachineState *machine, const char *arg); - void (*smp_parse)(MachineState *ms, QemuOpts *opts); + void (*smp_parse)(MachineState *ms, QemuOpts *opts, Error **errp); =20 BlockInterfaceType block_default_type; int units_per_default_bus; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 4c2ca6d36a..87294f2632 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -138,8 +138,6 @@ extern int fd_bootchk; =20 void pc_acpi_smi_interrupt(void *opaque, int irq, int level); =20 -void pc_smp_parse(MachineState *ms, QemuOpts *opts); - void pc_guest_info_init(PCMachineState *pcms); =20 #define PCI_HOST_PROP_PCI_HOLE_START "pci-hole-start" --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162463176644691.20425276314927; Fri, 25 Jun 2021 07:36:06 -0700 (PDT) Received: from localhost ([::1]:44134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmw9-0001N3-6b for importer@patchew.org; Fri, 25 Jun 2021 10:36:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfT-0003sU-W8 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:52 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:33370) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfS-0003Kr-6E for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:51 -0400 Received: by mail-ej1-x633.google.com with SMTP id bu12so15473741ejb.0 for ; Fri, 25 Jun 2021 07:18:49 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18: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=tgRY/UoYrXPJogrdpYXe8mcUTWND/106oKlRBPU+jnw=; b=np+kbX7dvx9sRE6EVPkDNH5tOE5b6xShzH4jFxSBsTzB6WEurJT+kGv/xIJwO8Qnc6 ySVP6pyVhtzqsOtPbm/dP8JVcDUuYOFLJZDwbEMRnL8K27y+Mdbzekdja8tn6Rz+hcze vho46DxYqYB14xgTy12jvaUDJlzXzOLrfepsYu/z8jXdAfP1ewqyn4wzsDlRn20d8Y25 I3BFkROJj1rnAFAPRl2LTNbk0StCLQO7GtxkbWl0fWQCp7sCCgSxtxDpeTRf5NiksexB krbal+LpIhs23Liavgq1TTqKxZ4MKt9uV2apQNpOlS6WQIpvMnSetn4TzPbHLMRJ2FCn Ti4w== 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=tgRY/UoYrXPJogrdpYXe8mcUTWND/106oKlRBPU+jnw=; b=bwlEXI3oVKM9jq9wofObCVz14GAYooO6fh9VXHnesL305zhEbKOqyReIUPXIxa9qyW 8ul0icdlSubdALNnD80VtglIvO2HMuj400cidJTra9pUnnWTHnDS32qLE1+eFmcCXU9q ZSlzyH/ohc2eHVypfqCePfqSSJJMNi8HLDZMNE/mDyf4Rs5ygcUbv1oEjOyFpnfnqYUo IAFACW7Kd11NkRNSOjTQOsx4dRr1aTOJ0944xR4IbaSxB4Zj0a904zb8kw0jBixy1UUZ pXjn8QPV1Vjw33ab9vmG/V1nBYSMNFlxnZEY3sZjv6xILExxIT6AKfkRa5LBBVFvE/hk EYCg== X-Gm-Message-State: AOAM5310mNw2Upm4QtZQM7ubHWhGeTc3xk7Ywjlo0nRQdv4mCXMP+3fU 7BlAF7FCa0AezJgZRvFURDOQ2An9kKE= X-Google-Smtp-Source: ABdhPJw2RnsKEB9UavF3nn7NgfvLr4Dwlssn32Nu7EBZT9XCxywugCNnFAqnyzbiSSzAQRg08nzgEg== X-Received: by 2002:a17:907:7b82:: with SMTP id ne2mr10907064ejc.271.1624630728849; Fri, 25 Jun 2021 07:18:48 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 27/28] machine: pass QAPI struct to mc->smp_parse Date: Fri, 25 Jun 2021 16:18:21 +0200 Message-Id: <20210625141822.1368639-28-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) As part of converting -smp to a property with a QAPI type, define the struct and use it to do the actual parsing. machine_smp_parse takes care of doing the QemuOpts->QAPI conversion by hand, for now. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini Message-Id: <20210617155308.928754-10-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 33 +++++++++++++++++++++++---------- hw/i386/pc.c | 18 ++++++++---------- include/hw/boards.h | 2 +- qapi/machine.json | 28 ++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 21 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 5a9c97ccc5..9ad8341a31 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -739,12 +739,12 @@ void machine_set_cpu_numa_node(MachineState *machine, } } =20 -static void smp_parse(MachineState *ms, QemuOpts *opts, Error **errp) +static void smp_parse(MachineState *ms, SMPConfiguration *config, Error **= errp) { - unsigned cpus =3D qemu_opt_get_number(opts, "cpus", 0); - unsigned sockets =3D qemu_opt_get_number(opts, "sockets", 0); - unsigned cores =3D qemu_opt_get_number(opts, "cores", 0); - unsigned threads =3D qemu_opt_get_number(opts, "threads", 0); + unsigned cpus =3D config->has_cpus ? config->cpus : 0; + unsigned sockets =3D config->has_sockets ? config->sockets : 0; + unsigned cores =3D config->has_cores ? config->cores : 0; + unsigned threads =3D config->has_threads ? config->threads : 0; =20 /* compute missing values, prefer sockets over cores over threads */ if (cpus =3D=3D 0 || sockets =3D=3D 0) { @@ -754,8 +754,7 @@ static void smp_parse(MachineState *ms, QemuOpts *opts,= Error **errp) sockets =3D sockets > 0 ? sockets : 1; cpus =3D cores * threads * sockets; } else { - ms->smp.max_cpus =3D - qemu_opt_get_number(opts, "maxcpus", cpus); + ms->smp.max_cpus =3D config->has_maxcpus ? config->maxcpus : c= pus; sockets =3D ms->smp.max_cpus / (cores * threads); } } else if (cores =3D=3D 0) { @@ -773,8 +772,7 @@ static void smp_parse(MachineState *ms, QemuOpts *opts,= Error **errp) return; } =20 - ms->smp.max_cpus =3D - qemu_opt_get_number(opts, "maxcpus", cpus); + ms->smp.max_cpus =3D config->has_maxcpus ? config->maxcpus : cpus; =20 if (ms->smp.max_cpus < cpus) { error_setg(errp, "maxcpus must be equal to or greater than smp"); @@ -1129,7 +1127,22 @@ bool machine_smp_parse(MachineState *ms, QemuOpts *o= pts, Error **errp) ERRP_GUARD(); =20 if (opts) { - mc->smp_parse(ms, opts, errp); + SMPConfiguration config =3D { + .has_cpus =3D !!qemu_opt_get(opts, "cpus"), + .cpus =3D qemu_opt_get_number(opts, "cpus", 0), + .has_sockets =3D !!qemu_opt_get(opts, "sockets"), + .sockets =3D qemu_opt_get_number(opts, "sockets", 0), + .has_dies =3D !!qemu_opt_get(opts, "dies"), + .dies =3D qemu_opt_get_number(opts, "dies", 0), + .has_cores =3D !!qemu_opt_get(opts, "cores"), + .cores =3D qemu_opt_get_number(opts, "cores", 0), + .has_threads =3D !!qemu_opt_get(opts, "threads"), + .threads =3D qemu_opt_get_number(opts, "threads", 0), + .has_maxcpus =3D !!qemu_opt_get(opts, "maxcpus"), + .maxcpus =3D qemu_opt_get_number(opts, "maxcpus", 0), + }; + + mc->smp_parse(ms, &config, errp); if (*errp) { return false; } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index cce275dcb1..8e1220db72 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -710,13 +710,13 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int= level) * This function is very similar to smp_parse() * in hw/core/machine.c but includes CPU die support. */ -static void pc_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp) +static void pc_smp_parse(MachineState *ms, SMPConfiguration *config, Error= **errp) { - unsigned cpus =3D qemu_opt_get_number(opts, "cpus", 0); - unsigned sockets =3D qemu_opt_get_number(opts, "sockets", 0); - unsigned dies =3D qemu_opt_get_number(opts, "dies", 1); - unsigned cores =3D qemu_opt_get_number(opts, "cores", 0); - unsigned threads =3D qemu_opt_get_number(opts, "threads", 0); + unsigned cpus =3D config->has_cpus ? config->cpus : 0; + unsigned sockets =3D config->has_sockets ? config->sockets : 0; + unsigned dies =3D config->has_dies ? config->dies : 1; + unsigned cores =3D config->has_cores ? config->cores : 0; + unsigned threads =3D config->has_threads ? config->threads : 0; =20 /* compute missing values, prefer sockets over cores over threads */ if (cpus =3D=3D 0 || sockets =3D=3D 0) { @@ -726,8 +726,7 @@ static void pc_smp_parse(MachineState *ms, QemuOpts *op= ts, Error **errp) sockets =3D sockets > 0 ? sockets : 1; cpus =3D cores * threads * dies * sockets; } else { - ms->smp.max_cpus =3D - qemu_opt_get_number(opts, "maxcpus", cpus); + ms->smp.max_cpus =3D config->has_maxcpus ? config->maxcpus : c= pus; sockets =3D ms->smp.max_cpus / (cores * threads * dies); } } else if (cores =3D=3D 0) { @@ -745,8 +744,7 @@ static void pc_smp_parse(MachineState *ms, QemuOpts *op= ts, Error **errp) return; } =20 - ms->smp.max_cpus =3D - qemu_opt_get_number(opts, "maxcpus", cpus); + ms->smp.max_cpus =3D config->has_maxcpus ? config->maxcpus : cpus; =20 if (ms->smp.max_cpus < cpus) { error_setg(errp, "maxcpus must be equal to or greater than smp"); diff --git a/include/hw/boards.h b/include/hw/boards.h index 0483d6af86..1eae4427e8 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -210,7 +210,7 @@ struct MachineClass { void (*reset)(MachineState *state); void (*wakeup)(MachineState *state); int (*kvm_type)(MachineState *machine, const char *arg); - void (*smp_parse)(MachineState *ms, QemuOpts *opts, Error **errp); + void (*smp_parse)(MachineState *ms, SMPConfiguration *config, Error **= errp); =20 BlockInterfaceType block_default_type; int units_per_default_bus; diff --git a/qapi/machine.json b/qapi/machine.json index e4d0f9b24f..c3210ee1fb 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1284,3 +1284,31 @@ ## { 'event': 'MEM_UNPLUG_ERROR', 'data': { 'device': 'str', 'msg': 'str' } } + +## +# @SMPConfiguration: +# +# Schema for CPU topology configuration. "0" or a missing value lets +# QEMU figure out a suitable value based on the ones that are provided. +# +# @cpus: number of virtual CPUs in the virtual machine +# +# @sockets: number of sockets in the CPU topology +# +# @dies: number of dies per socket in the CPU topology +# +# @cores: number of cores per thread in the CPU topology +# +# @threads: number of threads per core in the CPU topology +# +# @maxcpus: maximum number of hotpluggable virtual CPUs in the virtual mac= hine +# +# Since: 6.1 +## +{ 'struct': 'SMPConfiguration', 'data': { + '*cpus': 'int', + '*sockets': 'int', + '*dies': 'int', + '*cores': 'int', + '*threads': 'int', + '*maxcpus': 'int' } } --=20 2.31.1 From nobody Sat May 18 23:14:54 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162463158220053.23392646881064; Fri, 25 Jun 2021 07:33:02 -0700 (PDT) Received: from localhost ([::1]:35570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwmtB-0003zS-49 for importer@patchew.org; Fri, 25 Jun 2021 10:33:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfU-0003uO-K4 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:52 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]:44955) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfT-0003LX-26 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:52 -0400 Received: by mail-ej1-x62b.google.com with SMTP id n2so4245156eju.11 for ; Fri, 25 Jun 2021 07:18:50 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18: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=/R3TDq643NWhjtYvkYyERAd4NBN6y6ftEYduc2A59LQ=; b=T7ExMpV26pJwva/vkFo3EhSq7MjwrtFZoVJms8NCP5HDx3A2tgHsNRLPq4B/yj0g0p djzdGsHfuXNCcrvH4wR4mmwjZZ9iF3vHbtHz+bG+AB1ZGYd1a2qP9yhpvbmlsWBHdbJf 0xRz7e1bQf/tlVkPC2r95MG/IqCquABStUIjiKQgV8be5xfY3CSSLbofNKhq8RH9Kov6 5qzyitUr6qpCmrMuOIMyn5nCU1/lND2bojli9ZCvdXUoUtJ1oN1urZJACLkL4wTZLKqB 6tTQuU1quqKAPeSXR+9nijos0VyvyXz1tQSIuZ1WJ9r8c/3bULCMbdEBHm+wNt4tQc4N z43w== 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=/R3TDq643NWhjtYvkYyERAd4NBN6y6ftEYduc2A59LQ=; b=WKm3ie/C7nDaQdDf9dSyPV0rbomMW1bE/INSYZ7dtT4H4toz3rx1ymPpj6DUZ10FP8 O0yGwEriFf0gXnS7+XE+Bn+7UoedHlNR19+ZVHbKACDay8bGwc9G0r+feI8BqStrxmCC bY0vuYHvM49mrHy/mvPhUsqpgbsBJoL+blenkJ2dDNWMTO+VpbQC/CaJxO/80cSOP54h jmsTOxg4JCJcMC77CmbrLr5DEgDbRCwbbfUdpErNeNB+dzj5kjgA/h3yp679Pr9cJcxY MF8GlQKCrN19CjDO+fD6UidujzaOvf5rPSnuZlFacpD0VksSEld+ZQfB8ts/oJ3xF7JG exdw== X-Gm-Message-State: AOAM531zAu1NFTyF+LdBZSU9Opyg9TSWC3wt3spXRVTbdh30CcR0ubdH j770+Em9dzVW1ncutlZWWJG7tzdJmf4= X-Google-Smtp-Source: ABdhPJzYyWk7d9a0o9HUYp/ml1ZbtldPQDT4bmGWvEkV1Vjf+Lax1jvIbsTKjowhuQB9jnQkPk49+Q== X-Received: by 2002:a17:906:1f11:: with SMTP id w17mr11098136ejj.33.1624630729714; Fri, 25 Jun 2021 07:18:49 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 28/28] machine: reject -smp dies!=1 for non-PC machines Date: Fri, 25 Jun 2021 16:18:22 +0200 Message-Id: <20210625141822.1368639-29-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62b.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini Message-Id: <20210617155308.928754-11-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index 9ad8341a31..ffc076ae84 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -746,6 +746,10 @@ static void smp_parse(MachineState *ms, SMPConfigurati= on *config, Error **errp) unsigned cores =3D config->has_cores ? config->cores : 0; unsigned threads =3D config->has_threads ? config->threads : 0; =20 + if (config->has_dies && config->dies !=3D 0 && config->dies !=3D 1) { + error_setg(errp, "dies not supported by this machine's CPU topolog= y"); + } + /* compute missing values, prefer sockets over cores over threads */ if (cpus =3D=3D 0 || sockets =3D=3D 0) { cores =3D cores > 0 ? cores : 1; --=20 2.31.1