diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index b7e145e0fa..58d86f9535 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1622,6 +1622,13 @@ domain will be restarted with the same configuration +
+ Since 3.9.0, the lifecycle events can
+ be configured via the
+
+ virDomainSetLifecycleAction
API.
+
The on_lockfailure
element (since
1.0.0) may be used to configure what action should be
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 9fb94a9837..4048acf38a 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -4728,4 +4728,32 @@ int virDomainSetBlockThreshold(virDomainPtr domain,
unsigned long long threshold,
unsigned int flags);
+typedef enum {
+ VIR_DOMAIN_LIFECYCLE_POWEROFF = 0,
+ VIR_DOMAIN_LIFECYCLE_REBOOT = 1,
+ VIR_DOMAIN_LIFECYCLE_CRASH = 2,
+
+# ifdef VIR_ENUM_SENTINELS
+ VIR_DOMAIN_LIFECYCLE_LAST
+# endif
+} virDomainLifecycle;
+
+typedef enum {
+ VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY = 0,
+ VIR_DOMAIN_LIFECYCLE_ACTION_RESTART = 1,
+ VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME = 2,
+ VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE = 3,
+ VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY = 4,
+ VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART = 5,
+
+# ifdef VIR_ENUM_SENTINELS
+ VIR_DOMAIN_LIFECYCLE_ACTION_LAST
+# endif
+} virDomainLifecycleAction;
+
+int virDomainSetLifecycleAction(virDomainPtr domain,
+ unsigned int type,
+ unsigned int action,
+ unsigned int flags);
+
#endif /* __VIR_LIBVIRT_DOMAIN_H__ */
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 38b966f6de..8240433611 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1791,25 +1791,6 @@ typedef enum {
VIR_DOMAIN_CAPS_FEATURE_LAST
} virDomainCapsFeature;
-typedef enum {
- VIR_DOMAIN_LIFECYCLE_POWEROFF,
- VIR_DOMAIN_LIFECYCLE_REBOOT,
- VIR_DOMAIN_LIFECYCLE_CRASH,
-
- VIR_DOMAIN_LIFECYCLE_LAST
-} virDomainLifecycle;
-
-typedef enum {
- VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY,
- VIR_DOMAIN_LIFECYCLE_ACTION_RESTART,
- VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME,
- VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE,
- VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY,
- VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART,
-
- VIR_DOMAIN_LIFECYCLE_ACTION_LAST
-} virDomainLifecycleAction;
-
typedef enum {
VIR_DOMAIN_LOCK_FAILURE_DEFAULT,
VIR_DOMAIN_LOCK_FAILURE_POWEROFF,
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 4de0581c3f..ce0e2b2525 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -1277,6 +1277,12 @@ typedef int
unsigned long long threshold,
unsigned int flags);
+typedef int
+(*virDrvDomainSetLifecycleAction)(virDomainPtr domain,
+ unsigned int type,
+ unsigned int action,
+ unsigned int flags);
+
typedef struct _virHypervisorDriver virHypervisorDriver;
typedef virHypervisorDriver *virHypervisorDriverPtr;
@@ -1521,6 +1527,7 @@ struct _virHypervisorDriver {
virDrvDomainSetGuestVcpus domainSetGuestVcpus;
virDrvDomainSetVcpu domainSetVcpu;
virDrvDomainSetBlockThreshold domainSetBlockThreshold;
+ virDrvDomainSetLifecycleAction domainSetLifecycleAction;
};
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index fc2e4ce381..a51d8e3820 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -12035,3 +12035,59 @@ virDomainSetBlockThreshold(virDomainPtr domain,
virDispatchError(domain->conn);
return -1;
}
+
+
+/**
+ * virDomainSetLifecycleAction:
+ * @domain: pointer to domain object
+ * @type: the lifecycle type from virDomainLifecycle
+ * @action: the action type from virDomainLifecycleAction
+ * @flags: bitwise-OR of virDomainModificationImpact
+ *
+ * Changes the actions of lifecycle events for domain represented as
+ *