virTimeMillisNowRaw() function are invariant now,
so, quite a few checks, dependent on it are become
irrelevant.
Fixes: f5e9bdb87f ("src: replace clock_gettime()/gettimeofday() with
g_get_real_time()")
Signed-off-by: Artem Chernyshev <artem.chernyshev(a)red-soft.ru>
---
src/conf/virdomainjob.c | 7 ++--
src/libxl/libxl_domain.c | 10 ++---
src/libxl/libxl_domain.h | 2 +-
src/libxl/libxl_driver.c | 6 +--
src/nwfilter/nwfilter_dhcpsnoop.c | 18 +++-----
src/qemu/qemu_agent.c | 6 +--
src/qemu/qemu_backup.c | 3 +-
src/qemu/qemu_dbus.c | 3 +-
src/qemu/qemu_domain.c | 2 +-
src/qemu/qemu_domainjob.c | 22 ++++------
src/qemu/qemu_domainjob.h | 4 +-
src/qemu/qemu_driver.c | 10 ++---
src/qemu/qemu_hotplug.c | 6 +--
src/qemu/qemu_migration.c | 4 +-
src/qemu/qemu_nbdkit.c | 3 +-
src/qemu/qemu_process.c | 9 ++--
src/qemu/qemu_tpm.c | 3 +-
src/storage/storage_backend_iscsi_direct.c | 4 +-
src/util/virfdstream.c | 3 +-
src/util/virhostuptime.c | 3 +-
src/util/virtime.c | 48 +++++-----------------
src/util/virtime.h | 14 +++----
src/vz/vz_driver.c | 15 +++----
src/vz/vz_utils.c | 16 +++-----
src/vz/vz_utils.h | 2 +-
tools/virsh-domain.c | 12 ++----
26 files changed, 82 insertions(+), 153 deletions(-)
diff --git a/src/conf/virdomainjob.c b/src/conf/virdomainjob.c
index 38f08f1d18..457b218f6f 100644
--- a/src/conf/virdomainjob.c
+++ b/src/conf/virdomainjob.c
@@ -326,8 +326,7 @@ virDomainObjBeginJobInternal(virDomainObj *obj,
virDomainAgentJobTypeToString(jobObj->agentActive),
virDomainAsyncJobTypeToString(jobObj->asyncJob));
- if (virTimeMillisNow(&now) < 0)
- return -1;
+ virTimeMillisNow(&now);
jobObj->jobsQueued++;
then = now + VIR_JOB_WAIT_TIME;
@@ -373,7 +372,7 @@ virDomainObjBeginJobInternal(virDomainObj *obj,
goto cleanup;
}
- ignore_value(virTimeMillisNow(&now));
+ virTimeMillisNow(&now);
if (job) {
virDomainObjResetJob(jobObj);
@@ -422,7 +421,7 @@ virDomainObjBeginJobInternal(virDomainObj *obj,
return 0;
error:
- ignore_value(virTimeMillisNow(&now));
+ virTimeMillisNow(&now);
if (jobObj->active && jobObj->started)
duration = now - jobObj->started;
if (jobObj->agentActive && jobObj->agentStarted)
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 19cbdd9e82..69bac7d0ae 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -43,24 +43,22 @@
VIR_LOG_INIT("libxl.libxl_domain");
-int
+void
libxlDomainJobGetTimeElapsed(virDomainJobObj *job, unsigned long long *timeElapsed)
{
unsigned long long now;
if (!job->started)
- return 0;
+ return;
- if (virTimeMillisNow(&now) < 0)
- return -1;
+ virTimeMillisNow(&now);
if (now < job->started) {
job->started = 0;
- return 0;
+ return;
}
*timeElapsed = now - job->started;
- return 0;
}
static void *
diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
index 94b693e477..c5573188d1 100644
--- a/src/libxl/libxl_domain.h
+++ b/src/libxl/libxl_domain.h
@@ -49,7 +49,7 @@ extern const struct libxl_event_hooks ev_hooks;
int
libxlDomainObjPrivateInitCtx(virDomainObj *vm);
-int
+void
libxlDomainJobGetTimeElapsed(virDomainJobObj *job,
unsigned long long *timeElapsed);
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 11a96233bd..5ad66261fd 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -5370,8 +5370,7 @@ libxlDomainGetJobInfo(virDomainPtr dom,
/* In libxl we don't have an estimated completion time
* thus we always set to unbounded and update time
* for the active job. */
- if (libxlDomainJobGetTimeElapsed(vm->job, &timeElapsed) < 0)
- goto cleanup;
+ libxlDomainJobGetTimeElapsed(vm->job, &timeElapsed);
/* setting only these two attributes is enough because libxl never sets
* anything else */
@@ -5417,8 +5416,7 @@ libxlDomainGetJobStats(virDomainPtr dom,
/* In libxl we don't have an estimated completion time
* thus we always set to unbounded and update time
* for the active job. */
- if (libxlDomainJobGetTimeElapsed(vm->job, &timeElapsed) < 0)
- goto cleanup;
+ libxlDomainJobGetTimeElapsed(vm->job, &timeElapsed);
if (virTypedParamsAddULLong(params, nparams, &maxparams,
VIR_DOMAIN_JOB_TIME_ELAPSED,
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index 26072ec26e..91e6bc28ef 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -1103,13 +1103,9 @@ virNWFilterSnoopRatePenalty(virNWFilterSnoopPcapConf *pc,
if (diff > limit) {
unsigned long long now;
- if (virTimeMillisNowRaw(&now) < 0) {
- g_usleep(PCAP_FLOOD_TIMEOUT_MS); /* 1 ms */
- pc->penaltyTimeoutAbs = 0;
- } else {
- /* don't listen to the fd for 1 ms */
- pc->penaltyTimeoutAbs = now + PCAP_FLOOD_TIMEOUT_MS;
- }
+ virTimeMillisNowRaw(&now);
+ /* don't listen to the fd for 1 ms */
+ pc->penaltyTimeoutAbs = now + PCAP_FLOOD_TIMEOUT_MS;
}
}
@@ -1127,12 +1123,8 @@ virNWFilterSnoopAdjustPoll(virNWFilterSnoopPcapConf *pc,
for (i = 0; i < nPc; i++) {
if (pc[i].penaltyTimeoutAbs != 0) {
- if (now == 0) {
- if (virTimeMillisNow(&now) < 0) {
- ret = -1;
- break;
- }
- }
+ if (now == 0)
+ virTimeMillisNow(&now);
if (now < pc[i].penaltyTimeoutAbs) {
/* don't listen to incoming data on the fd for some time */
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index f9bcf38dfb..7d3be39380 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -737,8 +737,7 @@ static int qemuAgentSend(qemuAgent *agent,
if (seconds > VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) {
unsigned long long now;
- if (virTimeMillisNow(&now) < 0)
- return -1;
+ virTimeMillisNow(&now);
if (seconds == VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT)
seconds = QEMU_AGENT_WAIT_TIME;
then = now + seconds * 1000ull;
@@ -803,8 +802,7 @@ qemuAgentGuestSyncSend(qemuAgent *agent,
qemuAgentMessage sync_msg = { 0 };
int rc;
- if (virTimeMillisNow(&id) < 0)
- return -1;
+ virTimeMillisNow(&id);
txMsg = g_strdup_printf("{\"execute\":\"guest-sync\",
"
"\"arguments\":{\"id\":%llu}}\n", id);
diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c
index 857709b17e..a269f1f802 100644
--- a/src/qemu/qemu_backup.c
+++ b/src/qemu/qemu_backup.c
@@ -1145,8 +1145,7 @@ qemuBackupGetJobInfoStats(virDomainObj *vm,
return -1;
}
- if (qemuDomainJobDataUpdateTime(jobData) < 0)
- return -1;
+ qemuDomainJobDataUpdateTime(jobData);
jobData->status = VIR_DOMAIN_JOB_STATUS_ACTIVE;
diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c
index 06b655d870..85e00b7607 100644
--- a/src/qemu/qemu_dbus.c
+++ b/src/qemu/qemu_dbus.c
@@ -231,8 +231,7 @@ qemuDBusStart(virQEMUDriver *driver,
goto cleanup;
}
- if (virTimeBackOffStart(&timebackoff, 1, timeout) < 0)
- goto cleanup;
+ virTimeBackOffStart(&timebackoff, 1, timeout);
while (virTimeBackOffWait(&timebackoff)) {
char errbuf[1024] = { 0 };
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 734d63f8a4..ac5aefeb43 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6439,7 +6439,7 @@ qemuDomainObjEnterMonitorInternal(virDomainObj *obj,
priv->mon, obj, obj->def->name);
virObjectLock(priv->mon);
virObjectRef(priv->mon);
- ignore_value(virTimeMillisNow(&priv->monStart));
+ virTimeMillisNow(&priv->monStart);
virObjectUnlock(obj);
return 0;
diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c
index 245e51f14b..9419795406 100644
--- a/src/qemu/qemu_domainjob.c
+++ b/src/qemu/qemu_domainjob.c
@@ -133,7 +133,7 @@ qemuDomainObjRestoreAsyncJob(virDomainObj *vm,
virDomainAsyncJobTypeToString(asyncJob), vm->def->name);
if (started == 0)
- ignore_value(virTimeMillisNow(&started));
+ virTimeMillisNow(&started);
job->jobsQueued++;
job->asyncJob = asyncJob;
@@ -151,48 +151,44 @@ qemuDomainObjRestoreAsyncJob(virDomainObj *vm,
}
-int
+void
qemuDomainJobDataUpdateTime(virDomainJobData *jobData)
{
unsigned long long now;
if (!jobData->started)
- return 0;
+ return;
- if (virTimeMillisNow(&now) < 0)
- return -1;
+ virTimeMillisNow(&now);
if (now < jobData->started) {
VIR_WARN("Async job starts in the future");
jobData->started = 0;
- return 0;
+ return;
}
jobData->timeElapsed = now - jobData->started;
- return 0;
}
-int
+void
qemuDomainJobDataUpdateDowntime(virDomainJobData *jobData)
{
unsigned long long now;
qemuDomainJobDataPrivate *priv = jobData->privateData;
if (!jobData->stopped)
- return 0;
+ return;
- if (virTimeMillisNow(&now) < 0)
- return -1;
+ virTimeMillisNow(&now);
if (now < jobData->stopped) {
VIR_WARN("Guest's CPUs stopped in the future");
jobData->stopped = 0;
- return 0;
+ return;
}
priv->stats.mig.downtime = now - jobData->stopped;
priv->stats.mig.downtime_set = true;
- return 0;
}
diff --git a/src/qemu/qemu_domainjob.h b/src/qemu/qemu_domainjob.h
index c3de401aa5..5bd457abc7 100644
--- a/src/qemu/qemu_domainjob.h
+++ b/src/qemu/qemu_domainjob.h
@@ -89,9 +89,9 @@ qemuDomainObjRestoreAsyncJob(virDomainObj *vm,
void qemuDomainObjDiscardAsyncJob(virDomainObj *obj);
void qemuDomainObjReleaseAsyncJob(virDomainObj *obj);
-int qemuDomainJobDataUpdateTime(virDomainJobData *jobData)
+void qemuDomainJobDataUpdateTime(virDomainJobData *jobData)
ATTRIBUTE_NONNULL(1);
-int qemuDomainJobDataUpdateDowntime(virDomainJobData *jobData)
+void qemuDomainJobDataUpdateDowntime(virDomainJobData *jobData)
ATTRIBUTE_NONNULL(1);
int qemuDomainJobDataToInfo(virDomainJobData *jobData,
virDomainJobInfoPtr info)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4b6068be04..9e2c930cf5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2578,8 +2578,7 @@ qemuDomainGetControlInfo(virDomainPtr dom,
info->state = VIR_DOMAIN_CONTROL_ERROR;
info->details = VIR_DOMAIN_CONTROL_ERROR_REASON_MONITOR;
} else if (vm->job->active) {
- if (virTimeMillisNow(&info->stateTime) < 0)
- goto cleanup;
+ virTimeMillisNow(&info->stateTime);
if (vm->job->current) {
info->state = VIR_DOMAIN_CONTROL_JOB;
info->stateTime -= vm->job->current->started;
@@ -11924,7 +11923,9 @@ qemuDomainGetJobInfoMigrationStats(virDomainObj *vm,
return 0;
}
- return qemuDomainJobDataUpdateTime(jobData);
+ qemuDomainJobDataUpdateTime(jobData);
+
+ return 0;
}
@@ -11948,8 +11949,7 @@ qemuDomainGetJobInfoDumpStats(virDomainObj *vm,
privJob->stats.dump = stats;
- if (qemuDomainJobDataUpdateTime(jobData) < 0)
- return -1;
+ qemuDomainJobDataUpdateTime(jobData);
switch (privJob->stats.dump.status) {
case QEMU_MONITOR_DUMP_STATUS_NONE:
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 75e1d39b60..fed292295a 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -252,8 +252,7 @@ qemuHotplugWaitForTrayEject(virDomainObj *vm,
unsigned long long now;
int rc;
- if (virTimeMillisNow(&now) < 0)
- return -1;
+ virTimeMillisNow(&now);
while (disk->tray_status != VIR_DOMAIN_DISK_TRAY_OPEN) {
if ((rc = virDomainObjWaitUntil(vm, now + CHANGE_MEDIA_TIMEOUT)) < 0)
@@ -5448,8 +5447,7 @@ qemuDomainWaitForDeviceRemoval(virDomainObj *vm)
qemuDomainObjPrivate *priv = vm->privateData;
unsigned long long until;
- if (virTimeMillisNow(&until) < 0)
- return 1;
+ virTimeMillisNow(&until);
until += qemuDomainGetUnplugTimeout(vm);
while (true) {
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 3ba0aa502b..9d49885cb0 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -5027,7 +5027,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
vm->job->completed->stopped = vm->job->current->stopped;
qemuDomainJobDataUpdateTime(vm->job->completed);
qemuDomainJobDataUpdateDowntime(vm->job->completed);
- ignore_value(virTimeMillisNow(&vm->job->completed->sent));
+ virTimeMillisNow(&vm->job->completed->sent);
}
cookieFlags |= QEMU_MIGRATION_COOKIE_NETWORK |
@@ -6846,7 +6846,7 @@ qemuMigrationDstFinish(virQEMUDriver *driver,
goto cleanup;
phase = QEMU_MIGRATION_PHASE_FINISH_RESUME;
}
- ignore_value(virTimeMillisNow(&timeReceived));
+ virTimeMillisNow(&timeReceived);
if (qemuMigrationJobStartPhase(vm, phase) < 0)
goto cleanup;
diff --git a/src/qemu/qemu_nbdkit.c b/src/qemu/qemu_nbdkit.c
index 85e61be44c..0ffde44fe3 100644
--- a/src/qemu/qemu_nbdkit.c
+++ b/src/qemu/qemu_nbdkit.c
@@ -1209,8 +1209,7 @@ qemuNbdkitProcessStart(qemuNbdkitProcess *proc,
goto error;
}
- if (virTimeBackOffStart(&timebackoff, 1, 1000) < 0)
- goto error;
+ virTimeBackOffStart(&timebackoff, 1, 1000);
while (virTimeBackOffWait(&timebackoff)) {
if (virFileExists(proc->socketfile)) {
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 5926acf7ad..43df1b4865 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -662,7 +662,7 @@ qemuProcessHandleStop(qemuMonitor *mon G_GNUC_UNUSED,
detail);
if (vm->job->current)
- ignore_value(virTimeMillisNow(&vm->job->current->stopped));
+ virTimeMillisNow(&vm->job->current->stopped);
if (priv->signalStop)
virDomainObjBroadcast(vm);
@@ -1869,7 +1869,7 @@ qemuConnectMonitor(virQEMUDriver *driver,
return -1;
}
- ignore_value(virTimeMillisNow(&priv->monStart));
+ virTimeMillisNow(&priv->monStart);
mon = qemuMonitorOpen(vm,
priv->monConfig,
@@ -2832,8 +2832,7 @@ qemuProcessStartManagedPRDaemon(virDomainObj *vm)
goto cleanup;
}
- if (virTimeBackOffStart(&timebackoff, 1, timeout) < 0)
- goto cleanup;
+ virTimeBackOffStart(&timebackoff, 1, timeout);
while (virTimeBackOffWait(&timebackoff)) {
char errbuf[1024] = { 0 };
@@ -3187,7 +3186,7 @@ int qemuProcessStopCPUs(virQEMUDriver *driver,
ignore_value(qemuInterfaceStopDevices(vm->def));
if (vm->job->current)
- ignore_value(virTimeMillisNow(&vm->job->current->stopped));
+ virTimeMillisNow(&vm->job->current->stopped);
/* The STOP event handler will change the domain state with the reason
* saved in priv->pausedReason and it will also emit corresponding domain
diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c
index bf0c6bcb0d..c5e6e6c41c 100644
--- a/src/qemu/qemu_tpm.c
+++ b/src/qemu/qemu_tpm.c
@@ -969,8 +969,7 @@ qemuTPMEmulatorStart(virQEMUDriver *driver,
goto error;
}
- if (virTimeBackOffStart(&timebackoff, 1, timeout) < 0)
- goto error;
+ virTimeBackOffStart(&timebackoff, 1, timeout);
while (virTimeBackOffWait(&timebackoff)) {
char errbuf[1024] = { 0 };
diff --git a/src/storage/storage_backend_iscsi_direct.c
b/src/storage/storage_backend_iscsi_direct.c
index 658a684e83..485416e0bd 100644
--- a/src/storage/storage_backend_iscsi_direct.c
+++ b/src/storage/storage_backend_iscsi_direct.c
@@ -188,9 +188,7 @@ virISCSIDirectTestUnitReady(struct iscsi_context *iscsi,
int ret = -1;
virTimeBackOffVar timebackoff;
- if (virTimeBackOffStart(&timebackoff, 1,
- VIR_ISCSI_TEST_UNIT_TIMEOUT) < 0)
- goto cleanup;
+ virTimeBackOffStart(&timebackoff, 1, VIR_ISCSI_TEST_UNIT_TIMEOUT);
do {
if (!(task = iscsi_testunitready_sync(iscsi, lun))) {
diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c
index 26a1f00316..926ca980e2 100644
--- a/src/util/virfdstream.c
+++ b/src/util/virfdstream.c
@@ -1213,8 +1213,7 @@ int virFDStreamConnectUNIX(virStreamPtr st,
return -1;
}
- if (virTimeBackOffStart(&timeout, 1, 3*1000 /* ms */) < 0)
- return -1;
+ virTimeBackOffStart(&timeout, 1, 3*1000 /* ms */);
while (virTimeBackOffWait(&timeout)) {
ret = connect(fd, (struct sockaddr *)&sa, sizeof(sa));
if (ret == 0)
diff --git a/src/util/virhostuptime.c b/src/util/virhostuptime.c
index 2467ea51b0..323e275483 100644
--- a/src/util/virhostuptime.c
+++ b/src/util/virhostuptime.c
@@ -51,8 +51,7 @@ virHostGetBootTimeProcfs(unsigned long long *btime)
g_autofree char *buf = NULL;
char *tmp;
- if (virTimeMillisNow(&now) < 0)
- return -errno;
+ virTimeMillisNow(&now);
/* 1KiB limit is more than enough. */
if (virFileReadAll(UPTIME_FILE, 1024, &buf) < 0)
diff --git a/src/util/virtime.c b/src/util/virtime.c
index baf4ce5db7..3d62494109 100644
--- a/src/util/virtime.c
+++ b/src/util/virtime.c
@@ -49,13 +49,10 @@ VIR_LOG_INIT("util.time");
*
* Retrieves the current system time, in milliseconds since the
* epoch
- *
- * Returns 0 on success, -1 on error with errno set
*/
-int virTimeMillisNowRaw(unsigned long long *now)
+void virTimeMillisNowRaw(unsigned long long *now)
{
*now = g_get_real_time() / 1000;
- return 0;
}
@@ -65,19 +62,13 @@ int virTimeMillisNowRaw(unsigned long long *now)
*
* Retrieves the current time, in broken-down field format.
* The time is always in UTC.
- *
- * Returns 0 on success, -1 on error with errno set
*/
-int virTimeFieldsNowRaw(struct tm *fields)
+void virTimeFieldsNowRaw(struct tm *fields)
{
unsigned long long now;
- if (virTimeMillisNowRaw(&now) < 0)
- return -1;
-
+ virTimeMillisNowRaw(&now);
virTimeFieldsThen(now, fields);
-
- return 0;
}
@@ -163,8 +154,7 @@ int virTimeStringNowRaw(char *buf)
{
unsigned long long now;
- if (virTimeMillisNowRaw(&now) < 0)
- return -1;
+ virTimeMillisNowRaw(&now);
return virTimeStringThenRaw(now, buf);
}
@@ -208,17 +198,10 @@ int virTimeStringThenRaw(unsigned long long when, char *buf)
*
* Retrieves the current system time, in milliseconds since the
* epoch
- *
- * Returns 0 on success, -1 on error with error reported
*/
-int virTimeMillisNow(unsigned long long *now)
+void virTimeMillisNow(unsigned long long *now)
{
- if (virTimeMillisNowRaw(now) < 0) {
- virReportSystemError(errno, "%s",
- _("Unable to get current time"));
- return -1;
- }
- return 0;
+ virTimeMillisNowRaw(now);
}
@@ -228,18 +211,13 @@ int virTimeMillisNow(unsigned long long *now)
*
* Retrieves the current time, in broken-down field format.
* The time is always in UTC.
- *
- * Returns 0 on success, -1 on error with errno reported
*/
-int virTimeFieldsNow(struct tm *fields)
+void virTimeFieldsNow(struct tm *fields)
{
unsigned long long now;
- if (virTimeMillisNow(&now) < 0)
- return -1;
-
+ virTimeMillisNow(&now);
virTimeFieldsThen(now, fields);
- return 0;
}
@@ -327,19 +305,15 @@ virTimeLocalOffsetFromUTC(long *offset)
* @timeout: Timeout (milliseconds).
*
* Initialize the timeout variable @var and start the timer running.
- *
- * Returns 0 on success, -1 on error and raises a libvirt error.
*/
-int
+void
virTimeBackOffStart(virTimeBackOffVar *var,
unsigned long long first, unsigned long long timeout)
{
- if (virTimeMillisNow(&var->start_t) < 0)
- return -1;
+ virTimeMillisNow(&var->start_t);
var->next = first;
var->limit_t = var->start_t + timeout;
- return 0;
}
@@ -379,7 +353,7 @@ virTimeBackOffWait(virTimeBackOffVar *var)
{
unsigned long long next, t = 0;
- ignore_value(virTimeMillisNowRaw(&t));
+ virTimeMillisNowRaw(&t);
VIR_DEBUG("t=%llu, limit=%llu", t, var->limit_t);
diff --git a/src/util/virtime.h b/src/util/virtime.h
index d4fba4aff5..19604f2b55 100644
--- a/src/util/virtime.h
+++ b/src/util/virtime.h
@@ -39,10 +39,6 @@ void virTimeFieldsThen(unsigned long long when, struct tm *fields)
/* These APIs are async signal safe and return -1, setting
* errno on failure */
-int virTimeMillisNowRaw(unsigned long long *now)
- ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
-int virTimeFieldsNowRaw(struct tm *fields)
- ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
int virTimeStringNowRaw(char *buf)
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
int virTimeStringThenRaw(unsigned long long when, char *buf)
@@ -51,10 +47,6 @@ int virTimeStringThenRaw(unsigned long long when, char *buf)
/* These APIs are *not* async signal safe and return -1,
* raising a libvirt error on failure
*/
-int virTimeMillisNow(unsigned long long *now)
- ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
-int virTimeFieldsNow(struct tm *fields)
- ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
char *virTimeStringNow(void);
char *virTimeStringThen(unsigned long long when);
@@ -67,7 +59,11 @@ typedef struct {
unsigned long long limit_t;
} virTimeBackOffVar;
-int virTimeBackOffStart(virTimeBackOffVar *var,
+void virTimeBackOffStart(virTimeBackOffVar *var,
unsigned long long first, unsigned long long timeout);
bool virTimeBackOffWait(virTimeBackOffVar *var);
+void virTimeMillisNowRaw(unsigned long long *now);
+void virTimeFieldsNowRaw(struct tm *fields);
+void virTimeMillisNow(unsigned long long *now);
+void virTimeFieldsNow(struct tm *fields);
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index c7ceec2339..93f0e1bbb4 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -3320,7 +3320,7 @@ vzDomainMigrateConfirm3Params(virDomainPtr domain G_GNUC_UNUSED,
return 0;
}
-static int
+static void
vzDomainGetJobInfoImpl(virDomainObj *dom, virDomainJobInfoPtr info)
{
struct vzDomObj *privdom = dom->privateData;
@@ -3329,18 +3329,15 @@ vzDomainGetJobInfoImpl(virDomainObj *dom, virDomainJobInfoPtr
info)
memset(info, 0, sizeof(*info));
if (!job->active || !job->hasProgress)
- return 0;
+ return;
- if (vzDomainJobUpdateTime(job) < 0)
- return -1;
+ vzDomainJobUpdateTime(job);
info->type = VIR_DOMAIN_JOB_UNBOUNDED;
info->dataTotal = 100;
info->dataProcessed = job->progress;
info->dataRemaining = 100 - job->progress;
info->timeElapsed = job->elapsed;
-
- return 0;
}
static int
@@ -3355,7 +3352,8 @@ vzDomainGetJobInfo(virDomainPtr domain, virDomainJobInfoPtr info)
if (virDomainGetJobInfoEnsureACL(domain->conn, dom->def) < 0)
goto cleanup;
- ret = vzDomainGetJobInfoImpl(dom, info);
+ vzDomainGetJobInfoImpl(dom, info);
+ ret = 0;
cleanup:
virDomainObjEndAPI(&dom);
@@ -3416,8 +3414,7 @@ vzDomainGetJobStats(virDomainPtr domain,
if (virDomainGetJobStatsEnsureACL(domain->conn, dom->def) < 0)
goto cleanup;
- if (vzDomainGetJobInfoImpl(dom, &info) < 0)
- goto cleanup;
+ vzDomainGetJobInfoImpl(dom, &info);
if (info.type == VIR_DOMAIN_JOB_NONE) {
*type = VIR_DOMAIN_JOB_NONE;
diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c
index 7c08d0f88b..bbcffa3148 100644
--- a/src/vz/vz_utils.c
+++ b/src/vz/vz_utils.c
@@ -584,8 +584,7 @@ vzDomainObjBeginJob(virDomainObj *dom)
unsigned long long now;
unsigned long long then;
- if (virTimeMillisNow(&now) < 0)
- return -1;
+ virTimeMillisNow(&now);
then = now + VZ_JOB_WAIT_TIME;
while (pdom->job.active) {
@@ -593,8 +592,7 @@ vzDomainObjBeginJob(virDomainObj *dom)
goto error;
}
- if (virTimeMillisNow(&now) < 0)
- return -1;
+ virTimeMillisNow(&now);
pdom->job.active = true;
pdom->job.started = now;
@@ -623,23 +621,21 @@ vzDomainObjEndJob(virDomainObj *dom)
virCondSignal(&pdom->job.cond);
}
-int
+void
vzDomainJobUpdateTime(struct _vzDomainJobObj *job)
{
unsigned long long now;
if (!job->started)
- return 0;
+ return;
- if (virTimeMillisNow(&now) < 0)
- return -1;
+ virTimeMillisNow(&now);
if (now < job->started) {
VIR_WARN("Async job starts in the future");
job->started = 0;
- return 0;
+ return;
}
job->elapsed = now - job->started;
- return 0;
}
diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h
index 7a797953a5..6da4e8c998 100644
--- a/src/vz/vz_utils.h
+++ b/src/vz/vz_utils.h
@@ -149,5 +149,5 @@ int
vzDomainObjBeginJob(virDomainObj *dom);
void
vzDomainObjEndJob(virDomainObj *dom);
-int
+void
vzDomainJobUpdateTime(struct _vzDomainJobObj *job);
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 58d5a4ab57..778a96856f 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1917,10 +1917,8 @@ virshBlockJobWait(virshBlockJobWaitData *data)
sigaction(SIGINT, &sig_action, &old_sig_action);
#endif /* !WIN32 */
- if (data->timeout && virTimeMillisNow(&start) < 0) {
- vshSaveLibvirtError();
- goto cleanup;
- }
+ if (data->timeout)
+ virTimeMillisNow(&start);
last.cur = last.end = 0;
@@ -1969,10 +1967,8 @@ virshBlockJobWait(virshBlockJobWaitData *data)
info.end);
last = info;
- if (data->timeout && virTimeMillisNow(&curr) < 0) {
- vshSaveLibvirtError();
- goto cleanup;
- }
+ if (data->timeout)
+ virTimeMillisNow(&curr);
if (intCaught || (data->timeout && (curr - start >
data->timeout))) {
if (virDomainBlockJobAbort(data->dom, data->dev, abort_flags) < 0)
{
--
2.43.0