From nobody Sun Feb 8 16:30:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575933403; cv=none; d=zohomail.com; s=zohoarc; b=CGtgWyfVI2W8vIEZeArSd3g8xmT4PA+Tf9/6PjXPyF5/+8/NMrmyBN9yTm0Wwzvr8Xt2oJvoQ30LxuOZbRtd2xjs7RXDb1XONN7arTGG49gk5aMH4WvET5fz8dKawj4VmG5qceBfjohHtqxsaX/vAF4qjNANdSJTiefo2hGQmY4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575933403; 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=v/ivVxrWi8E9+wA/8Jg5KRv3LuIMLnd8QHFzOsgo7dc=; b=ljQ1xC2KHV4e0JJEYcaoICFC+rGFXRMPaJpVCRobfFoevkX3K8qLhinZbm5WOckYQxfT0u+12SNxIZIJ4C9FwsqgHdVPpSoLbC2EBQWD7AzNg0jhyMIYam+39e+nydGY09c1T/VfpIBX8nbR5Z96iyWsi7+UWkWSwaInw1R76PE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1575933403671581.4552674883496; Mon, 9 Dec 2019 15:16:43 -0800 (PST) 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-350-DR_l5FRIOYuBPjniDGTthw-1; Mon, 09 Dec 2019 18:16:39 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5BE2A8024CE; Mon, 9 Dec 2019 23:16:32 +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 34BD55D9D6; Mon, 9 Dec 2019 23:16:32 +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 D6E428356C; Mon, 9 Dec 2019 23:16:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB9NGSEr008712 for ; Mon, 9 Dec 2019 18:16:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9B4CEDBF19; Mon, 9 Dec 2019 23:16:28 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 96581DBF14 for ; Mon, 9 Dec 2019 23:16:28 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7437290B970 for ; Mon, 9 Dec 2019 23:16:28 +0000 (UTC) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-171-Ux-035fLNiSK5jTkXNpq4w-1; Mon, 09 Dec 2019 18:16:25 -0500 Received: by mail-qk1-f196.google.com with SMTP id k6so14800259qki.5; Mon, 09 Dec 2019 15:16:24 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:fe5:8243:c780:f073:3beb]) by smtp.gmail.com with ESMTPSA id e130sm352436qkb.72.2019.12.09.15.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 15:16:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575933402; 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=v/ivVxrWi8E9+wA/8Jg5KRv3LuIMLnd8QHFzOsgo7dc=; b=PQVBpeDbu9LcmptQO2NcR0e6hajBzBye+6Fsgt2c1TXEUPfkpVbdFf5qQ8TFJ6e3orIoFT dmcrLulRJpqXf80Zw781vb6xmS+jMAMHKKZY2sRpH2+I+Nz2sMIf1y2STa593skuHDRSjl roqkooNQ+LVm/AkDZ6ljqY2oXZy/I/I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QwoV8Hh3ThCjfBm29BTsrEfZOqSODffI4HlswgYqzGo=; b=IP95hL/+NqRRAa5DQYkCHxocDo+LYgr3PbSeVroFCxioiT/ZWMl/hnvY3rf4G9GNob G8Rl1AFIxHvSYRVo6LdYXdcltTVEHAt9OLLP8uehyjzt29xB5v+79E4YY2Pc2Fs9VuGL HrcsHOfPMKC+nKPeAzz8btumAKb0m+aSCr0AQUAlFXJW/QnaYHYuxDHup2ctCWHcwSwz jvRVLthsdKCmSCHUlDxoby+cIRstkg5Ull9gG4/J3rhkqLeYtq/Q8EhnsNUiIwTNb5nu b4UwBuzTo2uGaaTdlro76bhRRndNHVHekldWul7SHJIYlkElHPSb+nvrMDFj4YgvAJ1O P2EQ== X-Gm-Message-State: APjAAAUhM8GUlyd47lyUuBodl3wnsNgUSlzHv9KvRHYK6uTWZ3iqMJMm e2wpCx4NWdBnQWFBFkNUKYTwF/A6hfY= X-Google-Smtp-Source: APXvYqyfWGSaLJ/MlloBMh8FCZ0MVVS8FqkN9chqXZMcm/h7Yc6146K0zd4K8/WNUpoC5BCLhh9ZRQ== X-Received: by 2002:a37:9245:: with SMTP id u66mr30983513qkd.102.1575933384252; Mon, 09 Dec 2019 15:16:24 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Mon, 9 Dec 2019 20:15:31 -0300 Message-Id: <20191209231531.2423222-27-danielhb413@gmail.com> In-Reply-To: <20191209231531.2423222-1-danielhb413@gmail.com> References: <20191209231531.2423222-1-danielhb413@gmail.com> MIME-Version: 1.0 X-MC-Unique: Ux-035fLNiSK5jTkXNpq4w-1 X-MC-Unique: DR_l5FRIOYuBPjniDGTthw-1 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xB9NGSEr008712 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , crobinso@redhat.com Subject: [libvirt] [PATCH v1 26/26] qemu: move qemuBuildTPMDevStr TPM validation to qemu_domain.c 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.14 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" qemuBuildTPMDevStr() does TPM model validation that can be moved to qemu_domain.c, allowing validation in domain define time. This patch moves it to the existing qemuDomainDeviceDefValidateTPM() function. Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_command.c | 32 ++++---------------------------- src/qemu/qemu_domain.c | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d1befdab90..b77003d1b1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9029,34 +9029,11 @@ qemuBuildDomainLoaderCommandLine(virCommandPtr cmd, =20 =20 static char * -qemuBuildTPMDevStr(const virDomainDef *def, - virQEMUCapsPtr qemuCaps) +qemuBuildTPMDevStr(const virDomainDef *def) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const virDomainTPMDef *tpm =3D def->tpm; const char *model =3D virDomainTPMModelTypeToString(tpm->model); - virQEMUCapsFlags flag; - - switch (tpm->model) { - case VIR_DOMAIN_TPM_MODEL_TIS: - flag =3D QEMU_CAPS_DEVICE_TPM_TIS; - break; - case VIR_DOMAIN_TPM_MODEL_CRB: - flag =3D QEMU_CAPS_DEVICE_TPM_CRB; - break; - case VIR_DOMAIN_TPM_MODEL_LAST: - default: - virReportEnumRangeError(virDomainTPMModel, tpm->model); - return NULL; - } - - if (!virQEMUCapsGet(qemuCaps, flag)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("The QEMU executable %s does not support TPM " - "model %s"), - def->emulator, model); - return NULL; - } =20 virBufferAsprintf(&buf, "%s,tpmdev=3Dtpm-%s,id=3D%s", model, tpm->info.alias, tpm->info.alias); @@ -9150,8 +9127,7 @@ qemuBuildTPMBackendStr(const virDomainDef *def, =20 static int qemuBuildTPMCommandLine(virCommandPtr cmd, - const virDomainDef *def, - virQEMUCapsPtr qemuCaps) + const virDomainDef *def) { char *optstr; g_autofree char *chardev =3D NULL; @@ -9191,7 +9167,7 @@ qemuBuildTPMCommandLine(virCommandPtr cmd, VIR_FREE(fdset); } =20 - if (!(optstr =3D qemuBuildTPMDevStr(def, qemuCaps))) + if (!(optstr =3D qemuBuildTPMDevStr(def))) return -1; =20 virCommandAddArgList(cmd, "-device", optstr, NULL); @@ -9915,7 +9891,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, chardevStdioLogd) < 0) return NULL; =20 - if (qemuBuildTPMCommandLine(cmd, def, qemuCaps) < 0) + if (qemuBuildTPMCommandLine(cmd, def) < 0) return NULL; =20 if (qemuBuildInputCommandLine(cmd, def, qemuCaps) < 0) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3dba074c5c..f5369f5b36 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7600,6 +7600,8 @@ qemuDomainDeviceDefValidateTPM(virDomainTPMDef *tpm, const virDomainDef *def, virQEMUCapsPtr qemuCaps) { + virQEMUCapsFlags flag; + /* TPM 1.2 and 2 are not compatible, so we choose a specific version h= ere */ if (tpm->version =3D=3D VIR_DOMAIN_TPM_VERSION_DEFAULT) tpm->version =3D VIR_DOMAIN_TPM_VERSION_1_2; @@ -7636,6 +7638,28 @@ qemuDomainDeviceDefValidateTPM(virDomainTPMDef *tpm, break; } =20 + switch (tpm->model) { + case VIR_DOMAIN_TPM_MODEL_TIS: + flag =3D QEMU_CAPS_DEVICE_TPM_TIS; + break; + case VIR_DOMAIN_TPM_MODEL_CRB: + flag =3D QEMU_CAPS_DEVICE_TPM_CRB; + break; + case VIR_DOMAIN_TPM_MODEL_LAST: + default: + virReportEnumRangeError(virDomainTPMModel, tpm->model); + return -1; + } + + if (!virQEMUCapsGet(qemuCaps, flag)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("The QEMU executable %s does not support TPM " + "model %s"), + def->emulator, + virDomainTPMModelTypeToString(tpm->model)); + return -1; + } + return 0; =20 no_support: --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list