[go PATCH 2/2] Add virDomainSetLifecycleAction API support

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

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 domain.go        | 33 +++++++++++++++++++++++++++++++++
 domain_compat.go | 12 ++++++++++++
 domain_compat.h  | 41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+)

diff --git a/domain.go b/domain.go
index 5183726..36d77ba 100644
--- a/domain.go
+++ b/domain.go
@@ -4504,3 +4504,36 @@ func (d *Domain) ManagedSaveGetXMLDesc(flags uint32) (string, error) {
 	C.free(unsafe.Pointer(ret))
 	return xml, nil
 }
+
+type DomainLifecycle int
+
+const (
+	DOMAIN_LIFECYCLE_POWEROFF = DomainLifecycle(C.VIR_DOMAIN_LIFECYCLE_POWEROFF)
+	DOMAIN_LIFECYCLE_REBOOT   = DomainLifecycle(C.VIR_DOMAIN_LIFECYCLE_REBOOT)
+	DOMAIN_LIFECYCLE_CRASH    = DomainLifecycle(C.VIR_DOMAIN_LIFECYCLE_CRASH)
+)
+
+type DomainLifecycleAction int
+
+const (
+	DOMAIN_LIFECYCLE_ACTION_DESTROY          = DomainLifecycleAction(C.VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY)
+	DOMAIN_LIFECYCLE_ACTION_RESTART          = DomainLifecycleAction(C.VIR_DOMAIN_LIFECYCLE_ACTION_RESTART)
+	DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME   = DomainLifecycleAction(C.VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME)
+	DOMAIN_LIFECYCLE_ACTION_PRESERVE         = DomainLifecycleAction(C.VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE)
+	DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY = DomainLifecycleAction(C.VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY)
+	DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART = DomainLifecycleAction(C.VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART)
+)
+
+// See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSetLifecycleAction
+func (d *Domain) SetLifecycleAction(lifecycleType uint32, action uint32, flags uint32) error {
+	if C.LIBVIR_VERSION_NUMBER < 3009000 {
+		return GetNotImplementedError("virDomainSetLifecycleAction")
+	}
+
+	ret := C.virDomainSetLifecycleActionCompat(d.ptr, C.uint(lifecycleType), C.uint(action), C.uint(flags))
+	if ret == -1 {
+		return GetLastError()
+	}
+
+	return nil
+}
diff --git a/domain_compat.go b/domain_compat.go
index c59b00e..eada95c 100644
--- a/domain_compat.go
+++ b/domain_compat.go
@@ -345,5 +345,17 @@ int virDomainManagedSaveDefineXMLCompat(virDomainPtr domain,
 #endif
 }
 
+int virDomainSetLifecycleActionCompat(virDomainPtr domain,
+                                      unsigned int type,
+                                      unsigned int action,
+                                      unsigned int flags)
+{
+#if LIBVIR_VERSION_NUMBER < 3009000
+    assert(0); // Caller should have checked version
+#else
+    return virDomainSetLifecycleAction(domain, type, action, flags);
+#endif
+}
+
 */
 import "C"
diff --git a/domain_compat.h b/domain_compat.h
index afef84d..2793b1b 100644
--- a/domain_compat.h
+++ b/domain_compat.h
@@ -977,4 +977,45 @@ int virDomainManagedSaveDefineXMLCompat(virDomainPtr domain,
 #define VIR_DOMAIN_JOB_MEMORY_PAGE_SIZE "memory_page_size"
 #endif
 
+#ifndef VIR_DOMAIN_LIFECYCLE_POWEROFF
+#define VIR_DOMAIN_LIFECYCLE_POWEROFF 0
+#endif
+
+#ifndef VIR_DOMAIN_LIFECYCLE_REBOOT
+#define VIR_DOMAIN_LIFECYCLE_REBOOT 1
+#endif
+
+#ifndef VIR_DOMAIN_LIFECYCLE_CRASH
+#define VIR_DOMAIN_LIFECYCLE_CRASH 2
+#endif
+
+#ifndef VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY
+#define VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY 0
+#endif
+
+#ifndef VIR_DOMAIN_LIFECYCLE_ACTION_RESTART
+#define VIR_DOMAIN_LIFECYCLE_ACTION_RESTART 1
+#endif
+
+#ifndef VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME
+#define VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME 2
+#endif
+
+#ifndef VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE
+#define VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE 3
+#endif
+
+#ifndef VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY
+#define VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY 4
+#endif
+
+#ifndef VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART
+#define VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART 5
+#endif
+
+int virDomainSetLifecycleActionCompat(virDomainPtr domain,
+                                      unsigned int type,
+                                      unsigned int action,
+                                      unsigned int flags);
+
 #endif /* LIBVIRT_GO_DOMAIN_COMPAT_H__ */
-- 
2.13.6

--
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]
  Powered by Linux