[libvirt] [PATCH 2/2] qemu: Enforce vCPU hotplug granularity constraints
Peter Krempa
pkrempa at redhat.com
Fri Dec 15 12:22:14 UTC 2017
On Thu, Dec 14, 2017 at 17:29:51 +0100, Andrea Bolognani wrote:
> 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 at redhat.com>
> ---
> src/qemu/qemu_domain.c | 41 ++++++++++++++++++++++
> tests/qemuxml2argvdata/cpu-hotplug-granularity.xml | 18 ++++++++++
> tests/qemuxml2argvtest.c | 3 ++
> 3 files changed, 62 insertions(+)
> create mode 100644 tests/qemuxml2argvdata/cpu-hotplug-granularity.xml
>
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index e93333669..632f330f7 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -3289,6 +3289,36 @@ qemuDomainDefValidateVideo(const virDomainDef *def)
> }
>
>
> +/**
> + * qemuDomainDefGetVcpuHotplugGranularity:
> + * @def: domain definition
> + * @granularity: return location for vCPU hotplug granularity
> + *
> + * With QEMU 2.7 and newer, vCPUs can only be hotplugged @granularity at
> + * a time; because of that, QEMU will not allow guests to start unless the
> + * initial number of vCPUs is a multiple of @granularity.
> + *
> + * Returns 0 on success, 1 if topology is not configured and -1 on error.
> + */
> +static int
> +qemuDomainDefGetVcpuHotplugGranularity(const virDomainDef *def,
> + unsigned int *granularity)
> +{
> + if (!granularity)
> + return -1;
Why?
> +
> + if (!def->cpu || def->cpu->sockets == 0)
> + return 1;
I think we assume '1' as threads here if it's not specified.
> +
> + if (qemuDomainIsPSeries(def))
> + *granularity = def->cpu->threads;
> + else
> + *granularity = 1;
Why not just return the granularity rather than this weirdness?
> +
> + return 0;
> +}
> +
> +
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20171215/05cdc2ba/attachment-0001.sig>
More information about the libvir-list
mailing list