mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: Rename qemuBuildSmpArgStr to qemuBuildSmpCommandLine
Rename function and move code in from qemuBuildCommandLine to keep smp related code together. Also make a few style changes for long lines, return value change, and 2 spaces between functions. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
aa076fe8e4
commit
e0dd78c9b2
@ -5186,17 +5186,22 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static int
|
||||||
qemuBuildSmpArgStr(const virDomainDef *def,
|
qemuBuildSmpCommandLine(virCommandPtr cmd,
|
||||||
|
const virDomainDef *def,
|
||||||
virQEMUCapsPtr qemuCaps)
|
virQEMUCapsPtr qemuCaps)
|
||||||
{
|
{
|
||||||
|
char *smp;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
|
virCommandAddArg(cmd, "-smp");
|
||||||
|
|
||||||
virBufferAsprintf(&buf, "%u", virDomainDefGetVcpus(def));
|
virBufferAsprintf(&buf, "%u", virDomainDefGetVcpus(def));
|
||||||
|
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SMP_TOPOLOGY)) {
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SMP_TOPOLOGY)) {
|
||||||
if (virDomainDefHasVcpusOffline(def))
|
if (virDomainDefHasVcpusOffline(def))
|
||||||
virBufferAsprintf(&buf, ",maxcpus=%u", virDomainDefGetVcpusMax(def));
|
virBufferAsprintf(&buf, ",maxcpus=%u",
|
||||||
|
virDomainDefGetVcpusMax(def));
|
||||||
/* sockets, cores, and threads are either all zero
|
/* sockets, cores, and threads are either all zero
|
||||||
* or all non-zero, thus checking one of them is enough */
|
* or all non-zero, thus checking one of them is enough */
|
||||||
if (def->cpu && def->cpu->sockets) {
|
if (def->cpu && def->cpu->sockets) {
|
||||||
@ -5204,7 +5209,8 @@ qemuBuildSmpArgStr(const virDomainDef *def,
|
|||||||
virBufferAsprintf(&buf, ",cores=%u", def->cpu->cores);
|
virBufferAsprintf(&buf, ",cores=%u", def->cpu->cores);
|
||||||
virBufferAsprintf(&buf, ",threads=%u", def->cpu->threads);
|
virBufferAsprintf(&buf, ",threads=%u", def->cpu->threads);
|
||||||
} else {
|
} else {
|
||||||
virBufferAsprintf(&buf, ",sockets=%u", virDomainDefGetVcpusMax(def));
|
virBufferAsprintf(&buf, ",sockets=%u",
|
||||||
|
virDomainDefGetVcpusMax(def));
|
||||||
virBufferAsprintf(&buf, ",cores=%u", 1);
|
virBufferAsprintf(&buf, ",cores=%u", 1);
|
||||||
virBufferAsprintf(&buf, ",threads=%u", 1);
|
virBufferAsprintf(&buf, ",threads=%u", 1);
|
||||||
}
|
}
|
||||||
@ -5214,15 +5220,20 @@ qemuBuildSmpArgStr(const virDomainDef *def,
|
|||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("setting current vcpu count less than maximum is "
|
_("setting current vcpu count less than maximum is "
|
||||||
"not supported with this QEMU binary"));
|
"not supported with this QEMU binary"));
|
||||||
return NULL;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virBufferCheckError(&buf) < 0)
|
if (virBufferCheckError(&buf) < 0)
|
||||||
return NULL;
|
return -1;
|
||||||
|
|
||||||
return virBufferContentAndReset(&buf);
|
smp = virBufferContentAndReset(&buf);
|
||||||
|
virCommandAddArg(cmd, smp);
|
||||||
|
VIR_FREE(smp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg,
|
qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg,
|
||||||
const virDomainDef *def,
|
const virDomainDef *def,
|
||||||
@ -6787,7 +6798,6 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
virErrorPtr originalError = NULL;
|
virErrorPtr originalError = NULL;
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
char uuid[VIR_UUID_STRING_BUFLEN];
|
char uuid[VIR_UUID_STRING_BUFLEN];
|
||||||
char *smp;
|
|
||||||
bool havespice = false;
|
bool havespice = false;
|
||||||
int last_good_net = -1;
|
int last_good_net = -1;
|
||||||
virCommandPtr cmd = NULL;
|
virCommandPtr cmd = NULL;
|
||||||
@ -6880,11 +6890,8 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
if (qemuBuildMemCommandLine(cmd, cfg, def, qemuCaps) < 0)
|
if (qemuBuildMemCommandLine(cmd, cfg, def, qemuCaps) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
virCommandAddArg(cmd, "-smp");
|
if (qemuBuildSmpCommandLine(cmd, def, qemuCaps) < 0)
|
||||||
if (!(smp = qemuBuildSmpArgStr(def, qemuCaps)))
|
|
||||||
goto error;
|
goto error;
|
||||||
virCommandAddArg(cmd, smp);
|
|
||||||
VIR_FREE(smp);
|
|
||||||
|
|
||||||
if (def->niothreadids) {
|
if (def->niothreadids) {
|
||||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD)) {
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user