DDR爱好者之家 Design By 杰米

1.安装ubuntu时使用的virt-install的配置:

virt-install --name test4 --ram 1024 --disk path=/data/01_ubuntu/ubuntu4.img,size=6 --vcpus 1 --hvm --os-type linux --network network=default --os-variant ubuntuquantal --graphics none --console pty,target_type=serial --location /data/00_osfile/ubuntu-16.04.1-server-amd64.iso --extra-args 'console=ttyS0,115200n8 serial'

报错如下:

ERROR Couldn't find hvm kernel for Ubuntu tree.
Domain installation does not appear to have been successful.

通过查资料发现,virt-install可以开debug模式的,加入--debug选项即可

2.virt-install的debug模式得到的结果:

[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (urlfetcher:268) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.xPL9y1/current/images/MANIFEST
[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (urlfetcher:89) Fetching URI: /var/lib/libvirt/boot/virtinstmnt.xPL9y1/install/netboot/version.info
Retrieving file version.info... | 58 B 00:00:00 
[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (urlfetcher:1164) Didn't find any known codename in the URL string
[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (urlfetcher:511) Detected distro name=Ubuntu osvariant=linux
[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (urlfetcher:268) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.xPL9y1/install/netboot/ubuntu-installer/i386/linux

这里就可以看出问题了,明明是64位的操作系统,为什么去找./install/netboot/ubuntu-install/i386/linux的路径

我们去看看iso文件中正确的路径是什么:

[root@11.102 01_ubuntu]$mount /data/00_osfile/ubuntu-16.04.1-server-amd64.iso /mnt
mount: /dev/loop2 is write-protected, mounting read-only
[root@11.102 01_ubuntu]$ls /mnt/install/netboot/ubuntu-installer/amd64/linux 
/mnt/install/netboot/ubuntu-installer/amd64/linux

基本确定,如果将路径的i386改为amd64,virt-install安装就没有问题。

debug模式剩余的log:

[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (urlfetcher:320) Cleaning up mount at /var/lib/libvirt/boot/virtinstmnt.xPL9y1
[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (cli:305) File "/usr/share/virt-manager/virt-install", line 1077, in <module>
sys.exit(main())
File "/usr/share/virt-manager/virt-install", line 1071, in main
start_install(guest, continue_inst, options)
File "/usr/share/virt-manager/virt-install", line 775, in start_install
fail(e, do_exit=False)
File "/usr/share/virt-manager/virtinst/cli.py", line 305, in fail
logging.debug("".join(traceback.format_stack()))
[Wed, 30 Nov 2016 11:16:07 virt-install 26900] ERROR (cli:306) Couldn't find hvm kernel for Ubuntu tree.
[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (cli:308) 
Traceback (most recent call last):
File "/usr/share/virt-manager/virt-install", line 747, in start_install
dom = guest.start_install(meter=meter, noboot=options.noreboot)
File "/usr/share/virt-manager/virtinst/guest.py", line 491, in start_install
self._prepare_install(meter, dry)
File "/usr/share/virt-manager/virtinst/guest.py", line 304, in _prepare_install
self.installer.prepare(self, meter)
File "/usr/share/virt-manager/virtinst/installer.py", line 200, in prepare
self._prepare(guest, meter)
File "/usr/share/virt-manager/virtinst/distroinstaller.py", line 451, in _prepare
self._prepare_kernel_url(guest, fetcher)
File "/usr/share/virt-manager/virtinst/distroinstaller.py", line 360, in _prepare_kernel_url
kernel, initrd, args = store.acquireKernel(guest)
File "/usr/share/virt-manager/virtinst/urlfetcher.py", line 603, in acquireKernel
{"distro": self.name, "type" : self.type})
RuntimeError: Couldn't find hvm kernel for Ubuntu tree.

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'

DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米

《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线

暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。

艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。

《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。