<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Is it possible to make the max number of monitors something persistent (e.g. set / get that using libvirt), so that the behavior would be consistent between a first boot and a reboot?</div><div class=""><br class=""></div><div class="">Christophe</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On 20 Feb 2017, at 15:49, Jonathon Jongsma <<a href="mailto:jjongsma@redhat.com" class="">jjongsma@redhat.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">On Thu, 2017-02-02 at 10:30 -0600, Jonathon Jongsma wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">On Thu, 2017-02-02 at 05:29 -0500, Frediano Ziglio wrote:<br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><br class="">When a guest is rebooted, the QXL driver gets unloaded at some<br class="">point in<br class="">the reboot process. When the driver is unloaded, the spice server<br class="">sets a<br class="">single flag to FALSE: RedWorker::driver_cap_monitors_config. This<br class="">flag<br class="">indicates whether the driver is capable of sending its own<br class="">monitors<br class="">config<br class="">messages to the client.<br class=""><br class="">The only place this flag is used is when a new primary surface is<br class="">created. If<br class="">this flag is true, the server assumes that the driver will send<br class="">its<br class="">own<br class="">monitors config very soon after the surface is created. If it's<br class="">false, the<br class="">server directly sends its own temporary monitors config message<br class="">to<br class="">the client<br class="">since the driver cannot.  This temporary monitors config message<br class="">is<br class="">based on<br class="">the size of the just-created primary surface and always has a<br class="">maximum monitor<br class="">count of 1.<br class=""><br class="">This flag is initialized to false at startup so that in early<br class="">boot<br class="">(e.g. vga<br class="">text mode), the server will send out these 'temporary' monitor<br class="">config<br class="">messages<br class="">to the client whenever the primary surface is destroyed and re-<br class="">created. This<br class="">causes the client to resize its window to match the size of the<br class="">guest. When<br class="">the<br class="">QXL driver is eventually loaded and starts taking over the<br class="">monitors<br class="">config<br class="">responsibilities, we set this flag to true and the server stops<br class="">sending<br class="">monitors config messages out on its own.<br class=""><br class="">If we reboot and set this flag to false, it will result in the<br class="">server sending<br class="">a<br class="">monitors config message to the client indicating that the guest<br class="">now<br class="">supports<br class="">a<br class="">maximum of 1 monitor. If the guest happens to have more than one<br class="">display<br class="">window<br class="">open, it will destroy those extra windows because they exceed the<br class="">maximum<br class="">allowed number of monitors. This means that if you reboot a guest<br class="">with 4<br class="">monitors, after reboot it will only have 1 monitor.<br class=""><br class=""></blockquote><br class="">After reading this paragraph and the bug I don't see the issue.<br class="">I mean, if on my laptop I reboot when I reboot I get a single<br class="">monitor<br class="">till the OS and other stuff kick in. After a reboot the firmware<br class="">use<br class="">one monitor or if capable do the mirroring but always the same way.<br class=""><br class="">I think the issue is that on first boot the guest activate the<br class="">additional monitors and the client do the same while on second<br class="">boot (reboot) not so to me looks like more an issue of the client<br class="">instead of the server.<br class=""><br class=""></blockquote><br class="">Well, it could be considered a client issue to some extent, but not<br class="">an<br class="">easy one to fix. <br class=""><br class=""><blockquote type="cite" class="">I would try to get a network capture to look at DisplayChannel<br class="">messages if they are more or less the same for first boot and<br class="">reboot. If they are the same I would look at the client state<br class="">to check that while booting it's the same.<br class=""></blockquote><br class="">The initial boot and the reboot are the same, and that's basically<br class="">why<br class="">the problem exists. At initial boot, it brings up a single display.<br class="">And<br class="">on reboot, it also brings up a single display. The issue is that we<br class="">want the reboot to behave differently.<br class=""><br class="">Initial boot:<br class="">-------------<br class=""> - In early boot, the server sends monitors config message when<br class="">primary<br class="">surface is created. monitors=1, max-monitors=1<br class=""> - client only shows a single window, disables menu items for<br class="">enabling<br class="">additional displays because the guest doesn't support more than 1<br class=""> - When QXL driver is loaded and takes over, it takes over sending<br class="">monitors config messages. monitors=1, max-monitors=4<br class=""> - client still shows a single window, but now the menu items for<br class="">enabling additional menus are enabled<br class=""> - client enables a second monitor. Client sends monitors-config<br class="">request to server <br class=""> - QXL driver enables the second monitor and sends a new monitors-<br class="">config response to the client. monitors = 2, max-monitors=4<br class=""><br class="">Reboot:<br class="">-------<br class=""> - At some point in the reboot process while the QXL driver is still<br class="">loaded, it disables all but the first monitor, but still claims to<br class="">support more than one. monitors=1, max-monitors=4<br class=""> - client keeps both display windows open, but the second one just<br class="">says<br class="">"Waiting for display 2..."<br class=""> - eventually the QXL driver gets unloaded, and the<br class="">RedWorker::driver_cap_monitors_config flag gets set to false<br class=""> - The next time a primary surface is created (during early boot?)<br class="">the<br class="">server sends out a new monitors config message to match the size of<br class="">the<br class="">primary surface. monitors=1, max-monitors=1<br class=""> - the client sees that the guest only supports a single monitor, so<br class="">it<br class="">closes that inactive second display window<br class=""> - when the qxl driver is loaded and takes over, it takes over<br class="">sending<br class="">monitors-config messages. monitors=1, max-monitors=4.<br class=""><br class=""><br class="">Before qemu commit 0a2b5e3a7899b40d05d7c6c1c41eb4e64dd2ed4b, the QXL<br class="">driver never called _unload() during reboot. This meant that during<br class="">early boot, the server would never send out monitors-config messages<br class="">with max-monitors=1. So the client would have never closed its extra<br class="">inactive display windows. They would have simply remained open with a<br class="">"Waiting for display n..." message. And as soon as the vdagent was<br class="">reconnected, the client would have sent a new monitors-config request<br class="">attempting to enable displays for all open windows. But now that<br class="">doesn't happen because those windows get closed during reboot.<br class=""><br class="">So my fix attempts to retain that behavior (while still fixing the<br class="">bug<br class="">that was addressed by 0a2b5e3a7899b40d05d7c6c1c41eb4e64dd2ed4b) by<br class="">keeping the max-monitors value the same as it had been before<br class="">rebooting.  <br class=""><br class="">You could possibly argue that you should instead fix this issue in<br class="">the<br class="">client by refusing to close/destroy displays when we recieve a<br class="">monitors-config message with a max-monitors value that is less than<br class="">the<br class=""> number of currently-open windows. But the design of the client is<br class="">such<br class="">that when we recieve a monitors-config message from the server, we<br class="">automatically create N Display objects (where N is the value of max-<br class="">monitors) even if these displays are not yet enabled. The existence<br class="">of<br class="">these Display objects determines whether or not the menu for enabling<br class="">additional displays are enabled, etc. So if we change the client to<br class="">not<br class="">destroy extra displays when we receive max-monitors, I fear that we<br class="">will introduce some additional bugs by violating some hidden<br class="">assumptions. But we could try it if you think it's a better approach.<br class="">It would be a more complicated fix, however.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Anybody have additional thoughts about this patch?</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><br class=""><br class=""><blockquote type="cite" class=""><br class=""><blockquote type="cite" class="">To avoid this, we assume that if we had the ability to support<br class="">multiple<br class="">monitors at some point, that ability will return at some point.<br class="">So<br class="">when the<br class="">server constructs its own temporary monitors config message to<br class="">send<br class="">to the<br class="">client (when the driver_cap_monitors_config flag is false), we<br class="">continue to<br class="">send<br class="">the previous maximum monitor count instead of always sending a<br class="">maximum of 1.<br class=""><br class="">Resolves: rhbz#1274447<br class="">---<br class=""><br class="">NOTE: this fix is a workaround that assumes some things that may<br class="">not be valid<br class="">in all cases.  The main assumption is that if the QXL driver was<br class="">used before<br class="">the reboot, it will continue to be used after the reboot. If this<br class="">assumption<br class="">is<br class="">violated, the server will continue to report that the guest<br class="">supports e.g. 4<br class="">displays even though the driver may only support 1. The client<br class="">would then be<br class="">able to attempt to enable additional displays, which would<br class="">inevitably fail<br class="">without explanation.  This is not a huge problem, but maybe it's<br class="">not<br class="">acceptable. If it's not acceptable, I think that fixing this bug<br class="">would<br class="">require<br class="">significantly more work and may not be worth the effort.<br class=""><br class=""> server/display-channel.c | 7 +++++--<br class=""> 1 file changed, 5 insertions(+), 2 deletions(-)<br class=""><br class="">diff --git a/server/display-channel.c b/server/display-channel.c<br class="">index a554bfd..88ee194 100644<br class="">--- a/server/display-channel.c<br class="">+++ b/server/display-channel.c<br class="">@@ -2459,15 +2459,18 @@ void<br class="">display_channel_set_monitors_config_to_primary(DisplayChannel<br class="">*display)<br class=""> {<br class="">     DrawContext *context = &display->priv->surfaces[0].context;<br class="">     QXLHead head = { 0, };<br class="">+    uint16_t old_max = 1;<br class=""> <br class="">     spice_return_if_fail(display->priv-<br class=""><blockquote type="cite" class="">surfaces[0].context.canvas);<br class=""></blockquote><br class=""> <br class="">-    if (display->priv->monitors_config)<br class="">+    if (display->priv->monitors_config) {<br class="">+        old_max = display->priv->monitors_config->max_allowed;<br class="">         monitors_config_unref(display->priv->monitors_config);<br class="">+    }<br class=""> <br class="">     head.width = context->width;<br class="">     head.height = context->height;<br class="">-    display->priv->monitors_config = monitors_config_new(&head,<br class="">1,<br class="">1);<br class="">+    display->priv->monitors_config = monitors_config_new(&head,<br class="">1,<br class="">old_max);<br class=""> }<br class=""> <br class=""> void display_channel_reset_image_cache(DisplayChannel *self)<br class=""></blockquote><br class="">Frediano<br class=""></blockquote><br class="">_______________________________________________<br class="">Spice-devel mailing list<br class=""><a href="mailto:Spice-devel@lists.freedesktop.org" class="">Spice-devel@lists.freedesktop.org</a><br class="">https://lists.freedesktop.org/mailman/listinfo/spice-devel<br class=""></blockquote><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Spice-devel mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:Spice-devel@lists.freedesktop.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">Spice-devel@lists.freedesktop.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.freedesktop.org/mailman/listinfo/spice-devel" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://lists.freedesktop.org/mailman/listinfo/spice-devel</a></div></blockquote></div><br class=""></body></html>