[virt-tools-list] [virt-manager PATCH] virt-install: add --events support

Chen Hanxiao chenhanxiao at cn.fujitsu.com
Mon May 26 08:20:57 UTC 2014


This patch will enable setting event configuration:
on_poweroff, on_reboot and on_crash.

Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
 man/virt-install.pod                                       |  6 ++++++
 tests/cli-test-xml/compare/virt-xml-edit-simple-events.xml | 11 +++++++++++
 tests/clitest.py                                           |  1 +
 virtinst/cli.py                                            | 13 +++++++++++++
 4 files changed, 31 insertions(+)
 create mode 100644 tests/cli-test-xml/compare/virt-xml-edit-simple-events.xml

diff --git a/man/virt-install.pod b/man/virt-install.pod
index 4dcb5b2..8aa7ead 100644
--- a/man/virt-install.pod
+++ b/man/virt-install.pod
@@ -123,6 +123,12 @@ Specify metadata values for the guest. Possible options include name, uuid, titl
 
 Use --metadata=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsMetadata>
 
+=item --events OPT=VAL,[...]
+
+Specify events values for the guest. Possible options include on_poweroff, on_reboot, and on_crash.
+
+Use --events=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsEvents>
+
 =item --vcpus=VCPUS[,maxvcpus=MAX][,sockets=#][,cores=#][,threads=#][,cpuset=CPUSET]
 
 Number of virtual cpus to configure for the guest. If 'maxvcpus' is specified,
diff --git a/tests/cli-test-xml/compare/virt-xml-edit-simple-events.xml b/tests/cli-test-xml/compare/virt-xml-edit-simple-events.xml
new file mode 100644
index 0000000..8ca96c8
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-xml-edit-simple-events.xml
@@ -0,0 +1,11 @@
+   </clock>
+   <on_poweroff>destroy</on_poweroff>
+   <on_reboot>restart</on_reboot>
+-  <on_crash>restart</on_crash>
++  <on_crash>preserve</on_crash>
+   <pm>
+     <suspend-to-mem enabled="no"/>
+   </pm>
+
+Domain 'test-many-devices' defined successfully.
+Changes will take effect after the next domain shutdown.
\ No newline at end of file
diff --git a/tests/clitest.py b/tests/clitest.py
index 75938b3..95c7667 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -805,6 +805,7 @@ c = vixml.add_category("simple edit diff", "test-many-devices --edit --print-dif
 c.add_compare("""--metadata name=foo-my-new-name,uuid=12345678-12F4-1234-1234-123456789AFA,description="hey this is my
 new
 very,very=new desc\\\'",title="This is my,funky=new title" """, "edit-simple-metadata")
+c.add_compare("--events on_poweroff=destroy,on_reboot=restart,on_crash=preserve", "edit-simple-events")
 c.add_compare("--memory 500,maxmemory=1000,hugepages=off", "edit-simple-memory")
 c.add_compare("--vcpus 10,maxvcpus=20,cores=5,sockets=4,threads=1", "edit-simple-vcpus")
 c.add_compare("--cpu model=pentium2,+x2apic,forbid=pbe", "edit-simple-cpu")
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 79e7e06..a84cee8 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -797,6 +797,7 @@ def add_guest_xml_options(geng):
                     help=_("Set domain <clock> XML. Ex:\n"
                            "--clock offset=localtime,rtc_tickpolicy=catchup"))
     geng.add_argument("--pm", help=_("Config power management features"))
+    geng.add_argument("--events", help=_("Config OS lifecycle operation management features"))
 
 
 def add_boot_options(insg):
@@ -1226,6 +1227,17 @@ class ParserMetadata(VirtCLIParser):
 
 
 ######################
+# --events parsing   #
+######################
+
+class ParserEvents(VirtCLIParser):
+    def _init_params(self):
+        self.set_param("on_poweroff", "on_poweroff")
+        self.set_param("on_reboot", "on_reboot")
+        self.set_param("on_crash", "on_crash")
+
+
+######################
 # --numatune parsing #
 ######################
 
@@ -2212,6 +2224,7 @@ def build_parser_map(options, skip=None, only=None):
         parsermap[parserobj.option_variable_name] = parserobj
 
     register_parser("metadata", ParserMetadata)
+    register_parser("events", ParserEvents)
     register_parser("memory", ParserMemory)
     register_parser("memtune", ParserMemorytune)
     register_parser("vcpus", ParserVCPU)
-- 
1.9.0




More information about the virt-tools-list mailing list