[libvirt] libvirt equivalent config for a kvm command line

Rajkumar S rajkumars at gmail.com
Thu Nov 20 14:09:46 UTC 2008


Hi,

I had been running kvm in a previous version of Ubuntu with the
following command line:

 /usr/bin/kvm
-hda /mnt/kvm/vm-images-work/nanobsd.img
-net nic,vlan=26,macaddr=52:54:00:12:34:26 -net tap,vlan=26,ifname=tap26
-net nic,vlan=27,macaddr=52:54:00:12:34:27 -net tap,vlan=27,ifname=tap27
-net nic,vlan=28,macaddr=52:54:00:12:34:28 -net tap,vlan=28,ifname=tap28
-m 640 -vnc :26 -usbdevice tablet

The vm shows couple if lines in console and then redirects rest of the
output to serial console. I can see that in ctrl-alt-3 of vncviewer
ctrl-alt-2 gives access to emulation console and 4 gives access to
parallel console.

After upgrading to latest Intrepid Ibex I decided to move to using
virsh to manage my vms. For the above vm I am using the following xml
file.

<domain type='kvm'>
  <name>nanobsd</name>
  <memory>262144</memory>
  <currentMemory>262144</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='localtime'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='disk'>
      <source file='/mnt/kvm/vm-images-work/nanotest.img'/>
      <target dev='hda' bus='ide'/>
    </disk>
    <interface type='bridge'>
      <mac address='52:54:00:12:34:31'/>
      <source bridge='br0'/>
    </interface>
    <interface type='bridge'>
      <mac address='52:54:00:12:34:32'/>
      <source bridge='br0'/>
    </interface>
    <interface type='bridge'>
      <mac address='52:54:00:12:34:33'/>
      <source bridge='br0'/>
    </interface>
    <serial type='vc'>
      <target port='2'/>
    </serial>
    <console type='pty'>
      <target port='0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5931' listen='192.168.3.3'/>
  </devices>
</domain>

Which produces the following command line.

 /usr/bin/kvm -S -M pc -m 256 -smp 1 -name nanobsd -monitor pty
-localtime -boot c
-drive file=/mnt/kvm/vm-images-work/nanotest.img,if=ide,index=0,boot=on
-net nic,macaddr=52:54:00:12:34:31,vlan=0 -net
tap,fd=28,script=,vlan=0,ifname=vnet5
-net nic,macaddr=52:54:00:12:34:32,vlan=1 -net
tap,fd=29,script=,vlan=1,ifname=vnet6
-net nic,macaddr=52:54:00:12:34:33,vlan=2 -net
tap,fd=30,script=,vlan=2,ifname=vnet7
-serial vc -parallel none -usb -vnc  192.168.3.3:31

Problem with this configuration is that the screen freezes after
couple of minuets of booting, I am not sure if this is the problem
with the serial console or actual execution. I can see the serial
console in ctrl-alt-2, but the window size changes. The image works
perfectly in normal PC as well as if I use the previous command line.
I guess I am missing some thing here, but I would be very happy if I
can get the old behaviour back :)

raj




More information about the libvir-list mailing list