[PATCH] test_driver: provide virDomainGetTime implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Implement testDomainGetTime by returning the current time.

Signed-off-by: Ilias Stamatis <stamatis.iliass@xxxxxxxxx>
---
 I initially implemented this using clock_gettime, but Pavel suggested
 that this might not be a good idea since it isn't a cross-platform
 function. So I used virTimeMillisNow instead and set the nanoseconds
 part to 0 which can be ok for the test driver.

 src/test/test_driver.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index d5eecf4b7f..b6f12e784f 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -64,6 +64,7 @@
 #include "virinterfaceobj.h"
 #include "virhostcpu.h"
 #include "virdomainsnapshotobjlist.h"
+#include "virtime.h"

 #define VIR_FROM_THIS VIR_FROM_TEST

@@ -1943,6 +1944,23 @@ testDomainGetState(virDomainPtr domain,
     return 0;
 }

+static int
+testDomainGetTime(virDomainPtr dom ATTRIBUTE_UNUSED,
+                  long long *seconds,
+                  unsigned int *nseconds,
+                  unsigned int flags ATTRIBUTE_UNUSED)
+{
+    unsigned long long now;
+
+    if (virTimeMillisNow(&now) < 0)
+        return -1;
+
+    *seconds = now / 1000;
+    *nseconds = 0;
+
+    return 0;
+}
+
 #define TEST_SAVE_MAGIC "TestGuestMagic"

 static int
@@ -6786,6 +6804,7 @@ static virHypervisorDriver testHypervisorDriver = {
     .domainSetMemory = testDomainSetMemory, /* 0.1.4 */
     .domainGetInfo = testDomainGetInfo, /* 0.1.1 */
     .domainGetState = testDomainGetState, /* 0.9.2 */
+    .domainGetTime = testDomainGetTime, /* 5.3.0 */
     .domainSave = testDomainSave, /* 0.3.2 */
     .domainSaveFlags = testDomainSaveFlags, /* 0.9.4 */
     .domainRestore = testDomainRestore, /* 0.3.2 */
--
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux