提交 19f75d5e 编写于 作者: J Ján Tomko

qemu: add hv_vapic and hv_spinlocks support

XML:
<features>
  <hyperv>
    <vapic state='on'/>
    <spinlocks state='on' retries='4096'/>
  </hyperv>
</features>

results in the following QEMU command line:
qemu -cpu <cpu_model>,hv_vapic,hv_spinlocks=0x1000

https://bugzilla.redhat.com/show_bug.cgi?id=784836
上级 800b51d7
......@@ -5786,14 +5786,16 @@ qemuBuildCpuArgStr(const virQEMUDriverPtr driver,
for (i = 0; i < VIR_DOMAIN_HYPERV_LAST; i++) {
switch ((enum virDomainHyperv) i) {
case VIR_DOMAIN_HYPERV_RELAXED:
case VIR_DOMAIN_HYPERV_VAPIC:
if (def->hyperv_features[i] == VIR_DOMAIN_FEATURE_STATE_ON)
virBufferAsprintf(&buf, ",hv_%s",
virDomainHypervTypeToString(i));
break;
case VIR_DOMAIN_HYPERV_VAPIC:
case VIR_DOMAIN_HYPERV_SPINLOCKS:
/* implemented in the next commit */
if (def->hyperv_features[i] == VIR_DOMAIN_FEATURE_STATE_ON)
virBufferAsprintf(&buf, ",hv_spinlocks=0x%x",
def->hyperv_spinlocks);
break;
case VIR_DOMAIN_HYPERV_LAST:
......@@ -9632,6 +9634,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
{
virCPUDefPtr cpu = NULL;
char **tokens;
char **hv_tokens = NULL;
char *model = NULL;
int ret = -1;
int i;
......@@ -9711,9 +9714,19 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
goto cleanup;
}
} else if (STRPREFIX(tokens[i], "hv_")) {
const char *feature = tokens[i] + 3; /* "hv_" */
const char *token = tokens[i] + 3; /* "hv_" */
const char *feature, *value;
int f;
if (*token == '\0')
goto syntax;
if (!(hv_tokens = virStringSplit(token, "=", 2)))
goto cleanup;
feature = hv_tokens[0];
value = hv_tokens[1];
if (*feature == '\0')
goto syntax;
......@@ -9728,17 +9741,39 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
switch ((enum virDomainHyperv) f) {
case VIR_DOMAIN_HYPERV_RELAXED:
case VIR_DOMAIN_HYPERV_VAPIC:
if (value) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("HyperV feature '%s' should not "
"have a value"), feature);
goto cleanup;
}
dom->hyperv_features[f] = VIR_DOMAIN_FEATURE_STATE_ON;
break;
case VIR_DOMAIN_HYPERV_VAPIC:
case VIR_DOMAIN_HYPERV_SPINLOCKS:
/* implemented in the next commit */
dom->hyperv_features[f] = VIR_DOMAIN_FEATURE_STATE_ON;
if (!value) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("missing HyperV spinlock retry count"));
goto cleanup;
}
if (virStrToLong_ui(value, NULL, 0, &dom->hyperv_spinlocks) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("cannot parse HyperV spinlock retry count"));
goto cleanup;
}
if (dom->hyperv_spinlocks < 0xFFF)
dom->hyperv_spinlocks = 0xFFF;
break;
case VIR_DOMAIN_HYPERV_LAST:
break;
}
virStringFreeList(hv_tokens);
hv_tokens = NULL;
}
}
......@@ -9766,6 +9801,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
cleanup:
VIR_FREE(model);
virStringFreeList(tokens);
virStringFreeList(hv_tokens);
return ret;
syntax:
......
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc \
-cpu qemu32,hv_relaxed -m 214 -smp 6 -nographic -monitor \
-cpu qemu32,hv_relaxed,hv_vapic,hv_spinlocks=0x2fff -m 214 -smp 6 -nographic -monitor \
unix:/tmp/test-monitor,server,nowait -boot n -usb -net none -serial none \
-parallel none
......@@ -12,6 +12,8 @@
<acpi/>
<hyperv>
<relaxed state='on'/>
<vapic state='on'/>
<spinlocks state='on' retries='12287'/>
</hyperv>
</features>
<clock offset='utc'/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册