The nuts and bolts => Software General => Topic started by: askfor on September 13, 2015, 10:16:10 am

Title: KVM
Post by: askfor on September 13, 2015, 10:16:10 am
Hello !

I'd like to start with KVM on VL 7.1 64. Previously I have been running VirtualBox on OpenSUSE, on the same machine. I know that I could still use VirtualBox, but I'd like to try something else.

I have been searching the web, and it is quite confusing. Often you find something like 'use ubuntu-something' or 'fedora-something'. I managed to start libvirtd, but virt-manager doesn't start, and virt-manager is described in most of the tutorials. It looks like some python module/dependency is missing, but I am 100% sure about that. Perhaps it is some gtk thing which python GUI might need.

At this point I am trying to run MS SQL (not my preference, but i need it ) in WinXP, inside virtual machine.
There seems to be more than one way to achieve this, perhaps using qemu related tools ? Can someone give me some hints please. ?

I know there is a CL tool named virsh, but I'd like to have some basic understanding of what am I doing, not just copy & paste into XTerm.
Title: Re: KVM
Post by: askfor on September 13, 2015, 03:41:55 pm
Update: manged to get virt-manager working. Installed pygobject3 package.
Title: Re: KVM
Post by: M0E-lnx on September 14, 2015, 06:56:37 am
I was going to suggest virt-manager too, but if you just need to run an isolated mysql instance, I would suggest doing this in docker.  Docker works in 7.1 and you will get rid of the 99.999 of the overhead needed to run a vbox/vmware/ or KVM vm just for that server alone.

You can find our docker documentation here
Our docker images can be found here
Title: Re: KVM
Post by: askfor on September 14, 2015, 08:46:33 am
Thanks, but it is MS SQL, not MySQL. Microsoft SQL server, which runs only in windows. I need to connect to it from JSP and PHP applications, which I prefer to develop in Linux.

I have found several tutorials, and my impression is that it is easier to use Qemu/Kvm tools to create an image, virt-manager to manage it.

Any way I hope that my solution to the problem, i.e. installation of pygobject3 helps someone else who has problems running virt-manager. The problem is that virt-manager silently fails to start without it. Fortunately, I have found a --debug switch which reveaeld some error messages.
Title: Re: KVM
Post by: M0E-lnx on September 14, 2015, 08:51:41 am
Sorry, My miskake.
Thanks for the input on the virt-manager package.  We will re-build it and fix the problem so that it pulls the dependencies automatically.

BTW, virt-manager can create the image for you.  Follow the wizard to install your OS.  Or if you already have an image, you should be able to load it using the wizard there.
Title: Re: KVM
Post by: askfor on September 14, 2015, 10:42:07 am
I know, but in those tutorials they always copied iso image from CDROM to hard disc when working with virt-manager. I don't know is it really necessary, or they were just borrowing from one another. Qemu-kvm examples worked with CDROM directly. I didn't have time to look into it yet.
Title: Re: KVM
Post by: askfor on September 14, 2015, 11:11:03 am
This is not strictly related, but here is another fix. In order to get pan (newsreader) to work, one needs to make symlink:

cd /usr/lib64
ln -s
Title: Re: KVM
Post by: askfor on September 20, 2015, 09:15:07 pm
GUI tools gave me nothing but frustration. There was several problems and I lost patience. I know it doesn't help fix the problems, sorry.

Here is something else that might help someone out there. I turned to command line. I created 16GB  virtual disk first with:

qemu-img create -f qcow2 winxp0.qcow2 16G

Then set up a network bridge and started WM with qemu-kvm. I am posting a script which handles the whole process and it is easy to adapt and modify.

First, I'd like to explain what was my intention. I wanted to have fixed IP addresses in both networks, so I could connect to the server process running either in virtual or real machine. My real machine gets IP address from DHCP, so I created a dummy network device and attached an interface to it with address which is on the same network as my physical machine, but outside DHCP range. Also I set up a fixed IP address in VM. In the end I tested everything by installing and running NGinX on both machines. Here is the script which starts and stops VM and sets up network bridge.

LIBVIRT_START="/etc/rc.d/rc.libvirt start"
LIBVIRT_STOP="/etc/rc.d/rc.libvirt stop"
# --- network params
# --- VM params
if [ $VMID=winxp0 ]
   MOUSECAPT="-usbdevice tablet"
# --- start or stop
if [ x${1} = x ]
if [ $ACTION = start ] 
   # --- start kvm
   NL=`lsmod | grep "^kvm" | wc -l`
   if [ $NL -ne 2 ]
   # --- start bridge
   lsmod | grep "^dummy"
   if [ $? -ne 0 ]
      modprobe dummy
   tunctl -t $GUESTIF -u $VUSER
   ifconfig $GUESTIF promisc
   ifconfig $HOSTIF $HOSTNET promisc
   brctl addbr $BRIDGEIF
   brctl addif $BRIDGEIF $GUESTIF
   ifconfig $HOSTIF up
   ifconfig $GUESTIF up
   ifconfig $BRIDGEIF $GUESTGW
   ifconfig $BRIDGEIF up
   netstat -nr | grep $GUESTNET > /dev/null
   if [ $? -ne 0 ]
      route add -net $GUESTNET netmask $GUESTMASK dev $BRIDGEIF
   VMCMD="qemu-kvm -enable-kvm "$SDL" -m "$MEMORY 
   if [ x$CDROM != x ]
      VMCMD=$VMCMD" -cdrom "$CDROM
   VMCMD=$VMCMD" -boot order="$ORDER
   VMCMD=$VMCMD" -net nic,vlan=0,model="$NIC",macaddr="$MAC
   VMCMD=$VMCMD" -net tap,vlan=0,ifname=tap0,script=no,downscript=no"
   if [ x$SOUND != x ]
      VMCMD=$VMCMD" -soundhw "$SOUND
   exec $VMCMD &         
elif [ $ACTION = stop ]
   ifconfig $BRIDGEIF down
   brctl delbr $BRIDGEIF
   ifconfig $GUESTIF down
   tunctl -d $GUESTIF
   ifconfig $HOSTIF
   ifconfig $HOSTIF down
   rmmod dummy
   sleep 5