~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to tools/python/xen/xend/server/vfbif.py

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from xen.xend.server.DevController import DevController
 
2
from xen.xend.XendLogging import log
 
3
 
 
4
from xen.xend.XendError import VmError
 
5
import xen.xend
 
6
import os
 
7
 
 
8
CONFIG_ENTRIES = ['type', 'vncdisplay', 'vnclisten', 'vncpasswd', 'vncunused',
 
9
                  'display', 'xauthority', 'keymap', 'vnc', 'sdl', 'uuid',
 
10
                  'location', 'protocol', 'opengl']
 
11
 
 
12
class VfbifController(DevController):
 
13
    """Virtual frame buffer controller. Handles all vfb devices for a domain.
 
14
    Note that we only support a single vfb per domain at the moment.
 
15
    """
 
16
 
 
17
    def __init__(self, vm):
 
18
        DevController.__init__(self, vm)
 
19
        
 
20
    def getDeviceDetails(self, config):
 
21
        """@see DevController.getDeviceDetails"""
 
22
 
 
23
        back = dict([(k, str(config[k])) for k in CONFIG_ENTRIES
 
24
                     if config.has_key(k)])
 
25
 
 
26
        devid = 0
 
27
        return (devid, back, {})
 
28
 
 
29
 
 
30
    def getDeviceConfiguration(self, devid, transaction = None):
 
31
        result = DevController.getDeviceConfiguration(self, devid, transaction)
 
32
 
 
33
        if transaction is None:
 
34
            devinfo = self.readBackend(devid, *CONFIG_ENTRIES)
 
35
        else:
 
36
            devinfo = self.readBackendTxn(transaction, devid, *CONFIG_ENTRIES)
 
37
        return dict([(CONFIG_ENTRIES[i], devinfo[i])
 
38
                     for i in range(len(CONFIG_ENTRIES))
 
39
                     if devinfo[i] is not None])
 
40
 
 
41
    def waitForDevice(self, devid):
 
42
        # is a qemu-dm managed device, don't wait for hotplug for these.
 
43
        return
 
44
 
 
45
    def reconfigureDevice(self, _, config):
 
46
        """ Only allow appending location information of vnc port into
 
47
        xenstore."""
 
48
 
 
49
        if 'location' in config:
 
50
            (devid, back, front) = self.getDeviceDetails(config)
 
51
            self.writeBackend(devid, 'location', config['location'])
 
52
            return back.get('uuid')
 
53
 
 
54
        raise VmError('Refusing to reconfigure device vfb:%d' % devid)
 
55
 
 
56
    def destroyDevice(self, devid, force):
 
57
        # remove the backend xenstore entries no matter what
 
58
        # because we kill qemu-dm with extreme prejudice
 
59
        # not giving it a chance to remove them itself
 
60
        DevController.destroyDevice(self, devid, True)
 
61
 
 
62
 
 
63
    def migrate(self, deviceConfig, network, dst, step, domName):
 
64
        # Handled by qemu-dm so no action needed
 
65
        return 0
 
66
 
 
67
    
 
68
class VkbdifController(DevController):
 
69
    """Virtual keyboard controller. Handles all vkbd devices for a domain.
 
70
    """
 
71
 
 
72
    def getDeviceDetails(self, config):
 
73
        """@see DevController.getDeviceDetails"""
 
74
        devid = 0
 
75
        back = {}
 
76
        front = {}
 
77
        return (devid, back, front)
 
78
 
 
79
    def waitForDevice(self, config):
 
80
        # is a qemu-dm managed device, don't wait for hotplug for these.
 
81
        return
 
82
 
 
83
    def destroyDevice(self, devid, force):
 
84
        # remove the backend xenstore entries no matter what
 
85
        # because we kill qemu-dm with extreme prejudice
 
86
        # not giving it a chance to remove them itself
 
87
        DevController.destroyDevice(self, devid, True)
 
88
 
 
89
    def migrate(self, deviceConfig, network, dst, step, domName):
 
90
        # Handled by qemu-dm so no action needed
 
91
        return 0