提交 8e33cb41 编写于 作者: M Michal Privoznik

qemu: Implement pci-serial

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: NMichal Privoznik <mprivozn@redhat.com>
上级 335b834d
...@@ -283,6 +283,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, ...@@ -283,6 +283,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"machine-vmport-opt", /* 185 */ "machine-vmport-opt", /* 185 */
"aes-key-wrap", "aes-key-wrap",
"dea-key-wrap", "dea-key-wrap",
"pci-serial",
); );
...@@ -1539,6 +1540,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { ...@@ -1539,6 +1540,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
{ "iothread", QEMU_CAPS_OBJECT_IOTHREAD}, { "iothread", QEMU_CAPS_OBJECT_IOTHREAD},
{ "ivshmem", QEMU_CAPS_DEVICE_IVSHMEM }, { "ivshmem", QEMU_CAPS_DEVICE_IVSHMEM },
{ "pc-dimm", QEMU_CAPS_DEVICE_PC_DIMM }, { "pc-dimm", QEMU_CAPS_DEVICE_PC_DIMM },
{ "pci-serial", QEMU_CAPS_DEVICE_PCI_SERIAL },
}; };
static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = { static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {
......
...@@ -227,6 +227,7 @@ typedef enum { ...@@ -227,6 +227,7 @@ typedef enum {
QEMU_CAPS_MACHINE_VMPORT_OPT = 185, /* -machine xxx,vmport=on/off/auto */ QEMU_CAPS_MACHINE_VMPORT_OPT = 185, /* -machine xxx,vmport=on/off/auto */
QEMU_CAPS_AES_KEY_WRAP = 186, /* -machine aes_key_wrap */ QEMU_CAPS_AES_KEY_WRAP = 186, /* -machine aes_key_wrap */
QEMU_CAPS_DEA_KEY_WRAP = 187, /* -machine dea_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 */ QEMU_CAPS_LAST, /* this must always be the last item */
} virQEMUCapsFlags; } virQEMUCapsFlags;
......
...@@ -2312,6 +2312,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, ...@@ -2312,6 +2312,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
* - VirtIO balloon * - VirtIO balloon
* - Host device passthrough * - Host device passthrough
* - Watchdog (not IB700) * - Watchdog (not IB700)
* - pci serial devices
* *
* Prior to this function being invoked, qemuCollectPCIAddress() will have * Prior to this function being invoked, qemuCollectPCIAddress() will have
* added all existing PCI addresses from the 'def' to 'addrs'. Thus this * added all existing PCI addresses from the 'def' to 'addrs'. Thus this
...@@ -2584,7 +2585,16 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, ...@@ -2584,7 +2585,16 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
/* Nada - none are PCI based (yet) */ /* Nada - none are PCI based (yet) */
} }
for (i = 0; i < def->nserials; i++) { 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++) { for (i = 0; i < def->nchannels; i++) {
/* Nada - none are PCI based (yet) */ /* Nada - none are PCI based (yet) */
...@@ -10932,6 +10942,24 @@ qemuBuildSerialChrDeviceStr(char **deviceStr, ...@@ -10932,6 +10942,24 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
goto error; goto error;
} }
break; 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;
} }
} }
......
...@@ -134,4 +134,5 @@ ...@@ -134,4 +134,5 @@
<flag name='vmware-svga.vgamem_mb'/> <flag name='vmware-svga.vgamem_mb'/>
<flag name='qxl.vgamem_mb'/> <flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/> <flag name='qxl-vga.vgamem_mb'/>
<flag name='pci-serial'/>
</qemuCaps> </qemuCaps>
...@@ -135,4 +135,5 @@ ...@@ -135,4 +135,5 @@
<flag name='vmware-svga.vgamem_mb'/> <flag name='vmware-svga.vgamem_mb'/>
<flag name='qxl.vgamem_mb'/> <flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/> <flag name='qxl-vga.vgamem_mb'/>
<flag name='pci-serial'/>
</qemuCaps> </qemuCaps>
...@@ -144,4 +144,5 @@ ...@@ -144,4 +144,5 @@
<flag name='vmware-svga.vgamem_mb'/> <flag name='vmware-svga.vgamem_mb'/>
<flag name='qxl.vgamem_mb'/> <flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/> <flag name='qxl-vga.vgamem_mb'/>
<flag name='pci-serial'/>
</qemuCaps> </qemuCaps>
...@@ -150,4 +150,5 @@ ...@@ -150,4 +150,5 @@
<flag name='vmware-svga.vgamem_mb'/> <flag name='vmware-svga.vgamem_mb'/>
<flag name='qxl.vgamem_mb'/> <flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/> <flag name='qxl-vga.vgamem_mb'/>
<flag name='pci-serial'/>
</qemuCaps> </qemuCaps>
...@@ -150,4 +150,5 @@ ...@@ -150,4 +150,5 @@
<flag name='vmware-svga.vgamem_mb'/> <flag name='vmware-svga.vgamem_mb'/>
<flag name='qxl.vgamem_mb'/> <flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/> <flag name='qxl-vga.vgamem_mb'/>
<flag name='pci-serial'/>
</qemuCaps> </qemuCaps>
...@@ -166,4 +166,5 @@ ...@@ -166,4 +166,5 @@
<flag name='qxl.vgamem_mb'/> <flag name='qxl.vgamem_mb'/>
<flag name='qxl-vga.vgamem_mb'/> <flag name='qxl-vga.vgamem_mb'/>
<flag name='pc-dimm'/> <flag name='pc-dimm'/>
<flag name='pci-serial'/>
</qemuCaps> </qemuCaps>
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
...@@ -1060,6 +1060,9 @@ mymain(void) ...@@ -1060,6 +1060,9 @@ mymain(void)
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("console-compat-chardev", DO_TEST("console-compat-chardev",
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); 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", DO_TEST("channel-guestfwd",
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册