From nobody Sat Feb 7 04:40:26 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 1625152194597437.01517613606063; Thu, 1 Jul 2021 08:09:54 -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-465-w8x6c5zsM8S2IDyhCOhWCQ-1; Thu, 01 Jul 2021 11:09:51 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9E7CA804153; Thu, 1 Jul 2021 15:09:45 +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 A1E2E10023AB; Thu, 1 Jul 2021 15:09:43 +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 0313B4EA2A; Thu, 1 Jul 2021 15:09:43 +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 161CDmqH022559 for ; Thu, 1 Jul 2021 08:13:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id EF921103CCB; Thu, 1 Jul 2021 12:13:47 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E8A33103CC7 for ; Thu, 1 Jul 2021 12:13:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (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 2FFC6866DFC for ; Thu, 1 Jul 2021 12:13:44 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-430--IC7OgPqOfCktV9NKGgAEQ-3; Thu, 01 Jul 2021 08:13:42 -0400 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2021 05:12:38 -0700 Received: from nhsgx.sh.intel.com ([10.239.36.138]) by orsmga005.jf.intel.com with ESMTP; 01 Jul 2021 05:12:36 -0700 X-MC-Unique: w8x6c5zsM8S2IDyhCOhWCQ-1 X-MC-Unique: -IC7OgPqOfCktV9NKGgAEQ-3 X-IronPort-AV: E=McAfee;i="6200,9189,10031"; a="195812175" X-IronPort-AV: E=Sophos;i="5.83,314,1616482800"; d="scan'208";a="195812175" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,314,1616482800"; d="scan'208";a="626344962" From: Haibin Huang To: libvir-list@redhat.com, haibin.huang@intel.com, jian-feng.ding@intel.com, lin.a.yang@intel.com, lianhao.lu@intel.com Subject: [libvirt][PATCH v4 2/4] qemu: Add command-line to generate SGX EPC memory backend Date: Thu, 1 Jul 2021 20:10:27 +0800 Message-Id: <20210701121029.10837-3-haibin.huang@intel.com> In-Reply-To: <20210701121029.10837-1-haibin.huang@intel.com> References: <20210701121029.10837-1-haibin.huang@intel.com> 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.79 on 10.11.54.5 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Thu, 01 Jul 2021 11:06:50 -0400 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.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Lin Yang According to the result parsing from xml, add the argument of SGX EPC memory backend into QEMU command line: -object memory-backend-epc,id=3Dmem1,size=3DK,prealloc \ -sgx-epc id=3Depc1,memdev=3Dmem1 --- src/qemu/qemu_command.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 01812cd39b..2c3785886c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9869,6 +9869,27 @@ qemuBuildVsockCommandLine(virCommandPtr cmd, } =20 =20 +static int +qemuBuildSGXCommandLine(virCommandPtr cmd, virDomainSGXDefPtr sgx) +{ + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + + if (!sgx) + return 0; + + VIR_DEBUG("sgx->epc_size=3D%lluKiB", sgx->epc_size); + + virBufferAsprintf(&buf, "memory-backend-epc,id=3Dmem1,size=3D%lluK,pre= alloc", sgx->epc_size); + virCommandAddArg(cmd, "-object"); + virCommandAddArgBuffer(cmd, &buf); + + virCommandAddArg(cmd, "-sgx-epc"); + virCommandAddArg(cmd, "id=3Depc1,memdev=3Dmem1"); + + return 0; +} + + /* * Constructs a argv suitable for launching qemu with config defined * for a given virtual machine. @@ -10154,6 +10175,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, cfg->logTimestamp) virCommandAddArgList(cmd, "-msg", "timestamp=3Don", NULL); =20 + if (qemuBuildSGXCommandLine(cmd, def->sgx) < 0) + return NULL; + return g_steal_pointer(&cmd); } =20 --=20 2.17.1