]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add tests and docs for the new PCI passthrough format
authorDaniel Veillard <veillard@redhat.com>
Mon, 12 Jan 2009 15:09:19 +0000 (15:09 +0000)
committerDaniel Veillard <veillard@redhat.com>
Mon, 12 Jan 2009 15:09:19 +0000 (15:09 +0000)
* 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
docs/formatdomain.html
docs/formatdomain.html.in
docs/libvirt.rng
tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c
tests/qemuxml2xmltest.c

index 853b46d52e04ee515a2d2d567acee59a84049404..d47d67399ce36aaf9aa650d2f1313d39812f5621 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Mon Jan 12 16:07:32 CET 2009 Daniel Veillard <veillard@redhat.com>
+
+       * 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<agx@sigxcpu.org>
 
        * src/qemu_driver.c (qemudLogFD): use snprintf instead of emulating it
index 1a15f5a3448df780a9a8612caace3df96d00d27d..acc63dd54a9aaa83dec07322321fd929dbd50c25 100644 (file)
                 <ul><li>
                     <a href="#elementsDisks">Hard drives, floppy disks, CDROMs</a>
                   </li><li>
-                    <a href="#elementsUSB">USB devices</a>
+                    <a href="#elementsUSB">USB and PCI devices</a>
                   </li><li>
                     <a href="#elementsNICS">Network interfaces</a>
                     <ul><li>
        attribute provides the sub-type. <span class="since">Since 0.1.8</span>
       </dd></dl>
         <h4>
-          <a name="elementsUSB" id="elementsUSB">USB devices</a>
+          <a name="elementsUSB" id="elementsUSB">USB and PCI devices</a>
         </h4>
         <p>
-      USB devices attached to the host can be passed through to the guest using
-      the <code>hostdev</code> element. <span class="since">since after 0.4.4</span>
+      USB and PCI devices attached to the host can be passed through to the guest using
+      the <code>hostdev</code> element. <span class="since">since after
+      0.4.4 for USB and 0.6.0 for PCI (KVM only)</span>:
     </p>
         <pre>
           ...
            &lt;/source&gt;
          &lt;/hostdev&gt;
          ...</pre>
+        <p>or:</p>
+        <pre>
+          ...
+         &lt;hostdev mode='subsystem' type='pci'&gt;
+           &lt;source&gt;
+             &lt;address&gt;bus='0x06' slot='0x02' function='0x0'&lt;/address&gt;
+           &lt;/source&gt;
+         &lt;/hostdev&gt;
+         ...</pre>
         <dl><dt><code>hostdev</code></dt><dd>The <code>hostdev</code> element is the main container for describing
       host devices. For usb device passthrough <code>mode</code> is always
-      "subsystem" and <code>type</code> is "usb".
+      "subsystem" and <code>type</code> is "usb" for an USB device and "pci"
+      for a PCI device..
       </dd><dt><code>source</code></dt><dd>The source element describes the device as seen from the host.
       The USB device can either be addressed by vendor / product id using the
       <code>vendor</code> and <code>product</code> elements or by the device's
-      address on the hosts using the <code>address</code> element.</dd><dt><code>vendor</code>, <code>product</code></dt><dd>The <code>vendor</code> and <code>product</code> elements each have an
+      address on the hosts using the <code>address</code> element.
+      PCI devices on the other hand can only be described by their
+      <code>address</code></dd><dt><code>vendor</code>, <code>product</code></dt><dd>The <code>vendor</code> and <code>product</code> elements each have an
       <code>id</code> 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.</dd><dt><code>address</code></dt><dd>The <code>address</code> element has a <code>bus</code> and
-      <code>device</code> 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.</dd></dl>
+      octal (starting with 0) form.</dd><dt><code>address</code></dt><dd>The <code>address</code> element for USB devices has a
+      <code>bus</code> and <code>device</code> 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 <code>lspci</code> or
+      with <code>virsh nodedev-list</code>. The
+      <code>bus</code> attribute allows the hexadecimal values 0 to ff, the
+      <code>slot</code> attribute allows the hexadecimal values 0 to 1f, and
+      the <code>function</code> attribute allows the hexadecimal values 0 to
+      7. There is also an optional <code>domain</code> attribute for the
+      PCI domain, with hexadecimal values 0 to ffff, but it is currently
+      not used by qemu.</dd></dl>
         <h4>
           <a name="elementsNICS" id="elementsNICS">Network interfaces</a>
         </h4>
index 62235c074f78cb19dd75f5063ece53b6d8556bdd..965262a3443765fdb3006427fcebafced08b940d 100644 (file)
       </dd>
     </dl>
 
-    <h4><a name="elementsUSB">USB devices</a></h4>
+    <h4><a name="elementsUSB">USB and PCI devices</a></h4>
 
     <p>
-      USB devices attached to the host can be passed through to the guest using
-      the <code>hostdev</code> element. <span class="since">since after 0.4.4</span>
+      USB and PCI devices attached to the host can be passed through to the guest using
+      the <code>hostdev</code> element. <span class="since">since after
+      0.4.4 for USB and 0.6.0 for PCI (KVM only)</span>:
     </p>
 
     <pre>
            &lt;/source&gt;
          &lt;/hostdev&gt;
          ...</pre>
+    <p>or:</p>
+    <pre>
+          ...
+         &lt;hostdev mode='subsystem' type='pci'&gt;
+           &lt;source&gt;
+             &lt;address&gt;bus='0x06' slot='0x02' function='0x0'&lt;/address&gt;
+           &lt;/source&gt;
+         &lt;/hostdev&gt;
+         ...</pre>
 
     <dl>
       <dt><code>hostdev</code></dt>
       <dd>The <code>hostdev</code> element is the main container for describing
       host devices. For usb device passthrough <code>mode</code> is always
-      "subsystem" and <code>type</code> is "usb".
+      "subsystem" and <code>type</code> is "usb" for an USB device and "pci"
+      for a PCI device..
       <dt><code>source</code></dt>
       <dd>The source element describes the device as seen from the host.
       The USB device can either be addressed by vendor / product id using the
       <code>vendor</code> and <code>product</code> elements or by the device's
-      address on the hosts using the <code>address</code> element.</dd>
+      address on the hosts using the <code>address</code> element.
+      PCI devices on the other hand can only be described by their
+      <code>address</code></dd>
       <dt><code>vendor</code>, <code>product</code></dt>
       <dd>The <code>vendor</code> and <code>product</code> elements each have an
       <code>id</code> 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.</dd>
       <dt><code>address</code></dt>
-      <dd>The <code>address</code> element has a <code>bus</code> and
-      <code>device</code> 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.</dd>
+      <dd>The <code>address</code> element for USB devices has a
+      <code>bus</code> and <code>device</code> 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 <code>lspci</code> or
+      with <code>virsh nodedev-list</code>. The
+      <code>bus</code> attribute allows the hexadecimal values 0 to ff, the
+      <code>slot</code> attribute allows the hexadecimal values 0 to 1f, and
+      the <code>function</code> attribute allows the hexadecimal values 0 to
+      7. There is also an optional <code>domain</code> attribute for the
+      PCI domain, with hexadecimal values 0 to ffff, but it is currently
+      not used by qemu.</dd>
     </dl>
 
     <h4><a name="elementsNICS">Network interfaces</a></h4>
index 52370640ea1f811244ebef224935ffff1ed2fbb0..6acdbeca5616b669f8494da8b0fdf1042f556a19 100644 (file)
             <choice>
               <ref name="usbproduct"/>
               <ref name="usbaddress"/>
+              <ref name="pciaddress"/>
             </choice>
           </element>
       </group>
     </element>
   </define>
 
+  <define name="pciaddress">
+    <element name="address">
+      <optional>
+        <attribute name="domain">
+          <ref name="pciDomain"/>
+        </attribute>
+      </optional>
+      <attribute name="bus">
+        <ref name="pciBus"/>
+      </attribute>
+      <attribute name="slot">
+        <ref name="pciSlot"/>
+      </attribute>
+      <attribute name="function">
+        <ref name="pciFunc"/>
+      </attribute>
+    </element>
+  </define>
   <!--
       Devices attached to a domain.
     -->
       <param name="pattern">(0x)?[0-9a-fA-F]{1,3}</param>
     </data>
   </define>
+  <define name='pciDomain'>
+    <data type='string'>
+      <param name="pattern">(0x)?[0-9a-fA-F]{1,4}</param>
+    </data>
+  </define>
+  <define name='pciBus'>
+    <data type='string'>
+      <param name="pattern">(0x)?[0-9a-fA-F]{1,2}</param>
+    </data>
+  </define>
+  <define name='pciSlot'>
+    <data type='string'>
+      <param name="pattern">(0x)?[0-1]?[0-9a-fA-F]</param>
+    </data>
+  </define>
+  <define name='pciFunc'>
+    <data type='string'>
+      <param name="pattern">(0x)?[0-7]</param>
+    </data>
+  </define>
 </grammar>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.args
new file mode 100644 (file)
index 0000000..2ad66d1
--- /dev/null
@@ -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 (file)
index 0000000..af2f400
--- /dev/null
@@ -0,0 +1,27 @@
+<domain type='qemu'>
+  <name>QEMUGuest2</name>
+  <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+  <memory>219200</memory>
+  <currentMemory>219200</currentMemory>
+  <vcpu>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest2'/>
+      <target dev='hda' bus='ide'/>
+    </disk>
+    <hostdev mode='subsystem' type='pci'>
+      <source>
+        <address domain='0x0000' bus='0x06' slot='0x12' function='0x5'/>
+      </source>
+    </hostdev>
+  </devices>
+</domain>
index 36288d3f145f29a0764f616e0f40828402d5e0ed..17684fdd9d6f745111868a23a51195bb41202fa3 100644 (file)
@@ -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);
index bc02b5daf728b1810b1e5799917cb940d1919670..e5606094e6a597a9f2c2b964ebb75469002179de 100644 (file)
@@ -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);