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` - + ... @@ -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. + ``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 reports + more bits than that, ``limit`` is used. :since:`Since 9.3.0` + Guest NUMA topology can be specified using the ``numa`` element. :since:`Since 0.9.8` 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 = virXMLPropUInt(maxphysaddrNode, "limit", 10, + VIR_XML_PROP_NONZERO, + &def->addr->limit)) < 0) { + return -1; + } else if (rv > 0 && def->addr->mode != VIR_CPU_MAX_PHYS_ADDR_MODE_PASSTHROUGH) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("attribute 'limit' is only supported for maxphysaddr mode 'passthrough'")); + return -1; + } + } *cpu = g_steal_pointer(&def); @@ -843,6 +854,8 @@ virCPUDefFormatBuf(virBuffer *buf, virCPUMaxPhysAddrModeTypeToString(def->addr->mode)); if (def->addr->bits != -1) virBufferAsprintf(buf, " bits='%d'", def->addr->bits); + if (def->addr->limit > 0) + virBufferAsprintf(buf, " limit='%d'", def->addr->limit); virBufferAddLit(buf, "/>\n"); } 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; }; 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 @@ + + + + + diff --git a/tests/qemuxml2argvdata/cpu-phys-bits-limit.xml b/tests/qemuxml2argvdata/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 + +
+ + + + +