This is used to control what happens (restart, stop, ...) to the VM
when it crashes, shuts down, ...
---
libvirt-gconfig/libvirt-gconfig-domain.c | 20 ++++++++++++++++++++
libvirt-gconfig/libvirt-gconfig-domain.h | 18 ++++++++++++++++++
libvirt-gconfig/libvirt-gconfig.sym | 3 +++
libvirt-gconfig/tests/test-domain-create.c | 4 ++++
4 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c
b/libvirt-gconfig/libvirt-gconfig-domain.c
index 2f34c1b..9a723cb 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain.c
@@ -300,6 +300,26 @@ void gvir_config_domain_set_seclabel(GVirConfigDomain *domain,
GVIR_CONFIG_OBJECT(seclabel));
}
+void gvir_config_domain_set_lifecycle(GVirConfigDomain *domain,
+ GVirConfigDomainLifecycleEvent event,
+ GVirConfigDomainLifecycleAction action)
+{
+ const char *event_str;
+ const char *action_str;
+
+ g_return_if_fail((event == GVIR_CONFIG_DOMAIN_LIFECYCLE_ON_CRASH) ||
+ ((action != GVIR_CONFIG_DOMAIN_LIFECYCLE_COREDUMP_DESTROY)
&&
+ (action != GVIR_CONFIG_DOMAIN_LIFECYCLE_COREDUMP_RESTART)));
+
+ event_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DOMAIN_LIFECYCLE_EVENT,
event);
+ g_return_if_fail(event_str != NULL);
+ action_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DOMAIN_LIFECYCLE_ACTION,
action);
+ g_return_if_fail(action_str != NULL);
+
+ gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(domain),
+ event_str, action_str);
+}
+
/**
* gvir_config_domain_set_devices:
* @devices: (in) (element-type LibvirtGConfig.DomainDevice):
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.h
b/libvirt-gconfig/libvirt-gconfig-domain.h
index 7b40f99..b96aae0 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain.h
@@ -69,6 +69,21 @@ typedef enum {
GVIR_CONFIG_DOMAIN_VIRT_LXC,
} GVirConfigDomainVirtType;
+typedef enum {
+ GVIR_CONFIG_DOMAIN_LIFECYCLE_ON_POWEROFF, /*< nick=on_poweroff >*/
+ GVIR_CONFIG_DOMAIN_LIFECYCLE_ON_REBOOT, /*< nick=on_reboot >*/
+ GVIR_CONFIG_DOMAIN_LIFECYCLE_ON_CRASH /*< nick=on_crash >*/
+} GVirConfigDomainLifecycleEvent;
+
+typedef enum {
+ GVIR_CONFIG_DOMAIN_LIFECYCLE_DESTROY,
+ GVIR_CONFIG_DOMAIN_LIFECYCLE_RESTART,
+ GVIR_CONFIG_DOMAIN_LIFECYCLE_PRESERVE,
+ GVIR_CONFIG_DOMAIN_LIFECYCLE_RENAME_RESTART,
+ GVIR_CONFIG_DOMAIN_LIFECYCLE_COREDUMP_DESTROY,
+ GVIR_CONFIG_DOMAIN_LIFECYCLE_COREDUMP_RESTART
+} GVirConfigDomainLifecycleAction;
+
GType gvir_config_domain_get_type(void);
GVirConfigDomain *gvir_config_domain_new_from_xml(const gchar *xml, GError **error);
@@ -95,6 +110,9 @@ void gvir_config_domain_set_devices(GVirConfigDomain *domain,
GList *devices);
void gvir_config_domain_add_device(GVirConfigDomain *domain,
GVirConfigDomainDevice *device);
+void gvir_config_domain_set_lifecycle(GVirConfigDomain *domain,
+ GVirConfigDomainLifecycleEvent event,
+ GVirConfigDomainLifecycleAction action);
G_END_DECLS
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 9b6d420..c5726b9 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -9,12 +9,15 @@ LIBVIRT_GCONFIG_0.0.1 {
gvir_config_domain_add_device;
gvir_config_domain_get_type;
+ gvir_config_domain_lifecycle_action_get_type;
+ gvir_config_domain_lifecycle_event_get_type;
gvir_config_domain_new;
gvir_config_domain_new_from_xml;
gvir_config_domain_set_clock;
gvir_config_domain_set_devices;
gvir_config_domain_get_features;
gvir_config_domain_set_features;
+ gvir_config_domain_set_lifecycle;
gvir_config_domain_get_memory;
gvir_config_domain_set_memory;
gvir_config_domain_get_name;
diff --git a/libvirt-gconfig/tests/test-domain-create.c
b/libvirt-gconfig/tests/test-domain-create.c
index 0e52e9e..59aa5b0 100644
--- a/libvirt-gconfig/tests/test-domain-create.c
+++ b/libvirt-gconfig/tests/test-domain-create.c
@@ -60,6 +60,10 @@ int main(void)
}
g_strfreev(feat);
+ gvir_config_domain_set_lifecycle(domain,
+ GVIR_CONFIG_DOMAIN_LIFECYCLE_ON_POWEROFF,
+ GVIR_CONFIG_DOMAIN_LIFECYCLE_RESTART);
+
/* clock node */
GVirConfigDomainClock *klock;
--
1.7.7.3
Show replies by date