Message ID | 1561041461-22326-14-git-send-email-kwankhede@nvidia.com |
---|---|
State | New |
Headers | show |
Series | Add migration support for VFIO device | expand |
* Kirti Wankhede (kwankhede@nvidia.com) wrote: > Signed-off-by: Kirti Wankhede <kwankhede@nvidia.com> > Reviewed-by: Neo Jia <cjia@nvidia.com> Thanks, adding traces really helps; however, it might be easier if you just add them in your previous patches where you're adding the functions. Dave > --- > hw/vfio/migration.c | 26 ++++++++++++++++++++++++++ > hw/vfio/trace-events | 18 ++++++++++++++++++ > 2 files changed, 44 insertions(+) > > diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c > index 68775b5dec11..70c03f1a969f 100644 > --- a/hw/vfio/migration.c > +++ b/hw/vfio/migration.c > @@ -21,6 +21,7 @@ > #include "exec/ramlist.h" > #include "exec/ram_addr.h" > #include "pci.h" > +#include "trace.h" > > /* > * Flags used as delimiter: > @@ -104,6 +105,7 @@ static int vfio_migration_set_state(VFIODevice *vbasedev, uint32_t state) > } > > vbasedev->device_state = state; > + trace_vfio_migration_set_state(vbasedev->name, state); > return 0; > } > > @@ -173,6 +175,8 @@ static int vfio_save_buffer(QEMUFile *f, VFIODevice *vbasedev) > qemu_put_be64(f, data_size); > } > > + trace_vfio_save_buffer(vbasedev->name, data_offset, data_size, > + migration->pending_bytes); > ret = qemu_file_get_error(f); > > return data_size; > @@ -195,6 +199,7 @@ static int vfio_update_pending(VFIODevice *vbasedev) > } > > migration->pending_bytes = pending_bytes; > + trace_vfio_update_pending(vbasedev->name, pending_bytes); > return 0; > } > > @@ -209,6 +214,8 @@ static int vfio_save_device_config_state(QEMUFile *f, void *opaque) > } > qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); > > + trace_vfio_save_device_config_state(vbasedev->name); > + > return qemu_file_get_error(f); > } > > @@ -225,6 +232,7 @@ static int vfio_load_device_config_state(QEMUFile *f, void *opaque) > return -EINVAL; > } > > + trace_vfio_load_device_config_state(vbasedev->name); > return qemu_file_get_error(f); > } > > @@ -343,6 +351,9 @@ void vfio_get_dirty_page_list(VFIODevice *vbasedev, > } > } while (count < pfn_count); > > + trace_vfio_get_dirty_page_list(vbasedev->name, start_pfn, pfn_count, > + page_size); > + > dpl_unlock: > qemu_mutex_unlock(&migration->lock); > } > @@ -390,6 +401,7 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) > return ret; > } > > + trace_vfio_save_setup(vbasedev->name); > return 0; > } > > @@ -401,6 +413,7 @@ static void vfio_save_cleanup(void *opaque) > if (migration->region.buffer.mmaps) { > vfio_region_unmap(&migration->region.buffer); > } > + trace_vfio_cleanup(vbasedev->name); > } > > static void vfio_save_pending(QEMUFile *f, void *opaque, > @@ -424,6 +437,7 @@ static void vfio_save_pending(QEMUFile *f, void *opaque, > *res_postcopy_only += migration->pending_bytes; > } > *res_compatible += 0; > + trace_vfio_save_pending(vbasedev->name); > } > > static int vfio_save_iterate(QEMUFile *f, void *opaque) > @@ -451,6 +465,7 @@ static int vfio_save_iterate(QEMUFile *f, void *opaque) > return ret; > } > > + trace_vfio_save_iterate(vbasedev->name); > return ret; > } > > @@ -504,6 +519,8 @@ static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) > error_report("Failed to set state STOPPED"); > return ret; > } > + > + trace_vfio_save_complete_precopy(vbasedev->name); > return ret; > } > > @@ -544,6 +561,9 @@ static int vfio_load_state(QEMUFile *f, void *opaque, int version_id) > > data = qemu_get_be64(f); > while (data != VFIO_MIG_FLAG_END_OF_STATE) { > + > + trace_vfio_load_state(vbasedev->name, data); > + > switch (data) { > case VFIO_MIG_FLAG_DEV_CONFIG_STATE: > { > @@ -627,6 +647,8 @@ static int vfio_load_state(QEMUFile *f, void *opaque, int version_id) > return -EINVAL; > } > } > + trace_vfio_load_state_device_data(vbasedev->name, data_offset, > + data_size); > break; > } > } > @@ -668,6 +690,7 @@ static void vfio_vmstate_change(void *opaque, int running, RunState state) > } > > vbasedev->vm_running = running; > + trace_vfio_vmstate_change(vbasedev->name, running); > } > > static void vfio_migration_state_notifier(Notifier *notifier, void *data) > @@ -676,6 +699,8 @@ static void vfio_migration_state_notifier(Notifier *notifier, void *data) > VFIODevice *vbasedev = container_of(notifier, VFIODevice, migration_state); > int ret; > > + trace_vfio_migration_state_notifier(vbasedev->name, s->state); > + > switch (s->state) { > case MIGRATION_STATUS_ACTIVE: > if (vbasedev->device_state & VFIO_DEVICE_STATE_RUNNING) { > @@ -758,6 +783,7 @@ int vfio_migration_probe(VFIODevice *vbasedev, Error **errp) > return ret; > } > } else { > + trace_vfio_migration_probe(vbasedev->name, info->index); > return vfio_migration_init(vbasedev, info); > } > > diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events > index 8cdc27946cb8..b1f19ae7a806 100644 > --- a/hw/vfio/trace-events > +++ b/hw/vfio/trace-events > @@ -143,3 +143,21 @@ vfio_display_edid_link_up(void) "" > vfio_display_edid_link_down(void) "" > vfio_display_edid_update(uint32_t prefx, uint32_t prefy) "%ux%u" > vfio_display_edid_write_error(void) "" > + > +# migration.c > +vfio_migration_set_state(char *name, uint32_t state) " (%s) state %d" > +vfio_save_buffer(char *name, uint64_t data_offset, uint64_t data_size, uint64_t pending) " (%s), Offset 0x%"PRIx64" size 0x%"PRIx64" pending 0x%"PRIx64 > +vfio_update_pending(char *name, uint64_t pending) " (%s), pending 0x%"PRIx64 > +vfio_save_device_config_state(char *name) " (%s)" > +vfio_load_device_config_state(char *name) " (%s)" > +vfio_get_dirty_page_list(char *name, uint64_t start, uint64_t pfn_count, uint64_t page_size) " (%s) start 0x%"PRIx64" pfn_count 0x%"PRIx64 " page size 0x%"PRIx64 > +vfio_save_setup(char *name) " (%s)" > +vfio_cleanup(char *name) " (%s)" > +vfio_save_pending(char *name) " (%s)" > +vfio_save_iterate(char *name) " (%s)" > +vfio_save_complete_precopy(char *name) " (%s)" > +vfio_load_state(char *name, uint64_t data) " (%s) data 0x%"PRIx64 > +vfio_load_state_device_data(char *name, uint64_t data_offset, uint64_t data_size) " (%s), Offset 0x%"PRIx64" size 0x%"PRIx64 > +vfio_vmstate_change(char *name, int running) " (%s) running %d" > +vfio_migration_state_notifier(char *name, int state) " (%s) state %d" > +vfio_migration_probe(char *name, uint32_t index) " (%s) Region %d" > -- > 2.7.0 > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
On 6/21/2019 12:20 AM, Dr. David Alan Gilbert wrote: > * Kirti Wankhede (kwankhede@nvidia.com) wrote: >> Signed-off-by: Kirti Wankhede <kwankhede@nvidia.com> >> Reviewed-by: Neo Jia <cjia@nvidia.com> > > Thanks, adding traces really helps; however, it might be easier > if you just add them in your previous patches where you're > adding the functions. > Ok. I'll change it. Thanks, Kirti > Dave > >> --- >> hw/vfio/migration.c | 26 ++++++++++++++++++++++++++ >> hw/vfio/trace-events | 18 ++++++++++++++++++ >> 2 files changed, 44 insertions(+) >> >> diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c >> index 68775b5dec11..70c03f1a969f 100644 >> --- a/hw/vfio/migration.c >> +++ b/hw/vfio/migration.c >> @@ -21,6 +21,7 @@ >> #include "exec/ramlist.h" >> #include "exec/ram_addr.h" >> #include "pci.h" >> +#include "trace.h" >> >> /* >> * Flags used as delimiter: >> @@ -104,6 +105,7 @@ static int vfio_migration_set_state(VFIODevice *vbasedev, uint32_t state) >> } >> >> vbasedev->device_state = state; >> + trace_vfio_migration_set_state(vbasedev->name, state); >> return 0; >> } >> >> @@ -173,6 +175,8 @@ static int vfio_save_buffer(QEMUFile *f, VFIODevice *vbasedev) >> qemu_put_be64(f, data_size); >> } >> >> + trace_vfio_save_buffer(vbasedev->name, data_offset, data_size, >> + migration->pending_bytes); >> ret = qemu_file_get_error(f); >> >> return data_size; >> @@ -195,6 +199,7 @@ static int vfio_update_pending(VFIODevice *vbasedev) >> } >> >> migration->pending_bytes = pending_bytes; >> + trace_vfio_update_pending(vbasedev->name, pending_bytes); >> return 0; >> } >> >> @@ -209,6 +214,8 @@ static int vfio_save_device_config_state(QEMUFile *f, void *opaque) >> } >> qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); >> >> + trace_vfio_save_device_config_state(vbasedev->name); >> + >> return qemu_file_get_error(f); >> } >> >> @@ -225,6 +232,7 @@ static int vfio_load_device_config_state(QEMUFile *f, void *opaque) >> return -EINVAL; >> } >> >> + trace_vfio_load_device_config_state(vbasedev->name); >> return qemu_file_get_error(f); >> } >> >> @@ -343,6 +351,9 @@ void vfio_get_dirty_page_list(VFIODevice *vbasedev, >> } >> } while (count < pfn_count); >> >> + trace_vfio_get_dirty_page_list(vbasedev->name, start_pfn, pfn_count, >> + page_size); >> + >> dpl_unlock: >> qemu_mutex_unlock(&migration->lock); >> } >> @@ -390,6 +401,7 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) >> return ret; >> } >> >> + trace_vfio_save_setup(vbasedev->name); >> return 0; >> } >> >> @@ -401,6 +413,7 @@ static void vfio_save_cleanup(void *opaque) >> if (migration->region.buffer.mmaps) { >> vfio_region_unmap(&migration->region.buffer); >> } >> + trace_vfio_cleanup(vbasedev->name); >> } >> >> static void vfio_save_pending(QEMUFile *f, void *opaque, >> @@ -424,6 +437,7 @@ static void vfio_save_pending(QEMUFile *f, void *opaque, >> *res_postcopy_only += migration->pending_bytes; >> } >> *res_compatible += 0; >> + trace_vfio_save_pending(vbasedev->name); >> } >> >> static int vfio_save_iterate(QEMUFile *f, void *opaque) >> @@ -451,6 +465,7 @@ static int vfio_save_iterate(QEMUFile *f, void *opaque) >> return ret; >> } >> >> + trace_vfio_save_iterate(vbasedev->name); >> return ret; >> } >> >> @@ -504,6 +519,8 @@ static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) >> error_report("Failed to set state STOPPED"); >> return ret; >> } >> + >> + trace_vfio_save_complete_precopy(vbasedev->name); >> return ret; >> } >> >> @@ -544,6 +561,9 @@ static int vfio_load_state(QEMUFile *f, void *opaque, int version_id) >> >> data = qemu_get_be64(f); >> while (data != VFIO_MIG_FLAG_END_OF_STATE) { >> + >> + trace_vfio_load_state(vbasedev->name, data); >> + >> switch (data) { >> case VFIO_MIG_FLAG_DEV_CONFIG_STATE: >> { >> @@ -627,6 +647,8 @@ static int vfio_load_state(QEMUFile *f, void *opaque, int version_id) >> return -EINVAL; >> } >> } >> + trace_vfio_load_state_device_data(vbasedev->name, data_offset, >> + data_size); >> break; >> } >> } >> @@ -668,6 +690,7 @@ static void vfio_vmstate_change(void *opaque, int running, RunState state) >> } >> >> vbasedev->vm_running = running; >> + trace_vfio_vmstate_change(vbasedev->name, running); >> } >> >> static void vfio_migration_state_notifier(Notifier *notifier, void *data) >> @@ -676,6 +699,8 @@ static void vfio_migration_state_notifier(Notifier *notifier, void *data) >> VFIODevice *vbasedev = container_of(notifier, VFIODevice, migration_state); >> int ret; >> >> + trace_vfio_migration_state_notifier(vbasedev->name, s->state); >> + >> switch (s->state) { >> case MIGRATION_STATUS_ACTIVE: >> if (vbasedev->device_state & VFIO_DEVICE_STATE_RUNNING) { >> @@ -758,6 +783,7 @@ int vfio_migration_probe(VFIODevice *vbasedev, Error **errp) >> return ret; >> } >> } else { >> + trace_vfio_migration_probe(vbasedev->name, info->index); >> return vfio_migration_init(vbasedev, info); >> } >> >> diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events >> index 8cdc27946cb8..b1f19ae7a806 100644 >> --- a/hw/vfio/trace-events >> +++ b/hw/vfio/trace-events >> @@ -143,3 +143,21 @@ vfio_display_edid_link_up(void) "" >> vfio_display_edid_link_down(void) "" >> vfio_display_edid_update(uint32_t prefx, uint32_t prefy) "%ux%u" >> vfio_display_edid_write_error(void) "" >> + >> +# migration.c >> +vfio_migration_set_state(char *name, uint32_t state) " (%s) state %d" >> +vfio_save_buffer(char *name, uint64_t data_offset, uint64_t data_size, uint64_t pending) " (%s), Offset 0x%"PRIx64" size 0x%"PRIx64" pending 0x%"PRIx64 >> +vfio_update_pending(char *name, uint64_t pending) " (%s), pending 0x%"PRIx64 >> +vfio_save_device_config_state(char *name) " (%s)" >> +vfio_load_device_config_state(char *name) " (%s)" >> +vfio_get_dirty_page_list(char *name, uint64_t start, uint64_t pfn_count, uint64_t page_size) " (%s) start 0x%"PRIx64" pfn_count 0x%"PRIx64 " page size 0x%"PRIx64 >> +vfio_save_setup(char *name) " (%s)" >> +vfio_cleanup(char *name) " (%s)" >> +vfio_save_pending(char *name) " (%s)" >> +vfio_save_iterate(char *name) " (%s)" >> +vfio_save_complete_precopy(char *name) " (%s)" >> +vfio_load_state(char *name, uint64_t data) " (%s) data 0x%"PRIx64 >> +vfio_load_state_device_data(char *name, uint64_t data_offset, uint64_t data_size) " (%s), Offset 0x%"PRIx64" size 0x%"PRIx64 >> +vfio_vmstate_change(char *name, int running) " (%s) running %d" >> +vfio_migration_state_notifier(char *name, int state) " (%s) state %d" >> +vfio_migration_probe(char *name, uint32_t index) " (%s) Region %d" >> -- >> 2.7.0 >> > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK >
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 68775b5dec11..70c03f1a969f 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -21,6 +21,7 @@ #include "exec/ramlist.h" #include "exec/ram_addr.h" #include "pci.h" +#include "trace.h" /* * Flags used as delimiter: @@ -104,6 +105,7 @@ static int vfio_migration_set_state(VFIODevice *vbasedev, uint32_t state) } vbasedev->device_state = state; + trace_vfio_migration_set_state(vbasedev->name, state); return 0; } @@ -173,6 +175,8 @@ static int vfio_save_buffer(QEMUFile *f, VFIODevice *vbasedev) qemu_put_be64(f, data_size); } + trace_vfio_save_buffer(vbasedev->name, data_offset, data_size, + migration->pending_bytes); ret = qemu_file_get_error(f); return data_size; @@ -195,6 +199,7 @@ static int vfio_update_pending(VFIODevice *vbasedev) } migration->pending_bytes = pending_bytes; + trace_vfio_update_pending(vbasedev->name, pending_bytes); return 0; } @@ -209,6 +214,8 @@ static int vfio_save_device_config_state(QEMUFile *f, void *opaque) } qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); + trace_vfio_save_device_config_state(vbasedev->name); + return qemu_file_get_error(f); } @@ -225,6 +232,7 @@ static int vfio_load_device_config_state(QEMUFile *f, void *opaque) return -EINVAL; } + trace_vfio_load_device_config_state(vbasedev->name); return qemu_file_get_error(f); } @@ -343,6 +351,9 @@ void vfio_get_dirty_page_list(VFIODevice *vbasedev, } } while (count < pfn_count); + trace_vfio_get_dirty_page_list(vbasedev->name, start_pfn, pfn_count, + page_size); + dpl_unlock: qemu_mutex_unlock(&migration->lock); } @@ -390,6 +401,7 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) return ret; } + trace_vfio_save_setup(vbasedev->name); return 0; } @@ -401,6 +413,7 @@ static void vfio_save_cleanup(void *opaque) if (migration->region.buffer.mmaps) { vfio_region_unmap(&migration->region.buffer); } + trace_vfio_cleanup(vbasedev->name); } static void vfio_save_pending(QEMUFile *f, void *opaque, @@ -424,6 +437,7 @@ static void vfio_save_pending(QEMUFile *f, void *opaque, *res_postcopy_only += migration->pending_bytes; } *res_compatible += 0; + trace_vfio_save_pending(vbasedev->name); } static int vfio_save_iterate(QEMUFile *f, void *opaque) @@ -451,6 +465,7 @@ static int vfio_save_iterate(QEMUFile *f, void *opaque) return ret; } + trace_vfio_save_iterate(vbasedev->name); return ret; } @@ -504,6 +519,8 @@ static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) error_report("Failed to set state STOPPED"); return ret; } + + trace_vfio_save_complete_precopy(vbasedev->name); return ret; } @@ -544,6 +561,9 @@ static int vfio_load_state(QEMUFile *f, void *opaque, int version_id) data = qemu_get_be64(f); while (data != VFIO_MIG_FLAG_END_OF_STATE) { + + trace_vfio_load_state(vbasedev->name, data); + switch (data) { case VFIO_MIG_FLAG_DEV_CONFIG_STATE: { @@ -627,6 +647,8 @@ static int vfio_load_state(QEMUFile *f, void *opaque, int version_id) return -EINVAL; } } + trace_vfio_load_state_device_data(vbasedev->name, data_offset, + data_size); break; } } @@ -668,6 +690,7 @@ static void vfio_vmstate_change(void *opaque, int running, RunState state) } vbasedev->vm_running = running; + trace_vfio_vmstate_change(vbasedev->name, running); } static void vfio_migration_state_notifier(Notifier *notifier, void *data) @@ -676,6 +699,8 @@ static void vfio_migration_state_notifier(Notifier *notifier, void *data) VFIODevice *vbasedev = container_of(notifier, VFIODevice, migration_state); int ret; + trace_vfio_migration_state_notifier(vbasedev->name, s->state); + switch (s->state) { case MIGRATION_STATUS_ACTIVE: if (vbasedev->device_state & VFIO_DEVICE_STATE_RUNNING) { @@ -758,6 +783,7 @@ int vfio_migration_probe(VFIODevice *vbasedev, Error **errp) return ret; } } else { + trace_vfio_migration_probe(vbasedev->name, info->index); return vfio_migration_init(vbasedev, info); } diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 8cdc27946cb8..b1f19ae7a806 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -143,3 +143,21 @@ vfio_display_edid_link_up(void) "" vfio_display_edid_link_down(void) "" vfio_display_edid_update(uint32_t prefx, uint32_t prefy) "%ux%u" vfio_display_edid_write_error(void) "" + +# migration.c +vfio_migration_set_state(char *name, uint32_t state) " (%s) state %d" +vfio_save_buffer(char *name, uint64_t data_offset, uint64_t data_size, uint64_t pending) " (%s), Offset 0x%"PRIx64" size 0x%"PRIx64" pending 0x%"PRIx64 +vfio_update_pending(char *name, uint64_t pending) " (%s), pending 0x%"PRIx64 +vfio_save_device_config_state(char *name) " (%s)" +vfio_load_device_config_state(char *name) " (%s)" +vfio_get_dirty_page_list(char *name, uint64_t start, uint64_t pfn_count, uint64_t page_size) " (%s) start 0x%"PRIx64" pfn_count 0x%"PRIx64 " page size 0x%"PRIx64 +vfio_save_setup(char *name) " (%s)" +vfio_cleanup(char *name) " (%s)" +vfio_save_pending(char *name) " (%s)" +vfio_save_iterate(char *name) " (%s)" +vfio_save_complete_precopy(char *name) " (%s)" +vfio_load_state(char *name, uint64_t data) " (%s) data 0x%"PRIx64 +vfio_load_state_device_data(char *name, uint64_t data_offset, uint64_t data_size) " (%s), Offset 0x%"PRIx64" size 0x%"PRIx64 +vfio_vmstate_change(char *name, int running) " (%s) running %d" +vfio_migration_state_notifier(char *name, int state) " (%s) state %d" +vfio_migration_probe(char *name, uint32_t index) " (%s) Region %d"