RFC: qxl: allow to specify head limit to qxl driver
PATCH v2 1/1 RFC: qxl: allow to specify head limit to qxl driver
This patch allow to limit number of heads using qxl driver. By default qxl driver is not limited on any kind on head use so can decide to use as much heads.
libvirt has this as a video card parameter (actually set to 1 but not used). This parameter will allow to limit setting a use can do (which could be confusing).
This patch rely on some change in spice-protocol which are not still accepted. See
http://lists.freedesktop.org/archives/spice-devel/2015-June/020221.html.
--- hw/display/qxl.c | 20 +++++++++++++++----- hw/display/qxl.h | 1 + 2 files changed, 16 insertions(+), 5 deletions(-)
This version change the way limit is set. It came from Gerd Hoffmann suggestion.
hw/display/qxl.c +15 -5
@@ -272,6 +272,10 @@ static void qxl_spice_monitors_config_async(PCIQXLDevice *qxl, int replay)QXL_COOKIE_TYPE_POST_LOAD_MONITORS_CONFIG , 0)); }else { +if (qxl->max_outputs) { +spice_qxl_set_monitors_config_limit (&qxl->ssd.qxl, + qxl->max_outputs); + } qxl->guest_monitors_config = qxl->ram->monitors_config; spice_qxl_monitors_config_async(&qxl->ssd.qxl, qxl->ram->monitors_config,
@@ -992,6 +996,7 @@ static int interface_client_monitors_config(QXLInstance *sin,PCIQXLDevice *qxl =container_of (sin, PCIQXLDevice, ssd.qxl);QXLRom *rom =memory_region_get_ram_ptr (&qxl->rom_bar);int i; +unsigned max_outputs =ARRAY_SIZE (rom->client_monitors_config.heads);if (qxl->revision <4 ) { trace_qxl_client_monitors_config_unsupported_by_device(qxl->id,
@@ -1014,17 +1019,21 @@ static int interface_client_monitors_config(QXLInstance *sin,if (!monitors_config) {return 1 ; } + +/* limit number of outputs based on setting limit */ +if (qxl->max_outputs && qxl->max_outputs <= max_outputs) { + max_outputs = qxl->max_outputs; + } +memset (&rom->client_monitors_config,0 ,sizeof (rom->client_monitors_config)); rom->client_monitors_config.count = monitors_config->num_of_monitors;/* monitors_config->flags ignored */ -if (rom->client_monitors_config.count >= -ARRAY_SIZE (rom->client_monitors_config.heads)) { +if (rom->client_monitors_config.count >= max_outputs) {trace_qxl_client_monitors_config_capped (qxl->id, monitors_config->num_of_monitors, -ARRAY_SIZE (rom->client_monitors_config.heads)); - rom->client_monitors_config.count = -ARRAY_SIZE (rom->client_monitors_config.heads); + max_outputs); + rom->client_monitors_config.count = max_outputs; }for (i =0 ; i < rom->client_monitors_config.count ; ++i) {VDAgentMonConfig *monitor = &monitors_config->monitors[i];
@@ -2278,6 +2287,7 @@ static Property qxl_properties[] = {DEFINE_PROP_UINT32 ("vram64_size_mb" , PCIQXLDevice, vram_size_mb,-1 ),DEFINE_PROP_UINT32 ("vgamem_mb" , PCIQXLDevice, vgamem_size_mb,16 ),DEFINE_PROP_INT32 ("surfaces" , PCIQXLDevice, ssd.num_surfaces,1024 ), +DEFINE_PROP_UINT16 ("max_outputs" , PCIQXLDevice, max_outputs,0 ), DEFINE_PROP_END_OF_LIST(), };
hw/display/qxl.h +1 -0
@@ -99,6 +99,7 @@ typedef struct PCIQXLDevice {QXLModes *modes;uint32_t rom_size;MemoryRegion rom_bar; +uint16_t max_outputs;/* vram pci bar */ uint32_t vram_size;
Signature · 1 line
2.1.0
Quoted 3 lines · Frediano Ziglio
libvirt has this as a video card parameter (actually set to 1 but not used). This parameter will allow to limit setting a use can do (which could be confusing).
Hmm. So heads is '1' by default but ignored today. When this starts to be actually applied that will break existing multihead setups I suspect.
Quoted 3 lines
This patch rely on some change in spice-protocol which are not still accepted. See
http://lists.freedesktop.org/archives/spice-devel/2015-June/020221.html.
Spice-server changes, right?
Needs #ifdefs so qemu continues to build with old spice-server versions. The spice-server changes need to be upstream first.
Also: when we pass on the limit to spice-server anyway spice-server can take care to apply the limit both ways and not call the ->client_monitors_config() callback with more than $limit monitors. Has the advantage to reduce the test matrix: Limit either works or doesn't. There will be no spice-server/qemu version combination where the limit is applied one way only.
Gerd
Quoted 9 lines · Frediano Ziglio
Quoted 3 lines
libvirt has this as a video card parameter (actually set to 1 but not used). This parameter will allow to limit setting a use can do (which could be confusing).
Hmm. So heads is '1' by default but ignored today. When this starts to be actually applied that will break existing multihead setups I suspect.
Yes, unfortunately libvirt always set the default to 1 even if not used by driver. However the Qemu default (with no parameter) is still unlimited so it's a libvirt issue more then Qemu.
Quoted 8 lines
Quoted 3 lines
This patch rely on some change in spice-protocol which are not still accepted. See
http://lists.freedesktop.org/archives/spice-devel/2015-June/020221.html.Spice-server changes, right?
Needs #ifdefs so qemu continues to build with old spice-server versions. The spice-server changes need to be upstream first.
Yes, I'll do.
Quoted 9 lines
Also: when we pass on the limit to spice-server anyway spice-server can take care to apply the limit both ways and not call the ->client_monitors_config() callback with more than $limit monitors. Has the advantage to reduce the test matrix: Limit either works or doesn't. There will be no spice-server/qemu version combination where the limit is applied one way only.
Gerd
Is always Qemu that decide to apply the limitation, default (even for spice-server) is still unlimited. As Qemu compiled with option on won't run with older version there will never this problem. However I would agree that the patch for Qemu keeping all limits on one place would be smaller.
Frediano