[PATCH 1/2] Introduce pci-serial

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



https://bugzilla.redhat.com/show_bug.cgi?id=998813

Like usb-serial, the pci-serial device allows a serial device to be
attached to PCI bus. An example XML looks like this:

  <serial type='dev'>
    <source path='/dev/ttyS2'/>
    <target type='pci-serial' port='0'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
  </serial>

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 docs/formatdomain.html.in                          | 16 ++++++----
 docs/schemas/domaincommon.rng                      |  1 +
 src/conf/domain_conf.c                             |  3 +-
 src/conf/domain_conf.h                             |  1 +
 .../qemuxml2argv-pci-serial-dev-chardev.xml        | 37 ++++++++++++++++++++++
 tests/qemuxml2xmltest.c                            |  1 +
 6 files changed, 52 insertions(+), 7 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pci-serial-dev-chardev.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index e0b6ba7..b61798a 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5107,12 +5107,16 @@ qemu-kvm -net nic,model=? /dev/null
       specifies the port number. Ports are numbered starting from 0. There are
       usually 0, 1 or 2 serial ports. There is also an optional
       <code>type</code> attribute <span class="since">since 1.0.2</span>
-      which has two choices for its value, one is <code>isa-serial</code>,
-      the other is <code>usb-serial</code>. If <code>type</code> is missing,
-      <code>isa-serial</code> will be used by default. For <code>usb-serial</code>
-      an optional sub-element <code>&lt;address&gt;</code> with
-      <code>type='usb'</code> can tie the device to a particular controller,
-      <a href="#elementsAddress">documented above</a>.
+      which has three choices for its value, one is <code>isa-serial</code>,
+      then <code>usb-serial</code> and last one is <code>pci-serial</code>.
+      If <code>type</code> is missing, <code>isa-serial</code> will be used by
+      default. For <code>usb-serial</code> an optional sub-element
+      <code>&lt;address/&gt;</code> with <code>type='usb'</code> can tie the
+      device to a particular controller, <a href="#elementsAddress">documented above</a>.
+      Similarly, <code>pci-serial</code> can be used to attach the device to
+      the pci bus (<span class="since">since 1.2.16</span>). Again, it has
+      optional sub-element <code>&lt;address/&gt;</code> with
+      <code>type='pci'</code> to select desired location on the PCI bus.
     </p>
 
     <h6><a name="elementCharConsole">Console</a></h6>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index c151e92..f3cb37a 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3055,6 +3055,7 @@
       <choice>
         <value>isa-serial</value>
         <value>usb-serial</value>
+        <value>pci-serial</value>
       </choice>
     </attribute>
   </define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4cd36a1..6c60c4e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -407,7 +407,8 @@ VIR_ENUM_IMPL(virDomainChrDeviceState, VIR_DOMAIN_CHR_DEVICE_STATE_LAST,
 VIR_ENUM_IMPL(virDomainChrSerialTarget,
               VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST,
               "isa-serial",
-              "usb-serial")
+              "usb-serial",
+              "pci-serial")
 
 VIR_ENUM_IMPL(virDomainChrChannelTarget,
               VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 087d282..55d0b98 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1076,6 +1076,7 @@ typedef enum {
 typedef enum {
     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA = 0,
     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB,
+    VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI,
 
     VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST
 } virDomainChrSerialTargetType;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-serial-dev-chardev.xml b/tests/qemuxml2argvdata/qemuxml2argv-pci-serial-dev-chardev.xml
new file mode 100644
index 0000000..a058e38
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-serial-dev-chardev.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>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/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <serial type='dev'>
+      <source path='/dev/ttyS2'/>
+      <target type='pci-serial' port='0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </serial>
+    <console type='dev'>
+      <source path='/dev/ttyS2'/>
+      <target type='serial' port='0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </console>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index b611afd..1fa980f 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -479,6 +479,7 @@ mymain(void)
     DO_TEST("hostdev-pci-address");
     DO_TEST("hostdev-vfio");
     DO_TEST("pci-rom");
+    DO_TEST("pci-serial-dev-chardev");
 
     DO_TEST("encrypted-disk");
     DO_TEST_DIFFERENT("memtune");
-- 
2.3.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]