From nobody Wed Feb 11 07:09:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1492604290865333.17029251724625; Wed, 19 Apr 2017 05:18:10 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id D89443B72D; Wed, 19 Apr 2017 12:18:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE78F7DB69; Wed, 19 Apr 2017 12:18:08 +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 61CBE5ED65; Wed, 19 Apr 2017 12:18:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3JCHkIv004856 for ; Wed, 19 Apr 2017 08:17:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 287427DB75; Wed, 19 Apr 2017 12:17:46 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 20C557DB74 for ; Wed, 19 Apr 2017 12:17:44 +0000 (UTC) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3D86C3D97E for ; Wed, 19 Apr 2017 12:17:43 +0000 (UTC) Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v3JCHgcV025157 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Apr 2017 12:17:42 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v3JCHgqo016260 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Apr 2017 12:17:42 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v3JCHgla014346; Wed, 19 Apr 2017 12:17:42 GMT Received: from nina.dynamic.ziggo.nl (/10.175.165.165) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 19 Apr 2017 05:17:41 -0700 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D89443B72D Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=oracle.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D89443B72D DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3D86C3D97E Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=oracle.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=wim.ten.have@oracle.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3D86C3D97E From: Wim Ten Have To: Libvirt Development List Date: Wed, 19 Apr 2017 14:17:16 +0200 Message-Id: <20170419121717.22223-3-wim.ten.have@oracle.com> In-Reply-To: <20170419121717.22223-1-wim.ten.have@oracle.com> References: <20170419121717.22223-1-wim.ten.have@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 19 Apr 2017 12:17:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 19 Apr 2017 12:17:43 +0000 (UTC) for IP:'156.151.31.81' DOMAIN:'userp1040.oracle.com' HELO:'userp1040.oracle.com' FROM:'wim.ten.have@oracle.com' RCPT:'' X-RedHat-Spam-Score: -101.621 (BAYES_50, DCC_REPUT_13_19, RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY, USER_IN_WHITELIST) 156.151.31.81 userp1040.oracle.com 156.151.31.81 userp1040.oracle.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Joao Martins , Wim ten Have Subject: [libvirt] [PATCH v3 2/3] xenconfig: add conversions for xen-xl 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 19 Apr 2017 12:18:09 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Wim ten Have Per xen-xl conversions from and to native under host-passthrough mode we take care for Xen (nestedhvm =3D mode) applied and inherited settings generating or processing correct feature policy: [On Intel (VT-x) architectures] or [On AMD (AMD-V) architectures] It will then generate (or parse) for nestedhvm=3D1 in/from xl format. Signed-off-by: Joao Martins Signed-off-by: Wim ten Have --- cfg.mk | 2 +- src/xenconfig/xen_xl.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/cfg.mk b/cfg.mk index 69e3f3a..32c3725 100644 --- a/cfg.mk +++ b/cfg.mk @@ -777,7 +777,7 @@ sc_prohibit_cross_inclusion: locking/) safe=3D"($$dir|util|conf|rpc)";; \ cpu/| network/| node_device/| rpc/| security/| storage/) \ safe=3D"($$dir|util|conf|storage)";; \ - xenapi/ | xenconfig/ ) safe=3D"($$dir|util|conf|xen)";; \ + xenapi/ | xenconfig/ ) safe=3D"($$dir|util|conf|xen|cpu)";; \ *) safe=3D"($$dir|$(mid_dirs)|util)";; \ esac; \ in_vc_files=3D"^src/$$dir" \ diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index 74f68b3..62af8b8 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -34,6 +34,7 @@ #include "virstoragefile.h" #include "xen_xl.h" #include "libxl_capabilities.h" +#include "cpu/cpu.h" =20 #define VIR_FROM_THIS VIR_FROM_XENXL =20 @@ -106,6 +107,7 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virC= apsPtr caps) if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { const char *bios; const char *boot; + int val =3D 0; =20 if (xenConfigGetString(conf, "bios", &bios, NULL) < 0) return -1; @@ -164,6 +166,40 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, vir= CapsPtr caps) } def->os.nBootDevs++; } + + if (xenConfigGetBool(conf, "nestedhvm", &val, -1) < 0) + return -1; + + if (val !=3D -1) { + virCPUDefPtr cpu =3D NULL; + + if (VIR_ALLOC(cpu) < 0) + return -1; + + if (val =3D=3D 0) { + bool isVTx =3D true; + + if (VIR_ALLOC(cpu->features) < 0) { + VIR_FREE(cpu); + return -1; + } + + if (caps && caps->host.cpu && ARCH_IS_X86(def->os.arch)) + isVTx =3D virCPUCheckFeature(caps->host.arch, caps->ho= st.cpu, "vmx"); + + if (VIR_STRDUP(cpu->features->name, isVTx ? "vmx" : "svm")= < 0) { + VIR_FREE(cpu->features); + VIR_FREE(cpu); + return -1; + } + cpu->features->policy =3D VIR_CPU_FEATURE_DISABLE; + cpu->nfeatures =3D cpu->nfeatures_max =3D 1; + } + cpu->mode =3D VIR_CPU_MODE_HOST_PASSTHROUGH; + cpu->type =3D VIR_CPU_TYPE_GUEST; + def->cpu =3D cpu; + } + } else { if (xenConfigCopyStringOpt(conf, "bootloader", &def->os.bootloader= ) < 0) return -1; @@ -897,6 +933,34 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def) if (xenConfigSetString(conf, "boot", boot) < 0) return -1; =20 + if (def->cpu && + def->cpu->mode =3D=3D VIR_CPU_MODE_HOST_PASSTHROUGH) { + bool hasHwVirt =3D true; + + if (def->cpu->nfeatures) { + for (i =3D 0; i < def->cpu->nfeatures; i++) { + + switch (def->cpu->features[i].policy) { + case VIR_CPU_FEATURE_DISABLE: + case VIR_CPU_FEATURE_FORBID: + if (STREQ(def->cpu->features[i].name, "vmx") || + STREQ(def->cpu->features[i].name, "svm")) + hasHwVirt =3D false; + break; + + case VIR_CPU_FEATURE_FORCE: + case VIR_CPU_FEATURE_REQUIRE: + case VIR_CPU_FEATURE_OPTIONAL: + case VIR_CPU_FEATURE_LAST: + break; + } + } + } + + if (xenConfigSetInt(conf, "nestedhvm", hasHwVirt) < 0) + return -1; + } + /* XXX floppy disks */ } else { if (def->os.bootloader && --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list