[PATCH 1/2] qemuBuildClockArgStr: Allow localtime clock basis

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

 



https://bugzilla.redhat.com/show_bug.cgi?id=1046192

Commit b8bf79a, which adds clock='variable', forgets to check
localtime basis in qemuBuildClockArgStr(). So that localtime
basis could not be used.

Reported-by: Jincheng Miao <jmiao@xxxxxxxxxx>
Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5b94de1..6cc32f9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6491,14 +6491,18 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
         time_t now = time(NULL);
         struct tm nowbits;
 
-        if (def->data.variable.basis != VIR_DOMAIN_CLOCK_BASIS_UTC) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("unsupported clock basis '%s'"),
-                           virDomainClockBasisTypeToString(def->data.variable.basis));
-            goto error;
+        switch ((enum virDomainClockBasis) def->data.variable.basis) {
+        case VIR_DOMAIN_CLOCK_BASIS_UTC:
+            now += def->data.variable.adjustment;
+            gmtime_r(&now, &nowbits);
+            break;
+        case VIR_DOMAIN_CLOCK_BASIS_LOCALTIME:
+            now += def->data.variable.adjustment;
+            localtime_r(&now, &nowbits);
+            break;
+        case VIR_DOMAIN_CLOCK_BASIS_LAST:
+            break;
         }
-        now += def->data.variable.adjustment;
-        gmtime_r(&now, &nowbits);
 
         /* Store the guest's basedate */
         def->data.variable.basedate = now;
-- 
1.8.5.2

--
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]