target/i386/cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Included the mention of WHPX when the option -cpu host doesn't have
an accelerator option.
Signed-off-by: Andrew Nguyen <xmphyr@gmail.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4836
---
This is a resolution for issue #4836: https://gitlab.com/qemu-project/qemu/-/work_items/4836.
"-cpu host" by itself is not permitted; an accelerator must be specified as well. For Linux,
it is KVM. macOS is HVF and Windows is WHPX.
Previously, QEMU would only tell the user to use either KVM or HVF, essentially excluding
Windows users. This patch adds WHPX to the error message. A similar patch was made seven
months ago in target/arm/cpu.c:1861.
Signed-off-by: Andrew Nguyen <xmphyr@gmail.com>
---
Changes:
- cpu.c:10229: added WHPX to the error message when "-cpu host" doesn't include an accelerator
---
target/i386/cpu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index eab0d5a4d4..7dd5535f80 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -10229,7 +10229,8 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) {
g_autofree char *name = x86_cpu_class_get_model_name(xcc);
- error_setg(&local_err, "CPU model '%s' requires KVM or HVF", name);
+ error_setg(&local_err, "The '%s' CPU type can only be used with KVM,
+ HVF or WHPX", name);
goto out;
}
---
base-commit: e9fa1f66f0d47c74b6766e1b8b87ad7c2a9394d5
change-id: 20261115-4836-cpu-host-error-1e85b17e0f1d
Best regards,
--
Andrew Nguyen <xmphyr@gmail.com>
On Mon, 16 Nov 2026 at 03:38, Andrew Nguyen <xmphyr@gmail.com> wrote:
>
> Included the mention of WHPX when the option -cpu host doesn't have
> an accelerator option.
>
> Signed-off-by: Andrew Nguyen <xmphyr@gmail.com>
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4836
> ---
> This is a resolution for issue #4836: https://gitlab.com/qemu-project/qemu/-/work_items/4836.
> "-cpu host" by itself is not permitted; an accelerator must be specified as well. For Linux,
> it is KVM. macOS is HVF and Windows is WHPX.
>
> Previously, QEMU would only tell the user to use either KVM or HVF, essentially excluding
> Windows users. This patch adds WHPX to the error message. A similar patch was made seven
> months ago in target/arm/cpu.c:1861.
>
> Signed-off-by: Andrew Nguyen <xmphyr@gmail.com>
> ---
> Changes:
> - cpu.c:10229: added WHPX to the error message when "-cpu host" doesn't include an accelerator
> ---
> target/i386/cpu.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index eab0d5a4d4..7dd5535f80 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -10229,7 +10229,8 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
>
> if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) {
> g_autofree char *name = x86_cpu_class_get_model_name(xcc);
> - error_setg(&local_err, "CPU model '%s' requires KVM or HVF", name);
> + error_setg(&local_err, "The '%s' CPU type can only be used with KVM,
> + HVF or WHPX", name);
> goto out;
> }
The code isn't checking "is this KVM, HVF or WHPX", though.
accel_uses_host_cpuid() is checking "not TCG" (also "not qtest" but as
that's a test facility we don't need to mention it here). Listing
an explicit set of accelerators means it gets out of date whenever
a new one is added (as has already happened here once when the
WHPX accelerator was added and the message not updated).
thanks
-- PMM
Hi Andrew,
On 16/11/26 10:38, Peter Maydell wrote:
> On Mon, 16 Nov 2026 at 03:38, Andrew Nguyen <xmphyr@gmail.com> wrote:
>>
>> Included the mention of WHPX when the option -cpu host doesn't have
>> an accelerator option.
>>
>> Signed-off-by: Andrew Nguyen <xmphyr@gmail.com>
>>
>> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4836
>> ---
>> This is a resolution for issue #4836: https://gitlab.com/qemu-project/qemu/-/work_items/4836.
>> "-cpu host" by itself is not permitted; an accelerator must be specified as well. For Linux,
>> it is KVM. macOS is HVF and Windows is WHPX.
>>
>> Previously, QEMU would only tell the user to use either KVM or HVF, essentially excluding
>> Windows users. This patch adds WHPX to the error message. A similar patch was made seven
>> months ago in target/arm/cpu.c:1861.
>>
>> Signed-off-by: Andrew Nguyen <xmphyr@gmail.com>
>> ---
>> Changes:
>> - cpu.c:10229: added WHPX to the error message when "-cpu host" doesn't include an accelerator
>> ---
>> target/i386/cpu.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
>> index eab0d5a4d4..7dd5535f80 100644
>> --- a/target/i386/cpu.c
>> +++ b/target/i386/cpu.c
>> @@ -10229,7 +10229,8 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
>>
>> if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) {
>> g_autofree char *name = x86_cpu_class_get_model_name(xcc);
>> - error_setg(&local_err, "CPU model '%s' requires KVM or HVF", name);
>> + error_setg(&local_err, "The '%s' CPU type can only be used with KVM,
>> + HVF or WHPX", name);
>> goto out;
>> }
>
> The code isn't checking "is this KVM, HVF or WHPX", though.
> accel_uses_host_cpuid() is checking "not TCG" (also "not qtest" but as
> that's a test facility we don't need to mention it here). Listing
> an explicit set of accelerators means it gets out of date whenever
> a new one is added (as has already happened here once when the
> WHPX accelerator was added and the message not updated).
See commit f7fa2b88084c22299b347cea8fd9fadb0b136b22 for an example
of the hwaccel_enabled() method.
I appreciate the both of you for the feedback.
As Philippe has suggested, I will add hwaccel_enabled() as a condition in
order to check for KVM, HVF, or WHPX.
To Peter, instead of explicitly printing the list of accelerators, maybe I
should add a macro of a string that's something like "KVM, HVF, or WHPX"?
This would be in include/system/hw_accel.h.
As a sidenote, this is my first patch. When I receive feedback, should I
reply first with my plan and get feedback on that before sending a revision?
---
Thanks,
Andrew Nguyen
On Mon, Nov 16, 2026 at 8:10 AM Philippe Mathieu-Daudé <
philmd@oss.qualcomm.com> wrote:
> Hi Andrew,
>
> On 16/11/26 10:38, Peter Maydell wrote:
> > On Mon, 16 Nov 2026 at 03:38, Andrew Nguyen <xmphyr@gmail.com> wrote:
> >>
> >> Included the mention of WHPX when the option -cpu host doesn't have
> >> an accelerator option.
> >>
> >> Signed-off-by: Andrew Nguyen <xmphyr@gmail.com>
> >>
> >> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4836
> >> ---
> >> This is a resolution for issue #4836:
> https://gitlab.com/qemu-project/qemu/-/work_items/4836.
> >> "-cpu host" by itself is not permitted; an accelerator must be
> specified as well. For Linux,
> >> it is KVM. macOS is HVF and Windows is WHPX.
> >>
> >> Previously, QEMU would only tell the user to use either KVM or HVF,
> essentially excluding
> >> Windows users. This patch adds WHPX to the error message. A similar
> patch was made seven
> >> months ago in target/arm/cpu.c:1861.
> >>
> >> Signed-off-by: Andrew Nguyen <xmphyr@gmail.com>
> >> ---
> >> Changes:
> >> - cpu.c:10229: added WHPX to the error message when "-cpu host" doesn't
> include an accelerator
> >> ---
> >> target/i386/cpu.c | 3 ++-
> >> 1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> >> index eab0d5a4d4..7dd5535f80 100644
> >> --- a/target/i386/cpu.c
> >> +++ b/target/i386/cpu.c
> >> @@ -10229,7 +10229,8 @@ static void x86_cpu_realizefn(DeviceState *dev,
> Error **errp)
> >>
> >> if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) {
> >> g_autofree char *name = x86_cpu_class_get_model_name(xcc);
> >> - error_setg(&local_err, "CPU model '%s' requires KVM or HVF",
> name);
> >> + error_setg(&local_err, "The '%s' CPU type can only be used
> with KVM,
> >> + HVF or WHPX", name);
> >> goto out;
> >> }
> >
> > The code isn't checking "is this KVM, HVF or WHPX", though.
> > accel_uses_host_cpuid() is checking "not TCG" (also "not qtest" but as
> > that's a test facility we don't need to mention it here). Listing
> > an explicit set of accelerators means it gets out of date whenever
> > a new one is added (as has already happened here once when the
> > WHPX accelerator was added and the message not updated).
>
> See commit f7fa2b88084c22299b347cea8fd9fadb0b136b22 for an example
> of the hwaccel_enabled() method.
>
Hi Andrew,
On 17/11/26 05:15, xmphyr wrote:
> I appreciate the both of you for the feedback.
>
> As Philippe has suggested, I will add hwaccel_enabled() as a condition in
> order to check for KVM, HVF, or WHPX.
>
> To Peter, instead of explicitly printing the list of accelerators, maybe I
> should add a macro of a string that's something like "KVM, HVF, or WHPX"?
> This would be in include/system/hw_accel.h.
Or:
error_setg(&local_err, "CPU type '%s' can not work with '%s':"
" hardware accelerator required",
name, current_accel_name());
> As a sidenote, this is my first patch.
Going well so far! :)
> When I receive feedback, should I
> reply first with my plan and get feedback on that before sending a revision?
Extra reply is never an issue, the list is noisy anyway, subscribers
have to filter for noise.
When the requested changes are not obvious, it is indeed better to
expose your plan before respinning, so doubts can be cleared early
enough.
(Also, on technical mailing lists, it is better to not write comments
at the top, see
https://subspace.kernel.org/etiquette.html#do-not-top-post-when-replying
for an explanation)
Regards,
Phil.
>
> ---
> Thanks,
> Andrew Nguyen
>
> On Mon, Nov 16, 2026 at 8:10 AM Philippe Mathieu-Daudé <
> philmd@oss.qualcomm.com> wrote:
>
>> Hi Andrew,
>>
>> On 16/11/26 10:38, Peter Maydell wrote:
>>> On Mon, 16 Nov 2026 at 03:38, Andrew Nguyen <xmphyr@gmail.com> wrote:
>>>>
>>>> Included the mention of WHPX when the option -cpu host doesn't have
>>>> an accelerator option.
>>>>
>>>> Signed-off-by: Andrew Nguyen <xmphyr@gmail.com>
>>>>
>>>> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4836
>>>> ---
>>>> This is a resolution for issue #4836:
>> https://gitlab.com/qemu-project/qemu/-/work_items/4836.
>>>> "-cpu host" by itself is not permitted; an accelerator must be
>> specified as well. For Linux,
>>>> it is KVM. macOS is HVF and Windows is WHPX.
>>>>
>>>> Previously, QEMU would only tell the user to use either KVM or HVF,
>> essentially excluding
>>>> Windows users. This patch adds WHPX to the error message. A similar
>> patch was made seven
>>>> months ago in target/arm/cpu.c:1861.
>>>>
>>>> Signed-off-by: Andrew Nguyen <xmphyr@gmail.com>
>>>> ---
>>>> Changes:
>>>> - cpu.c:10229: added WHPX to the error message when "-cpu host" doesn't
>> include an accelerator
>>>> ---
>>>> target/i386/cpu.c | 3 ++-
>>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
>>>> index eab0d5a4d4..7dd5535f80 100644
>>>> --- a/target/i386/cpu.c
>>>> +++ b/target/i386/cpu.c
>>>> @@ -10229,7 +10229,8 @@ static void x86_cpu_realizefn(DeviceState *dev,
>> Error **errp)
>>>>
>>>> if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) {
>>>> g_autofree char *name = x86_cpu_class_get_model_name(xcc);
>>>> - error_setg(&local_err, "CPU model '%s' requires KVM or HVF",
>> name);
>>>> + error_setg(&local_err, "The '%s' CPU type can only be used
>> with KVM,
>>>> + HVF or WHPX", name);
>>>> goto out;
>>>> }
>>>
>>> The code isn't checking "is this KVM, HVF or WHPX", though.
>>> accel_uses_host_cpuid() is checking "not TCG" (also "not qtest" but as
>>> that's a test facility we don't need to mention it here). Listing
>>> an explicit set of accelerators means it gets out of date whenever
>>> a new one is added (as has already happened here once when the
>>> WHPX accelerator was added and the message not updated).
>>
>> See commit f7fa2b88084c22299b347cea8fd9fadb0b136b22 for an example
>> of the hwaccel_enabled() method.
>>
>
© 2016 - 2026 Red Hat, Inc.