mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-11 12:25:52 +00:00
qemu: Enforce vCPU hotplug granularity constraints
QEMU 2.7 and newer don't allow guests to start unless the initial vCPUs count is a multiple of the vCPU hotplug granularity, so validate it and report an error if needed. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1283700 Signed-off-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
parent
54acfac4a5
commit
a38aa340fe
@ -3289,6 +3289,36 @@ qemuDomainDefValidateVideo(const virDomainDef *def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* qemuDomainDefGetVcpuHotplugGranularity:
|
||||||
|
* @def: domain definition
|
||||||
|
*
|
||||||
|
* With QEMU 2.7 and newer, vCPUs can only be hotplugged in groups that
|
||||||
|
* respect the guest's hotplug granularity; because of that, QEMU will
|
||||||
|
* not allow guests to start unless the initial number of vCPUs is a
|
||||||
|
* multiple of the hotplug granularity.
|
||||||
|
*
|
||||||
|
* Returns the vCPU hotplug granularity.
|
||||||
|
*/
|
||||||
|
static unsigned int
|
||||||
|
qemuDomainDefGetVcpuHotplugGranularity(const virDomainDef *def)
|
||||||
|
{
|
||||||
|
/* If the guest CPU topology has not been configured, assume we
|
||||||
|
* can hotplug vCPUs one at a time */
|
||||||
|
if (!def->cpu || def->cpu->sockets == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* For pSeries guests, hotplug can only be performed one core
|
||||||
|
* at a time, so the vCPU hotplug granularity is the number
|
||||||
|
* of threads per core */
|
||||||
|
if (qemuDomainIsPSeries(def))
|
||||||
|
return def->cpu->threads;
|
||||||
|
|
||||||
|
/* In all other cases, we can hotplug vCPUs one at a time */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define QEMU_MAX_VCPUS_WITHOUT_EIM 255
|
#define QEMU_MAX_VCPUS_WITHOUT_EIM 255
|
||||||
|
|
||||||
|
|
||||||
@ -3363,6 +3393,7 @@ qemuDomainDefValidate(const virDomainDef *def,
|
|||||||
* CPU topology. Verify known constraints are respected */
|
* CPU topology. Verify known constraints are respected */
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS)) {
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS)) {
|
||||||
unsigned int topologycpus;
|
unsigned int topologycpus;
|
||||||
|
unsigned int granularity;
|
||||||
|
|
||||||
/* Starting from QEMU 2.5, max vCPU count and overall vCPU topology
|
/* Starting from QEMU 2.5, max vCPU count and overall vCPU topology
|
||||||
* must agree. We only actually enforce this with QEMU 2.7+, due
|
* must agree. We only actually enforce this with QEMU 2.7+, due
|
||||||
@ -3373,6 +3404,16 @@ qemuDomainDefValidate(const virDomainDef *def,
|
|||||||
_("CPU topology doesn't match maximum vcpu count"));
|
_("CPU topology doesn't match maximum vcpu count"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* vCPU hotplug granularity must be respected */
|
||||||
|
granularity = qemuDomainDefGetVcpuHotplugGranularity(def);
|
||||||
|
if ((virDomainDefGetVcpus(def) % granularity) != 0) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("vCPUs count must be a multiple of the vCPU "
|
||||||
|
"hotplug granularity (%u)"),
|
||||||
|
granularity);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ARCH_IS_X86(def->os.arch) &&
|
if (ARCH_IS_X86(def->os.arch) &&
|
||||||
|
18
tests/qemuxml2argvdata/cpu-hotplug-granularity.xml
Normal file
18
tests/qemuxml2argvdata/cpu-hotplug-granularity.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>guest</name>
|
||||||
|
<uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
|
||||||
|
<memory unit='KiB'>524288</memory>
|
||||||
|
<vcpu placement='static' current='2'>8</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='ppc64' machine='pseries'>hvm</type>
|
||||||
|
</os>
|
||||||
|
<cpu>
|
||||||
|
<topology sockets='1' cores='2' threads='4'/>
|
||||||
|
</cpu>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu-system-ppc64</emulator>
|
||||||
|
<controller type='pci' model='pci-root'/>
|
||||||
|
<controller type='usb' model='none'/>
|
||||||
|
<memballoon model='none'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -2900,6 +2900,9 @@ mymain(void)
|
|||||||
QEMU_CAPS_DEVICE_INTEL_IOMMU);
|
QEMU_CAPS_DEVICE_INTEL_IOMMU);
|
||||||
|
|
||||||
DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
|
DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
|
||||||
|
DO_TEST_PARSE_ERROR("cpu-hotplug-granularity",
|
||||||
|
QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
|
||||||
|
|
||||||
DO_TEST("virtio-options", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_KEYBOARD,
|
DO_TEST("virtio-options", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_KEYBOARD,
|
||||||
QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET,
|
QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET,
|
||||||
QEMU_CAPS_VIRTIO_INPUT_HOST,
|
QEMU_CAPS_VIRTIO_INPUT_HOST,
|
||||||
|
Loading…
Reference in New Issue
Block a user