[libvirt] Supporting hypervisor specific APIs in libvirt

Juan Quintela quintela at redhat.com
Wed Mar 24 08:49:40 UTC 2010

Andi Kleen <andi at firstfloor.org> wrote:
> Juan Quintela <quintela at redhat.com> writes:
>> - networking: man, setting networking is a mess, libvirt just does it
>>   for you.
> Agreed it's messy, but isn't this something that the standard qemu
> command line tool could potentially do better by itself? I don't see why you 
> need a wrapper for that.

In my case, basically it is MAC addresses.  I have dhcp setup, and it
always give the same IP to the same MAC.  But you have to remember to
type the MAC addresses.

This is the typical command line that virsh start launch for me:

/usr/libexec/qemu-kvm -S -M pc-0.12 -enable-kvm -m 1024 -smp
2,sockets=2,cores=1,threads=1 -name f12X-64 -uuid
1fbe73a6-f519-e848-03bd-6636f765d143 -nodefaults -chardev
-mon chardev=monitor,mode=readline -rtc base=utc -boot c -drive
-net tap,fd=18,vlan=0,name=hostnet0 -chardev pty,id=serial0 -device
isa-serial,chardev=serial0 -usb -device usb-tablet,id=input0 -vnc -k es -vga cirrus -device

>From parts:


I don't want that
 -M pc-0.12

I don't care.


I _want_ :)
-m 1024

Also god idea

-smp 2,sockets=2,cores=1,threads=1

by hand it is always "-smp 2"
-name f12X-64

-uuid 1fbe73a6-f519-e848-03bd-6636f765d143

don't care


-mon chardev=monitor,mode=readline

this is simplified as:
  -monitor stdio
when I launch it by hand.

 -rtc base=utc -boot c

don't care

-drive file=/mnt/kvm/images/f12X-64.img,if=none,id=drive-virtio-disk0,boot=on,cache=none
-device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0

this is _wow_, I only want to put the disk image path and convince it to
use virtio driver

-device virtio-net-pci,vlan=0,id=net0,mac=54:52:00:44:72:e6,bus=pci.0,addr=0x5
-net tap,fd=18,vlan=0,name=hostnet0

this always have to be changed. s/fd=18/script=/etc/kvm-ifup/
and then I normally found that I want "downscript=" to avoid the warning
at exit time.  If I don't put a mac address, qemu command line works
well, but as I normally also use vnc I have to:
- launch qemu
- kill it, relaunch with -vnc :0 instead of -vnc
- re-launch qemu
- connect to vnc
- check what address the dhcp server was giving to it this time
- I can ssh to the client now
with libvirt handling the command line, I just ssh to the same dhcp
address that was given the previous time/day/...

-chardev pty,id=serial0 -device isa-serial,chardev=serial0

I only use serial from time to time, and using -serial
tcp:0,server,nowait (or whatever is the sintax is easier by hand)

-usb -device usb-tablet,id=input0

usb tablet is mandatory, just in case the guest is able to _not_ grab
the mouse.


Allways wrong in my case, because I want to run the vnc client in a
different machine.  a way to convince virt-viewer to connect to a qemu
launched by hand, or a way to convince libvirt to let me edit the
command line will be great.

 -k es -vga cirrus

this get right by default.

-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3

I normally don't use balloon.

Notice for the "normally I don't care bits", that at the end I always
care.  Why?  because then somebody arrives and told me that sound don't
work, and I have to edit the config file, and add sound option.  add a
sound option to the command line of qemu is not too complicate.

The other big problem for me are snapshots,  I have to remember
_exactly_ what was the qemu command line with which I saved the
snapshot.  Guess what, I normally don't remember and end:

- launching old qemu
- save a new snapshot
- test with the new qemu and new snapshot (because now I have the
  command line that I launched 5 mins before).

Just in case it helps.

Later, Juan.

More information about the libvir-list mailing list