diff mbox

spice: add display & head options

Message ID 1487663858-11731-1-git-send-email-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gerd Hoffmann Feb. 21, 2017, 7:57 a.m. UTC
This allows to specify display and head to use, simliar to vnc.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/spice-core.c    |  6 ++++++
 ui/spice-display.c | 22 +++++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

Comments

Marc-André Lureau Feb. 21, 2017, 8:52 a.m. UTC | #1
Hi

On Tue, Feb 21, 2017 at 11:58 AM Gerd Hoffmann <kraxel@redhat.com> wrote:

> This allows to specify display and head to use, simliar to vnc.
>
>
Does "head" in qemu always match the head for multi-monitor spice? (with a
single qxl/virtio). I don't clearly understand the relation, I would need
to do some research.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  ui/spice-core.c    |  6 ++++++
>  ui/spice-display.c | 22 +++++++++++++++++++++-
>  2 files changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/ui/spice-core.c b/ui/spice-core.c
> index d613f1a..e18ad77 100644
> --- a/ui/spice-core.c
> +++ b/ui/spice-core.c
> @@ -498,6 +498,12 @@ static QemuOptsList qemu_spice_opts = {
>          },{
>              .name = "seamless-migration",
>              .type = QEMU_OPT_BOOL,
> +        },{
> +            .name = "display",
> +            .type = QEMU_OPT_STRING,
> +        },{
> +            .name = "head",
> +            .type = QEMU_OPT_NUMBER,
>  #ifdef HAVE_SPICE_GL
>          },{
>              .name = "gl",
> diff --git a/ui/spice-display.c b/ui/spice-display.c
> index 64e472e..9c58e5a 100644
> --- a/ui/spice-display.c
> +++ b/ui/spice-display.c
> @@ -1029,9 +1029,26 @@ static void qemu_spice_display_init_one(QemuConsole
> *con)
>
>  void qemu_spice_display_init(void)
>  {
> -    QemuConsole *con;
> +    QemuOptsList *olist = qemu_find_opts("spice");
> +    QemuOpts *opts = QTAILQ_FIRST(&olist->head);
> +    QemuConsole *spice_con, *con;
> +    const char *str;
>      int i;
>
> +    str = qemu_opt_get(opts, "display");
> +    if (str) {
> +        int head = qemu_opt_get_number(opts, "head", 0);
> +        Error *err = NULL;
> +
> +        spice_con = qemu_console_lookup_by_device_name(str, head, &err);
> +        if (err) {
> +            error_report("Failed to lookup display/head");
> +            exit(1);
> +        }
> +    } else {
> +        spice_con = NULL;
> +    }
> +
>      for (i = 0;; i++) {
>          con = qemu_console_lookup_by_index(i);
>          if (!con || !qemu_console_is_graphic(con)) {
> @@ -1040,6 +1057,9 @@ void qemu_spice_display_init(void)
>          if (qemu_spice_have_display_interface(con)) {
>              continue;
>          }
> +        if (spice_con != NULL && spice_con != con) {
> +            continue;
> +        }
>          qemu_spice_display_init_one(con);
>      }
>  }
> --
> 1.8.3.1
>
>
> --
Marc-André Lureau
Gerd Hoffmann Feb. 21, 2017, 9:11 a.m. UTC | #2
On Di, 2017-02-21 at 08:52 +0000, Marc-André Lureau wrote:
> Hi
> 
> On Tue, Feb 21, 2017 at 11:58 AM Gerd Hoffmann <kraxel@redhat.com>
> wrote:
> 
>         This allows to specify display and head to use, simliar to
>         vnc.
>         
> 
> 
> Does "head" in qemu always match the head for multi-monitor spice?
> (with a single qxl/virtio).

Yes, head as specified in graphic_console_init().

cheers,
  Gerd
Marc-André Lureau Feb. 21, 2017, 9:23 a.m. UTC | #3
Hi

On Tue, Feb 21, 2017 at 1:11 PM Gerd Hoffmann <kraxel@redhat.com> wrote:

> On Di, 2017-02-21 at 08:52 +0000, Marc-André Lureau wrote:
> > Hi
> >
> > On Tue, Feb 21, 2017 at 11:58 AM Gerd Hoffmann <kraxel@redhat.com>
> > wrote:
> >
> >         This allows to specify display and head to use, simliar to
> >         vnc.
> >
> >
> >
> > Does "head" in qemu always match the head for multi-monitor spice?
> > (with a single qxl/virtio).
>
> Yes, head as specified in graphic_console_init().
>

It's always 0, except with virtio.

But I think virtio linux driver multi-monitor code would work with a single
qemu head (like qxl, fwiw last time I checked, multi-monitor virtio+spice
worked, with 3d too). It seems to me the qemu "head" is quite different
(lower-level) from spice "head".

The relation would need to be clarified imho before we expose this option.
Gerd Hoffmann Feb. 21, 2017, 10:04 a.m. UTC | #4
Hi,

> It's always 0, except with virtio. 
> 
> But I think virtio linux driver multi-monitor code would work with a
> single qemu head (like qxl, fwiw last time I checked, multi-monitor
> virtio+spice worked, with 3d too).

> It seems to me the qemu "head" is quite different (lower-level) from
> spice "head".

Well.  spice/qxl supports two different ways to do multihead ...

The first way is one display channel per head.  Which maps nicely to
qemu heads.  With qxl you'll use one qxl-vga device for the primary
display and one (or more) qxl devices for the secondary displays.  I
think multihead with windows guests still works that way, but xorg
support for that (xinerama mode) is pretty bad.  IIRC it needs manual
configuration, could also be recent xorg versions don't support it any
more.  Dunno where we stand with wayland.

The second way is a single display channel with a single, big surface
for all heads.  Then -- with spice-agent help -- guest and client
negotiate which region of the big display gets scanned out to which
head.

Multihead spice with virtio-gpu fundamentally works like the first way,
except that we have a single device with multiple heads (and display
channels) instead of multiple devices which have a single head each.

The use case I see for this is not so much multihead configuration.
With multiple display devices in your system, for example one intel-vgpu
and one emulated display device one could export only one of the two via
spice.

cheers,
  Gerd
Marc-André Lureau Feb. 22, 2017, 9:04 a.m. UTC | #5
Hi

On Tue, Feb 21, 2017 at 2:04 PM Gerd Hoffmann <kraxel@redhat.com> wrote:

>   Hi,
>
> > It's always 0, except with virtio.
> >
> > But I think virtio linux driver multi-monitor code would work with a
> > single qemu head (like qxl, fwiw last time I checked, multi-monitor
> > virtio+spice worked, with 3d too).
>
> > It seems to me the qemu "head" is quite different (lower-level) from
> > spice "head".
>
> Well.  spice/qxl supports two different ways to do multihead ...
>
> The first way is one display channel per head.  Which maps nicely to
> qemu heads.  With qxl you'll use one qxl-vga device for the primary
> display and one (or more) qxl devices for the secondary displays.  I
> think multihead with windows guests still works that way, but xorg
> support for that (xinerama mode) is pretty bad.  IIRC it needs manual
> configuration, could also be recent xorg versions don't support it any
> more.  Dunno where we stand with wayland.
>
> The second way is a single display channel with a single, big surface
> for all heads.  Then -- with spice-agent help -- guest and client
> negotiate which region of the big display gets scanned out to which
> head.
>
> Multihead spice with virtio-gpu fundamentally works like the first way,
> except that we have a single device with multiple heads (and display
> channels) instead of multiple devices which have a single head each.
>

ok


>
> The use case I see for this is not so much multihead configuration.
> With multiple display devices in your system, for example one intel-vgpu
> and one emulated display device one could export only one of the two via
> spice.
>

My understanding is that "head" will not work correctly with QXL (only head
0, but can be a multi-head QXL), but should do what you expect with virtio.

thanks
Gerd Hoffmann Feb. 22, 2017, 10:40 a.m. UTC | #6
Hi,

>         The second way is a single display channel with a single, big
>         surface
>         for all heads.  Then -- with spice-agent help -- guest and
>         client
>         negotiate which region of the big display gets scanned out to
>         which
>         head.


> My understanding is that "head" will not work correctly with QXL (only
> head 0, but can be a multi-head QXL),

For the second way yes, because in that case "head" is a qxl/spice
private thing and not visible outside.  You'll see that for example in
case you try to screendump or connect with vnc.  No heads, only the big
surface.

cheers,
  Gerd
diff mbox

Patch

diff --git a/ui/spice-core.c b/ui/spice-core.c
index d613f1a..e18ad77 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -498,6 +498,12 @@  static QemuOptsList qemu_spice_opts = {
         },{
             .name = "seamless-migration",
             .type = QEMU_OPT_BOOL,
+        },{
+            .name = "display",
+            .type = QEMU_OPT_STRING,
+        },{
+            .name = "head",
+            .type = QEMU_OPT_NUMBER,
 #ifdef HAVE_SPICE_GL
         },{
             .name = "gl",
diff --git a/ui/spice-display.c b/ui/spice-display.c
index 64e472e..9c58e5a 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -1029,9 +1029,26 @@  static void qemu_spice_display_init_one(QemuConsole *con)
 
 void qemu_spice_display_init(void)
 {
-    QemuConsole *con;
+    QemuOptsList *olist = qemu_find_opts("spice");
+    QemuOpts *opts = QTAILQ_FIRST(&olist->head);
+    QemuConsole *spice_con, *con;
+    const char *str;
     int i;
 
+    str = qemu_opt_get(opts, "display");
+    if (str) {
+        int head = qemu_opt_get_number(opts, "head", 0);
+        Error *err = NULL;
+
+        spice_con = qemu_console_lookup_by_device_name(str, head, &err);
+        if (err) {
+            error_report("Failed to lookup display/head");
+            exit(1);
+        }
+    } else {
+        spice_con = NULL;
+    }
+
     for (i = 0;; i++) {
         con = qemu_console_lookup_by_index(i);
         if (!con || !qemu_console_is_graphic(con)) {
@@ -1040,6 +1057,9 @@  void qemu_spice_display_init(void)
         if (qemu_spice_have_display_interface(con)) {
             continue;
         }
+        if (spice_con != NULL && spice_con != con) {
+            continue;
+        }
         qemu_spice_display_init_one(con);
     }
 }