Bug 370494 - Automatic VM display resolution broken under KDE hosts
Summary: Automatic VM display resolution broken under KDE hosts
Status: RESOLVED DUPLICATE of bug 356864
Alias: None
Product: KScreen
Classification: Plasma
Component: common (show other bugs)
Version: 5.8.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Sebastian Kügler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-11 18:45 UTC by adrelanos
Modified: 2016-11-18 00:04 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
~/.local/share/kscreen/kscreen.log (12.88 KB, text/plain)
2016-10-18 15:05 UTC, Pavel Grunt
Details
xrandr -q (1.04 KB, text/plain)
2016-10-18 15:32 UTC, Pavel Grunt
Details
xrandr -q (1.04 KB, text/plain)
2016-10-18 17:44 UTC, Pavel Grunt
Details
kscreen-console (7.76 KB, text/plain)
2016-10-18 17:44 UTC, Pavel Grunt
Details
~/.local/share/kscreen/kscreen.log (25.77 KB, text/x-log)
2016-10-18 17:45 UTC, Pavel Grunt
Details
another file under kscreen (415 bytes, text/plain)
2016-10-18 17:46 UTC, Pavel Grunt
Details
tail -f ~/.local/share/kscreen/ (2.31 KB, text/plain)
2016-10-18 17:50 UTC, Pavel Grunt
Details
kded5 debug with timestamp (7.95 KB, text/plain)
2016-10-18 18:03 UTC, Pavel Grunt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description adrelanos 2016-10-11 18:45:42 UTC
Automatic adjustment of screen resolution in VMs is broken.

Reproducible: Always

Steps to Reproduce:
This is easy to reproduce. Running any VM guest on a KDE host will prevent it from automatically adjusting its resolution to fit the virt-viewer screen.

Actual Results:  
Resolution does not fit.

Expected Results:  
Resolution should fit.

Related bug reports and suggested solution:

https://forums.whonix.org/t/not-able-to-adjust-display-resolution-in-kvm-and-late-password-prompt-during-login/2798/4

https://bugzilla.redhat.com/show_bug.cgi?id=1383425

The solution is to implement handling of the monitor hotplug event in the window manager of KDE, like GNOME did in mutter and gnome-settings-daemon
Comment 1 Martin Flöser 2016-10-12 05:28:54 UTC
This is nothing the window manager should do. Reassigning to kscreen which might be the best fitting area.

Personally I think that's a problem of virt-viewer. This used to work in the past and got broken. There is no reason why every desktop environment has to reimplement the same code instead of having one generic solution.
Comment 2 Sebastian Kügler 2016-10-12 23:32:52 UTC
This could be two things:

(1) libkscreen failing to mode-set for some reason, we had a number of bugs that could lead to that and fixed them for 5.8.

(2) https://bugs.kde.org/show_bug.cgi?id=356864 which means that xrandr changes the list of modes on the fly, which libkscreen doesn't handle gracefully enough (yet). In that case, killing kscreen_backend_launcher and kded5, then restarting kded5 should allow to set the correct mode (not an acceptable workaround, of course, just a quick test to confirm this hunch).

To judge, we'd need
* confirmation if this is fixed in Plasma 5.8, or not
* xrandr -q, ~/.local/share/kscreen/kscreen.log, etc., as explained on https://community.kde.org/Solid/Projects/ScreenManagement#Debugging_Information
Comment 3 adrelanos 2016-10-17 16:09:06 UTC
Unfortunately I run Debian Stable and it will be a while before 5.8 lands in the repo. I understand there is a lot going on that you have to handle but please try to prioritize this before the Debian Stretch freeze.
Comment 4 Sebastian Kügler 2016-10-17 20:38:53 UTC
The thing is, I need to know if it works with 5.8, I won't spend time on it without knowing that it's still broken as I can't fix it twice. So if you ask me to prioritize this problem, that's useless unless I get the information I need to actually work on this.
Comment 5 Pavel Grunt 2016-10-18 15:03:33 UTC
Hi, it is not fixed in
plasma-desktop-5.8.1-1.fc25.x86_64

Respectively it resizes once, just after the login, after that it doesn't react on changes of window size
Comment 6 Pavel Grunt 2016-10-18 15:05:04 UTC
Created attachment 101622 [details]
~/.local/share/kscreen/kscreen.log
Comment 7 Pavel Grunt 2016-10-18 15:32:30 UTC
Created attachment 101623 [details]
xrandr -q

Preferred changed to:
1920x1080     59.96 +  60.00
but the current didn't adjust
Comment 8 Sebastian Kügler 2016-10-18 15:42:32 UTC
Thanks! Could you also post the output of:

* kscreen-console (should show the same mode info as xrandr -q, but does it really?)
* and the remaining files in ~/.local/share/kscreen/

Also, if you look "tail -f ~/.local/share/kscreen/", are there any new events in kscreen.log when you resize the window?

If you kill kscreen_backend_launcher (it will be automatically restarted when needed), does kscreen-console show the information matching with xrandr -q?

I've looked into the hotplug flag that was added in GNOME to make this case work, but this is not available through XCB (I couldn't find it), but should work automatically -- that is we do monitor the relevant events for the output, this is done in libkscreen/backends/xcblistener.cpp

    xcb_randr_select_input(c, m_window,
            XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE |
            XCB_RANDR_NOTIFY_MASK_OUTPUT_CHANGE |
            XCB_RANDR_NOTIFY_MASK_CRTC_CHANGE |
            XCB_RANDR_NOTIFY_MASK_OUTPUT_PROPERTY
    );
Comment 9 Pavel Grunt 2016-10-18 17:44:14 UTC
Created attachment 101628 [details]
xrandr -q
Comment 10 Pavel Grunt 2016-10-18 17:44:41 UTC
Created attachment 101629 [details]
kscreen-console
Comment 11 Pavel Grunt 2016-10-18 17:45:28 UTC
Created attachment 101630 [details]
~/.local/share/kscreen/kscreen.log
Comment 12 Pavel Grunt 2016-10-18 17:46:16 UTC
Created attachment 101631 [details]
another file under kscreen
Comment 13 Pavel Grunt 2016-10-18 17:50:31 UTC
Created attachment 101632 [details]
tail -f ~/.local/share/kscreen/

Resized to something bigger than 1024x768
Comment 14 Pavel Grunt 2016-10-18 17:58:34 UTC
(In reply to Sebastian Kügler from comment #8)
> Thanks! Could you also post the output of:
> 
> * kscreen-console (should show the same mode info as xrandr -q, but does it
> really?)
> * and the remaining files in ~/.local/share/kscreen/
> 
> Also, if you look "tail -f ~/.local/share/kscreen/", are there any new
> events in kscreen.log when you resize the window?

yes, there is a notify but not matching newly requested size
> 
> If you kill kscreen_backend_launcher (it will be automatically restarted
> when needed), does kscreen-console show the information matching with xrandr
> -q?
yes, both provide the same info - the correct preferred size
> 
> I've looked into the hotplug flag that was added in GNOME to make this case
> work, but this is not available through XCB (I couldn't find it), but should
> work automatically -- that is we do monitor the relevant events for the
> output, this is done in libkscreen/backends/xcblistener.cpp

mutter uses drmModeGetProperty to get info about "hotplug_mode_update" (it is drm kms property - I googled for some info and found https://01.org/linuxgraphics/gfx-docs/drm/drm-kms-properties.html )

Also in mutter it is not about the value of the property, but about its presence. This comment may be useful:
https://git.gnome.org/browse/mutter/tree/src/backends/meta-monitor-config.c#n1478

> 
>     xcb_randr_select_input(c, m_window,
>             XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE |
>             XCB_RANDR_NOTIFY_MASK_OUTPUT_CHANGE |
>             XCB_RANDR_NOTIFY_MASK_CRTC_CHANGE |
>             XCB_RANDR_NOTIFY_MASK_OUTPUT_PROPERTY
>     );
Comment 15 Pavel Grunt 2016-10-18 18:03:44 UTC
Created attachment 101634 [details]
kded5 debug with timestamp

can the bug be related to this:
[20::00:58.168] unknown: Unable to get EDID for output "Virtual-1"
[20::00:58.205] unknown: Failed to register device: "device id 'xrandr-Virtual-1' already exists"
[20::00:58.207] unknown: Failed to create ICC profile on cmsCreateRGBProfile
[20::00:59.150] unknown: Config does not have at least one screen enabled, WILL NOT save this config, this is not what user wants.
Comment 16 Sebastian Kügler 2016-10-18 21:06:53 UTC
Interesting. So it seems we do get an update event, but since we don't reparse the mode list, it stays static, and nothing actually changes.

Thanks a lot for the info, I'll look into coming up with a fix.
Comment 17 Sebastian Kügler 2016-11-18 00:04:48 UTC
So, good news.

This bug is a duplicate of another of bug:356864. 

Here's a bit of context, before I redirect this bug's traffic to the other one, which has tracked the related changes.

libkscreen's list of modes for each output were never assumed to change at runtime, so a whole lot of components assumed it would never change and not react to changes, the list of modes was constant, as reasonable assumption given hardware. Less reasonable in vms, as we know. So the vm presents us with changing modes for outputs, but these were never re-read (in our xrandr backend), and changes never propagated through libkscreen's API to the kded module (which handles all the policy bits and initiates the actual changes at runtime). A few patches down the road, and I've now successfully (with git master) resizing Plasma inside the VM window.

In my setup (qemu with neon git unstable inside, host is a debian unstable thinkpad with intel graphics), I'm running into a bug, however. When at least one axis of the vm window shrinks, I reliably get a black screen, when I grow any or both axes, and kscreen's kded sets the new mode, it works again. I can reproduce this behavior also with using bare xrandr, so I assume that this is not a problem in kscreen. More info on that welcome, of course.

So git master has all the patches in place, and I'll look into backporting these bits to Plasma 5.8.4.

*** This bug has been marked as a duplicate of bug 356864 ***