mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 22:45:21 +00:00
Add a macro timeval_to_ms to compute micro seconds from timeval
This commit is contained in:
parent
8806c0db63
commit
54c6833392
@ -96,6 +96,8 @@
|
|||||||
|
|
||||||
#define QEMU_NAMESPACE_HREF "http://libvirt.org/schemas/domain/qemu/1.0"
|
#define QEMU_NAMESPACE_HREF "http://libvirt.org/schemas/domain/qemu/1.0"
|
||||||
|
|
||||||
|
#define timeval_to_ms(tv) (((tv).tv_sec * 1000ull) + ((tv).tv_usec / 1000))
|
||||||
|
|
||||||
/* Only 1 job is allowed at any time
|
/* Only 1 job is allowed at any time
|
||||||
* A job includes *all* monitor commands, even those just querying
|
* A job includes *all* monitor commands, even those just querying
|
||||||
* information, not merely actions */
|
* information, not merely actions */
|
||||||
@ -376,8 +378,7 @@ static int qemuDomainObjBeginJob(virDomainObjPtr obj)
|
|||||||
_("cannot get time of day"));
|
_("cannot get time of day"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
then = (now.tv_sec * 1000ull) + (now.tv_usec / 1000);
|
then = timeval_to_ms(now) + QEMU_JOB_WAIT_TIME;
|
||||||
then += QEMU_JOB_WAIT_TIME;
|
|
||||||
|
|
||||||
virDomainObjRef(obj);
|
virDomainObjRef(obj);
|
||||||
|
|
||||||
@ -396,7 +397,7 @@ static int qemuDomainObjBeginJob(virDomainObjPtr obj)
|
|||||||
priv->jobActive = QEMU_JOB_UNSPECIFIED;
|
priv->jobActive = QEMU_JOB_UNSPECIFIED;
|
||||||
priv->jobSignals = 0;
|
priv->jobSignals = 0;
|
||||||
memset(&priv->jobSignalsData, 0, sizeof(priv->jobSignalsData));
|
memset(&priv->jobSignalsData, 0, sizeof(priv->jobSignalsData));
|
||||||
priv->jobStart = (now.tv_sec * 1000ull) + (now.tv_usec / 1000);
|
priv->jobStart = timeval_to_ms(now);
|
||||||
memset(&priv->jobInfo, 0, sizeof(priv->jobInfo));
|
memset(&priv->jobInfo, 0, sizeof(priv->jobInfo));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -422,8 +423,7 @@ static int qemuDomainObjBeginJobWithDriver(struct qemud_driver *driver,
|
|||||||
_("cannot get time of day"));
|
_("cannot get time of day"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
then = (now.tv_sec * 1000ull) + (now.tv_usec / 1000);
|
then = timeval_to_ms(now) + QEMU_JOB_WAIT_TIME;
|
||||||
then += QEMU_JOB_WAIT_TIME;
|
|
||||||
|
|
||||||
virDomainObjRef(obj);
|
virDomainObjRef(obj);
|
||||||
qemuDriverUnlock(driver);
|
qemuDriverUnlock(driver);
|
||||||
@ -444,7 +444,7 @@ static int qemuDomainObjBeginJobWithDriver(struct qemud_driver *driver,
|
|||||||
priv->jobActive = QEMU_JOB_UNSPECIFIED;
|
priv->jobActive = QEMU_JOB_UNSPECIFIED;
|
||||||
priv->jobSignals = 0;
|
priv->jobSignals = 0;
|
||||||
memset(&priv->jobSignalsData, 0, sizeof(priv->jobSignalsData));
|
memset(&priv->jobSignalsData, 0, sizeof(priv->jobSignalsData));
|
||||||
priv->jobStart = (now.tv_sec * 1000ull) + (now.tv_usec / 1000);
|
priv->jobStart = timeval_to_ms(now);
|
||||||
memset(&priv->jobInfo, 0, sizeof(priv->jobInfo));
|
memset(&priv->jobInfo, 0, sizeof(priv->jobInfo));
|
||||||
|
|
||||||
virDomainObjUnlock(obj);
|
virDomainObjUnlock(obj);
|
||||||
@ -5469,9 +5469,7 @@ qemuDomainWaitForMigrationComplete(struct qemud_driver *driver, virDomainObjPtr
|
|||||||
_("cannot get time of day"));
|
_("cannot get time of day"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
priv->jobInfo.timeElapsed =
|
priv->jobInfo.timeElapsed = timeval_to_ms(now) - priv->jobStart;
|
||||||
((now.tv_sec * 1000ull) + (now.tv_usec / 1000)) -
|
|
||||||
priv->jobStart;
|
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE:
|
case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE:
|
||||||
@ -11154,7 +11152,7 @@ endjob:
|
|||||||
virDomainObjIsActive(vm)) {
|
virDomainObjIsActive(vm)) {
|
||||||
priv->jobActive = QEMU_JOB_MIGRATION_IN;
|
priv->jobActive = QEMU_JOB_MIGRATION_IN;
|
||||||
priv->jobInfo.type = VIR_DOMAIN_JOB_UNBOUNDED;
|
priv->jobInfo.type = VIR_DOMAIN_JOB_UNBOUNDED;
|
||||||
priv->jobStart = (now.tv_sec * 1000ull) + (now.tv_usec / 1000);
|
priv->jobStart = timeval_to_ms(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -11382,7 +11380,7 @@ endjob:
|
|||||||
virDomainObjIsActive(vm)) {
|
virDomainObjIsActive(vm)) {
|
||||||
priv->jobActive = QEMU_JOB_MIGRATION_IN;
|
priv->jobActive = QEMU_JOB_MIGRATION_IN;
|
||||||
priv->jobInfo.type = VIR_DOMAIN_JOB_UNBOUNDED;
|
priv->jobInfo.type = VIR_DOMAIN_JOB_UNBOUNDED;
|
||||||
priv->jobStart = (now.tv_sec * 1000ull) + (now.tv_usec / 1000);
|
priv->jobStart = timeval_to_ms(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -12371,9 +12369,7 @@ static int qemuDomainGetJobInfo(virDomainPtr dom,
|
|||||||
_("cannot get time of day"));
|
_("cannot get time of day"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
info->timeElapsed =
|
info->timeElapsed = timeval_to_ms(now) - priv->jobStart;
|
||||||
((now.tv_sec * 1000ull) + (now.tv_usec / 1000)) -
|
|
||||||
priv->jobStart;
|
|
||||||
} else {
|
} else {
|
||||||
memset(info, 0, sizeof(*info));
|
memset(info, 0, sizeof(*info));
|
||||||
info->type = VIR_DOMAIN_JOB_NONE;
|
info->type = VIR_DOMAIN_JOB_NONE;
|
||||||
|
Loading…
Reference in New Issue
Block a user