[virt-tools-list] virt-viewer fails to build with spice-gtk

Martin Kletzander mkletzan at redhat.com
Thu Mar 13 08:16:00 UTC 2014


Hi everyone.

I'm building virt-viewer from git and for some time I had to have
commit  d1d53d0c8b5600f61e55e472c592ebc86a65ee6f reverded, but only
now I got the time to discover why.

I'm building with upstream spice (and spice common and spice-protocol)
from git and spice-gtk-0.23.  The commit mentioned adds this line of
code:

#if defined(SPICE_GTK_CHECK_VERSION) && SPICE_GTK_CHECK_VERSION(0, 23, 21)

which looks ok, but in my case there are 2 problems and I don't know
which one to solve (send patch for) first.  Both are caused by the
fact that even though configure finds the spice-gtk and everything as
expected (--with-spice-gtk without problems), the macro
SPICE_GTK_CHECK_VERSION is not defined.

First question: Is this due to my old spice-gtk (is upstream 0.23
release too old for this)?

Second problem: That macro not being defined doesn't skip the second
part of that condition, therefore the compiler complains:

---8<--------------------------->8---

virt-viewer-session-spice.c: In function 'virt_viewer_session_spice_main_channel_event':
virt-viewer-session-spice.c:525:64: error: missing binary operator before token "("
 #if defined(SPICE_GTK_CHECK_VERSION) && SPICE_GTK_CHECK_VERSION(0, 23, 21)
                                                                ^
virt-viewer-session-spice.c:476:19: warning: unused variable 'error'
[-Wunused-variable] const GError *error;
                                  ^
---8<--------------------------->8---

This should be easily fixable with the following patch (which I'm
ready to send to the list as a fix), but I would like to know
beforehand if that's all I need to do or if there's something wrong
with that macro not being defined as well.

Thank you,
Martin

diff --git i/src/virt-viewer-session-spice.c w/src/virt-viewer-session-spice.c
index 1740ba3..fb63c9c 100644
--- i/src/virt-viewer-session-spice.c
+++ w/src/virt-viewer-session-spice.c
@@ -473,7 +473,6 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel G_GNUC_UNUSED
                                              SpiceChannelEvent event,
                                              VirtViewerSession *session)
 {
-    const GError *error;
     VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
     gchar *password = NULL, *user = NULL;
     int ret;
@@ -522,8 +521,10 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel G_GNUC_UNUSED
         }
         break;
     case SPICE_CHANNEL_ERROR_CONNECT:
-#if defined(SPICE_GTK_CHECK_VERSION) && SPICE_GTK_CHECK_VERSION(0, 23, 21)
-        error = spice_channel_get_error(channel);
+#if defined(SPICE_GTK_CHECK_VERSION)
+# if SPICE_GTK_CHECK_VERSION(0, 23, 21)
+    {
+        const GError *error = spice_channel_get_error(channel);

         DEBUG_LOG("main channel: failed to connect %s", error ? error->message : "");

@@ -545,6 +546,11 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel G_GNUC_UNUSED
         } else {
             g_signal_emit_by_name(session, "session-disconnected");
         }
+    }
+# else
+        DEBUG_LOG("main channel: failed to connect");
+        g_signal_emit_by_name(session, "session-disconnected");
+# endif
 #else
         DEBUG_LOG("main channel: failed to connect");
         g_signal_emit_by_name(session, "session-disconnected");
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20140313/5df688da/attachment.sig>


More information about the virt-tools-list mailing list