From nobody Thu May 15 10:32:19 2025 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.zohomail.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 1512871929136397.4691373157618; Sat, 9 Dec 2017 18:12:09 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6755881226; Sun, 10 Dec 2017 02:12:07 +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 460AF5C7AA; Sun, 10 Dec 2017 02:12:07 +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 106E73FCF9; Sun, 10 Dec 2017 02:12:07 +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 vBA2BrWZ003275 for ; Sat, 9 Dec 2017 21:11:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 56D185DA7B; Sun, 10 Dec 2017 02:11:53 +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 500795D9C9 for ; Sun, 10 Dec 2017 02:11:51 +0000 (UTC) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 93CFB356D6 for ; Sun, 10 Dec 2017 02:11:50 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 1D0B420A62; Sat, 9 Dec 2017 21:11:50 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Sat, 09 Dec 2017 21:11:50 -0500 Received: from localhost.localdomain (ip5b40bfaa.dynamic.kabel-deutschland.de [91.64.191.170]) by mail.messagingengine.com (Postfix) with ESMTPA id 779AD7F7F6; Sat, 9 Dec 2017 21:11:49 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:in-reply-to :message-id:references:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=ycWRWukd4G8MoX9Kxc5vhrJvTqwMm eHkKWznDFD9aKg=; b=Khk+Tx7KqZ2BMRXiTtReo8NLNkQUoKtcXripHjjRC4RCz 3JhnZ87+acYwbeK7lfez5fwKDVepiCJTQCsncwG7AOSQKcOo1aLVLABQtRwl7qwG 3jBM3HUNHb+dh9vyifavuO0/Hy5yqmVhcHr2mN4vIh05UeSth/C7Jj+kBqmE/tjK Y+8jGGULudICDiC/isnsu1xnvxFt9Rznc8KE2uxrV2Tdzfs6lSSQSzn8jNOk0xGY XjfvQIDubFqbmYmqe44CdrA+eOGgqRhyY/cOqsBlyPVYdoFl0HUaH8vCSxK/YzQU 1j3GWs8vHDS4Zrxl3RlVlp0g1NgRPdFVDdp+SbUIQ== X-ME-Sender: From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: libvir-list@redhat.com Date: Sun, 10 Dec 2017 03:10:47 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sun, 10 Dec 2017 02:11:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sun, 10 Dec 2017 02:11:50 +0000 (UTC) for IP:'66.111.4.27' DOMAIN:'out3-smtp.messagingengine.com' HELO:'out3-smtp.messagingengine.com' FROM:'marmarek@invisiblethingslab.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_LOW) 66.111.4.27 out3-smtp.messagingengine.com 66.111.4.27 out3-smtp.messagingengine.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 Subject: [libvirt] [PATCH v3 2/6] libxl: do not enable nested HVM by mere presence of element 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sun, 10 Dec 2017 02:12:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" element may be used to configure other features, like NUMA, or CPUID. Do not enable nested HVM (which is in "preview" state after all) by mere presence of element, but require explicit (or 'svm'). Also, adjust xenconfig driver to appropriately translate to/from nestedhvm=3D1. While at it, adjust xenconfig driver to not override def->cpu if already set elsewhere. This will help with adding cpuid support. --- Changes since v2: - new patch --- src/libxl/libxl_conf.c | 10 ++- src/xenconfig/xen_xl.c | 57 +++++++++---------- tests/libxlxml2domconfigdata/vnuma-hvm.json | 1 +- tests/xlconfigdata/test-fullvirt-nestedhvm.xml | 4 +- 4 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index f39e783..1846109 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -355,6 +355,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, =20 if (caps && def->cpu) { bool hasHwVirt =3D false; + int nested_hvm =3D -1; bool svm =3D false, vmx =3D false; =20 if (def->cpu->mode !=3D (VIR_CPU_MODE_HOST_PASSTHROUGH)) { @@ -379,18 +380,23 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, case VIR_CPU_FEATURE_FORBID: if ((vmx && STREQ(def->cpu->features[i].name, = "vmx")) || (svm && STREQ(def->cpu->features[i].name, = "svm"))) - hasHwVirt =3D false; + nested_hvm =3D 0; break; =20 case VIR_CPU_FEATURE_FORCE: case VIR_CPU_FEATURE_REQUIRE: + if ((vmx && STREQ(def->cpu->features[i].name, = "vmx")) || + (svm && STREQ(def->cpu->features[i].name, = "svm"))) + nested_hvm =3D 1; + break; case VIR_CPU_FEATURE_OPTIONAL: case VIR_CPU_FEATURE_LAST: break; } } } - libxl_defbool_set(&b_info->u.hvm.nested_hvm, hasHwVirt); + if (hasHwVirt && nested_hvm !=3D -1) + libxl_defbool_set(&b_info->u.hvm.nested_hvm, nested_hvm); } =20 if (def->nsounds > 0) { diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index 9e239a7..317c7a0 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -170,16 +170,7 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, vir= CapsPtr caps) if (xenConfigGetBool(conf, "nestedhvm", &val, -1) < 0) return -1; =20 - if (val =3D=3D 1) { - virCPUDefPtr cpu; - - if (VIR_ALLOC(cpu) < 0) - return -1; - - cpu->mode =3D VIR_CPU_MODE_HOST_PASSTHROUGH; - cpu->type =3D VIR_CPU_TYPE_GUEST; - def->cpu =3D cpu; - } else if (val =3D=3D 0) { + if (val !=3D -1) { const char *vtfeature =3D NULL; =20 if (caps && caps->host.cpu && ARCH_IS_X86(def->os.arch)) { @@ -190,26 +181,29 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, vi= rCapsPtr caps) } =20 if (vtfeature) { - virCPUDefPtr cpu; - - if (VIR_ALLOC(cpu) < 0) - return -1; + if (!def->cpu) { + virCPUDefPtr cpu; + if (VIR_ALLOC(cpu) < 0) + return -1; =20 - if (VIR_ALLOC(cpu->features) < 0) { - VIR_FREE(cpu); - return -1; + cpu->mode =3D VIR_CPU_MODE_HOST_PASSTHROUGH; + cpu->type =3D VIR_CPU_TYPE_GUEST; + cpu->nfeatures =3D 0; + cpu->nfeatures_max =3D 0; + def->cpu =3D cpu; } =20 - if (VIR_STRDUP(cpu->features->name, vtfeature) < 0) { - VIR_FREE(cpu->features); - VIR_FREE(cpu); - return -1; + if (val =3D=3D 0) { + if (virCPUDefAddFeature(def->cpu, + vtfeature, + VIR_CPU_FEATURE_DISABLE) < 0) + return -1; + } else if (val =3D=3D 1) { + if (virCPUDefAddFeature(def->cpu, + vtfeature, + VIR_CPU_FEATURE_FORCE) < 0) + 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 { @@ -1157,6 +1151,7 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def) if (def->cpu && def->cpu->mode =3D=3D VIR_CPU_MODE_HOST_PASSTHROUGH) { bool hasHwVirt =3D true; + int nestedhvm =3D -1; =20 if (def->cpu->nfeatures) { for (i =3D 0; i < def->cpu->nfeatures; i++) { @@ -1166,11 +1161,15 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def) case VIR_CPU_FEATURE_FORBID: if (STREQ(def->cpu->features[i].name, "vmx") || STREQ(def->cpu->features[i].name, "svm")) - hasHwVirt =3D false; + nestedhvm =3D 0; break; =20 case VIR_CPU_FEATURE_FORCE: case VIR_CPU_FEATURE_REQUIRE: + if (STREQ(def->cpu->features[i].name, "vmx") || + STREQ(def->cpu->features[i].name, "svm")) + nestedhvm =3D 1; + break; case VIR_CPU_FEATURE_OPTIONAL: case VIR_CPU_FEATURE_LAST: break; @@ -1178,7 +1177,9 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def) } } =20 - if (xenConfigSetInt(conf, "nestedhvm", hasHwVirt) < 0) + if (hasHwVirt && + nestedhvm !=3D -1 && + xenConfigSetInt(conf, "nestedhvm", nestedhvm) < 0) return -1; } =20 diff --git a/tests/libxlxml2domconfigdata/vnuma-hvm.json b/tests/libxlxml2d= omconfigdata/vnuma-hvm.json index 3a5071e..2437a84 100644 --- a/tests/libxlxml2domconfigdata/vnuma-hvm.json +++ b/tests/libxlxml2domconfigdata/vnuma-hvm.json @@ -113,7 +113,6 @@ "pae": "True", "apic": "True", "acpi": "True", - "nested_hvm": "True", "vga": { "kind": "cirrus" }, diff --git a/tests/xlconfigdata/test-fullvirt-nestedhvm.xml b/tests/xlconfi= gdata/test-fullvirt-nestedhvm.xml index 8c02e7a..8a55bea 100644 --- a/tests/xlconfigdata/test-fullvirt-nestedhvm.xml +++ b/tests/xlconfigdata/test-fullvirt-nestedhvm.xml @@ -14,7 +14,9 @@ - + + + destroy restart --=20 git-series 0.9.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list