Message ID | 20220512154320.19697-3-avihaih@nvidia.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | vfio/migration: Implement VFIO migration protocol v2 | expand |
On Thu, 12 May 2022 18:43:13 +0300 Avihai Horon <avihaih@nvidia.com> wrote: > VFIO migration protocol v1 was deprecated and as part of it some of the > uAPI definitions were renamed. This caused compilation errors. > Fix them. > > Signed-off-by: Avihai Horon <avihaih@nvidia.com> > --- > hw/vfio/common.c | 6 +++--- > hw/vfio/migration.c | 29 ++++++++++++++++------------- > 2 files changed, 19 insertions(+), 16 deletions(-) > > diff --git a/hw/vfio/common.c b/hw/vfio/common.c > index 159f910421..29982c7af8 100644 > --- a/hw/vfio/common.c > +++ b/hw/vfio/common.c > @@ -355,7 +355,7 @@ static bool vfio_devices_all_dirty_tracking(VFIOContainer *container) > } > > if ((vbasedev->pre_copy_dirty_page_tracking == ON_OFF_AUTO_OFF) > - && (migration->device_state & VFIO_DEVICE_STATE_RUNNING)) { > + && (migration->device_state & VFIO_DEVICE_STATE_V1_RUNNING)) { > return false; > } > } > @@ -381,8 +381,8 @@ static bool vfio_devices_all_running_and_saving(VFIOContainer *container) > return false; > } > > - if ((migration->device_state & VFIO_DEVICE_STATE_SAVING) && > - (migration->device_state & VFIO_DEVICE_STATE_RUNNING)) { > + if ((migration->device_state & VFIO_DEVICE_STATE_V1_SAVING) && > + (migration->device_state & VFIO_DEVICE_STATE_V1_RUNNING)) { > continue; > } else { > return false; > diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c > index ff6b45de6b..835608cd23 100644 > --- a/hw/vfio/migration.c > +++ b/hw/vfio/migration.c > @@ -432,7 +432,7 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) > } > > ret = vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_MASK, > - VFIO_DEVICE_STATE_SAVING); > + VFIO_DEVICE_STATE_V1_SAVING); > if (ret) { > error_report("%s: Failed to set state SAVING", vbasedev->name); > return ret; > @@ -531,8 +531,8 @@ static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) > uint64_t data_size; > int ret; > > - ret = vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_RUNNING, > - VFIO_DEVICE_STATE_SAVING); > + ret = vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_V1_RUNNING, > + VFIO_DEVICE_STATE_V1_SAVING); > if (ret) { > error_report("%s: Failed to set state STOP and SAVING", > vbasedev->name); > @@ -569,7 +569,7 @@ static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) > return ret; > } > > - ret = vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_SAVING, 0); > + ret = vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_V1_SAVING, 0); > if (ret) { > error_report("%s: Failed to set state STOPPED", vbasedev->name); > return ret; > @@ -609,7 +609,7 @@ static int vfio_load_setup(QEMUFile *f, void *opaque) > } > > ret = vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_MASK, > - VFIO_DEVICE_STATE_RESUMING); > + VFIO_DEVICE_STATE_V1_RESUMING); > if (ret) { > error_report("%s: Failed to set state RESUMING", vbasedev->name); > if (migration->region.mmaps) { > @@ -717,20 +717,20 @@ static void vfio_vmstate_change(void *opaque, bool running, RunState state) > * In both the above cases, set _RUNNING bit. > */ > mask = ~VFIO_DEVICE_STATE_MASK; > - value = VFIO_DEVICE_STATE_RUNNING; > + value = VFIO_DEVICE_STATE_V1_RUNNING; > } else { > /* > * Here device state could be either _RUNNING or _SAVING|_RUNNING. Reset > * _RUNNING bit > */ > - mask = ~VFIO_DEVICE_STATE_RUNNING; > + mask = ~VFIO_DEVICE_STATE_V1_RUNNING; > > /* > * When VM state transition to stop for savevm command, device should > * start saving data. > */ > if (state == RUN_STATE_SAVE_VM) { > - value = VFIO_DEVICE_STATE_SAVING; > + value = VFIO_DEVICE_STATE_V1_SAVING; > } else { > value = 0; > } > @@ -767,9 +767,10 @@ static void vfio_migration_state_notifier(Notifier *notifier, void *data) > case MIGRATION_STATUS_CANCELLED: > case MIGRATION_STATUS_FAILED: > bytes_transferred = 0; > - ret = vfio_migration_set_state(vbasedev, > - ~(VFIO_DEVICE_STATE_SAVING | VFIO_DEVICE_STATE_RESUMING), > - VFIO_DEVICE_STATE_RUNNING); > + ret = vfio_migration_set_state( > + vbasedev, > + ~(VFIO_DEVICE_STATE_V1_SAVING | VFIO_DEVICE_STATE_V1_RESUMING), > + VFIO_DEVICE_STATE_V1_RUNNING); Yikes! Please follow the line wrapping used elsewhere. There's no need to put the first arg on a new line and subsequent wrapped lines should be indented to match the previous line, or at least to avoid wrapping itself. Here we can use something like: ret = vfio_migration_set_state(vbasedev, ~(VFIO_DEVICE_STATE_V1_SAVING | VFIO_DEVICE_STATE_V1_RESUMING), VFIO_DEVICE_STATE_V1_RUNNING); Thanks, Alex > if (ret) { > error_report("%s: Failed to set state RUNNING", vbasedev->name); > } > @@ -864,8 +865,10 @@ int vfio_migration_probe(VFIODevice *vbasedev, Error **errp) > goto add_blocker; > } > > - ret = vfio_get_dev_region_info(vbasedev, VFIO_REGION_TYPE_MIGRATION, > - VFIO_REGION_SUBTYPE_MIGRATION, &info); > + ret = vfio_get_dev_region_info(vbasedev, > + VFIO_REGION_TYPE_MIGRATION_DEPRECATED, > + VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATED, > + &info); > if (ret) { > goto add_blocker; > }
On Thu, May 12, 2022 at 11:57:10AM -0600, Alex Williamson wrote: > > @@ -767,9 +767,10 @@ static void vfio_migration_state_notifier(Notifier *notifier, void *data) > > case MIGRATION_STATUS_CANCELLED: > > case MIGRATION_STATUS_FAILED: > > bytes_transferred = 0; > > - ret = vfio_migration_set_state(vbasedev, > > - ~(VFIO_DEVICE_STATE_SAVING | VFIO_DEVICE_STATE_RESUMING), > > - VFIO_DEVICE_STATE_RUNNING); > > + ret = vfio_migration_set_state( > > + vbasedev, > > + ~(VFIO_DEVICE_STATE_V1_SAVING | VFIO_DEVICE_STATE_V1_RESUMING), > > + VFIO_DEVICE_STATE_V1_RUNNING); > > Yikes! Please follow the line wrapping used elsewhere. There's no need > to put the first arg on a new line and subsequent wrapped lines should > be indented to match the previous line, or at least to avoid wrapping > itself. Here we can use something like: This is generated by clang-format with one of the qmeu styles, it follows the documented guide: In case of function, there are several variants: - 4 spaces indent from the beginning - align the secondary lines just after the opening parenthesis of the first clang-format selected the first option due to its optimization algorithm. Knowing nothing about qmeu, I am confused?? Jason
On Thu, 12 May 2022 15:25:32 -0300 Jason Gunthorpe <jgg@nvidia.com> wrote: > On Thu, May 12, 2022 at 11:57:10AM -0600, Alex Williamson wrote: > > > @@ -767,9 +767,10 @@ static void vfio_migration_state_notifier(Notifier *notifier, void *data) > > > case MIGRATION_STATUS_CANCELLED: > > > case MIGRATION_STATUS_FAILED: > > > bytes_transferred = 0; > > > - ret = vfio_migration_set_state(vbasedev, > > > - ~(VFIO_DEVICE_STATE_SAVING | VFIO_DEVICE_STATE_RESUMING), > > > - VFIO_DEVICE_STATE_RUNNING); > > > + ret = vfio_migration_set_state( > > > + vbasedev, > > > + ~(VFIO_DEVICE_STATE_V1_SAVING | VFIO_DEVICE_STATE_V1_RESUMING), > > > + VFIO_DEVICE_STATE_V1_RUNNING); > > > > Yikes! Please follow the line wrapping used elsewhere. There's no need > > to put the first arg on a new line and subsequent wrapped lines should > > be indented to match the previous line, or at least to avoid wrapping > > itself. Here we can use something like: > > This is generated by clang-format with one of the qmeu styles, it > follows the documented guide: > > In case of function, there are several variants: > > - 4 spaces indent from the beginning > - align the secondary lines just after the opening parenthesis of the > first > > clang-format selected the first option due to its optimization > algorithm. > > Knowing nothing about qmeu, I am confused?? Maybe someone needs to throw more AI models at clang-format so that it considers the more readable option? QEMU does a lot wrong with style imo, and maybe it's technically compliant as written, but I think what I proposed is also compliant, as well as more readable and more consistent with the existing file. Thanks, Alex
On Thu, May 12, 2022 at 03:11:40PM -0600, Alex Williamson wrote: > On Thu, 12 May 2022 15:25:32 -0300 > Jason Gunthorpe <jgg@nvidia.com> wrote: > > > On Thu, May 12, 2022 at 11:57:10AM -0600, Alex Williamson wrote: > > > > @@ -767,9 +767,10 @@ static void vfio_migration_state_notifier(Notifier *notifier, void *data) > > > > case MIGRATION_STATUS_CANCELLED: > > > > case MIGRATION_STATUS_FAILED: > > > > bytes_transferred = 0; > > > > - ret = vfio_migration_set_state(vbasedev, > > > > - ~(VFIO_DEVICE_STATE_SAVING | VFIO_DEVICE_STATE_RESUMING), > > > > - VFIO_DEVICE_STATE_RUNNING); > > > > + ret = vfio_migration_set_state( > > > > + vbasedev, > > > > + ~(VFIO_DEVICE_STATE_V1_SAVING | VFIO_DEVICE_STATE_V1_RESUMING), > > > > + VFIO_DEVICE_STATE_V1_RUNNING); > > > > > > Yikes! Please follow the line wrapping used elsewhere. There's no need > > > to put the first arg on a new line and subsequent wrapped lines should > > > be indented to match the previous line, or at least to avoid wrapping > > > itself. Here we can use something like: > > > > This is generated by clang-format with one of the qmeu styles, it > > follows the documented guide: > > > > In case of function, there are several variants: > > > > - 4 spaces indent from the beginning > > - align the secondary lines just after the opening parenthesis of the > > first > > > > clang-format selected the first option due to its optimization > > algorithm. > > > > Knowing nothing about qmeu, I am confused?? > > Maybe someone needs to throw more AI models at clang-format so that it > considers the more readable option? QEMU does a lot wrong with style > imo, and maybe it's technically compliant as written, but I think what > I proposed is also compliant, as well as more readable and more > consistent with the existing file. Thanks, Let Avihai know any indenting you don't like he will fix it. IIRC clang scores line-breaking an expression as worse than going to the smaller indent. Personally I would agree with this. Thanks, Jason
On Thu, May 12 2022, Alex Williamson <alex.williamson@redhat.com> wrote: > On Thu, 12 May 2022 18:43:13 +0300 > Avihai Horon <avihaih@nvidia.com> wrote: > >> @@ -767,9 +767,10 @@ static void vfio_migration_state_notifier(Notifier *notifier, void *data) >> case MIGRATION_STATUS_CANCELLED: >> case MIGRATION_STATUS_FAILED: >> bytes_transferred = 0; >> - ret = vfio_migration_set_state(vbasedev, >> - ~(VFIO_DEVICE_STATE_SAVING | VFIO_DEVICE_STATE_RESUMING), >> - VFIO_DEVICE_STATE_RUNNING); >> + ret = vfio_migration_set_state( >> + vbasedev, >> + ~(VFIO_DEVICE_STATE_V1_SAVING | VFIO_DEVICE_STATE_V1_RESUMING), >> + VFIO_DEVICE_STATE_V1_RUNNING); > > Yikes! Please follow the line wrapping used elsewhere. There's no need > to put the first arg on a new line and subsequent wrapped lines should > be indented to match the previous line, or at least to avoid wrapping > itself. Here we can use something like: > > ret = vfio_migration_set_state(vbasedev, > ~(VFIO_DEVICE_STATE_V1_SAVING | > VFIO_DEVICE_STATE_V1_RESUMING), > VFIO_DEVICE_STATE_V1_RUNNING); FWIW, I'd prefer this variant as well.
diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 159f910421..29982c7af8 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -355,7 +355,7 @@ static bool vfio_devices_all_dirty_tracking(VFIOContainer *container) } if ((vbasedev->pre_copy_dirty_page_tracking == ON_OFF_AUTO_OFF) - && (migration->device_state & VFIO_DEVICE_STATE_RUNNING)) { + && (migration->device_state & VFIO_DEVICE_STATE_V1_RUNNING)) { return false; } } @@ -381,8 +381,8 @@ static bool vfio_devices_all_running_and_saving(VFIOContainer *container) return false; } - if ((migration->device_state & VFIO_DEVICE_STATE_SAVING) && - (migration->device_state & VFIO_DEVICE_STATE_RUNNING)) { + if ((migration->device_state & VFIO_DEVICE_STATE_V1_SAVING) && + (migration->device_state & VFIO_DEVICE_STATE_V1_RUNNING)) { continue; } else { return false; diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index ff6b45de6b..835608cd23 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -432,7 +432,7 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) } ret = vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_MASK, - VFIO_DEVICE_STATE_SAVING); + VFIO_DEVICE_STATE_V1_SAVING); if (ret) { error_report("%s: Failed to set state SAVING", vbasedev->name); return ret; @@ -531,8 +531,8 @@ static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) uint64_t data_size; int ret; - ret = vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_RUNNING, - VFIO_DEVICE_STATE_SAVING); + ret = vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_V1_RUNNING, + VFIO_DEVICE_STATE_V1_SAVING); if (ret) { error_report("%s: Failed to set state STOP and SAVING", vbasedev->name); @@ -569,7 +569,7 @@ static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) return ret; } - ret = vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_SAVING, 0); + ret = vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_V1_SAVING, 0); if (ret) { error_report("%s: Failed to set state STOPPED", vbasedev->name); return ret; @@ -609,7 +609,7 @@ static int vfio_load_setup(QEMUFile *f, void *opaque) } ret = vfio_migration_set_state(vbasedev, ~VFIO_DEVICE_STATE_MASK, - VFIO_DEVICE_STATE_RESUMING); + VFIO_DEVICE_STATE_V1_RESUMING); if (ret) { error_report("%s: Failed to set state RESUMING", vbasedev->name); if (migration->region.mmaps) { @@ -717,20 +717,20 @@ static void vfio_vmstate_change(void *opaque, bool running, RunState state) * In both the above cases, set _RUNNING bit. */ mask = ~VFIO_DEVICE_STATE_MASK; - value = VFIO_DEVICE_STATE_RUNNING; + value = VFIO_DEVICE_STATE_V1_RUNNING; } else { /* * Here device state could be either _RUNNING or _SAVING|_RUNNING. Reset * _RUNNING bit */ - mask = ~VFIO_DEVICE_STATE_RUNNING; + mask = ~VFIO_DEVICE_STATE_V1_RUNNING; /* * When VM state transition to stop for savevm command, device should * start saving data. */ if (state == RUN_STATE_SAVE_VM) { - value = VFIO_DEVICE_STATE_SAVING; + value = VFIO_DEVICE_STATE_V1_SAVING; } else { value = 0; } @@ -767,9 +767,10 @@ static void vfio_migration_state_notifier(Notifier *notifier, void *data) case MIGRATION_STATUS_CANCELLED: case MIGRATION_STATUS_FAILED: bytes_transferred = 0; - ret = vfio_migration_set_state(vbasedev, - ~(VFIO_DEVICE_STATE_SAVING | VFIO_DEVICE_STATE_RESUMING), - VFIO_DEVICE_STATE_RUNNING); + ret = vfio_migration_set_state( + vbasedev, + ~(VFIO_DEVICE_STATE_V1_SAVING | VFIO_DEVICE_STATE_V1_RESUMING), + VFIO_DEVICE_STATE_V1_RUNNING); if (ret) { error_report("%s: Failed to set state RUNNING", vbasedev->name); } @@ -864,8 +865,10 @@ int vfio_migration_probe(VFIODevice *vbasedev, Error **errp) goto add_blocker; } - ret = vfio_get_dev_region_info(vbasedev, VFIO_REGION_TYPE_MIGRATION, - VFIO_REGION_SUBTYPE_MIGRATION, &info); + ret = vfio_get_dev_region_info(vbasedev, + VFIO_REGION_TYPE_MIGRATION_DEPRECATED, + VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATED, + &info); if (ret) { goto add_blocker; }
VFIO migration protocol v1 was deprecated and as part of it some of the uAPI definitions were renamed. This caused compilation errors. Fix them. Signed-off-by: Avihai Horon <avihaih@nvidia.com> --- hw/vfio/common.c | 6 +++--- hw/vfio/migration.c | 29 ++++++++++++++++------------- 2 files changed, 19 insertions(+), 16 deletions(-)