mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
virsh: Add mode option to domdirtyrate-calc virsh api
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(黄勇) <huangy81@chinatelecom.cn> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
b4b1ec6f73
commit
72e60ddf1b
@ -1717,13 +1717,16 @@ domdirtyrate-calc
|
|||||||
::
|
::
|
||||||
|
|
||||||
domdirtyrate-calc <domain> [--seconds <sec>]
|
domdirtyrate-calc <domain> [--seconds <sec>]
|
||||||
|
--mode=[page-sampling | dirty-bitmap | dirty-ring]
|
||||||
|
|
||||||
Calculate an active domain's memory dirty rate which may be expected by
|
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.
|
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
|
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
|
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
|
if missing. These three *page-sampling, dirty-bitmap, dirty-ring* modes
|
||||||
'domstats --dirtyrate'.
|
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
|
domdisplay
|
||||||
|
@ -1150,3 +1150,22 @@ virshDomainNumatuneModeCompleter(vshControl *ctl G_GNUC_UNUSED,
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char **
|
||||||
|
virshDomainDirtyRateCalcModeCompleter(vshControl *ctl G_GNUC_UNUSED,
|
||||||
|
const vshCmd *cmd G_GNUC_UNUSED,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
char **ret = NULL;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
|
ret = g_new0(char *, VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_LAST + 1);
|
||||||
|
|
||||||
|
for (i = 0; i < VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_LAST; i++)
|
||||||
|
ret[i] = g_strdup(virshDomainDirtyRateCalcModeTypeToString(i));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -186,3 +186,7 @@ char **
|
|||||||
virshDomainNumatuneModeCompleter(vshControl *ctl,
|
virshDomainNumatuneModeCompleter(vshControl *ctl,
|
||||||
const vshCmd *cmd,
|
const vshCmd *cmd,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
char **
|
||||||
|
virshDomainDirtyRateCalcModeCompleter(vshControl *ctl,
|
||||||
|
const vshCmd *cmd,
|
||||||
|
unsigned int flags);
|
||||||
|
@ -14486,14 +14486,28 @@ static const vshCmdOptDef opts_domdirtyrate_calc[] = {
|
|||||||
.help = N_("calculate memory dirty rate within specified seconds, "
|
.help = N_("calculate memory dirty rate within specified seconds, "
|
||||||
"the supported value range from 1 to 60, default to 1.")
|
"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}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
VIR_ENUM_IMPL(virshDomainDirtyRateCalcMode,
|
||||||
|
VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_LAST,
|
||||||
|
"page-sampling",
|
||||||
|
"dirty-bitmap",
|
||||||
|
"dirty-ring");
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *cmd)
|
cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
g_autoptr(virshDomain) dom = NULL;
|
g_autoptr(virshDomain) dom = NULL;
|
||||||
int seconds = 1; /* the default value is 1 */
|
int seconds = 1; /* the default value is 1 */
|
||||||
|
const char *modestr = NULL;
|
||||||
|
unsigned int flags = 0;
|
||||||
|
|
||||||
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
@ -14501,7 +14515,33 @@ cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (vshCommandOptInt(ctl, cmd, "seconds", &seconds) < 0)
|
if (vshCommandOptInt(ctl, cmd, "seconds", &seconds) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (virDomainStartDirtyRateCalc(dom, seconds, 0) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "mode", &modestr) < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (modestr) {
|
||||||
|
int mode = virshDomainDirtyRateCalcModeTypeFromString(modestr);
|
||||||
|
|
||||||
|
if (mode < 0) {
|
||||||
|
vshError(ctl, _("Unknown calculation mode '%s'"), modestr);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ((virshDomainDirtyRateCalcMode) mode) {
|
||||||
|
case VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_PAGE_SAMPLING:
|
||||||
|
flags |= VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING;
|
||||||
|
break;
|
||||||
|
case VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_DIRTY_BITMAP:
|
||||||
|
flags |= VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP;
|
||||||
|
break;
|
||||||
|
case VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_DIRTY_RING:
|
||||||
|
flags |= VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING;
|
||||||
|
break;
|
||||||
|
case VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_LAST:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virDomainStartDirtyRateCalc(dom, seconds, flags) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
vshPrintExtra(ctl, _("Start to calculate domain's memory "
|
vshPrintExtra(ctl, _("Start to calculate domain's memory "
|
||||||
|
@ -46,6 +46,15 @@ typedef enum {
|
|||||||
|
|
||||||
VIR_ENUM_DECL(virshDomainInterfaceSourceMode);
|
VIR_ENUM_DECL(virshDomainInterfaceSourceMode);
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_PAGE_SAMPLING,
|
||||||
|
VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_DIRTY_BITMAP,
|
||||||
|
VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_DIRTY_RING,
|
||||||
|
VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_LAST,
|
||||||
|
} virshDomainDirtyRateCalcMode;
|
||||||
|
|
||||||
|
VIR_ENUM_DECL(virshDomainDirtyRateCalcMode);
|
||||||
|
|
||||||
extern const vshCmdDef domManagementCmds[];
|
extern const vshCmdDef domManagementCmds[];
|
||||||
|
|
||||||
VIR_ENUM_DECL(virshDomainProcessSignal);
|
VIR_ENUM_DECL(virshDomainProcessSignal);
|
||||||
|
Loading…
Reference in New Issue
Block a user