lost and found ( for me ? )

Fedora 18 : KVM , nested VM

Here’s an explanation of how to configure nested VM.

JeOS VM is running within Ubuntu 12.10 VM which is running within Fedora KVM

JeOS VM
---------------
Ubuntu 12.10 VM
---------------------------
Fedora 18 ( KVM host )

KVM host

[root@localhost ~]# uname -ri
3.7.5-201.fc18.x86_64 x86_64

[root@localhost ~]# cat /etc/fedora-release
Fedora release 18 (Spherical Cow)

[root@localhost ~]# libvirtd --version
libvirtd (libvirt) 0.10.2.3

[root@localhost ~]# qemu-kvm --version
QEMU emulator version 1.2.2 (qemu-kvm-devel), Copyright (c) 2003-2008 Fabrice Bellard

[root@localhost ~]# egrep "model name" /proc/cpuinfo |uniq
model name : AMD Phenom(tm) II X4 925 Processor

[root@localhost ~]# egrep 'vmx|svm' /proc/cpuinfo | uniq
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nopl nonstop_tsc extd_apicid pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt hw_pstate npt lbrv svm_lock nrip_save


kvm_amd seemed to be enabled on  Fedora 18’s KVM package by default settings.
[root@localhost ~]# modinfo kvm_amd
filename:       /lib/modules/3.7.5-201.fc18.x86_64/kernel/arch/x86/kvm/kvm-amd.ko
license:        GPL
author:         Qumranet
alias:          x86cpu:vendor:*:family:*:model:*:feature:*00C2*
depends:        kvm
intree:         Y
vermagic:       3.7.5-201.fc18.x86_64 SMP mod_unload
parm:           npt:int
parm:           nested:int

[root@localhost ~]# cat /sys/module/kvm_amd/parameters/nested
1


I’ve prepared a ubuntu 12.10 VM.

start the VM
virsh # start ubuntu1210-vm01 --console
Domain ubuntu1210-vm01 started
Connected to domain ubuntu1210-vm01
Escape character is ^]

Ubuntu 12.10 ubuntu1210-vm1 ttyS0

ubuntu1210-vm1 login: root
Password:
root@ubuntu1210-vm1:~#


check the CPU info of that VM to see if the VM’s CPU support AMD-V.
the VM supports AMD-V
root@ubuntu1210-vm1:~# egrep 'model name|svm' /proc/cpuinfo
model name : QEMU Virtual CPU version 1.2.2
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm up nopl pni cx16 popcnt hypervisor lahf_lm svm abm sse4a


install KVM and vm builder
root@ubuntu1210-vm1:~# apt-get install -y kvm libvirt-bin
root@ubuntu1210-vm1:~# apt-get install -y python-vm-builder-ec2

root@ubuntu1210-vm1:~# kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used


build a JeOS VM within the Ubuntu 12.10 VM which is running within Fedora KVM.
root@ubuntu1210-vm1:~# vmbuilder kvm ubuntu --suite precise --flavour virtual --arch i386 -o --libvirt qemu:///system --hostname myvm --user user --pass default
2013-02-26 00:13:49,061 INFO    : Calling hook: preflight_check
2013-02-26 00:13:49,065 INFO    : Calling hook: set_defaults
2013-02-26 00:13:49,066 INFO    : Calling hook: bootstrap
<snip>
2013-02-26 00:36:14,281 INFO    : Converting /tmp/tmpdowa5G to qcow2, format ubuntu-kvm/tmpdowa5G.qcow2
2013-02-26 00:36:45,799 INFO    : Calling hook: fix_ownership
2013-02-26 00:36:45,828 INFO    : Calling hook: deploy
root@ubuntu1210-vm1:~#


start the VM..
ooops , permission denied..
root@ubuntu1210-vm1:~# virsh
lWelcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
      'quit' to quit

virsh # list --all
Id    Name                           State
----------------------------------------------------
-     myvm                           shut off

virsh # start myvm
error: Failed to start domain myvm
error: internal error process exited while connecting to monitor: kvm: -drive file=/root/ubuntu-kvm/tmpdowa5G.qcow2,if=none,id=drive-ide0-0-0,format=qcow2: could not open disk image /root/ubuntu-kvm/tmpdowa5G.qcow2: Permission denied


virsh #


mv qcow2 image to /var/lib/libvirt/images directory
root@ubuntu1210-vm1:~# mv ubuntu-kvm/tmpdowa5G.qcow2 /var/lib/libvirt/images/myvm.qcow2


and edit XML

from
<source file='/root/ubuntu-kvm/tmpdowa5G.qcow2'/>


to
<source file='/var/lib/libvirt/images/myvm.qcow2'/>


start the VM
the VM “myvm” is running ubuntu 12.10 VM which is running within Fedora KVM.
virsh # start myvm
Domain myvm started

virsh # list --all
Id    Name                           State
----------------------------------------------------
2     myvm                           running

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.