]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemuBuildClockArgStr: Allow localtime clock basis
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 5 Feb 2014 14:30:11 +0000 (15:30 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 6 Feb 2014 06:51:07 +0000 (07:51 +0100)
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@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_command.c

index 5b94de13750d83fd408a7b971bf4bc6f89cca672..6cc32f9fc2023764260598f2ad8ee74dde3d0bcf 100644 (file)
@@ -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;