1. 24 Jul, 2019 5 commits
    • Frediano Ziglio's avatar
      x11: Change check to make code scanners not giving warning · 0b94306d
      Frediano Ziglio authored
      Some code scanners (both Coverity and clang one) report that
      prev_sel/prev_cond could be unreferenced while NULL.
      Change condition to make clear a NULL pointer is not used.
      Signed-off-by: Frediano Ziglio's avatarFrediano Ziglio <fziglio@redhat.com>
      Acked-by: 's avatarVictor Toso <victortoso@redhat.com>
      0b94306d
    • Victor Toso's avatar
      device-info: remove g_list_length() on compare_addresses() · 66935d13
      Victor Toso authored
      The g_list_length() function does iterate over both lists to compare
      its length. Considering that we use this to check for true/false and
      we will iterate again on both lists, we can do so once.
      
      This also avoids covscan/clang warnings:
      
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:216:27: warning: Access to field 'data' results in a dereference of a null pointer (loaded from variable 'lb')
       | #        PciDevice *devb = lb->data;
       | #                          ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:397:5: note: Taking false branch
       | #    if (!user_pci_addr) {
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:407:22: note: Calling 'find_device_at_pci_address'
       | #    char *dev_path = find_device_at_pci_address(user_pci_addr, &vendor_id, &device_id);
       | #                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:329:5: note: Taking true branch
       | #    g_return_val_if_fail(pci_addr != NULL, NULL);
       | #    ^
       | /usr/include/glib-2.0/glib/gmessages.h:594:9: note: expanded from macro 'g_return_val_if_fail'
       | #     if G_LIKELY(expr) { } else                                         \
       | #        ^
       | /usr/include/glib-2.0/glib/gmacros.h:385:43: note: expanded from macro 'G_LIKELY'
       | ##define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR((expr)), 1))
       | #                                          ^
       | /usr/include/glib-2.0/glib/gmacros.h:379:4: note: expanded from macro '_G_BOOLEAN_EXPR'
       | #   if (expr)                                    \
       | #   ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:329:5: note: Taking true branch
       | /usr/include/glib-2.0/glib/gmessages.h:594:6: note: expanded from macro 'g_return_val_if_fail'
       | #     if G_LIKELY(expr) { } else                                         \
       | #     ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:329:5: note: Loop condition is false.  Exiting loop
       | /usr/include/glib-2.0/glib/gmessages.h:593:40: note: expanded from macro 'g_return_val_if_fail'
       | ##define g_return_val_if_fail(expr,val)  G_STMT_START{                   \
       | #                                        ^
       | /usr/include/glib-2.0/glib/gmacros.h:346:23: note: expanded from macro 'G_STMT_START'
       | ##define G_STMT_START  do
       | #                      ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:330:5: note: Taking true branch
       | #    g_return_val_if_fail(device_id != NULL, NULL);
       | #    ^
       | /usr/include/glib-2.0/glib/gmessages.h:594:9: note: expanded from macro 'g_return_val_if_fail'
       | #     if G_LIKELY(expr) { } else                                         \
       | #        ^
       | /usr/include/glib-2.0/glib/gmacros.h:385:43: note: expanded from macro 'G_LIKELY'
       | ##define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR((expr)), 1))
       | #                                          ^
       | /usr/include/glib-2.0/glib/gmacros.h:379:4: note: expanded from macro '_G_BOOLEAN_EXPR'
       | #   if (expr)                                    \
       | #   ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:330:5: note: Taking true branch
       | /usr/include/glib-2.0/glib/gmessages.h:594:6: note: expanded from macro 'g_return_val_if_fail'
       | #     if G_LIKELY(expr) { } else                                         \
       | #     ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:330:5: note: Loop condition is false.  Exiting loop
       | /usr/include/glib-2.0/glib/gmessages.h:593:40: note: expanded from macro 'g_return_val_if_fail'
       | ##define g_return_val_if_fail(expr,val)  G_STMT_START{                   \
       | #                                        ^
       | /usr/include/glib-2.0/glib/gmacros.h:346:23: note: expanded from macro 'G_STMT_START'
       | ##define G_STMT_START  do
       | #                      ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:331:5: note: Taking true branch
       | #    g_return_val_if_fail(vendor_id != NULL, NULL);
       | #    ^
       | /usr/include/glib-2.0/glib/gmessages.h:594:9: note: expanded from macro 'g_return_val_if_fail'
       | #     if G_LIKELY(expr) { } else                                         \
       | #        ^
       | /usr/include/glib-2.0/glib/gmacros.h:385:43: note: expanded from macro 'G_LIKELY'
       | ##define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR((expr)), 1))
       | #                                          ^
       | /usr/include/glib-2.0/glib/gmacros.h:379:4: note: expanded from macro '_G_BOOLEAN_EXPR'
       | #   if (expr)                                    \
       | #   ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:331:5: note: Taking true branch
       | /usr/include/glib-2.0/glib/gmessages.h:594:6: note: expanded from macro 'g_return_val_if_fail'
       | #     if G_LIKELY(expr) { } else                                         \
       | #     ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:331:5: note: Loop condition is false.  Exiting loop
       | /usr/include/glib-2.0/glib/gmessages.h:593:40: note: expanded from macro 'g_return_val_if_fail'
       | ##define g_return_val_if_fail(expr,val)  G_STMT_START{                   \
       | #                                        ^
       | /usr/include/glib-2.0/glib/gmacros.h:346:23: note: expanded from macro 'G_STMT_START'
       | ##define G_STMT_START  do
       | #                      ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:334:5: note: Loop condition is true.  Entering loop body
       | #    for (int i = 0; i < 10; ++i) {
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:340:13: note: Assuming the condition is false
       | #        if (stat(dev_path, &buf) != 0) {
       | #            ^~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:340:9: note: Taking false branch
       | #        if (stat(dev_path, &buf) != 0) {
       | #        ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:355:13: note: Assuming the condition is false
       | #        if (realpath(sys_path, device_link) == NULL) {
       | #            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:355:9: note: Taking false branch
       | #        if (realpath(sys_path, device_link) == NULL) {
       | #        ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:361:36: note: Calling 'parse_pci_address_from_sysfs_path'
       | #        PciAddress *drm_pci_addr = parse_pci_address_from_sysfs_path(device_link);
       | #                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:129:9: note: Assuming 'pos' is non-null
       | #    if (!pos) {
       | #        ^~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:129:5: note: Taking false branch
       | #    if (!pos) {
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:136:9: note: Assuming 'pos' is non-null
       | #    if (!pos) {
       | #        ^~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:136:5: note: Taking false branch
       | #    if (!pos) {
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:142:9: note: Assuming 'pos' is non-null
       | #    if (!pos) {
       | #        ^~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:142:5: note: Taking false branch
       | #    if (!pos) {
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:146:27: note: Calling 'pci_address_new'
       | #    PciAddress *address = pci_address_new();
       | #                          ^~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:61:12: note: Taking false branch
       | #    return g_new0(PciAddress, 1);
       | #           ^
       | /usr/include/glib-2.0/glib/gmem.h:279:42: note: expanded from macro 'g_new0'
       | ##define g_new0(struct_type, n_structs)                  _G_NEW (struct_type, n_structs, malloc0)
       | #                                                        ^
       | /usr/include/glib-2.0/glib/gmem.h:211:4: note: expanded from macro '_G_NEW'
       | #          if (__s == 1)                                         \
       | #          ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:61:12: note: Left side of '&&' is false
       | /usr/include/glib-2.0/glib/gmem.h:279:42: note: expanded from macro 'g_new0'
       | ##define g_new0(struct_type, n_structs)                  _G_NEW (struct_type, n_structs, malloc0)
       | #                                                        ^
       | /usr/include/glib-2.0/glib/gmem.h:213:40: note: expanded from macro '_G_NEW'
       | #          else if (__builtin_constant_p (__n) &&                \
       | #                                              ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:61:12: note: Null pointer value stored to field 'devices'
       | #    return g_new0(PciAddress, 1);
       | #           ^~~~~~~~~~~~~~~~~~~~~
       | /usr/include/glib-2.0/glib/gmem.h:279:42: note: expanded from macro 'g_new0'
       | ##define g_new0(struct_type, n_structs)                  _G_NEW (struct_type, n_structs, malloc0)
       | #                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | /usr/include/glib-2.0/glib/gmem.h:217:12: note: expanded from macro '_G_NEW'
       | #            __p = g_##func##_n (__n, __s);                      \
       | #                  ^~~~~~~~~~~~~~~~~~~~~~~
       | <scratch space>:76:1: note: expanded from here
       | #g_malloc0_n
       | #^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:146:27: note: Returning from 'pci_address_new'
       | #    PciAddress *address = pci_address_new();
       | #                          ^~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:149:5: note: Loop condition is true.  Entering loop body
       | #    while (pos) {
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:150:26: note: Taking false branch
       | #        PciDevice *dev = g_new0(PciDevice, 1);
       | #                         ^
       | /usr/include/glib-2.0/glib/gmem.h:279:42: note: expanded from macro 'g_new0'
       | ##define g_new0(struct_type, n_structs)                  _G_NEW (struct_type, n_structs, malloc0)
       | #                                                        ^
       | /usr/include/glib-2.0/glib/gmem.h:211:4: note: expanded from macro '_G_NEW'
       | #          if (__s == 1)                                         \
       | #          ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:150:26: note: Left side of '&&' is false
       | /usr/include/glib-2.0/glib/gmem.h:279:42: note: expanded from macro 'g_new0'
       | ##define g_new0(struct_type, n_structs)                  _G_NEW (struct_type, n_structs, malloc0)
       | #                                                        ^
       | /usr/include/glib-2.0/glib/gmem.h:213:40: note: expanded from macro '_G_NEW'
       | #          else if (__builtin_constant_p (__n) &&                \
       | #                                              ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:152:9: note: Taking true branch
       | #        if (!parse_pci_device(pos + 1, next, dev)) {
       | #        ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:154:13: note:  Execution continues on line 159
       | #            break;
       | #            ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:361:36: note: Returning from 'parse_pci_address_from_sysfs_path'
       | #        PciAddress *drm_pci_addr = parse_pci_address_from_sysfs_path(device_link);
       | #                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:362:9: note: Taking false branch
       | #        if (!drm_pci_addr) {
       | #        ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:367:14: note: Calling 'compare_addresses'
       | #        if (!compare_addresses(pci_addr, drm_pci_addr)) {
       | #             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:207:11: note: Assuming the condition is true
       | #    if (!(a->domain == b->domain
       | #          ^~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:207:11: note: Left side of '&&' is true
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:208:12: note: Assuming the condition is true
       | #        && g_list_length(a->devices) == g_list_length(b->devices))) {
       | #           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:207:5: note: Taking false branch
       | #    if (!(a->domain == b->domain
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:212:35: note: 'lb' initialized to a null pointer value
       | #    for (GList *la = a->devices, *lb = b->devices;
       | #                                  ^~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:213:10: note: Assuming 'la' is not equal to NULL
       | #         la != NULL;
       | #         ^~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:212:5: note: Loop condition is true.  Entering loop body
       | #    for (GList *la = a->devices, *lb = b->devices;
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:216:27: note: Access to field 'data' results in a dereference of a null pointer (loaded from variable 'lb')
       | #        PciDevice *devb = lb->data;
       | #                          ^~
       | #  214|            la = la->next, lb = lb->next) {
       | #  215|           PciDevice *deva = la->data;
       | #  216|->         PciDevice *devb = lb->data;
       | #  217|
       | #  218|           if (deva->slot != devb->slot
      Signed-off-by: 's avatarVictor Toso <victortoso@redhat.com>
      Acked-by: Frediano Ziglio's avatarFrediano Ziglio <fziglio@redhat.com>
      66935d13
    • Frediano Ziglio's avatar
      x11: Constify XEvent argument · af8d1948
      Frediano Ziglio authored
      No reasons to have it mutable.
      Signed-off-by: Frediano Ziglio's avatarFrediano Ziglio <fziglio@redhat.com>
      Acked-by: 's avatarVictor Toso <victortoso@redhat.com>
      af8d1948
    • Frediano Ziglio's avatar
      x11: Avoid passing XEvent as value · 3522667b
      Frediano Ziglio authored
      The structure is not that small and is not necessary to copy
      the value.
      This also removed a Coverity warning.
      Signed-off-by: Frediano Ziglio's avatarFrediano Ziglio <fziglio@redhat.com>
      Acked-by: 's avatarVictor Toso <victortoso@redhat.com>
      3522667b
    • Frediano Ziglio's avatar
      x11-randr: Avoid passing XEvent as value · b6dfef73
      Frediano Ziglio authored
      The structure is not that small and is not necessary to copy
      the value.
      This also removed a Coverity warning.
      Signed-off-by: Frediano Ziglio's avatarFrediano Ziglio <fziglio@redhat.com>
      Acked-by: 's avatarVictor Toso <victortoso@redhat.com>
      b6dfef73
  2. 19 Jul, 2019 4 commits
    • Victor Toso's avatar
      vdagent: simple fix for address-of-packed-member · 6bfbd03e
      Victor Toso authored
      Seems to be a false positive but as this message only happens when user
      client connects, we can copy this array to make compiling warn free.
      
       > src/vdagent/vdagent.c: In function ‘daemon_read_complete’:
       > src/vdagent/vdagent.c:226:71: error: taking address of packed member of
       >     ‘struct VDAgentAudioVolumeSync’ may result in an unaligned pointer
       >     value [-Werror=address-of-packed-member]
       >   226 |             vdagent_audio_playback_sync(avs->mute, avs->nchannels, avs->volume);
       >       |                                                                    ~~~^~~~~~~~
       > src/vdagent/vdagent.c:228:69: error: taking address of packed member of
       >     ‘struct VDAgentAudioVolumeSync’ may result in an unaligned pointer
       >     value [-Werror=address-of-packed-member]
       >   228 |             vdagent_audio_record_sync(avs->mute, avs->nchannels, avs->volume);
       >       |                                                                  ~~~^~~~~~~~
      Signed-off-by: 's avatarVictor Toso <victortoso@redhat.com>
      Acked-by: Frediano Ziglio's avatarFrediano Ziglio <fziglio@redhat.com>
      6bfbd03e
    • Victor Toso's avatar
      x11-randr: simplest fix for address-of-packed-member · 7976dc31
      Victor Toso authored
      The struct type for width/height is uint32_t while we are trying to
      access and change it with int* - code can be improved a bit in following
      patches but this one fixes the warning by copying the value from the
      struct and copying back new value afterwards.
      
      Also:
      - Moved variables to internal scope;
      - Added braces to inner if;
      
       > src/vdagent/x11-randr.c: In function ‘zero_base_monitors’:
       >     src/vdagent/x11-randr.c:621:28: error: taking address of packed member of
       >     ‘struct VDAgentMonConfig’ may result in an unaligned pointer value
       > [-Werror=address-of-packed-member]
       >   621 |         mon_width = (int *)&mon_config->monitors[i].width;
       >       |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > src/vdagent/x11-randr.c:622:29: error: taking address of packed member of
       >     ‘struct VDAgentMonConfig’ may result in an unaligned pointer value
       >     [-Werror=address-of-packed-member]
       >   622 |         mon_height = (int *)&mon_config->monitors[i].height;
       >       |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Signed-off-by: 's avatarVictor Toso <victortoso@redhat.com>
      Acked-by: Frediano Ziglio's avatarFrediano Ziglio <fziglio@redhat.com>
      7976dc31
    • Victor Toso's avatar
      x11-randr: use glib's MAX and MIN · 70c5908f
      Victor Toso authored
      Since 28618682 "randr: remove monitors.xml on auto-configuration" in
      2015-04-10 by Marc-Andre Lureau <marcandre.lureau@redhat.com> this
      file includes glib.h and can remove those helpers.
      Signed-off-by: 's avatarVictor Toso <victortoso@redhat.com>
      Acked-by: Frediano Ziglio's avatarFrediano Ziglio <fziglio@redhat.com>
      70c5908f
    • Victor Toso's avatar
      vdagent: fix memory leak of g_memdup() · b6fde164
      Victor Toso authored
      Found by covscan:
      
       | spice-vdagent-0.19.0/src/vdagent/vdagent.c:432:9: warning: Potential leak of memory pointed to by 'orig_argv'
       | #        g_printerr("Invalid arguments, %s\n", error->message);
       | #        ^
       | spice-vdagent-0.19.0/src/vdagent/vdagent.c:418:24: note: Memory is allocated
       | #    char **orig_argv = g_memdup(argv, sizeof(char*) * (argc+1));
       | #                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/vdagent.c:431:9: note: Assuming 'error' is not equal to NULL
       | #    if (error != NULL) {
       | #        ^~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/vdagent.c:431:5: note: Taking true branch
       | #    if (error != NULL) {
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/vdagent.c:432:9: note: Potential leak of memory pointed to by 'orig_argv'
       | #        g_printerr("Invalid arguments, %s\n", error->message);
       | #        ^
       | #  430|
       | #  431|       if (error != NULL) {
       | #  432|->         g_printerr("Invalid arguments, %s\n", error->message);
       | #  433|           g_clear_error(&error);
       | #  434|           return -1;
      Signed-off-by: 's avatarVictor Toso <victortoso@redhat.com>
      Acked-by: Frediano Ziglio's avatarFrediano Ziglio <fziglio@redhat.com>
      b6fde164
  3. 12 Apr, 2019 3 commits
  4. 08 Mar, 2019 5 commits
  5. 01 Mar, 2019 3 commits
  6. 27 Feb, 2019 2 commits
  7. 25 Feb, 2019 1 commit
    • Jakub Janků's avatar
      x11: invalidate requests for targets on grab from client · 3aff7839
      Jakub Janků authored
      If XSetSelectionOwner() is invoked during the time
      we are waiting for the requested clipboard targets,
      the targets we eventually receive are no longer valid.
      
      To solve this, ignore the same count of target notifications
      as we expected at the time we received grab from the client.
      
      Otherwise we end up in a situation when vdagent holds
      the clipboard grab in the guest but cannot provide data to the
      apps that request it - this can be observed in the log:
      
          clipboard: received selection request event for target *, while not owning client clipboard
      Signed-off-by: Jakub Janků's avatarJakub Janků <jjanku@redhat.com>
      Acked-by: 's avatarVictor Toso <victortoso@redhat.com>
      3aff7839
  8. 22 Feb, 2019 1 commit
    • Jakub Janků's avatar
      clipboard: cancel request for targets on grab from client · 783ceece
      Jakub Janků authored
      If gtk_clipboard_set_with_data() is invoked between
      gtk_clipboard_request_targets() and the
      GtkClipboardTargetsReceivedFunc callback,
      the targets we eventually receive are no longer valid.
      
      To solve this, cancel the request in vdagent_clipboard_grab().
      
      Otherwise we end up in a situation when vdagent holds
      clipboard grab in the guest but cannot provide data to the
      apps that request it - this can be observed in the log:
      
          CRITICAL **: 20:48:55.782: clipboard_get_cb: assertion 'c->selections[sel_id].owner == OWNER_CLIENT' failed
      Signed-off-by: Jakub Janků's avatarJakub Janků <jjanku@redhat.com>
      Acked-by: 's avatarVictor Toso <victortoso@redhat.com>
      783ceece
  9. 20 Feb, 2019 1 commit
  10. 05 Feb, 2019 1 commit
  11. 31 Jan, 2019 2 commits
  12. 30 Jan, 2019 1 commit
  13. 29 Jan, 2019 8 commits
    • Jonathon Jongsma's avatar
      Send device info to agent when it connects · 67f3a09c
      Jonathon Jongsma authored
      Previously, the device info was only sent from the daemon to the session
      agent when we receive the device info message from the host. That means
      that if the session agent exits and reconnects, the session agent will
      not have the device info necessary to translate spice display IDs to
      guest device outputs. This patch saves the last device info message that
      was received from the host, and re-sends it to the session agent when it
      reconnects.
      
      NOTE: this may not be necessary if the server simply re-sends a device
      info message when it detects that the agent has connected...
      Acked-by: Lukáš Hrázký's avatarLukáš Hrázký <lhrazky@redhat.com>
      Signed-off-by: 's avatarJonathon Jongsma <jjongsma@redhat.com>
      67f3a09c
    • Jonathon Jongsma's avatar
      Send display_id down to the vdagentd daemon · 5ad18905
      Jonathon Jongsma authored
      Add a display_id field to the structure that we use to send down the
      list of guest display resolutions to the vdagentd daemon. This allows us
      to map the spice display id to the proper X display for determining
      mouse locations, etc.
      
      In the case where we have an mjpeg plugin running in the streaming
      agent, we have two spice displays representing the same guest display.
      In that scenario, the session agent may maintain the following guest
      output mapping:
       spice channel 0 (QXL) => X output 0
       spice channel 1 (streaming-agent) => X output 0
      
      While this is not necessarily a supported scenario, it would be nice if
      the cursor input worked properly in this case. The root problem is that
      when the session agent sends down the guest xorg resolutions to the
      system daemon, it simply loops through the list of xorg displays, and
      for each X display it looks up the first spice display ID associated
      with it and sends that down to the daemon. In the scenario mentioned
      above, since there is only a single X display configured (albeit
      represented by two different spice displays), we would send down a
      single display resolution to the system daemon:
       - { width=1280, height=1024, x=0, y=0, display_id=0 }
      
      Notice that there is no entry for display_id=1. When the agent receives
      a cursor input message for display channel 1, that message will get
      passed to the systemn daemon, which will attempt to look up display_id 1
      in order to convert the event coordinates to global coordinates. Finding
      no entry for display_id=1, the mouse events do not work.
      
      In this patch, when we want to send the guest resolutions down to the
      system daemon, we still loop through the list of X outputs, but for each
      output we also loop through the guest output mapping table and send a
      resolution structure down to the daemon for each registered output
      mapping.  This means that in the previously mentioned scenario, we would
      send down the following information:
       - { width=1280, height=1024, x=0, y=0, display_id=0 }
       - { width=1280, height=1024, x=0, y=0, display_id=1 }
      
       This means that when the client sends a mouse event for display_id=1,
       the system daemon knows the coordinates of the guest display associated
       with that ID and can process the mouse event properly.
      Acked-by: Lukáš Hrázký's avatarLukáš Hrázký <lhrazky@redhat.com>
      Signed-off-by: 's avatarJonathon Jongsma <jjongsma@redhat.com>
      5ad18905
    • Jonathon Jongsma's avatar
      Use new function in vdagent_x11_send_daemon_guest_xorg_res() · 5374fcc5
      Jonathon Jongsma authored
      Rather than getting the current guest resolution in a
      VDAgentMonitorsConfig struct and then translating it to a new struct
      type for sending down to the daemon, simply use the new function that
      was factored out in a previous commit and populate the message struct
      directly.
      Acked-by: Lukáš Hrázký's avatarLukáš Hrázký <lhrazky@redhat.com>
      Signed-off-by: 's avatarJonathon Jongsma <jjongsma@redhat.com>
      5374fcc5
    • Jonathon Jongsma's avatar
      Factor a function out of get_current_mon_config() · 254b5472
      Jonathon Jongsma authored
      When sending the guest xorg resolution to the vdagentd daemon, we get
      the current resolution with this function, which returns a
      VDAgentMonitorsConfig structure that must then be converted to the
      structure that we send to the daemon. Rather than re-using this function
      that returns the wrong type, factor out most of the functionality into a
      separate function. This function can be used by a new function to return
      a type appropriate for sending the xorg resolution to the daemon.
      
      This is necessary because in the next few commits I'll be changing the
      vdagentd protocol to send an additional display_id parameter to the
      daemon.
      Acked-by: Lukáš Hrázký's avatarLukáš Hrázký <lhrazky@redhat.com>
      Signed-off-by: 's avatarJonathon Jongsma <jjongsma@redhat.com>
      254b5472
    • Jonathon Jongsma's avatar
      Use guest output map to determine xrandr output · d48945fd
      Jonathon Jongsma authored
      instead of using the spice display id directly as the xrandr output,
      look it up using our new guest output map
      Acked-by: Lukáš Hrázký's avatarLukáš Hrázký <lhrazky@redhat.com>
      Signed-off-by: 's avatarJonathon Jongsma <jjongsma@redhat.com>
      d48945fd
    • Jonathon Jongsma's avatar
      Make clearer distinctions between output ids · 0e7e7b66
      Jonathon Jongsma authored
      There are basically three ways to refer to an output within vdagent:
        - The index of the array of MonitorConfig message. This is essentially
          a "spice display id"
        - the index of the array of xrandr outputs. This is the "output index"
        - the xrandr output id. This is the "output ID"
      
      Previously, the "spice display id" and the "output index" were treated
      as synonymous. But in order to support more complciated setups with
      multiple display devices, etc, we need to differentiate these ideas more
      clearly. This patch simply renames some variables and a function so that
      we can tell more easily which one of these concepts we are dealing with.
      Acked-by: Lukáš Hrázký's avatarLukáš Hrázký <lhrazky@redhat.com>
      Signed-off-by: 's avatarJonathon Jongsma <jjongsma@redhat.com>
      0e7e7b66
    • Jonathon Jongsma's avatar
      Look up and store xrandr output in display map · 353592e8
      Jonathon Jongsma authored
      Instead of storing each device address and device display ID in the hash
      table, simply use the lookup_xrandr_output_for_device_info() function to
      look up the ID of the xrandr output and store that in the hash table.
      Acked-by: Lukáš Hrázký's avatarLukáš Hrázký <lhrazky@redhat.com>
      Signed-off-by: 's avatarJonathon Jongsma <jjongsma@redhat.com>
      353592e8
    • Jonathon Jongsma's avatar
      Add lookup_xrand_output_for_device_info() · 8dc49074
      Jonathon Jongsma authored
      Add a function to look up an xrandr output for a given device display
      id. This uses sysfs and the drm subsystem to lookup information about a
      graphics device output. It then compares the drm output name to xrandr
      output names to try to match that device output to an xrandr output.
      This is necesary for guests that have multiple graphics devices.
      Acked-by: Lukáš Hrázký's avatarLukáš Hrázký <lhrazky@redhat.com>
      Signed-off-by: 's avatarJonathon Jongsma <jjongsma@redhat.com>
      8dc49074
  14. 28 Jan, 2019 1 commit
  15. 26 Jan, 2019 1 commit
  16. 17 Jan, 2019 1 commit