]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Implement pci-serial
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 6 May 2015 15:50:03 +0000 (17:50 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 21 May 2015 15:49:02 +0000 (17:49 +0200)
https://bugzilla.redhat.com/show_bug.cgi?id=998813

Implementation is pretty straight-forward. Of course, not all qemus
out there supports the device, so new capability is introduced and
checked prior each use of the device.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_capabilities.c
src/qemu/qemu_capabilities.h
src/qemu/qemu_command.c
tests/qemucapabilitiesdata/caps_1.3.1-1.caps
tests/qemucapabilitiesdata/caps_1.4.2-1.caps
tests/qemucapabilitiesdata/caps_1.5.3-1.caps
tests/qemucapabilitiesdata/caps_1.6.0-1.caps
tests/qemucapabilitiesdata/caps_1.6.50-1.caps
tests/qemucapabilitiesdata/caps_2.1.1-1.caps
tests/qemuxml2argvdata/qemuxml2argv-pci-serial-dev-chardev.args [new file with mode: 0644]
tests/qemuxml2argvtest.c

index 2757636cfc24f3c3a517ae8cab5e92e4f02ca7d8..375df22345c75aba662d78d185d8b5c7ee7f396b 100644 (file)
@@ -283,6 +283,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               "machine-vmport-opt", /* 185 */
               "aes-key-wrap",
               "dea-key-wrap",
+              "pci-serial",
     );
 
 
@@ -1539,6 +1540,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
     { "iothread", QEMU_CAPS_OBJECT_IOTHREAD},
     { "ivshmem", QEMU_CAPS_DEVICE_IVSHMEM },
     { "pc-dimm", QEMU_CAPS_DEVICE_PC_DIMM },
+    { "pci-serial", QEMU_CAPS_DEVICE_PCI_SERIAL },
 };
 
 static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {
index 4da9637fd567df84dcc849d15e6036a5064ab61b..9c956f3007be74845f03cb43cf90ae18ec21e05c 100644 (file)
@@ -227,6 +227,7 @@ typedef enum {
     QEMU_CAPS_MACHINE_VMPORT_OPT = 185, /* -machine xxx,vmport=on/off/auto */
     QEMU_CAPS_AES_KEY_WRAP       = 186, /* -machine aes_key_wrap */
     QEMU_CAPS_DEA_KEY_WRAP       = 187, /* -machine dea_key_wrap */
+    QEMU_CAPS_DEVICE_PCI_SERIAL  = 188, /* -device pci-serial */
 
     QEMU_CAPS_LAST,                   /* this must always be the last item */
 } virQEMUCapsFlags;
index 30597087d8b71e16929ed0da9d5a13308d567afb..81e89fc7f3882f7aeec737292df0cd0fd59800c7 100644 (file)
@@ -2312,6 +2312,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
  *  - VirtIO balloon
  *  - Host device passthrough
  *  - Watchdog (not IB700)
+ *  - pci serial devices
  *
  * Prior to this function being invoked, qemuCollectPCIAddress() will have
  * added all existing PCI addresses from the 'def' to 'addrs'. Thus this
@@ -2584,7 +2585,16 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
         /* Nada - none are PCI based (yet) */
     }
     for (i = 0; i < def->nserials; i++) {
-        /* Nada - none are PCI based (yet) */
+        virDomainChrDefPtr chr = def->serials[i];
+
+        if (chr->targetType != VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI)
+            continue;
+
+        if (chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
+            continue;
+
+        if (virDomainPCIAddressReserveNextSlot(addrs, &chr->info, flags) < 0)
+            goto error;
     }
     for (i = 0; i < def->nchannels; i++) {
         /* Nada - none are PCI based (yet) */
@@ -10932,6 +10942,24 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
                 goto error;
             }
             break;
+
+        case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI:
+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCI_SERIAL)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("pci-serial is not supported with this QEMU binary"));
+                goto error;
+            }
+
+            if (serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+                serial->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("pci-serial requires address of pci type"));
+                goto error;
+            }
+
+            if (qemuBuildDeviceAddressStr(&cmd, def, &serial->info, qemuCaps) < 0)
+                goto error;
+            break;
         }
     }
 
index 68bed9fc6d411c9bf17a3c940fbfd8a239d03e05..ea3d850dd6a4fe9d17f65dab37d93be6a59c88f4 100644 (file)
     <flag name='vmware-svga.vgamem_mb'/>
     <flag name='qxl.vgamem_mb'/>
     <flag name='qxl-vga.vgamem_mb'/>
+    <flag name='pci-serial'/>
   </qemuCaps>
index baf2e77da28d5bffb128e06eb3477f6de2cc7e01..2c19ddc644c3185a41e7ffdd4bd0161e3adbbd1f 100644 (file)
     <flag name='vmware-svga.vgamem_mb'/>
     <flag name='qxl.vgamem_mb'/>
     <flag name='qxl-vga.vgamem_mb'/>
+    <flag name='pci-serial'/>
   </qemuCaps>
index 496f3051e1b6690fc5856a731f41f8ddab32da49..aadccd5e4379f72b9dd66ba7b44e993761b062bd 100644 (file)
     <flag name='vmware-svga.vgamem_mb'/>
     <flag name='qxl.vgamem_mb'/>
     <flag name='qxl-vga.vgamem_mb'/>
+    <flag name='pci-serial'/>
   </qemuCaps>
index 38333a6b817bb68fd88b5e780a61ad4e19baf36a..3e81cbfe06b893178be55f319af9fc00e94bd54f 100644 (file)
     <flag name='vmware-svga.vgamem_mb'/>
     <flag name='qxl.vgamem_mb'/>
     <flag name='qxl-vga.vgamem_mb'/>
+    <flag name='pci-serial'/>
   </qemuCaps>
index b093e0869bab7e97abef85b0b1e75fcab8cb6c17..84c357f73557501404b12b54cdc92f650ae64b29 100644 (file)
     <flag name='vmware-svga.vgamem_mb'/>
     <flag name='qxl.vgamem_mb'/>
     <flag name='qxl-vga.vgamem_mb'/>
+    <flag name='pci-serial'/>
   </qemuCaps>
index 5637edb86cc9bbff720b763089640de653307855..b1ee8df1d94382f6f4433ee4f71f82c82eda573a 100644 (file)
     <flag name='qxl.vgamem_mb'/>
     <flag name='qxl-vga.vgamem_mb'/>
     <flag name='pc-dimm'/>
+    <flag name='pci-serial'/>
   </qemuCaps>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-serial-dev-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-pci-serial-dev-chardev.args
new file mode 100644 (file)
index 0000000..36cb067
--- /dev/null
@@ -0,0 +1,7 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline -no-acpi -boot c -usb \
+-hda /dev/HostVG/QEMUGuest1 -chardev tty,id=charserial0,path=/dev/ttyS2 \
+-device pci-serial,chardev=charserial0,id=serial0,bus=pci.0,addr=0x4 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
index 06f0417a0bbddf8c5b511b5c8c367b4c76c42b0b..958f786f70530e15aa09797b2a8a0c5f5680102d 100644 (file)
@@ -1060,6 +1060,9 @@ mymain(void)
             QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
     DO_TEST("console-compat-chardev",
             QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
+    DO_TEST("pci-serial-dev-chardev",
+            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+            QEMU_CAPS_DEVICE_PCI_SERIAL);
 
     DO_TEST("channel-guestfwd",
             QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);