From: Gerd Hoffmann <kraxel@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Khor, Swee Aun" <swee.aun.khor@intel.com>,
"Romli, Khairul Anuar" <khairul.anuar.romli@intel.com>,
"eblake@redhat.com" <eblake@redhat.com>,
"Kasireddy, Vivek" <vivek.kasireddy@intel.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [PATCH v2] ui/gtk: Allow user to select monitor number to display qemu in full screen through new gtk display option
Date: Mon, 21 Jun 2021 13:07:10 +0200 [thread overview]
Message-ID: <20210621110710.u7stl5la2cp5mlqw@sirius.home.kraxel.org> (raw)
In-Reply-To: <875yy739hv.fsf@dusky.pond.sub.org>
> > I don't think qemu has to worry much here, and trying to automatically
> > adapt to hot-plugged monitors might even have bad interactions with
> > whatever the display server is going to do.
>
> I'm concerned there is a TOCTTOU issue:
>
> if (opts->u.gtk.has_monitor) {
> int n_monitor;
> 1. n_monitor = gdk_display_get_n_monitors(window_display);
>
> 2. if ((opts->u.gtk.monitor <= n_monitor) &&
> (opts->u.gtk.monitor > 0)) {
> GdkScreen *gdk_screen;
> gdk_screen = gdk_display_get_default_screen(window_display);
> 3. gtk_window_fullscreen_on_monitor(GTK_WINDOW(s->window), gdk_screen,
> (opts->u.gtk.monitor - 1));
> } else {
> fprintf(stderr, "Invalid GTK monitor argument\n");
> }
> }
>
> If monitors can go at any time, then the check 2. cannot ensure we pass
> a valid monitor number at 3.
>
> I asked what happens when we pass an invalid monitor number. I'm not
> sure I understand sweeaun's answer.
>
> If what happens is sane, then why have check 2.?
gtk_window_fullscreen_on_monitor() seems to be a "best effort" offer and
it doesn't return error codes. So catching possible user errors looks
useful to me. The code should use error_report instead though (or maybe
warn_report given this is not fatal). Reporting the valid range is
probably a good idea too.
take care,
Gerd
next prev parent reply other threads:[~2021-06-21 11:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-17 2:06 [PATCH v2] ui/gtk: Allow user to select monitor number to display qemu in full screen through new gtk display option sweeaun
2021-06-18 11:07 ` Markus Armbruster
2021-06-21 5:26 ` Khor, Swee Aun
2021-06-21 6:51 ` Gerd Hoffmann
2021-06-21 7:23 ` Khor, Swee Aun
2021-06-21 11:14 ` Gerd Hoffmann
2021-06-21 13:10 ` Khor, Swee Aun
2021-06-21 8:30 ` Markus Armbruster
2021-06-21 9:10 ` Khor, Swee Aun
2021-06-21 11:07 ` Gerd Hoffmann [this message]
2021-06-21 8:32 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210621110710.u7stl5la2cp5mlqw@sirius.home.kraxel.org \
--to=kraxel@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=khairul.anuar.romli@intel.com \
--cc=qemu-devel@nongnu.org \
--cc=swee.aun.khor@intel.com \
--cc=vivek.kasireddy@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).