vfio: Add struct vfio_vmstate_info to introduce vfio device put/get funtion
RFC 2/5 vfio: Add struct vfio_vmstate_info to introduce vfio device put/get funtion
Introduce vfio_device_put/vfio_device_get funtion for vfio device state save/restore usage. And vfio device unmigratable flag will be set to false during initialization if device flag VFIO_DEVICE_FLAGS_MIGRATABLE is set.
Signed-off-by Yulei Zhang <[email protected]>
--- hw/vfio/pci.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
hw/vfio/pci.c +34 -1
@@ -37,6 +37,7 @@static void vfio_disable_interrupts (VFIOPCIDevice *vdev);static void vfio_mmap_set_enabled (VFIOPCIDevice *vdev,bool enabled); +static VMStateDescription vfio_pci_vmstate;/* * Disabling BAR mmaping can be slow, but toggling it around INTx can
@@ -2375,6 +2376,7 @@ static void vfio_populate_device(VFIOPCIDevice *vdev, Error **errp) }QLIST_INIT (&vdev->device_state.quirks); + vfio_pci_vmstate.unmigratable =0 ; } ret = vfio_get_region_info(vbasedev,
@@ -2946,6 +2948,17 @@ post_reset:vfio_pci_post_reset (vdev); } +static int vfio_device_put (QEMUFile *f,void *pv,size_t size,VMStateField *field, +QJSON *vmdesc) +{ +return 0 ; +} + +static int vfio_device_get (QEMUFile *f,void *pv,size_t size,VMStateField *field) +{ +return 0 ; +} +static void vfio_instance_init (Object *obj) {PCIDevice *pci_dev =PCI_DEVICE (obj);
@@ -2990,9 +3003,29 @@ static Property vfio_pci_dev_properties[] = { DEFINE_PROP_END_OF_LIST(), }; -static const VMStateDescription vfio_pci_vmstate = { +static VMStateInfo vfio_vmstate_info = { + .name ="vfio-state" , + .get = vfio_device_get, + .put = vfio_device_put, +}; + +static VMStateDescription vfio_pci_vmstate = { .name ="vfio-pci" , .unmigratable =1 , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { + { + .name ="vfio dev" , + .version_id =0 , + .field_exists =NULL , + .size =0 , + .info = &vfio_vmstate_info, + .flags =VMS_SINGLE , + .offset =0 , + }, +VMSTATE_END_OF_LIST () + }, };static void vfio_pci_dev_class_init (ObjectClass *klass,void *data)
Signature · 1 line
2.7.4