[libvirt] [PATCH v2 2/4] qemu: Implement pci-serial
Daniel P. Berrange
berrange at redhat.com
Wed May 13 16:46:28 UTC 2015
On Mon, May 11, 2015 at 05:26:09PM +0200, Michal Privoznik wrote:
> 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 at redhat.com>
> ---
> src/qemu/qemu_capabilities.c | 2 ++
> src/qemu/qemu_capabilities.h | 1 +
> src/qemu/qemu_command.c | 18 ++++++++++++++++++
> tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 +
> tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 +
> tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 +
> tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 +
> tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 +
> tests/qemucapabilitiesdata/caps_2.1.1-1.caps | 1 +
> .../qemuxml2argv-pci-serial-dev-chardev.args | 7 +++++++
> tests/qemuxml2argvtest.c | 3 +++
> 11 files changed, 37 insertions(+)
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pci-serial-dev-chardev.args
>
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 25c15bf..d7bb443 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -281,6 +281,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
> "pc-dimm",
>
> "machine-vmport-opt", /* 185 */
> + "pci-serial",
> );
>
>
> @@ -1537,6 +1538,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[] = {
> diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
> index 81557b7..a2edf82 100644
> --- a/src/qemu/qemu_capabilities.h
> +++ b/src/qemu/qemu_capabilities.h
> @@ -225,6 +225,7 @@ typedef enum {
> QEMU_CAPS_QXL_VGA_VGAMEM = 183, /* -device qxl-vga.vgamem_mb */
> QEMU_CAPS_DEVICE_PC_DIMM = 184, /* pc-dimm device */
> QEMU_CAPS_MACHINE_VMPORT_OPT = 185, /* -machine xxx,vmport=on/off/auto */
> + QEMU_CAPS_DEVICE_PCI_SERIAL = 186, /* -device pci-serial */
>
> QEMU_CAPS_LAST, /* this must always be the last item */
> } virQEMUCapsFlags;
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index fe4622e..938dbca 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -10862,6 +10862,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;
> }
> }
You also ned to change
qemuAssignDevicePCISlots(virDomainDefPtr def,
virDomainPCIAddressSetPtr addrs) {
....
for (i = 0; i < def->nserials; i++) {
/* Nada - none are PCI based (yet) */
}
Since the comment is clearly wrong now :-)
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list