LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   [ANN] Introducing vms - more qemu virtual machines ! (https://www.linuxquestions.org/questions/slackware-14/%5Bann%5D-introducing-vms-more-qemu-virtual-machines-4175637126/)

ninikos 08-25-2018 03:49 PM

[ANN] Introducing vms - more qemu virtual machines !
 
Hallo,

I am introducing vms.

vms is a little system for managing qemu virtual machines. It is written in bash. Two main utilities are provided; vms and rc.vms.

vms is for running as a normal user eg. joe. It is used to create and manage virtual machines using simple commands like this

Code:

vms create vm1
vms conf vm1 disk0 '~/.vms/vm1/disk.img'
vms list
vms info vm1
vms start vm1
vms stop vm1

rc.vms is to be used by root for controlling a set of predefined virtual machines. Starting vm1 during boot can be done like this

Code:

echo 'joe vm1' >> /etc/rc.d/rc.vms.conf
/etc/rc.d/rc.vms start

The code is hosted here https://bitbucket.org/yotis/vms
See README.md and the man pages vms(1), vms.conf(5), rc.vms.conf(8), rc.vms.conf(5), vms-tutorial for more information.

A ready to install slackware package is here vms-0.2.1-noarch-1did.tgz (!!updated!!!)

vms HOW TO: https://docs.slackware.com/howtos:emulators:vms

I am using this for quite some time now. It has grown from using custom scripts inspired by Alien Bob's qemu posts and scripts. I have been running with this various linux distros, BSD's, minix, MacOS, windows etc. It has also been used with pci-stub and vfio-pci passthrough for having available hardware in the vm, such as pci graphics and audio cards or the whole usb bridge. See https://bitbucket.org/yotis/vms/src/...sbin/vfio-bind

I find it useful, maybe it will be for others useful too. Any feedback and contribution is more than welcome :)

I will also submit a SlackBuild to slackbuilds.org.

TommyC7 08-26-2018 09:27 AM

What differentiates vms from virsh/libvirt?

ninikos 08-26-2018 10:20 AM

Quote:

Originally Posted by TommyC7 (Post 5896140)
What differentiates vms from virsh/libvirt?

Well, I am by no means expert on libvirt. First of all, vms is very small. The slackware package is around 10K. It also has minimal dependencies. Namely bash, qemu, socat, vde2, tigervnc. Being very simple and written in bash, it can be easily understood and customized.

The main utility vms supports a very simple interface.
Code:

$ vms
Usage:
vms create <vm_name> [vm_template]
vms list
vms info <vm_name>
vms status <vm_name>
vms start <vm_name>
vms kill <vm_name>
vms stop <vm_name> [timeout]
vms restart <vm_name> [timeout]
vms log <vm_name>
vms monitor <vm_name>
vms serial <vm_name>
vms vnc <vm_name>

vms uses a simple configuration file ~/.vms/vms.conf for configuring the virtual machines per user that declares one bash associative array for each virtual machine. Much simpler than dealing with XML configuration files that the managing tools are messing around with your edits. A complete working minimal vms.conf example would be like this.

Code:

#!/bin/bash

APATH=/path/to/storage

declare -A avm
avm[name]=avm
avm[uuid]='xxxxxxxx-ffff-ffff-ffff-ffffffffffff'
avm[arch]=x86_64
avm[mem]=2048
avm[smp]=2
avm[disk0]="$APATH/avm-disk0.img"
avm[bootcd]="$APATH/install-dvd.iso"

I started using a set of scripts based on alienbob's qemu and vde scripts. This was in 2012-2013. Back then, I wanted to run virtual machines with pci passthrough for graphics cards. IIRC I tried to do this with CentOS, ubuntu, debian, .. None of them could do it. The main problem was that specific kernels and packages where needed for this to work. That was one of the reasons I tried slackware and it is the only system I use now. I could only do pci passthrough with slackware64-14.0, only with the scripts and custom kernels. libvirt was giving me a lot of problems and pci passthrough was not working with it at the time. So, after a lot of copying and evolving those scripts, vms was created, at first as an easy fast way to create a virtual machine and manage a set of them in one file easily.

I will upload soon a 0.1.2 version that has some manpages, with some more examples and documentation how to use it.

ninikos 08-26-2018 12:08 PM

I just uploaded another package, vms-0.1.2, it has man pages for vms and vms.conf. In there there are some more examples. See the first post for download link.

slacksam 08-26-2018 05:16 PM

1 Attachment(s)
Thanks for sharing your scripts.

I installed vms-0.1.2-noarch-1did.tgz and read the man pages first. Then I created $HOME/.vms/vms.conf (file is attached) and ran "vms create vslack01" and got an error message that it can't find '/var/lib/vms/vm.sh'. I found '/var/lib/vms/vm.sh.new' instead, so I renamed it. When I started that command again, it complained that
Quote:

vslack01 already exists
But the directory $HOME/.vms/vslack01/ was empty so I copied the script manually with
Code:

cp /var/lib/vms/vm.sh $HOME/.vms/vslack01/vslack01.sh
The command "vms create vslack01" created a new array named vslack01 into vms.conf so I deleted it since I already created it before running that command.

Now when I do
Code:

vms start vslack01
I get the message
Code:

starting vslack01 ...qemu-system-x86_64: -device virtio-net-pci,netdev=nd1,mac=52:54:00:12:34:65: drive with bus=0, unit=0 (index=0) exists
 error!
qemu error 1

I tried to comment out the line which define the network interface in my vms.conf but then I got the same error message
Code:

starting vslack01 ...qemu-system-x86_64: -boot once=d: drive with bus=0, unit=0 (index=0) exists
 error!
qemu error 1

So I guess the settings in vms.conf are not the reason for the error message.

Any idea what else it could be?

ninikos 08-26-2018 06:31 PM

Thank you for testing :)

About /var/lib/vms/vm.sh.new, it is indeed a packaging issue, I forgot to add a line to doinst.sh, it will be ok with the next package.
The easiest way to start is by
Code:

$ vms create vmslack01
You do this or you create the files by hand like this and then add the first lines by hand in ~/.vms/vms.conf
Code:

mkdir ~/.vms/vmslack01/
cp /var/lib/vms/vm.sh ~/.vms/vmslack01/vmslack01.sh

I just tried your config. I created the image files, so I did not touch vslack01 config at all and it works just fine. Are you sure your .qcow2 and .iso files exist?

What qemu version are you using? I am using here 2.9.0. From the error message you get I think it tries to attach a disk device where another one is already attached. Can you try modifing the disk like this?

Code:

vslack01[disk0]="$VMSTORE/Slackware_14.2_avahi.qcow2,index=1"
or

Code:

vslack01[disk0]="$VMSTORE/Slackware_14.2_avahi,if=virtio"
Also, can you post the output of vms info vslack01 ?

ninikos 08-26-2018 06:40 PM

Also qemu monitor console is to be used like this

Code:

vslack01[monitor]=yes
and then you can attach to it using

Code:

vms monitor vslack01

slacksam 08-26-2018 06:58 PM

Thanks for the quick reply.
Quote:

Originally Posted by ninikos (Post 5896351)
What qemu version are you using?

Using Qemu version 2.12.0 here.

Adding
Code:

,index=1
or
Code:

,if=virtio
made no difference.

Quote:

Originally Posted by ninikos (Post 5896352)
Also qemu monitor console is to be used like this

Code:

vslack01[monitor]=yes
and then you can attach to it using

This made it work.
Thanks! :)

ninikos 08-26-2018 07:01 PM

I have uploaded vms-0.1.2-noarch-2did.tgz package that fixes the /var/lib/vms/vm.sh related errors when using 'vms create vslack01'.

ninikos 08-27-2018 10:42 AM

I have uploaded vms-0.1.3-noarch-1did.tgz package.

It has better documentation. See the first post for links to the man pages. Install it like this

Code:

upgradepkg --install-new vms-0.1.3-noarch-1did.tgz
slackpkg new-config


ninikos 08-28-2018 10:31 AM

And here is another package for vms 0.2.0, get it there

vms-0.2.0-noarch-1did.tgz

There is a tutorial `man vms-tutorial` and updated man pages.
A new option is introduced 'vms conf' for editing ~/.vms/vms.conf.
Code:

vms create vm1
vms conf vm1 cpu host
cms conf vm1 kvm yes
cms conf mv1 mem 2048
vms conf vm1 disk0 '~/.vms/vm1/disk0.img'
vms conf vm1 disk1 '"$A_VARB_IN_VMS_CONF/another/disk1.img"'
vms conf vm1 extra0 "'-usb -device usb-mouse -k en_us'"
vms conf vm1 extra1 "'-device vfio-pci,host=04:00.0,romfile=gfx-card-bios.rom'"

:)

bifferos 08-29-2018 06:33 PM

I think this would be better posted in the generic Linux forum. Granted it comes with Slackware packages but it won't be rocket science to get it working with other distros.

It reminds me of something I put together a while back: http://www.biffer.talktalk.net/PyQemu/?showpage=true. I can't believe that was 12 years ago... :-(

ninikos 08-30-2018 08:32 AM

Quote:

Originally Posted by bifferos (Post 5897737)
I think this would be better posted in the generic Linux forum. Granted it comes with Slackware packages but it won't be rocket science to get it working with other distros.

Well, I think the vms command will work with very little effort. Some path adjustments maybe are needed for the init script. Even if I am using this for two years now, I haven't tested it with any other distributions. Maybe this will be an excuse to try nested kvm.

Quote:

Originally Posted by bifferos
It reminds me of something I put together a while back: http://www.biffer.talktalk.net/PyQemu/?showpage=true. I can't believe that was 12 years ago... :-(

I was very temped to write this in python. Python dictionaries are much more easy to work with than bash associative arrays. The main reasons that I left it in bash until now are that bash can be very easily customized and as it is, it has minimal dependencies.

ninikos 08-30-2018 08:40 AM

vms 0.2.1
 
I have uploaded vms-0.2.1-noarch-1did.tgz

It has many little fixes, some performance improvements, much more polished and tested examples and man pages and saner output to the user. I think this is the most polished version so far. If you tried any of the previous ones, please try again.

There is also a how to at https://docs.slackware.com/howtos:emulators:vms

Have fun

hazel 08-30-2018 11:40 AM

Maybe you shouldn't have called it vms. There's an operating system called that (used to be used on DEC Vaxes).


All times are GMT -5. The time now is 07:29 AM.