]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Add on_lockfailure event configuration
authorJiri Denemark <jdenemar@redhat.com>
Thu, 6 Sep 2012 20:17:01 +0000 (22:17 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 11 Oct 2012 12:41:41 +0000 (14:41 +0200)
Using this new element, one can configure an action that should be
performed when resource locks are lost.

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

index f6f24b1c28d42d6a36a47bd88deddc1bc34264f5..71b2f76a5239f72cec422415a8654d5f2c02a33a 100644 (file)
   &lt;on_poweroff&gt;destroy&lt;/on_poweroff&gt;
   &lt;on_reboot&gt;restart&lt;/on_reboot&gt;
   &lt;on_crash&gt;restart&lt;/on_crash&gt;
+  &lt;on_lockfailure&gt;poweroff&lt;/on_lockfailure&gt;
   ...</pre>
 
     <p>
         domain will be restarted with the same configuration</dd>
     </dl>
 
+    <p>
+      The <code>on_lockfailure</code> element (<span class="since">since
+      0.10.3</span>) may be used to configure what action should be
+      taken when a lock manager loses resource locks. The following
+      actions are recognized by libvirt, although not all of them need
+      to be supported by individual lock managers. When no action is
+      specified, each lock manager will take its default action.
+    </p>
+    <dl>
+      <dt><code>poweroff</code></dt>
+      <dd>The domain will be forcefully powered off.</dd>
+      <dt><code>restart</code></dt>
+      <dd>The domain will be powered off and started up again to
+        reacquire its locks.</dd>
+      <dt><code>pause</code></dt>
+      <dd>The domain will be paused so that it can be manually resumed
+        when lock issues are solved.</dd>
+      <dt><code>ignore</code></dt>
+      <dd>Keep the domain running as if nothing happened.</dd>
+    </dl>
+
     <h3><a name="elementsPowerManagement">Power Management</a></h3>
 
     <p>
index ab8d4a11f769b77374e9f6853622ca03573da974..2df2efa7012d29164f3a61a83a97365da41521d2 100644 (file)
           <ref name="crashOptions"/>
         </element>
       </optional>
+      <optional>
+        <element name="on_lockfailure">
+          <ref name="lockfailureOptions"/>
+        </element>
+      </optional>
     </interleave>
   </define>
   <!--
       <value>coredump-restart</value>
     </choice>
   </define>
+  <!--
+      Options when resource locks are lost:
+      poweroff: power off the domain
+      restart: power off the domain and start it up again to reacquire the
+               locks
+      pause: pause the execution of the domain so that it can be manually
+             resumed when lock issues are solved
+      ignore: keep the domain running
+  -->
+  <define name="lockfailureOptions">
+    <choice>
+      <value>poweroff</value>
+      <value>restart</value>
+      <value>pause</value>
+      <value>ignore</value>
+    </choice>
+  </define>
   <!--
       Control ACPI sleep states (dis)allowed for the domain
       For each of the states the following rules apply:
index 40abf398208a279420fd69f68d71dcd7dbd73aae..120d82f543749513b389a15fc6b65db6a8a4569f 100644 (file)
@@ -134,6 +134,13 @@ VIR_ENUM_IMPL(virDomainLifecycleCrash, VIR_DOMAIN_LIFECYCLE_CRASH_LAST,
               "coredump-destroy",
               "coredump-restart")
 
+VIR_ENUM_IMPL(virDomainLockFailure, VIR_DOMAIN_LOCK_FAILURE_LAST,
+              "default",
+              "poweroff",
+              "restart",
+              "pause",
+              "ignore")
+
 VIR_ENUM_IMPL(virDomainPMState, VIR_DOMAIN_PM_STATE_LAST,
               "default",
               "yes",
@@ -8963,6 +8970,13 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
                                      virDomainLifecycleCrashTypeFromString) < 0)
         goto error;
 
+    if (virDomainEventActionParseXML(ctxt, "on_lockfailure",
+                                     "string(./on_lockfailure[1])",
+                                     &def->onLockFailure,
+                                     VIR_DOMAIN_LOCK_FAILURE_DEFAULT,
+                                     virDomainLockFailureTypeFromString) < 0)
+        goto error;
+
     if (virDomainPMStateParseXML(ctxt,
                                  "string(./pm/suspend-to-mem/@enabled)",
                                  &def->pm.s3) < 0)
@@ -13692,6 +13706,11 @@ virDomainDefFormatInternal(virDomainDefPtr def,
                                       "on_crash",
                                       virDomainLifecycleCrashTypeToString) < 0)
         goto cleanup;
+    if (def->onLockFailure != VIR_DOMAIN_LOCK_FAILURE_DEFAULT &&
+        virDomainEventActionDefFormat(buf, def->onLockFailure,
+                                      "on_lockfailure",
+                                      virDomainLockFailureTypeToString) < 0)
+        goto cleanup;
 
     if (def->pm.s3 || def->pm.s4) {
         virBufferAddLit(buf, "  <pm>\n");
index 0ae6e48e3471e062ff921b12302dc2dd809f66af..c41e0cfc287e4fb625d8ae215dec1895be2221f2 100644 (file)
@@ -1413,6 +1413,18 @@ enum virDomainLifecycleCrashAction {
     VIR_DOMAIN_LIFECYCLE_CRASH_LAST
 };
 
+typedef enum {
+    VIR_DOMAIN_LOCK_FAILURE_DEFAULT,
+    VIR_DOMAIN_LOCK_FAILURE_POWEROFF,
+    VIR_DOMAIN_LOCK_FAILURE_RESTART,
+    VIR_DOMAIN_LOCK_FAILURE_PAUSE,
+    VIR_DOMAIN_LOCK_FAILURE_IGNORE,
+
+    VIR_DOMAIN_LOCK_FAILURE_LAST
+} virDomainLockFailureAction;
+
+VIR_ENUM_DECL(virDomainLockFailure)
+
 enum virDomainPMState {
     VIR_DOMAIN_PM_STATE_DEFAULT = 0,
     VIR_DOMAIN_PM_STATE_ENABLED,
@@ -1681,6 +1693,8 @@ struct _virDomainDef {
     int onPoweroff;
     int onCrash;
 
+    int onLockFailure; /* enum virDomainLockFailureAction */
+
     struct {
         /* These options are actually type of enum virDomainPMState */
         int s3;
index a8c81e7cb9e2b58e886ccc41ed126e4ca46b1205..fe31bbea4ffb7249dc9ffa8b640f09d24d62e9c7 100644 (file)
@@ -421,6 +421,8 @@ virDomainLifecycleTypeFromString;
 virDomainLifecycleTypeToString;
 virDomainLiveConfigHelperMethod;
 virDomainLoadAllConfigs;
+virDomainLockFailureTypeFromString;
+virDomainLockFailureTypeToString;
 virDomainMemballoonModelTypeFromString;
 virDomainMemballoonModelTypeToString;
 virDomainMemDumpTypeFromString;