EzDevInfo.com

kvm interview questions

Top kvm frequently asked interview questions

KVM is not installed on this machine (/dev/kvm is missing)

I'm using Ubuntu 14.04. I recently installed Android Studio, but whenever I try to run a Hello World app, I get this error:

/home/praveen/Android/Sdk/tools/emulator -avd Nexus_6_API_21 -netspeed full -netdelay none
emulator: ERROR: x86 emulation currently requires hardware acceleration!
Please ensure KVM is properly installed and usable.
CPU acceleration status: KVM is not installed on this machine (/dev/kvm is missing).

Source: (StackOverflow)

What is the virbr0 interface used for?

      virbr0    Link encap:Ethernet  HWaddr a2:17:ea:e3:47:7e  
      inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
      UP BROADCAST MULTICAST  MTU:1500  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

can anyone tell me what this interface does and how I can change the IP address? I want to see if it is the reason my guests cannot connect.


Source: (StackOverflow)

Advertisements

KVM Bridged Network Not Working

I just installed KVM on my Ubuntu Server according to this guide : https://help.ubuntu.com/community/KVM/Installation

Then prepared a bridged network as shown in here : https://help.ubuntu.com/community/KVM/Networking

Then, I created a virtual machine with virt-manager. I tried several times but the guest fails to connect to the network! Any help?

ifconfig :

      br0       Link encap:Ethernet  HWaddr d0:27:88:b0:e4:38  
                inet addr:192.168.20.100  Bcast:192.168.20.255  Mask:255.255.255.0
                inet6 addr: fe80::d227:88ff:feb0:e438/64 Scope:Link
                UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
                RX packets:62 errors:0 dropped:0 overruns:0 frame:0
                TX packets:62 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:0 
                RX bytes:10493 (10.4 KB)  TX bytes:8433 (8.4 KB)

      eth0      Link encap:Ethernet  HWaddr d0:27:88:b0:e4:38  
                UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
                RX packets:62 errors:0 dropped:0 overruns:0 frame:0
                TX packets:63 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:1000 
                RX bytes:11361 (11.3 KB)  TX bytes:8479 (8.4 KB)
                Interrupt:41 

      lo        Link encap:Local Loopback  
                inet addr:127.0.0.1  Mask:255.0.0.0
                inet6 addr: ::1/128 Scope:Host
                UP LOOPBACK RUNNING  MTU:16436  Metric:1
                RX packets:0 errors:0 dropped:0 overruns:0 frame:0
                TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:0 
                RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

      virbr0    Link encap:Ethernet  HWaddr 5a:8c:57:95:af:3b  
                inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
                UP BROADCAST MULTICAST  MTU:1500  Metric:1
                RX packets:0 errors:0 dropped:0 overruns:0 frame:0
                TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:0 
                RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

brctl show :

 bridge name    bridge id      STP enabled    interfaces
 br0       8000.d02788b0e438   no        eth0
 virbr0         8000.000000000000   yes  

brctl showmacs br0 :

 port no   mac addr       is local? ageing timer
   1  5c:d9:98:67:b6:28   no          48.33
   1  d0:27:88:b0:e4:38   yes          0.00
   1  e0:2a:82:f9:6c:09   no           0.00

ip route :

 default via 192.168.20.1 dev br0  metric 100 
 192.168.20.0/24 dev br0  proto kernel  scope link  src 192.168.20.100 
 192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1

*In the guest * I was unable to copy paste the info from the guest because can't ssh to it. It didn't get any ip from DHCP. Won't work even after setting it up manually.


Source: (StackOverflow)

How to resize / enlarge / grow a non-LVM ext4 partition

I have already searched the forums, but couldnt find a good suitable answer:

I have an Ubuntu Server 10.04 as KVM Host and a guest system, that also runs 10.04. The host system uses LVM and there are three logical volumes, which are provided to the guest as virtual block devices - one for /, one for /home and one for swap. The guest had been partitioned without LVM.

I have already enlarged the logical volume in the host system - the guest successfully sees the bigger virtual disk. However, this virtual disk contains one "good old" partition, which still has the old small size.

The output of fdisk -l is

me@produktion:/$ LC_ALL=en_US sudo fdisk -l

Disk /dev/vda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c8ce7

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1        3917    31455232   83  Linux

Disk /dev/vdb: 2147 MB, 2147483648 bytes
244 heads, 47 sectors/track, 365 cylinders
Units = cylinders of 11468 * 512 = 5871616 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000f2bf7

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1               1         366     2095104   82  Linux swap / Solaris
Partition 1 has different physical/logical beginnings (non-Linux?):
     phys=(0, 32, 33) logical=(0, 43, 28)
Partition 1 has different physical/logical endings:
     phys=(260, 243, 47) logical=(365, 136, 44)

Disk /dev/vdc: 225.5 GB, 225485783040 bytes
255 heads, 63 sectors/track, 27413 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00027f25

   Device Boot      Start         End      Blocks   Id  System
/dev/vdc1               1        9138    73398272   83  Linux

The output of parted print all is

Model: Virtio Block Device (virtblk)
Disk /dev/vda: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  32.2GB  32.2GB  primary  ext4         boot


Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  2146MB  2145MB  primary  linux-swap(v1)


Model: Virtio Block Device (virtblk)
Disk /dev/vdc: 225GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  75.2GB  75.2GB  primary  ext4

What I want to achieve is to simply grow or resize the partition /dev/vdc1 so that it uses the whole space provided by the virtual block device /dev/vdc. The problem is, that when I try to do that with parted, it complains:

(parted) select /dev/vdc                                                  
Using /dev/vdc
(parted) print                                                            
Model: Virtio Block Device (virtblk)
Disk /dev/vdc: 225GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  75.2GB  75.2GB  primary  ext4

(parted) resize 1                                                         
WARNING: you are attempting to use parted to operate on (resize) a file system.
parted's file system manipulation code is not as robust as what you'll find in
dedicated, file-system-specific packages like e2fsprogs.  We recommend
you use parted only to manipulate partition tables, whenever possible.
Support for performing most operations on most types of file systems
will be removed in an upcoming release.
Start?  [1049kB]?                                                         
End?  [75.2GB]? 224GB                                                     
Error: File system has an incompatible feature enabled.  Compatible features are has_journal, dir_index, filetype, sparse_super and large_file.  Use tune2fs
or debugfs to remove features.

So what can I do? This is a headless production system. What is a safe way to grow this partition? I CAN unmount it, though - so this is not the problem.

Edit: Cfdisk showed a small free space unpartitioned space, then the partition (flagged as "boot" and Linux/ext3) and then the rest of the unpartitioned space. After deleting the partition and creating it again using cfdisk - cfdisk shows one big partitioned area (which would be fine with me) and as filesystem type only "Linux"

Resize2fs returns this error resize2fs 1.41.11 (14-Mar-2010) resize2fs: Bad magic number in super-block while trying to open /dev/vdc1 Couldn't find valid filesystem superblock


Source: (StackOverflow)

How do I use "virsh shutdown" on KVM domains to shut down Ubuntu guests?

I am using various KVM domains on a Ubuntu server. Both the host and guests run 10.04.1, 2.6.32-24 kernel, virsh reports version 0.7.5, KVM 0.12.3. The guests boot automatically when the host boots and they have <features><acpi/><features> in their configuration.

I could never manage to make virsh shutdown MyDomain on the host to have any effect. It responds with Domain MyDomain is being shutdown and the domain keeps happily running. virsh list still lists them in the state running.

virsh destroy MyDomain works fine, but of course that's not really what I want, so most of the time I log into each one and shut them down manually, which is pretty annoying.

I couldn't really find any information on how virsh shutdown tries to shut the domain down. Pointers to useful bits of documentation are welcome.

What could cause this? How is it supposed to work?


Source: (StackOverflow)

How to share a folder between KVM host and guest using virt-manager?

For some time now, I've been using virt-manager to manage my virtual machines. When I want to copy a file from the host to the vm, I have been using scp to copy via ssh over the network. This is kind of tedious, and there must be a way to share a folder similar to VirtualBox. So how can I best share a folder between a KVM host and guest using virt-manager?


Source: (StackOverflow)

How do I disable unwanted iPXE boot attempt in Libvirt/qemu-kvm?

Somehow after upgrading to 12.04, my virtual machines always boot with an attempt to boot from the network first. See this:

virt-manager screenshot

while I don't have any PXE configuration set:

PXE boot configuration

I've tried:

  • to disable SPICE, by changing the emulator to /usr/bin/kvm from /usr/bin/kvm-spice by editing the XML.
  • Ctrl+B to configure the iPXE, but it doesn't let disable this as a boot option.
  • setting another type of NIC - not an option, I need virtio for performance reasons. However, e1000e doesn't work either.
  • removing the NIC: works. However, I need network.
  • Googling around. Hard. Lots of result is about failing configured PXE boots.

Not a big issue, but it increases boot times by 50-100% here (booting from SSD), so it's relatively long and annoys me.

How can I disable this and boot from virtual hard disk directly?


Source: (StackOverflow)

How can KVM be located by Android Studio on Ubuntu 14.04 LTS

When running the emulator, Android Studio reports the following message:

Please ensure KVM is properly installed and usable.

CPU acceleration status: KVM is not installed on this machine (/dev/kvm is missing)

However, KVM is installed as shown by the following:

which kvm

/usr/bin/kvm

Thanks...


Source: (StackOverflow)

virt-manager can't connect to libvirt

enter image description here

I'm running Ubuntu 12.04.2 32 bits.

The error doesn't show up if I start gksudo virt-manager.

  • libvirt-bin is installed.
  • I don't know how to check for the daemon.
  • I am a member of libvirtd.

Output of ps ax | grep libvirt:

9225 ? Sl 0:04 /usr/sbin/libvirtd -d
9302 ? S 0:00 /usr/sbin/dnsmasq -u libvirt-dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/default.pid --conf-file= --except-interface lo --listen-address 192.168.122.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases --dhcp-lease-max=253 --dhcp-no-override`

Output of ls -l /var/run/libvirt/libvirt-sock:

srwxrwx--- 1 root libvirtd 0 Set 13 15:04 /var/run/libvirt/libvirt-sock

Output of getent group libvirtd:

libvirtd:x:130:OTHERUSER,MYUSER

Detailed error message

Impossível conectar a libvirt:

Falha ao conectar socket a '/var/run/libvirt/libvirt-sock': Permissão negada

Verify that:
 - The 'libvirt-bin' package is installed
 - The 'libvirtd' daemon has been started
 - You are member of the 'libvirtd' group

A URI Libvirt é: qemu:///system

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/connection.py", line 1185, in _open_thread
    self.vmm = self._try_open()
  File "/usr/share/virt-manager/virtManager/connection.py", line 1167, in _try_open
    flags)
  File "/usr/lib/python2.7/dist-packages/libvirt.py", line 102, in openAuth
    if ret is None:raise libvirtError('virConnectOpenAuth() failed')
libvirtError: Falha ao conectar socket a '/var/run/libvirt/libvirt-sock': Permissão negada

Source: (StackOverflow)

How do I configure spice with KVM?

I'm running Ubuntu 12.10 and I have installed KVM. Trying to install / configure spice but not having any luck finding sources that work. Has anyone done this yet?


Source: (StackOverflow)

It is possible to create two graphic terminals in one computer?

I have a computer with two screens, and I want to share it with my daugther. If I attach two mice and two keyboard, can the computer be configured so each screen is like an independent computer?

I have a couple of ideas about how to solve this:

  1. Use kvm to virtualize the machine, install two OSes and bind each one to a screen, keyboard and mouse (I don't know if this is possible)
  2. A standard Lubuntu (or *Ubuntu) installation, and setup with 2 X servers, one on each screen.

Has anyone build something like this? Do you know any tutorial about how to do this?


Source: (StackOverflow)

Why do we need an IP address for a bridge?

A bridge is a layer 2 network device. On physical bridges we only have an IP address for operation and maintenance. I'm a little bit confused why we need in KVM an IP address for the bridge. I understand that the VM's interface get's an IP address and that the physical interface attached to the bridge has no IP address. This ensures that the VM's Ip address is visible to the outside. In an server environment, I would only use static IP addressing for the VM's.

Let's assume, I use static IP addressing for the VM's, than why do I need an IP address on the bridge?


Source: (StackOverflow)

Is my VM using KVM or QEMU?

After installing Ubuntu 11.10 and copying my KVM images which were created on Ubuntu 11.04 over to the new system, I notice that Virt-manager says it's using QEMU and not KVM. Also when running virsh version it says Running hypervisor: QEMU 0.14.1.

However, when I run kvm-ok it says INFO: /dev/kvm exists and KVM acceleration can be used. Also, the XML file of my VM clearly states it should use KVM: <domain type='kvm'> <emulator>/usr/bin/kvm</emulator>.

Furthermore, lsmod |grep kvm shows the following (when the VM is running):

kvm_intel              61643  3
kvm                   383822  1 kvm_intel

So how do I know if KVM or QEMU is being used? And why am I getting such contradictory output of these different commands?


Source: (StackOverflow)

How do I manually boot from the grub prompt after do-release-upgrade?

I read a couple of other questions on this topic and they both pointed to the Grub2 community documentation and installing grub configs from an install disk. I had some trouble with the documentation, so here's where I am. This may be complete PEBKAC.

I have two guests sitting on an Ubuntu 10.04 server virtualized under KVM, both were initially running 10.04. I used "do-release-upgrade" to update to 10.10 without a hitch on both boxes, rebooted, and then ran "do-release-upgrade" to update to 11.04 on both boxes. In my haste, I ignored the errors about missing grub configurations. When I restarted the guests, naturally I'm presented with a grub prompt. Issuing "boot" yields "error: no loaded kernel".

Here's ls output for the root partition:

grub prompt ls output

When following the manual boot guide, I can't get the options straight either using "SS928-root" or "hda0,1" as the root filesystem. Most everything gives the "file not found" error.

Issuing "ls" on both of those filesystems show several options for vmlinuz and initrd.img. These guests are using LVM if that helps any.

EDIT

I've gotten a little bit further. The following command sequence:

semi-successful boot

Yields the following screen (after scrolling through quite a bit of text):

BusyBox Shell


Source: (StackOverflow)

How do I set up a KVM/NVidia Passthrough virtual machine for gaming?

I've seen a guide or two that seems to be replicated around on the internet on setting up KVM to use passthrough for Nvidia. It seems to require 2 video cards.

Is it possible to do it with 1 video card? I'm trying to see if it's possible to have a gaming machine setup so I don't have to dual boot.

Is this possible? I've heard Xen has a passthrough of their own, but Nvidia doesn't seem to support it on their desktop cards.

I have a GTX 760.

Is it possible to virtualize and get native or near-native performance good enough for modern game gaming?


Source: (StackOverflow)