Tuesday, January 5, 2010

Converting from Xen to kvm

So my Saturday/Sunday project, after all the good football games were over, was to convert from Xen to kvm here.  I've got six virtual RHEL5 servers running on this host.  Five were no problem at all, and took less than an hour total to convert and reboot.  One more small hint:  comment out

co:2345:respawn:/sbin/agetty xvc0 9600 vt100-nav
in /etc/inittab.  It started respawning rapidly.

The sixth server caused all kinds of problems.  It is, of course, our main production server.

First problem is that using the virt-install --import command imports all of the disks as hdx, on the ide bus.  Fine - unless you have more than four, the maximum number that the ide bus can support.  I'm working on getting these switch over to vdx-type virtio disks, but it's not as simple as I thought it should be, i.e., adding

    <disk device="disk" type="file">
      ...
      <target bus="virtio" dev="vda">
    </target> 

to the .xml file.  Ah, well, I'll keep working on it.  Luckily, the disks that I don't have up are historical files; I've got at least a week.

The other problem was networking.  The way I've got Denman set up is that all traffic goes through a central gateway machine. Only the inside virtual servers and the host are on the 192.168.1.0 network, and can talk to each other directly.  But one of those six new kvm boxes was on the 0.0 network.  In order to get that network up and running, I had to define it on the host.  But if I defined it on the host, then the host could get to the 0.0 network directly, foiling my nice firewall scheme.

The solution took some head-scratching, but I finally came up with this:

DEVICE=br0
BROADCAST=192.168.0.255
IPADDR=192.168.0.130
NETMASK=255.255.255.255

and the secret is the netmask.  It creates the bridge:

[root@defiant ~]# ifconfig
br0       Link encap:Ethernet  HWaddr 00:19:B9:B8:95:F5
          inet addr:192.168.0.130  Bcast:192.168.0.255  Mask:255.255.255.255
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          
but doesn't route it anywhere:

[root@defiant ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     *               255.255.255.0   U     0      0        0 br1
default         saratoga1.denma 0.0.0.0         UG    0      0        0 br1

so the traffic to the 0.0 network still has to go through the gateway.

No comments:

Post a Comment