debuggers.hg

view tools/python/xen/xend/XendDevices.py @ 13654:b111908dd70b

[XEND] Preliminary console support in Xen API

Made serial/vnc consoles a 'fake' device so that we can take advantage
of storing state information in xenstore.

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Thu Jan 25 18:54:25 2007 +0000 (2007-01-25)
parents 260426e3924f
children c1deef05c354
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, usbif, 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 'usb': usbif.UsbifController,
45 'tap': BlktapController,
46 'vfb': vfbif.VfbifController,
47 'vkbd': vfbif.VkbdifController,
48 'console': ConsoleController,
49 }
51 #@classmethod
52 def valid_devices(cls):
53 return cls.controllers.keys()
54 valid_devices = classmethod(valid_devices)
56 #@classmethod
57 def make_controller(cls, name, domain):
58 """Factory function to make device controllers per domain.
60 @param name: device class name in L{VALID_DEVICES}
61 @type name: String
62 @param domain: domain this controller is handling devices for.
63 @type domain: XendDomainInfo
64 @return: DevController of class 'name' or None
65 @rtype: subclass of DevController
66 """
67 if name in cls.controllers.keys():
68 cls.controllers[name].deviceClass = name
69 return cls.controllers[name](domain)
70 return None
72 make_controller = classmethod(make_controller)
74 def destroy_device_state(cls, domain):
75 """Destroy the state of (external) devices. This is necessary
76 to do when a VM's configuration is destroyed.
78 @param domain: domain this controller is handling devices for.
79 @type domain: XendDomainInfo
80 """
81 tpmif.destroy_vtpmstate(domain.getName())
83 destroy_device_state = classmethod(destroy_device_state)