Setting up virtual machine via virsh/virt-manager/virt-viewer

My requirementsfor the setup: Setup VM client with VMX and VT-d

As compared with an earlier article which focus entirely on virsh, and virt-viewer command, now here the focus is on virt-manager:

https://tthtlc.wordpress.com/2016/02/03/how-to-setup-virsh-or-libvirt-or-virtio-in-a-custom-kernel/

The tool virt-manager is a complex and sophisticated tool to generate the command line for QEMU, using libvirtd:

From https://virt-manager.org/
virt-manager-vm-list.png

Someone had said on the web, normally command line is the preferred mechanism to work in Linux, as it facilitate automation easily. But ease of use provided by virt-manager, vs the complex XML which it can generate to create the VM guest, really justify its use.

The relationship between libvirtd, QEMU, and virt-manager or virt-viewer are as follows:

From http://www.ibm.com/developerworks/cloud/library/cl-managingvms/:

figure2.jpg

Environment:

Ubuntu 16.04 Xenial (64-bit):

http://askubuntu.com/questions/103965/how-to-determine-if-cpu-vt-extensions-enabled-in-bios

http://serverfault.com/questions/633183/how-do-i-enable-kvm-device-passthrough-in-linux

https://www.centos.org/forums/viewtopic.php?f=47&t=48115 (note that the basic problem of achieving VT-d is not solved in that thread, as the hardware is not capable of VT-d).

For a list of hardware that support VT-d (+VMX):

http://www.intel.com/content/www/us/en/support/boards-and-kits/desktop-boards/000005758.html

First edit “sudo vi /etc/default/grub” and change the line:

GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”

to:

GRUB_CMDLINE_LINUX_DEFAULT=”intel_iommu=on”

Do a sudo update-grub, and reboot.

Next install the following (in addition to existng packages which you have installed in the past):

apt-get update

apt-get install openssh-server

apt-get install virt-manager virt-viewer lsscsi

apt-get install qemu-system-x86

apt-get install libvirt-dev

apt-get install ssh-askpass

apt-get install kvm

Edit the file /etc/ssh/sshd_config and ensure the following:

PermitRootLogin yes
StrictModes yes

The “sudo service ssh restart” to restart the ssh server, and so now you can login as root into localhost.

Next, enter “sudo virt-manager” and then “File->Create new connection”:

Add a localhost connection as root, which will be prompted for password later (which is why we need to permit rootlogin locally).

The following are the commands to directly interact with libvirtd, which can be equally done by virt-manager’s GUI interface:

=======================================================

sudo virsh sysinfo

# other command are
#virsh -c qemu+ssh://bozz@SERVER/system sysinfo
#virsh -c qemu+ssh://tteikhua@localhost/system sysinfo
#virsh -c qemu+ssh://tteikhua@localhost sysinfo
#virsh -c qemu+ssh://user@localhost/system sysinfosudo virsh pool-list

sudo virsh net-list –all

sudo virsh net-start default

sudo virsh list

sudo virsh destroy myguest_domain

### the following command will create the VM guest from the XML file “myguest_domain.xml” which have been saved beforehand.
sudo virsh define myguest_domain.xml

# after creating the domain, you have to start it to get it booted up.

sudo virsh start myguest_domain

sudo virt-host-validate

============================================================

The following is the output of sysinfo:
<sysinfo type='smbios'>
  <bios>
    <entry name='vendor'>American Megatrends Inc.</entry>
    <entry name='version'>G56JK.201</entry>
    <entry name='date'>05/13/2014</entry>
    <entry name='release'>4.6</entry>
  </bios>
  <system>
    <entry name='manufacturer'>ASUSTeK COMPUTER INC.</entry>
    <entry name='product'>G56JK</entry>
    <entry name='version'>1.0       </entry>
    <entry name='serial'>EBN0BC00467945B     </entry>
    <entry name='uuid'>837152F2-5681-444E-92DB-54A05089F05E</entry>
    <entry name='sku'>ASUS-NotebookSKU</entry>
    <entry name='family'>G</entry>
  </system>
  <baseBoard>
    <entry name='manufacturer'>ASUSTeK COMPUTER INC.</entry>
    <entry name='product'>G56JK</entry>
    <entry name='version'>1.0       </entry>
    <entry name='serial'>BSN12345678901234567</entry>
    <entry name='asset'>ATN12345678901234567</entry>
    <entry name='location'>MIDDLE              </entry>
  </baseBoard>
  <processor>
    <entry name='socket_destination'>SOCKET 0</entry>
    <entry name='type'>Central Processor</entry>
    <entry name='family'>Core i7</entry>
    <entry name='manufacturer'>Intel</entry>
    <entry name='signature'>Type 0, Family 6, Model 60, Stepping 3</entry>
    <entry name='version'>Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz</entry>
    <entry name='external_clock'>100 MHz</entry>
    <entry name='max_speed'>3800 MHz</entry>
    <entry name='status'>Populated, Enabled</entry>
    <entry name='serial_number'>Not Specified</entry>
    <entry name='part_number'>Fill By OEM</entry>
  </processor>
  <memory_device>
    <entry name='size'>8192 MB</entry>
    <entry name='form_factor'>SODIMM</entry>
    <entry name='locator'>ChannelB-DIMM0</entry>
    <entry name='bank_locator'>BANK 2</entry>
    <entry name='type'>DDR3</entry>
    <entry name='type_detail'>Synchronous</entry>
    <entry name='speed'>1600 MHz</entry>
    <entry name='manufacturer'>Samsung</entry>
    <entry name='serial_number'>E187DCC9</entry>
    <entry name='part_number'>M471B1G73DB0-YK0</entry>
  </memory_device>
</sysinfo>
And the following is the output of validate-host:
Domain myguest_domain started

  QEMU: Checking for hardware virtualization                                 : PASS
  QEMU: Checking if device /dev/kvm exists                                   : PASS
  QEMU: Checking if device /dev/kvm is accessible                            : PASS
  QEMU: Checking if device /dev/vhost-net exists                             : PASS
  QEMU: Checking if device /dev/net/tun exists                               : PASS
  QEMU: Checking for cgroup 'memory' controller support                      : PASS
  QEMU: Checking for cgroup 'memory' controller mount-point                  : PASS
  QEMU: Checking for cgroup 'cpu' controller support                         : PASS
  QEMU: Checking for cgroup 'cpu' controller mount-point                     : PASS
  QEMU: Checking for cgroup 'cpuacct' controller support                     : PASS
  QEMU: Checking for cgroup 'cpuacct' controller mount-point                 : PASS
  QEMU: Checking for cgroup 'devices' controller support                     : PASS
  QEMU: Checking for cgroup 'devices' controller mount-point                 : PASS
  QEMU: Checking for cgroup 'net_cls' controller support                     : PASS
  QEMU: Checking for cgroup 'net_cls' controller mount-point                 : PASS
  QEMU: Checking for cgroup 'blkio' controller support                       : PASS
  QEMU: Checking for cgroup 'blkio' controller mount-point                   : PASS
  QEMU: Checking for device assignment IOMMU support                         : PASS
  QEMU: Checking if IOMMU is enabled by kernel                               : PASS
   LXC: Checking for Linux >= 2.6.26                                         : PASS
   LXC: Checking for namespace ipc                                           : PASS
   LXC: Checking for namespace mnt                                           : PASS
   LXC: Checking for namespace pid                                           : PASS
   LXC: Checking for namespace uts                                           : PASS
   LXC: Checking for namespace net                                           : PASS
   LXC: Checking for namespace user                                          : PASS
   LXC: Checking for cgroup 'memory' controller support                      : PASS
   LXC: Checking for cgroup 'memory' controller mount-point                  : PASS
   LXC: Checking for cgroup 'cpu' controller support                         : PASS
   LXC: Checking for cgroup 'cpu' controller mount-point                     : PASS
   LXC: Checking for cgroup 'cpuacct' controller support                     : PASS
   LXC: Checking for cgroup 'cpuacct' controller mount-point                 : PASS
   LXC: Checking for cgroup 'devices' controller support                     : PASS
   LXC: Checking for cgroup 'devices' controller mount-point                 : PASS
   LXC: Checking for cgroup 'net_cls' controller support                     : PASS
   LXC: Checking for cgroup 'net_cls' controller mount-point                 : PASS
   LXC: Checking for cgroup 'freezer' controller support                     : PASS
   LXC: Checking for cgroup 'freezer' controller mount-point                 : PASS

 

Advertisements

One response to this post.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: