* Eric Blake (ebl...@redhat.com) wrote: > On 8/16/20 10:20 PM, Chuan Zheng wrote: > > Implement qmp_cal_dirty_rate()/qmp_get_dirty_rate() function which could be > > called > > > > Signed-off-by: Chuan Zheng <zhengch...@huawei.com> > > --- > > > +++ b/qapi/migration.json > > @@ -1621,3 +1621,45 @@ > > ## > > { 'event': 'UNPLUG_PRIMARY', > > 'data': { 'device-id': 'str' } } > > + > > +## > > +# @DirtyRateInfo: > > +# > > +# Information about current dirty page rate of vm. > > +# > > +# @dirty-rate: @dirtyrate describing the dirty page rate of vm > > +# in units of MB/s. > > +# If this field return '-1', it means querying is not > > +# start or not complete. > > +# > > +# @status: @status containing dirtyrate query status includes > > +# status with 'not start measuring' or > > +# 'Still measuring' or 'measured'(since 5.2) > > Missing space before ( > > > +## > > +{ 'struct': 'DirtyRateInfo', > > + 'data': {'dirty-rate': 'int64', > > + 'status': 'str'} } > > Based on your description, this should be an enum type rather than an > open-coded string. Something like: > > { 'enum': 'DirtyRateStatus', 'data': [ 'unstarted', 'measuring', 'measured' > ] } > { 'struct': 'DirtyRateInfo', 'data': { 'dirty-rate': 'int64', 'status': > 'DirtyRateStatus' } }
Yes, and if you do that I think you'll find qmp would automatically define a C enum type for you, so you don't need to define the CalculatingDirtyRateStage yourself; see how MigrationStatus works. Dave > > > + > > +## > > +# @calc-dirty-rate: > > +# > > +# start calculating dirty page rate for vm > > +# > > +# @calc-time: time in units of second for sample dirty pages > > +# > > +# Since: 5.2 > > +# > > +# Example: > > +# {"command": "cal-dirty-rate", "data": {"calc-time": 1} } > > +# > > +## > > +{ 'command': 'calc-dirty-rate', 'data': {'calc-time': 'int64'} } > > + > > +## > > +# @query-dirty-rate: > > +# > > +# query dirty page rate in units of MB/s for vm > > +# > > +# Since: 5.2 > > +## > > +{ 'command': 'query-dirty-rate', 'returns': 'DirtyRateInfo' } > > > > -- > Eric Blake, Principal Software Engineer > Red Hat, Inc. +1-919-301-3226 > Virtualization: qemu.org | libvirt.org -- Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK