Archive for March, 2016

virt-manager error

While trying to create a VM in virt-manager, I got a “bind socket” permission denied error. This happens whether CentOS or Ubuntu is used as the VM guest.

Error as follows:

Unable to complete install: ‘internal error: process exited while connecting to monitor: 2016-03-19T04:58:53.268413Z qemu-system-x86_64: -chardev socket,id=charchannel0,path=/var/lib/libvirt/qemu/channel/target/domain-centos7.0/org.qemu.guest_agent.0,server,nowait: Failed to bind socket to /var/lib/libvirt/qemu/channel/target/domain-centos7.0/org.qemu.guest_agent.0: Permission denied’
Traceback (most recent call last):
File “/usr/share/virt-manager/virtManager/asyncjob.py”, line 90, in cb_wrapper
callback(asyncjob, *args, **kwargs)
File “/usr/share/virt-manager/virtManager/create.py”, line 2277, in _do_async_install
guest.start_install(meter=meter)
File “/usr/share/virt-manager/virtinst/guest.py”, line 501, in start_install
noboot)
File “/usr/share/virt-manager/virtinst/guest.py”, line 416, in _create_guest
dom = self.conn.createLinux(start_xml or final_xml, 0)
File “/usr/lib/python2.7/dist-packages/libvirt.py”, line 3606, in createLinux
if ret is None:raise libvirtError(‘virDomainCreateLinux() failed’, conn=self)
libvirtError: internal error: process exited while connecting to monitor: 2016-03-19T04:58:53.268413Z qemu-system-x86_64: -chardev socket,id=charchannel0,path=/var/lib/libvirt/qemu/channel/target/domain-centos7.0/org.qemu.guest_agent.0,server,nowait: Failed to bind socket to /var/lib/libvirt/qemu/channel/target/domain-centos7.0/org.qemu.guest_agent.0: Permission denied

Causes of error:

The error arise from “channel qemu-ga” virtual hardware not emulated correctedly.

Workaround Steps:

a. Create new VM -> select ISO images.

b. Use ISO images -> select ISO file.

c. Set memory / CPU.

d. Set disk image size.

e. Set filename of image, and then now select “custom configuration before install”.

f. Inside the custom configuration screen, you see “Channel qemu-ga” as the hardware. Remove this hardware.

g. After removable, everything now works.

XFS: how to extend the filesystem size when full?

Scenario: My CentOS7 is running inside QEMU.

Looking at my CentOS7 filesystem using "df":

You can see the /home is near 100%. How to extend it?

Luckily, the default filesystem in CentOS7 is XFS:

Just do a "sudo blkid /dev/mapper/centos-home" and you can see that it is "XFS".

To extend it I need to do a few things:

a. Add new disk. SInce the OS is running inside QEMU, just do:

qemu-img create -f qcow2 centos7_hdd2.img 80G

to create a new "harddisk" named as centos7_hdd2.img. If you are not using QEMU, then it is equivalent to shutting down system and putting a new harddisk instead.

b. Reboot CentOS7. If you are using QEMU, then remember to include the new harddisk image when you start your CentOS7 guest, for example part of it shown below:

qemu-system-x86_64 -hda centos7_hdd.img -hdb centos7_hdd2.img …

c. Now the new harddisk is recognized as /dev/sdb. Create a new partition table using "fdisk /dev/sdb" and add a new partition called /dev/sdb1.

Now XFS is using LVM concept: There is PV: which house all the harddisk. Now we will have two PV – /dev/sda and /dev/sdb. From the PV, you create VG: nothing to add as we are reusing an existing VG. From VG, you create LV: nothing to add, but the LV size need to be extended. So here it goes:

d. Add the new partition to PV:

sudo pvcreate /dev/sdb1

And check:

sudo pvdisplay

e. Extend the existing VG with the new PV:

sudo vgextend centos /dev/sdb1

And check:

sudo vgdisplay

f. Now extend the size of the LV:

sudo lvextend -L80G /dev/centos/home

And check:

sudo lvdisplay

g. Finally extend the filesystem (XFS) on the LV:

sudo xfs_growfs /home

And check:

sudo df

And now the diskspace utilization is 35%. Cool.

https://ma.ttias.be/increase-expand-xfs-filesystem-in-red-hat-rhel-7-cento7/

http://serverfault.com/questions/610973/how-to-increase-the-size-of-an-xfs-file-system

http://linoxide.com/file-system/create-mount-extend-xfs-filesystem/

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/xfsgrow.html

https://www.centos.org/docs/5/html/Cluster_Logical_Volume_Manager/VG_grow.html

http://www.microhowto.info/howto/increase_the_size_of_an_lvm_logical_volume.html

https://www.centos.org/docs/5/html/Cluster_Logical_Volume_Manager/lv_extend.html

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

 

Vickblöm

Research scattered with thoughts, ideas, and dreams

Penetration Testing Lab

Offensive Techniques & Methodologies

Astr0baby's not so random thoughts _____ rand() % 100;

@astr0baby on Twitter for fresh randomness

The Data Explorer

playing around with open data to learn some cool stuff about data analysis and the world

Conorsblog

Data | ML | NLP | Python | R

quyv

Just a thought

IFT6266 - H2017 Deep Learning

A Graduate Course Offered at Université de Montréal

Deep Learning IFT6266-H2017 UdeM

Philippe Paradis - My solutions to the image inpainting problem

IFT6266 – H2017 DEEP LEARNING

Pulkit's thoughts on the course project

Thomas Dinsmore's Blog

No man but a blockhead ever wrote except for money -- Samuel Johnson

the morning paper

a random walk through Computer Science research, by Adrian Colyer

The Spectator

Shakir's Machine Learning Blog