[Libvir] <model>e1000</model> - Specifying model in XML Configs

Hi guys, I just tried to port a few customers over to this libvirt setup i'm hoping to run and I couldn't get their machines started because there's no mechanism to specify a model in the XML! I know redhat have changed KVM's default driver to e1000, which I think is the one I like the most and almost if not all of my VMs use. Ubuntu haven't done that yet however! Is there a model directive in the latest version? In the works? Just so I know which solution I should pursue (updating libvirt or harassing ubuntu to change the default) Thanks, Henri

P.S. I'd take even a hack to get this working in the meantime Henri Cook wrote:
Hi guys,
I just tried to port a few customers over to this libvirt setup i'm hoping to run and I couldn't get their machines started because there's no mechanism to specify a model in the XML!
I know redhat have changed KVM's default driver to e1000, which I think is the one I like the most and almost if not all of my VMs use. Ubuntu haven't done that yet however!
Is there a model directive in the latest version? In the works? Just so I know which solution I should pursue (updating libvirt or harassing ubuntu to change the default)
Thanks,
Henri
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Mon, Apr 07, 2008 at 10:51:56PM +0100, Henri Cook wrote:
I just tried to port a few customers over to this libvirt setup i'm hoping to run and I couldn't get their machines started because there's no mechanism to specify a model in the XML!
I know redhat have changed KVM's default driver to e1000, which I think is the one I like the most and almost if not all of my VMs use. Ubuntu haven't done that yet however!
Is there a model directive in the latest version? In the works? Just so I know which solution I should pursue (updating libvirt or harassing ubuntu to change the default)
There isn't a way to select the model, but there ought to be. In KVM 64 the following NIC models are supported: i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio Part of the problem with implementing this will be validating the model (unless we just pass the model string directly to qemu which could lead to errors). The documentation suggests running qemu with '-net nic,model=?' to list the models, and there is code in qemu/hw/pci.c to implement this, but it just doesn't work for me. $ qemu-kvm -net nic,model=? [ prints full help because of the missing hda parameter ] $ qemu-kvm -net nic,model=? hda=/dev/null open /dev/kvm: Permission denied Could not initialize KVM, will disable KVM support Warning: vlan 0 is not connected to host network qemu: could not open disk image hda=/dev/null $ qemu-kvm -net nic,model=? hda=/dev/zero open /dev/kvm: Permission denied Could not initialize KVM, will disable KVM support Warning: vlan 0 is not connected to host network qemu: could not open disk image hda=/dev/zero $ touch /tmp/file $ qemu-kvm -net nic,model=? hda=/tmp/file open /dev/kvm: Permission denied Could not initialize KVM, will disable KVM support Warning: vlan 0 is not connected to host network qemu: could not open disk image hda=/tmp/file $ dd if=/dev/zero of=/tmp/file bs=1024 count=1024 1024+0 records in 1024+0 records out 1048576 bytes (1.0 MB) copied, 0.00765395 s, 137 MB/s $ qemu-kvm -net nic,model=? hda=/tmp/file open /dev/kvm: Permission denied Could not initialize KVM, will disable KVM support Warning: vlan 0 is not connected to host network qemu: could not open disk image hda=/tmp/file Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top

On Tue, Apr 08, 2008 at 09:05:41AM +0100, Richard W.M. Jones wrote:
On Mon, Apr 07, 2008 at 10:51:56PM +0100, Henri Cook wrote:
I just tried to port a few customers over to this libvirt setup i'm hoping to run and I couldn't get their machines started because there's no mechanism to specify a model in the XML!
I know redhat have changed KVM's default driver to e1000, which I think is the one I like the most and almost if not all of my VMs use. Ubuntu haven't done that yet however!
Is there a model directive in the latest version? In the works? Just so I know which solution I should pursue (updating libvirt or harassing ubuntu to change the default)
There isn't a way to select the model, but there ought to be. In KVM 64 the following NIC models are supported:
i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio
Part of the problem with implementing this will be validating the model (unless we just pass the model string directly to qemu which could lead to errors). The documentation suggests running qemu with '-net nic,model=?' to list the models, and there is code in qemu/hw/pci.c to implement this, but it just doesn't work for me.
Then what happen if you pass a wrong string ? Is there any way to get a meaningful error back from qemu and report it. Thet would IMHO be quite better than tracking the evolution of the emulation in QEmu, plus the added benefit of not being tied to a strict version of QEmu, Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Tue, Apr 08, 2008 at 04:45:23AM -0400, Daniel Veillard wrote:
Then what happen if you pass a wrong string ? Is there any way to get a meaningful error back from qemu and report it. Thet would IMHO be quite better than tracking the evolution of the emulation in QEmu, plus the added benefit of not being tied to a strict version of QEmu,
The error handling in this part of the code seems a bit confused at the moment. For example: if (virExecNonBlock(conn, argv, &vm->pid, vm->stdin, &vm->stdout, &vm->stderr) == 0) { /* [add new qemu to list of VMs] */ } /* [free up various resources] */ if (virEventAddHandle(vm->stdout, POLLIN | POLLERR | POLLHUP, qemudDispatchVMEvent, driver) < 0) { qemudShutdownVMDaemon(conn, driver, vm); return -1; } /* [another call to virEventAddHandle] */ if (qemudWaitForMonitor(conn, driver, vm) < 0) { qemudShutdownVMDaemon(conn, driver, vm); return -1; } return 0; If virExecNonBlock fails, because one of the system calls such as fork(2) or pipe(2) fails, then vm->stdout may be uninitialized. I think it will assume the value 0 in this case and virEventAddHandle will quite happily register a handler for fd 0. On the other hand it is tricky to know what to do when launching a process. In the case where KVM doesn't understand part of the command line arguments, the fork & exec will both succeed and the earliest point where we will see any error will be at qemudWaitForMonitor (because the monitor won't come up -- note this code is synchronous). Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top

I've made a hack for this in the meantime that adds the <model></model> option to the <interface> section and allows me to pass in any string for addition - since I really wanted this functionality. Obviously this means i'm now compiling my Ubuntu package from source which isn't ideal, it'll probably get overwritten by apt at any moment :o Also, i got in a bit of a pickle last night which I had to reboot to fix: root@mintaka:~# /usr/sbin/libvirtd -d libvir: QEMU error : cannot create bridge 'virbr0' : File exists Failed to autostart network 'default': cannot create bridge 'virbr0' : File exists Is there a way to fix this without rebooting? ifconfig virbr0 0.0.0.0 down && brctl delbr virbr0 - doesn't seem to be enough, what did I miss? On the <model> options - an error message does seem like the best option: with model=foo in the -net options qemu: Unsupported NIC: foo I'd love to put all that in myself but my C-fu is seriously limited - I can only do simple work without more time to learn things properly, like adding things to the XML based on all the previous examples *g* Cheers, Henri Daniel Veillard wrote:
On Tue, Apr 08, 2008 at 09:05:41AM +0100, Richard W.M. Jones wrote:
On Mon, Apr 07, 2008 at 10:51:56PM +0100, Henri Cook wrote:
I just tried to port a few customers over to this libvirt setup i'm hoping to run and I couldn't get their machines started because there's no mechanism to specify a model in the XML!
I know redhat have changed KVM's default driver to e1000, which I think is the one I like the most and almost if not all of my VMs use. Ubuntu haven't done that yet however!
Is there a model directive in the latest version? In the works? Just so I know which solution I should pursue (updating libvirt or harassing ubuntu to change the default)
There isn't a way to select the model, but there ought to be. In KVM 64 the following NIC models are supported:
i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio
Part of the problem with implementing this will be validating the model (unless we just pass the model string directly to qemu which could lead to errors). The documentation suggests running qemu with '-net nic,model=?' to list the models, and there is code in qemu/hw/pci.c to implement this, but it just doesn't work for me.
Then what happen if you pass a wrong string ? Is there any way to get a meaningful error back from qemu and report it. Thet would IMHO be quite better than tracking the evolution of the emulation in QEmu, plus the added benefit of not being tied to a strict version of QEmu,
Daniel

On Tue, Apr 08, 2008 at 10:19:02AM +0100, Henri Cook wrote:
I've made a hack for this in the meantime that adds the <model></model>
You have a patch?
Is there a way to fix this without rebooting? ifconfig virbr0 0.0.0.0 down && brctl delbr virbr0 - doesn't seem to be enough, what did I miss?
This should be enough to get rid of the bridge, but if not then you need to look at the error messages and the output of 'brctl show'. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top

There's nothing in brctl show for virbr0 - br0 still exists but that's in use (And shouldn't be causing the problem?) Maybe it's a one off - i'll try to recreate It could be a patch, maybe, I think bits of it are really bad C (i.e. hackery at its worst) - i'll make sure it works then see if i can merge it with source - unless someone who knows more and can do the error checking beats me too it, it's only about 6 lines Cheers, Henri Richard W.M. Jones wrote:
On Tue, Apr 08, 2008 at 10:19:02AM +0100, Henri Cook wrote:
I've made a hack for this in the meantime that adds the <model></model>
You have a patch?
Is there a way to fix this without rebooting? ifconfig virbr0 0.0.0.0 down && brctl delbr virbr0 - doesn't seem to be enough, what did I miss?
This should be enough to get rid of the bridge, but if not then you need to look at the error messages and the output of 'brctl show'.
Rich.

Sorry - I tried to make a patch, but it appears it makes libvirtd segfault (it starts but when i try to use virsh -c qemu:///system create vm.cfg it segfaults). Also - when building my own copy of libvirt - I can connect via virsh -c qemu:///system, but just 'virsh' says it cannot connect to the hypervisor - any idea what could cause that? I'm root at the time As I said, my C-fu is weak - it's probably not useable, if anyone feels really generous i'd appreciate some criticism, otherwise probably best if one of you guys made it :p I think for the meantime i'm going to hard code model=e1000 into my build, since all my VMs will use that (no windows ones) Henri Richard W.M. Jones wrote:
On Tue, Apr 08, 2008 at 10:19:02AM +0100, Henri Cook wrote:
I've made a hack for this in the meantime that adds the <model></model>
You have a patch?
Is there a way to fix this without rebooting? ifconfig virbr0 0.0.0.0 down && brctl delbr virbr0 - doesn't seem to be enough, what did I miss?
This should be enough to get rid of the bridge, but if not then you need to look at the error messages and the output of 'brctl show'.
Rich.

Quoting "Richard W.M. Jones" <rjones@redhat.com>:
On Mon, Apr 07, 2008 at 10:51:56PM +0100, Henri Cook wrote:
I just tried to port a few customers over to this libvirt setup i'm hoping to run and I couldn't get their machines started because there's no mechanism to specify a model in the XML!
I know redhat have changed KVM's default driver to e1000, which I think is the one I like the most and almost if not all of my VMs use. Ubuntu haven't done that yet however!
Is there a model directive in the latest version? In the works? Just so I know which solution I should pursue (updating libvirt or harassing ubuntu to change the default)
There isn't a way to select the model, but there ought to be. In KVM 64 the following NIC models are supported:
i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio
Part of the problem with implementing this will be validating the model (unless we just pass the model string directly to qemu which could lead to errors). The documentation suggests running qemu with '-net nic,model=?' to list the models, and there is code in qemu/hw/pci.c to implement this, but it just doesn't work for me.
$ qemu-kvm -net nic,model=?
[ prints full help because of the missing hda parameter ]
$ qemu-kvm -net nic,model=? hda=/dev/null open /dev/kvm: Permission denied Could not initialize KVM, will disable KVM support Warning: vlan 0 is not connected to host network qemu: could not open disk image hda=/dev/null
$ qemu-kvm -net nic,model=? hda=/dev/zero open /dev/kvm: Permission denied Could not initialize KVM, will disable KVM support Warning: vlan 0 is not connected to host network qemu: could not open disk image hda=/dev/zero
$ touch /tmp/file $ qemu-kvm -net nic,model=? hda=/tmp/file open /dev/kvm: Permission denied Could not initialize KVM, will disable KVM support Warning: vlan 0 is not connected to host network qemu: could not open disk image hda=/tmp/file
$ dd if=/dev/zero of=/tmp/file bs=1024 count=1024 1024+0 records in 1024+0 records out 1048576 bytes (1.0 MB) copied, 0.00765395 s, 137 MB/s $ qemu-kvm -net nic,model=? hda=/tmp/file open /dev/kvm: Permission denied Could not initialize KVM, will disable KVM support Warning: vlan 0 is not connected to host network qemu: could not open disk image hda=/tmp/file
The same error happens in KVM and Qemu (not qemu-kvm) on Ubuntu. I'd say the problem belongs to Qemu, not to KVM. -- Pau Garcia i Quiles http://www.elpauer.org (Due to my workload, I may need 10 days to answer)

Henri Cook wrote:
Hi guys,
I just tried to port a few customers over to this libvirt setup i'm hoping to run and I couldn't get their machines started because there's no mechanism to specify a model in the XML!
I know redhat have changed KVM's default driver to e1000, which I think is the one I like the most and almost if not all of my VMs use. Ubuntu haven't done that yet however!
Is there a model directive in the latest version? In the works? Just so I know which solution I should pursue (updating libvirt or harassing ubuntu to change the default)
Hi, I posted a series of patches to do this last year: http://www.mail-archive.com/libvir-list@redhat.com/msg03554.html It generated some discussion but AFAIK didn't go anywhere. Henri, if you want a quick hack to add specific options to kvm, you can just specify a script as the KVM binary and have it add or modify arguments as you wish. For example, I used: #!/bin/bash i=0 ARGV=("$@") while [ $i -lt $# ] ; do # Use rtl8139 network card instead of default ne2k_pci ARGV[$i]=${ARGV[$i]/#nic/nic,model=rtl8139} i=$((i+1)) done exec /usr/bin/kvm ${ARGV[@]} -jim
participants (5)
-
Daniel Veillard
-
Henri Cook
-
Jim Paris
-
Pau Garcia i Quiles
-
Richard W.M. Jones