From nobody Mon Nov 25 23:24:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1589581539; cv=none; d=zohomail.com; s=zohoarc; b=JRdcYL/Hg9/WiU8e+V/8CjryhGIudsTB+0PcNTks/g9utFORoNg47M2pgWFOIObuwEhYS4BXvZVd+54aQWprXgv4XscQk3lUVuiflgv1aGl1VXei90WQohWDRWKtXR8Jh09/220ZUROG8Hj/iE35pmEDOh/ZehQRrtevvUrAFHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589581539; 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=OiA9/Mc8ez/wSfyS79OAwPo72lTlNwQJOScSPsc1BGA=; b=A+X040/zqyVD3Pqrwh5YAO9XFFbHMckEN5qFGx5j/+HOPvxjDwuMRNDC4K4Ye9TtZwU/xJKV6UP538GFE4wRkW4BHabMreqbdtB4uIIUClTdnPeo6jjS0sBu5vou7rOugmx11EzJjSjkQJMDFAltiOJdikaoXZYDabyHJZjikn0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1589581539850953.752913840388; Fri, 15 May 2020 15:25:39 -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-17-4LmZg4slOa22vKKwctvr7Q-1; Fri, 15 May 2020 18:25:36 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6A35391164; Fri, 15 May 2020 22:25:30 +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 469F12DE74; Fri, 15 May 2020 22:25:30 +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 17BC31806B0D; Fri, 15 May 2020 22:25:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04FMPOQ6015353 for ; Fri, 15 May 2020 18:25:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 622361009C7F; Fri, 15 May 2020 22:25:24 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5CE991008B7F for ; Fri, 15 May 2020 22:25:24 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 1143F8007C8 for ; Fri, 15 May 2020 22:25:24 +0000 (UTC) Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208-hd7wREoBPXuNOH_e-u41Og-1; Fri, 15 May 2020 18:25:16 -0400 Received: by mail-qt1-f194.google.com with SMTP id p12so3349912qtn.13; Fri, 15 May 2020 15:25:16 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:fbf2:bc5e:c314:af31:7070]) by smtp.gmail.com with ESMTPSA id o18sm3181386qtb.7.2020.05.15.15.25.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 15:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589581538; 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=OiA9/Mc8ez/wSfyS79OAwPo72lTlNwQJOScSPsc1BGA=; b=X/9qA5dWYtjk+fsW5HbsXDrYfpHL6Xj9910vN3x4DfB3kgchYir3i8YDu/UBVy9/wbemkB HRRIaZ0zI2sAqxaxWtztaA1VEnMyT3YAPiinBbSoaAtTs/1e40AjGBtr3Gx6zCpY0OtV7V G4KijYAunttGzTs5QVeCBVncZY9+kiI= X-MC-Unique: 4LmZg4slOa22vKKwctvr7Q-1 X-MC-Unique: hd7wREoBPXuNOH_e-u41Og-1 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=OiA9/Mc8ez/wSfyS79OAwPo72lTlNwQJOScSPsc1BGA=; b=QuF00YuM/TG6pp/0YKjvo7ZwDM09IMMLWVQGWQgXz1ONtJJXqIuuGA1+sf9ZNskrS3 PZV4ulu4qbdvC7kTnAh9qB2UpJHMX8mIaPG9c3+z1eDSuu1JYL10wbXVCJqe9k1hQ/J9 gIul1ZZC3/L71v1kmAGFoWMmQtNrK2HS6JJLZxQ7G4MLQyuMM9BvPBdKrAjgw8s5vaop nHKJIPgEGYAqpjjb3yrZckVP+QK8b5i4Tp4WWGxrYkOyzx3/UlelwQzIJ/hTBP2JKLNg ZOAP4Y8uQ3ZfW1xhM6Gpxx4pGBwUJW4Em1ivCrFpaF5oiiBL2Ten1g2c+vWZc6l0h+IT xhtA== X-Gm-Message-State: AOAM531r8tjl+xRmPjPRg5XD2RFjDvCpqHnCLaBDjLSOA1dyUryJsrEc uLayxwCS+0BlXEf+SzJ801pSOBsB X-Google-Smtp-Source: ABdhPJzF7y/QlvYK0grTpgJADQvKhih4DxkhABVK8002WcFuX2eYLbVl72OzgVUdCu2JEYuP+n+4iQ== X-Received: by 2002:ac8:66d8:: with SMTP id m24mr5802503qtp.175.1589581515811; Fri, 15 May 2020 15:25:15 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v4 08/10] qemu: build command line for the TPM Proxy device Date: Fri, 15 May 2020 19:24:11 -0300 Message-Id: <20200515222413.1231605-9-danielhb413@gmail.com> In-Reply-To: <20200515222413.1231605-1-danielhb413@gmail.com> References: <20200515222413.1231605-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , stefanb@linux.ibm.com, jtomko@redhat.com, david@gibson.dropbear.id.au 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.23 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" This patch wraps it up all the wiring done in previous patches, enabling a PPC64 guest to launch a guest using a TPM Proxy device. Note that device validation is already being done in qemu_validate.c, qemuValidateDomainDeviceDefTPM(), on domain define time. We don't need to verify QEMU capabilities for this device again inside qemu_command.c. Reviewed-by: Stefan Berger Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_alias.c | 5 ++++- src/qemu/qemu_command.c | 27 ++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 9d72391ddb..522426794d 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -408,7 +408,10 @@ qemuAssignDeviceTPMAlias(virDomainTPMDefPtr tpm, if (tpm->info.alias) return 0; =20 - tpm->info.alias =3D g_strdup_printf("tpm%d", idx); + if (tpm->model =3D=3D VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY) + tpm->info.alias =3D g_strdup_printf("tpmproxy%d", idx); + else + tpm->info.alias =3D g_strdup_printf("tpm%d", idx); return 0; } =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d2ac19a7a8..1eef79b2a0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8979,6 +8979,26 @@ qemuBuildTPMCommandLine(virCommandPtr cmd, } =20 =20 +static int +qemuBuildTPMProxyCommandLine(virCommandPtr cmd, + virDomainTPMDefPtr tpm) +{ + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + const char *filePath =3D NULL; + + filePath =3D tpm->data.passthrough.source.data.file.path; + + virCommandAddArg(cmd, "-device"); + virBufferAsprintf(&buf, "%s,id=3D%s,host-path=3D", + virDomainTPMModelTypeToString(tpm->model), + tpm->info.alias); + virQEMUBuildBufferEscapeComma(&buf, filePath); + virCommandAddArgBuffer(cmd, &buf); + + return 0; +} + + static int qemuBuildTPMsCommandLine(virCommandPtr cmd, const virDomainDef *def, @@ -8987,8 +9007,13 @@ qemuBuildTPMsCommandLine(virCommandPtr cmd, size_t i; =20 for (i =3D 0; i < def->ntpms; i++) { - if (qemuBuildTPMCommandLine(cmd, def, def->tpms[i], qemuCaps) < 0) + if (def->tpms[i]->model =3D=3D VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY) { + if (qemuBuildTPMProxyCommandLine(cmd, def->tpms[i]) < 0) + return -1; + } else if (qemuBuildTPMCommandLine(cmd, def, + def->tpms[i], qemuCaps) < 0) { return -1; + } } =20 return 0; --=20 2.26.2