qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 5/7] target/i386/cpu: Improve errors for out of bounds pro


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2 5/7] target/i386/cpu: Improve errors for out of bounds property values
Date: Thu, 10 Oct 2024 14:38:15 -0300
User-agent: Mozilla Thunderbird

On 10/10/24 12:01, Markus Armbruster wrote:
The error message for a "stepping" value that is out of bounds is a
bit odd:

     $ qemu-system-x86_64 -cpu qemu64,stepping=16
     qemu-system-x86_64: can't apply global qemu64-x86_64-cpu.stepping=16: 
Property .stepping doesn't take value 16 (minimum: 0, maximum: 15)

The "can't apply global" part is an unfortunate artifact of -cpu's
implementation.  Left for another day.

The remainder feels overly verbose.  Change it to

     qemu64-x86_64-cpu: can't apply global qemu64-x86_64-cpu.stepping=16: 
parameter 'stepping' can be at most 15

Likewise for "family", "model", and "tsc-frequency".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
  target/i386/cpu.c | 20 +++++++++-----------
  1 file changed, 9 insertions(+), 11 deletions(-)


@@ -5623,16 +5622,15 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor 
*v, const char *name,
                                     void *opaque, Error **errp)
  {
      X86CPU *cpu = X86_CPU(obj);
-    const int64_t min = 0;
      const int64_t max = INT64_MAX;
      int64_t value;
if (!visit_type_int(v, name, &value, errp)) {
          return;
      }
-    if (value < min || value > max) {
-        error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "",
-                   name ? name : "null", value, min, max);
+    if (value < 0 || value > max) {
+        error_setg(errp, "parameter '%s' can be at most %" PRId64,
+                   name ? name : "null", max);

Confusing:

qemu64-x86_64-cpu: can't apply global qemu64-x86_64-cpu.stepping=-1: parameter 'stepping' can be at most 15

          return;
      }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]