ia64/xen-unstable

changeset 18895:c0c113ab0be5

xend: Remember bootable flag for vbds in xenstore

When xend is restarted, bootable flags of all disk devices are lost
and then the first disk is marked as bootable by a "compatibility
hack". When a guest domain is created with a mixture of several vbd
and tap devices, the compatibility hack may fail to choose the right
bootable device. Thus preventing the guest to be restarted. This patch
fixes this behavior by remembering bootable flag for each disk device
in xenstore database.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Dec 09 12:45:45 2008 +0000 (2008-12-09)
parents b1b9cf7a2d36
children f7f8f44b9292
files tools/python/xen/xend/XendConfig.py tools/python/xen/xend/server/blkif.py
line diff
     1.1 --- a/tools/python/xen/xend/XendConfig.py	Tue Dec 09 12:44:32 2008 +0000
     1.2 +++ b/tools/python/xen/xend/XendConfig.py	Tue Dec 09 12:45:45 2008 +0000
     1.3 @@ -1289,7 +1289,6 @@ class XendConfig(dict):
     1.4                      pass
     1.5  
     1.6              if dev_type == 'vbd':
     1.7 -                dev_info['bootable'] = 0
     1.8                  if dev_info.get('dev', '').startswith('ioemu:'):
     1.9                      dev_info['driver'] = 'ioemu'
    1.10                  else:
    1.11 @@ -1325,7 +1324,7 @@ class XendConfig(dict):
    1.12                  if param not in target:
    1.13                      target[param] = []
    1.14                  if dev_uuid not in target[param]:
    1.15 -                    if dev_type == 'vbd':
    1.16 +                    if dev_type == 'vbd' and 'bootable' not in dev_info:
    1.17                          # Compat hack -- mark first disk bootable
    1.18                          dev_info['bootable'] = int(not target[param])
    1.19                      target[param].append(dev_uuid)
    1.20 @@ -1333,8 +1332,9 @@ class XendConfig(dict):
    1.21                  if 'vbd_refs' not in target:
    1.22                      target['vbd_refs'] = []
    1.23                  if dev_uuid not in target['vbd_refs']:
    1.24 -                    # Compat hack -- mark first disk bootable
    1.25 -                    dev_info['bootable'] = int(not target['vbd_refs'])
    1.26 +                    if 'bootable' not in dev_info:
    1.27 +                        # Compat hack -- mark first disk bootable
    1.28 +                        dev_info['bootable'] = int(not target['vbd_refs'])
    1.29                      target['vbd_refs'].append(dev_uuid)
    1.30                      
    1.31              elif dev_type == 'vfb':
     2.1 --- a/tools/python/xen/xend/server/blkif.py	Tue Dec 09 12:44:32 2008 +0000
     2.2 +++ b/tools/python/xen/xend/server/blkif.py	Tue Dec 09 12:45:45 2008 +0000
     2.3 @@ -78,6 +78,10 @@ class BlkifController(DevController):
     2.4          if uuid:
     2.5              back['uuid'] = uuid
     2.6  
     2.7 +        bootable = config.get('bootable', None)
     2.8 +        if bootable != None:
     2.9 +            back['bootable'] = str(bootable)
    2.10 +
    2.11          if security.on() == xsconstants.XS_POLICY_USE:
    2.12              self.do_access_control(config, uname)
    2.13  
    2.14 @@ -143,11 +147,12 @@ class BlkifController(DevController):
    2.15          config = DevController.getDeviceConfiguration(self, devid, transaction)
    2.16          if transaction is None:
    2.17              devinfo = self.readBackend(devid, 'dev', 'type', 'params', 'mode',
    2.18 -                                       'uuid')
    2.19 +                                       'uuid', 'bootable')
    2.20          else:
    2.21              devinfo = self.readBackendTxn(transaction, devid,
    2.22 -                                          'dev', 'type', 'params', 'mode', 'uuid')
    2.23 -        dev, typ, params, mode, uuid = devinfo
    2.24 +                                          'dev', 'type', 'params', 'mode', 'uuid',
    2.25 +                                          'bootable')
    2.26 +        dev, typ, params, mode, uuid, bootable = devinfo
    2.27          
    2.28          if dev:
    2.29              if transaction is None:
    2.30 @@ -165,6 +170,8 @@ class BlkifController(DevController):
    2.31              config['mode'] = mode
    2.32          if uuid:
    2.33              config['uuid'] = uuid
    2.34 +        if bootable != None:
    2.35 +            config['bootable'] = int(bootable)
    2.36  
    2.37          proto = self.readFrontend(devid, 'protocol')
    2.38          if proto: