Existing VMs and Virtio network driver

Hi,

I just updated Cloudmin to 4.9, and saw the new possibility to create VMs with virtio network and disk drivers.

But, is it possible to update exsiting VM's with Virtio drivers ?

Thanks,

Miguel.

Status: 
Active

Comments

Do you mean to add a disk using virtIO to an existing VM? Or switch existing disks to virtIO?

Yes, I mean switch disk and network driver to virtio.

The network driver can be switched on the Network Interfaces page, by selecting a different model for eth0.

The disk driver cannot be switched without manually editing the cloudmin config file for the VM, as this also requires that /etc/fstab on the host by modified to use /dev/vda instead of /dev/hda . If you are willing to do this, the steps are :

  1. Edit /etc/fstab on the VM
  2. Shut it down
  3. Get the VM's unique ID with the command cloudmin list-systems --host yourkvminstance --id-only
  4. Edit the file /etc/webmin/servers/XXX.serv , where XXX is the unique ID
  5. In the kvm_drives line , add ,if=virtio to the options for each disk
  6. Start up the VM

This is kind of risky though, as the VM may not boot if the kernel doesn't support virtIO. That's why Cloudmin doesn't currently offer a way to do in via the UI.

Did that for the Network driver. I'll test the hard disk part on a test VM.

Thanks !

Tested it today for disk driver, and it was a no-go... "No bootable disk found" error.

To be able to boot the VM again, I had to mount it's LVM disk on another VM, revert /etc/fstab to "/dev/hda1", and replace "if=virtio" by "if=ide" in the config file.

I tried to create a new VM with virtio, and it's booting correctly on /dev/vda1.

So I guess we're missing something in the steps to migrate a VM from ide to virtio.

P.S : No problem to migrate network driver to virtio, though.

Just had time to investigate a little bit :

on the new VM, wich works with virtio block device, lsmod | grep virtio gives :

virtio_balloon 39877 0

virtio_net 47425 0

virtio_blk 41417 2

virtio_pci 41417 0

virtio_ring 37441 1 virtio_pci

virtio 39365 4 virtio_balloon,virtio_net,virtio_blk,virtio_pci

On the other one, wich didn't work with virtio, the same comman gives :

virtio_net 47424 0

virtio_balloon 39877 0

virtio_pci 41545 0

virtio_ring 37441 1 virtio_pci

virtio 39365 3 virtio_net,virtio_balloon,virtio_pci

So... the virtio block device driver isn't loaded in the kernel. Have to find how to load that kernel module permanently.

P.S: by the way, why does this form remove all CR ? I have to manually add empty lines to prevent it to concat lines... strange.

I just realized that I forgot something in my instructions - when editing the kvm_drives= line, you need to add ,if=virtio,boot=on to allow the system to boot from that disk.

Ok, I'll give a try.

But meanwhile, I found that :

"When switching from IDE to virtio, you need to first build a new initrd in the guest with e.g.:

$> mkinitrd --with virtio_pci --with virtio_blk -f /boot/initrd-$(kernelversion) $(kernelversion)

You only need to do this once. After that, if a new kernel is installed while you're booted off a virtio disk, then mkinitrd will include the modules automatically."

Source : http://www.mail-archive.com/fedora-xen@redhat.com/msg02538.html

Do you think it's relevant in this case ?

Side question : to revert /etc/fstab, I had to attach the image to another VM (I was glad I had a test VM I could reboot). Is there an easy way to mount an VM's LVM Volume on the host, in order to be able to modify files in its filesystem ?

Yes, you might need to build a new initrd. Although I haven't tested this, as I usually do a complete fresh install into a VirtIO VM.

As for access to files, the easiest way is using Cloudmin's command-line API, which can access files even when a virtual machine is down. It does this by mounting the disk image on the host system as needed. See :

http://www.virtualmin.com/documentation/cloudmin/devel/cli

and

http://www.virtualmin.com/documentation/cloudmin/devel/cli/cloudmin_file...

Ok. I'll keep you in touch as soon as I can test again the procedure.