From nobody Thu May 2 02:06:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594198198; cv=none; d=zohomail.com; s=zohoarc; b=m8LYZ9659Lp1/oa/ZkrgqgZMk2ZfgTCLq+7pd98lqeiFWHPVzV/OH9gDpmFAu7xT8jmFfQEogu55mCZbTGqx3+XhHgL38v5nVxwvnfeRtTgOFzqSz8O3spXO8S8WzPmr4441JRklK5yydiCSjn11SuCHgDg2SFK/XQdZ5VdTLMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594198198; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hLEf7kdqllCQogCXpBXRfgLD9bMXH2pyungrio94Pn8=; b=ewQXTWZW34eIhxCKrH8rUo1uO98Z4espSihKaDA+vMDl5F4Mtv3Vn4qxGZycTA6eIb+S1Ltj407uLDoiSdhFw58YueZMJWYEvfUb9PeuCoVf7HrWLZkKa2bZo6dTmZkGVhNXhsrc4nKJLd2NBql1sjNnMZefET5YP29A+xsqdig= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594198198258220.7142178824115; Wed, 8 Jul 2020 01:49:58 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-188-rinRbLG2PVKO7B-CSn4A5A-1; Wed, 08 Jul 2020 04:49:54 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 79C20805729; Wed, 8 Jul 2020 08:49:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5730A1000235; Wed, 8 Jul 2020 08:49:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 279A31809557; Wed, 8 Jul 2020 08:49:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0688naCn016459 for ; Wed, 8 Jul 2020 04:49:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8B57E1A914; Wed, 8 Jul 2020 08:49:36 +0000 (UTC) Received: from nautilus.redhat.com (unknown [10.40.193.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id D301519C4F; Wed, 8 Jul 2020 08:49:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594198196; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hLEf7kdqllCQogCXpBXRfgLD9bMXH2pyungrio94Pn8=; b=NWNELi0jStDIMhe2FWXHeqyHMHzBu3h2ZYgEZu8xobQjx135iv9GAuyYiTr15XLgsHDwil RPACVSomB696s+UkgMUfOdzH9HMLCX+CEmayvA+K1oTT0QUY5VjvpSS5uYth9+2hC6trXd BF3/6Alhr75J2mYn3enFy5jEJpBKyPM= X-MC-Unique: rinRbLG2PVKO7B-CSn4A5A-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt PATCH v2 1/2] qemu: Use virQEMUCapsCacheLookupDefault instead of lookup by arch Date: Wed, 8 Jul 2020 10:49:30 +0200 Message-Id: <912341135b0342dfb34867152ea293ebb3d49577.1594198169.git.eskultet@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Erik Skultety X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Firstly, SEV is present only on AMD, so we can safely assume x86. Secondly, the problem with looking up capabilities in the cache by arch is that it's using virHashSearch with a callback to find the right capabilities and get the binary name from it as well, but since the cache is empty, it will return NULL and we won't get the corresponding binary name out of the lookup either. Then, during the cache validation we try to create a new cache entry for the emulator, but since we don't have the binary name, nothing gets created. Therefore, virQEMUCapsCacheLookupDefault is used to fix this issue, because it doesn't rely on the capabilities cache to construct the emulator binary name. https://bugzilla.redhat.com/show_bug.cgi?id=3D1852311 Signed-off-by: Erik Skultety Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_driver.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a5b38b3d24..cd8d7ffb56 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -22823,8 +22823,10 @@ qemuNodeGetSEVInfo(virConnectPtr conn, if (virNodeGetSevInfoEnsureACL(conn) < 0) return -1; =20 - qemucaps =3D virQEMUCapsCacheLookupByArch(driver->qemuCapsCache, - virArchFromHost()); + qemucaps =3D virQEMUCapsCacheLookupDefault(driver->qemuCapsCache, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL); + if (!qemucaps) return -1; =20 --=20 2.26.2 From nobody Thu May 2 02:06:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594198189; cv=none; d=zohomail.com; s=zohoarc; b=NDj2C/nY0DpFm/6nTajs6/MvBNhUTzPcCoztpbjs50+UIr6puM5RepCQA2Aw7hnfhyAzIAdlqfbPoL62Yr04JlgqjJduJzCoWz77RXhPwipV+XAGtVKkEWLSpfpTcIHqNx5Bfq9bR6AJjuN+mpD+NH2Nri9NIbCOtefvRfDjetM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594198189; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mQmJhut3MWFu988AJz0C0GEApMEJIZoeW1bPpUBZwd0=; b=Le0H8jT177j/9DYLEdxVOzhiLpluFHbwHIkLKCBdeFOmi2Qio4dxE2e74tnM3eQ+BxCWYyaeOsu4LJgNBJ93dO3F9OnR5LltYAvZ7MSNS4guvFzv2BZM58OicISD8TmDyzVwsXbjT3c5AgJIVDkVJgbFDWrBVkRH9XkBf1/14Zs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594198189399907.1155217533907; Wed, 8 Jul 2020 01:49:49 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-96--wr5_npAO7ScxpGSqWDQEw-1; Wed, 08 Jul 2020 04:49:45 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 896248015F3; Wed, 8 Jul 2020 08:49:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B7D36106A; Wed, 8 Jul 2020 08:49:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E3CAB1809547; Wed, 8 Jul 2020 08:49:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0688nbQE016470 for ; Wed, 8 Jul 2020 04:49:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 965841A914; Wed, 8 Jul 2020 08:49:37 +0000 (UTC) Received: from nautilus.redhat.com (unknown [10.40.193.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF02719D7E; Wed, 8 Jul 2020 08:49:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594198188; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mQmJhut3MWFu988AJz0C0GEApMEJIZoeW1bPpUBZwd0=; b=b3gNrFcGOLH+eKsoPvpaA12LqP0454G19OB5kh435VqNC1T854hS7s21NXWaT9uo82I8Xa HqViX9yu7KerPuf1YAVYfDceJQ5Ub/IsvHYKWGDHPkmGe75xrvIQ8wPKWCzZtcHtaXCq87 Ok2tvAdPwntReJ2OZWoByx0vfBvhIP0= X-MC-Unique: -wr5_npAO7ScxpGSqWDQEw-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt PATCH v2 2/2] qemu: capabilities: Drop the virQEMUCapsCacheLookupByArch function Date: Wed, 8 Jul 2020 10:49:31 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Erik Skultety X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Previous commit removed the last usage of the function. Drop virQEMUCapsCompareArch as well since virQEMUCapsCacheLookupByArch was its only caller. Signed-off-by: Erik Skultety Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_capabilities.c | 63 ------------------------------------ src/qemu/qemu_capabilities.h | 2 -- 2 files changed, 65 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index efc42aac17..25a0b36940 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5668,69 +5668,6 @@ virQEMUCapsCacheLookupCopy(virFileCachePtr cache, } =20 =20 -static int -virQEMUCapsCompareArch(const void *payload, - const void *name G_GNUC_UNUSED, - const void *opaque) -{ - struct virQEMUCapsSearchData *data =3D (struct virQEMUCapsSearchData *= )opaque; - const virQEMUCaps *qemuCaps =3D payload; - - if (qemuCaps->arch !=3D data->arch) - return false; - - if (data->binaryFilter && - !strstr(qemuCaps->binary, data->binaryFilter)) { - return false; - } - - return true; -} - - -virQEMUCapsPtr -virQEMUCapsCacheLookupByArch(virFileCachePtr cache, - virArch arch) -{ - virQEMUCapsCachePrivPtr priv =3D virFileCacheGetPriv(cache); - virQEMUCapsPtr ret =3D NULL; - const char *binaryFilters[] =3D { - "qemu-system-", - NULL, - }; - virArch archs[] =3D { - arch, - virQEMUCapsFindTarget(virArchFromHost(), arch), - }; - size_t i; - size_t j; - - priv->microcodeVersion =3D virHostCPUGetMicrocodeVersion(); - - for (i =3D 0; i < G_N_ELEMENTS(binaryFilters); i++) { - for (j =3D 0; j < G_N_ELEMENTS(archs); j++) { - struct virQEMUCapsSearchData data =3D { - .arch =3D archs[j], - .binaryFilter =3D binaryFilters[i], - }; - - ret =3D virFileCacheLookupByFunc(cache, virQEMUCapsCompareArch= , &data); - if (ret) - goto done; - } - } - - virReportError(VIR_ERR_INVALID_ARG, - _("unable to find any emulator to serve '%s' " - "architecture"), virArchToString(arch)); - - done: - VIR_DEBUG("Returning caps %p for arch %s", ret, virArchToString(arch)); - - return ret; -} - - /** * virQEMUCapsCacheLookupDefault: * @cache: QEMU capabilities cache diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 3e585d1229..9834fc2a52 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -703,8 +703,6 @@ virQEMUCapsPtr virQEMUCapsCacheLookupCopy(virFileCacheP= tr cache, virDomainVirtType virtType, const char *binary, const char *machineType); -virQEMUCapsPtr virQEMUCapsCacheLookupByArch(virFileCachePtr cache, - virArch arch); virQEMUCapsPtr virQEMUCapsCacheLookupDefault(virFileCachePtr cache, const char *binary, const char *archStr, --=20 2.26.2