Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
8 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#include "qemu/osdep.h" | ||
#include "hw/vmstate-if.h" | ||
|
||
static const TypeInfo vmstate_if_info = { | ||
.name = TYPE_VMSTATE_IF, | ||
.parent = TYPE_INTERFACE, | ||
.class_size = sizeof(VMStateIfClass), | ||
}; | ||
|
||
static void vmstate_register_types(void) | ||
{ | ||
type_register_static(&vmstate_if_info); | ||
} | ||
|
||
type_init(vmstate_register_types); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters