WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] fix domain exit actions that contain hyphen

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] fix domain exit actions that contain hyphen
From: Jim Fehlig <jfehlig@xxxxxxxxxx>
Date: Tue, 02 Mar 2010 15:55:47 -0700
Delivery-date: Tue, 02 Mar 2010 14:56:34 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.18 (X11/20081112)
Domain exit actions that contain a hyphen (e.g. rename-restart) were not
being detected properly when xm is configured to use xenapi.  Domain
config containing on_crash="rename-restart" results in

xen53:~ # xm new /tmp/domU.config
Using config file "/tmp/domU.config".
Unexpected error: <type 'exceptions.TypeError'>

Please report to xen-devel@xxxxxxxxxxxxxxxxxxx
Traceback (most recent call last):
  File "/usr/sbin/xm", line 7, in <module>
    main.main(sys.argv)
  File "/usr/lib64/python2.6/site-packages/xen/xm/main.py", line 3937,
in main
    _, rc = _run_cmd(cmd, cmd_name, args)
  File "/usr/lib64/python2.6/site-packages/xen/xm/main.py", line 3961,
in _run_cmd
    return True, cmd(args)
  File "<string>", line 1, in <lambda>
  File "/usr/lib64/python2.6/site-packages/xen/xm/main.py", line 1582,
in xm_importcommand
    cmd.main([command] + args)
  File "/usr/lib64/python2.6/site-packages/xen/xm/new.py", line 69, in main
    doc = sxp2xml_inst.convert_sxp_to_xml(config)
  File "/usr/lib64/python2.6/site-packages/xen/xm/xenapi_create.py",
line 680, in convert_sxp_to_xml
    XEN_API_ON_CRASH_BEHAVIOUR)
  File "/usr/lib64/python2.6/site-packages/xen/xm/xenapi_create.py",
line 671, in conv_chk
    raise "Invalid value: " + val
TypeError: exceptions must be classes or instances, not str

The attached patch fixes the raised exception and at the same time
handles the replacement of hyphen with underscore properly.

Regards,
Jim

     Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxxxx>


Index: xen-4.0.0-testing/tools/python/xen/xm/xenapi_create.py
===================================================================
--- xen-4.0.0-testing.orig/tools/python/xen/xm/xenapi_create.py
+++ xen-4.0.0-testing/tools/python/xen/xm/xenapi_create.py
@@ -666,11 +666,11 @@ class sxp2xml:
             = get_child_by_name(config, "on_crash", "restart")
 
         def conv_chk(val, vals):
-            val.replace("-", "_")
-            if val not in vals:
-                raise "Invalid value: " + val
+            lval = val.replace("-", "_")
+            if lval not in vals:
+                raise ValueError("Invalid value: %s" % val)
             else:
-                return val
+                return lval
 
         actions_after_shutdown = conv_chk(actions_after_shutdown,\
                                           XEN_API_ON_NORMAL_EXIT)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] fix domain exit actions that contain hyphen, Jim Fehlig <=