From c8ef64bdd74af25f26f9ff5679b2515097293e3a Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Mon, 12 Jan 2009 15:09:19 +0000 Subject: [PATCH] Add tests and docs for the new PCI passthrough format * docs/formatdomain.html.in docs/libvirt.rng docs/formatdomain.html: document the new PCI passthrough format * tests/qemuxml2argvtest.c tests/qemuxml2xmltest.c tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.args tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.xml: and add a regression test for it. Daniel --- ChangeLog | 9 ++++ docs/formatdomain.html | 44 ++++++++++++++----- docs/formatdomain.html.in | 42 +++++++++++++----- docs/libvirt.rng | 39 ++++++++++++++++ .../qemuxml2argv-hostdev-pci-address.args | 1 + .../qemuxml2argv-hostdev-pci-address.xml | 27 ++++++++++++ tests/qemuxml2argvtest.c | 2 + tests/qemuxml2xmltest.c | 1 + 8 files changed, 144 insertions(+), 21 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.xml diff --git a/ChangeLog b/ChangeLog index 853b46d52e..d47d67399c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Mon Jan 12 16:07:32 CET 2009 Daniel Veillard + + * docs/formatdomain.html.in docs/libvirt.rng docs/formatdomain.html: + document the new PCI passthrough format + * tests/qemuxml2argvtest.c tests/qemuxml2xmltest.c + tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.args + tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.xml: + and add a regression test for it. + Sun Jan 11 12:18:38 CET 2009 Guido Günther * src/qemu_driver.c (qemudLogFD): use snprintf instead of emulating it diff --git a/docs/formatdomain.html b/docs/formatdomain.html index 1a15f5a344..acc63dd54a 100644 --- a/docs/formatdomain.html +++ b/docs/formatdomain.html @@ -140,7 +140,7 @@
  • Hard drives, floppy disks, CDROMs
  • - USB devices + USB and PCI devices
  • Network interfaces
    • @@ -464,11 +464,12 @@ attribute provides the sub-type. Since 0.1.8

      - USB devices + USB and PCI devices

      - USB devices attached to the host can be passed through to the guest using - the hostdev element. since after 0.4.4 + USB and PCI devices attached to the host can be passed through to the guest using + the hostdev element. since after + 0.4.4 for USB and 0.6.0 for PCI (KVM only):

                 ...
      @@ -479,20 +480,41 @@
       	    </source>
       	  </hostdev>
       	  ...
      +

      or:

      +
      +          ...
      +	  <hostdev mode='subsystem' type='pci'>
      +	    <source>
      +	      <address>bus='0x06' slot='0x02' function='0x0'</address>
      +	    </source>
      +	  </hostdev>
      +	  ...
      hostdev
      The hostdev element is the main container for describing host devices. For usb device passthrough mode is always - "subsystem" and type is "usb". + "subsystem" and type is "usb" for an USB device and "pci" + for a PCI device..
      source
      The source element describes the device as seen from the host. The USB device can either be addressed by vendor / product id using the vendor and product elements or by the device's - address on the hosts using the address element.
      vendor, product
      The vendor and product elements each have an + address on the hosts using the address element. + PCI devices on the other hand can only be described by their + address
      vendor, product
      The vendor and product elements each have an id attribute that specifies the USB vendor and product id. The ids can be given in decimal, hexadecimal (starting with 0x) or - octal (starting with 0) form.
      address
      The address element has a bus and - device attribute to specify the USB bus and device number - the device appears at on the host. The values of these attributes can - be given in decimal, hexadecimal (starting with 0x) or octal (starting - with 0) form.
      + octal (starting with 0) form.
      address
      The address element for USB devices has a + bus and device attribute to specify the + USB bus and device number the device appears at on the host. + The values of these attributes can be given in decimal, hexadecimal + (starting with 0x) or octal (starting with 0) form. + For PCI devices the element carries 3 attributes allowing to designate + the device as can be found with the lspci or + with virsh nodedev-list. The + bus attribute allows the hexadecimal values 0 to ff, the + slot attribute allows the hexadecimal values 0 to 1f, and + the function attribute allows the hexadecimal values 0 to + 7. There is also an optional domain attribute for the + PCI domain, with hexadecimal values 0 to ffff, but it is currently + not used by qemu.

      Network interfaces

      diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 62235c074f..965262a344 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -375,11 +375,12 @@ -

      USB devices

      +

      USB and PCI devices

      - USB devices attached to the host can be passed through to the guest using - the hostdev element. since after 0.4.4 + USB and PCI devices attached to the host can be passed through to the guest using + the hostdev element. since after + 0.4.4 for USB and 0.6.0 for PCI (KVM only):

      @@ -391,28 +392,49 @@
       	    </source>
       	  </hostdev>
       	  ...
      +

      or:

      +
      +          ...
      +	  <hostdev mode='subsystem' type='pci'>
      +	    <source>
      +	      <address>bus='0x06' slot='0x02' function='0x0'</address>
      +	    </source>
      +	  </hostdev>
      +	  ...
      hostdev
      The hostdev element is the main container for describing host devices. For usb device passthrough mode is always - "subsystem" and type is "usb". + "subsystem" and type is "usb" for an USB device and "pci" + for a PCI device..
      source
      The source element describes the device as seen from the host. The USB device can either be addressed by vendor / product id using the vendor and product elements or by the device's - address on the hosts using the address element.
      + address on the hosts using the address element. + PCI devices on the other hand can only be described by their + address
      vendor, product
      The vendor and product elements each have an id attribute that specifies the USB vendor and product id. The ids can be given in decimal, hexadecimal (starting with 0x) or octal (starting with 0) form.
      address
      -
      The address element has a bus and - device attribute to specify the USB bus and device number - the device appears at on the host. The values of these attributes can - be given in decimal, hexadecimal (starting with 0x) or octal (starting - with 0) form.
      +
      The address element for USB devices has a + bus and device attribute to specify the + USB bus and device number the device appears at on the host. + The values of these attributes can be given in decimal, hexadecimal + (starting with 0x) or octal (starting with 0) form. + For PCI devices the element carries 3 attributes allowing to designate + the device as can be found with the lspci or + with virsh nodedev-list. The + bus attribute allows the hexadecimal values 0 to ff, the + slot attribute allows the hexadecimal values 0 to 1f, and + the function attribute allows the hexadecimal values 0 to + 7. There is also an optional domain attribute for the + PCI domain, with hexadecimal values 0 to ffff, but it is currently + not used by qemu.

      Network interfaces

      diff --git a/docs/libvirt.rng b/docs/libvirt.rng index 52370640ea..6acdbeca56 100644 --- a/docs/libvirt.rng +++ b/docs/libvirt.rng @@ -890,6 +890,7 @@ + @@ -920,6 +921,24 @@ + + + + + + + + + + + + + + + + + + @@ -1069,4 +1088,24 @@ (0x)?[0-9a-fA-F]{1,3} + + + (0x)?[0-9a-fA-F]{1,4} + + + + + (0x)?[0-9a-fA-F]{1,2} + + + + + (0x)?[0-1]?[0-9a-fA-F] + + + + + (0x)?[0-7] + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.args new file mode 100644 index 0000000000..2ad66d1c47 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -pidfile /nowhere/QEMUGuest2.pid -no-acpi -boot c -hda /dev/HostVG/QEMUGuest2 -net none -serial none -parallel none -usb -pcidevice host=06:12.5 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.xml new file mode 100644 index 0000000000..af2f400b0b --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.xml @@ -0,0 +1,27 @@ + + QEMUGuest2 + c7a5fdbd-edaf-9466-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + +
      + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 36288d3f14..17684fdd9d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -224,6 +224,8 @@ mymain(int argc, char **argv) DO_TEST("hostdev-usb-product", 0); DO_TEST("hostdev-usb-address", 0); + DO_TEST("hostdev-pci-address", 0); + virCapabilitiesFree(driver.caps); return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index bc02b5daf7..e5606094e6 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -123,6 +123,7 @@ mymain(int argc, char **argv) DO_TEST("hostdev-usb-product"); DO_TEST("hostdev-usb-address"); + DO_TEST("hostdev-pci-address"); virCapabilitiesFree(driver.caps);