|
|
b38b0f |
From 2d0261e575197b60fd17850f1079359375fb82a3 Mon Sep 17 00:00:00 2001
|
|
|
b38b0f |
From: Danilo de Paula <ddepaula@redhat.com>
|
|
|
b38b0f |
Date: Wed, 22 May 2019 20:24:33 +0100
|
|
|
b38b0f |
Subject: [PATCH 11/12] spice: set device address and device display ID in QXL
|
|
|
b38b0f |
interface
|
|
|
b38b0f |
MIME-Version: 1.0
|
|
|
b38b0f |
Content-Type: text/plain; charset=UTF-8
|
|
|
b38b0f |
Content-Transfer-Encoding: 8bit
|
|
|
b38b0f |
|
|
|
b38b0f |
RH-Author: Danilo de Paula <ddepaula@redhat.com>
|
|
|
b38b0f |
Message-id: <20190522202434.2529-2-ddepaula@redhat.com>
|
|
|
b38b0f |
Patchwork-id: 88166
|
|
|
b38b0f |
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 1/2] spice: set device address and device display ID in QXL interface
|
|
|
b38b0f |
Bugzilla: 1712946
|
|
|
b38b0f |
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
b38b0f |
RH-Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
b38b0f |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
b38b0f |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
b38b0f |
|
|
|
b38b0f |
From: Lukáš Hrázký <lhrazky@redhat.com>
|
|
|
b38b0f |
|
|
|
b38b0f |
Calls the new SPICE QXL interface function spice_qxl_set_device_info to
|
|
|
b38b0f |
set the hardware address of the graphics device represented by the QXL
|
|
|
b38b0f |
interface (e.g. a PCI path) and the device display IDs (the IDs of the
|
|
|
b38b0f |
device's monitors that belong to this QXL interface).
|
|
|
b38b0f |
|
|
|
b38b0f |
Also stops using the deprecated spice_qxl_set_max_monitors, the new
|
|
|
b38b0f |
interface function replaces it.
|
|
|
b38b0f |
|
|
|
b38b0f |
Signed-off-by: Lukáš Hrázký <lhrazky@redhat.com>
|
|
|
b38b0f |
Message-Id: <20190215150919.8263-1-lhrazky@redhat.com>
|
|
|
b38b0f |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
b38b0f |
(cherry picked from commit be812c0ab7d5ab741d0d87387a75a0e8bb6461e7)
|
|
|
b38b0f |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
b38b0f |
---
|
|
|
b38b0f |
hw/display/qxl.c | 14 ++++++++++++-
|
|
|
b38b0f |
include/ui/spice-display.h | 4 ++++
|
|
|
b38b0f |
ui/spice-core.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
b38b0f |
ui/spice-display.c | 11 ++++++++++
|
|
|
b38b0f |
4 files changed, 79 insertions(+), 1 deletion(-)
|
|
|
b38b0f |
|
|
|
b38b0f |
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
|
|
|
b38b0f |
index e36ef32..b373c50 100644
|
|
|
b38b0f |
--- a/hw/display/qxl.c
|
|
|
b38b0f |
+++ b/hw/display/qxl.c
|
|
|
b38b0f |
@@ -275,7 +275,8 @@ static void qxl_spice_monitors_config_async(PCIQXLDevice *qxl, int replay)
|
|
|
b38b0f |
QXL_COOKIE_TYPE_POST_LOAD_MONITORS_CONFIG,
|
|
|
b38b0f |
0));
|
|
|
b38b0f |
} else {
|
|
|
b38b0f |
-#if SPICE_SERVER_VERSION >= 0x000c06 /* release 0.12.6 */
|
|
|
b38b0f |
+/* >= release 0.12.6, < release 0.14.2 */
|
|
|
b38b0f |
+#if SPICE_SERVER_VERSION >= 0x000c06 && SPICE_SERVER_VERSION < 0x000e02
|
|
|
b38b0f |
if (qxl->max_outputs) {
|
|
|
b38b0f |
spice_qxl_set_max_monitors(&qxl->ssd.qxl, qxl->max_outputs);
|
|
|
b38b0f |
}
|
|
|
b38b0f |
@@ -2161,6 +2162,17 @@ static void qxl_realize_common(PCIQXLDevice *qxl, Error **errp)
|
|
|
b38b0f |
SPICE_INTERFACE_QXL_MAJOR, SPICE_INTERFACE_QXL_MINOR);
|
|
|
b38b0f |
return;
|
|
|
b38b0f |
}
|
|
|
b38b0f |
+
|
|
|
b38b0f |
+#if SPICE_SERVER_VERSION >= 0x000e02 /* release 0.14.2 */
|
|
|
b38b0f |
+ char device_address[256] = "";
|
|
|
b38b0f |
+ if (qemu_spice_fill_device_address(qxl->vga.con, device_address, 256)) {
|
|
|
b38b0f |
+ spice_qxl_set_device_info(&qxl->ssd.qxl,
|
|
|
b38b0f |
+ device_address,
|
|
|
b38b0f |
+ 0,
|
|
|
b38b0f |
+ qxl->max_outputs);
|
|
|
b38b0f |
+ }
|
|
|
b38b0f |
+#endif
|
|
|
b38b0f |
+
|
|
|
b38b0f |
qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, qxl);
|
|
|
b38b0f |
|
|
|
b38b0f |
qxl->update_irq = qemu_bh_new(qxl_update_irq_bh, qxl);
|
|
|
b38b0f |
diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h
|
|
|
b38b0f |
index 87a84a5..53c3612 100644
|
|
|
b38b0f |
--- a/include/ui/spice-display.h
|
|
|
b38b0f |
+++ b/include/ui/spice-display.h
|
|
|
b38b0f |
@@ -179,3 +179,7 @@ void qemu_spice_wakeup(SimpleSpiceDisplay *ssd);
|
|
|
b38b0f |
void qemu_spice_display_start(void);
|
|
|
b38b0f |
void qemu_spice_display_stop(void);
|
|
|
b38b0f |
int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd);
|
|
|
b38b0f |
+
|
|
|
b38b0f |
+bool qemu_spice_fill_device_address(QemuConsole *con,
|
|
|
b38b0f |
+ char *device_address,
|
|
|
b38b0f |
+ size_t size);
|
|
|
b38b0f |
diff --git a/ui/spice-core.c b/ui/spice-core.c
|
|
|
b38b0f |
index ae8921a..ebc2f09 100644
|
|
|
b38b0f |
--- a/ui/spice-core.c
|
|
|
b38b0f |
+++ b/ui/spice-core.c
|
|
|
b38b0f |
@@ -35,6 +35,7 @@
|
|
|
b38b0f |
#include "qemu/option.h"
|
|
|
b38b0f |
#include "migration/misc.h"
|
|
|
b38b0f |
#include "hw/hw.h"
|
|
|
b38b0f |
+#include "hw/pci/pci_bus.h"
|
|
|
b38b0f |
#include "ui/spice-display.h"
|
|
|
b38b0f |
|
|
|
b38b0f |
/* core bits */
|
|
|
b38b0f |
@@ -872,6 +873,56 @@ bool qemu_spice_have_display_interface(QemuConsole *con)
|
|
|
b38b0f |
return false;
|
|
|
b38b0f |
}
|
|
|
b38b0f |
|
|
|
b38b0f |
+/*
|
|
|
b38b0f |
+ * Recursively (in reverse order) appends addresses of PCI devices as it moves
|
|
|
b38b0f |
+ * up in the PCI hierarchy.
|
|
|
b38b0f |
+ *
|
|
|
b38b0f |
+ * @returns true on success, false when the buffer wasn't large enough
|
|
|
b38b0f |
+ */
|
|
|
b38b0f |
+static bool append_pci_address(char *buf, size_t buf_size, const PCIDevice *pci)
|
|
|
b38b0f |
+{
|
|
|
b38b0f |
+ PCIBus *bus = pci_get_bus(pci);
|
|
|
b38b0f |
+ /*
|
|
|
b38b0f |
+ * equivalent to if (!pci_bus_is_root(bus)), but the function is not built
|
|
|
b38b0f |
+ * with PCI_CONFIG=n, avoid using an #ifdef by checking directly
|
|
|
b38b0f |
+ */
|
|
|
b38b0f |
+ if (bus->parent_dev != NULL) {
|
|
|
b38b0f |
+ append_pci_address(buf, buf_size, bus->parent_dev);
|
|
|
b38b0f |
+ }
|
|
|
b38b0f |
+
|
|
|
b38b0f |
+ size_t len = strlen(buf);
|
|
|
b38b0f |
+ ssize_t written = snprintf(buf + len, buf_size - len, "/%02x.%x",
|
|
|
b38b0f |
+ PCI_SLOT(pci->devfn), PCI_FUNC(pci->devfn));
|
|
|
b38b0f |
+
|
|
|
b38b0f |
+ return written > 0 && written < buf_size - len;
|
|
|
b38b0f |
+}
|
|
|
b38b0f |
+
|
|
|
b38b0f |
+bool qemu_spice_fill_device_address(QemuConsole *con,
|
|
|
b38b0f |
+ char *device_address,
|
|
|
b38b0f |
+ size_t size)
|
|
|
b38b0f |
+{
|
|
|
b38b0f |
+ DeviceState *dev = DEVICE(object_property_get_link(OBJECT(con),
|
|
|
b38b0f |
+ "device",
|
|
|
b38b0f |
+ &error_abort));
|
|
|
b38b0f |
+ PCIDevice *pci = (PCIDevice *) object_dynamic_cast(OBJECT(dev),
|
|
|
b38b0f |
+ TYPE_PCI_DEVICE);
|
|
|
b38b0f |
+
|
|
|
b38b0f |
+ if (pci == NULL) {
|
|
|
b38b0f |
+ warn_report("Setting device address of a display device to SPICE: "
|
|
|
b38b0f |
+ "Not a PCI device.");
|
|
|
b38b0f |
+ return false;
|
|
|
b38b0f |
+ }
|
|
|
b38b0f |
+
|
|
|
b38b0f |
+ strncpy(device_address, "pci/0000", size);
|
|
|
b38b0f |
+ if (!append_pci_address(device_address, size, pci)) {
|
|
|
b38b0f |
+ warn_report("Setting device address of a display device to SPICE: "
|
|
|
b38b0f |
+ "Too many PCI devices in the chain.");
|
|
|
b38b0f |
+ return false;
|
|
|
b38b0f |
+ }
|
|
|
b38b0f |
+
|
|
|
b38b0f |
+ return true;
|
|
|
b38b0f |
+}
|
|
|
b38b0f |
+
|
|
|
b38b0f |
int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con)
|
|
|
b38b0f |
{
|
|
|
b38b0f |
if (g_slist_find(spice_consoles, con)) {
|
|
|
b38b0f |
diff --git a/ui/spice-display.c b/ui/spice-display.c
|
|
|
b38b0f |
index fe73482..22332f4 100644
|
|
|
b38b0f |
--- a/ui/spice-display.c
|
|
|
b38b0f |
+++ b/ui/spice-display.c
|
|
|
b38b0f |
@@ -1115,6 +1115,17 @@ static void qemu_spice_display_init_one(QemuConsole *con)
|
|
|
b38b0f |
|
|
|
b38b0f |
ssd->qxl.base.sif = &dpy_interface.base;
|
|
|
b38b0f |
qemu_spice_add_display_interface(&ssd->qxl, con);
|
|
|
b38b0f |
+
|
|
|
b38b0f |
+#if SPICE_SERVER_VERSION >= 0x000e02 /* release 0.14.2 */
|
|
|
b38b0f |
+ char device_address[256] = "";
|
|
|
b38b0f |
+ if (qemu_spice_fill_device_address(con, device_address, 256)) {
|
|
|
b38b0f |
+ spice_qxl_set_device_info(&ssd->qxl,
|
|
|
b38b0f |
+ device_address,
|
|
|
b38b0f |
+ qemu_console_get_head(con),
|
|
|
b38b0f |
+ 1);
|
|
|
b38b0f |
+ }
|
|
|
b38b0f |
+#endif
|
|
|
b38b0f |
+
|
|
|
b38b0f |
qemu_spice_create_host_memslot(ssd);
|
|
|
b38b0f |
|
|
|
b38b0f |
register_displaychangelistener(&ssd->dcl);
|
|
|
b38b0f |
--
|
|
|
b38b0f |
1.8.3.1
|
|
|
b38b0f |
|