summaryrefslogtreecommitdiffstats
path: root/include/hw
diff options
context:
space:
mode:
authorMarc-André Lureau2019-08-28 14:00:19 +0200
committerMarc-André Lureau2020-01-06 15:41:32 +0100
commit107b59698f79b323c4d111c46eb9e3db6f9d258b (patch)
tree45152d37afb55b46ad20bcdfc1ee792dae7438e5 /include/hw
parentMerge remote-tracking branch 'remotes/ehabkost/tags/python-next-pull-request'... (diff)
downloadqemu-107b59698f79b323c4d111c46eb9e3db6f9d258b.tar.gz
qemu-107b59698f79b323c4d111c46eb9e3db6f9d258b.tar.xz
qemu-107b59698f79b323c4d111c46eb9e3db6f9d258b.zip
vmstate: add qom interface to get id
Add an interface to get the instance id, instead of depending on Device and qdev_get_dev_path(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'include/hw')
-rw-r--r--include/hw/vmstate-if.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/include/hw/vmstate-if.h b/include/hw/vmstate-if.h
new file mode 100644
index 0000000000..8ff7f0f292
--- /dev/null
+++ b/include/hw/vmstate-if.h
@@ -0,0 +1,40 @@
+/*
+ * VMState interface
+ *
+ * Copyright (c) 2009-2019 Red Hat Inc
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef VMSTATE_IF_H
+#define VMSTATE_IF_H
+
+#include "qom/object.h"
+
+#define TYPE_VMSTATE_IF "vmstate-if"
+
+#define VMSTATE_IF_CLASS(klass) \
+ OBJECT_CLASS_CHECK(VMStateIfClass, (klass), TYPE_VMSTATE_IF)
+#define VMSTATE_IF_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(VMStateIfClass, (obj), TYPE_VMSTATE_IF)
+#define VMSTATE_IF(obj) \
+ INTERFACE_CHECK(VMStateIf, (obj), TYPE_VMSTATE_IF)
+
+typedef struct VMStateIf VMStateIf;
+
+typedef struct VMStateIfClass {
+ InterfaceClass parent_class;
+
+ char * (*get_id)(VMStateIf *obj);
+} VMStateIfClass;
+
+static inline char *vmstate_if_get_id(VMStateIf *vmif)
+{
+ if (!vmif) {
+ return NULL;
+ }
+
+ return VMSTATE_IF_GET_CLASS(vmif)->get_id(vmif);
+}
+
+#endif /* VMSTATE_IF_H */