Patchwork target-i386: Do not allow to set apic-id one CPU is realized

login
register
mail settings
Submitter Igor Mammedov
Date April 26, 2013, 5:29 p.m.
Message ID <1366997396-22996-1-git-send-email-imammedo@redhat.com>
Download mbox | patch
Permalink /patch/239893/
State New
Headers show

Comments

Igor Mammedov - April 26, 2013, 5:29 p.m.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu.c | 6 ++++++
 1 file changed, 6 insertions(+)
Eduardo Habkost - April 26, 2013, 5:33 p.m.
On Fri, Apr 26, 2013 at 07:29:56PM +0200, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

I believe you meant "once CPU is realized" on subject line?

Except for that:

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

> ---
>  target-i386/cpu.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index f1cecc0..3152ad5 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -1289,6 +1289,12 @@ static void x86_cpuid_set_apic_id(Object *obj, Visitor *v, void *opaque,
>      Error *error = NULL;
>      int64_t value;
>  
> +    if (DEVICE(obj)->realized) {
> +        error_setg(errp, "Attempt to set property '%s' on '%s' after "
> +                   "it was realized", name, object_get_typename(obj));
> +        return;
> +    }
> +
>      visit_type_int(v, &value, name, &error);
>      if (error) {
>          error_propagate(errp, error);
> -- 
> 1.8.2.1
>
Andreas Färber - April 26, 2013, 5:39 p.m.
Am 26.04.2013 19:29, schrieb Igor Mammedov:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  target-i386/cpu.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index f1cecc0..3152ad5 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -1289,6 +1289,12 @@ static void x86_cpuid_set_apic_id(Object *obj, Visitor *v, void *opaque,
>      Error *error = NULL;
>      int64_t value;
>  
> +    if (DEVICE(obj)->realized) {

http://wiki.qemu.org/QOMConventions

Anthony asked to not do FOO(x)->bar. Please add a DeviceState *dev
variable above.

> +        error_setg(errp, "Attempt to set property '%s' on '%s' after "
> +                   "it was realized", name, object_get_typename(obj));

Peter had introduced a helper for that that you had pointed me to
before, but I believe it's static in qdev-properties.c, so copying seems
the easiest here. Fine with me if you could address the above.

Andreas

> +        return;
> +    }
> +
>      visit_type_int(v, &value, name, &error);
>      if (error) {
>          error_propagate(errp, error);
>
Igor Mammedov - April 26, 2013, 5:48 p.m.
On Fri, 26 Apr 2013 19:39:01 +0200
Andreas Färber <afaerber@suse.de> wrote:

> Am 26.04.2013 19:29, schrieb Igor Mammedov:
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >  target-i386/cpu.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> > index f1cecc0..3152ad5 100644
> > --- a/target-i386/cpu.c
> > +++ b/target-i386/cpu.c
> > @@ -1289,6 +1289,12 @@ static void x86_cpuid_set_apic_id(Object *obj, Visitor *v, void *opaque,
> >      Error *error = NULL;
> >      int64_t value;
> >  
> > +    if (DEVICE(obj)->realized) {
> 
> http://wiki.qemu.org/QOMConventions
> 
> Anthony asked to not do FOO(x)->bar. Please add a DeviceState *dev
> variable above.
Ok, I wanted to save a line. I'll repost in a minute.

> 
> > +        error_setg(errp, "Attempt to set property '%s' on '%s' after "
> > +                   "it was realized", name, object_get_typename(obj));
> 
> Peter had introduced a helper for that that you had pointed me to
> before, but I believe it's static in qdev-properties.c, so copying seems
> the easiest here. Fine with me if you could address the above.
> 
> Andreas
> 
> > +        return;
> > +    }
> > +
> >      visit_type_int(v, &value, name, &error);
> >      if (error) {
> >          error_propagate(errp, error);
> > 
> 
> 
> -- 
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
>

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index f1cecc0..3152ad5 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1289,6 +1289,12 @@  static void x86_cpuid_set_apic_id(Object *obj, Visitor *v, void *opaque,
     Error *error = NULL;
     int64_t value;
 
+    if (DEVICE(obj)->realized) {
+        error_setg(errp, "Attempt to set property '%s' on '%s' after "
+                   "it was realized", name, object_get_typename(obj));
+        return;
+    }
+
     visit_type_int(v, &value, name, &error);
     if (error) {
         error_propagate(errp, error);