All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [XEN-API] Not raising an API error in VTPM destroy method
@ 2007-02-07 23:37 Stefan Berger
  2007-02-08 15:53 ` Ewan Mellor
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Berger @ 2007-02-07 23:37 UTC (permalink / raw)
  To: xen-devel; +Cc: Ewan Mellor

[-- Attachment #1: Type: text/plain, Size: 212 bytes --]

Don't return an API error if vTPM cannot be destroyed due to a running
VM, but a value indicating failure instead. Adapt python code, libxen
and documentation.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>


[-- Attachment #2: xenapi_vtpm_destroy.diff --]
[-- Type: text/x-patch, Size: 4139 bytes --]

Index: root/xen-unstable.hg/tools/libxen/include/xen_vtpm.h
===================================================================
--- root.orig/xen-unstable.hg/tools/libxen/include/xen_vtpm.h
+++ root/xen-unstable.hg/tools/libxen/include/xen_vtpm.h
@@ -172,7 +172,7 @@ xen_vtpm_create(xen_session *session, xe
  * Destroy the specified VTPM instance.
  */
 extern bool
-xen_vtpm_destroy(xen_session *session, xen_vtpm vtpm);
+xen_vtpm_destroy(xen_session *session, int64_t *result, xen_vtpm vtpm);
 
 
 /**
Index: root/xen-unstable.hg/tools/libxen/src/xen_vtpm.c
===================================================================
--- root.orig/xen-unstable.hg/tools/libxen/src/xen_vtpm.c
+++ root/xen-unstable.hg/tools/libxen/src/xen_vtpm.c
@@ -132,7 +132,7 @@ xen_vtpm_create(xen_session *session, xe
 
 
 bool
-xen_vtpm_destroy(xen_session *session, xen_vtpm vtpm)
+xen_vtpm_destroy(xen_session *session, int64_t *result, xen_vtpm vtpm)
 {
     abstract_value param_values[] =
         {
@@ -140,7 +140,10 @@ xen_vtpm_destroy(xen_session *session, x
               .u.string_val = vtpm }
         };
 
-    xen_call_(session, "VTPM.destroy", param_values, 1, NULL, NULL);
+    abstract_type result_type = abstract_type_int;
+
+    *result = 0;
+    XEN_CALL_("VTPM.destroy");
     return session->ok;
 }
 
Index: root/xen-unstable.hg/tools/python/xen/xend/XendAPI.py
===================================================================
--- root.orig/xen-unstable.hg/tools/python/xen/xend/XendAPI.py
+++ root/xen-unstable.hg/tools/python/xen/xend/XendAPI.py
@@ -1834,9 +1834,7 @@ class XendAPI(object):
         if dom:
             if dom.state != XEN_API_VM_POWER_STATE_HALTED:
                 vm_ref = dom.get_dev_property('vtpm', vtpm_ref, 'VM')
-                return xen_api_error(['VM_BAD_POWER_STATE', vm_ref,
-                 XendDomain.POWER_STATE_NAMES[XEN_API_VM_POWER_STATE_HALTED],
-                 XendDomain.POWER_STATE_NAMES[dom.state]])
+                return xen_api_success(False)
             from xen.xend.server import tpmif
             tpmif.destroy_vtpmstate(dom.getName())
             return xen_api_success(True)
Index: root/xen-unstable.hg/docs/xen-api/xenapi-datamodel.tex
===================================================================
--- root.orig/xen-unstable.hg/docs/xen-api/xenapi-datamodel.tex
+++ root/xen-unstable.hg/docs/xen-api/xenapi-datamodel.tex
@@ -10880,7 +10880,7 @@ reference to the newly created object
 Destroy the specified VTPM instance.
 
  \noindent {\bf Signature:} 
-\begin{verbatim} void destroy (session_id s, VTPM ref self)\end{verbatim}
+\begin{verbatim} int destroy (session_id s, VTPM ref self)\end{verbatim}
 
 
 \noindent{\bf Arguments:}
@@ -10898,11 +10898,11 @@ Destroy the specified VTPM instance.
 
  \noindent {\bf Return Type:} 
 {\tt 
-void
+int
 }
 
 
-
+Success (1) or failure of the operation.
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
Index: root/xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py
===================================================================
--- root.orig/xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py
+++ root/xen-unstable.hg/tools/xm-test/tests/vtpm/09_vtpm-xapi.py
@@ -112,22 +112,19 @@ if not re.search("PCR-00:",run["output"]
     saveLog(console.getHistory())
     FAIL("1. Virtual TPM is not working correctly on /dev/vtpm on backend side: \n%s" % run["output"])
 
-try:
-    rc = session.xenapi.VTPM.destroy(vtpm_uuid)
-    #Should never get here
+rc = session.xenapi.VTPM.destroy(vtpm_uuid)
+if int(rc) != 0:
+    #Should not be able to destroy the VTPM with the VM running
     FAIL("Could destroy vTPM while VM is running")
-except:
-    pass
 
 rc = session.xenapi.VM.suspend(vm_uuid)
 if rc:
     FAIL("Could not suspend VM")
 
-try:
-    rc = session.xenapi.VTPM.destroy(vtpm_uuid)
-    #May not throw an exception in 'suspend' state
-except:
-    pass
+rc = session.xenapi.VTPM.destroy(vtpm_uuid)
+if int(rc) != 0:
+    #Should not be able to destroy the VTPM with the VM running
+    print "Could destroy vTPM while VM is suspended?!"
 
 rc = session.xenapi.VM.resume(vm_uuid, False)
 if rc:

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-02-08 19:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-07 23:37 [PATCH] [XEN-API] Not raising an API error in VTPM destroy method Stefan Berger
2007-02-08 15:53 ` Ewan Mellor
2007-02-08 18:25   ` Stefan Berger
2007-02-08 19:00     ` Ewan Mellor
2007-02-08 19:07       ` Stefan Berger
2007-02-08 19:08       ` Stefan Berger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.