Total Pageviews

Friday, 23 December 2016

Virtualization Shell (virsh) Commands !!!

In this post I am going to show different commands of "virsh" CLI including output. To manage virtual machines of KVM through command line we need "virsh". To enable virsh CLI we install libvirt-bin package.

Now I am going to show basic commands and their sub-commands usage. Whenever we learn any new commands, it is always a good practice to remember a command as follows:

command: virsh.
sub-command: the part comes next to the command.
options or optional things: which changes as per sub-command.

Sorry if I messed it, but what I mean to explain is...

Every command starts with a name, sub-command and options. So if we need to attach a disk the sub-command will be attach-disk and options are like size of the disk. Similarly command for renaming a domain, can be virsh rename oldname newname. So sometimes instead of options there will be optional things.

Even if my explanation is still unclear, don't worry about it, just continue with the post. Below are the few commands and its usage with output.

root@ubuntu-kvm:~# virsh -v                                 --- for short description
2.1.0
root@ubuntu-kvm:~#
root@ubuntu-kvm:~# virsh --version
2.1.0
root@ubuntu-kvm:~#

root@ubuntu-kvm:~# virsh -V                                  --- for long description
Virsh command line tool of libvirt 2.1.0
See web site at http://libvirt.org/

Compiled with support for:
 Hypervisors: QEMU/KVM LXC UML Xen LibXL OpenVZ VMware VirtualBox ESX Test
 Networking: Remote Network Bridging Interface netcf Nwfilter VirtualPort
 Storage: Dir Disk Filesystem SCSI Multipath iSCSI LVM RBD Sheepdog ZFS
 Miscellaneous: Daemon Nodedev AppArmor Secrets Debug DTrace Readline Modular
root@ubuntu-kvm:~#

root@ubuntu-kvm:~# virsh list
 Id    Name                           State
----------------------------------------------------
 7     win2003                        running
 8     VM1                            running


root@ubuntu-kvm:~#

Host and Hypervisor related:

To view version of hypervisor,

root@ubuntu-kvm:~# virsh version                       
Compiled against library: libvirt 2.1.0
Using library: libvirt 2.1.0
Using API: QEMU 2.1.0
Running hypervisor: QEMU 2.6.1

root@ubuntu-kvm:~#

To view maximum cpus of host,

root@ubuntu-kvm:~# virsh maxvcpus                     
16

root@ubuntu-kvm:~#

To view memory statistics of host,

root@ubuntu-kvm:~# virsh nodememstats
total  :              2047852 KiB
free   :                81620 KiB
buffers:                 9600 KiB
cached :               148500 KiB

root@ubuntu-kvm:~#

To view cpu statistics of host,

root@ubuntu-kvm:~# virsh nodecpustats
user:                 27478810000000
system:                 736920000000
idle:                 14469860000000
iowait:                1864430000000

root@ubuntu-kvm:~#

To view info related to host,

root@ubuntu-kvm:~# virsh nodeinfo
CPU model:           x86_64
CPU(s):              1
CPU frequency:       2200 MHz
CPU socket(s):       1
Core(s) per socket:  1
Thread(s) per core:  1
NUMA cell(s):        1
Memory size:         2047852 KiB

root@ubuntu-kvm:~#

To view hostname of host machine,

root@ubuntu-kvm:~# virsh hostname
ubuntu-kvm

root@ubuntu-kvm:~#

To view URI (Uniform Resource Identifier),

root@ubuntu-kvm:~# virsh uri
qemu:///system

root@ubuntu-kvm:~#

To view complete system info of host,

root@ubuntu-kvm:~# virsh sysinfo
<sysinfo type='smbios'>
  <bios>
    <entry name='vendor'>innotek GmbH</entry>
    <entry name='version'>VirtualBox</entry>
    <entry name='date'>12/01/2006</entry>
  </bios>
  <system>
    <entry name='manufacturer'>innotek GmbH</entry>
    <entry name='product'>VirtualBox</entry>
    <entry name='version'>1.2</entry>
    <entry name='serial'>0</entry>
    <entry name='uuid'>6F5ED8B0-1976-4DB6-A716-93F90015C16A</entry>
    <entry name='sku'>Not Specified</entry>
    <entry name='family'>Virtual Machine</entry>
  </system>
  <baseBoard>
    <entry name='manufacturer'>Oracle Corporation</entry>
    <entry name='product'>VirtualBox</entry>
    <entry name='version'>1.2</entry>
    <entry name='serial'>0</entry>
    <entry name='asset'>Not Specified</entry>
    <entry name='location'>Not Specified</entry>
  </baseBoard>
</sysinfo>


root@ubuntu-kvm:~#

Domain Administration related:

To take console of our domain/VM,

root@ubuntu-kvm:~# virsh console VM1
Connected to domain VM1
Escape character is ^]
Killed

root@ubuntu-kvm:~#

To view description of our domain/VM,

root@ubuntu-kvm:~# virsh desc VM1
No description for domain: VM1

root@ubuntu-kvm:~#

To view cpustats of domain/VM,

root@ubuntu-kvm:~# virsh cpu-stats VM1
CPU0:
        cpu_time           451.542828932 seconds
Total:
        cpu_time           451.542828932 seconds
        user_time          360.800000000 seconds
        system_time         67.150000000 seconds

root@ubuntu-kvm:~#

To view memory stats of domain/VM,

root@ubuntu-kvm:~# virsh dommemstat VM1
actual 1048576
swap_in 0
last_update 1482452747
rss 1101100
root@ubuntu-kvm:~#

To display connection URI of domain/VM,

root@ubuntu-kvm:~# virsh domdisplay VM1
spice://127.0.0.1:5900
root@ubuntu-kvm:~#

To create dump of domain/VM,

root@ubuntu-kvm:~# virsh dumpxml VM1 >>vm1.xml
root@ubuntu-kvm:~#
root@ubuntu-kvm:~# ls
vm1.xml
root@ubuntu-kvm:~#

To take snapshot of domain/VM,

root@ubuntu-kvm:~# virsh screenshot VM1 vmsnap
Screenshot saved to vmsnap, with type of image/x-portable-pixmap
root@ubuntu-kvm:~#
root@ubuntu-kvm:~# ls
vm1.xml  vmsnap
root@ubuntu-kvm:~#

To suspend our domain/VM,

root@ubuntu-kvm:~# virsh suspend VM1
Domain VM1 suspended

root@ubuntu-kvm:~#
root@ubuntu-kvm:~# virsh list
 Id    Name                           State
----------------------------------------------------
 7     win2003                        running
 8     VM1                            paused

root@ubuntu-kvm:~#

To resume our domain/VM,

root@ubuntu-kvm:~# virsh resume VM1
Domain VM1 resumed

root@ubuntu-kvm:~#
root@ubuntu-kvm:~# virsh list
 Id    Name                           State
----------------------------------------------------
 7     win2003                        running
 8     VM1                            running

root@ubuntu-kvm:~#

To shutdown our domain/VM,

root@ubuntu-kvm:~# virsh shutdown VM1
Domain VM1 is being shutdown

root@ubuntu-kvm:~#
root@ubuntu-kvm:~# virsh list
 Id    Name                           State
----------------------------------------------------
 7     win2003                        running

root@ubuntu-kvm:~#

To rename our domain/VM,

root@ubuntu-kvm:~# virsh domrename VM1 Ubuntu
Domain successfully renamed

root@ubuntu-kvm:~#
root@ubuntu-kvm:~# virsh list
 Id    Name                           State
----------------------------------------------------
 7     win2003                        running

root@ubuntu-kvm:~#

To check state of our domain/VM,

root@ubuntu-kvm:~# virsh domstate Ubuntu
shut off
root@ubuntu-kvm:~#

To start our domain/VM,

root@ubuntu-kvm:~# virsh start VM1
error: failed to get domain 'VM1'                                 Error because VM1 no longer exists...
error: Domain not found: no domain with matching name 'VM1'
root@ubuntu-kvm:~#

As soon as we renamed our domain, the default xml file of our domain also gets renamed automatically...

root@ubuntu-kvm:/etc/libvirt/qemu# ls -lrth
total 16K
drwxr-xr-x 3 root root 4.0K Dec 21 18:48 networks
-rw------- 1 root root 4.3K Dec 22 18:48 win2003.xml
-rw------- 1 root root 3.9K Dec 23 17:58 Ubuntu.xml
root@ubuntu-kvm:/etc/libvirt/qemu#

root@ubuntu-kvm:~# virsh start Ubuntu
Domain Ubuntu started

root@ubuntu-kvm:~#
root@ubuntu-kvm:~# virsh list
 Id    Name                           State
----------------------------------------------------
 7     win2003                        running
 9     Ubuntu                         running

root@ubuntu-kvm:~#

Similarly to restart/reset/destroy our domain/vm....

root@ubuntu-kvm:~# virsh restart/reset/destroy <domname>

Similarly to save/restore state of our domain/vm....

root@ubuntu-kvm:~#
 virsh save Ubuntu vm1state
Domain Ubuntu saved to vm1state
root@ubuntu-kvm:~#
root@ubuntu-kvm:~#
 virsh restore Ubuntu vm1state
root@ubuntu-kvm:~#

Adding/removing resources related:

To change vcpus of our domain/VM,

root@ubuntu-kvm:~# virsh setvcpus --count 1 Ubuntu

To change vcpus of our domain/VM,

root@ubuntu-kvm:~# virsh setmem --size 512 Ubuntu

To attach disk/device/interface to our domain/VM,

root@ubuntu-kvm:~# virsh 
attach-device 
<domain> <file> 
                                           attach-disk 
<domain> <source> <target> 
                                           attach-interface 
<domain> <type> <source>

To detach disk/device/interface to our domain/VM,

root@ubuntu-kvm:~# virsh de
tach-device 
<domain> <file> 
                                           detach-disk 
<domain> <source> <target> 
                                           detach-interface 
<domain> <type> <source> 

To view disks attached to our domain/VM,

root@ubuntu-kvm:~# virsh domblklist win2003
Target     Source
------------------------------------------------
hda        /var/lib/libvirt/images/win2003.qcow2
hdb        /test/Windows 2003 Server.iso

root@ubuntu-kvm:~#

To view network properties of our domain/VM,

root@ubuntu-kvm:~# virsh domiflist win2003
Interface  Type       Source     Model       MAC
-------------------------------------------------------
-          network    default    rtl8139     52:54:00:20:1d:55

root@ubuntu-kvm:~#

######################################################################################

Thursday, 22 December 2016

Kernel-based Virtual Machine (KVM) creation !!!

On top of a physical machine, once we installed set of packages and enabled the Virtualization,  we can create virtual machines within it. We can create/manage in three ways...

1. Virtualization shell (virsh CLI).
2. Virtual Manager -virt-manager (GUI).
3. Ubuntu-vm-builder (Command Line tool).

At first I am going to show you the steps to create vm using commands. 

Command: virt-install

Options:   --name    --ram    --vcpus   --disk path   ---cdrom     ---boot    --location    --console

USAGE: 
             root@ubuntu-kvm:~# virt-install
                      WARNING  KVM acceleration not available, using 'qemu'
                      ERROR
                      --name is required
                      --memory amount in MiB is required
                      --disk storage must be specified (override with --disk none)
                       An install method must be specified
                       (--location URL, --cdrom CD/ISO, --pxe, --import, --boot hd|cdrom|...)
              root@ubuntu-kvm:~#

After installing libvirt-bin, we can use the virsh commands...

virsh CLI

To install new vm,

root@ubuntu-kvm:/test# virt-install --name VM1 --ram 1024 --vcpus=1 --disk=/var/lib/libvirt/images/VM1.img,size=8 --cdrom /test/ubuntu-16.10-server-amd64.iso
WARNING  KVM acceleration not available, using 'qemu'
WARNING  Graphics requested but DISPLAY is not set. Not running virt-viewer.
                      virt-viewer is not running, I am running these commands from putty.....
WARNING  No console to launch for the guest, defaulting to --wait -1

Starting install...
Allocating 'VM1.img'                                                                               | 8.0 GB  00:00:02
Creating domain...                                                                                 |    0 B  00:00:00
Domain installation still in progress. Waiting for installation to complete.

Use the command virt-viewer to view the installation process,


Click on "connect", then we can view the installation....


From now it is all normal installation process....


Other than above options, we can also give different options like...

  virt-install --connect qemu:///system
-n vm10                     (name)
-r 1024                      (ram)
--vcpus=2                  (virtual cpu)
--disk path=/var/lib/libvirt/images/vm10.img,size=12      (disk and its size)
-c /test/ubuntu.iso             (cdrom)
-x “console=tty”
--os-type linux          (specify OS type)
--graphics                  (nographics)
--accelerate
--network=bridge:br0       (to specify network card)
--virt-type HV_TYPE            (to specify Hypervisor name (kvm, qemu, xen, ...))
--hvm             (to specify guest should be a fully virtualized guest)
--autostart            (to autostart domain on host boot up)

Still many other options, we can check the usage by "virt-install --help".

Installation process is about to complete...


root@ubuntu-kvm:/test# virt-install --name VM1 --ram 1024 --vcpus=1 --disk=/var/lib/libvirt/images/VM1.img,size=8 --cdrom /test/ubuntu-16.10-server-amd64.iso

Starting install...
Allocating 'VM1.img'                                                                               | 8.0 GB  00:00:02
Creating domain...                                                                                 |    0 B  00:00:00
Domain installation still in progress. Waiting for installation to complete.
                                                              Takes bit long time, once installation completed it will be....
Domain has shutdown. Continuing.
Domain creation completed.
Restarting guest.
root@ubuntu-kvm:/test#

 Below is the output of virt-viewer upon reboot of VM....


Once logged in,



We can check the newly created vm by,

root@ubuntu-kvm:~# virsh list
 Id    Name                           State
----------------------------------------------------
 1     VM1                            running

root@ubuntu-kvm:~#

root@ubuntu-kvm:~# virsh -c qemu:///system list
 Id    Name                           State
----------------------------------------------------
 1     VM1                            running

root@ubuntu-kvm:~#

We can also enter the commands from virsh terminal....

root@ubuntu-kvm:~# virsh
Welcome to virsh, the virtualization interactive terminal.

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

virsh #
virsh # list
 Id    Name                           State
----------------------------------------------------
 1     VM1                            running

virsh #
virsh # exit

root@ubuntu-kvm:~#

By this we created a vm using CLI of virsh environment. Now let us create another VM using GUI virt-manager....

virt-manager

As soon as we entered the virt-manager command, GUI screen will be popped out...



Click on create a new virtual machine...


We are using local media so click on forward...


Browse the iso image location....



Choose the Memory and vcpus for our domain/vm...


Choose the Storage for our vm...


Check the allocated resources, if we want we can do some network selection like IP assigning, router an netmask....


Initated the domain or vm creation process....


Windows setup is started....


From now, it is general process of Windows OS installation....


Setup copying files is about to complete....


First reboot during the installation process....




By the time of completion, we will be having 2 VMs within our Host Ubuntu machine...


root@ubuntu-kvm:~# virsh list
 Id    Name                           State
----------------------------------------------------
 2     VM1                            running
 5     win2003                        running

root@ubuntu-kvm:~#

Above, if you observe the instance ID is 5, ID will be changed upon every reboot. It means when we created VM1 its ID is 1 and when it is rebooted ID is 2.

Similarly when win2003 is created its ID is 3, during installation process it was rebooted twice and so ID is 5.

Ubuntu-vm-builder

Now let us create another VM using Ubuntu-vm-builder utility....

root@ubuntu-kvm:~# ubuntu-vm-builder
2016-12-22 19:34:13,623 INFO    : logging to file: /tmp/tmpaIORvG
Usage: ubuntu-vm-builder hypervisor suite [options]

ubuntu-vm-builder: error: You need to specify at least the hypervisor type and the series
root@ubuntu-kvm:~#

OR ELSE

root@ubuntu-kvm:~# vmbuilder
2016-12-22 19:46:50,755 INFO    : logging to file: /tmp/tmpGF7Z7n
Usage: vmbuilder hypervisor distro [options]

vmbuilder: error: You need to specify at least the hypervisor type and the distro
root@ubuntu-kvm:~#

Let us create a vm using some basic options....

root@ubuntu-kvm:~# vmbuilder kvm ubuntu --domain VM2 --cpus=1 --mem=1024 --dest /var/lib/libvirt/images/VM2.img  --iso /test/ubuntu-16.10-server-amd64.iso  --libvirt qemu://system 

2016-12-22 19:52:08,987 INFO    : logging to file: /tmp/tmp4xfqeU
2016-12-22 19:52:09,014 INFO    : Calling hook: preflight_check
2016-12-22 19:52:09,018 INFO    : Calling hook: set_defaults
2016-12-22 19:52:09,020 INFO    : Calling hook: bootstrap
2016-12-22 19:52:09,030 INFO    : mount: /dev/loop0 is write-protected, mounting read-only
2016-12-22 19:52:09,161 INFO    : Cleaning up
2016-12-22 19:52:09,192 ERROR   : Process (['/usr/sbin/debootstrap', '--arch=amd64', 'lucid', '/tmp/tmp0RLlyc', 'file:///tmp/tmpNtk6ch']) returned 1. stdout: I: Retrieving InRelease

************** OUTPUT TRUNCATED **************

This is followed by general steps of Ubuntu installation..... Once the installation is done, we have 3 VMs within our host machine.

root@ubuntu-kvm:~# virsh list
 Id    Name                           State
----------------------------------------------------
 2     VM1                            running
 5     win2003                        running
 7     VM2                             running

root@ubuntu-kvm:~#

Different options which we can provide with vmbuilder command during creation of vm...

vmbuilder USAGE:
ubuntu-vm-builder kvm --domain VM2 
                  --arch i386 or amd64   (to specify CPU architecture)
                  --hostname myvm (to specify hostname)
                  --user ubu  (to create a user)
                  --pass ubu  (to assign password to user)
--bridge=br0 (to specify NIC)
                  --ip 10.0.0.222                          (to assign ip)
                  --mask 255.255.255.0 (to assign netmask)
                  --net 10.0.0.0                             (to define network range)
                  --bcast 10.0.0.255      (to assign broadcast)
                  --gw 10.0.0.1                             (to assign gateway)
                  --dns 10.0.0.1                            (to assign DNS)
                  --rootsize=102400 (to allocate root size)
--addpkg openssh-server        (to add additional package)

We created KVMs in all the three different ways. In this post, I concentrated only on the different utilities which we use to create/manage VMs in Linux.

######################################################################################

Wednesday, 21 December 2016

Linux KVM (Kernel-based Virtual Machine) !!!

So far I covered virtualization concepts of VMware (ESXi host and VMs) and Solaris (LDOMS), In this post I am going to discuss about virtualization in Linux which is KVM (Kernel-based Virtual Machine).

Soon after installing Linux OS on top of some high configuration server, we have to install few packages and enable virtualization at kernel level to build and configure VMs (Virtual Machines).

In my Ubuntu machine, I am going to install some packages like kvm, qemu (Quick Emulator) and libvirtd-bin to work with CLI of KVM which is virsh (Virtualization Shell).

QEMU is opensource hosted hypervisor to achieve hardware virtualization, we use qemu so that we can create VMs with different CPU architecture. If we use KVM, we can create and manage VMs with the same architecture of CPU as host machine.

Let me explain you in detail with steps,

At first lets update our apt (Advanced Packaging Tool)....

root@ubuntu-kvm:~# apt-get update
Hit:1 http://us.archive.ubuntu.com/ubuntu yakkety InRelease
Get:2 http://us.archive.ubuntu.com/ubuntu yakkety-updates InRelease [102 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu yakkety-backports InRelease [102 kB]
Get:4 http://security.ubuntu.com/ubuntu yakkety-security InRelease [102 kB]
Fetched 306 kB in 3s (78.1 kB/s)
Reading package lists... Done
root@ubuntu-kvm:~#

Before installing, let us check for the packages which we are going to install now.

root@ubuntu-kvm:~# apt list --installed | grep -i libvirtd

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

root@ubuntu-kvm:~#
root@ubuntu-kvm:~# apt list --installed | grep -i virt-manager

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

root@ubuntu-kvm:~#
root@ubuntu-kvm:~# apt list --installed | grep -i qemu-kvm

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

root@ubuntu-kvm:~#

Now I will install qemu-kvm package which acts as hypervisor for managing our guest machines. Here I am giving normal kvm also, just to show one thing...

root@ubuntu-kvm:~# apt-get install kvm qemu-kvm
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'qemu-kvm' instead of 'kvm'
The following additional packages will be installed:
  cpu-checker ipxe-qemu libaio1 libasound2 libasound2-data libasyncns0 libbluetooth3 libboost-iostreams1.61.0

  ****************        OUTPUT TRUNCATED     ****************

Need to get 14.4 MB of archives.
After this operation, 56.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 libjpeg-turbo8 amd64 1.5.0-0ubuntu1 [113 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 libogg0 amd64 1.3.2-1 [17.2 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 libiscsi7 amd64 1.17.0-1 [55.6 kB]

****************        OUTPUT TRUNCATED     ****************

Fetched 14.4 MB in 3s (4,468 kB/s)
Extracting templates from packages: 100%
Selecting previously unselected package libjpeg-turbo8:amd64.
(Reading database ... 61611 files and directories currently installed.)
Preparing to unpack .../00-libjpeg-turbo8_1.5.0-0ubuntu1_amd64.deb ...
Unpacking libjpeg-turbo8:amd64 (1.5.0-0ubuntu1) ...

****************        OUTPUT TRUNCATED     ****************

Setting up libpulse0:amd64 (1:9.0-2ubuntu2.1) ...
Setting up libsdl1.2debian:amd64 (1.2.15+dfsg1-4) ...
Setting up qemu-system-x86 (1:2.6.1+dfsg-0ubuntu5.1) ...
Setting up qemu-kvm (1:2.6.1+dfsg-0ubuntu5.1) ...
Processing triggers for libc-bin (2.24-3ubuntu1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (231-9git1) ...                          DONE

root@ubuntu-kvm:~#

This time if we check for the package,

root@ubuntu-kvm:~# apt list --installed | grep -i qemu-kvm

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

qemu-kvm/yakkety-updates,yakkety-security,now 1:2.6.1+dfsg-0ubuntu5.1 amd64 [installed]
root@ubuntu-kvm:~#

As I explained above, so far whatever we did, is for enabling virtualization only. We still need some other packages for creating and managing VMs.

root@ubuntu-kvm:~# virsh list
The program 'virsh' is currently not installed. You can install it by typing:
apt install libvirt-clients
root@ubuntu-kvm:~#                              That is why we can't work with virt shell commands...

Now let us install packages related to libvirt-bin, entire binary package of libvirt and bridge-utils which is responsible for Ethernet bridging (VMs network connectivity).

root@ubuntu-kvm:~# apt-get install libvirt-bin bridge-utils
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:

  ****************        OUTPUT TRUNCATED     ****************

Need to get 4,952 kB of archives.
After this operation, 20.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 libavahi-common-data amd64 0.6.32-1ubuntu1 [22.0 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 libavahi-common3 amd64 0.6.32-1ubuntu1 [21.6 kB]

****************        OUTPUT TRUNCATED     ****************

Get:19 http://us.archive.ubuntu.com/ubuntu yakkety/main amd64 vbetool amd64 1.1-4 [11.5 kB]
Fetched 4,952 kB in 1s (2,813 kB/s)
Selecting previously unselected package libavahi-common-data:amd64.
(Reading database ... 62254 files and directories currently installed.)
Preparing to unpack .../00-libavahi-common-data_0.6.32-1ubuntu1_amd64.deb ...
Unpacking libavahi-common-data:amd64 (0.6.32-1ubuntu1) ...
****************        OUTPUT TRUNCATED     ****************

Setting up libvirt-daemon (2.1.0-1ubuntu9.1) ...
Setting up libvirt-clients (2.1.0-1ubuntu9.1) ...
Setting up libvirt-daemon-system (2.1.0-1ubuntu9.1) ...
Adding group `libvirt' (GID 118) ...
Done.
Adding user `libvirt-qemu' to group `libvirt-qemu' ...
Adding user libvirt-qemu to group libvirt-qemu
Done.
Created symlink /etc/systemd/system/multi-user.target.wants/libvirt-guests.service → /lib/systemd/system/libvirt-guests.service.

****************        OUTPUT TRUNCATED     ****************

Setting up libvirt-daemon dnsmasq configuration.
Setting up libvirt-bin (2.1.0-1ubuntu9.1) ...
Processing triggers for libc-bin (2.24-3ubuntu1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (231-9git1) ...
root@ubuntu-kvm:~#

Now we can check with "virsh" commands....

root@ubuntu-kvm:~# virsh list
 Id    Name                           State
----------------------------------------------------
root@ubuntu-kvm:~#

root@ubuntu-kvm:~# virsh -c qemu:///system list
 Id    Name                           State
----------------------------------------------------
root@ubuntu-kvm:~#

To work with GUI part of virtual machine management we need virt-manager.

root@ubuntu-kvm:~# virt-manager
The program 'virt-manager' is currently not installed. You can install it by typing:
apt install virt-manager

root@ubuntu-kvm:~#

So I am installing it now, if you need GUI you have to install it.

root@ubuntu-kvm:~# apt-get install virt-manager ubuntu-vm-builder
Reading package lists... Done                            
           ubuntu-vm-builder is different utility to create and manage virtual machines in ubuntu.
Building dependency tree
Reading state information... Done

The following additional packages will be installed:

****************        OUTPUT TRUNCATED     ****************

Setting up gir1.2-vte-2.91:amd64 (0.44.2-1ubuntu3) ...
Setting up indicator-application (12.10.1+15.04.20150128-0ubuntu1) ...
Setting up gir1.2-appindicator3-0.1 (12.10.1+16.10.20160905-0ubuntu1) ...
Setting up virt-manager (1:1.3.2-3ubuntu3) ...
Processing triggers for libc-bin (2.24-3ubuntu1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (231-9git1) ...

Processing triggers for libgdk-pixbuf2.0-0:amd64 (2.34.0-1ubuntu2) ...
root@ubuntu-kvm:~#

root@ubuntu-kvm:~# apt list --installed | grep -i virt-manager

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.


virt-manager/yakkety,yakkety,now 1:1.3.2-3ubuntu3 all [installed]
root@ubuntu-kvm:~#

root@ubuntu-kvm:~# apt list --installed | grep -i ubuntu-vm-builder

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

ubuntu-vm-builder/yakkety,yakkety,now 0.12.4+bzr494-0ubuntu1 all [installed]
root@ubuntu-kvm:~#

As of now, we installed required packages and ready for creating some VMs.

To create VMs from CLI, 

root@ubuntu-kvm:~# virt-install

WARNING  KVM acceleration not available, using 'qemu'
ERROR
--name is required
--memory amount in MiB is required
--disk storage must be specified (override with --disk none)
An install method must be specified
(--location URL, --cdrom CD/ISO, --pxe, --import, --boot hd|cdrom|...)

root@ubuntu-kvm:~#

To start working with GUI virt-manager, 



Then a window will be popped, by clicking on "Create a Virtual Machine" we can start creating VMs.


That's it for this post, we covered what packages need to be installed and how to enable virtualization in Linux machine. In the next post, I will discuss about how to create/manage VMs.

######################################################################################