61581229 发表于 2015-4-13 12:26:17

xen虚机的启动过程

  XendDomain.py:1027
   1   _refresh():
              Refresh the domain list. Needs to be called when either xenstore has changed or when a
              method requires up to date information (like uptime, cputime stats).
              调用_refreshTxn()刷新运行状态的虚机
            调用XendDomainInfo的update方法更新DomainInfo
            Update with info from xc.domain_getinfo()
      xenstore里面有而xend里面没有的,重新创建
      xc.domain_getinfo()中已不再运行状态,而xend中还处在运行状态的,更新xend
2    domain_lookup_nr():查询虚机的信息
            参数domid会按照name,id,uuid都查找一遍,而不是设置一个类型
            如果虚机不是halt状态,则返回错误
3    调用XendDomainInof.start()启动虚机
      XendTask.log_progress(0, 30, self._constructDomain) # 添加到xenddomain,hvm的判断、设置domain为TSC模式、设置时间配置、设置接口、最大CPU数目以及PCI等(调用了xen.lowlevle.xc.xc()函数创建domain)
                XendTask.log_progress(31, 60, self._initDomain)
                XendTask.log_progress(61, 70, self._storeVmDetails) # 向xenstore写虚机信息
                XendTask.log_progress(71, 80, self._storeDomDetails) # 同上
                XendTask.log_progress(81, 90, self._registerWatches) # 注册watcher
                XendTask.log_progress(91, 100, self.refreshShutdown) # Checks the domain for whether a shutdown is required.
4    dominfo.waitForDevices():
      等待后端设备,其实就是去读下面参数的结果,这个值会由
      # xenstore-read /local/domain/0/backend/vif/2/0/hotplug-status
      # connected
      该状态由xen-hotplug-common.sh脚本设置
页: [1]
查看完整版本: xen虚机的启动过程