From nobody Mon Apr 29 00:55:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1677674090; cv=none; d=zohomail.com; s=zohoarc; b=Ls0lQEYZFjS8hB7VzLJhbX81kHd//mtZD5DCJnhsxIdxgTSa6zrOwCOiifHV+hxRvZROwzqrPpTStqFjC2nNMcPDMxlqRjznpf1u9jbbHDv6F4eRJXhutUKNdYvFisfv4rnAU3E4WEkBxOJq1BPtibCcG7EgnXceiYPIn84c98o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677674090; 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=SP0ZIEJ4ezgPN7+xiZyMWUsMmMRipVdDS9zelLo9RrI=; b=CRFubuukru2/I8a+re9k4nXz5953bl4K2LKC49XhQ9qFNolokE1HUcSmMHSKTl2dtZ0GRXbS6u0uouD2ljUGeKpBPrP8eVyVFIagABG4BUwddBpnfDn2P7XGy5IaF5IwVd+3ui+d5uEkurwM0GTUZcJl5U+Cf/XltNuDEB0woxs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1677674090432602.843827127737; Wed, 1 Mar 2023 04:34:50 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-342-VeFvgDuKMP2M_-T-gdgHTw-1; Wed, 01 Mar 2023 07:34:47 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A7EFF1C08786; Wed, 1 Mar 2023 12:34:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21D4B2166B26; Wed, 1 Mar 2023 12:34:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F33901946A72; Wed, 1 Mar 2023 12:34:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 535AD19465B9 for ; Wed, 1 Mar 2023 12:34:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 359C9492B01; Wed, 1 Mar 2023 12:34:39 +0000 (UTC) Received: from fedora.. (unknown [10.43.2.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0C7F492B00 for ; Wed, 1 Mar 2023 12:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677674089; 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=SP0ZIEJ4ezgPN7+xiZyMWUsMmMRipVdDS9zelLo9RrI=; b=N1jOk3DrNJTUbpna4kIndSBQK+ZYw/qPREKDeaUzFfeHQCj5yv8oxpQocqRV9ReabxLh7K qk4TLDeIMzP0saBwVtCf0N/uUd4w6/ifUGHbZiYMcwHSmY9k+kZDpt7KyKBml1s2ZoQk0j YJYJJ1yVK9JzfWeDI6m0ZpdrBWKvVfA= X-MC-Unique: VeFvgDuKMP2M_-T-gdgHTw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/4] conf: cpu: add limit for maxphysaddr Date: Wed, 1 Mar 2023 13:34:32 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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) X-ZM-MESSAGEID: 1677674091959100001 Add a limit attribute to restrict the maximum physical address bits that would be used for the guest CPU: https://gitlab.com/libvirt/libvirt/-/issues/450 https://bugzilla.redhat.com/show_bug.cgi?id=3D2171860 Signed-off-by: J=C3=A1n Tomko --- docs/formatdomain.rst | 7 ++++- src/conf/cpu_conf.c | 7 +++++ src/conf/cpu_conf.h | 1 + src/conf/schemas/cputypes.rng | 5 +++ .../qemuxml2argvdata/cpu-phys-bits-limit.xml | 20 ++++++++++++ .../cpu-phys-bits-limit.x86_64-latest.xml | 31 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 ++ 7 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/cpu-phys-bits-limit.xml create mode 100644 tests/qemuxml2xmloutdata/cpu-phys-bits-limit.x86_64-lat= est.xml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 638768c18d..29854037a9 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -1353,7 +1353,7 @@ following collection of elements. :since:`Since 0.7.5` =20 - + ... =20 @@ -1623,6 +1623,11 @@ In case no restrictions need to be put on CPU model = and its features, a simpler The ``bits`` attribute is mandatory if the ``mode`` attribute is set= to ``emulate`` and specifies the virtual CPU address size in bits. =20 + ``limit`` + The ``limit`` attribute can be used to restrict the maximum value of + address bits for ``passthrough`` mode, i.e. in case the host CPU repo= rts + more bits than that, ``limit`` is used. :since:`Since 9.2.0` + Guest NUMA topology can be specified using the ``numa`` element. :since:`S= ince 0.9.8` =20 diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index a33f39ef31..bbe454ed10 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -680,6 +680,11 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, VIR_XML_PROP_NONNEGATIVE, &def->addr->bits, -1) < 0) return -1; + + if (virXMLPropInt(maxphysaddrNode, "limit", 10, + VIR_XML_PROP_NONNEGATIVE, + &def->addr->limit, -1) < 0) + return -1; } =20 *cpu =3D g_steal_pointer(&def); @@ -855,6 +860,8 @@ virCPUDefFormatBuf(virBuffer *buf, virCPUMaxPhysAddrModeTypeToString(def->addr->mod= e)); if (def->addr->bits !=3D -1) virBufferAsprintf(buf, " bits=3D'%d'", def->addr->bits); + if (def->addr->limit !=3D -1) + virBufferAsprintf(buf, " limit=3D'%d'", def->addr->limit); virBufferAddLit(buf, "/>\n"); } =20 diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index 113d349708..6a00c0aaf9 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -128,6 +128,7 @@ VIR_ENUM_DECL(virCPUMaxPhysAddrMode); typedef struct _virCPUMaxPhysAddrDef virCPUMaxPhysAddrDef; struct _virCPUMaxPhysAddrDef { int bits; /* -1 for unspecified */ + int limit; /* -1 for unspecified */ virCPUMaxPhysAddrMode mode; }; =20 diff --git a/src/conf/schemas/cputypes.rng b/src/conf/schemas/cputypes.rng index 3e79bdd563..db1aa57158 100644 --- a/src/conf/schemas/cputypes.rng +++ b/src/conf/schemas/cputypes.rng @@ -318,6 +318,11 @@ + + + + + =20 diff --git a/tests/qemuxml2argvdata/cpu-phys-bits-limit.xml b/tests/qemuxml= 2argvdata/cpu-phys-bits-limit.xml new file mode 100644 index 0000000000..aabfb77523 --- /dev/null +++ b/tests/qemuxml2argvdata/cpu-phys-bits-limit.xml @@ -0,0 +1,20 @@ + + foo + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + + + + destroy + restart + destroy + + + diff --git a/tests/qemuxml2xmloutdata/cpu-phys-bits-limit.x86_64-latest.xml= b/tests/qemuxml2xmloutdata/cpu-phys-bits-limit.x86_64-latest.xml new file mode 100644 index 0000000000..ced2d9c5ca --- /dev/null +++ b/tests/qemuxml2xmloutdata/cpu-phys-bits-limit.x86_64-latest.xml @@ -0,0 +1,31 @@ + + foo + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + + + +