Virtualization in Grid'5000: Difference between revisions
Jump to navigation
Jump to search
(→Or, you can start the guest OS using libvirt: Wrong line for the driver entry) |
mNo edit summary |
||
Line 54: | Line 54: | ||
</os> | </os> | ||
<clock sync="localtime"/> | <clock sync="localtime"/> | ||
<on_poweroff>destroy</on_poweroff> | |||
<on_reboot>restart</on_reboot> | |||
<on_crash>destroy</on_crash> | |||
<devices> | <devices> | ||
<emulator>/usr/bin/kvm</emulator> | <emulator>/usr/bin/kvm</emulator> | ||
<disk type='file' device='disk'> | <disk type='file' device='disk'> | ||
<driver | <driver type='qcow2'/> | ||
<source file='/tmp/squeeze-x64-base.qcow2'/> | <source file='/tmp/squeeze-x64-base.qcow2'/> | ||
<target dev=' | <target dev='vda' bus='virtio'/> | ||
</disk> | </disk> | ||
<interface type='ethernet'> | <interface type='ethernet'> | ||
<target dev='tap0'/> | <target dev='tap0'/> | ||
<script path='no'/> | <script path='no'/> | ||
<mac address='00:16:3e: | <mac address='00:16:3e:78:b8:04'/> | ||
</interface> | </interface> | ||
<serial type='pty'> | <serial type='pty'> | ||
Line 70: | Line 73: | ||
<target port='0'/> | <target port='0'/> | ||
</serial> | </serial> | ||
<console type='pty | <console type='pty'> | ||
<source path='/dev/ttyS0'/> | <source path='/dev/ttyS0'/> | ||
<target port='0'/> | <target port='0'/> | ||
Line 76: | Line 79: | ||
</devices> | </devices> | ||
</domain> | </domain> | ||
* Now, the guest OS can be started. | * Now, the guest OS can be started. | ||
Line 81: | Line 85: | ||
* You can use <code class="command">virsh</code> to manage your guest OS. | * You can use <code class="command">virsh</code> to manage your guest OS. | ||
jdoe@griffon-37:~$ virsh list | jdoe@griffon-37:~$ virsh list | ||
jdoe@griffon-37:~$ virsh connect squeeze | |||
{{Note|text= You can use the script <code class="command">/usr/local/bin/random_mac</code> to generate a mac address. | {{Note|text= You can use the script <code class="command">/usr/local/bin/random_mac</code> to generate a mac address. | ||
}} | }} |
Revision as of 20:27, 26 December 2011
See also: KVM | KVM_on_production_environment
Purpose
This page presents ways to use KVM on production image.
Usage
First, submit the job using habitual oarsub command
jdoe@fnancy:~$ oarsub -I
Copy the kvm disk image to /tmp on the node
jdoe@griffon-37:~$ cp /grid5000/images/KVM/squeeze-x64-base.qcow2 /tmp/
Create Tun/Tap interface for your guest OS
jdoe@griffon-37:~$ sudo create_tap
- Tun/Tap interfaces are listed by issuing the command
/sbin/ifconfig
.
jdoe@griffon-37:~$ /sbin/ifconfig
[...] tap0 Link encap:Ethernet HWaddr 00:16:3e:db:c6:41 inet6 addr: fe80::58ff:a4ff:fe97:c6a8/64 Scope:Link UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:29435 overruns:0 carrier:0 collisions:0 txqueuelen:500 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Generate a random mac address for the Tun/Tap interface
- Use the following script
jdoe@griffon-37:~$ export MACADDR=`random_mac`
![]() |
Note |
---|---|
The first three octets are important (identification for the virtualized network). Don't change it. |
Now, you can run the guest OS using kvm
jdoe@griffon-37:~$ screen kvm -m 512 -hda /tmp/squeeze-x64-base.qcow2 -net nic,macaddr=$MACADDR
-net tap,ifname=tap0
,script=no -nographic
![]() |
Note |
---|---|
In this example, |
Or, you can start the guest OS using libvirt
- Edit the domain file
eg : domain.xml
<domain type='kvm'> <name>squeeze</name> <memory>524288</memory> <vcpu>1</vcpu> <os> <type arch="x86_64">hvm</type> </os> <clock sync="localtime"/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> <emulator>/usr/bin/kvm</emulator> <disk type='file' device='disk'> <driver type='qcow2'/>
<target dev='vda' bus='virtio'/> </disk> <interface type='ethernet'> <target dev='tap0'/> <script path='no'/> <mac address='00:16:3e:78:b8:04'/> </interface> <serial type='pty'>
<target port='0'/> </serial> <console type='pty'>
<target port='0'/> </console> </devices> </domain>
- Now, the guest OS can be started.
jdoe@griffon-37:~$ virsh create domain.xml
- You can use
virsh
to manage your guest OS.
jdoe@griffon-37:~$ virsh list jdoe@griffon-37:~$ virsh connect squeeze
Misc notes
- For the deployment of an important number of guest OS, you can use the subnet reservation. See also the virtual network interlink.
- Manage the console for all your guest OS with Screen
- Use
tunctl
if you need to delete a Tun/Tap device.
jdoe@griffon-37:~$ /usr/sbin/tunctl -d tap0
- Some clusters don't have virtualization support in the BIOS. To check :
jdoe@griffon-37:~$ egrep '^flags.*(vmx|svm)' /proc/cpuinfo