xref: /qemu/include/hw/s390x/storage-attributes.h (revision db1015e92e04835c9eb50c29625fe566d1202dbd)
1 /*
2  * s390 storage attributes device
3  *
4  * Copyright 2016 IBM Corp.
5  * Author(s): Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
6  *
7  * This work is licensed under the terms of the GNU GPL, version 2 or (at
8  * your option) any later version. See the COPYING file in the top-level
9  * directory.
10  */
11 
12 #ifndef S390_STORAGE_ATTRIBUTES_H
13 #define S390_STORAGE_ATTRIBUTES_H
14 
15 #include "hw/qdev-core.h"
16 #include "monitor/monitor.h"
17 #include "qom/object.h"
18 
19 #define TYPE_S390_STATTRIB "s390-storage_attributes"
20 #define TYPE_QEMU_S390_STATTRIB "s390-storage_attributes-qemu"
21 #define TYPE_KVM_S390_STATTRIB "s390-storage_attributes-kvm"
22 
23 typedef struct S390StAttribClass S390StAttribClass;
24 typedef struct S390StAttribState S390StAttribState;
25 #define S390_STATTRIB(obj) \
26     OBJECT_CHECK(S390StAttribState, (obj), TYPE_S390_STATTRIB)
27 
28 struct S390StAttribState {
29     DeviceState parent_obj;
30     uint64_t migration_cur_gfn;
31     bool migration_enabled;
32 };
33 
34 #define S390_STATTRIB_CLASS(klass) \
35     OBJECT_CLASS_CHECK(S390StAttribClass, (klass), TYPE_S390_STATTRIB)
36 #define S390_STATTRIB_GET_CLASS(obj) \
37     OBJECT_GET_CLASS(S390StAttribClass, (obj), TYPE_S390_STATTRIB)
38 
39 struct S390StAttribClass {
40     DeviceClass parent_class;
41     /* Return value: < 0 on error, or new count */
42     int (*get_stattr)(S390StAttribState *sa, uint64_t *start_gfn,
43                       uint32_t count, uint8_t *values);
44     int (*peek_stattr)(S390StAttribState *sa, uint64_t start_gfn,
45                        uint32_t count, uint8_t *values);
46     int (*set_stattr)(S390StAttribState *sa, uint64_t start_gfn,
47                       uint32_t count, uint8_t *values);
48     void (*synchronize)(S390StAttribState *sa);
49     int (*set_migrationmode)(S390StAttribState *sa, bool value);
50     int (*get_active)(S390StAttribState *sa);
51     long long (*get_dirtycount)(S390StAttribState *sa);
52 };
53 
54 typedef struct QEMUS390StAttribState QEMUS390StAttribState;
55 #define QEMU_S390_STATTRIB(obj) \
56     OBJECT_CHECK(QEMUS390StAttribState, (obj), TYPE_QEMU_S390_STATTRIB)
57 
58 struct QEMUS390StAttribState {
59     S390StAttribState parent_obj;
60 };
61 
62 typedef struct KVMS390StAttribState KVMS390StAttribState;
63 #define KVM_S390_STATTRIB(obj) \
64     OBJECT_CHECK(KVMS390StAttribState, (obj), TYPE_KVM_S390_STATTRIB)
65 
66 struct KVMS390StAttribState {
67     S390StAttribState parent_obj;
68     uint64_t still_dirty;
69     uint8_t *incoming_buffer;
70 };
71 
72 void s390_stattrib_init(void);
73 
74 #ifdef CONFIG_KVM
75 Object *kvm_s390_stattrib_create(void);
76 #else
77 static inline Object *kvm_s390_stattrib_create(void)
78 {
79     return NULL;
80 }
81 #endif
82 
83 void hmp_info_cmma(Monitor *mon, const QDict *qdict);
84 void hmp_migrationmode(Monitor *mon, const QDict *qdict);
85 
86 #endif /* S390_STORAGE_ATTRIBUTES_H */
87