ia64/xen-unstable

changeset 14803:5f6bca864d9c

xend: Store canonical vnif config info in /vm/<uuid>/device
rather than in frontend store directory. Two advantages are that the
frontend cannot mess with the config information; also an
ioemu-specific vif does nto need a frontend directory at all. This
avoids confusing netfront pv-on-hvm driver.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Apr 11 14:30:56 2007 +0100 (2007-04-11)
parents 6e7ef794cdbc
children bfe2136c163a
files tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/server/DevController.py tools/python/xen/xend/server/netif.py
line diff
     1.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Wed Apr 11 09:29:00 2007 +0100
     1.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Wed Apr 11 14:30:56 2007 +0100
     1.3 @@ -75,13 +75,6 @@ def save(fd, dominfo, network, live, dst
     1.4  
     1.5          image_cfg = dominfo.info.get('image', {})
     1.6          hvm = dominfo.info.is_hvm()
     1.7 -        stdvga = 0
     1.8 -
     1.9 -        if hvm:
    1.10 -            log.info("save hvm domain")
    1.11 -            if dominfo.info['platform'].has_key('stdvga'):
    1.12 -                if dominfo.info['platform']['stdvga'] == 1:
    1.13 -                    stdvga = 1
    1.14  
    1.15          # xc_save takes three customization parameters: maxit, max_f, and
    1.16          # flags the last controls whether or not save is 'live', while the
     2.1 --- a/tools/python/xen/xend/server/DevController.py	Wed Apr 11 09:29:00 2007 +0100
     2.2 +++ b/tools/python/xen/xend/server/DevController.py	Wed Apr 11 14:30:56 2007 +0100
     2.3 @@ -223,6 +223,7 @@ class DevController:
     2.4                  xstransact.Remove(backpath)
     2.5              xstransact.Remove(frontpath)
     2.6  
     2.7 +        self.vm._removeVm("device/%s/%d" % (self.deviceClass, devid))
     2.8  
     2.9      def configurations(self):
    2.10          return map(self.configuration, self.deviceIDs())
     3.1 --- a/tools/python/xen/xend/server/netif.py	Wed Apr 11 09:29:00 2007 +0100
     3.2 +++ b/tools/python/xen/xend/server/netif.py	Wed Apr 11 14:30:56 2007 +0100
     3.3 @@ -88,46 +88,6 @@ def parseRate(ratestr):
     3.4      return "%lu,%lu" % (bytes_per_interval, interval_usecs)
     3.5  
     3.6  
     3.7 -write_rate_G_re = re.compile('^([0-9]+)000000000(B/s@[0-9]+us)$')
     3.8 -write_rate_M_re = re.compile('^([0-9]+)000000(B/s@[0-9]+us)$')
     3.9 -write_rate_K_re = re.compile('^([0-9]+)000(B/s@[0-9]+us)$')
    3.10 -write_rate_s_re = re.compile('^([0-9]+[GMK]?B/s@[0-9]+)000000us$')
    3.11 -write_rate_m_re = re.compile('^([0-9]+[GMK]?B/s@[0-9]+)000us$')
    3.12 -
    3.13 -def formatRate(rate):
    3.14 -    (bytes_per_interval, interval_usecs) = map(long, rate.split(','))
    3.15 -
    3.16 -    if interval_usecs != 0:
    3.17 -        bytes_per_second = (bytes_per_interval * 1000 * 1000) / interval_usecs
    3.18 -    else:
    3.19 -        bytes_per_second = 0xffffffffL
    3.20 -
    3.21 -    ratestr = "%uB/s@%uus" % (bytes_per_second, interval_usecs)
    3.22 -
    3.23 -    # look for '000's
    3.24 -    m = write_rate_G_re.match(ratestr)
    3.25 -    if m:
    3.26 -        ratestr = m.group(1) + "G" + m.group(2)
    3.27 -    else:
    3.28 -        m = write_rate_M_re.match(ratestr)
    3.29 -        if m:
    3.30 -            ratestr = m.group(1) + "M" + m.group(2)
    3.31 -        else:
    3.32 -            m = write_rate_K_re.match(ratestr)
    3.33 -            if m:
    3.34 -                ratestr = m.group(1) + "K" + m.group(2)
    3.35 -
    3.36 -    m = write_rate_s_re.match(ratestr)
    3.37 -    if m:
    3.38 -        ratestr = m.group(1) + "s"
    3.39 -    else:
    3.40 -        m = write_rate_m_re.match(ratestr)
    3.41 -        if m:
    3.42 -            ratestr = m.group(1) + "ms"
    3.43 -
    3.44 -    return ratestr
    3.45 -
    3.46 -
    3.47  class NetifController(DevController):
    3.48      """Network interface controller. Handles all network devices for a domain.
    3.49      """
    3.50 @@ -138,8 +98,7 @@ class NetifController(DevController):
    3.51      def getDeviceDetails(self, config):
    3.52          """@see DevController.getDeviceDetails"""
    3.53  
    3.54 -        script = os.path.join(xoptions.network_script_dir,
    3.55 -                              config.get('script', xoptions.get_vif_script()))
    3.56 +        script  = config.get('script', xoptions.get_vif_script())
    3.57          typ     = config.get('type')
    3.58          bridge  = config.get('bridge')
    3.59          mac     = config.get('mac')
    3.60 @@ -149,24 +108,17 @@ class NetifController(DevController):
    3.61          ipaddr  = config.get('ip')
    3.62          model   = config.get('model')
    3.63  
    3.64 -        devid = self.allocateDeviceID()
    3.65 -
    3.66          if not typ:
    3.67              typ = xoptions.netback_type
    3.68 -            
    3.69 +
    3.70          if not mac:
    3.71              mac = randomMAC()
    3.72  
    3.73 +        devid = self.allocateDeviceID()
    3.74 +
    3.75          back = { 'script' : script,
    3.76                   'mac'    : mac,
    3.77 -                 'handle' : "%i" % devid,
    3.78                   'type'   : typ }
    3.79 -
    3.80 -        if typ == 'ioemu':
    3.81 -            front = {}
    3.82 -        else:
    3.83 -            front = { 'handle' : "%i" % devid,
    3.84 -                      'mac'    : mac }
    3.85          if ipaddr:
    3.86              back['ip'] = ipaddr
    3.87          if bridge:
    3.88 @@ -174,12 +126,26 @@ class NetifController(DevController):
    3.89          if vifname:
    3.90              back['vifname'] = vifname
    3.91          if rate:
    3.92 -            back['rate'] = parseRate(rate)
    3.93 +            back['rate'] = rate
    3.94          if uuid:
    3.95              back['uuid'] = uuid
    3.96          if model:
    3.97              back['model'] = model
    3.98  
    3.99 +        config_path = "device/%s/%d/" % (self.deviceClass, devid)
   3.100 +        for x in back:
   3.101 +            self.vm._writeVm(config_path + x, back[x])
   3.102 +
   3.103 +        back['handle'] = "%i" % devid
   3.104 +        back['script'] = os.path.join(xoptions.network_script_dir, script)
   3.105 +        if rate:
   3.106 +            back['rate'] = parseRate(rate)
   3.107 +
   3.108 +        front = {}
   3.109 +        if typ != 'ioemu':
   3.110 +            front = { 'handle' : "%i" % devid,
   3.111 +                      'mac'    : mac }
   3.112 +
   3.113          return (devid, back, front)
   3.114  
   3.115  
   3.116 @@ -187,14 +153,17 @@ class NetifController(DevController):
   3.117          """@see DevController.configuration"""
   3.118  
   3.119          result = DevController.getDeviceConfiguration(self, devid)
   3.120 -        devinfo =  self.readBackend(devid, 'script', 'ip', 'bridge',
   3.121 -                                    'mac', 'type', 'vifname', 'rate',
   3.122 -                                    'uuid', 'model')
   3.123 +
   3.124 +        config_path = "device/%s/%d/" % (self.deviceClass, devid)
   3.125 +        devinfo = ()
   3.126 +        for x in ( 'script', 'ip', 'bridge', 'mac',
   3.127 +                   'type', 'vifname', 'rate', 'uuid', 'model' ):
   3.128 +            y = self.vm._readVm(config_path + x)
   3.129 +            devinfo += (y,)
   3.130          (script, ip, bridge, mac, typ, vifname, rate, uuid, model) = devinfo
   3.131  
   3.132          if script:
   3.133 -            network_script_dir = xoptions.network_script_dir + os.sep
   3.134 -            result['script'] = script.replace(network_script_dir, "")
   3.135 +            result['script'] = script
   3.136          if ip:
   3.137              result['ip'] = ip
   3.138          if bridge:
   3.139 @@ -206,11 +175,10 @@ class NetifController(DevController):
   3.140          if vifname:
   3.141              result['vifname'] = vifname
   3.142          if rate:
   3.143 -            result['rate'] = formatRate(rate)
   3.144 +            result['rate'] = rate
   3.145          if uuid:
   3.146              result['uuid'] = uuid
   3.147          if model:
   3.148              result['model'] = model
   3.149              
   3.150          return result
   3.151 -