[libvirt] [PATCH 08/10] qemu: Reorganize -smp argument
Peter Krempa
pkrempa at redhat.com
Wed Feb 17 09:04:13 UTC 2016
On Tue, Feb 16, 2016 at 19:44:18 -0500, John Ferlan wrote:
> Reorganize the module to put all the -smp argument processing code together
> after the memory arguments to form a logical order of processing for
> qemuBuildCommandLine working top down in the module.
Misleading commit message.
>
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
> src/qemu/qemu_command.c | 102 ++++++++++++++++++++++++++++--------------------
> 1 file changed, 60 insertions(+), 42 deletions(-)
>
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index a8d1f4f..c90650f 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -976,6 +976,65 @@ qemuBuildMemCommandLine(virCommandPtr cmd,
> }
>
>
> +/** Start SMP (-smp) arguments */
Wrong comment style.
> +static char *
> +qemuBuildSmpArgStr(const virDomainDef *def,
> + virQEMUCapsPtr qemuCaps)
I don't think you need to move this at all.
> +{
> + virBuffer buf = VIR_BUFFER_INITIALIZER;
> +
> + virBufferAsprintf(&buf, "%u", virDomainDefGetVcpus(def));
> +
> + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SMP_TOPOLOGY)) {
> + if (virDomainDefHasVcpusOffline(def))
> + virBufferAsprintf(&buf, ",maxcpus=%u", virDomainDefGetVcpusMax(def));
> + /* sockets, cores, and threads are either all zero
> + * or all non-zero, thus checking one of them is enough */
> + if (def->cpu && def->cpu->sockets) {
> + virBufferAsprintf(&buf, ",sockets=%u", def->cpu->sockets);
> + virBufferAsprintf(&buf, ",cores=%u", def->cpu->cores);
> + virBufferAsprintf(&buf, ",threads=%u", def->cpu->threads);
> + } else {
> + virBufferAsprintf(&buf, ",sockets=%u", virDomainDefGetVcpusMax(def));
> + virBufferAsprintf(&buf, ",cores=%u", 1);
> + virBufferAsprintf(&buf, ",threads=%u", 1);
> + }
> + } else if (virDomainDefHasVcpusOffline(def)) {
> + virBufferFreeAndReset(&buf);
> + /* FIXME - consider hot-unplugging cpus after boot for older qemu */
> + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> + _("setting current vcpu count less than maximum is "
> + "not supported with this QEMU binary"));
> + return NULL;
> + }
> +
> + if (virBufferCheckError(&buf) < 0)
> + return NULL;
> +
> + return virBufferContentAndReset(&buf);
> +}
> +
> +
> +static int
> +qemuBuildSmpCommandLine(virCommandPtr cmd,
> + const virDomainDef *def,
> + virQEMUCapsPtr qemuCaps)
> +{
> + char *smp;
> +
> + virCommandAddArg(cmd, "-smp");
> + if (!(smp = qemuBuildSmpArgStr(def, qemuCaps)))
You could fold this code into qemuBuildSmpArgStr and just rename it
rather than adding a new function.
> + goto error;
return -1; ...
> + virCommandAddArg(cmd, smp);
> + VIR_FREE(smp);
Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160217/7a01b727/attachment-0001.sig>
More information about the libvir-list
mailing list