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-changelog

[Xen-changelog] [xen-unstable] The attached patch implements more of the

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] The attached patch implements more of the Xen-API functionality related
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 10 Nov 2006 04:50:15 +0000
Delivery-date: Thu, 09 Nov 2006 20:50:25 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Node ID 913324616183963671b8acaca0c5f233aa5fd70e
# Parent  62376b480034a3a53f7c40053bfe34f1723f7f9a
The attached patch implements more of the Xen-API functionality related
to the vTPM.

Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxx>
---
 tools/python/scripts/xapi.domcfg.py     |    2 -
 tools/python/scripts/xapi.py            |   33 +++++++++++++++-
 tools/python/scripts/xapi.vtpmcfg.py    |    3 +
 tools/python/xen/xend/XendAPI.py        |   64 +++++++++++++++++++++++++++-----
 tools/python/xen/xend/XendDomainInfo.py |   16 +++-----
 5 files changed, 95 insertions(+), 23 deletions(-)

diff -r 62376b480034 -r 913324616183 tools/python/scripts/xapi.domcfg.py
--- a/tools/python/scripts/xapi.domcfg.py       Thu Nov 09 11:40:28 2006 +0000
+++ b/tools/python/scripts/xapi.domcfg.py       Thu Nov 09 15:27:32 2006 +0000
@@ -20,8 +20,6 @@ actions_after_reboot =  'restart'
 actions_after_reboot =  'restart'
 actions_after_suspend =  'destroy'
 actions_after_crash =  'restart'
-TPM_instance =  ''
-TPM_backend =  ''
 bios_boot =  ''
 platform_std_VGA =  False
 platform_serial =  ''
diff -r 62376b480034 -r 913324616183 tools/python/scripts/xapi.py
--- a/tools/python/scripts/xapi.py      Thu Nov 09 11:40:28 2006 +0000
+++ b/tools/python/scripts/xapi.py      Thu Nov 09 15:27:32 2006 +0000
@@ -42,6 +42,7 @@ COMMANDS = {
     'vdi-rename': ('<vdi_uuid> <new_name>', 'Rename VDI'),
     'vdi-delete': ('<vdi_uuid>', 'Delete VDI'),
     'vif-create': ('<domname> <pycfg>', 'Create VIF attached to domname'),
+    'vtpm-create' : ('<domname> <pycfg>', 'Create VTPM attached to domname'),
 
     'vm-create': ('<pycfg>', 'Create VM with python config'),
     'vm-destroy': ('<domname>', 'Delete VM'),
@@ -208,16 +209,22 @@ def xapi_vm_list(*args):
         if is_long:
             vbds = vm_info['vbds']
             vifs = vm_info['vifs']
+            vtpms = vm_info['vtpms']
             vif_infos = []
             vbd_infos = []
+            vtpm_infos = []
             for vbd in vbds:
                 vbd_info = execute(server.VBD.get_record, session, vbd)
                 vbd_infos.append(vbd_info)
             for vif in vifs:
                 vif_info = execute(server.VIF.get_record, session, vif)
                 vif_infos.append(vif_info)
+            for vtpm in vtpms:
+                vtpm_info = execute(server.VTPM.get_record, session, vtpm)
+                vtpm_infos.append(vtpm_info)
             vm_info['vbds'] = vbd_infos
             vm_info['vifs'] = vif_infos
+            vm_info['vtpms'] = vtpm_infos
             pprint(vm_info)
         else:
             print VM_LIST_FORMAT % _stringify(vm_info)
@@ -377,8 +384,30 @@ def xapi_vdi_rename(*args):
     print 'Renaming VDI %s to %s' % (vdi_uuid, vdi_name)
     result = execute(server.VDI.set_name_label, session, vdi_uuid, vdi_name)
     print 'Done.'
-    
-        
+
+
+def xapi_vtpm_create(*args):
+    server, session = _connect()
+    domname = args[0]
+    cfg = _read_python_cfg(args[1])
+
+    vm_uuid = resolve_vm(server, session, domname)
+    cfg['VM'] = vm_uuid
+    print "Creating vTPM with cfg = %s" % cfg
+    vtpm_uuid = execute(server.VTPM.create, session, cfg)
+    print "Done. (%s)" % vtpm_uuid
+    vtpm_id = execute(server.VTPM.get_instance, session, vtpm_uuid)
+    print "Has instance number '%s'" % vtpm_id
+    vtpm_be = execute(server.VTPM.get_backend, session, vtpm_uuid)
+    print "Has backend in '%s'" % vtpm_be
+    driver = execute(server.VTPM.get_driver, session, vtpm_uuid)
+    print "Has driver type '%s'" % driver
+    vtpm_rec = execute(server.VTPM.get_record, session, vtpm_uuid)
+    print "Has vtpm record '%s'" % vtpm_rec
+    vm = execute(server.VTPM.get_VM, session, vtpm_uuid)
+    print "Has VM '%s'" % vm
+
+
 #
 # Command Line Utils
 #
diff -r 62376b480034 -r 913324616183 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Thu Nov 09 11:40:28 2006 +0000
+++ b/tools/python/xen/xend/XendAPI.py  Thu Nov 09 15:27:32 2006 +0000
@@ -1282,11 +1282,11 @@ class XendAPI:
     # Xen API: Class VTPM
     # ----------------------------------------------------------------
 
-    VTPM_attr_ro = [ ]
-    VTPM_attr_rw = ['type',
-                    'VM',
+    VTPM_attr_rw = [ ]
+    VTPM_attr_ro = ['VM',
                     'backend',
-                    'instance']
+                    'instance',
+                    'driver']
 
     VTPM_attr_inst = VTPM_attr_rw
 
@@ -1307,17 +1307,61 @@ class XendAPI:
 
         return xen_api_success(cfg)
 
+    # Class Functions
+    def vtpm_get_instance(self, session, vtpm_ref):
+        xendom = XendDomain.instance()
+        vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref)
+        if not vm:
+            return xen_api_error(XEND_ERROR_VTPM_INVALID)
+        cfg = vm.get_dev_xenapi_config('vtpm', vtpm_ref)
+        if not cfg:
+            return xen_api_error(XEND_ERROR_VTPM_INVALID)
+        if cfg.has_key('instance'):
+            instance = cfg['instance']
+        else:
+            instance = -1
+        return xen_api_success(instance)
+
+    def vtpm_get_driver(self, session, vtpm_ref):
+        xendom = XendDomain.instance()
+        vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref)
+        if not vm:
+            return xen_api_error(XEND_ERROR_VTPM_INVALID)
+        cfg = vm.get_dev_xenapi_config('vtpm', vtpm_ref)
+        if not cfg:
+            return xen_api_error(XEND_ERROR_VTPM_INVALID)
+        if cfg.has_key('type'):
+            driver = cfg['type']
+        else:
+            driver = "Unknown"
+        return xen_api_success(driver)
+
+    def vtpm_get_backend(self, session, vtpm_ref):
+        xendom = XendDomain.instance()
+        vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref)
+        if not vm:
+            return xen_api_error(XEND_ERROR_VTPM_INVALID)
+        cfg = vm.get_dev_xenapi_config('vtpm', vtpm_ref)
+        if not cfg:
+            return xen_api_error(XEND_ERROR_VTPM_INVALID)
+        if cfg.has_key('backend'):
+            backend = cfg['backend']
+        else:
+            backend = "Domain-0"
+        return xen_api_success(backend)
+
+    def vtpm_get_vm(self, session, vtpm_ref):
+        xendom = XendDomain.instance()
+        return xen_api_success(xendom.get_dev_property('vtpm', vtpm_ref, 'VM'))
+
     # class methods
     def vtpm_create(self, session, vtpm_struct):
         xendom = XendDomain.instance()
         if xendom.is_valid_vm(vtpm_struct['VM']):
             dom = xendom.get_vm_by_uuid(vtpm_struct['VM'])
-            try:
-                vtpm_ref = dom.create_vtpm(vtpm_struct)
-                xendom.managed_config_save(dom)
-                return xen_api_success(vtpm_ref)
-            except XendError:
-                return xen_api_error(XEND_ERROR_TODO)
+            vtpm_ref = dom.create_vtpm(vtpm_struct)
+            xendom.managed_config_save(dom)
+            return xen_api_success(vtpm_ref)
         else:
             return xen_api_error(XEND_ERROR_DOMAIN_INVALID)
 
diff -r 62376b480034 -r 913324616183 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Thu Nov 09 11:40:28 2006 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py   Thu Nov 09 15:27:32 2006 +0000
@@ -1689,10 +1689,6 @@ class XendDomainInfo:
         return '' # TODO
     def get_power_state(self):
         return XEN_API_VM_POWER_STATE[self.state]
-    def get_tpm_instance(self):
-        return '' # TODO
-    def get_tpm_backend(self):
-        return '' # TODO
     def get_bios_boot(self):
         return '' # TODO
     def get_platform_std_vga(self):
@@ -1833,6 +1829,9 @@ class XendDomainInfo:
             else:
                 config['mode'] = 'RW'
 
+        if dev_class == 'vtpm':
+            config['driver'] = 'paravirtualised' # TODO
+
         return config
 
     def get_dev_property(self, dev_class, dev_uuid, field):
@@ -1927,14 +1926,13 @@ class XendDomainInfo:
         @rtype: string
         """
 
+        if self.state not in (DOM_STATE_HALTED,):
+            raise VmError("Can only add vTPM to a halted domain.")
+        if self.get_vtpms() != []:
+            raise VmError('Domain already has a vTPM.')
         dev_uuid = self.info.device_add('vtpm', cfg_xenapi = xenapi_vtpm)
         if not dev_uuid:
             raise XendError('Failed to create device')
-
-        if self.state in (DOM_STATE_HALTED,):
-            sxpr = self.info.device_sxpr(dev_uuid)
-            devid = self.getDeviceController('vtpm').createDevice(sxpr)
-            raise XendError("Device creation failed")
 
         return dev_uuid
 
diff -r 62376b480034 -r 913324616183 tools/python/scripts/xapi.vtpmcfg.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/python/scripts/xapi.vtpmcfg.py      Thu Nov 09 15:27:32 2006 +0000
@@ -0,0 +1,3 @@
+type = 'paravirtualised'
+backend = 'Domain-0'
+instance = 1

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] The attached patch implements more of the Xen-API functionality related, Xen patchbot-unstable <=