Re: [PATCH] conf: add localtime support in guest clock with variable attibute

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

 



On 24.12.2013 07:31, Jincheng Miao wrote:
commit b8bf79a, which add clock=variable, forgets to check localtime
basis in qemuBuildClockArgStr(). So that localtime basis could not
be used, like this bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1046192
---
  src/qemu/qemu_command.c | 14 ++++++++++----
  1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d723dc8..749ad54 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6490,15 +6490,21 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
          time_t now = time(NULL);
          struct tm nowbits;

-        if (def->data.variable.basis != VIR_DOMAIN_CLOCK_BASIS_UTC) {
+        if (def->data.variable.basis == VIR_DOMAIN_CLOCK_BASIS_UTC) {
+            now += def->data.variable.adjustment;
+            gmtime_r(&now, &nowbits);
+        }
+        else if (def->data.variable.basis == VIR_DOMAIN_CLOCK_BASIS_LOCALTIME) {
+            now += def->data.variable.adjustment;
+            localtime_r(&now, &nowbits);
+        }
+        else {
              virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                             _("unsupported clock basis '%s'"),
                             virDomainClockBasisTypeToString(def->data.variable.basis));
              goto error;
          }
-        now += def->data.variable.adjustment;
-        gmtime_r(&now, &nowbits);
-
+
          /* Store the guest's basedate */
          def->data.variable.basedate = now;



I've changed the patch to use switch instead of if-else and introduced a test:

https://www.redhat.com/archives/libvir-list/2014-February/msg00250.html

Michal

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