]> xenbits.xensource.com Git - libvirt.git/commitdiff
build: remove use of usleep gnulib module in favour of g_usleep
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 2 Oct 2019 17:01:11 +0000 (18:01 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Mon, 14 Oct 2019 09:54:42 +0000 (10:54 +0100)
The usleep function was missing on older mingw versions, but we can rely
on it existing everywhere these days. It may only support times upto 1
second in duration though, so we'll prefer to use g_usleep instead.

The commandhelper program is not changed since that can't link to glib.
Fortunately it doesn't need to build on Windows platforms either.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
31 files changed:
bootstrap.conf
src/hyperv/hyperv_driver.c
src/hyperv/hyperv_wmi.c
src/locking/lock_daemon.c
src/locking/lock_driver_sanlock.c
src/lxc/lxc_controller.c
src/lxc/lxc_driver.c
src/lxc/lxc_process.c
src/network/bridge_driver.c
src/nwfilter/nwfilter_dhcpsnoop.c
src/nwfilter/nwfilter_learnipaddr.c
src/qemu/qemu_monitor_json.c
src/qemu/qemu_process.c
src/qemu/qemu_tpm.c
src/rpc/virnetsocket.c
src/security/security_manager.c
src/storage/storage_util.c
src/util/vircgroup.c
src/util/virfile.c
src/util/virnetdev.c
src/util/virnetdevip.c
src/util/virnetdevmacvlan.c
src/util/virnetdevvportprofile.c
src/util/virpci.c
src/util/virprocess.c
src/util/virtime.c
src/vbox/vbox_common.c
tests/commandtest.c
tests/eventtest.c
tests/fdstreamtest.c
tools/virsh-domain.c

index 241dce50c29c7187a514ae52384f917f7b10a708..1b5a68b873b95a2c526caf9b4b5f223a1f0c618d 100644 (file)
@@ -90,7 +90,6 @@ timegm
 ttyname_r
 uname
 unsetenv
-usleep
 verify
 vsnprintf
 waitpid
index 0e2c6c55ef31a83c6d2039839a54733204473480..ceaf528dd360cb73d367b4e4b0e2176e3f0d4613 100644 (file)
@@ -1415,7 +1415,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset,
 
     /* simulate holdtime by sleeping */
     if (holdtime > 0)
-        usleep(holdtime * 1000);
+        g_usleep(holdtime * 1000);
 
     /* release the keys */
     for (i = 0; i < nkeycodes; i++) {
index 0f39bd443134b2c96dfc7279b3a32295ad214421..c2c1f082e1d403360c0f40c66fbbbb5589724ccf 100644 (file)
@@ -909,7 +909,7 @@ hypervInvokeMethod(hypervPrivate *priv, hypervInvokeParamsListPtr params,
                 case MSVM_CONCRETEJOB_JOBSTATE_SHUTTING_DOWN:
                     hypervFreeObject(priv, (hypervObject *)job);
                     job = NULL;
-                    usleep(100 * 1000); /* sleep 100 ms */
+                    g_usleep(100 * 1000); /* sleep 100 ms */
                     timeout -= 100;
                     continue;
                 case MSVM_CONCRETEJOB_JOBSTATE_COMPLETED:
@@ -1418,7 +1418,7 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain,
                 hypervFreeObject(priv, (hypervObject *)concreteJob);
                 concreteJob = NULL;
 
-                usleep(100 * 1000);
+                g_usleep(100 * 1000);
                 continue;
 
               case MSVM_CONCRETEJOB_JOBSTATE_COMPLETED:
index a5a3a97e99f7c25e772d3fd42c23ea1e354165e7..c12cb4ea0fd21f7ecdbb47f23ea4fcbb5782f093 100644 (file)
@@ -657,7 +657,7 @@ virLockDaemonClientFree(void *opaque)
                     VIR_WARN("Failed to kill off pid %lld",
                              (unsigned long long)priv->clientPid);
                 }
-                usleep(200 * 1000);
+                g_usleep(200 * 1000);
             }
         }
     }
index 85a23c764234ec32dc3ce17cc30978c43ff96b99..7ebd63913eb4bdc0b9d8c948e6601133122c5adf 100644 (file)
@@ -376,7 +376,7 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriverPtr driver)
 #else
             /* fall back to polling */
             VIR_DEBUG("Sleeping for %dms", LOCKSPACE_SLEEP);
-            usleep(LOCKSPACE_SLEEP * 1000);
+            g_usleep(LOCKSPACE_SLEEP * 1000);
 #endif
             VIR_DEBUG("Retrying to add lockspace (left %d)", retries);
             goto retry;
index 37851bf284e51281e6e35bf99269092d0a134404..9097655b4d2ea6011ff26a8bacad41d3ea93e720 100644 (file)
@@ -574,7 +574,7 @@ static int virLXCControllerAppendNBDPids(virLXCControllerPtr ctrl,
     while (!virFileExists(pidpath)) {
         /* wait for 100ms before checking again, but don't do it for ever */
         if (errno == ENOENT && loops < 10) {
-            usleep(100 * 1000);
+            g_usleep(100 * 1000);
             loops++;
         } else {
             virReportSystemError(errno,
index a69589e50c0239bbd77caa81afb5c16c08f9b0c0..c0bbeb09e8cb23c224410db9c0ab4cc0236da6c8 100644 (file)
@@ -2965,7 +2965,7 @@ static int lxcFreezeContainer(virDomainObjPtr vm)
          * decide that the freezing has been complete only with
          * the state actually transit to "FROZEN".
          */
-        usleep(check_interval * 1000);
+        g_usleep(check_interval * 1000);
 
         r = virCgroupGetFreezerState(priv->cgroup, &state);
 
index cbdc7b1268973f6c322d2d0b18d57b44a86b79e5..318b4c16532501eaa697f1d991095f3502490558 100644 (file)
@@ -1095,7 +1095,7 @@ virLXCProcessReadLogOutputData(virDomainObjPtr vm,
             goto cleanup;
         }
 
-        usleep(100*1000);
+        g_usleep(100*1000);
         retries--;
     }
 
index c05157c3ca99b4da55af8a0b267a25960862e119..d10665efa328163137f1cf8147334f76816d54b3 100644 (file)
@@ -1034,7 +1034,7 @@ networkKillDaemon(pid_t pid,
          * than modifications to domains, this seems a reasonable
          * tradeoff in exchange for less code disruption.
          */
-        usleep(20 * 1000);
+        g_usleep(20 * 1000);
     }
     VIR_WARN("Timed out waiting after SIG%s to %s process %d "
              "(network '%s')",
index 2af8cfdd321cab139711987a261ae3294d81f83e..c82457989ed80940daf54e015eac0c54a66578c5 100644 (file)
@@ -1273,7 +1273,7 @@ virNWFilterSnoopRatePenalty(virNWFilterSnoopPcapConfPtr pc,
         unsigned long long now;
 
         if (virTimeMillisNowRaw(&now) < 0) {
-            usleep(PCAP_FLOOD_TIMEOUT_MS); /* 1 ms */
+            g_usleep(PCAP_FLOOD_TIMEOUT_MS); /* 1 ms */
             pc->penaltyTimeoutAbs = 0;
         } else {
             /* don't listen to the fd for 1 ms */
@@ -2010,7 +2010,7 @@ virNWFilterSnoopJoinThreads(void)
     while (virAtomicIntGet(&virNWFilterSnoopState.nThreads) != 0) {
         VIR_WARN("Waiting for snooping threads to terminate: %u",
                  virAtomicIntGet(&virNWFilterSnoopState.nThreads));
-        usleep(1000 * 1000);
+        g_usleep(1000 * 1000);
     }
 }
 
index cd66e3ea7d5ac1a705ec59e7ed0c4375c21679a4..34b8d7fcd9af6c7c10a9a7445664b456465f177e 100644 (file)
@@ -812,7 +812,7 @@ virNWFilterLearnThreadsTerminate(bool allowNewThreads)
     threadsTerminate = true;
 
     while (virHashSize(pendingLearnReq) != 0)
-        usleep((PKT_TIMEOUT_MS * 1000) / 3);
+        g_usleep((PKT_TIMEOUT_MS * 1000) / 3);
 
     if (allowNewThreads)
         threadsTerminate = false;
index a6facdc09b36f1716479795ecdff76554457091b..dbc32acb5ef3d4eebb0d9373ea6a1631fafd8569 100644 (file)
@@ -1650,7 +1650,7 @@ qemuMonitorJSONStartCPUs(qemuMonitorPtr mon)
 
         virJSONValueFree(reply);
         reply = NULL;
-        usleep(250000);
+        g_usleep(250000);
     } while (++i <= timeout);
 
     virJSONValueFree(cmd);
index 3b45b2f641e293c49f96cffeca242e38c7f7abb6..c6fac01adaf57cf8eef954ffd52a969cc1fc31b9 100644 (file)
@@ -7611,7 +7611,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
  retry:
     if ((ret = qemuRemoveCgroup(vm)) < 0) {
         if (ret == -EBUSY && (retries++ < 5)) {
-            usleep(200*1000);
+            g_usleep(200*1000);
             goto retry;
         }
         VIR_WARN("Failed to remove cgroup for %s",
index 1d68803a287091c97a51f9042666bada7ba22123..31fdfa995fcc280161ca25b35f090a1031ea0b3b 100644 (file)
@@ -884,7 +884,7 @@ qemuExtTPMStartEmulator(virQEMUDriverPtr driver,
         rc = qemuTPMEmulatorGetPid(cfg->swtpmStateDir, shortName, &pid);
         if (rc < 0) {
             timeout -= 50;
-            usleep(50 * 1000);
+            g_usleep(50 * 1000);
             continue;
         }
         if (rc == 0 && pid == (pid_t)-1)
index a469907779d90dee430d3c9ffaf20b9b2088a8a5..bd5fa967513d2b1540da2965c482a26a5acac207 100644 (file)
@@ -749,7 +749,7 @@ int virNetSocketNewConnectUNIX(const char *path,
             daemonLaunched = true;
         }
 
-        usleep(10000);
+        g_usleep(10000);
     }
 
     localAddr.len = sizeof(localAddr.data);
index 7c905f07852b1794b736cb31393a3d0ce3cfdce1..7f187c9068b61b254800b00bb739acd6f1a5293c 100644 (file)
@@ -1349,7 +1349,7 @@ virSecurityManagerMetadataLock(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
                 if (retries && (errno == EACCES || errno == EAGAIN)) {
                     /* File is locked. Try again. */
                     retries--;
-                    usleep(1000);
+                    g_usleep(1000);
                     continue;
                 } else {
                     virReportSystemError(errno,
index 6165dd43b20b90bc5854849471fa252408046bb8..be084119f4cb6ac5d5cd0ed38d89ed181056f191 100644 (file)
@@ -1940,7 +1940,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
     if (virDirOpenQuiet(&dh, def->target.path) < 0) {
         opentries++;
         if (loop && errno == ENOENT && opentries < 50) {
-            usleep(100 * 1000);
+            g_usleep(100 * 1000);
             goto reopen;
         }
         virReportSystemError(errno,
@@ -1975,7 +1975,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
     }
 
     if (!direrr && loop && ++retry < 100) {
-        usleep(100 * 1000);
+        g_usleep(100 * 1000);
         goto retry;
     }
 
index 4f9d80666d1b0b145d457ee0570c11125043d156..70d41c4ba516c689ce3502bd29cabe7603c80fdc 100644 (file)
@@ -2656,7 +2656,7 @@ virCgroupKillPainfully(virCgroupPtr group)
         if (ret <= 0)
             break;
 
-        usleep(200 * 1000);
+        g_usleep(200 * 1000);
     }
     VIR_DEBUG("Complete %d", ret);
     return ret;
index bb844c64e5f24c67bcec852589a2657611284fab..dead335c6264ceddf33f0a81da92ef428957b92e 100644 (file)
@@ -4387,7 +4387,7 @@ virFileWaitForExists(const char *path,
         if (tries == 0 || errno != ENOENT)
             return -1;
 
-        usleep(ms * 1000);
+        g_usleep(ms * 1000);
     }
 
     return 0;
index 5c0e9723b915a350ae70d6cb6f967bc2c81acc8c..5fef0b79aab9474e51c22f15cfea25fd09808b73 100644 (file)
@@ -2304,7 +2304,7 @@ virNetDevSetNetConfig(const char *linkdev, int vf,
              * wait, then upcoming operations on the VF may fail.
              */
             while (retries-- > 0 && !virNetDevExists(linkdev))
-               usleep(1000);
+               g_usleep(1000);
         }
 
         if (pfDevOrig && setMACrc == 0) {
index e2009fd829e41a35ce33edd079d07176848b9fe7..e9d1ce0831001ece8cf11b03c9bd0e89115a2ef6 100644 (file)
@@ -465,7 +465,7 @@ virNetDevIPWaitDadFinish(virSocketAddrPtr *addrs, size_t count)
         /* Parse response. */
         dad = virNetDevIPParseDadStatus(resp, recvbuflen, addrs, count);
         if (dad)
-            usleep(1000 * 10);
+            g_usleep(1000 * 10);
     }
     /* Check timeout. */
     if (dad) {
index e8a9b052b6f7c6aca8be885719add7985fc26a71..efd81c3aa095e5679789a42c5250b4726887d6e2 100644 (file)
@@ -404,7 +404,7 @@ virNetDevMacVLanTapOpen(const char *ifname,
                 tapfd[i] = fd;
             } else if (retries-- > 0) {
                 /* may need to wait for udev to be done */
-                usleep(20000);
+                g_usleep(20000);
             } else {
                 /* However, if haven't succeeded, quit. */
                 virReportSystemError(errno,
index a5ecd783f23b49dbfe79f5dc306fa3d1fce4fa97..048f8919207a3223d22046035f744eb5d1048a65 100644 (file)
@@ -999,7 +999,7 @@ virNetDevVPortProfileOpCommon(const char *ifname, int ifindex,
             break;
         }
 
-        usleep(STATUS_POLL_INTERVL_USEC);
+        g_usleep(STATUS_POLL_INTERVL_USEC);
     }
 
     if (status == PORT_PROFILE_RESPONSE_INPROGRESS) {
index ee78151e748d5eb65dfb69afa6c12d5950203f5c..9b828b77818f3e60776bd8ac5ad128a65a0d6677 100644 (file)
@@ -833,11 +833,11 @@ virPCIDeviceTrySecondaryBusReset(virPCIDevicePtr dev,
     virPCIDeviceWrite16(parent, parentfd, PCI_BRIDGE_CONTROL,
                         ctl | PCI_BRIDGE_CTL_RESET);
 
-    usleep(200 * 1000); /* sleep 200ms */
+    g_usleep(200 * 1000); /* sleep 200ms */
 
     virPCIDeviceWrite16(parent, parentfd, PCI_BRIDGE_CONTROL, ctl);
 
-    usleep(200 * 1000); /* sleep 200ms */
+    g_usleep(200 * 1000); /* sleep 200ms */
 
     if (virPCIDeviceWrite(dev, cfgfd, 0, config_space, PCI_CONF_LEN) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -881,12 +881,12 @@ virPCIDeviceTryPowerManagementReset(virPCIDevicePtr dev, int cfgfd)
     virPCIDeviceWrite32(dev, cfgfd, dev->pci_pm_cap_pos + PCI_PM_CTRL,
                         ctl | PCI_PM_CTRL_STATE_D3hot);
 
-    usleep(10 * 1000); /* sleep 10ms */
+    g_usleep(10 * 1000); /* sleep 10ms */
 
     virPCIDeviceWrite32(dev, cfgfd, dev->pci_pm_cap_pos + PCI_PM_CTRL,
                         ctl | PCI_PM_CTRL_STATE_D0);
 
-    usleep(10 * 1000); /* sleep 10ms */
+    g_usleep(10 * 1000); /* sleep 10ms */
 
     if (virPCIDeviceWrite(dev, cfgfd, 0, &config_space[0], PCI_CONF_LEN) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
index 66834d37d3518fbb2d0ea3d1c7832fb01b3129c0..b1544af7309103977fb1a03aea308ef17f247fb5 100644 (file)
@@ -177,7 +177,7 @@ virProcessAbort(pid_t pid)
     } else if (ret == 0) {
         VIR_DEBUG("trying SIGTERM to child process %d", pid);
         kill(pid, SIGTERM);
-        usleep(10 * 1000);
+        g_usleep(10 * 1000);
         while ((ret = waitpid(pid, &status, WNOHANG)) == -1 &&
                errno == EINTR);
         if (ret == pid) {
@@ -399,7 +399,7 @@ virProcessKillPainfullyDelay(pid_t pid, bool force, unsigned int extradelay)
             goto cleanup; /* process is dead */
         }
 
-        usleep(200 * 1000);
+        g_usleep(200 * 1000);
     }
 
     virReportSystemError(EBUSY,
index 86993e4e8d3ae8b3eb35ad3766041fd13aed9aa7..6f978d7c642b7f9da1563fceb19dd4a3550647ee 100644 (file)
@@ -448,6 +448,6 @@ virTimeBackOffWait(virTimeBackOffVar *var)
 
     VIR_DEBUG("sleeping for %llu ms", next);
 
-    usleep(next * 1000);
+    g_usleep(next * 1000);
     return 1;
 }
index d3b8fb625f314a931317eb0c009f3aa98d26bf62..748133933c953afbf366ed047db9098c5b190173 100644 (file)
@@ -7932,7 +7932,7 @@ vboxDomainSendKey(virDomainPtr dom,
     /* since VBOX does not support holdtime, simulate it by sleeping and
        then sending the release key scancodes */
     if (holdtime > 0)
-        usleep(holdtime * 1000);
+        g_usleep(holdtime * 1000);
 
     rc = gVBoxAPI.UIKeyboard.PutScancodes(keyboard, nkeycodes, keyUpCodes,
                                           &codesStored);
index 2aaddef3d1bea705244a2d9ca7bcb7aa13fe0103..2ec3434f1e75915088a9e024946d73a055d02f86 100644 (file)
@@ -262,7 +262,7 @@ static int test4(const void *unused ATTRIBUTE_UNUSED)
         goto cleanup;
     }
     while (kill(pid, 0) != -1)
-        usleep(100*1000);
+        g_usleep(100*1000);
 
     ret = checkoutput("test4", NULL);
 
@@ -751,7 +751,7 @@ static int test18(const void *unused ATTRIBUTE_UNUSED)
     }
 
     while (kill(pid, SIGINT) != -1)
-        usleep(100*1000);
+        g_usleep(100*1000);
 
     ret = 0;
 
@@ -1052,7 +1052,7 @@ static int test25(const void *unused ATTRIBUTE_UNUSED)
                 goto cleanup;
             }
 
-            usleep(10 * 1000);
+            g_usleep(10 * 1000);
         } else {
             break;
         }
index f426469d213b8777c3d146db238437be6bcc1e3f..f04b416ad25c9a41e59070e335be43a5492d8ab8 100644 (file)
@@ -382,7 +382,7 @@ mymain(void)
     startJob();
     pthread_mutex_unlock(&eventThreadMutex);
     sched_yield();
-    usleep(100 * 1000);
+    g_usleep(100 * 1000);
     pthread_mutex_lock(&eventThreadMutex);
     virEventPollRemoveHandle(handles[1].watch);
     if (finishJob("Interrupted during poll", -1, -1) != EXIT_SUCCESS)
@@ -448,7 +448,7 @@ mymain(void)
     startJob();
     pthread_mutex_unlock(&eventThreadMutex);
     sched_yield();
-    usleep(100 * 1000);
+    g_usleep(100 * 1000);
     pthread_mutex_lock(&eventThreadMutex);
     virEventPollRemoveTimeout(timers[1].timer);
     if (finishJob("Interrupted during poll", -1, -1) != EXIT_SUCCESS)
index 054c405cec6d5968293b20263913f0793d230ea6..98519e626684328bc90e26b7348f41014f914d88 100644 (file)
@@ -101,7 +101,7 @@ static int testFDStreamReadCommon(const char *scratchdir, bool blocking)
             got = st->driver->streamRecv(st, buf + offset, want);
             if (got < 0) {
                 if (got == -2 && !blocking) {
-                    usleep(20 * 1000);
+                    g_usleep(20 * 1000);
                     goto reread;
                 }
                 virFilePrintf(stderr, "Failed to read stream: %s\n",
@@ -222,7 +222,7 @@ static int testFDStreamWriteCommon(const char *scratchdir, bool blocking)
             got = st->driver->streamSend(st, pattern + offset, want);
             if (got < 0) {
                 if (got == -2 && !blocking) {
-                    usleep(20 * 1000);
+                    g_usleep(20 * 1000);
                     goto rewrite;
                 }
                 if (i == 9 &&
index fbfdc09c0d54daae294a13075950352f44551414..c2e7c2b227f5fd98a5862478c4af3362410f519e 100644 (file)
@@ -1945,7 +1945,7 @@ virshBlockJobWait(virshBlockJobWaitDataPtr data)
             break;
         }
 
-        usleep(500 * 1000);
+        g_usleep(500 * 1000);
     }
 
     /* print 100% completed */