debuggers.hg

view tools/python/xen/xend/XendDevices.py @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children 5c0bf00e371d
line source
1 #===========================================================================
2 # This library is free software; you can redistribute it and/or
3 # modify it under the terms of version 2.1 of the GNU Lesser General Public
4 # License as published by the Free Software Foundation.
5 #
6 # This library is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 # Lesser General Public License for more details.
10 #
11 # You should have received a copy of the GNU Lesser General Public
12 # License along with this library; if not, write to the Free Software
13 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 #============================================================================
15 # Copyright (C) 2006 XenSource Ltd
16 #============================================================================
18 #
19 # A collection of DevControllers
20 #
22 from xen.xend.server import blkif, netif, tpmif, pciif, iopif, irqif, vfbif
23 from xen.xend.server.BlktapController import BlktapController
24 from xen.xend.server.ConsoleController import ConsoleController
27 class XendDevices:
28 """ An ugly halfway point between the module local device name
29 to class map we used to have in XendDomainInfo and something
30 slightly more managable.
32 This class should contain all the functions that have to do
33 with managing devices in Xend. Right now it is only a factory
34 function.
35 """
37 controllers = {
38 'vbd': blkif.BlkifController,
39 'vif': netif.NetifController,
40 'vtpm': tpmif.TPMifController,
41 'pci': pciif.PciController,
42 'ioports': iopif.IOPortsController,
43 'irq': irqif.IRQController,
44 'tap': BlktapController,
45 'vfb': vfbif.VfbifController,
46 'vkbd': vfbif.VkbdifController,
47 'console': ConsoleController,
48 }
50 #@classmethod
51 def valid_devices(cls):
52 return cls.controllers.keys()
53 valid_devices = classmethod(valid_devices)
55 #@classmethod
56 def make_controller(cls, name, domain):
57 """Factory function to make device controllers per domain.
59 @param name: device class name in L{VALID_DEVICES}
60 @type name: String
61 @param domain: domain this controller is handling devices for.
62 @type domain: XendDomainInfo
63 @return: DevController of class 'name' or None
64 @rtype: subclass of DevController
65 """
66 if name in cls.controllers.keys():
67 cls.controllers[name].deviceClass = name
68 return cls.controllers[name](domain)
69 return None
71 make_controller = classmethod(make_controller)
73 def destroy_device_state(cls, domain):
74 """Destroy the state of (external) devices. This is necessary
75 to do when a VM's configuration is destroyed.
77 @param domain: domain this controller is handling devices for.
78 @type domain: XendDomainInfo
79 """
80 from xen.xend.XendLogging import log
81 tpmif.destroy_vtpmstate(domain.info.get('vtpm_refs'))
83 destroy_device_state = classmethod(destroy_device_state)