Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
docs/formatdomain.html.in | 6 +++++
include/libvirt/libvirt-domain.h | 28 ++++++++++++++++++++
src/conf/domain_conf.h | 19 --------------
src/driver-hypervisor.h | 7 +++++
src/libvirt-domain.c | 56 ++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 5 ++++
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 14 +++++++++-
8 files changed, 116 insertions(+), 20 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index b93ace7cba..cb19a547fe 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1623,6 +1623,12 @@
</dl>
<p>
+ The lifecycle events can be configured via
+ virDomainSetLifecycleAction() API
+ <span class="since">since 3.9.0 (QEMU only)</span>.
+ </p>
+
+ <p>
The <code>on_lockfailure</code> element (<span class="since">since
1.0.0</span>) may be used to configure what action should be
taken when a lock manager loses resource locks. The following
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
@@ -1792,25 +1792,6 @@ typedef enum {
} 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,
VIR_DOMAIN_LOCK_FAILURE_RESTART,
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
+ * <on_$type>$action</on_$type> in the domain XML.
+ *
+ * Returns 0 on success, -1 on failure.
+ */
+int virDomainSetLifecycleAction(virDomainPtr domain,
+ unsigned int type,
+ unsigned int action,
+ unsigned int flags)
+{
+ VIR_DOMAIN_DEBUG(domain, "type='%u' action='%u' flags='0x%x'",
+ type, action, flags);
+
+ virResetLastError();
+
+ virCheckDomainReturn(domain, -1);
+ virCheckReadOnlyGoto(domain->conn->flags, error);
+
+ if (type >= VIR_DOMAIN_LIFECYCLE_LAST) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("invalid lifecycle type '%u'"), type);
+ goto error;
+ }
+
+ if (action >= VIR_DOMAIN_LIFECYCLE_ACTION_LAST) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("invalid lifecycle action '%u'"), action);
+ goto error;
+ }
+
+ if (domain->conn->driver->domainSetLifecycleAction) {
+ int ret;
+ ret = domain->conn->driver->domainSetLifecycleAction(domain,
+ type,
+ action,
+ flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virReportUnsupportedError();
+
+ error:
+ virDispatchError(domain->conn);
+ return -1;
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 4986019431..0efde25a7f 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -774,4 +774,9 @@ LIBVIRT_3.7.0 {
virDomainManagedSaveGetXMLDesc;
virDomainManagedSaveDefineXML;
} LIBVIRT_3.4.0;
+
+LIBVIRT_3.9.0 {
+ global:
+ virDomainSetLifecycleAction;
+} LIBVIRT_3.7.0;
# .... define new API here using predicted next version number ....
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 00e8086d51..06719bb825 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8497,6 +8497,7 @@ static virHypervisorDriver hypervisor_driver = {
.domainSetGuestVcpus = remoteDomainSetGuestVcpus, /* 2.0.0 */
.domainSetVcpu = remoteDomainSetVcpu, /* 3.1.0 */
.domainSetBlockThreshold = remoteDomainSetBlockThreshold, /* 3.2.0 */
+ .domainSetLifecycleAction = remoteDomainSetLifecycleAction /* 3.9.0 */
};
static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index e3014f66bc..0aed25220d 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -3433,6 +3433,12 @@ struct remote_domain_set_block_threshold_args {
unsigned int flags;
};
+struct remote_domain_set_lifecycle_action_args {
+ remote_nonnull_domain dom;
+ unsigned int type;
+ unsigned int action;
+ unsigned int flags;
+};
/*----- Protocol. -----*/
@@ -6108,5 +6114,11 @@ enum remote_procedure {
* @acl: domain:write
* @acl: domain:hibernate
*/
- REMOTE_PROC_DOMAIN_MANAGED_SAVE_DEFINE_XML = 389
+ REMOTE_PROC_DOMAIN_MANAGED_SAVE_DEFINE_XML = 389,
+
+ /**
+ * @generate: both
+ * @acl: domain:write
+ */
+ REMOTE_PROC_DOMAIN_SET_LIFECYCLE_ACTION = 390
};
--
2.13.6
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On 10/16/2017 07:06 AM, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
> docs/formatdomain.html.in | 6 +++++
> include/libvirt/libvirt-domain.h | 28 ++++++++++++++++++++
> src/conf/domain_conf.h | 19 --------------
> src/driver-hypervisor.h | 7 +++++
> src/libvirt-domain.c | 56 ++++++++++++++++++++++++++++++++++++++++
> src/libvirt_public.syms | 5 ++++
> src/remote/remote_driver.c | 1 +
> src/remote/remote_protocol.x | 14 +++++++++-
> 8 files changed, 116 insertions(+), 20 deletions(-)
Of course the aforementioned src/remote_protocol-structs will be here...
>
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index b93ace7cba..cb19a547fe 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -1623,6 +1623,12 @@
> </dl>
>
> <p>
> + The lifecycle events can be configured via
> + virDomainSetLifecycleAction() API
> + <span class="since">since 3.9.0 (QEMU only)</span>.
> + </p>
s/via/via the/
s/()//
Add the href like other examples, such as
<a href="html/libvirt-libvirt-domain.html#virDomainSetLifecycleAction">
<code>virDomainSetLifecycleAction</code>
</a>
I also don't think you can say "(QEMU only)" since the API exists in
libvirt - the implementation is only on QEMU, so you have to add some
text indicating not all hypervisors support.
You may also want to consider text like:
<span class="since">Since 3.9.0</span>, the lifecycle events can be
configured via the xxx API. Not all hypervisors support all events and
all actions.
I think having the since afterwards can be "confusing" sometimes, ymmv.
John
> +
> + <p>
> The <code>on_lockfailure</code> element (<span class="since">since
> 1.0.0</span>) may be used to configure what action should be
> taken when a lock manager loses resource locks. The following
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Wed, Oct 18, 2017 at 04:38:23PM -0400, John Ferlan wrote: > > > On 10/16/2017 07:06 AM, Pavel Hrdina wrote: > > Signed-off-by: Pavel Hrdina <phrdina@redhat.com> > > --- > > docs/formatdomain.html.in | 6 +++++ > > include/libvirt/libvirt-domain.h | 28 ++++++++++++++++++++ > > src/conf/domain_conf.h | 19 -------------- > > src/driver-hypervisor.h | 7 +++++ > > src/libvirt-domain.c | 56 ++++++++++++++++++++++++++++++++++++++++ > > src/libvirt_public.syms | 5 ++++ > > src/remote/remote_driver.c | 1 + > > src/remote/remote_protocol.x | 14 +++++++++- > > 8 files changed, 116 insertions(+), 20 deletions(-) > > Of course the aforementioned src/remote_protocol-structs will be here... > > > > > diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in > > index b93ace7cba..cb19a547fe 100644 > > --- a/docs/formatdomain.html.in > > +++ b/docs/formatdomain.html.in > > @@ -1623,6 +1623,12 @@ > > </dl> > > > > <p> > > + The lifecycle events can be configured via > > + virDomainSetLifecycleAction() API > > + <span class="since">since 3.9.0 (QEMU only)</span>. > > + </p> > > s/via/via the/ > s/()// > > Add the href like other examples, such as > > <a href="html/libvirt-libvirt-domain.html#virDomainSetLifecycleAction"> > <code>virDomainSetLifecycleAction</code> > </a> Fixed > I also don't think you can say "(QEMU only)" since the API exists in > libvirt - the implementation is only on QEMU, so you have to add some > text indicating not all hypervisors support. > > You may also want to consider text like: > > <span class="since">Since 3.9.0</span>, the lifecycle events can be > configured via the xxx API. Not all hypervisors support all events and > all actions. The sentence "Not all hypervisors ..." is used few paragraphs above this one so I'll just remove the (QEMU only) part. We actually have a matrix of supported APIs by drivers <https://libvirt.org/hvsupport.html> so there is no need to mention that not all hypervisors support this API. > I think having the since afterwards can be "confusing" sometimes, ymmv. Usually when it's at the end of a whole paragraph it indicates that everything in that paragraph is covered by the "since" limitation. It can definitely be at the beginning :) I personally don't care. Thanks Pavel -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2026 Red Hat, Inc.