mirror of https://gitee.com/openkylin/libvirt.git
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: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
335b834d95
commit
8e33cb41f3
|
@ -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[] = {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -134,4 +134,5 @@
|
|||
<flag name='vmware-svga.vgamem_mb'/>
|
||||
<flag name='qxl.vgamem_mb'/>
|
||||
<flag name='qxl-vga.vgamem_mb'/>
|
||||
<flag name='pci-serial'/>
|
||||
</qemuCaps>
|
||||
|
|
|
@ -135,4 +135,5 @@
|
|||
<flag name='vmware-svga.vgamem_mb'/>
|
||||
<flag name='qxl.vgamem_mb'/>
|
||||
<flag name='qxl-vga.vgamem_mb'/>
|
||||
<flag name='pci-serial'/>
|
||||
</qemuCaps>
|
||||
|
|
|
@ -144,4 +144,5 @@
|
|||
<flag name='vmware-svga.vgamem_mb'/>
|
||||
<flag name='qxl.vgamem_mb'/>
|
||||
<flag name='qxl-vga.vgamem_mb'/>
|
||||
<flag name='pci-serial'/>
|
||||
</qemuCaps>
|
||||
|
|
|
@ -150,4 +150,5 @@
|
|||
<flag name='vmware-svga.vgamem_mb'/>
|
||||
<flag name='qxl.vgamem_mb'/>
|
||||
<flag name='qxl-vga.vgamem_mb'/>
|
||||
<flag name='pci-serial'/>
|
||||
</qemuCaps>
|
||||
|
|
|
@ -150,4 +150,5 @@
|
|||
<flag name='vmware-svga.vgamem_mb'/>
|
||||
<flag name='qxl.vgamem_mb'/>
|
||||
<flag name='qxl-vga.vgamem_mb'/>
|
||||
<flag name='pci-serial'/>
|
||||
</qemuCaps>
|
||||
|
|
|
@ -166,4 +166,5 @@
|
|||
<flag name='qxl.vgamem_mb'/>
|
||||
<flag name='qxl-vga.vgamem_mb'/>
|
||||
<flag name='pc-dimm'/>
|
||||
<flag name='pci-serial'/>
|
||||
</qemuCaps>
|
||||
|
|
|
@ -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
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue