From 107b59698f79b323c4d111c46eb9e3db6f9d258b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 28 Aug 2019 16:00:19 +0400 Subject: vmstate: add qom interface to get id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add an interface to get the instance id, instead of depending on Device and qdev_get_dev_path(). Signed-off-by: Marc-André Lureau Reviewed-by: Daniel P. Berrangé Acked-by: Dr. David Alan Gilbert --- include/hw/vmstate-if.h | 40 ++++++++++++++++++++++++++++++++++++++++ include/migration/register.h | 2 ++ include/migration/vmstate.h | 2 ++ 3 files changed, 44 insertions(+) create mode 100644 include/hw/vmstate-if.h (limited to 'include') 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 */ diff --git a/include/migration/register.h b/include/migration/register.h index a13359a08d..73149c9a01 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -14,6 +14,8 @@ #ifndef MIGRATION_REGISTER_H #define MIGRATION_REGISTER_H +#include "hw/vmstate-if.h" + typedef struct SaveVMHandlers { /* This runs inside the iothread lock. */ SaveStateHandler *save_state; diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index ac4f46a67d..f546f61c5e 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -27,6 +27,8 @@ #ifndef QEMU_VMSTATE_H #define QEMU_VMSTATE_H +#include "hw/vmstate-if.h" + typedef struct VMStateInfo VMStateInfo; typedef struct VMStateField VMStateField; -- cgit v1.2.3