From nobody Wed Feb 11 10:17:15 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 1490389500400876.4912681514518; Fri, 24 Mar 2017 14:05:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8FF080515; Fri, 24 Mar 2017 21:04:59 +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 8B78D171F5; Fri, 24 Mar 2017 21:04:59 +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 463F518523CC; Fri, 24 Mar 2017 21:04:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2OL2xbp000774 for ; Fri, 24 Mar 2017 17:02:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2E69B171F2; Fri, 24 Mar 2017 21:02:59 +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 27E485C8A3 for ; Fri, 24 Mar 2017 21:02:57 +0000 (UTC) Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) (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 2D04D3DBC7 for ; Fri, 24 Mar 2017 21:02:56 +0000 (UTC) Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v2OL2r84016998 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Mar 2017 21:02:53 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v2OL2r5L027698 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 24 Mar 2017 21:02:53 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v2OL2p5L019415; Fri, 24 Mar 2017 21:02:52 GMT Received: from nina.dynamic.ziggo.nl (/10.175.181.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 24 Mar 2017 14:02:51 -0700 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B8FF080515 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=oracle.com Authentication-Results: ext-mx03.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 B8FF080515 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2D04D3DBC7 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 2D04D3DBC7 From: Wim Ten Have To: Libvirt Development List Date: Fri, 24 Mar 2017 22:02:35 +0100 Message-Id: <20170324210236.17019-3-wim.ten.have@oracle.com> In-Reply-To: <20170324210236.17019-1-wim.ten.have@oracle.com> References: <20170324210236.17019-1-wim.ten.have@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] 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]); Fri, 24 Mar 2017 21:02:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 24 Mar 2017 21:02:56 +0000 (UTC) for IP:'141.146.126.69' DOMAIN:'aserp1040.oracle.com' HELO:'aserp1040.oracle.com' FROM:'wim.ten.have@oracle.com' RCPT:'' X-RedHat-Spam-Score: -104.401 (BAYES_50, DCC_REPUT_13_19, RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY, USER_IN_WHITELIST) 141.146.126.69 aserp1040.oracle.com 141.146.126.69 aserp1040.oracle.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Joao Martins , Wim ten Have Subject: [libvirt] [PATCH v2 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 24 Mar 2017 21:05:00 +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 --- src/xenconfig/xen_xl.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 67 insertions(+) diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index 74f68b3..d3797b8 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -106,6 +106,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 +165,47 @@ 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) { + if (VIR_ALLOC_N(cpu->features, 2) < 0) + goto cleanup; + + /* + * Below is pointless in real world but for purpose + * of testing let's check features depth holding at + * least multiple elements and also check if both + * vmx|svm are understood. + */ + cpu->features[0].policy =3D VIR_CPU_FEATURE_DISABLE; + if (VIR_STRDUP(cpu->features[0].name, "vmx") < 0) + goto cleanup; + cpu->features[1].policy =3D VIR_CPU_FEATURE_DISABLE; + if (VIR_STRDUP(cpu->features[1].name, "svm") < 0) + goto cleanup; + + cpu->nfeatures =3D cpu->nfeatures_max =3D 2; + } + cpu->mode =3D VIR_CPU_MODE_HOST_PASSTHROUGH; + cpu->type =3D VIR_CPU_TYPE_GUEST; + def->cpu =3D cpu; + cpu =3D NULL; + cleanup: + if (cpu) { + VIR_FREE(cpu->features); + VIR_FREE(cpu); + return -1; + } + } + } else { if (xenConfigCopyStringOpt(conf, "bootloader", &def->os.bootloader= ) < 0) return -1; @@ -897,6 +939,31 @@ 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; + + default: + 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