From nobody Tue Feb 10 23:00:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1624006491119507.9101942550669; Fri, 18 Jun 2021 01:54:51 -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-457-JtMcJc5QPHqvQLrsZumEXA-1; Fri, 18 Jun 2021 04:54:48 -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 C9D00100C670; Fri, 18 Jun 2021 08:54:42 +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 A7EF160E3A; Fri, 18 Jun 2021 08:54:42 +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 6F2C21809CAC; Fri, 18 Jun 2021 08:54:42 +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 15I8r0Pa010552 for ; Fri, 18 Jun 2021 04:53:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id DDB0D10C7339; Fri, 18 Jun 2021 08:53:00 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D96ED10C732B for ; Fri, 18 Jun 2021 08:53:00 +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-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C3562101A55F for ; Fri, 18 Jun 2021 08:53:00 +0000 (UTC) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-596-QEQC4jLyPgeuXCBKEDKk4g-5; Fri, 18 Jun 2021 04:52:58 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2021 01:51:55 -0700 Received: from duan-client-optiplex-7080.bj.intel.com ([10.238.156.114]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2021 01:51:54 -0700 X-MC-Unique: JtMcJc5QPHqvQLrsZumEXA-1 X-MC-Unique: QEQC4jLyPgeuXCBKEDKk4g-5 IronPort-SDR: lhh0Il68nEhbWFLDxbFt7NtFkN6R6+R7Cxu6N9oc4BkqQSEmv66+adNZYIzF8Cga2w7msUYcw4 jATA7Q3rzxhA== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="267665947" X-IronPort-AV: E=Sophos;i="5.83,283,1616482800"; d="scan'208";a="267665947" IronPort-SDR: Y5dWlmpZpZeSyQPDMkV6m4VudnPrxlGzs2LWcqiq1muskpihGj9qhsP32Sn5m+VhpTJP6aO4RW GzFaMZYl0fIQ== X-IronPort-AV: E=Sophos;i="5.83,283,1616482800"; d="scan'208";a="485611641" From: Zhenzhong Duan To: libvir-list@redhat.com Subject: [RFC PATCH 4/7] qemu: add support to launch TDX guest Date: Fri, 18 Jun 2021 16:50:49 +0800 Message-Id: <20210618085052.564315-5-zhenzhong.duan@intel.com> In-Reply-To: <20210618085052.564315-1-zhenzhong.duan@intel.com> References: <20210618085052.564315-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Fri, 18 Jun 2021 04:54:23 -0400 Cc: isaku.yamahata@intel.com, jun.j.tian@intel.com, chenyi.qiang@intel.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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" QEMU will provides 'tdx-guest' object which is used to launch encrypted VMs on Intel platform using TDX feature. The tag can be used to launch a TDX guest. A typical TDX guest launch command line looks like: $QEMU ... \ -object tdx-guest,id=3Dtdx0,debug=3Don \ -machine q35, confidential-guest-support=3Dtdx0,kvm-type=3Dtdx,pic=3Dno,k= ernel_irqchip=3Dsplit Signed-off-by: Zhenzhong Duan --- src/qemu/qemu_command.c | 31 +++++++++++++++ .../.trust-domain-tdx.xml.swo | Bin 0 -> 12288 bytes tests/qemuxml2argvdata/trust-domain-tdx.args | 32 ++++++++++++++++ tests/qemuxml2argvdata/trust-domain-tdx.xml | 36 ++++++++++++++++++ tests/qemuxml2argvtest.c | 3 ++ 5 files changed, 102 insertions(+) create mode 100644 tests/qemuxml2argvdata/.trust-domain-tdx.xml.swo create mode 100644 tests/qemuxml2argvdata/trust-domain-tdx.args create mode 100644 tests/qemuxml2argvdata/trust-domain-tdx.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ea513693f7..1e14c95a49 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6974,6 +6974,9 @@ qemuBuildMachineCommandLine(virCommand *cmd, } } =20 + if (def->tdx) + virBufferAddLit(&buf, ",confidential-guest-support=3Dtdx0,kvm-type= =3Dtdx"); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { if (priv->pflash0) virBufferAsprintf(&buf, ",pflash0=3D%s", priv->pflash0->nodefo= rmat); @@ -9860,6 +9863,31 @@ qemuBuildSEVCommandLine(virDomainObj *vm, virCommand= *cmd, return 0; } =20 +static int +qemuBuildTDXCommandLine(virDomainObj *vm, virCommand *cmd, + virDomainTDXDef *tdx) +{ + g_autoptr(virJSONValue) props =3D NULL; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + qemuDomainObjPrivate *priv =3D vm->privateData; + + if (!tdx) + return 0; + + VIR_DEBUG("policy=3D0x%x", tdx->policy); + + if (qemuMonitorCreateObjectProps(&props, "tdx-guest", "tdx0", + "B:debug", !!(tdx->policy & 1)) < 0) + return -1; + + if (qemuBuildObjectCommandlineFromJSON(&buf, props, priv->qemuCaps) < = 0) + return -1; + + virCommandAddArg(cmd, "-object"); + virCommandAddArgBuffer(cmd, &buf); + return 0; +} + static int qemuBuildVMCoreInfoCommandLine(virCommand *cmd, const virDomainDef *def) @@ -10562,6 +10590,9 @@ qemuBuildCommandLine(virQEMUDriver *driver, if (qemuBuildSEVCommandLine(vm, cmd, def->sev) < 0) return NULL; =20 + if (qemuBuildTDXCommandLine(vm, cmd, def->tdx) < 0) + return NULL; + if (snapshot) virCommandAddArgList(cmd, "-loadvm", snapshot->def->name, NULL); =20 diff --git a/tests/qemuxml2argvdata/.trust-domain-tdx.xml.swo b/tests/qemux= ml2argvdata/.trust-domain-tdx.xml.swo new file mode 100644 index 0000000000000000000000000000000000000000..2835d4a14342651d239657fb153= 1318de3eff8e8 GIT binary patch literal 12288 zcmeI2zmMER6vrpfAcgR=3DOk<8>D&N?f+~!X5xRasc7k;p+lmDH)HSK<#Gt6jChv5^7+kop5J_CeA4M&l^x$ZO7?ei z0@oXa+$f)X`sOEB$#-AALaZ@9g#YW3J#SM{Yt{Pn!_MoEYPCvlW&7EMiA=3D3JV?C>N zwba(1^d0lcdB;9eO}}dD3AYcIl6%g)?VV4hX}E4vFIT%TdLbD;A^{}uoCL0s8<6RD^zpK|g>(P2YgEQVRL6RjKuwh+F)|cy|E?hon@77W8Zb^*3PRYUF}a#rZ)?=3D zb%pbD?u-MJb^~Yt{wZMuHU{tg2wcN+1asd>kJ`qoFg8lr{7DQz^E=3DU=3DpGH z1S~Ef?!6e+2)Q-~HN0ZOcMG64Tq;;t$NhqN!|vZcKHQzlf{g=3D^8j=3DTa3AbV~qr+<9 zuyL`_Er9Aon(t<`Tr8V{1!Me3hPM_=3D(e+7JbD + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + + + + + + + + + 0x0001 + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 7fed871c9e..ac5dc6b40b 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3456,6 +3456,9 @@ mymain(void) DO_TEST_CAPS_VER("launch-security-sev", "2.12.0"); DO_TEST_CAPS_VER("launch-security-sev", "6.0.0"); DO_TEST_CAPS_VER("launch-security-sev-missing-platform-info", "2.12.0"= ); + DO_TEST("trust-domain-tdx", + QEMU_CAPS_KVM, + QEMU_CAPS_TDX_GUEST); =20 DO_TEST_CAPS_LATEST("vhost-user-fs-fd-memory"); DO_TEST_CAPS_LATEST("vhost-user-fs-hugepages"); --=20 2.25.1