From nobody Mon May 13 20:52:37 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=1682343620; cv=none; d=zohomail.com; s=zohoarc; b=nTl5HLpon3GeMpxPckhYDou3yfrEROuBey8hlCSQJJx26v99D6aTti4g4SyIfk8MFPC4CtdzqbLU91RO+bs5e4VO4SXksBU40IVP2/xfRX0eTYx211AIpfoG6AryTrpCwAOtz/hWH4qivNSgVg2b8aeRnc0GMy+nzyIOgw4g0O4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682343620; 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=DqZKK2J6jE0lmuiiHESDvQJiXC6Lt1UmuiMqDYMaRfg=; b=KCQNYtSv/w29jYjcpsa5ChGIi9Ey+DCrqZItVpavdc6JBLRzxMvtYDVGNR/MqcIDt24dDBxBKho8E8pDVyP7jIRs6Offa8xrNU0NV35dW7OChDyAwN7OUZyNZ203aD7Nx+wWsdDaT+zLur6fgYELc3uMXmCHY1ZBapF8RuN4cOM= 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 1682343620137741.2077608696347; Mon, 24 Apr 2023 06:40:20 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-34-xP1nf5XYN7Caq-fnjPpb7w-1; Mon, 24 Apr 2023 09:40:14 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 013D687A3A5; Mon, 24 Apr 2023 13:40:11 +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 DDCB714171BB; Mon, 24 Apr 2023 13:40:10 +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 303C21946A46; Mon, 24 Apr 2023 13:40:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 360E01946588 for ; Mon, 24 Apr 2023 13:40:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 28B942166B2A; Mon, 24 Apr 2023 13:40:09 +0000 (UTC) Received: from fedora.. (unknown [10.43.2.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id C48062166B29 for ; Mon, 24 Apr 2023 13:40:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682343619; 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=DqZKK2J6jE0lmuiiHESDvQJiXC6Lt1UmuiMqDYMaRfg=; b=eh8GSYgWqcKvZ2+qf5DcfQj7ZhvDEGLUhwF07kc3wGzB8P4kp0ovJQXJkaVoWhJCAjo3fi REBHzWEMUo4GBL9T+z2L4oMGa+tDjuMhhy4egINhZYnvyaRqcwRDzFzVy9WVjDh2TysgK1 rAbuOds2hK5vmdzFJtNjdviy0aLhpeY= X-MC-Unique: xP1nf5XYN7Caq-fnjPpb7w-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 PATCHv2 1/3] conf: cpu: add limit for maxphysaddr Date: Mon, 24 Apr 2023 15:40:02 +0200 Message-Id: <3033f2efa5436a1e3faf20bd5fd3a63f565235e1.1682343566.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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.7 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: 1682343620672100001 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 Reviewed-by: Martin Kletzander --- docs/formatdomain.rst | 7 ++++- src/conf/cpu_conf.c | 13 ++++++++ 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, 78 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 cb3fe3dc1c..f5bbfdc20a 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -1374,7 +1374,7 @@ following collection of elements. :since:`Since 0.7.5` =20 - + ... =20 @@ -1644,6 +1644,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.3.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 2b361d2c68..98adb0e5d5 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -668,6 +668,17 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, VIR_XML_PROP_NONNEGATIVE, &def->addr->bits, -1) < 0) return -1; + + if ((rv =3D virXMLPropUInt(maxphysaddrNode, "limit", 10, + VIR_XML_PROP_NONZERO, + &def->addr->limit)) < 0) { + return -1; + } else if (rv > 0 && def->addr->mode !=3D VIR_CPU_MAX_PHYS_ADDR_MO= DE_PASSTHROUGH) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("attribute 'limit' is only supported for maxp= hysaddr mode 'passthrough'")); + return -1; + } + } =20 *cpu =3D g_steal_pointer(&def); @@ -843,6 +854,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 > 0) + 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 82083d668c..3e4c53675c 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 */ + unsigned int limit; /* 0 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 + +
+ + + + +