From nobody Sun Feb 8 14:12:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612879205; cv=none; d=zohomail.com; s=zohoarc; b=f5vkwyoKtM4jTnsAnpfCFw6Kp9BTqntOHtZB6LSHS+1c7eHzOg1VnMUfBs/2P711WPes1vNb7zUvPJX3NB8lnpQbIm5p4AYvCDEcydomDd+CZ5OpQyP+5BhUFax0MsRe3ettUk8UrjON/xugGu6zVC1cOWOJI63QFVrfTBM/fgM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612879205; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r/SztCOql1ZuuaB35Bf8q08r5pw8aLSe4KSfAOSQ1Ss=; b=mZZS8tVR2IsCj+h/+zgcxLNj9CPv9cy1x30Rbkq2NB3bewItjX4m4+xV0YbhoEvoDxXJkxFsg2kGItAnuP5kbqc3uXR65DCnv0VHBJmnDbcpz7DJzyoV3evIJLZ7vNp+WI4NJ83RPvoLE7T0xH+TvluMVvZBR+Nxf4AallTDPxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612879205454765.1222351176734; Tue, 9 Feb 2021 06:00:05 -0800 (PST) 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-120-jpCDLIhPM7yCyteVTu1MNw-1; Tue, 09 Feb 2021 08:59:24 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C2F17100CCC5; Tue, 9 Feb 2021 13:59:17 +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 9D9A25D745; Tue, 9 Feb 2021 13:59:17 +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 5FBA918095CB; Tue, 9 Feb 2021 13:59:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 119Dx9Zl024557 for ; Tue, 9 Feb 2021 08:59:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id D3E286064B; Tue, 9 Feb 2021 13:59:09 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-66.ams2.redhat.com [10.36.115.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id D744418F15; Tue, 9 Feb 2021 13:59:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612879203; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=r/SztCOql1ZuuaB35Bf8q08r5pw8aLSe4KSfAOSQ1Ss=; b=FQfyi77HBux732lw7oOet/POKK0y+CjVYNbxdtTThAWT0XpKhJTrVpnyoIoDVZUCRCJt1h PSVOIgGBbe4iM2JVMICL76SHB9d9P6515HrExP0YEwFhjr7kg7GsYeiOy9yzyXH4TCRCRA mt9dD5X3ZQ+zg11k/VqzD0VyK9gk+fw= X-MC-Unique: jpCDLIhPM7yCyteVTu1MNw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/5] conf: define a new "maximum" CPU mode Date: Tue, 9 Feb 2021 13:58:57 +0000 Message-Id: <20210209135901.1225861-2-berrange@redhat.com> In-Reply-To: <20210209135901.1225861-1-berrange@redhat.com> References: <20210209135901.1225861-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Jiri Denemark 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.15 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) For hardware virtualization this is functionally identical to the existing host-passthrough mode so the same caveats apply. For emulated guest this exposes the maximum featureset supported by the emulator. Note that despite being emulated this is not guaranteed to be migration safe, especially if different emulator software versions are used on each host. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- docs/formatdomain.rst | 24 ++++++++++++++++++++++++ src/conf/cpu_conf.c | 13 +++++++++---- src/conf/cpu_conf.h | 1 + src/cpu/cpu.c | 1 + src/qemu/qemu_capabilities.c | 1 + src/qemu/qemu_command.c | 1 + src/qemu/qemu_domain.c | 1 + src/qemu/qemu_validate.c | 1 + 8 files changed, 39 insertions(+), 4 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 0f78aa3a8c..976770bdb6 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -1226,6 +1226,13 @@ following collection of elements. :since:`Since 0.7.= 5` ... =20 +:: + + + + + ... + In case no restrictions need to be put on CPU model and its features, a si= mpler ``cpu`` element can be used. :since:`Since 0.7.6` =20 @@ -1351,6 +1358,18 @@ In case no restrictions need to be put on CPU model = and its features, a simpler another host safer: even with ``migratable=3D'on'`` migration will be dangerous unless both hosts are identical as described above. =20 + ``maximum`` + When running a guest with hardware virtualization this CPU model is + functionally identical to ``host-passthrough``, so refer to the docs + above. + + When running a guest with CPU emulation, this CPU model will enable + the maximum set of features that the emulation engine is able to sup= port. + Note that even with ``migratable=3D'on'`` migration will be dangerous + unless both hosts are running identical versions of the emulation co= de. + + :since:`Since 7.1.0` with the QEMU driver. + Both ``host-model`` and ``host-passthrough`` modes make sense when a do= main can run directly on the host CPUs (for example, domains with type ``kvm= ``). The actual host CPU is irrelevant for domains with emulated virtual CPUs @@ -1358,6 +1377,11 @@ In case no restrictions need to be put on CPU model = and its features, a simpler ``host-model`` may be implemented even for domains running on emulated = CPUs in which case the best CPU the hypervisor is able to emulate may be used rather then trying to mimic the host CPU model. + + If an application does not care about a specific CPU, just wants the + best featureset without a need for migration compatibility, the + ``maximum`` model is a good choice on hypervisors where it is available. + ``model`` The content of the ``model`` element specifies CPU model requested by t= he guest. The list of available CPU models and their definition can be fou= nd in diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index f98b0a0eb3..eb4bfbbcfa 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -44,6 +44,7 @@ VIR_ENUM_IMPL(virCPUMode, "custom", "host-model", "host-passthrough", + "maximum", ); =20 VIR_ENUM_IMPL(virCPUMatch, @@ -402,10 +403,11 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, if ((migratable =3D virXMLPropString(ctxt->node, "migratable"))) { int val; =20 - if (def->mode !=3D VIR_CPU_MODE_HOST_PASSTHROUGH) { + if (def->mode !=3D VIR_CPU_MODE_HOST_PASSTHROUGH && + def->mode !=3D VIR_CPU_MODE_MAXIMUM) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Attribute migratable is only allowed for " - "host-passthrough CPU")); + "'host-passthrough' / 'maximum' CPU mode")); return -1; } =20 @@ -500,7 +502,8 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, } =20 if (def->type =3D=3D VIR_CPU_TYPE_GUEST && - def->mode !=3D VIR_CPU_MODE_HOST_PASSTHROUGH) { + def->mode !=3D VIR_CPU_MODE_HOST_PASSTHROUGH && + def->mode !=3D VIR_CPU_MODE_MAXIMUM) { =20 if ((fallback =3D virXPathString("string(./model[1]/@fallback)", c= txt))) { if ((def->fallback =3D virCPUFallbackTypeFromString(fallback))= < 0) { @@ -727,7 +730,9 @@ virCPUDefFormatBufFull(virBufferPtr buf, virCPUCheckTypeToString(def->check)); } =20 - if (def->mode =3D=3D VIR_CPU_MODE_HOST_PASSTHROUGH && def->migrata= ble) { + if ((def->mode =3D=3D VIR_CPU_MODE_HOST_PASSTHROUGH || + def->mode =3D=3D VIR_CPU_MODE_MAXIMUM) && + def->migratable) { virBufferAsprintf(&attributeBuf, " migratable=3D'%s'", virTristateSwitchTypeToString(def->migratabl= e)); } diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index b744b06c2d..7ab198d370 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -44,6 +44,7 @@ typedef enum { VIR_CPU_MODE_CUSTOM, VIR_CPU_MODE_HOST_MODEL, VIR_CPU_MODE_HOST_PASSTHROUGH, + VIR_CPU_MODE_MAXIMUM, =20 VIR_CPU_MODE_LAST } virCPUMode; diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 44094bd0df..6ff88d6a9f 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -563,6 +563,7 @@ virCPUUpdate(virArch arch, =20 switch ((virCPUMode) guest->mode) { case VIR_CPU_MODE_HOST_PASSTHROUGH: + case VIR_CPU_MODE_MAXIMUM: return 0; =20 case VIR_CPU_MODE_HOST_MODEL: diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index d41b4a4753..d0378f94bc 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2334,6 +2334,7 @@ virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps, cpus =3D virQEMUCapsGetAccel(qemuCaps, type)->cpuModels; return cpus && cpus->ncpus > 0; =20 + case VIR_CPU_MODE_MAXIMUM: case VIR_CPU_MODE_LAST: break; } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 92036d26c0..059563d92f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6356,6 +6356,7 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver, virBufferAdd(buf, cpu->model, -1); break; =20 + case VIR_CPU_MODE_MAXIMUM: case VIR_CPU_MODE_LAST: break; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0f09e321fb..d89aea340b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4151,6 +4151,7 @@ qemuDomainDefCPUPostParse(virDomainDefPtr def, def->cpu->check =3D VIR_CPU_CHECK_PARTIAL; break; =20 + case VIR_CPU_MODE_MAXIMUM: case VIR_CPU_MODE_LAST: break; } diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 78e80b7919..bf4ac19104 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -396,6 +396,7 @@ qemuValidateDomainDefCpu(virQEMUDriverPtr driver, * CUSTOM. */ break; + case VIR_CPU_MODE_MAXIMUM: case VIR_CPU_MODE_CUSTOM: case VIR_CPU_MODE_LAST: break; --=20 2.29.2