]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Add support for reboot-timeout
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 18 Sep 2012 10:30:52 +0000 (12:30 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 20 Sep 2012 14:41:01 +0000 (16:41 +0200)
Whenever the guest machine fails to boot, new parameter (reboot-timeout)
controls whether it should reboot and after how many ms it should do so.

Docs included.

docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h

index 51f897cd9cd853db8b74c7af992e535dd216ae2e..a403ba8c5bb2621e115db8d318f00449af4aa999 100644 (file)
     &lt;boot dev='cdrom'/&gt;
     &lt;bootmenu enable='yes'/&gt;
     &lt;smbios mode='sysinfo'/&gt;
-    &lt;bios useserial='yes'/&gt;
+    &lt;bios useserial='yes' rebootTimeout='0'/&gt;
   &lt;/os&gt;
   ...</pre>
 
         Serial Graphics Adapter which allows users to see BIOS messages
         on a serial port. Therefore, one needs to have
         <a href="#elementCharSerial">serial port</a> defined.
-        <span class="since">Since 0.9.4</span>
-      </dd>
+        <span class="since">Since 0.9.4</span>.
+        <span class="since">Since 0.10.2 (QEMU only)</span> there is
+        another attribute, <code>rebootTimeout</code> that controls
+        whether and after how long the guest should start booting
+        again in case the boot fails (according to BIOS). The value is
+        in milliseconds with maximum of <code>65535</code> and special
+        value <code>-1</code> disables the reboot.
     </dl>
 
     <h4><a name="elementsOSBootloader">Host bootloader</a></h4>
index aafb10c575d713870406259f773b82e18e7cbaf3..afa6bbd19f6265ff44ecb96aa51cf1ae4fddc9c4 100644 (file)
 
   <define name="bios">
     <element name="bios">
-      <attribute name="useserial">
-        <choice>
-          <value>yes</value>
-          <value>no</value>
-        </choice>
-      </attribute>
+      <optional>
+        <attribute name="useserial">
+          <choice>
+            <value>yes</value>
+            <value>no</value>
+          </choice>
+        </attribute>
+      </optional>
+      <optional>
+        <attribute name="rebootTimeout">
+          <ref name="rebootTimeoutDelay"/>
+        </attribute>
+      </optional>
     </element>
   </define>
 
       <param name='minInclusive'>-1</param>
     </data>
   </define>
+  <define name="rebootTimeoutDelay">
+    <data type="short">
+      <param name="minInclusive">-1</param>
+    </data>
+  </define>
   <define name="PortNumber">
     <data type="short">
       <param name="minInclusive">-1</param>
index 35814fb021b907b1066b7a82c75010586b74d3a9..d6f2ebfe20a3e188834fe52cb13fb85f18dc5391 100644 (file)
@@ -8136,7 +8136,7 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt,
 {
     xmlNodePtr *nodes = NULL;
     int i, n;
-    char *bootstr;
+    char *bootstr, *tmp;
     char *useserial = NULL;
     int ret = -1;
     unsigned long deviceBoot, serialPorts;
@@ -8214,10 +8214,25 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt,
         }
     }
 
+    tmp = virXPathString("string(./os/bios[1]/@rebootTimeout)", ctxt);
+    if (tmp) {
+        /* that was really just for the check if it is there */
+
+        if (virStrToLong_i(tmp, NULL, 0, &def->os.bios.rt_delay) < 0 ||
+            def->os.bios.rt_delay < -1 || def->os.bios.rt_delay > 65535) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("invalid value for rebootTimeout, "
+                             "must be in range [-1,65535]"));
+            goto cleanup;
+        }
+        def->os.bios.rt_set = true;
+    }
+
     *bootCount = deviceBoot;
     ret = 0;
 
 cleanup:
+    VIR_FREE(tmp);
     VIR_FREE(useserial);
     VIR_FREE(nodes);
     return ret;
@@ -13494,11 +13509,17 @@ virDomainDefFormatInternal(virDomainDefPtr def,
             virBufferAsprintf(buf, "    <bootmenu enable='%s'/>\n", enabled);
         }
 
-        if (def->os.bios.useserial) {
-            const char *useserial = (def->os.bios.useserial ==
-                                     VIR_DOMAIN_BIOS_USESERIAL_YES ? "yes"
-                                                                   : "no");
-            virBufferAsprintf(buf, "    <bios useserial='%s'/>\n", useserial);
+        if (def->os.bios.useserial || def->os.bios.rt_set) {
+            virBufferAddLit(buf, "    <bios");
+            if (def->os.bios.useserial)
+                virBufferAsprintf(buf, " useserial='%s'",
+                                  (def->os.bios.useserial ==
+                                   VIR_DOMAIN_BIOS_USESERIAL_YES ? "yes"
+                                                                   : "no"));
+            if (def->os.bios.rt_set)
+                virBufferAsprintf(buf, " rebootTimeout='%d'", def->os.bios.rt_delay);
+
+            virBufferAddLit(buf, "/>\n");
         }
     }
 
index 510406a631460aeeb8f6c0dc5759bb18925b9f33..d719d57dad7b2d6f6c47871c6a899fb033815bf3 100644 (file)
@@ -1420,6 +1420,9 @@ typedef struct _virDomainBIOSDef virDomainBIOSDef;
 typedef virDomainBIOSDef *virDomainBIOSDefPtr;
 struct _virDomainBIOSDef {
     int useserial;
+    /* reboot-timeout parameters */
+    bool rt_set;
+    int rt_delay;
 };
 
 /* Operating system configuration data & machine / arch */