[PATCH 2/7] conf: Add on_lockfailure event configuration

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

 



Using this new element, one can configure an action that should be
performed when resource locks are lost.
---
 docs/formatdomain.html.in     | 22 ++++++++++++++++++++++
 docs/schemas/domaincommon.rng | 22 ++++++++++++++++++++++
 src/conf/domain_conf.c        | 19 +++++++++++++++++++
 src/conf/domain_conf.h        | 14 ++++++++++++++
 src/libvirt_private.syms      |  2 ++
 5 files changed, 79 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 57444fb..1001055 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -919,6 +919,7 @@
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
+  <on_lockfailure>poweroff</on_lockfailure>
   ...</pre>
 
     <p>
@@ -974,6 +975,27 @@
         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>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index ab8d4a1..2df2efa 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2246,6 +2246,11 @@
           <ref name="crashOptions"/>
         </element>
       </optional>
+      <optional>
+        <element name="on_lockfailure">
+          <ref name="lockfailureOptions"/>
+        </element>
+      </optional>
     </interleave>
   </define>
   <!--
@@ -2288,6 +2293,23 @@
     </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:
       on: the state will be forcefully enabled
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 40abf39..120d82f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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");
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 0ae6e48..c41e0cf 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -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;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index dab607a..9e04d2b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -421,6 +421,8 @@ virDomainLifecycleTypeFromString;
 virDomainLifecycleTypeToString;
 virDomainLiveConfigHelperMethod;
 virDomainLoadAllConfigs;
+virDomainLockFailureTypeFromString;
+virDomainLockFailureTypeToString;
 virDomainMemballoonModelTypeFromString;
 virDomainMemballoonModelTypeToString;
 virDomainMemDumpTypeFromString;
-- 
1.7.12

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