aboutsummaryrefslogtreecommitdiff
path: root/include/qom/cpu.h
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2013-02-22 21:50:10 +0100
committerAndreas Färber <afaerber@suse.de>2013-03-12 10:35:54 +0100
commitca91b15f2d2e43eba8f9a3ec5090f0a11b861ba4 (patch)
tree2d3b08d64ddf8c2fb3d82c59721aa74b63b36a59 /include/qom/cpu.h
parentb170fce3dd06372f7bfec9a780ebcb1fce6d57e4 (diff)
cpu: Introduce cpu_class_set_vmsd()
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> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'include/qom/cpu.h')
-rw-r--r--include/qom/cpu.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 5b1b0d7ac4..90c5f4579f 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -138,6 +138,27 @@ 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. Unused for %CONFIG_USER_ONLY.
+ *
+ * Sets #VMStateDescription for @cc.
+ *
+ * The @value argument is intentionally discarded for the non-softmmu targets
+ * to avoid linker errors or excessive preprocessor usage. If this behavior
+ * is undesired, you should assign #CPUState.vmsd directly instead.
+ */
+#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(cc, value) ((cc)->vmsd = NULL)
+#endif
+
+/**
* qemu_cpu_has_work:
* @cpu: The vCPU to check.
*