Context
The following guide is dedicated to anyone that loves commandline interface and scriptability. It also serves as a solution against integrated tools in KVM management (this sounds weird! ^_^)
I will use seperate tools to complete the job.
Essential tools for regular tasks
Create a disk image
Use tool qemu-img in linux to create disk image:
See manpage of qemu-img to learn more options.
Convert image
If you need to use an existing disk image whose format is different from qcow2 or raw, you can convert it with qemu-img
Create a VM
Use virt-install tool to create a new VM. Five basic options required for a new VM includes name, ram, disk, install method, graphics.
Install method usually takes cdrom or http url. The url must be directory listings of install content not an iso image. Below is an example:
The graphics option can be omitted if graphical display is not necessary for VM. By default vnc display of VM listens at 127.0.0.1. So if you need to access the display remotely, an IP address must specified. There are also other display methods than vnc. Check virt-install manpage for more.
List VMs
Use virsh tool to manage VMs.
List running VMs:
List all existing VM:
Power off VMs
Start VMs
Edit VM setting
Because a running VM corresponds to a process named qemu-kvm launched with passed arguments, so it is impossible to edit machine setting on runtime. The VM must be destroyed before editing. To edit VM settings:
Settings of VM are stored in XML format. You must learn XML tags at libvirt.org to customize your VM.
View VM serial/graphical console
User can interact with his VM via serial console or graphical console. Serial console may not be always present. It depends on whether OS on the VM outputs via serial console or not. To access serial console:
For vnc display, each VM is bound to a vnc port for user to connect. The binding is done automatically during VM installation if user don't specify port option. To see at which port the vnc display of a VM is listening:
Then use a vnc viewer e.g tigervnc to access the display.
No comments:
Post a Comment