3.修改virt-manager代码:
通过上面的报错,发现virt-manager使用python写的!正好想看什么源码来自,这个正好!
通过对virt-manager这一项目一步步debug,找到问题:
[root@11.102 ~]$grep -n -A22 "class DebianDistro" /usr/share/virt-manager/virtinst/urlfetcher.py 1076:class DebianDistro(Distro): 1077- # ex. http://ftp.egr.msu.edu/debian/dists/sarge/main/installer-i386/ 1078- # daily builds: http://d-i.debian.org/daily-images/amd64/ 1079- name = "Debian" 1080- urldistro = "debian" 1081- os_variant = "linux" 1082- 1083- def __init__(self, *args, **kwargs): 1084- Distro.__init__(self, *args, **kwargs) 1085- 1086- # Pull the tree's arch out of the URL text 1087- self._treeArch = 'i386' 1088- for pattern in ["^.*/installer-(w+)/?$", 1089- "^.*/daily-images/(w+)/?$"]: 1090- arch = re.findall(pattern, self.uri) 1091- if arch: 1092- self._treeArch = arch[0] 1093- break 1094- 1095- self._url_prefix = 'current/images' 1096- self._installer_dirname = self.name.lower() + "-installer" 1097- self._set_media_paths()
发现基于Debian的系统,__init__方法中self._treeArch初始化时是i386,估计是virt-manager读取ubuntu的iso文件时,出了什么问题,没读出该系统是x86_64类型,将该值改为amd64,就可以了。
再次运行virt-install,成功进入ubuntu安装界面!
附:CentOS命令行使用KVM安装64位ubuntu报"Couldn't find hvm kernel for Ubuntu tree."的解决办法
grep -n -A21 'class DebianDistro' /usr/lib/python2.6/site-packages/virtinst/OSDistro.py 命令可以查看DebianDistro类的__init__方法
[root@2 virtinst]$grep -n -A21 'class DebianDistro' /usr/lib/python2.6/site-packages/virtinst/OSDistro.py
892:class DebianDistro(Distro):
893- # ex. http://ftp.egr.msu.edu/debian/dists/sarge/main/installer-i386/
894- # daily builds: http://people.debian.org/~joeyh/d-i/
895-
896- name = "Debian"
897- os_type = "linux"
898-
899- def __init__(self, uri, arch, vmtype=None, scratchdir=None):
900- Distro.__init__(self, uri, arch, vmtype, scratchdir)
901- if uri.count("installer-i386"):
902- self._treeArch = "i386"
903- elif uri.count("installer-amd64"):
904- self._treeArch = "amd64"
905- else:
906- self._treeArch = "i386"
907-
908- if re.match(r'i[4-9]86', arch):
909- self.arch = 'i386'
910-
911- self._installer_name = self.name.lower() + "-" + "installer"
912- self._prefix = 'current/images'
913- self._set_media_paths()
改变__init__方法里的else:条件下面的一行,将"i386"改为"amd64"即可
- self._treeArch = 'i386' + self._treeArch = 'amd64'








