]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
domain: add tsc.on_reboot element
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 24 Mar 2022 09:48:38 +0000 (10:48 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 25 Mar 2022 15:30:48 +0000 (16:30 +0100)
Some versions of Windows hang on reboot if their TSC value is greater
than 2^54.  The workaround is to reset the TSC to a small value.  Add
to the domain configuration an attribute for this.  It can be used
by QEMU and in principle also by ESXi, which has a property called
monitor_control.enable_softResetClearTSC as well.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
docs/formatdomain.rst
src/conf/domain_conf.c
src/conf/domain_conf.h
src/conf/schemas/domaincommon.rng

index e4925320047fe6a7b6ebf0c2b572f74cfffda659..514c165bb54f05b41d8a862b9dab5e6236a05d9b 100644 (file)
@@ -2243,6 +2243,10 @@ Windows, however, expects it to be in so called 'localtime'.
    ``frequency``
       The ``frequency`` attribute is an unsigned integer specifying the
       frequency at which ``name="tsc"`` runs.
+   ``on_reboot``
+      The ``on_reboot`` attribute controls how the ``name="tsc"`` timer behaves
+      when the VM is reset, and can be "default", "clear" or "keep". The reset
+      behavior of other timers is hardcoded, and depends on the type of timer.
    ``mode``
       The ``mode`` attribute controls how the ``name="tsc"`` timer is managed,
       and can be "auto", "native", "emulate", "paravirt", or "smpsafe". Other
index 731139f80fcbc135670d806606e53cdba2914447..ed927ab66942cfd0aa86f4eaf7b9789bc8f0a68f 100644 (file)
@@ -1217,6 +1217,13 @@ VIR_ENUM_IMPL(virDomainTimerMode,
               "smpsafe",
 );
 
+VIR_ENUM_IMPL(virDomainTimerRebootMode,
+              VIR_DOMAIN_TIMER_REBOOT_MODE_LAST,
+              "default",
+              "keep",
+              "clear",
+);
+
 VIR_ENUM_IMPL(virDomainStartupPolicy,
               VIR_DOMAIN_STARTUP_POLICY_LAST,
               "default",
@@ -12080,6 +12087,11 @@ virDomainTimerDefParseXML(xmlNodePtr node,
         }
     }
 
+    if (virXMLPropEnum(node, "on_reboot",
+                       virDomainTimerRebootModeTypeFromString,
+                       VIR_XML_PROP_NONZERO, &def->reboot) < 0)
+        goto error;
+
     catchup = virXPathNode("./catchup", ctxt);
     if (catchup != NULL) {
         ret = virXPathULong("string(./catchup/@threshold)", ctxt,
@@ -26158,6 +26170,11 @@ virDomainTimerDefFormat(virBuffer *buf,
             virBufferAsprintf(&timerAttr, " mode='%s'",
                               virDomainTimerModeTypeToString(def->mode));
         }
+
+        if (def->reboot) {
+            virBufferAsprintf(&timerAttr, " on_reboot='%s'",
+                              virDomainTimerRebootModeTypeToString(def->mode));
+        }
     }
 
     if (def->catchup.threshold > 0)
index 49c964e6e1c0f5e62cde8e1d5222fb4663fb8137..42db4b69c3feee680413ee981c4d1cdde54c6fc2 100644 (file)
@@ -2408,6 +2408,14 @@ typedef enum {
     VIR_DOMAIN_TIMER_MODE_LAST
 } virDomainTimerModeType;
 
+typedef enum {
+    VIR_DOMAIN_TIMER_REBOOT_MODE_DEFAULT = 0,
+    VIR_DOMAIN_TIMER_REBOOT_MODE_KEEP,
+    VIR_DOMAIN_TIMER_REBOOT_MODE_CLEAR,
+
+    VIR_DOMAIN_TIMER_REBOOT_MODE_LAST
+} virDomainTimerRebootModeType;
+
 typedef enum {
     VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC = 0,
     VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO,
@@ -2439,6 +2447,7 @@ struct _virDomainTimerDef {
     /* frequency & mode are only valid for name='tsc' */
     unsigned long long frequency; /* in Hz, unspecified = 0 */
     int mode;   /* enum virDomainTimerModeType */
+    virDomainTimerRebootModeType reboot;
 };
 
 typedef enum {
@@ -4033,6 +4042,7 @@ VIR_ENUM_DECL(virDomainClockBasis);
 VIR_ENUM_DECL(virDomainTimerName);
 VIR_ENUM_DECL(virDomainTimerTrack);
 VIR_ENUM_DECL(virDomainTimerTickpolicy);
+VIR_ENUM_DECL(virDomainTimerRebootMode);
 VIR_ENUM_DECL(virDomainTimerMode);
 VIR_ENUM_DECL(virDomainCpuPlacementMode);
 
index 34bccee2f52d61cd5b8d8a7f863166041ce8356e..8890034f52526fa5d9c724742cc4ee13583e61a9 100644 (file)
               <ref name="unsignedLong"/>
             </attribute>
           </optional>
+          <optional>
+            <attribute name="on_reboot">
+              <choice>
+                <value>clear</value>
+                <value>keep</value>
+              </choice>
+            </attribute>
+          </optional>
           <optional>
             <attribute name="mode">
               <choice>