From nobody Fri May 17 23:32:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1643632877; cv=none; d=zohomail.com; s=zohoarc; b=jEpQ1eb82rxAYawOzr422bNO2fSzdJBx41pmc3NdHiPju7VYPo/dv/z/Fxir8SbU6dhfw9uqYVOznA1DMTQ1zB4c0oJdQqyxF+MX/x/eNq22iNOSliIdy7itA5tZDqCnhez5AOGXveo2PH0uyqSWWwcmOK8TVKqTbUNEV26mgiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643632877; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=xqFK6CsbAnzWAEIyS2frnTKzE1SanUtuGLXhPFAIV4Y=; b=SkfjgB5KoFu36gmQdMJbokwO3ErufOF0uTfCGo0ckKuZUhkr/5IVt0NgcTjhMIIXj+7jtOOzpm5keVUrgmB3qVduj2ZKKmVV6itFh+y2GYwkmFdOIHgNciCfSwXEkBQI2bOQweqm3G9cG8M0lMRRmgnOkREQQFuh56CaEAwjlKk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1643632877677238.58344252516122; Mon, 31 Jan 2022 04:41:17 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-479-BffzxpMJP4aaSRZwMVtUtg-1; Mon, 31 Jan 2022 07:41:12 -0500 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 811631006AA3; Mon, 31 Jan 2022 12:41:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3263478C2E; Mon, 31 Jan 2022 12:41:07 +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 B349E4BB7C; Mon, 31 Jan 2022 12:41:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20VCf4rE026469 for ; Mon, 31 Jan 2022 07:41:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id E4EC28464C; Mon, 31 Jan 2022 12:41:04 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63B2C84643 for ; Mon, 31 Jan 2022 12:40:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643632876; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xqFK6CsbAnzWAEIyS2frnTKzE1SanUtuGLXhPFAIV4Y=; b=U6rwdMU4l8ydxCVlJlOKqd2A8TSClBWZfthB9uJj+GFiMsBVf8tBbeFXnb1QjyyfW7g/Zz X3/ADT4nsP1yTURy/LLpp2Y9k+HyNe74TqfHl/CDgaw1PM5ikxHWgOiqGk7/IgNhQjolUj 7VWpG0gdeNV6PkPFT/wAy4gsYPasoh4= X-MC-Unique: BffzxpMJP4aaSRZwMVtUtg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH] qemu: qemuDomainSetLaunchSecurityState: do not lookup qemuCaps in cache Date: Mon, 31 Jan 2022 13:40:34 +0100 Message-Id: <489a65a73f6ac4f80db129f13bae3f6f5e3ee995.1643632815.git.jtomko@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643632880357100001 Any active domain has a copy in the privateData, filled in qemuProcessInit. Move the qemu capability check below the activeness check and remove the extra lookup. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/qemu/qemu_driver.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cbd17c10ae..acaa6f7629 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19975,12 +19975,12 @@ qemuDomainSetLaunchSecurityState(virDomainPtr dom= ain, virDomainObj *vm; int ret =3D -1; int rc; - g_autoptr(virQEMUCaps) qemucaps =3D NULL; const char *secrethdr =3D NULL; const char *secret =3D NULL; unsigned long long setaddr =3D 0; bool hasSetaddr =3D false; int state; + qemuDomainObjPrivate *priv; =20 virCheckFlags(0, -1); if (virTypedParamsValidate(params, nparams, @@ -19996,6 +19996,8 @@ qemuDomainSetLaunchSecurityState(virDomainPtr domai= n, if (!(vm =3D qemuDomainObjFromDomain(domain))) goto cleanup; =20 + priv =3D vm->privateData; + if (virDomainSetLaunchSecurityStateEnsureACL(domain->conn, vm->def) < = 0) goto cleanup; =20 @@ -20007,17 +20009,6 @@ qemuDomainSetLaunchSecurityState(virDomainPtr doma= in, goto cleanup; } =20 - if (!(qemucaps =3D virQEMUCapsCacheLookupDefault(driver->qemuCapsCache, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL))) - goto cleanup; - - if (!virQEMUCapsGet(qemucaps, QEMU_CAPS_SEV_INJECT_LAUNCH_SECRET)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("QEMU does not support setting a launch secret")); - goto cleanup; - } - if (virTypedParamsGetString(params, nparams, VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_HEAD= ER, &secrethdr) < 0 || @@ -20050,6 +20041,12 @@ qemuDomainSetLaunchSecurityState(virDomainPtr doma= in, goto endjob; } =20 + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_SEV_INJECT_LAUNCH_SECRET= )) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("QEMU does not support setting a launch secret")); + goto cleanup; + } + qemuDomainObjEnterMonitor(driver, vm); rc =3D qemuMonitorSetLaunchSecurityState(QEMU_DOMAIN_PRIVATE(vm)->mon, secrethdr, secret, setaddr, has= Setaddr); --=20 2.34.1