From nobody Tue Nov 26 00:45:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; 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 207.211.31.81 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=1589379133; cv=none; d=zohomail.com; s=zohoarc; b=P/Tp1Tmb+VMtBhDJpSbnf40ycLuH7S8iw2nx5VDoQSMEE9rWDsTU8htOQ4f4sokcfaFTV4l8lwdm8Ls/e/TvgZ+mvby8kQ5FB7nZoAnaFSaTh1IHclvaQhTU18Ig7KAGG3GlYFmlO1W8jLZodLthadPDaSVQqltzO200tjCad+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589379133; 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=Gppxy3UOmo0zY6+O2WcUZXybquBxUw811CSZ88aSM5A=; b=QmMCqib+dyI6ATKtwf4UAF/nIy57sALjzHCo1rrHrzEMXqUo/13psxbXSOILQp16rpkXTtAeAeGwPQGHESf1w/xhie3Aqp8S/GyMGtyP+EgmOOtvKIO3XnS0haPY2Y1kTsf7CqiJKaWJYNiPJqiYwPWjyAzi2bEviaPGuMl5oBg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1589379133694288.69944503715533; Wed, 13 May 2020 07:12:13 -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-101-ssPikIaTMUGz1FVEZ1_UYg-1; Wed, 13 May 2020 10:12:10 -0400 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 84B501009454; Wed, 13 May 2020 14:12:04 +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 651F95D9E8; Wed, 13 May 2020 14:12:04 +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 2CA711806B0B; Wed, 13 May 2020 14:12:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04DEB6VK026939 for ; Wed, 13 May 2020 10:11:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id BF0852018297; Wed, 13 May 2020 14:11:05 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D770D2029F72 for ; Wed, 13 May 2020 14:11:04 +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 18FAB804025 for ; Wed, 13 May 2020 14:11:04 +0000 (UTC) Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-372-s7IKsRaUPLuKYK_kxMirEg-1; Wed, 13 May 2020 10:11:01 -0400 Received: by mail-qt1-f196.google.com with SMTP id b1so13448845qtt.1 for ; Wed, 13 May 2020 07:11:01 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:fbf2:bc5e:c314:af31:7070]) by smtp.gmail.com with ESMTPSA id y28sm9906755qtc.62.2020.05.13.07.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 07:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589379132; 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=Gppxy3UOmo0zY6+O2WcUZXybquBxUw811CSZ88aSM5A=; b=fThjmqSB/hjI0GBUtuPubTg0BqEgRbhpZsk6ZUchqmOwjM2S0YzAUVanW43xuU/ep7Isqg YobRVIT1uSqAnXKrEfUwziL8bjr5u0f+xA/jopeTXPNWfG5jpazTDABUzW5yPRkjvB3nY9 vl1EyG9u+fKEkszXF2rt7flfmL3OEwQ= X-MC-Unique: ssPikIaTMUGz1FVEZ1_UYg-1 X-MC-Unique: s7IKsRaUPLuKYK_kxMirEg-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=Gppxy3UOmo0zY6+O2WcUZXybquBxUw811CSZ88aSM5A=; b=Cj63sA9wMS7qdv6GrYo3Bez0wP42MRyKgmasrScbM/2j6I2AsBz/+FCcNoZjK/A1+u VldUdcJioYkE8nEjMtJo7CxkMXI8Ocrez80dF5e6V/btgZrDhHipmZvFAEX93ixqpaij QnE3N0PvdkHI8Px2bWmFPyrSQtnA78uCMKBJ3rbbn/J2soAXcZafIbyyo4u2n1Ol2Iji vf0qplIbVTa+YqqnLkZlvDUwbKKiJp/3y8xWuZv4mgXDL+EK02QT6luRi8sSwdEqmSDD 2OmSJdzQrZJKJS1Bfsyhda0rpDSjd7hGx/Dc9swWQmEqMVlQQGnG5wvCpvhfOaq0vUTz cxtA== X-Gm-Message-State: AGi0Puau63lXHzzgAYXxVMVTdlC+nmuvW/aC4oM49FuT5kD10E6Jj58C 74gWruQKuDnVjSd3en0edwnfVl5Rf4w= X-Google-Smtp-Source: APiQypJrwr5Rv5deKwBu2nUs2IV/ws1K+8NeWu+ibpmMYpXqY+kHIx6I1bUPdPKZ6/QGEdAculjKRA== X-Received: by 2002:aed:3ac8:: with SMTP id o66mr28063807qte.110.1589379060792; Wed, 13 May 2020 07:11:00 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 6/8] qemu: build command line for the TPM Proxy device Date: Wed, 13 May 2020 11:10:37 -0300 Message-Id: <20200513141040.2580726-7-danielhb413@gmail.com> In-Reply-To: <20200513141040.2580726-1-danielhb413@gmail.com> References: <20200513141040.2580726-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , stefanb@linux.ibm.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.79 on 10.5.11.14 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. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Stefan Berger --- src/qemu/qemu_alias.c | 16 ++++++++++++++++ src/qemu/qemu_command.c | 21 +++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index b0ea62af39..08fe5aa501 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -413,6 +413,18 @@ qemuAssignDeviceTPMAlias(virDomainTPMDefPtr tpm, } =20 =20 +static int +qemuAssignDeviceTPMProxyAlias(virDomainTPMDefPtr tpmproxy, + int idx) +{ + if (tpmproxy->info.alias) + return 0; + + tpmproxy->info.alias =3D g_strdup_printf("tpmproxy%d", idx); + return 0; +} + + int qemuAssignDeviceRedirdevAlias(virDomainDefPtr def, virDomainRedirdevDefPtr redirdev, @@ -673,6 +685,10 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCa= psPtr qemuCaps) if (qemuAssignDeviceTPMAlias(def->tpm, 0) < 0) return -1; } + if (def->tpmproxy) { + if (qemuAssignDeviceTPMProxyAlias(def->tpmproxy, 0) < 0) + return -1; + } for (i =3D 0; i < def->nmems; i++) { if (qemuAssignDeviceMemoryAlias(NULL, def->mems[i], false) < 0) return -1; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index bfe70ed228..0b97db7388 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8981,6 +8981,24 @@ qemuBuildTPMCommandLine(virCommandPtr cmd, return 0; } =20 +static int +qemuBuildTPMProxyCommandLine(virCommandPtr cmd, + const virDomainDef *def) +{ + const virDomainTPMDef *tpmproxy =3D def->tpmproxy; + + if (!tpmproxy) + return 0; + + virCommandAddArg(cmd, "-device"); + virCommandAddArgFormat(cmd, "%s,id=3D%s,host-path=3D%s", + virDomainTPMModelTypeToString(tpmproxy->model), + tpmproxy->info.alias, + tpmproxy->data.passthrough.source.data.file.pat= h); + + return 0; +} + static int qemuBuildSEVCommandLine(virDomainObjPtr vm, virCommandPtr cmd, virDomainSEVDefPtr sev) @@ -9662,6 +9680,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildTPMCommandLine(cmd, def, qemuCaps) < 0) return NULL; =20 + if (qemuBuildTPMProxyCommandLine(cmd, def) < 0) + return NULL; + if (qemuBuildInputCommandLine(cmd, def, qemuCaps) < 0) return NULL; =20 --=20 2.26.2