[libvirt-users] can someone explain why the domain, function bus, slot function is used in this xml

I don't understand the domain bus slot fuction in below xml,becase, this is used when deal with management of host devices that can be handed to guests via passthrough as <hostdev> elements in the domain XML.( from http://libvirt.org/formatnode.html) I don't see it use passthrough feature, why it has "domain" bus" slot" and function here <disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/kvm/images/disk/vmname_boot.img'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </disk> <interface type='bridge'> <mac address='52:54:00:07:ab:b0'/> <source bridge='br0'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> which originally comes from this blog: http://blog.allanglesit.com/2011/03/kvm-guests-manipulating-libvirt-xml-for-... Any point?

On Wed, Jan 02, 2013 at 08:31:59PM +0800, lei yang wrote:
I don't understand the domain bus slot fuction in below xml,becase, this is used when deal with management of host devices that can be handed to guests via passthrough as <hostdev> elements in the domain XML.( from http://libvirt.org/formatnode.html)
I don't see it use passthrough feature, why it has "domain" bus" slot" and function here
You're mixing up two different addresses here - host addresses vs guest addresses. Every device added to QEMU has a guest address of some kind, typically either PCI or USB based. This specifies where the device appears to the guest OS. When using host device passthrough, you also need to specify the address of the host PCI device to assign.
<disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/kvm/images/disk/vmname_boot.img'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </disk>
<interface type='bridge'> <mac address='52:54:00:07:ab:b0'/> <source bridge='br0'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface>
These are both guest addresses. They are important, because when you start/stop guests, you want the devices to always have the same address. If the address changed, then some OS like Windows get unhappy and require re-activation. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 1/2/13, Daniel P. Berrange <berrange@redhat.com> wrote:
On Wed, Jan 02, 2013 at 08:31:59PM +0800, lei yang wrote:
I don't understand the domain bus slot fuction in below xml,becase, this is used when deal with management of host devices that can be handed to guests via passthrough as <hostdev> elements in the domain XML.( from http://libvirt.org/formatnode.html)
I don't see it use passthrough feature, why it has "domain" bus" slot" and function here
You're mixing up two different addresses here - host addresses vs guest addresses. Every device added to QEMU has a guest address of some kind, typically either PCI or USB based. This specifies where the device appears to the guest OS. When using host device passthrough, you also need to specify the address of the host PCI device to assign.
<disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/kvm/images/disk/vmname_boot.img'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </disk>
<interface type='bridge'> <mac address='52:54:00:07:ab:b0'/> <source bridge='br0'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface>
These are both guest addresses.
They are important, because when you start/stop guests, you want the devices to always have the same address. If the address changed, then some OS like Windows get unhappy and require re-activation.
Thanks for pointing me for this I have two questiones. 1)I'm using guest as guest,I don't assgin address(disk or nic) to guest,but it works well, any risk here? 2)I don't know how to set the address for guest, or just set a host unused address to guest Lei
Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 01/02/2013 09:43 AM, lei yang wrote:
1)I'm using guest as guest,I don't assgin address(disk or nic) to guest,but it works well, any risk here?
No - libvirt intentionally allows you to omit address assignment when first defining the guest, at which point libvirt will then fill in the information for you, so that future uses of the guest will have an assigned address.
2)I don't know how to set the address for guest, or just set a host unused address to guest
The easiest way is to omit the guest assignment from your XML, and let libvirt manage it. The guest view is completely independent from the host view, so you don't need to worry about address collisions with the host. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Jan 2, 2013 at 8:51 AM, Eric Blake <eblake@redhat.com> wrote:
On 01/02/2013 09:43 AM, lei yang wrote:
1)I'm using guest as guest,I don't assgin address(disk or nic) to guest,but it works well, any risk here?
No - libvirt intentionally allows you to omit address assignment when first defining the guest, at which point libvirt will then fill in the information for you, so that future uses of the guest will have an assigned address.
2)I don't know how to set the address for guest, or just set a host unused address to guest
The easiest way is to omit the guest assignment from your XML, and let libvirt manage it. The guest view is completely independent from the host view, so you don't need to worry about address collisions with the host.
Thanks, I always see some explain assgin them to guest. and use linux as guest. I'm wondering why they don't leave it to libvirt manage it. if they want to assgin it by themselves,Is there a rule to this assginment Lei
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
lei yang