QEMU-KVM use

Moderator: Forum moderators

Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

QEMU-KVM use

Post by Clarity »

QEMU is available in the package manager.

There is currently a GUIDE for QEMU KVM use that intends to be a simple elementary read. But, it is dated and needs an update that is specific to KLV. Its contents ARE accurate for those distro it shows.

I will attempt to gain access and/or get it updated soon.

Last edited by Clarity on Tue Dec 13, 2022 1:37 am, edited 4 times in total.
Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

Re: QEMU-KVM use

Post by Clarity »

These are several commands that affords audio coming from the VM that is booted.

Code: Select all

qemu-system-x86_64 -boot d -m 2048 -enable-kvm -smp 2 -soundhw all -cdrom KLV-Airedale-CurrentVersion.iso

Here's another using a different video from the default

Code: Select all

qemu-system-x86_64 -enable-kvm -m 2048 -soundhw hda -vga cirrus -smp cpus=2 -drive format=raw,media=cdrom,readonly,file=KLV-Airedale-CurrentVersion.iso 

If you have suggestions or test results, post them to the thread

Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

Re: QEMU-KVM use

Post by Clarity »

A forum member, @Grey has presented a CURRENT version of QEMU to the forum. It is here (look for the 'Pet' line and disregard his post title of a prior version of QEMU)

His current download is version 7.1

Check against the version available thru your package manager.

Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

Re: QEMU-KVM use

Post by Clarity »

QEMU GUI on PUPs has reported some use issues of its features.
Notably: Its SAMBA feature option

KVMon PUP has reported some use issues running
Notably: Inability to detect KVM support when its built into the kernel

Although it doesn't ship with QEMU, there is another installable GUI utility known as AQEMU.

Lastly, the Virt-Manager is an excellent selection that is much more robust for management and even management of multiple VMs that may exist on multiple PCs in your home's LAN.

Operationally, it appears that running on x86-64 host PUPs & DOGs, QEMU, itself, is extremely stable for running both VM x86 type processors as well as VM ARM processors. Outside of Puppyland, there are no reports current on issues with VM Power-PC processors, either that would impact our use with forum distros. I am not sure if any members are running PPC systems as host or using any distros testing by them configuring QEMU for test of PPC VMs.

Geek3579
Posts: 269
Joined: Sat Jul 18, 2020 1:07 pm
Has thanked: 80 times
Been thanked: 68 times

Re: QEMU-KVM use

Post by Geek3579 »

There is currently a GUIDE for QEMU KVM use that intends to be a simple elementary read. But, it is dated and needs an update that is specific to KLV. Its contents ARE accurate for those distro it shows.

This is a very valuable instruction set which got me started in using QEMU in Puppy Linux (or anywhere, for that matter). As a CLI application QEMU has a very steep learning curve, which probably puts many people off.
However, QEMU in Fossapup64 runs well, and opened up new ways to run virtual OSs. However, unless the CLI code is spot on for the version of QEMU, I couldn't do things like boot EFI images reliably, nor access USBs and other drives which is what I needed.

I found that AQEMU (found in the PPM) is a great GUI app which solves many of my QEMU problems, providing a richer QEMU experience, especially generating tricky QEMU code which one can be copied and run independently of the GUI for convenience. For example, I can now install a Linux OS to an HDD or USB from a QEMU Live OS, which is arguably easier than with VirtualBox.

But the main convenience of QEMU is portability. Code and files made on one Puppy device can be simply copied and pasted to another which has the QEMU installed. No devx and kernel sources required as for VirtualBox. With the right documentation It can be a much easier way to get into virtual computing, and Puppy Linux provides a low demand host OS.

I recommend that new users start with the Fossapup64 pet and go from there.

Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

Re: QEMU-KVM use

Post by Clarity »

Yes.

And many members are unaware that from their running Host with PUPs/DOGs that they can create a Virtual PC to have any peripherals they want with any CPU they choose. And, as you share the result can be run OOTB on a REAL CPU PC that has those same perifpherals. Using QEMU from the command line and experiencing outstanding performances.

Further, some members have 16GB, and 32GB PCs. On those, they can run 8-16 (or more) Virtual PCs (VMs) depending on how much ram they want each to have. As well if they choose, they can put some/all of them on their LAN to make their other LAN machines see both the host PC as well as any of the VM PCs they choose to be on their home LAN.

That's, yet other ways, to setup, test, and run their chosen VM's for any home use.

Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

Re: QEMU-KVM use

Post by Clarity »

For a good complete picture of all of the VMs one might choose if a member wants, they might choose Virt-manager install via your PUP/DOG package manager to have good visual observation with tools to dynamically control the many instances and varied instances one might choose.

Its easy to understand and visually appealing too as it takes the guesswork out of some of the more complex configuration that can be deployed for any VM configuration the user saved or is active.

There are many demo videos from the past decades on installation, setup, and use of virt-manager for typical VMs.

Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

QEMU-KVM request for community help

Post by Clarity »

Hello Coding Members. I need your help.

I am in the process of review and improvement of a Forum Specific document(s) for member use in running a Virtual Machine with as little steps as possible. The intent is to cover both BIOS and UEFI VMs so that any/all work done within a VM is directly transferable to bare-metal operations.

I need help in this one area that will reduce any PUP user to insure his PC can take advantage of the Hardware built within most all (but not every) 64bit PCs. This need reduces 3-4 step outlined in the beginning of this manual for new people to VM operations.

By reducing the steps to a single program will make for a foolproof operation while also insuring a reduction in any user mistaken frustrations that could occur.

Here's is a flowchart of the need for someone who can code, please. My skills will lead to a 'bad' program while others of you will solve this efficiently in some simple commands.

Need a script that does this.
Need a script that does this.
KVM Setup for Linux PCs.jpg (55.23 KiB) Viewed 4919 times

The correct 3-4 steps are specified in this document but a simple script will change all of that as it reduces all to a single check with a result, rather than 3/4.

Last edited by Clarity on Wed Dec 28, 2022 7:39 am, edited 5 times in total.
Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

QEMU-KVM request for community coding help

Post by Clarity »

It is my intention to make a new document that covers the commandset used in the current versions of QEMU, namely v7+, which has been available this year. And I intend to finish it very soon.

From the above document for the command steps needed

Doc specifies

Terminal Command

Is the PC capable

egrep --color=always -i 'vmx|svm' /proc/cpuinfo # Is PC VM capable?

Is the kernel module loaded

lsmod | egrep --color=always kvm # is virtualization present?

Load KVM for Intel

modprobe kvm-intel # for Intel CPUs - eg. ‘vmx’ flag

Load KVM for AMD

modprobe kvm-amd # for AMD CPUs - eg. ‘svm’ flag

This simple request will replace a WHOLE section of that Guide for forum users.

This simple script would let a user know if their PC has the CPU feature active as well as insuring the kernel is present and loaded in a single step.

Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

Re: QEMU-KVM use

Post by Clarity »

OK, can anyone help me with coding to complete the 1st test, please.

The egrep command ends with a 0 or a 1 exit code. HOw do I correctly check for which the egrep completed with?

Code: Select all

#!/bin/bash

echo 'Running a test named/n' $0

egrep --color=always -i 'vmx|svm' /proc/cpuinfo >  nul # Is PC VM capable?
if [ $? eq 0]
	then echo "This PC has VM capability"
		exit
else echo "This PC does not have VM capability"
sleep 2
exit

Thanks in advance

icake
Posts: 446
Joined: Mon Jul 27, 2020 8:07 am
Been thanked: 45 times

Re: QEMU-KVM use

Post by icake »

Code: Select all

#!/bin/bash

echo 'Running a test named/n' $0

egrep --color=always -i 'vmx|svm' /proc/cpuinfo >  nul # Is PC VM capable?
if test $? -eq 0
	then echo "This PC has VM capability"
		exit
else echo "This PC does not have VM capability"
sleep 2
fi
exit
Last edited by rockedge on Thu Jan 12, 2023 12:16 pm, edited 1 time in total.
Reason: added code block to isolate script
Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

Re: QEMU-KVM use

Post by Clarity »

Attempting new version to match flowchart

Code: Select all

#!/bin/bash
# Credit to this script goes to the combined efforts 
# of Puppy Linux forum members
# 	especially members 'icake' and 'Burunduk'

echo 'Running a test named/n' $0

if grep -Eiq 'vmx|svm' /proc/cpuinfo; then
    echo "This PC has VM capability"
    if lsmod | egrep --color=always kvm # is virtualization loaded?; then 
		echo "This PC has KVM loaded"
		exit
	else
		echo "KVM is being loaded"
		if grep -Eiq 'vmx' /proc/cpuinfo; then
			modprobe kvm-intel # vmx flag is for Intel CPUs 
			exit
		else 
		modprobe kvm-amd # svm flag is for AMD CPUs 
		exit
	fi
fi
else
    echo "This PC does not have VM capability"
    exit
fi

.
Question

  • How do I successfully nest the test conditions?

?

I am a little lost again.

Error messages from this version

Code: Select all

line 13: syntax error near unexpected token `else'
line 13: `	else'
icake
Posts: 446
Joined: Mon Jul 27, 2020 8:07 am
Been thanked: 45 times

Re: QEMU-KVM use

Post by icake »

Please try this:
adjustment: line 10:
original line: if lsmod | egrep --color=always kvm # is virtualization loaded?; then
replacement: if lsmod | egrep --color=always kvm; then # is virtualization loaded?

Code: Select all

#!/bin/bash
# Credit to this script goes to the combined efforts 
# of Puppy Linux forum members
# 	especially members 'icake' and 'Burunduk'

echo 'Running a test named/n' $0

if grep -Eiq 'vmx|svm' /proc/cpuinfo; then
    echo "This PC has VM capability"
    if lsmod | egrep --color=always kvm; then  # is virtualization loaded?
		echo "This PC has KVM loaded"
		exit
	else
		echo "KVM is being loaded"
		if grep -Eiq 'vmx' /proc/cpuinfo; then
			modprobe kvm-intel # vmx flag is for Intel CPUs 
			exit
		else 
		modprobe kvm-amd # svm flag is for AMD CPUs 
		exit
	fi
fi
else
    echo "This PC does not have VM capability"
    exit
fi
Last edited by rockedge on Sun Jan 15, 2023 3:22 pm, edited 2 times in total.
Reason: added code blocks
User avatar
Sofiya
Posts: 2279
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1477 times
Been thanked: 1524 times

Re: QEMU-KVM use

Post by Sofiya »

Clarity wrote: Thu Jan 12, 2023 12:15 pm

Code: Select all

#!/bin/bash
# Credit to this script goes to the combined efforts 
# of Puppy Linux forum members
# especially members 'icake' and 'Burunduk'

echo 'Running a test named/n' "$0"

if grep -Eiq 'vmx|svm' /proc/cpuinfo; then
    echo "This PC has VM capability"
    if lsmod | grep -E --color=always kvm; then # is virtualization loaded?; then 
		echo "This PC has KVM loaded"
		exit
	else
		echo "KVM is being loaded"
		if grep -Eiq 'vmx' /proc/cpuinfo; then
			modprobe kvm-intel # vmx flag is for Intel CPUs 
			exit
		else 
		modprobe kvm-amd # svm flag is for AMD CPUs 
		exit
	fi
fi
else
    echo "This PC does not have VM capability"
    exit
fi
Last edited by Sofiya on Sat Jan 14, 2023 9:38 pm, edited 1 time in total.

KL
PUPPY LINUX Simple fast free

Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

Re: QEMU-KVM use

Post by Clarity »

icake wrote: Thu Jan 12, 2023 3:12 pm

Please try this:
adjustment: line 10:
original line: if lsmod | egrep --color=always kvm # is virtualization loaded?; then
replacement: if lsmod | egrep --color=always kvm; then # is virtualization loaded?
...

I see. The commandlsmod | egrep --color=always kvm # is virtualization loaded? is valid when used in a terminal, but in a bash script, the info portion is NOT allowed.

Thanks

Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

QEMU-KVM Setup Script

Post by Clarity »

I think this code should match perfectly with the flow chart here

Code: Select all

#!/bin/bash
# script to insure that optimum performance occurs when a QEMU VM is run
#
# Credit to this script goes to the combined efforts 
# of Puppy Linux forum members
# especially members 'icake' and 'Burunduk'

# echo $'Running a test named\n'"$0";echo

if grep -Eiq 'vmx|svm' /proc/cpuinfo; then
    echo "This PC has VM capability"
    if lsmod | grep -iq kvm; then # is virtualization loaded?
        echo "This PC has KVM loaded"
    else
        echo "KVM is being loaded"
        if grep -iq 'vmx' /proc/cpuinfo; then
            modprobe kvm-intel # vmx flag is for Intel CPUs 
        else 
            modprobe kvm-amd # svm flag is for AMD CPUs 
        fi
    fi
else
    echo "This PC does not have VM capability"
fi
Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

Re: QEMU-KVM use

Post by Clarity »

I think most 'might agree' that this PC identification acceleration utility's name is to be "kvm-check" and should exist in forum distros at /usr/local/bin.

Any disagreements?

User avatar
Sofiya
Posts: 2279
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1477 times
Been thanked: 1524 times

Re: QEMU-KVM use

Post by Sofiya »

Clarity wrote: Sat Jan 14, 2023 8:56 pm

I think most 'might agree' that this PC identification acceleration utility's name is to be "kvm-check" and should exist in forum distros at /usr/local/bin.

Any disagreements?

the question immediately arises, where to download this utility "kvm-check" :geek:
the title is great :thumbup:

KL
PUPPY LINUX Simple fast free

Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

Re: QEMU-KVM use

Post by Clarity »

YES. I will be opening a thread for "kvm-check v1.0" soon, on the forum...assuming the name is acceptable.

Until then, the utility can be copied from the 'code' here

User avatar
Sofiya
Posts: 2279
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1477 times
Been thanked: 1524 times

Re: QEMU-KVM use

Post by Sofiya »

Clarity wrote: Sat Jan 14, 2023 9:23 pm

YES. I will be opening a thread for "kvm-check v1.0" soon, on the forum...assuming the name is acceptable.

Until then, the utility can be copied from the 'code' here

everything my PC supports everything, it remains only to figure out how to install Qemu :D :D

Attachments
Screenshot(1).jpg
Screenshot(1).jpg (28.71 KiB) Viewed 4503 times

KL
PUPPY LINUX Simple fast free

Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

Re: QEMU-KVM use

Post by Clarity »

I believe @rockedge has plans for KLV repo with current QEMU v7+ available.

The version of QEMU v7.0+ that I am using on my Slacko64 & FossaPUP64 PCs came from @norgo and @Grey via this forum.

And @peebee 'may' be looking into updated WoofCE repo versions of QEMU for their PUPs.

User avatar
Sofiya
Posts: 2279
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1477 times
Been thanked: 1524 times

Re: QEMU-KVM use

Post by Sofiya »

Clarity wrote: Sat Jan 14, 2023 10:22 pm

I believe @rockedge has plans for KLV repo with current QEMU v7+ available.

The version of QEMU v7.0+ that I am using on my Slacko64 & FossaPUP64 PCs came from @norgo and @Grey via this forum.

And @peebee 'may' be looking into updated WoofCE repo versions of QEMU for their PUPs.

@Grey disappeared somewhere he was not seen for a long time

KL
PUPPY LINUX Simple fast free

User avatar
Sofiya
Posts: 2279
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1477 times
Been thanked: 1524 times

Re: QEMU-KVM use

Post by Sofiya »

I don’t know, maybe I’m doing something wrong, I can’t run KLV-Airedale in QEMU v7

Attachments
Screenshot(1).jpg
Screenshot(1).jpg (109.16 KiB) Viewed 4693 times

KL
PUPPY LINUX Simple fast free

User avatar
rockedge
Site Admin
Posts: 6543
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2749 times
Been thanked: 2624 times
Contact:

Re: QEMU-KVM use

Post by rockedge »

I've been worried about @Grey for the last few weeks. I have not seen any posts in December at all from him.

Hope to see a post again soon.

KLV-Airedale will not boot on a QEMU v7+ machine? That's not good. How are you starting qemu?

Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

Re: QEMU-KVM use

Post by Clarity »

@Sofiya, Questions

  • which distro is your host that you installed QEMU on?

  • Can you share your QEMU stanza used to launch the VM guest?

Thanks for sharing your findings

User avatar
Sofiya
Posts: 2279
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1477 times
Been thanked: 1524 times

Re: QEMU-KVM use

Post by Sofiya »

Clarity wrote: Sun Jan 15, 2023 12:43 am

@Sofiya, Questions

  • which distro is your host that you installed QEMU on?

  • Can you share your QEMU stanza used to launch the VM guest?

Thanks for sharing your findings

I install on KLV-Airedale out of the box Qemu-v7.1.0_1
qemu-system-x86_64 -boot d -m 2048 -smp 2 -cdrom KLV-Airedale-rc6.1.iso

KL
PUPPY LINUX Simple fast free

Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

Re: QEMU-KVM use

Post by Clarity »

@Sofiya, try this.

I just tested using KLV v7.2 on my FossaPUP64 launching QEMU v7.1.50 as follows

Code: Select all

qemu-system-x86_64 -enable-kvm -m 2G -vga cirrus -smp 2 -device AC97 -cdrom KLV-Airedale-rc7.2.iso

booting to this desktop

KLV v7.2 desktop in QEMU booted fast!
KLV v7.2 desktop in QEMU booted fast!
KLV Pristine with Cirrus VGA2.jpg (20.71 KiB) Viewed 4656 times

.

P.S. Did you boot QEMU from this terminal command "qemu_gui"? ... Just Curious in how you got your stanza. Your info will improve how we help others.

Geek3579
Posts: 269
Joined: Sat Jul 18, 2020 1:07 pm
Has thanked: 80 times
Been thanked: 68 times

Re: QEMU-KVM use

Post by Geek3579 »

@Clarity has a better script. One could run -enable-kvm ONCE in the terminal, but its better in the CLI as you cant forget to run it as easily. Also adding -vga cirrus/stdio/etc is a good idea.

One thing I discovered is that using AQEMU (from PPM) as a GUI helps to find a working script quickly, especially adding peripherals such as USBs, etc. One can then copy the generated scripts for future stand-alone use.

Clarity
Posts: 3829
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1628 times
Been thanked: 522 times

Re: QEMU-KVM use

Post by Clarity »

The script turns-on use of the firmware in your operating system. Then 'enable-kvm' is needed as it tells the QEMU program to use the turned-on acceleration.

On my Intel PCs, 'cirrus' video gives the PUPs what needed to easily display desktops.
Edit: The above statement is NOT true. I retract!!! QuickPUP64 is an example of this not true; it requires 'std', instead, for desktop success.

What I hope each member shows us in their use is

  • that they get to desktop with their forum distros

  • that they have sound available thru the host speakers

  • and, when possible, share their working stanza's they use

.So far, the stanzas shown are BIOS based VMs. In the coming weeks-months we, members, will show UEFI stanzas such that we will know that forum distros not only boots in a UEFI VMs, but also will boot on a bare-metal UEFI PC with exactly the same results as seen in the QEMU VMs.

Virtually, the QEMU stanzas describe a physical PC where we can tell it which physical units are present and used for booting a designated OS of our choosing.

VMs can be confusing, but, once a member gets aquainted, they see how they can use the bare-metal PC as if it is multiple physical PCs with little to no degradation in performance than gotten from the REAL PC.

User avatar
norgo
Posts: 283
Joined: Mon Jul 13, 2020 6:39 pm
Location: Germany
Has thanked: 6 times
Been thanked: 111 times
Contact:

Re: QEMU-KVM use

Post by norgo »

Clarity wrote: Sun Jan 15, 2023 1:28 am

P.S. Did you boot QEMU from this terminal command "qemu_gui"? ... Just Curious

good question
which qemu_gui script ;-)

Important hint
qemu_gui is included in rootfs-skeleton by default

PPM offers a Qemu_Control_Center-0.7 package.
This package contains a not working qemu_gui script.
Do not install this pet because the working qemu_gui script would be overwritten!

qemu_gui_07.jpg
qemu_gui_07.jpg (48.39 KiB) Viewed 4623 times
Post Reply

Return to “Utility”