Server virtualization

Need to deploy a server with user accounts and OS virtualization.

Thinking of going CentOS + QEMU/KVM + SPICE but I know it will be a PITA to manage user account VMs on shared storage. Anyone have tips to set this up as easily as possible?

There actually isn't a lot of info online about such a setup (user accounts + qemu access with shared storage). Should I just give users access to a QEMU script that loads up a VM drive stored in their ~ with shared filesystem access or have them login directly via SPICE?

Are there any distros made for this purpose?

How many accounts? Also why?

This is for a small science lab. We will have about 10 users at a single time but users will need to be added and removed because we have rotating lab members (summer internships, etc). Lots of number crunching, some VMs will need to be Windows for a specific piece of software.

It will be on a pretty new machine with a E5-2650v4 so I'm also interested in optimizing VM resources.

Xen orchestra? UI is a mess, but otherwise its pretty good for self-managed virtualization.

>Xen orchestra

This is academic in nature so licensing is a problem.

What OS for the VMs? If you're virtualizing 10 Fedora installs you might as well make one install of Fedora on the server and let everyone ssh in. Linux was build with multiuser in mind

Look into proxmox.

I've got windows mixed in there unfortunately or this would be easy peasy.

>proxmox

This looks really interesting, thanks. I'll have to see what features it adds over virt-manager.

Well using virt-manager is really easy. It lets you configure a few different types of storage pools. How were you going to store the VMs? In a qcow2 file or something else?

Its free and with all features unlocked. You just need to build it yourself.

just raw files

But this is where it starts to get complicated because I would like to just have small system images (20GB or so) per user that then have filesystem passthrough enabled (using 9p virtio) to a large data volume that is shared between all of the VMs so changes to files made in one VM are propagated to the other VMs (this is important since we do part of our calculations using proprietary windows software and then subsequent calculations in linux). I don't know if this is ideal because I'm not sure how the storage containers will need to grow over time and we are a small operation with less than unlimited storage just to house 20 different copies of virtualized OSes.

I havent tried it for myself, but if you create the VM "disks" through a logical pool you could grow them later if needed. You give virsh/virt-manager a LVM volume group and it creates logical volume inside which acts as a sort of block device for the VM virtual disk. Since they're just logical volumes, you can grow them later through the LVM commands. I havent tried it myself but I think it should work

Do you know if there is a mechanism to only store a diff snapshot (and several snapshots as backups) in a users home directory but provide all of the users access to a fresh VM install of a linux distro or windows so that the storage required to house many vms is lowered?

In other words they would load their personal diff snapshot on top of a shared vanilla starting installation?

and I realize this must be done with qcow2

Zfs dedup?

You can kind of do that with qcow2 and snapshots. I'd recommend just compressing qcow2 images when necessary using qemu-img

I should also mention qemu-img can compress a 50gb qcow2 file in 5 minutes where gzip takes 20 minutes and xz took 40 minutes. Just saying, qcow2 would work better than raw files for you

that's the same conclusion I've come to after spending some time on this

it looks like virt-manager doesn't support external snapshots (which is what I had imagined doing) so I'm trying to figure out if this is doable using internal snapshots or whether I will need to drop to the command line and script this out for users

If it becomes too much work I may look into the pre-existing solution like xen or proxmox, although I'm not sure if they have a similar solution built in.

Well you can do external backups through a script but the VMs need to be shutdown.

Here's a script I recently came up with, it first checks if the image is in use, then compressed it to whereever you want

#! /bin/bash --

# pname='qemu-system'

bdate=$(date +"%F.%T")

image=/home/brady/.vms/Ubuntu/ubuntu.qcow2
backup=/home/brady/backups/vms/Ubuntu/hdd."$bdate".qcow2

echo "checking if image is in use"
while fuser -s "$image"; do
# while lsof -tac "$pname" -f -- "$image" ; do
sleep 0.1
done

echo "image not in use"
echo "moving image"

mv -- "$image" "$image.moved-away" &&
echo "compressing image" &&
qemu-img convert -c -f qcow2 -O qcow2 "$image.moved-away" "$backup" &&
# gzip -k < "$image.moved-away" > "$backup.xz" &&
echo "moving image back" &&
mv -- "$image.moved-away" "$image"


The commented out stuff is just an alternative way of doing it, but what's being used works the best

So you could adapt this for your 10 VMs and run it in a cron job.

I run it weekly

good stuff, thanks

I'll use this to iterate through `users`

On a related note, what is the best clustered filesystem to be shared between the (Linux and Windows) VMs?

If you're going to be doing Linux as the back-end, look at CEPH.

As for the user management, I thought OpenStack did that, but I haven't used it in... years?

I just tried extending a logical volume created by virt-manager and it works fine, the VM reports the disk expanded.

It's a bit more involved to back up logical volumes tho, I think it can be done with LVM snapshots but I havent looked into it yet