Beginning with KVM

So I attempted to give it a try. Before even starting to create a new virtual machine I stumbled with few initial questions.

  1. SLES docs advise for using the vhost-net module as it’s more efficient. So as root user I did “modprobe vhost-net”, then confirmed with “lsmod | grep vhost”. But after rebooting module is no longer loaded. Is there a way to make it persistent after reboot/shutdown?

  2. I tried getting help for lsmod command, but “lsmod --help” only gave a message “usage: lsmod”, and echo $? gave 1, which meant it was an error. This was made as normal user. Does this have consequences for the OS? How can fix?

  3. When first opening virt-manager I saw a grayed-out entry “QEMU/KVM: not connected”; if selecting it there’s the option to “connect”. But connect to what? There are still no VMs whatsoever yet!

  4. Is there a more graphical way to open virtual machine manager other than having to open terminal and type “virt-manager”?

Thanks again.

Rather than using a SLES guide, refer to this guide for openSUSE

https://doc.opensuse.org/documentation/leap/virtualization/html/book.virt/cha.vt.installation.html

I’ve just started using KVM here.

  1. SLES docs advise for using the vhost-net module as it’s more efficient. So as root user I did “modprobe vhost-net”, then confirmed with “lsmod | grep vhost”. But after rebooting module is no longer loaded. Is there a way to make it persistent after reboot/shutdown?

I’m not currently using “vhost-net”.

For automatic loading of a module, try

man modules-load.d
  1. I tried getting help for lsmod command, but “lsmod --help” only gave a message “usage: lsmod”, and echo $? gave 1, which meant it was an error. This was made as normal user. Does this have consequences for the OS? How can fix?

You should be able to use:

man lsmod
  1. When first opening virt-manager I saw a grayed-out entry “QEMU/KVM: not connected”; if selecting it there’s the option to “connect”. But connect to what? There are still no VMs whatsoever yet!

It connects to “libvirtd”, which should be running as a service. Installing KVM sets that up. Once I connect, I see a list of virtual machines.

  1. Is there a more graphical way to open virtual machine manager other than having to open terminal and type “virt-manager”?

I did it by typing “virt” into the menu search of my desktop.

I also installed “ovmf” (well, “ovmf”, “ovmf-tools”, “qemu-ovmf-x86_64”). That gives me the possibility of a UEFI virtual machine.

First virtual install – fedora26 (I had already downloaded the iso). I’ve since deleted that, but I learned something from doing it.

Second virtual install - openSUSE 42.3. I’m normally a KDE person, so I installed Gnome. This was from the iso, already on my system. On screen 5 of setup, there’s a box where I could specify that I wanted extra configuration. That gave me a choice where I could select UEFI. So I did. That virtual machine is running well (except currently not running). Running Yast on that virtual machine, I noticed that it wanted to install “spice-vdagent”. So I allowed that to install. And it’s great. I can now do copy/paste between the main machine and that 42.3 virtual machine.

Third virtual install – Solus. That was a fail. I tried using UEFI. But it seems that the UEFI choice for KVM is locked into secure-boot, and Solus does not do secure-boot.

I redid without UEFI. And that worked. But as soon as I clicked on something with my mouse, the virtual machine captured the mouse. I later discovered that the manual I am reading (“Virtualization Guide - openSUSE 42.3” a pdf file that I downloaded) explains how to deal with that. So now it’s fixed, and Solus no longer captures the mouse. The way that I initially escaped from the captured mouse was to shutdown the virtual machine.

Final installl (for now) – another install of fedora26, this time with UEFI. Since fedora does support secure-boot, I expected that to work, and it did.

I would like to try UEFI without secure-boot. But it looks as if that will require a complicated command line method to specify which virtual firmware file to use.

In any case, I recommend that you try creating a few virtual machines. You can delete them later. Treat it as a learning experience. Maybe start with openSUSE 42.3.

My prior practice was bare metal installs (i.e. direct to computer). I’ll probably still prefer that, but using KVM adds additional choices.

  1. Assuming you’ve installed properly with libvirt, vhost-net should automatically be enabled and applied. Unless you’re specifically running QEMU commands instead, vhost-net should not require any special action on your part.
    https://www.suse.com/documentation/sles11/singlehtml/book_kvm/book_kvm.html#sec.kvm.requires.install

You’ll have to clarify if you really meant when your HostOS is rebooted (Not the Guest). The module should be automatically loaded (not require manual loading) and always available.

  1. Some commands don’t recognize “–help” (or similar). Sometimes “help” works if you use help without any dashes. Otherwise, read the MAN pages instead.

  2. When you launch virt-manager, it should automatically connect to the libvirt “server” running on localhost. If it doesn’t, that’s a sign something is mis-configured. Verify or manually start your libvirt daemon
    https://doc.opensuse.org/documentation/leap/virtualization/html/book.virt/cha.libvirt.overview.html

Beyond that, may require troubleshooting.
Sometimes re-installing is the only solution.

  1. After a proper installation, you should have new entries in your Desktop Application Menu for both VM Manager and virt-install, sometimes in two places (depends on the Desktop). If you don’t see these, like any problem of the vm manager connecting immediately to the libvirt “server” can be an indication you didn’t install your virtualization completely and correctly.

TSU

W T H !!??
Cannot believe it! So my KVM installation is totally buggy!! No vhost-net module automatically loaded when openSUSE host boots, KVM “local server” not automatically connecting when opening virt-manager… WTH!?

I installed KVM by following the SLES docs, i.e., by goinf to Yast > Virtualization > selecting KVM server (the other KVM option, “KVM tools” was grayed out by default, so I only selected KVM server), then accepting. It went through all the zypper-like process with NO aparent errors: all packages downloaded well, all were well installed, I accepted to install network passthrough, and once Yast finished all it didn’t even advised for rebooting, yet I did it anyways.

I’m guessing that it is fine.

No vhost-net module automatically loaded when openSUSE host boots, KVM “local server” not automatically connecting when opening virt-manager… WTH!?

“vhost-net” is loaded here. But I didn’t do it manually.

I’m guessing that it loads when used, which is probably the first time that I start a virtual host.

When I start “virt-manager”, it looks as you describe. So I double-click on the “QEMU/KVM” line, and it connects. After it connects, I can see a list of the virtual hosts that I have setup.

I installed KVM by following the SLES docs, i.e., by goinf to Yast > Virtualization > selecting KVM server (the other KVM option, “KVM tools” was grayed out by default, so I only selected KVM server), then accepting. It went through all the zypper-like process with NO aparent errors: all packages downloaded well, all were well installed, I accepted to install network passthrough, and once Yast finished all it didn’t even advised for rebooting, yet I did it anyways.

That’s pretty much identical to what I did. And it all seems to work.

I did use
Yast → Virtualization → Create Virtual Machines for XEN and KVM
to install a virtual machine.

First, do you all know why I verbosely and solely sticked to the SLES 11 documentation?
From my other thread:

And I don’t think mr tsu2 is nuts or something.

@nrickert:
Your comments begin to calm me down a bit, so thanks for that.
But then, was doing “modprobe vhost-net” as root user a big death mistake, very just like trying “lsmod --help” and getting the error instead of having just “man lsmod”? Did I put the whole OS host in danger or buggy? Do I need to clean reinstall yet again!?

Those actions should be harmless. Nothing to worry about.

Use Yast to install a virtual machine. You can delete it later. It’s just to get some practice.

I finally succeeded at this, after a few more false starts.

The magic incantation (i.e. command) that worked was:


virt-install --name efisolus --memory 4096 --vcpus 2 --disk size=20 \
 --cdrom /shared/iso/solus/Solus-2017.04.18.0-Budgie.iso \
 --boot loader=/usr/share/qemu/ovmf-x86_64-code.bin,loader_ro=yes,loader_type=pflash,nvram_template=/usr/share/qemu/ovmf-x86_64-vars.bin,loader_secure=no

Two parts of that command are specific to Solus (the “–name efisolus” and the argument following “–cdrom”). Those are the part that would have to change to install a different system.

I’m not sure whether that “loader_secure=no” actually does anything. I used the output of

man virt-install

as a guide.

You’ll notice in all my posts

  • Like all other posts in these openSUSE forums, the assumption is that you’re installing on openSUSE. If you’re installing on SLES, then go to those forums, I very rarely post anything that applies to SLES.
  • Use YaST to install your KVM/Xen/LXC, do not otherwise follow SLES Documentation for installing
  • Once your virtualization is installed, <then> everything you might read in the SLES documentation is fully applicable to understanding and doing virtualization on openSUSE.

Sp. I think it’s pretty straightforward.

  1. Use YaST to install.
  2. Use SLES 11 SP4 documentation for 99.9% of everything thereafter.

TSU

D**n…
So I used the wrong guide all along… openSUSE’s one even tells how to install using zypper!

@tsu2:
Just to get a second point of view, would you indeed agree with mr nrickert’s answer regarding my infamous errors “lsmod --help” and “modprobe vhost-net” as root?

I’d really NOT like to have to reinstall openSUSE…!!

Thanks.

Well,
The openSUSE doc about using zypper to install virtualization is incomplete. It will install the required packages, but it doesn’t quite do the same complete job of configuration and creating a networking bridge device(br0) like how YaST does it.

Done correctly, there is no need to lsmod or modprobe. For KVM, to my eye installing KVM doesn’t load any special modules, AFAIK all required kernel modules should be loaded and available for use in the standard distributed kernels. If you read up on KLM(or sometimes LKM), the main heavy lifting is compiling the modules and it’s really nice when it’s done in the very beginning as part of the initrd stage. Once a kernel is loaded, it can remain latent and unused until called upon. The alternative is to manually load kernel modules and then again it’s nice when the module has been pre-compiled. But, from what I’ve seen this has never been necessary for KVM.

So, you shouldn’t worry about details like whether a kernel module is loaded or not, just install and go right to using.
Only if you suspect that something isn’t working as well as it should, then spend some of your valuable time on it.

And,
If you have to do something drastic to uninstall (Are you installed on BTRFS? Maybe you can rollback to an earlier snapshot).
Installing virtualization (any kind) can make enormous and drastic changes to your system so you should always be prepared to have to do a complete re-install. This is why I generally prefer to install any kind of virtualization on brand new machines so if I have to pave and rebuild it’s less painless… And, you do want to leave no stone overturned making sure your system is as rock solid and perfect as immediately because it affects everything you do down the road.

IMO and HTH,
TSU

@tsu2:
I appreciate your attention, and without the least intention to offend, I think your replies are getting more convoluted than helpful, as if trying to show a bit of “vanity”, or more precisely, to scold.

There’s no way I was able to do things “the correct perfect way” since the beginning since I have NOT ever done this before, hence I tried to ask for help here. First reasonable and complete reply was from mr tsu2, so I took “all other guides are incomplete or with false information; you should take SLES 11 guide globablly for everything”.
Now it turned to be wrong.
I know one must use a bit of logic for everything, but I don’t think that is possible if one has no initial knowledge at all.

I guess I’ll have to trust mr nrickert then…

By the way, I look worried about having to reinstall openSUSE because reinstalling any OS is not an EASY task for me specially. It’s a very painful task for me, aside of the fact that here in the place where I am I don’t really have all the time of the world…

No offense taken.
As I related in another thread, unfortunately I cannot recommend either the openSUSE community documentation or the SLES 12 SP2 doumentation for openSUSE KVM users, so I consider our current situation a bit of being in the wilderness without a complete official documentation I feel comfortable with.

But, there is no reason for people to agree with me, if for example you or anyone else wishes to use the openSUSE community documentation, I wouldn’t feel offended in any way

https://doc.opensuse.org/documentation/leap/virtualization/html/book.virt/index.html

TSU

So I’ll attempt to install a new Windows virtual machine meanwhile.
But just to be sure, because I’m still a bit paranoid, could someone second support this, or mr nrickert, could you elaborate a bit more if possible?

“But then, was doing “modprobe vhost-net” as root user a big death mistake, very just like trying “lsmod --help” and getting the error instead of having just “man lsmod”? Did I put the whole OS host in danger or buggy? Do I need to clean reinstall yet again!?”

As I mentioned, mr tsu2’s arguments sound kind of long-scolding instead of helping, even for volunteers…
Thanks.

Let us know how that works out.

I’m not currently planning to do a Windows virtual machine.

But just to be sure, because I’m still a bit paranoid, could someone second support this, or mr nrickert, could you elaborate a bit more if possible?

“But then, was doing “modprobe vhost-net” as root user a big death mistake, very just like trying “lsmod --help” and getting the error instead of having just “man lsmod”? Did I put the whole OS host in danger or buggy? Do I need to clean reinstall yet again!?”

Doing the “modprobe” is like installing a stereo system in your car, but never turning it on. It doesn’t really do anything, except it took a bit of effort. It just loads a module in case it might be needed in the future. And reboot unloads it anyway.

It seems very unlikely that “lsmod --help” would do anything other than display a brief message. So, again, presumably no harm done.

Thanks sir!

So in my attempt to install a Windows 10 VM, I run the create virtual machine wizard (which is indeed an app icon, just need to manually search for it because it’s not in “all applications” by default).
In final step I need to check “custom install after finishing” since I plan to use Red Hat virtio drivers and I must specify them (aside of adding the virtio drivers iso). In the CD/DVD device menu, I see the physical DVD drive is being taken by default as IDE, even when I’m sure the physical drive’s connection is SATA, just like my physical HDD.

Can I change physical DVD drive’s setting to SATA, as well as adding an iso file as SATA, or is there a good reason for using IDE by default for both?

It probably doesn’t matter. I assume that operations on the virtual drive are translated to file operations on the host system. So it’s a matter of what is easiest to emulate.

If you are planning to use the “virtio” drivers, then it is more directly translated to file operations.

An IDE Virtual CDROM is created because it’s attached to a virtual IDE controller, which is the default.
If you created a virtual CD attached to a SATA controller, it would be a SATA CDROM, and there is nothing that would prevent you from doing that if you wish.

But, since it’s emulated, whether you connect to physical hardware or point to an ISO file, there’s no performance difference.

TSU

In the virtual machine settings, where one can tweak ALL possible settings such as processor, memory, drives, USB, and all other devices, I see in the memory section 2 fields: “current” and “maximum” allocation. Does it work just like dynamic memory ballooning? If not, how can I use dynamic memory ballooning provided I have the due drivers?

And, from openSUSE’s KVM docs, there’s just a very brief section about kvm-clock. In summary it advises to use NTP service, I think. But, can virtual guest clock be changed to UTC or local? Or it is not necessary if using NTP?
Point with it is, I’d like to try this https://wiki.archlinux.org/index.php/time#UTC_in_Windows