VectorLinux

Please login or register.

Login with username, password and session length
Advanced search  

News:

Visit our home page for VL info. For support and documentation, visit the Vector Linux Knowledge Center or search the Knowledge Center and this Forum using the search box above.

Author Topic: KVM  (Read 1732 times)

askfor

  • Member
  • *
  • Posts: 33
  • user
KVM
« 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.
 
Logged

askfor

  • Member
  • *
  • Posts: 33
  • user
Re: KVM
« Reply #1 on: September 13, 2015, 03:41:55 pm »

Update: manged to get virt-manager working. Installed pygobject3 package.
Logged

M0E-lnx

  • Administrator
  • Vectorian
  • *****
  • Posts: 3487
Re: KVM
« Reply #2 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
http://vlcoredocumentation.readthedocs.org/en/latest/manuals/docker.html
Our docker images can be found here
http://vlcore.vectorlinux.com/pkg/vlbuildslave/docker-images/

askfor

  • Member
  • *
  • Posts: 33
  • user
Re: KVM
« Reply #3 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.
Logged

M0E-lnx

  • Administrator
  • Vectorian
  • *****
  • Posts: 3487
Re: KVM
« Reply #4 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.

askfor

  • Member
  • *
  • Posts: 33
  • user
Re: KVM
« Reply #5 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.
Logged

askfor

  • Member
  • *
  • Posts: 33
  • user
Re: KVM
« Reply #6 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 libgmime-2.6.so.0.620.0 libgmime-2.4.so.2
Logged

askfor

  • Member
  • *
  • Posts: 33
  • user
Re: KVM
« Reply #7 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.


#!/bin/sh
ACTION=start
VMID=winxp0
#
LIBVIRT_START="/etc/rc.d/rc.libvirt start"
LIBVIRT_STOP="/etc/rc.d/rc.libvirt stop"
# --- network params
HOSTIF=dummy0
GUESTIF=tap0
VUSER=root
BRIDGEIF=br0
GUESTNET=192.168.8.0
GUESTGW=192.168.8.1
GUESTMASK=255.255.255.0
HOSTNET=192.168.1.60
# --- VM params
VMCMD=""
ORDER=""
if [ $VMID=winxp0 ]
then
   SDL="-sdl"
   MEMORY=512
   CDROM=xpsp3.iso
   NIC=rtl8139
   MAC="00:16:35:AF:94:4B"
   SOUND=es1370
   IMG=winxp0.qcow2
   MOUSECAPT="-usbdevice tablet"
fi
# --- start or stop
if [ x${1} = x ]
then
   ACTION=start
else
   ACTION=$1
fi
#
if [ $ACTION = start ] 
then   
   # --- start kvm
   NL=`lsmod | grep "^kvm" | wc -l`
   if [ $NL -ne 2 ]
   then
      $LIBVIRT_START
   fi
   # --- start bridge
   lsmod | grep "^dummy"
   if [ $? -ne 0 ]
   then
      modprobe dummy
   fi
   #       
   tunctl -t $GUESTIF -u $VUSER
   ifconfig $GUESTIF 0.0.0.0 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 ]
   then
      route add -net $GUESTNET netmask $GUESTMASK dev $BRIDGEIF
   fi
   #
   VMCMD="qemu-kvm -enable-kvm "$SDL" -m "$MEMORY 
   if [ x$CDROM != x ]
   then
      VMCMD=$VMCMD" -cdrom "$CDROM
      ORDER=cd
   else
      ORDER=c
   fi
   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 ]
   then
      VMCMD=$VMCMD" -soundhw "$SOUND
   fi
   VMCMD=$VMCMD" "$MOUSECAPT" "$IMG
   exec $VMCMD &         
elif [ $ACTION = stop ]
then
   ifconfig $BRIDGEIF down
   brctl delbr $BRIDGEIF
   #
   ifconfig $GUESTIF down
   tunctl -d $GUESTIF
   ifconfig $HOSTIF 0.0.0.0
   ifconfig $HOSTIF down
   rmmod dummy
   #
   sleep 5
   $LIBVIRT_STOP
fi

« Last Edit: September 20, 2015, 09:16:44 pm by askfor »
Logged