LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   What are the benefits for running kvm instead of virtualbox (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/what-are-the-benefits-for-running-kvm-instead-of-virtualbox-4175543685/)

Pearlseattle 05-30-2015 12:18 PM

Quote:

Originally Posted by dyasny (Post 5369632)
This isn't PCI passthrough, this is GPU passthrough, and it's quite simple with vfio. Regular PCI passthrough is even simpler, no rocket science there

Interesting, thank you!
Found here an overview.

EDDY1 05-30-2015 03:08 PM

Sorry for not replying to any of the posts here I'm actually just reading documentation on installing kvm.
I've been trying to figure out the networking portion of kvm, as I'm on a wireless network so I have to set my system to allow network to pass thru my wireless card.
I haven't attempted it yet, but will be trying it when time permits.

mralk3 05-30-2015 04:43 PM

Quote:

Originally Posted by EDDY1 (Post 5369932)
Sorry for not replying to any of the posts here I'm actually just reading documentation on installing kvm.
I've been trying to figure out the networking portion of kvm, as I'm on a wireless network so I have to set my system to allow network to pass thru my wireless card.
I haven't attempted it yet, but will be trying it when time permits.

You have to create a tap device for each VM and set up an arp proxy. Then you can work around the wifi issue with KVM. Otherwise your arp packets will be lost between the VM and the router. Resulting in all traffic for your virtual machines being routed incorrectly on your network.

I haven't used this for a while but, these are some notes I took the last time I set up KVM on my laptop using wifi:

Code:

Create a vm image that is sized up to 10GB of space

  qemu-img create Debian_Wheezy.img -f qcow2 10G

Install an ISO Image to the img using a 750mb swap

  qemu-kvm -m 750 -cdrom ../ISO/Debian_Wheezy/debian-7.7.0-amd64-CD-1.iso -boot d Debian_Wheezy.img

--Or with a tap device

  qemu-kvm -m 750 -cdrom ../ISO/Debian_Wheezy/debian-7.7.0-amd64-CD-1.iso -boot d Debian_Wheezy.img  -net nic -net tap,ifname=tap0,script=no

Boot an image

  sudo qemu-kvm -m 2048 Debian_Wheezy.img

Boot an image with a tap device

  sudo kvm -net nic -net tap,ifname=tap0,script=no -m 2048 Debian_Wheezy.img

Here is a very basic script I used to manage the tap device:

Code:

#!/bin/sh

tunctl -u mralk3
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/wlan0/proxy_arp
echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp

ip link set tap0 up

route add -host 192.168.x.x dev tap0

It worked like a charm. I didn't explore any way to automate this. I suppose it would make sense to pass the user, interfaces, and ip address to the script as arguments.

Someone please correct me if this is incorrect, it has been a while since I used those notes or the script.

EDIT:
I believe you also need to set the IP address of the VM to a static address.

EDIT2:
I have tested this on Debian and Slackware, it works.

EDDY1 05-30-2015 11:45 PM

@mralk3 when I try to setup vm it sys there's no network so I must setup networking first(I believe).

mralk3 05-31-2015 07:49 AM

Quote:

Originally Posted by EDDY1 (Post 5370082)
@mralk3 when I try to setup vm it sys there's no network so I must setup networking first(I believe).

Yes, #1 you need your wifi card on the host connected to your access point. #2 you create the tap0 device. #3 You create the virtual machine, #4 you boot the virtual machine with the tap0 device connected, #5 you set the static ip that is the static route you added for the tap0 device on the host, in the virtual machine.

Keep in mind that if the static ip you use as the host route is 192.168.1.240, then that is the ip address used in the virtual machine. In the virtual machine, you then set the netmask to 255.255.255.0, broadcast address to 192.168.1.255 and default gateway to 192.168.1.1 or 192.168.1.254. (depending on how your network is set up)

The default gateway is your router. You can set the nameservers to be the same as your router if it has DNS services, to Google DNS services, or what I like to do: install DNSMASQ on the host machine and point all virtual machines to the host for DNS look ups.

EDDY1 06-01-2015 11:32 AM

I have successfully installed kvm & configured it tu use my wifi card, theonly thing is now when I boot machine it no longer connects to wireless automatically.
It doesn't show my AP in list of available networks & to connect to it I had to go into networks & select the hidden network.
Also where is the default location for vm's, because when I was creating virtual drive it prompted me that the target only had 1.3G available. I changed the location to /home/user/vm but it took 2 tries for it to allow me to do it.

mralk3 06-01-2015 12:44 PM

Quote:

Originally Posted by EDDY1 (Post 5370604)
I have successfully installed kvm & configured it tu use my wifi card, theonly thing is now when I boot machine it no longer connects to wireless automatically.
It doesn't show my AP in list of available networks & to connect to it I had to go into networks & select the hidden network.
Also where is the default location for vm's, because when I was creating virtual drive it prompted me that the target only had 1.3G available. I changed the location to /home/user/vm but it took 2 tries for it to allow me to do it.

I am assuming you are running Debian.

If you are using NetworkManager you will need to adjust your settings so that your wifi card connects automatically. NetworkManager might be confused about what network card to use as default with the new virtual interfaces created by KVM. Additionally, I found NetworkManager to be buggy with my wifi card and was forced to use the NetworkManager CLI to configure wifi. The command for that is nmcli, which as it turns out, is much faster to use than the nm-applet gui to configure any interface using NetworkManager.

I believe the default location that Debian uses to store KVM images is: /var/lib/libvirt/images/

You can find more information at the following links, should get you started on the right path.
  1. https://wiki.debian.org/KVM
  2. https://wiki.debian.org/DebianKVMGuests

EDDY1 06-01-2015 12:56 PM

Then I need to adjust the size of /var.
After I get my network settinngs right.

Ihatewindows522 06-02-2015 01:52 PM

Quote:

Originally Posted by Pearlseattle (Post 5369526)
Let's not forget that VirtualBox is an Oracle product - the Oracle corporation could decide anytime to stop support/development of VirtualBox and at that point you would have to hope that somebody forks it in some intelligent way, or otherwise you would have to re-implement everything.

And KVM is owned by Oracle's chief competitor.
https://www.redhat.com/promo/qumranet/

Red Hat could just as easily stop supporting KVM. Your point is moot.

dyasny 06-02-2015 02:17 PM

Quote:

Originally Posted by Ihatewindows522 (Post 5371115)
And KVM is owned by Oracle's chief competitor.
https://www.redhat.com/promo/qumranet/

Red Hat could just as easily stop supporting KVM. Your point is moot.

If you had any idea about how these things work, you'd not be saying stupid things like these. 80% of cloud deployments are using KVM, vendors such as H, IBM, Intel, Canonical and lots of others are heavily invested in KVM. Red Hat is a driving force indeed, but even if hell freezes over and they abandon KVM, there's lots of folks out there to keep it going.

EDDY1 06-02-2015 02:29 PM

Well the network returned to normal, so, now I have to adjust the size of my /var, so I can install vm's to default location.
I guess that is definitely a benefit over vbox since the vm's should be accessible to all users instead of just the 1 that created the vm.

Pearlseattle 06-02-2015 04:02 PM

Quote:

Originally Posted by Ihatewindows522 (Post 5371115)
And KVM is owned by Oracle's chief competitor.
https://www.redhat.com/promo/qumranet/

Qumranet/RH is definitely not "Oracle's chief competitor" - you should rather target SAP.

Quote:

Red Hat could just as easily stop supporting KVM.
Yeah, any company or group of hackers could stop anyday working on anything.
For this particular sector I have the feeling that the likeliness of Oracle dropping VB would be definitely higher than RH dropping KVM.
Reason: virtualization doesn't belong to the core activities of Oracle, while it is kind-of-core for RH.

Samsonite2010 06-02-2015 04:43 PM

While the speculation is amusing, I do not think it is useful - you can back your own horse of course. Virtualbox is big - a huge user base. It has a robust desktop application for Linux, Mac and Windows, supports pretty much all VM file types and converts between them so you cannot really lose even if it was stopped. I do not think people realise how widely-used it is in the real world. I work in this industry, so I like to think I have a good idea.

PS I have no affiliation with VB or Oracle, in fact my company officially uses VMWare and pays for that, but I will still recommend VB to anyone who is starting out with VMs and I used it on all 3 platforms - the experience was good on all.

gradinaruvasile 06-03-2015 04:34 AM

On the topic itself:
The KVM userspace is absorbed fully by QEMU.
http://wiki.qemu.org/KVM

Some points worth considering:

- KVM is already built in the kernel and standard distros include just abput everything you need. VirtualBox needs to "stick itself in" meaning some kernel modules are built during installation. If you use a newer kernel that has some relevant ABIs changed there are chances that they will not compile (depends on upstream developers) - this happened to me when i started using kernels built from git.
- KVM requires hardware virtualization extension on the CPU (intel VT-x or AMD-V / vmx or svm processor flags under Linux). Virtually all CPUs have these features nowadays.
- if you have IOMMU extensions on the chipset+cpu (intel VT-d or AMD-Vi) you can use hardware PCI passthrough (probably all PCI devices including video cards, only that video card passthrough can be tricky).
- You can use even full block devices (including physical HDDs - tested myself) for storage.
- KVM too has USB device passthrough.
- If the guest is running linux, you can use file system passthrough via 9p. Although not available for Windows guests.
- KVM can be used in conjunction with libvirt: and can be managed by the graphical virt-manager utility, both are in the repos of just about any contemporary linux distro. Using them you will have:
-- A daemon that supervises the running virtual machines and stores their settings in xml files. The machines are started in the background, and you can connect to their console with virt-manager. This way they dont depend on the X server. You can have virtual machines auto started on boot, the machines are shut down orderly before shutdown/reboot.
-- Additionally libvirt can be accessed on remote machines tunneled via ssh. Virt-manager too can use these types of connections (built in feature), you can even export your local USB devices through network, connecting them to a VM that runs on another computer.
-- A graphical UI that works much in the same way as the VirtualBox one. If you use the qxl virtual video card and the user space vdagent, you can have dynamic resolution switching and clipboard sharing.
-- Linux guests work better than Windows.

Now on the downside:
- the best virtual video card (qxl) offers no hardware acceleration while virtualbox' card does (which is mostly emulation i suppose). I migrated machines from VBox to KVM (i use virt-manager) and they work just fine and i see no problems with the display - note that i use them for testing stuff that do not require hardware acceleration.
- With virt-manager you have to have a bridge pre-made (although you can create in the libvirt preferences) whereas VBox creates it for you on the fly (it behaves like VBox used to in older versions). Using NAT works just as with VBox but no port forwarding helpers from the GUI.

DJOtaku 06-25-2015 01:55 PM

I don't know if you're still looking for an answer, OP - it seems you've started playing with KVM already. But for completeness sake, let me add my $0.02.

I've been a LONG time user of Virtualbox - since it was first introduced as a competitor to VMWare. About 4 years ago I started playing with KVM via virt-manager. At the time I wrote this blog post: http://www.ericsbinaryworld.com/2011...chine-manager/

I used to use VirtualBox A LOT to do Linux Distro reviews - at least one per month - sometimes more.

In the meanwhile, both bits of software have improved. Now, as the OP has learned, bridging even works with NetworkManager!

At this point in time, my preference is strongly for Virt-Manager/KVM. Why? Four things - one is relatively minor.

1. Because of the way VirtualBox is packaged, if they release a new version you have to go install it manually. Only bugfixes are fixed via yum/dnf update. This is probably a good thing for having a consistent experience - what if they change something crucial that makes your VMs not work? (this is the minor complaint)
2. Just like nVidia cards, it needs a kmod to work correctly. Just like nVidia cards, this leads to suboptimal performance. Sometimes it leads to very annoying and hard to find issues. Other times, you just need to "recompile" the kmod - just a script.
3. The open source Virtualbox is missing stuff. Those things are closed source. They're free as in beer, but I've had LOTS of issues with them. They need to be reinstalled with every upgrade of VirtualBox and right now I have a Debian VM that has become borked because it's dependent upon an older version of the add-ons. (These are things like seamless mouse integration, USB 2.0, and some other stuff)
4. Finally, in my experience (on my hardware) Virt-manager/KVM tends to have better performance. My computer drags a lot less with KVM VMs; especially when I have more than one running. But, this is the most subjective and perhaps host/guest/hardware combinations that you have might lead to VirtualBox working better.


All times are GMT -5. The time now is 06:36 AM.