mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-08-24 09:49:59 +03:00
migration/dirtyrate: Implement qemuDomainStartDirtyRateCalc
Implement qemuDomainStartDirtyRateCalc which calculates domain's memory dirty rate calling qmp "calc-dirty-rate". Signed-off-by: Hao Wang <wanghao232@huawei.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
committed by
Michal Privoznik
parent
df5c5c3e60
commit
fbe99823e2
@ -20342,6 +20342,64 @@ qemuDomainGetMessages(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define MIN_DIRTYRATE_CALC_PERIOD 1 /* supported min dirtyrate calculating time: 1s */
|
||||||
|
#define MAX_DIRTYRATE_CALC_PERIOD 60 /* supported max dirtyrate calculating time: 60s */
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainStartDirtyRateCalc(virDomainPtr dom,
|
||||||
|
int seconds,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
virQEMUDriverPtr driver = dom->conn->privateData;
|
||||||
|
virDomainObjPtr vm;
|
||||||
|
qemuDomainObjPrivatePtr priv;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
if (seconds < MIN_DIRTYRATE_CALC_PERIOD ||
|
||||||
|
seconds > MAX_DIRTYRATE_CALC_PERIOD) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("seconds=%d is invalid, please choose value within [%d, %d]."),
|
||||||
|
seconds,
|
||||||
|
MIN_DIRTYRATE_CALC_PERIOD,
|
||||||
|
MAX_DIRTYRATE_CALC_PERIOD);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(vm = qemuDomainObjFromDomain(dom)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (virDomainStartDirtyRateCalcEnsureACL(dom->conn, vm->def) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (!virDomainObjIsActive(vm)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
|
"%s", _("domain is not running"));
|
||||||
|
goto endjob;
|
||||||
|
}
|
||||||
|
|
||||||
|
VIR_DEBUG("Calculate dirty rate in next %d seconds", seconds);
|
||||||
|
|
||||||
|
priv = vm->privateData;
|
||||||
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
|
ret = qemuMonitorStartDirtyRateCalc(priv->mon, seconds);
|
||||||
|
|
||||||
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
|
ret = -1;
|
||||||
|
|
||||||
|
endjob:
|
||||||
|
qemuDomainObjEndJob(driver, vm);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virDomainObjEndAPI(&vm);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static virHypervisorDriver qemuHypervisorDriver = {
|
static virHypervisorDriver qemuHypervisorDriver = {
|
||||||
.name = QEMU_DRIVER_NAME,
|
.name = QEMU_DRIVER_NAME,
|
||||||
.connectURIProbe = qemuConnectURIProbe,
|
.connectURIProbe = qemuConnectURIProbe,
|
||||||
@ -20584,6 +20642,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
|
|||||||
.domainAuthorizedSSHKeysGet = qemuDomainAuthorizedSSHKeysGet, /* 6.10.0 */
|
.domainAuthorizedSSHKeysGet = qemuDomainAuthorizedSSHKeysGet, /* 6.10.0 */
|
||||||
.domainAuthorizedSSHKeysSet = qemuDomainAuthorizedSSHKeysSet, /* 6.10.0 */
|
.domainAuthorizedSSHKeysSet = qemuDomainAuthorizedSSHKeysSet, /* 6.10.0 */
|
||||||
.domainGetMessages = qemuDomainGetMessages, /* 7.1.0 */
|
.domainGetMessages = qemuDomainGetMessages, /* 7.1.0 */
|
||||||
|
.domainStartDirtyRateCalc = qemuDomainStartDirtyRateCalc, /* 7.2.0 */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -4742,3 +4742,15 @@ qemuMonitorTransactionBackup(virJSONValuePtr actions,
|
|||||||
return qemuMonitorJSONTransactionBackup(actions, device, jobname, target,
|
return qemuMonitorJSONTransactionBackup(actions, device, jobname, target,
|
||||||
bitmap, syncmode);
|
bitmap, syncmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuMonitorStartDirtyRateCalc(qemuMonitorPtr mon,
|
||||||
|
int seconds)
|
||||||
|
{
|
||||||
|
VIR_DEBUG("seconds=%d", seconds);
|
||||||
|
|
||||||
|
QEMU_CHECK_MONITOR(mon);
|
||||||
|
|
||||||
|
return qemuMonitorJSONStartDirtyRateCalc(mon, seconds);
|
||||||
|
}
|
||||||
|
@ -1526,3 +1526,7 @@ qemuMonitorTransactionBackup(virJSONValuePtr actions,
|
|||||||
const char *target,
|
const char *target,
|
||||||
const char *bitmap,
|
const char *bitmap,
|
||||||
qemuMonitorTransactionBackupSyncMode syncmode);
|
qemuMonitorTransactionBackupSyncMode syncmode);
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuMonitorStartDirtyRateCalc(qemuMonitorPtr mon,
|
||||||
|
int seconds);
|
||||||
|
@ -9480,3 +9480,25 @@ qemuMonitorJSONGetCPUMigratable(qemuMonitorPtr mon,
|
|||||||
return virJSONValueGetBoolean(virJSONValueObjectGet(reply, "return"),
|
return virJSONValueGetBoolean(virJSONValueObjectGet(reply, "return"),
|
||||||
migratable);
|
migratable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuMonitorJSONStartDirtyRateCalc(qemuMonitorPtr mon,
|
||||||
|
int seconds)
|
||||||
|
{
|
||||||
|
g_autoptr(virJSONValue) cmd = NULL;
|
||||||
|
g_autoptr(virJSONValue) reply = NULL;
|
||||||
|
|
||||||
|
if (!(cmd = qemuMonitorJSONMakeCommand("calc-dirty-rate",
|
||||||
|
"i:calc-time", seconds,
|
||||||
|
NULL)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -711,3 +711,7 @@ int qemuMonitorJSONSetDBusVMStateIdList(qemuMonitorPtr mon,
|
|||||||
int
|
int
|
||||||
qemuMonitorJSONGetCPUMigratable(qemuMonitorPtr mon,
|
qemuMonitorJSONGetCPUMigratable(qemuMonitorPtr mon,
|
||||||
bool *migratable);
|
bool *migratable);
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuMonitorJSONStartDirtyRateCalc(qemuMonitorPtr mon,
|
||||||
|
int seconds);
|
||||||
|
Reference in New Issue
Block a user