]> git.proxmox.com Git - qemu.git/commitdiff
cpu: Introduce cpu_class_set_vmsd()
authorAndreas Färber <afaerber@suse.de>
Fri, 22 Feb 2013 20:50:10 +0000 (21:50 +0100)
committerAndreas Färber <afaerber@suse.de>
Tue, 12 Mar 2013 09:35:54 +0000 (10:35 +0100)
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>
include/qom/cpu.h

index 5b1b0d7ac41313cd9bf209b84c2cb84e86e68523..90c5f4579f9510a6a98422f1d505938f0e38a86a 100644 (file)
@@ -137,6 +137,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.