|
22 | 22 | #include "hw/pci/pci.h"
|
23 | 23 | #include "hw/pci/pci_bridge.h"
|
24 | 24 | #include "hw/pci/pci_host.h"
|
| 25 | +#include "hw/qdev-properties.h" |
25 | 26 | #include "qemu/module.h"
|
26 | 27 | #include "hw/pci/pci_bus.h"
|
| 28 | +#include "migration/vmstate.h" |
27 | 29 | #include "trace.h"
|
28 | 30 |
|
29 | 31 | /* debug PCI */
|
@@ -200,12 +202,43 @@ const MemoryRegionOps pci_host_data_be_ops = {
|
200 | 202 | .endianness = DEVICE_BIG_ENDIAN,
|
201 | 203 | };
|
202 | 204 |
|
| 205 | +static bool pci_host_needed(void *opaque) |
| 206 | +{ |
| 207 | + PCIHostState *s = opaque; |
| 208 | + return s->mig_enabled; |
| 209 | +} |
| 210 | + |
| 211 | +const VMStateDescription vmstate_pcihost = { |
| 212 | + .name = "PCIHost", |
| 213 | + .needed = pci_host_needed, |
| 214 | + .version_id = 1, |
| 215 | + .minimum_version_id = 1, |
| 216 | + .fields = (VMStateField[]) { |
| 217 | + VMSTATE_UINT32(config_reg, PCIHostState), |
| 218 | + VMSTATE_END_OF_LIST() |
| 219 | + } |
| 220 | +}; |
| 221 | + |
| 222 | +static Property pci_host_properties_common[] = { |
| 223 | + DEFINE_PROP_BOOL("x-config-reg-migration-enabled", PCIHostState, |
| 224 | + mig_enabled, true), |
| 225 | + DEFINE_PROP_END_OF_LIST(), |
| 226 | +}; |
| 227 | + |
| 228 | +static void pci_host_class_init(ObjectClass *klass, void *data) |
| 229 | +{ |
| 230 | + DeviceClass *dc = DEVICE_CLASS(klass); |
| 231 | + device_class_set_props(dc, pci_host_properties_common); |
| 232 | + dc->vmsd = &vmstate_pcihost; |
| 233 | +} |
| 234 | + |
203 | 235 | static const TypeInfo pci_host_type_info = {
|
204 | 236 | .name = TYPE_PCI_HOST_BRIDGE,
|
205 | 237 | .parent = TYPE_SYS_BUS_DEVICE,
|
206 | 238 | .abstract = true,
|
207 | 239 | .class_size = sizeof(PCIHostBridgeClass),
|
208 | 240 | .instance_size = sizeof(PCIHostState),
|
| 241 | + .class_init = pci_host_class_init, |
209 | 242 | };
|
210 | 243 |
|
211 | 244 | static void pci_host_register_types(void)
|
|
0 commit comments