https://www.heepy.net/index.php?title=KVM_virtual_machines_in_ubuntu&feed=atom&action=historyKVM virtual machines in ubuntu - Revision history2024-03-28T10:05:02ZRevision history for this page on the wikiMediaWiki 1.35.2https://www.heepy.net/index.php?title=KVM_virtual_machines_in_ubuntu&diff=109&oldid=prevMorris at 22:35, 11 September 20092009-09-11T22:35:23Z<p></p>
<p><b>New page</b></p><div>Install the packages: <br />
<br />
aptitude install ubuntu-virt-server virt-manager kvm python-vm-builder python-virtinst virt-viewer virt-top virt-goodies<br />
<br />
Make sure virtualization is enabled in host machine's BIOS; it usually isn't.<br />
<br />
If you don't want the default network config of a private network with a local dhcp server, get rid of libvirt's default nat setup:<br />
<br />
virsh -c qemu:///system<br />
# net-destroy default<br />
# net-edit default<br />
<br />
<br />
To use bridging to a local interface, make it look like this:<br />
<br />
<pre><br />
<network><br />
<name>default</name><br />
<uuid>18eb5edc-7b46-0f44-ac24-33028d540251</uuid><br />
<bridge name='virbr0' stp='on' forwardDelay='0' /><br />
</network><br />
</pre><br />
<br />
Then run (in virsh): <br />
# net-start default<br />
<br />
<br />
If there isn't a default storage pool defined already (I think the gui "virt-manager" will make one if it doesn't exist?) <br />
you can import an xml configuration using "virsh pool-define whatever.xml" of which an example is here:<br />
<pre><br />
<pool type='dir'><br />
<name>default</name><br />
<capacity>0</capacity><br />
<allocation>0</allocation><br />
<available>0</available><br />
<source><br />
</source><br />
<target><br />
<path>/var/lib/libvirt/images</path><br />
<permissions><br />
<mode>0700</mode><br />
<owner>0</owner><br />
<group>0</group><br />
</permissions><br />
</target><br />
</pool><br />
</pre><br />
<br />
You can use the virt-manager gui to create a VM, or do it on the command <br />
line with virt-install to have an initial configuration created for you.<br />
<br />
<pre><br />
# virt-install \<br />
--connect qemu:///system \<br />
-n testvm3 /<br />
-r 512 /<br />
--disk path=/var/lib/libvirt/images/testvm3.img,size=30 /<br />
--cdrom /home/eric/ubuntu-9.04-server-amd64.iso /<br />
--network bridge:br0 /<br />
--vnc /<br />
--accelerate --hvm<br />
</pre><br />
<br />
This will try to spawn a console for the vm so you can do the install. You can <br />
also manipulate configs and create new VMs directly with virsh commands. <br />
<br />
Dump the config of an existing vm: <br />
<br />
virsh -c qemu:///system dumpxml testvm > testvm.xml<br />
<br />
edit testvm.xml to suit, for example, have it point to a disk image you've<br />
already put in place, etc. Make sure to change name, vnc port, etc. If you<br />
just remove the uuid definition, it will generate a new one for you. Then, <br />
<br />
virsh -c qemu:///system create testvm.xml<br />
<br />
This will configure, create, and start the new VM. <br />
<br />
To use existing disk with virt-install:<br />
<br />
<pre><br />
virt-install --connect=qemu:///system --name blah --ram 256 --os-type=linux \<br />
--import --disk vol=default/blah.img ...<br />
</pre><br />
<br />
'''Note:'''<br />
The default network device emulation is rtl8139, which appears to not support vlan tags. <br />
If you try to pass tagged packets through it, the host system will see your packets with<br />
the tags stripped off. If you use e1000 emulation instead, by adding<br />
<model type='e1000'/><br />
to the "interface" section of the VM xml config, vlan tags will pass through to the host.<br />
<br />
<br />
[[Category:Incantations]]</div>Morris