Re: [PATCH v6 7/8] virsh: Add mode option to domdirtyrate-calc virsh api
在 2022/2/21 20:34, Michal Prívozník 写道: On 2/20/22 14:28, huang...@chinatelecom.cn wrote: From: Hyman Huang(黄勇) Extend domdirtyrate-calc virsh api with mode option, either of these three options "page-sampling,dirty-bitmap,dirty-ring" can be specified when calculating dirty page rate. Signed-off-by: Hyman Huang(黄勇) --- docs/manpages/virsh.rst| 7 +-- src/libvirt-domain.c | 12 +++- tools/virsh-completer-domain.c | 17 + tools/virsh-completer-domain.h | 4 tools/virsh-domain.c | 42 +- tools/virsh-domain.h | 9 + 6 files changed, 87 insertions(+), 4 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 429879d..00d21a1 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -1717,13 +1717,16 @@ domdirtyrate-calc :: domdirtyrate-calc [--seconds ] + --mode=[page-sampling | dirty-bitmap | dirty-ring] Calculate an active domain's memory dirty rate which may be expected by user in order to decide whether it's proper to be migrated out or not. The ``seconds`` parameter can be used to calculate dirty rate in a specific time which allows 60s at most now and would be default to 1s -if missing. The calculated dirty rate information is available by calling -'domstats --dirtyrate'. +if missing. These three *page-sampling, dirty-bitmap, dirty-ring* modes +are mutually exclusive and alternative when specify calculation mode, +*page-sampling* is the default mode if missing. The calculated dirty +rate information is available by calling 'domstats --dirtyrate'. domdisplay diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 8be2c21..7be4e02 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -13337,7 +13337,7 @@ virDomainGetMessages(virDomainPtr domain, * virDomainStartDirtyRateCalc: * @domain: a domain object * @seconds: specified calculating time in seconds - * @flags: extra flags; not used yet, so callers should always pass 0 + * @flags: bitwise-OR of supported virDomainDirtyRateCalcFlags * * Calculate the current domain's memory dirty rate in next @seconds
Re: [PATCH v6 7/8] virsh: Add mode option to domdirtyrate-calc virsh api
On 2/20/22 14:28, huang...@chinatelecom.cn wrote: > From: Hyman Huang(黄勇) > > Extend domdirtyrate-calc virsh api with mode option, either > of these three options "page-sampling,dirty-bitmap,dirty-ring" > can be specified when calculating dirty page rate. > > Signed-off-by: Hyman Huang(黄勇) > --- > docs/manpages/virsh.rst| 7 +-- > src/libvirt-domain.c | 12 +++- > tools/virsh-completer-domain.c | 17 + > tools/virsh-completer-domain.h | 4 > tools/virsh-domain.c | 42 > +- > tools/virsh-domain.h | 9 + > 6 files changed, 87 insertions(+), 4 deletions(-) > > diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst > index 429879d..00d21a1 100644 > --- a/docs/manpages/virsh.rst > +++ b/docs/manpages/virsh.rst > @@ -1717,13 +1717,16 @@ domdirtyrate-calc > :: > > domdirtyrate-calc [--seconds ] > + --mode=[page-sampling | dirty-bitmap | dirty-ring] > > Calculate an active domain's memory dirty rate which may be expected by > user in order to decide whether it's proper to be migrated out or not. > The ``seconds`` parameter can be used to calculate dirty rate in a > specific time which allows 60s at most now and would be default to 1s > -if missing. The calculated dirty rate information is available by calling > -'domstats --dirtyrate'. > +if missing. These three *page-sampling, dirty-bitmap, dirty-ring* modes > +are mutually exclusive and alternative when specify calculation mode, > +*page-sampling* is the default mode if missing. The calculated dirty > +rate information is available by calling 'domstats --dirtyrate'. > > > domdisplay > diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c > index 8be2c21..7be4e02 100644 > --- a/src/libvirt-domain.c > +++ b/src/libvirt-domain.c > @@ -13337,7 +13337,7 @@ virDomainGetMessages(virDomainPtr domain, > * virDomainStartDirtyRateCalc: > * @domain: a domain object > * @seconds: specified calculating time in seconds > - * @flags: extra flags; not used yet, so callers should always pass 0 > + * @flags: bitwise-OR of supported virDomainDirtyRateCalcFlags > * > * Calculate the current domain's memory dirty rate in next @seconds. > * The calculated dirty rate information is available by calling > @@ -13361,6 +13361,16 @@ virDomainStartDirtyRateCalc(virDomainPtr domain, > > virCheckReadOnlyGoto(conn->flags, error); > > +VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING, > + VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP, > + error); > +VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING, > + VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING, > + error); > +VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP, > + VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING, > + error); > + > if (conn->driver->domainStartDirtyRateCalc) { > int ret; > ret = conn->driver->domainStartDirtyRateCalc(domain, seconds, flags); > diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c > index b4e744c..1c2df56 100644 > --- a/tools/virsh-completer-domain.c > +++ b/tools/virsh-completer-domain.c > @@ -1150,3 +1150,20 @@ virshDomainNumatuneModeCompleter(vshControl *ctl > G_GNUC_UNUSED, > > return ret; > } > + > + > +char ** > +virshDomainDirtyRateCalcModeCompleter(vshControl *ctl, > + const vshCmd *cmd, > + unsigned int flags) > +{ > +const char *modes[] = {"page-sampling", "dirty-bitmap", "dirty-ring", > NULL}; > +const char *mode = NULL; > + > +virCheckFlags(0, NULL); > + > +if (vshCommandOptStringQuiet(ctl, cmd, "mode", &mode) < 0) > +return NULL; > + > +return virshCommaStringListComplete(mode, modes); No, the --mode argument supports only one value. It doesn't support --mode page-sampling,dirty-bitmap,dirty-ring. > +} > diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h > index 94bb3b5..044c675 100644 > --- a/tools/virsh-completer-domain.h > +++ b/tools/virsh-completer-domain.h > @@ -186,3 +186,7 @@ char ** > virshDomainNumatuneModeCompleter(vshControl *ctl, > const vshCmd *cmd, > unsigned int flags); > +char ** > +virshDomainDirtyRateCalcModeCompleter(vshControl *ctl, > + const vshCmd *cmd, > + unsigned int flags); > diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c > index 433ea67..256258b 100644 > --- a/tools/virsh-domain.c > +++ b/tools/virsh-domain.c > @@ -14486,14 +14486,28 @@ static const vshCmdOptDef opts_domdirtyrate_calc[] > = { > .help = N_("calculate memory dirty rate within specified seco
[PATCH v6 7/8] virsh: Add mode option to domdirtyrate-calc virsh api
From: Hyman Huang(黄勇) Extend domdirtyrate-calc virsh api with mode option, either of these three options "page-sampling,dirty-bitmap,dirty-ring" can be specified when calculating dirty page rate. Signed-off-by: Hyman Huang(黄勇) --- docs/manpages/virsh.rst| 7 +-- src/libvirt-domain.c | 12 +++- tools/virsh-completer-domain.c | 17 + tools/virsh-completer-domain.h | 4 tools/virsh-domain.c | 42 +- tools/virsh-domain.h | 9 + 6 files changed, 87 insertions(+), 4 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 429879d..00d21a1 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -1717,13 +1717,16 @@ domdirtyrate-calc :: domdirtyrate-calc [--seconds ] + --mode=[page-sampling | dirty-bitmap | dirty-ring] Calculate an active domain's memory dirty rate which may be expected by user in order to decide whether it's proper to be migrated out or not. The ``seconds`` parameter can be used to calculate dirty rate in a specific time which allows 60s at most now and would be default to 1s -if missing. The calculated dirty rate information is available by calling -'domstats --dirtyrate'. +if missing. These three *page-sampling, dirty-bitmap, dirty-ring* modes +are mutually exclusive and alternative when specify calculation mode, +*page-sampling* is the default mode if missing. The calculated dirty +rate information is available by calling 'domstats --dirtyrate'. domdisplay diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 8be2c21..7be4e02 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -13337,7 +13337,7 @@ virDomainGetMessages(virDomainPtr domain, * virDomainStartDirtyRateCalc: * @domain: a domain object * @seconds: specified calculating time in seconds - * @flags: extra flags; not used yet, so callers should always pass 0 + * @flags: bitwise-OR of supported virDomainDirtyRateCalcFlags * * Calculate the current domain's memory dirty rate in next @seconds. * The calculated dirty rate information is available by calling @@ -13361,6 +13361,16 @@ virDomainStartDirtyRateCalc(virDomainPtr domain, virCheckReadOnlyGoto(conn->flags, error); +VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING, + VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP, + error); +VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING, + VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING, + error); +VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP, + VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING, + error); + if (conn->driver->domainStartDirtyRateCalc) { int ret; ret = conn->driver->domainStartDirtyRateCalc(domain, seconds, flags); diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index b4e744c..1c2df56 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -1150,3 +1150,20 @@ virshDomainNumatuneModeCompleter(vshControl *ctl G_GNUC_UNUSED, return ret; } + + +char ** +virshDomainDirtyRateCalcModeCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags) +{ +const char *modes[] = {"page-sampling", "dirty-bitmap", "dirty-ring", NULL}; +const char *mode = NULL; + +virCheckFlags(0, NULL); + +if (vshCommandOptStringQuiet(ctl, cmd, "mode", &mode) < 0) +return NULL; + +return virshCommaStringListComplete(mode, modes); +} diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h index 94bb3b5..044c675 100644 --- a/tools/virsh-completer-domain.h +++ b/tools/virsh-completer-domain.h @@ -186,3 +186,7 @@ char ** virshDomainNumatuneModeCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); +char ** +virshDomainDirtyRateCalcModeCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 433ea67..256258b 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -14486,14 +14486,28 @@ static const vshCmdOptDef opts_domdirtyrate_calc[] = { .help = N_("calculate memory dirty rate within specified seconds, " "the supported value range from 1 to 60, default to 1.") }, +{.name = "mode", + .type = VSH_OT_STRING, + .completer = virshDomainDirtyRateCalcModeCompleter, + .help = N_("dirty page rate calculation mode, either of these 3 options " +"'page-sampling,dirty-bitmap,dirty-ring' can be specified.") +}, {.name = NULL} }; +VIR_ENUM_