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

[Xen-devel] [PATCH] [xend and libxenapi] Fix VM.get_power_state API


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
  • From: Jim Fehlig <jfehlig@xxxxxxxxxx>
  • Date: Wed, 13 Dec 2006 18:11:43 -0700
  • Delivery-date: Wed, 13 Dec 2006 17:15:41 -0800
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

Xend was returning an integer representation of the power state instead of a string representation as specified by the XenAPI spec.

On the c-bindings side, the marshaling code converts the string representation to an enum value. A subsequent attempt to convert the enum from a string to an enum in xen_vm_get_power_state() was causing a seg fault in client application.

This patch fixes the code paths in both xend and c-bindings.

Regards,
Jim
# HG changeset patch
# User jfehlig@xxxxxxxxxxxxxxxxxxxxxxxxx
# Date 1166058408 25200
# Node ID 42b515caeb78bc9921b1526a9a781724f232aff0
# Parent  360eb996fa38319867a74bf581c734a80bf6839d
Fix VM.get_power_state API.  On the xend side an integer representation of the 
power state was being returned instead of a string representation as specified 
by the XenAPI spec.

On the c-bindings side the marshalling code converts the string representation 
to an enum value.  A subsequent attempt to convert the enum from a string to an 
enum was causing a seg fault.

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

diff -r 360eb996fa38 -r 42b515caeb78 tools/libxen/include/xen_internal.h
--- a/tools/libxen/include/xen_internal.h       Wed Dec 13 16:13:26 2006 +0000
+++ b/tools/libxen/include/xen_internal.h       Wed Dec 13 18:06:48 2006 -0700
@@ -128,7 +128,6 @@ xen_enum_lookup_(xen_session *session, c
     xen_enum_lookup_(session__, str__, lookup_table__,  \
                      sizeof(lookup_table__) /           \
                      sizeof(lookup_table__[0]))         \
-                                                        \
 
 #define XEN_ALLOC(type__)                       \
 type__ *                                        \
diff -r 360eb996fa38 -r 42b515caeb78 tools/libxen/src/xen_vm.c
--- a/tools/libxen/src/xen_vm.c Wed Dec 13 16:13:26 2006 +0000
+++ b/tools/libxen/src/xen_vm.c Wed Dec 13 18:06:48 2006 -0700
@@ -328,9 +328,7 @@ xen_vm_get_power_state(xen_session *sess
         };
 
     abstract_type result_type = xen_vm_power_state_abstract_type_;
-    char *result_str = NULL;
     XEN_CALL_("VM.get_power_state");
-    *result = xen_vm_power_state_from_string(session, result_str);
     return session->ok;
 }
 
diff -r 360eb996fa38 -r 42b515caeb78 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Wed Dec 13 16:13:26 2006 +0000
+++ b/tools/python/xen/xend/XendAPI.py  Wed Dec 13 18:06:48 2006 -0700
@@ -655,7 +655,7 @@ class XendAPI:
     # attributes (ro)
     def VM_get_power_state(self, session, vm_ref):
         dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
-        return xen_api_success(dom.state)
+        return xen_api_success(dom.get_power_state())
     
     def VM_get_resident_on(self, session, vm_ref):
         return xen_api_success(XendNode.instance().uuid)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.