提交 d238b51f 编写于 作者: J John Ferlan

qemu: Rename qemuBuildCpuArgStr to qemuBuildCpuCommandLine

Rename function and move code from mainline qemuBuildCommandLine to
keep alike code together.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 e3b964bc
...@@ -4773,22 +4773,21 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver, ...@@ -4773,22 +4773,21 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
} }
static int static int
qemuBuildCpuArgStr(virQEMUDriverPtr driver, qemuBuildCpuCommandLine(virCommandPtr cmd,
virQEMUDriverPtr driver,
const virDomainDef *def, const virDomainDef *def,
virQEMUCapsPtr qemuCaps, virQEMUCapsPtr qemuCaps,
virArch hostarch,
char **opt,
bool *hasHwVirt,
bool migrating) bool migrating)
{ {
virArch hostarch = virArchFromHost();
char *cpu = NULL;
bool hasHwVirt = false;
const char *default_model; const char *default_model;
bool have_cpu = false; bool have_cpu = false;
int ret = -1; int ret = -1;
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
size_t i; size_t i;
*hasHwVirt = false;
if (def->os.arch == VIR_ARCH_I686) if (def->os.arch == VIR_ARCH_I686)
default_model = "qemu32"; default_model = "qemu32";
else else
...@@ -4797,7 +4796,7 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver, ...@@ -4797,7 +4796,7 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver,
if (def->cpu && if (def->cpu &&
(def->cpu->mode != VIR_CPU_MODE_CUSTOM || def->cpu->model)) { (def->cpu->mode != VIR_CPU_MODE_CUSTOM || def->cpu->model)) {
if (qemuBuildCpuModelArgStr(driver, def, &buf, qemuCaps, if (qemuBuildCpuModelArgStr(driver, def, &buf, qemuCaps,
hasHwVirt, migrating) < 0) &hasHwVirt, migrating) < 0)
goto cleanup; goto cleanup;
have_cpu = true; have_cpu = true;
} else { } else {
...@@ -4857,7 +4856,8 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver, ...@@ -4857,7 +4856,8 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver,
if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK]) { if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK]) {
char sign; char sign;
if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] == VIR_TRISTATE_SWITCH_ON) if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] ==
VIR_TRISTATE_SWITCH_ON)
sign = '+'; sign = '+';
else else
sign = '-'; sign = '-';
...@@ -4941,14 +4941,23 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver, ...@@ -4941,14 +4941,23 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver,
if (virBufferCheckError(&buf) < 0) if (virBufferCheckError(&buf) < 0)
goto cleanup; goto cleanup;
*opt = virBufferContentAndReset(&buf); cpu = virBufferContentAndReset(&buf);
if (cpu) {
virCommandAddArgList(cmd, "-cpu", cpu, NULL);
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NESTING) && hasHwVirt)
virCommandAddArg(cmd, "-enable-nesting");
}
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(cpu);
return ret; return ret;
} }
static int static int
qemuBuildObsoleteAccelArg(virCommandPtr cmd, qemuBuildObsoleteAccelArg(virCommandPtr cmd,
const virDomainDef *def, const virDomainDef *def,
...@@ -6731,11 +6740,9 @@ qemuBuildCommandLine(virConnectPtr conn, ...@@ -6731,11 +6740,9 @@ 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 *cpu;
char *smp; char *smp;
bool havespice = false; bool havespice = false;
int last_good_net = -1; int last_good_net = -1;
bool hasHwVirt = false;
virCommandPtr cmd = NULL; virCommandPtr cmd = NULL;
bool allowReboot = true; bool allowReboot = true;
bool emitBootindex = false; bool emitBootindex = false;
...@@ -6766,7 +6773,6 @@ qemuBuildCommandLine(virConnectPtr conn, ...@@ -6766,7 +6773,6 @@ qemuBuildCommandLine(virConnectPtr conn,
VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL, VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
VIR_DOMAIN_CONTROLLER_TYPE_CCID, VIR_DOMAIN_CONTROLLER_TYPE_CCID,
}; };
virArch hostarch = virArchFromHost();
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
virBuffer boot_buf = VIR_BUFFER_INITIALIZER; virBuffer boot_buf = VIR_BUFFER_INITIALIZER;
char *boot_order_str = NULL, *boot_opts_str = NULL; char *boot_order_str = NULL, *boot_opts_str = NULL;
...@@ -6815,19 +6821,9 @@ qemuBuildCommandLine(virConnectPtr conn, ...@@ -6815,19 +6821,9 @@ qemuBuildCommandLine(virConnectPtr conn,
if (qemuBuildMachineCommandLine(cmd, def, qemuCaps) < 0) if (qemuBuildMachineCommandLine(cmd, def, qemuCaps) < 0)
goto error; goto error;
if (qemuBuildCpuArgStr(driver, def, qemuCaps, if (qemuBuildCpuCommandLine(cmd, driver, def, qemuCaps, !!migrateURI) < 0)
hostarch, &cpu, &hasHwVirt, !!migrateURI) < 0)
goto error; goto error;
if (cpu) {
virCommandAddArgList(cmd, "-cpu", cpu, NULL);
VIR_FREE(cpu);
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NESTING) &&
hasHwVirt)
virCommandAddArg(cmd, "-enable-nesting");
}
if (qemuBuildDomainLoaderCommandLine(cmd, def, qemuCaps) < 0) if (qemuBuildDomainLoaderCommandLine(cmd, def, qemuCaps) < 0)
goto error; goto error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册