From nobody Tue Dec 16 21:05:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1591403065; cv=none; d=zohomail.com; s=zohoarc; b=kYi7Eghhsk/0ZtOeZ7UQqn3Cb1207u4Xcw9/YYZgvJEtf1Rr2uhGUyrHso+E0l4krMhKSkuvLkia6+4l6M/YDk1uhaEKLUeo2V4kQdgdBt/7nmILGq2hhA4BulTZKnlBjof9rI9dn+K+o5VnagOIJlgKNcSkL7IEYl6fy1+Ls3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591403065; h=Content-Type:Content-Transfer-Encoding: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=GKYGkdRHAvJNqL+I7ABTIwXY768coeyrnICKe9IsG84=; b=e7cPwsyqtxTz57bT1SkW1brLcLlmlD1Cloc0EJLofvQBmScSvdMhn9Y0TPTpOa9dHFjmuYLZdhWptOIxTqmC1NW6vwVhK4bcn1fXvOG4RN00U3DYcLKHG2yR17zA1FClUug/E6k2w+PaiUCHjWGNk7ZDd88BfvFZci8wgEMLrIY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1591403065352685.8845996522708; Fri, 5 Jun 2020 17:24:25 -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-266-_wISZifRPCW-EyQEYFT-3w-1; Fri, 05 Jun 2020 20:24:21 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B05E61009616; Sat, 6 Jun 2020 00:24:16 +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 92DBB61493; Sat, 6 Jun 2020 00:24:16 +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 603BA18045C3; Sat, 6 Jun 2020 00:24:16 +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 055IWIxJ030083 for ; Fri, 5 Jun 2020 14:32:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 67FE45C296; Fri, 5 Jun 2020 18:32:18 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.40.193.140]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 111685C3FD for ; Fri, 5 Jun 2020 18:32:18 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id D25D6245141; Fri, 5 Jun 2020 20:31:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591403064; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=GKYGkdRHAvJNqL+I7ABTIwXY768coeyrnICKe9IsG84=; b=N4H1qp8FUz4Wlh1XL92L/rUBEqCHdYlcDHEqRDTiwaSTIBWLowXM32hEiPAWO/90VQ4pn4 CKm1Tdke1sdi9kRYSr2yxfEFYpYZfJhuM5qunOXq8k0RR06Q8ypFbx3KRL1B+rHUoT6bLG QgcYXUDk2FgNeiaGsanDtOR8VauLsK0= X-MC-Unique: _wISZifRPCW-EyQEYFT-3w-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 5/9] conf: Introduce migratable attribute for the element Date: Fri, 5 Jun 2020 20:31:27 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The attribute is only allowed for host-passthrough CPUs and it can be used to request only migratable or all supported features to be enabled in the virtual CPU. Signed-off-by: Jiri Denemark --- docs/formatdomain.html.in | 14 ++++++++++++-- docs/schemas/domaincommon.rng | 5 +++++ src/conf/cpu_conf.c | 27 +++++++++++++++++++++++++++ src/conf/cpu_conf.h | 1 + 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 33cec1e6dd..6ebf19ae57 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1490,7 +1490,7 @@ ... =20
-<cpu mode=3D'host-passthrough'>
+<cpu mode=3D'host-passthrough' migratable=3D'off'>
   <cache mode=3D'passthrough'/>
   <feature policy=3D'disable' name=3D'lahf_lm'/>
 ...
@@ -1639,7 +1639,17 @@ using host-passthrough is dangerous if the source and destinatio= n hosts are not identical in both hardware, QEMU version, microcode vers= ion and configuration. If such a migration is attempted then the gue= st may - hang or crash upon resuming execution on the destination host. + hang or crash upon resuming execution on the destination host. + Depending on hypervisor version the virtual CPU may or may not + contain features which may block migration even to an identical = host. + Since 6.5.0 optional + migratable attribute may be used to explicitly requ= est + such features to be removed from (on) or kept in + (off) the virtual CPU. This attribute does not make + migration to another host safer: even with + migratable=3D'on' migration will be dangerous unles= s both + hosts are identical as described above. + =20 Both host-model and host-passthrough mod= es diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 6727cd743b..19242a9a32 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5469,6 +5469,11 @@ + + + + + diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 25648a946c..b40737e407 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -243,6 +243,7 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu) copy->cores =3D cpu->cores; copy->threads =3D cpu->threads; copy->arch =3D cpu->arch; + copy->migratable =3D cpu->migratable; =20 if (cpu->cache) { if (VIR_ALLOC(copy->cache) < 0) @@ -333,6 +334,7 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, g_autofree char *fallback =3D NULL; g_autofree char *vendor_id =3D NULL; g_autofree char *tscScaling =3D NULL; + g_autofree char *migratable =3D NULL; virHostCPUTscInfoPtr tsc =3D NULL; =20 *cpu =3D NULL; @@ -386,6 +388,26 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, def->mode =3D VIR_CPU_MODE_CUSTOM; } =20 + if ((migratable =3D virXMLPropString(ctxt->node, "migratable"))) { + int val; + + if (def->mode !=3D VIR_CPU_MODE_HOST_PASSTHROUGH) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Attribute migratable is only allowed for " + "host-passthrough CPU")); + return -1; + } + + if ((val =3D virTristateSwitchTypeFromString(migratable)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Invalid value in migratable attribute: '%s'"= ), + migratable); + return -1; + } + + def->migratable =3D val; + } + if (def->type =3D=3D VIR_CPU_TYPE_GUEST) { g_autofree char *match =3D virXMLPropString(ctxt->node, "match"); g_autofree char *check =3D NULL; @@ -698,6 +720,11 @@ virCPUDefFormatBufFull(virBufferPtr buf, virBufferAsprintf(&attributeBuf, " check=3D'%s'", virCPUCheckTypeToString(def->check)); } + + if (def->mode =3D=3D VIR_CPU_MODE_HOST_PASSTHROUGH && def->migrata= ble) { + virBufferAsprintf(&attributeBuf, " migratable=3D'%s'", + virTristateSwitchTypeToString(def->migratabl= e)); + } } =20 /* Format children */ diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index a95d56d017..24c51e3a63 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -141,6 +141,7 @@ struct _virCPUDef { virCPUFeatureDefPtr features; virCPUCacheDefPtr cache; virHostCPUTscInfoPtr tsc; + virTristateSwitch migratable; /* for host-passthrough mode */ }; =20 virCPUDefPtr virCPUDefNew(void); --=20 2.27.0