Patchwork [04/15] target-i386: introduce apic-id property

login
register
mail settings
Submitter Andreas Färber
Date April 26, 2013, 4:46 p.m.
Message ID <517AAF7A.1080604@suse.de>
Download mbox | patch
Permalink /patch/239890/
State New
Headers show

Comments

Andreas Färber - April 26, 2013, 4:46 p.m.
Am 25.04.2013 16:05, schrieb Igor Mammedov:
> The property is used from board level to set APIC ID for CPUs it
> creates. Do so in a new pc_new_cpu() helper, to be reused for hot-plug.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> Note:
>   * pc_new_cpu() function will be reused later in CPU hot-plug hook.
> 
> v4:
>   * after switching to qemu_for_each_cpu() in cpu_exists(), first CPU
>     becomes visible to cpu_exists() early and setting property fails,
>     skip APIC ID check if value to be set is the same as the current.
>   * use error_propagate() in pc_new_cpu()
>   * return CPU from pc_new_cpu(). Moved from "move APIC to ICC bus"
>     to reduce its size.
> v3:
>   * user error_propagate() in property setter
> v2:
>   * use generic cpu_exists() instead of custom one
>   * make apic-id dynamic property, so it won't be possible to use it
>     as global property, since it's instance specific
> ---
>  hw/i386/pc.c      |   29 ++++++++++++++++++++++++++++-
>  target-i386/cpu.c |   42 ++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 70 insertions(+), 1 deletions(-)

Thanks, applied to qom-cpu (with change suggested on v4 below):
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Question: This being a dynamic QOM property, QMP qom-set apic-id allows
to change the value during runtime. Should we suppress this with a
dev->realized check? If so, please supply a follow-up patch.

Andreas

     cpu->env.cpuid_apic_id = value;

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 0be0138..f1cecc0 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1295,16 +1295,14 @@  static void x86_cpuid_set_apic_id(Object *obj,
Visitor *v, void *opaque,
         return;
     }
     if (value < min || value > max) {
-        error_setg(&error, "Property %s.%s doesn't take value %" PRId64
+        error_setg(errp, "Property %s.%s doesn't take value %" PRId64
                    " (minimum: %" PRId64 ", maximum: %" PRId64 ")" ,
                    object_get_typename(obj), name, value, min, max);
-        error_propagate(errp, error);
         return;
     }

     if ((value != cpu->env.cpuid_apic_id) && cpu_exists(value)) {
-        error_setg(&error, "CPU with APIC ID %" PRIi64 " exists", value);
-        error_propagate(errp, error);
+        error_setg(errp, "CPU with APIC ID %" PRIi64 " exists", value);
         return;
     }