[perl PATCH 2/2] Add set_lifecycle_action

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

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 Changes                |  1 +
 Virt.xs                | 23 +++++++++++++++++++++
 lib/Sys/Virt/Domain.pm | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 80 insertions(+)

diff --git a/Changes b/Changes
index 06f66c8..ebc6548 100644
--- a/Changes
+++ b/Changes
@@ -3,6 +3,7 @@ Revision history for perl module Sys::Virt
 3.9.0 2017-11-00
 
  - Add VIR_DOMAIN_JOB_MEMORY_PAGE_SIZE constant
+ - Add set_lifecycle_action
 
 3.8.0 2017-10-04
 
diff --git a/Virt.xs b/Virt.xs
index eb8465f..c123769 100644
--- a/Virt.xs
+++ b/Virt.xs
@@ -6310,6 +6310,16 @@ set_block_threshold(dom, dev, thresholdsv, flags=0)
         _croak_error();
 
 void
+set_lifecycle_action(dom, type, action, flags=0)
+      virDomainPtr dom;
+      unsigned int type;
+      unsigned int action;
+      unsigned int flags;
+PPCODE:
+      if (virDomainSetLifecycleAction(dom, type, action, flags) < 0)
+          _croak_error();
+
+void
 destroy(dom_rv, flags=0)
       SV *dom_rv;
       unsigned int flags;
@@ -9091,6 +9101,19 @@ BOOT:
       REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED, REVERT_PAUSED);
       REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_REVERT_FORCE, REVERT_FORCE);
 
+      stash = gv_stashpv( "Sys::Virt::Lifecycle", TRUE );
+      REGISTER_CONSTANT(VIR_DOMAIN_LIFECYCLE_POWEROFF, LIFECYCLE_POWEROFF);
+      REGISTER_CONSTANT(VIR_DOMAIN_LIFECYCLE_REBOOT, LIFECYCLE_REBOOT);
+      REGISTER_CONSTANT(VIR_DOMAIN_LIFECYCLE_CRASH, LIFECYCLE_CRASH);
+
+      stash = gv_stashpv( "Sys::Virt::LifecycleAction", TRUE );
+      REGISTER_CONSTANT(VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY, LIFECYCLE_ACTION_DESTROY);
+      REGISTER_CONSTANT(VIR_DOMAIN_LIFECYCLE_ACTION_RESTART, LIFECYCLE_ACTION_RESTART);
+      REGISTER_CONSTANT(VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME, LIFECYCLE_ACTION_RESTART_RENAME);
+      REGISTER_CONSTANT(VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE, LIFECYCLE_ACTION_PRESERVE);
+      REGISTER_CONSTANT(VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY, LIFECYCLE_ACTION_COREDUMP_DESTROY);
+      REGISTER_CONSTANT(VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART, LIFECYCLE_ACTION_COREDUMP_RESTART);
+
       stash = gv_stashpv( "Sys::Virt::StoragePool", TRUE );
       REGISTER_CONSTANT(VIR_STORAGE_POOL_INACTIVE, STATE_INACTIVE);
       REGISTER_CONSTANT(VIR_STORAGE_POOL_BUILDING, STATE_BUILDING);
diff --git a/lib/Sys/Virt/Domain.pm b/lib/Sys/Virt/Domain.pm
index 273e6e6..38b9c9b 100644
--- a/lib/Sys/Virt/Domain.pm
+++ b/lib/Sys/Virt/Domain.pm
@@ -1999,6 +1999,11 @@ level. The threshold level is unset once the event fires. The
 event might not be delivered at all if libvirtd was not running
 at the moment when the threshold was reached.
 
+=item $dom->set_lifecycle_action($type, $action, $flags=0)
+
+Changes the actions of lifecycle events for domain represented as
+<on_$type>$action</on_$type> in the domain XML.
+
 =back
 
 =head1 CONSTANTS
@@ -4544,6 +4549,57 @@ The I/O threads pinning
 
 =back
 
+=head2 DOMAIN LIFECYCLE CONSTANTS
+
+The following constants are useful when setting action for
+lifecycle events.
+
+=over 4
+
+=item Sys::Virt::Domain::LIFECYCLE_POWEROFF
+
+The poweroff lifecycle event type
+
+=item Sys::Virt::Domain::LIFECYCLE_REBOOT
+
+The reboot lifecycle event type
+
+=item Sys::Virt::Domain::LIFECYCLE_CRASH
+
+The crash lifecycle event type
+
+=back
+
+=head2 DOMAIN LIFECYCLE ACTION CONSTANTS
+
+=over 4
+
+=item Sys::Virt::Domain::LIFECYCLE_ACTION_DESTROY
+
+The destroy lifecycle action
+
+=item Sys::Virt::Domain::LIFECYCLE_ACTION_RESTART
+
+The restart lifecycle action
+
+=item Sys::Virt::Domain::LIFECYCLE_ACTION_RESTART_RENAME
+
+The restart-rename lifecycle action
+
+=item Sys::Virt::Domain::LIFECYCLE_ACTION_PRESERVE
+
+The preserve lifecycle action
+
+=item Sys::Virt::Domain::LIFECYCLE_ACTION_COREDUMP_DESTROY
+
+The coredump-destroy lifecycle action
+
+=item Sys::Virt::Domain::LIFECYCLE_ACTION_COREDUMP_RESTART
+
+The coredump-restart lifecycle action
+
+=back
+
 =head1 AUTHORS
 
 Daniel P. Berrange <berrange@xxxxxxxxxx>
-- 
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