Patchwork [qom-cpu,v3,4/6] cpu: Introduce cpu_class_set_vmsd()

login
register
mail settings
Submitter Andreas Färber
Date Feb. 25, 2013, 6:22 p.m.
Message ID <1361816570-8707-5-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/223002/
State New
Headers show

Comments

Andreas Färber - Feb. 25, 2013, 6:22 p.m.
This setter avoids redefining each VMStateDescription value to
vmstate_dummy by not referencing the value for CONFIG_USER_ONLY.

Suggested-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 include/qom/cpu.h |   17 +++++++++++++++++
 1 Datei geändert, 17 Zeilen hinzugefügt(+)
Eduardo Habkost - Feb. 26, 2013, 7:32 p.m.
On Mon, Feb 25, 2013 at 07:22:48PM +0100, Andreas Färber wrote:
> This setter avoids redefining each VMStateDescription value to
> vmstate_dummy by not referencing the value for CONFIG_USER_ONLY.
> 
> Suggested-by: Juan Quintela <quintela@redhat.com>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
>  include/qom/cpu.h |   17 +++++++++++++++++
>  1 Datei geändert, 17 Zeilen hinzugefügt(+)
> 
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index 1106e39..65e24d3 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -135,6 +135,23 @@ void cpu_reset(CPUState *cpu);
>  ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model);
>  
>  /**
> + * cpu_class_set_vmsd:
> + * @cc: CPU class
> + * @value: Value to set.
> + *
> + * Sets #VMStateDescription for @cc.
> + */
> +#ifndef CONFIG_USER_ONLY
> +static inline void cpu_class_set_vmsd(CPUClass *cc,
> +                                      const struct VMStateDescription *value)
> +{
> +    cc->vmsd = value;
> +}
> +#else
> +#define cpu_class_set_vmsd(cpu, val) ((cpu)->vmsd = NULL)

Even after reading the description above, I was going to ask you why
this was not an inline function as well. But then I read patch 5/6 and
understood why.  :-)

I would add a coment here noting that "val" is actually expected to be
never evaluated when CONFIG_USER_ONLY is defined.

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


> +#endif
> +
> +/**
>   * qemu_cpu_has_work:
>   * @cpu: The vCPU to check.
>   *
> -- 
> 1.7.10.4
>
Andreas Färber - March 5, 2013, 5:10 p.m.
Am 26.02.2013 20:32, schrieb Eduardo Habkost:
> On Mon, Feb 25, 2013 at 07:22:48PM +0100, Andreas Färber wrote:
>> This setter avoids redefining each VMStateDescription value to
>> vmstate_dummy by not referencing the value for CONFIG_USER_ONLY.
>>
>> Suggested-by: Juan Quintela <quintela@redhat.com>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>> ---
>>  include/qom/cpu.h |   17 +++++++++++++++++
>>  1 Datei geändert, 17 Zeilen hinzugefügt(+)
>>
>> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
>> index 1106e39..65e24d3 100644
>> --- a/include/qom/cpu.h
>> +++ b/include/qom/cpu.h
>> @@ -135,6 +135,23 @@ void cpu_reset(CPUState *cpu);
>>  ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model);
>>  
>>  /**
>> + * cpu_class_set_vmsd:
>> + * @cc: CPU class
>> + * @value: Value to set.
>> + *
>> + * Sets #VMStateDescription for @cc.
>> + */
>> +#ifndef CONFIG_USER_ONLY
>> +static inline void cpu_class_set_vmsd(CPUClass *cc,
>> +                                      const struct VMStateDescription *value)
>> +{
>> +    cc->vmsd = value;
>> +}
>> +#else
>> +#define cpu_class_set_vmsd(cpu, val) ((cpu)->vmsd = NULL)
> 
> Even after reading the description above, I was going to ask you why
> this was not an inline function as well. But then I read patch 5/6 and
> understood why.  :-)
> 
> I would add a coment here noting that "val" is actually expected to be
> never evaluated when CONFIG_USER_ONLY is defined.

Done. I also renamed the arguments to match those of the function.

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

Thanks,
Andreas

Patch

diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 1106e39..65e24d3 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -135,6 +135,23 @@  void cpu_reset(CPUState *cpu);
 ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model);
 
 /**
+ * cpu_class_set_vmsd:
+ * @cc: CPU class
+ * @value: Value to set.
+ *
+ * Sets #VMStateDescription for @cc.
+ */
+#ifndef CONFIG_USER_ONLY
+static inline void cpu_class_set_vmsd(CPUClass *cc,
+                                      const struct VMStateDescription *value)
+{
+    cc->vmsd = value;
+}
+#else
+#define cpu_class_set_vmsd(cpu, val) ((cpu)->vmsd = NULL)
+#endif
+
+/**
  * qemu_cpu_has_work:
  * @cpu: The vCPU to check.
  *