Re: [virt-tools-list] [PATCH virt-viewer v2] remote-viewer: Prefer ca-cert from display instead of proxy

2019-10-11 Thread Eduardo Lima (Etrunko)

On 10/11/19 12:35 PM, Victor Toso wrote:

Hi,

On Fri, Oct 11, 2019 at 11:07:25AM -0300, Eduardo Lima (Etrunko) wrote:

Since oVirt engine version 4.3.2.1, the API returns certificate data for
display connection in the VM XML, so users do not need to specify it
from the command line anymore. The certificate obtained from the XML
gets precedence over the one from the command line, which is still kept
to keep compatibility of older versions of oVirt.

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

Signed-off-by: Eduardo Lima (Etrunko) 


Much nicer! Many thanks for that,

 Acked-by: Victor Toso 


Pushed now, thanks.




---
  src/remote-viewer.c | 12 ++--
  1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 8eaa72e..2450096 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -540,7 +540,8 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, 
GError **err)
  #ifdef HAVE_SPICE_GTK
  if (type == OVIRT_VM_DISPLAY_SPICE) {
  SpiceSession *session;
-GByteArray *ca_cert;
+GByteArray *ca_cert = NULL;
+const char *from = "display";
  
  session = remote_viewer_get_spice_session(REMOTE_VIEWER(app));

  g_object_set(G_OBJECT(session),
@@ -548,12 +549,19 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, 
GError **err)
   "cert-subject", host_subject,
   "proxy", proxy_url,
   NULL);
-g_object_get(G_OBJECT(proxy), "ca-cert", _cert, NULL);
+
+g_object_get(G_OBJECT(display), "ca-cert", _cert, NULL);
+if (ca_cert == NULL) {
+g_object_get(G_OBJECT(proxy), "ca-cert", _cert, NULL);
+from = "proxy";
+}
+
  if (ca_cert != NULL) {
  g_object_set(G_OBJECT(session),
  "ca", ca_cert,
  NULL);
  g_byte_array_unref(ca_cert);
+g_debug("Using ca-cert from %s", from);
  }
  }
  #endif
--
2.21.0

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list



--
Eduardo de Barros Lima (Etrunko)
Software Engineer - Red Hat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer v2] remote-viewer: Prefer ca-cert from display instead of proxy

2019-10-11 Thread Eduardo Lima (Etrunko)
Since oVirt engine version 4.3.2.1, the API returns certificate data for
display connection in the VM XML, so users do not need to specify it
from the command line anymore. The certificate obtained from the XML
gets precedence over the one from the command line, which is still kept
to keep compatibility of older versions of oVirt.

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

Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/remote-viewer.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 8eaa72e..2450096 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -540,7 +540,8 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, 
GError **err)
 #ifdef HAVE_SPICE_GTK
 if (type == OVIRT_VM_DISPLAY_SPICE) {
 SpiceSession *session;
-GByteArray *ca_cert;
+GByteArray *ca_cert = NULL;
+const char *from = "display";
 
 session = remote_viewer_get_spice_session(REMOTE_VIEWER(app));
 g_object_set(G_OBJECT(session),
@@ -548,12 +549,19 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, 
GError **err)
  "cert-subject", host_subject,
  "proxy", proxy_url,
  NULL);
-g_object_get(G_OBJECT(proxy), "ca-cert", _cert, NULL);
+
+g_object_get(G_OBJECT(display), "ca-cert", _cert, NULL);
+if (ca_cert == NULL) {
+g_object_get(G_OBJECT(proxy), "ca-cert", _cert, NULL);
+from = "proxy";
+}
+
 if (ca_cert != NULL) {
 g_object_set(G_OBJECT(session),
 "ca", ca_cert,
 NULL);
 g_byte_array_unref(ca_cert);
+g_debug("Using ca-cert from %s", from);
 }
 }
 #endif
-- 
2.21.0

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer] remote-viewer: Prefer ca-cert from display instead of proxy

2019-10-03 Thread Eduardo Lima (Etrunko)
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1402909

Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/remote-viewer.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 5c7a379..71f9a23 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -542,7 +542,7 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, 
GError **err)
 #ifdef HAVE_SPICE_GTK
 if (type == OVIRT_VM_DISPLAY_SPICE) {
 SpiceSession *session;
-GByteArray *ca_cert;
+GByteArray *ca_cert = NULL;
 
 session = remote_viewer_get_spice_session(REMOTE_VIEWER(app));
 g_object_set(G_OBJECT(session),
@@ -550,7 +550,12 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, 
GError **err)
  "cert-subject", host_subject,
  "proxy", proxy_url,
  NULL);
-g_object_get(G_OBJECT(proxy), "ca-cert", _cert, NULL);
+
+g_object_get(G_OBJECT(display), "ca-cert", _cert, NULL);
+if (ca_cert == NULL) {
+g_object_get(G_OBJECT(proxy), "ca-cert", _cert, NULL);
+}
+
 if (ca_cert != NULL) {
 g_object_set(G_OBJECT(session),
 "ca", ca_cert,
-- 
2.21.0

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH v4] remote-viewer: fix free on dangling pointer

2019-10-03 Thread Eduardo Lima (Etrunko)

On 10/3/19 7:12 AM, Victor Toso wrote:

From: Victor Toso 

On remote_viewer_session_connected() we are passing a dup of URI of
connection and freeing it afterwards. Problem is, we don't disconnect
from listening "session-connected" and on an eventual second emission
of this signal, remote-viewer crashes as seen in the backtrace below.

This can happen over switch-host migration message from
SpiceMainChannel.

A fix trying to use VirtViewerApp URI avoid the crash but introduces
regression while running remote-viewer with ovirt so, keeping the
changes to a minimum to avoid it, just use g_intern_string() for now.

Found it while improving migrate.py from spice/tests (server):
  | Invalid free() / delete / delete[] / realloc()
  |at 0x4839A0C: free (vg_replace_malloc.c:540)
  |by 0x56EBD8C: g_free (in /usr/lib64/libglib-2.0.so.0.6000.6)
  |by 0x11DED0: remote_viewer_session_connected (remote-viewer.c:658)
  |by 0x564D741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566AF68: g_signal_emit_by_name (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x135E5D: virt_viewer_session_spice_main_channel_event 
(virt-viewer-session-spice.c:699)
  |by 0x564D741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x53149E3: emit_main_context (gio-coroutine.c:198)
  |  Address 0x18f1ecc0 is 0 bytes inside a block of size 23 free'd
  |at 0x4839A0C: free (vg_replace_malloc.c:540)
  |by 0x56EBD8C: g_free (in /usr/lib64/libglib-2.0.so.0.6000.6)
  |by 0x11DED0: remote_viewer_session_connected (remote-viewer.c:658)
  |by 0x564D741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566AF68: g_signal_emit_by_name (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x135E5D: virt_viewer_session_spice_main_channel_event 
(virt-viewer-session-spice.c:699)
  |by 0x564D741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x53149E3: emit_main_context (gio-coroutine.c:198)
  |  Block was alloc'd at
  |at 0x483880B: malloc (vg_replace_malloc.c:309)
  |by 0x56EBC98: g_malloc (in /usr/lib64/libglib-2.0.so.0.6000.6)
  |by 0x5705C43: g_strdup (in /usr/lib64/libglib-2.0.so.0.6000.6)
  |by 0x11EB80: remote_viewer_initial_connect (remote-viewer.c:696)
  |by 0x11EB80: remote_viewer_start (remote-viewer.c:790)
  |by 0x1250D3: virt_viewer_app_start (virt-viewer-app.c:1727)
  |by 0x127108: virt_viewer_app_on_application_startup 
(virt-viewer-app.c:1870)
  |by 0x564D741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x5661638: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A972: g_signal_emit (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x553ECA1: g_application_register (in 
/usr/lib64/libgio-2.0.so.0.6000.6)
  |by 0x553F41D: g_application_run (in /usr/lib64/libgio-2.0.so.0.6000.6)

Signed-off-by: Victor Toso 
---
  src/remote-viewer.c | 10 +++---
  1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 8938ef9..8eaa72e 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -645,17 +645,13 @@ remote_viewer_recent_add(gchar *uri, const gchar 
*mime_type)
  
  static void

  remote_viewer_session_connected(VirtViewerSession *session,
-gchar *guri)
+const gchar *guri)
  {
  gchar *uri = virt_viewer_session_get_uri(session);
  const gchar *mime = virt_viewer_session_mime_type(session);
  
-if (uri == NULL)

-uri = g_strdup(guri);
-
-remote_viewer_recent_add(uri, mime);
+remote_viewer_recent_add(uri != NULL ? uri : (char *) guri, mime);


Acked-by: Eduardo Lima (Etrunko) 

IMO, removing the "!= NULL" test would make it easier to read, but it is 
just my preference.



  g_free(uri);
-g_free(guri);
  }
  
  static gchar *

@@ -694,7 +690,7 @@ remote_viewer_initial_connect(RemoteViewer *self, const 
gchar *type, const gchar
  }
  
  g_signal_connect(virt_viewer_app_get_session(app), "session-connected",

- G_CALLBACK(remote_viewer_session_connected), 
g_strdup(guri));
+ G_CALLBACK(remote_viewer_session_connected

Re: [virt-tools-list] [PATCH v2] remote-viewer: fix free on dangling pointer

2019-10-01 Thread Eduardo Lima (Etrunko)

On 10/1/19 12:51 PM, Victor Toso wrote:

Hi,

On Tue, Oct 01, 2019 at 11:17:22AM -0300, Eduardo Lima (Etrunko) wrote:

On 10/1/19 7:09 AM, Victor Toso wrote:

Patch builds now, but I started getting some warning when
connecting to ovirt:// uri.

(remote-viewer:16940): virt-viewer-CRITICAL **: 11:00:14.560:
remote_viewer_recent_add: assertion 'uri != NULL' failed


Right, this refactor is not straightforward on ovirt
codepath.  Thanks for testing it properly. I've sent a v3
without touching ovirt code now.


The warning is still present with your new patch, without it
applied, no warnings are shown.


Ovirt is not that easy to poke. Couldn't reproduce the warning
because I'm not able to connect to running ovirt with Fedora 31.
Tried with master from libgovirt, no luck.


I see, and taking a better look at ovirt in Fedora, it seems very 
outdated with upstream release. I will work on updating the package 
there. In the meantime we can try




As mentioned in the commit log, passing a g_strdup() + g_free()
to a signal that can be triggered more than once is problematic
by itself so, suggestions welcome.



One alternative solution would be usage of g_intern_string() so there is 
no need to free it anymore. Your patch would become something like the 
following:


diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index bd8c2eb..5c7a379 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -657,7 +657,6 @@ remote_viewer_session_connected(VirtViewerSession 
*session,


 remote_viewer_recent_add(uri, mime);
 g_free(uri);
-g_free(guri);
 }

 static gchar *
@@ -696,7 +695,7 @@ remote_viewer_initial_connect(RemoteViewer *self, 
const gchar *type, const gchar

 }

 g_signal_connect(virt_viewer_app_get_session(app), 
"session-connected",
- G_CALLBACK(remote_viewer_session_connected), 
g_strdup(guri));
+ G_CALLBACK(remote_viewer_session_connected), 
(gchar*) g_intern_string(guri));


 virt_viewer_session_set_file(virt_viewer_app_get_session(app), 
vvfile);

 #ifdef HAVE_OVIRT





Cheers,





static gchar *
@@ -675,14 +677,14 @@ read_all_stdin(gsize *len, GError **err)
}
static gboolean
-remote_viewer_initial_connect(RemoteViewer *self, const gchar *type, const 
gchar *guri,
+remote_viewer_initial_connect(RemoteViewer *self, const gchar *type,
  VirtViewerFile *vvfile, GError **error)
{
VirtViewerApp *app = VIRT_VIEWER_APP(self);
#ifdef HAVE_OVIRT
if (g_strcmp0(type, "ovirt") == 0) {
-if (!create_ovirt_session(app, guri, error)) {
+if (!create_ovirt_session(app, error)) {
g_prefix_error(error, _("Couldn't open oVirt session: "));
return FALSE;
}
@@ -694,7 +696,7 @@ remote_viewer_initial_connect(RemoteViewer *self, const 
gchar *type, const gchar
}
g_signal_connect(virt_viewer_app_get_session(app), "session-connected",
- G_CALLBACK(remote_viewer_session_connected), 
g_strdup(guri));
+ G_CALLBACK(remote_viewer_session_connected), app);
virt_viewer_session_set_file(virt_viewer_app_get_session(app), vvfile);
#ifdef HAVE_OVIRT
@@ -787,7 +789,7 @@ retry_dialog:
_("Cannot determine the connection type from 
URI"));
goto cleanup;
}
-if (!remote_viewer_initial_connect(self, type, guri, vvfile, ))
+if (!remote_viewer_initial_connect(self, type, vvfile, ))
goto cleanup;
}




--
Eduardo de Barros Lima (Etrunko)
Software Engineer - Red Hat
etru...@redhat.com



--
Eduardo de Barros Lima (Etrunko)
Software Engineer - Red Hat
etru...@redhat.com



--
Eduardo de Barros Lima (Etrunko)
Software Engineer - Red Hat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH v2] remote-viewer: fix free on dangling pointer

2019-10-01 Thread Eduardo Lima (Etrunko)

On 10/1/19 7:09 AM, Victor Toso wrote:

Hi,

On Mon, Sep 30, 2019 at 11:01:42AM -0300, Eduardo Lima (Etrunko) wrote:

On 9/30/19 5:08 AM, Victor Toso wrote:

From: Victor Toso 

On remote_viewer_session_connected() we are passing a dup of URI of
connection and freeing it afterwards. Problem is, we don't disconnect
from listening "session-connected" and on an eventual second emission
of this signal, remote-viewer crashes as seen in the backtrace below.

This can happen over switch-host migration message from
SpiceMainChannel.

To fix the issue, use VirtViewerApp URI information instead of passing
a dup char*. The other changes in this patch were warnings of unused
variables.

Found it while improving migrate.py from spice/tests (server):
   | Invalid free() / delete / delete[] / realloc()
   |at 0x4839A0C: free (vg_replace_malloc.c:540)
   |by 0x56EBD8C: g_free (in /usr/lib64/libglib-2.0.so.0.6000.6)
   |by 0x11DED0: remote_viewer_session_connected (remote-viewer.c:658)
   |by 0x564D741: g_closure_invoke (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x566AF68: g_signal_emit_by_name (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x135E5D: virt_viewer_session_spice_main_channel_event 
(virt-viewer-session-spice.c:699)
   |by 0x564D741: g_closure_invoke (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x53149E3: emit_main_context (gio-coroutine.c:198)
   |  Address 0x18f1ecc0 is 0 bytes inside a block of size 23 free'd
   |at 0x4839A0C: free (vg_replace_malloc.c:540)
   |by 0x56EBD8C: g_free (in /usr/lib64/libglib-2.0.so.0.6000.6)
   |by 0x11DED0: remote_viewer_session_connected (remote-viewer.c:658)
   |by 0x564D741: g_closure_invoke (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x566AF68: g_signal_emit_by_name (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x135E5D: virt_viewer_session_spice_main_channel_event 
(virt-viewer-session-spice.c:699)
   |by 0x564D741: g_closure_invoke (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x53149E3: emit_main_context (gio-coroutine.c:198)
   |  Block was alloc'd at
   |at 0x483880B: malloc (vg_replace_malloc.c:309)
   |by 0x56EBC98: g_malloc (in /usr/lib64/libglib-2.0.so.0.6000.6)
   |by 0x5705C43: g_strdup (in /usr/lib64/libglib-2.0.so.0.6000.6)
   |by 0x11EB80: remote_viewer_initial_connect (remote-viewer.c:696)
   |by 0x11EB80: remote_viewer_start (remote-viewer.c:790)
   |by 0x1250D3: virt_viewer_app_start (virt-viewer-app.c:1727)
   |by 0x127108: virt_viewer_app_on_application_startup 
(virt-viewer-app.c:1870)
   |by 0x564D741: g_closure_invoke (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x5661638: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x566A972: g_signal_emit (in /usr/lib64/libgobject-2.0.so.0.6000.6)
   |by 0x553ECA1: g_application_register (in 
/usr/lib64/libgio-2.0.so.0.6000.6)
   |by 0x553F41D: g_application_run (in /usr/lib64/libgio-2.0.so.0.6000.6)

Signed-off-by: Victor Toso 
---
   src/remote-viewer.c | 18 ++
   1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 8938ef9..7cad231 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -396,7 +396,7 @@ virt_viewer_app_set_ovirt_foreign_menu(VirtViewerApp *app,
   }
   static gboolean
-create_ovirt_session(VirtViewerApp *app, const char *uri, GError **err)
+create_ovirt_session(VirtViewerApp *app, GError **err)
   {
   OvirtProxy *proxy = NULL;
   OvirtApi *api = NULL;
@@ -421,9 +421,11 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, 
GError **err)
   gchar *ticket = NULL;
   gchar *host_subject = NULL;
   gchar *guid = NULL;
+gchar *uri = NULL;
   g_return_val_if_fail(VIRT_VIEWER_IS_APP(app), FALSE);
+g_object_get(app, "guri", , NULL);
   if (!parse_ovirt_uri(uri, _uri, _name, )) {
   g_set_error_literal(, VIRT_VIEWER_ERROR, 
VIRT_VIEWER_ERROR_FAILED,
   _("failed to parse ovirt uri"));
@@ -561,6 +563,7 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, 
GError **err)
   success = TRUE;
   error:
+g_free(uri);
   g_free(username);
   g

Re: [virt-tools-list] [PATCH v2] remote-viewer: fix free on dangling pointer

2019-09-30 Thread Eduardo Lima (Etrunko)

On 9/30/19 5:08 AM, Victor Toso wrote:

From: Victor Toso 

On remote_viewer_session_connected() we are passing a dup of URI of
connection and freeing it afterwards. Problem is, we don't disconnect
from listening "session-connected" and on an eventual second emission
of this signal, remote-viewer crashes as seen in the backtrace below.

This can happen over switch-host migration message from
SpiceMainChannel.

To fix the issue, use VirtViewerApp URI information instead of passing
a dup char*. The other changes in this patch were warnings of unused
variables.

Found it while improving migrate.py from spice/tests (server):
  | Invalid free() / delete / delete[] / realloc()
  |at 0x4839A0C: free (vg_replace_malloc.c:540)
  |by 0x56EBD8C: g_free (in /usr/lib64/libglib-2.0.so.0.6000.6)
  |by 0x11DED0: remote_viewer_session_connected (remote-viewer.c:658)
  |by 0x564D741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566AF68: g_signal_emit_by_name (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x135E5D: virt_viewer_session_spice_main_channel_event 
(virt-viewer-session-spice.c:699)
  |by 0x564D741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x53149E3: emit_main_context (gio-coroutine.c:198)
  |  Address 0x18f1ecc0 is 0 bytes inside a block of size 23 free'd
  |at 0x4839A0C: free (vg_replace_malloc.c:540)
  |by 0x56EBD8C: g_free (in /usr/lib64/libglib-2.0.so.0.6000.6)
  |by 0x11DED0: remote_viewer_session_connected (remote-viewer.c:658)
  |by 0x564D741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566AF68: g_signal_emit_by_name (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x135E5D: virt_viewer_session_spice_main_channel_event 
(virt-viewer-session-spice.c:699)
  |by 0x564D741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x53149E3: emit_main_context (gio-coroutine.c:198)
  |  Block was alloc'd at
  |at 0x483880B: malloc (vg_replace_malloc.c:309)
  |by 0x56EBC98: g_malloc (in /usr/lib64/libglib-2.0.so.0.6000.6)
  |by 0x5705C43: g_strdup (in /usr/lib64/libglib-2.0.so.0.6000.6)
  |by 0x11EB80: remote_viewer_initial_connect (remote-viewer.c:696)
  |by 0x11EB80: remote_viewer_start (remote-viewer.c:790)
  |by 0x1250D3: virt_viewer_app_start (virt-viewer-app.c:1727)
  |by 0x127108: virt_viewer_app_on_application_startup 
(virt-viewer-app.c:1870)
  |by 0x564D741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x5661638: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A972: g_signal_emit (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x553ECA1: g_application_register (in 
/usr/lib64/libgio-2.0.so.0.6000.6)
  |by 0x553F41D: g_application_run (in /usr/lib64/libgio-2.0.so.0.6000.6)

Signed-off-by: Victor Toso 
---
  src/remote-viewer.c | 18 ++
  1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 8938ef9..7cad231 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -396,7 +396,7 @@ virt_viewer_app_set_ovirt_foreign_menu(VirtViewerApp *app,
  }
  
  static gboolean

-create_ovirt_session(VirtViewerApp *app, const char *uri, GError **err)
+create_ovirt_session(VirtViewerApp *app, GError **err)
  {
  OvirtProxy *proxy = NULL;
  OvirtApi *api = NULL;
@@ -421,9 +421,11 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, 
GError **err)
  gchar *ticket = NULL;
  gchar *host_subject = NULL;
  gchar *guid = NULL;
+gchar *uri = NULL;
  
  g_return_val_if_fail(VIRT_VIEWER_IS_APP(app), FALSE);
  
+g_object_get(app, "guri", , NULL);

  if (!parse_ovirt_uri(uri, _uri, _name, )) {
  g_set_error_literal(, VIRT_VIEWER_ERROR, 
VIRT_VIEWER_ERROR_FAILED,
  _("failed to parse ovirt uri"));
@@ -561,6 +563,7 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, 
GError **err)
  success = TRUE;
  
  error:

+g_free(uri);
  g_free(username);
  g_free(rest_uri);
  g_free(vm_name);
@@ -645,17 +648,16 @@ remote_viewer_recent_add(gchar *uri, const gchar 
*mime_type)
  
  static void

  remote_viewer_session_connected(VirtViewerSession 

Re: [virt-tools-list] [remote-viewer v1] remote-viewer: fix free on dangling pointer

2019-09-27 Thread Eduardo Lima (Etrunko)

On 9/27/19 10:35 AM, Victor Toso wrote:

From: Victor Toso 

On remote_viewer_session_connected() we are passing a dup of URI of
connection and freeing it afterwards. Problem is, we don't disconnect
from listening "session-connected" and on an eventual second emission
of this signal, remote-viewer crashes as seen in the backtrace below.

This can happen over switch-host migration message from
SpiceMainChannel.

To fix the issue, use VirtViewerApp URI information instead of passing
a dup char*. The other changes in this patch were warnings of unused
variables.

Found it while improving migrate.py from spice/tests (server):
  | Invalid free() / delete / delete[] / realloc()
  |at 0x4839A0C: free (vg_replace_malloc.c:540)
  |by 0x56EBD8C: g_free (in /usr/lib64/libglib-2.0.so.0.6000.6)
  |by 0x11DED0: remote_viewer_session_connected (remote-viewer.c:658)
  |by 0x564D741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566AF68: g_signal_emit_by_name (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x135E5D: virt_viewer_session_spice_main_channel_event 
(virt-viewer-session-spice.c:699)
  |by 0x564D741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x53149E3: emit_main_context (gio-coroutine.c:198)
  |  Address 0x18f1ecc0 is 0 bytes inside a block of size 23 free'd
  |at 0x4839A0C: free (vg_replace_malloc.c:540)
  |by 0x56EBD8C: g_free (in /usr/lib64/libglib-2.0.so.0.6000.6)
  |by 0x11DED0: remote_viewer_session_connected (remote-viewer.c:658)
  |by 0x564D741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566AF68: g_signal_emit_by_name (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x135E5D: virt_viewer_session_spice_main_channel_event 
(virt-viewer-session-spice.c:699)
  |by 0x564D741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x56614F3: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x53149E3: emit_main_context (gio-coroutine.c:198)
  |  Block was alloc'd at
  |at 0x483880B: malloc (vg_replace_malloc.c:309)
  |by 0x56EBC98: g_malloc (in /usr/lib64/libglib-2.0.so.0.6000.6)
  |by 0x5705C43: g_strdup (in /usr/lib64/libglib-2.0.so.0.6000.6)
  |by 0x11EB80: remote_viewer_initial_connect (remote-viewer.c:696)
  |by 0x11EB80: remote_viewer_start (remote-viewer.c:790)
  |by 0x1250D3: virt_viewer_app_start (virt-viewer-app.c:1727)
  |by 0x127108: virt_viewer_app_on_application_startup 
(virt-viewer-app.c:1870)
  |by 0x564D741: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x5661638: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A34D: g_signal_emit_valist (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x566A972: g_signal_emit (in /usr/lib64/libgobject-2.0.so.0.6000.6)
  |by 0x553ECA1: g_application_register (in 
/usr/lib64/libgio-2.0.so.0.6000.6)
  |by 0x553F41D: g_application_run (in /usr/lib64/libgio-2.0.so.0.6000.6)

Signed-off-by: Victor Toso 
---
  src/remote-viewer.c | 18 ++
  1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 8938ef9..2818221 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -396,7 +396,7 @@ virt_viewer_app_set_ovirt_foreign_menu(VirtViewerApp *app,
  }
  
  static gboolean

-create_ovirt_session(VirtViewerApp *app, const char *uri, GError **err)
+create_ovirt_session(VirtViewerApp *app, GError **err)
  {
  OvirtProxy *proxy = NULL;
  OvirtApi *api = NULL;
@@ -421,9 +421,11 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, 
GError **err)
  gchar *ticket = NULL;
  gchar *host_subject = NULL;
  gchar *guid = NULL;
+gchar *guri = NULL;
  
  g_return_val_if_fail(VIRT_VIEWER_IS_APP(app), FALSE);
  
+g_object_get(app, "guri", , NULL);

  if (!parse_ovirt_uri(uri, _uri, _name, )) {


Patch does not build. Are you sure your configure passes the ovirt checks?


remote-viewer.c: In function 'create_ovirt_session':
remote-viewer.c:430:26: error: 'uri' undeclared (first use in this 
function); did you mean 'guri'?

  430 | if (!parse_ovirt_uri(uri, _uri, _name, )) {
  |  ^~~
  |  guri
remote-viewer.c:430:26: note: each undeclared identifier is reported 
only once for each function it appears in





  g_set_error_literal(, 

Re: [virt-tools-list] [PATCH virt-viewer] ovirt-foreign-menu: Plug memory leak

2019-08-29 Thread Eduardo Lima (Etrunko)
On 8/29/19 12:50 PM, Victor Toso wrote:
> On Wed, Aug 28, 2019 at 06:18:02PM -0300, Eduardo Lima (Etrunko) wrote:
>> Error caught by valgrind, the OvirtCollection object created in function
>> ovirt_foreign_menu_fetch_vm_async() was never freed.
>>
>> 433 (40 direct, 393 indirect) bytes in 1 blocks are definitely lost in loss 
>> record 16,708 of 17,677
>>at 0x5868FDF: g_type_create_instance (in 
>> /usr/lib64/libgobject-2.0.so.0.6000.6)
>>by 0x584B42C: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
>>by 0x584D347: g_object_new_valist (in 
>> /usr/lib64/libgobject-2.0.so.0.6000.6)
>>by 0x584D69C: g_object_new (in /usr/lib64/libgobject-2.0.so.0.6000.6)
>>by 0x558E823: ovirt_collection_new (ovirt-collection.c:304)
>>by 0x558E98C: ovirt_sub_collection_new_from_resource_search 
>> (ovirt-collection.c:375)
> 
> I guess > ovirt_api_search_vms()
> 
> Does this happen too on code not compiled with
> HAVE_OVIRT_API_SEARCH_VMS, otherwise you might need to ref after
> ovirt_api_get_vms()

The ovirt_api_get_vms() and ovirt_api_search_vms() functions are
compatible, returning an empty OvirtCollection object, which is only
populated by the ovirt_collection_fetch_async() call.

So, indeed the same leak happens with both calls, because the
OvirtCollection that is created in one function should be freed on the
callback, as there is no where else holding the reference to it.

Regards, Eduardo.

> 
>>by 0x42D510: ovirt_foreign_menu_fetch_vm_async (ovirt-foreign-menu.c:994)
>>by 0x42D510: ovirt_foreign_menu_next_async_step (ovirt-foreign-menu.c:316)
>>by 0x42D70D: api_fetched_cb (ovirt-foreign-menu.c:1025)
>>by 0x570BC19: ??? (in /usr/lib64/libgio-2.0.so.0.6000.6)
>>by 0x570C7EC: ??? (in /usr/lib64/libgio-2.0.so.0.6000.6)
>>    by 0x559005D: call_async_cb (ovirt-proxy.c:279)
>>by 0x55B5A07: ??? (in /usr/lib64/librest-0.7.so.0.0.0)
>>
>> Signed-off-by: Eduardo Lima (Etrunko) 
>> ---
>>  src/ovirt-foreign-menu.c | 5 -
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
>> index 190bb3b..98ab7b9 100644
>> --- a/src/ovirt-foreign-menu.c
>> +++ b/src/ovirt-foreign-menu.c
>> @@ -888,7 +888,7 @@ static void vms_fetched_cb(GObject *source_object,
>>  g_debug("failed to fetch VM list: %s", error->message);
>>  g_task_return_error(task, error);
>>  g_object_unref(task);
>> -return;
>> +goto end;
>>  }
>>  
>>  g_hash_table_iter_init(, 
>> ovirt_collection_get_resources(collection));
>> @@ -911,6 +911,9 @@ static void vms_fetched_cb(GObject *source_object,
>>  "Could not find a VM with guid \"%s\"", 
>> menu->priv->vm_guid);
>>  g_object_unref(task);
>>  }
>> +
>> +end:
>> +g_object_unref(collection);
>>  }
>>  
>>  
>> -- 
>> 2.21.0
>>
>> ___
>> virt-tools-list mailing list
>> virt-tools-list@redhat.com
>> https://www.redhat.com/mailman/listinfo/virt-tools-list


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - Red Hat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer] ovirt-foreign-menu: Plug memory leak

2019-08-28 Thread Eduardo Lima (Etrunko)
Error caught by valgrind, the OvirtCollection object created in function
ovirt_foreign_menu_fetch_vm_async() was never freed.

433 (40 direct, 393 indirect) bytes in 1 blocks are definitely lost in loss 
record 16,708 of 17,677
   at 0x5868FDF: g_type_create_instance (in 
/usr/lib64/libgobject-2.0.so.0.6000.6)
   by 0x584B42C: ??? (in /usr/lib64/libgobject-2.0.so.0.6000.6)
   by 0x584D347: g_object_new_valist (in /usr/lib64/libgobject-2.0.so.0.6000.6)
   by 0x584D69C: g_object_new (in /usr/lib64/libgobject-2.0.so.0.6000.6)
   by 0x558E823: ovirt_collection_new (ovirt-collection.c:304)
   by 0x558E98C: ovirt_sub_collection_new_from_resource_search 
(ovirt-collection.c:375)
   by 0x42D510: ovirt_foreign_menu_fetch_vm_async (ovirt-foreign-menu.c:994)
   by 0x42D510: ovirt_foreign_menu_next_async_step (ovirt-foreign-menu.c:316)
   by 0x42D70D: api_fetched_cb (ovirt-foreign-menu.c:1025)
   by 0x570BC19: ??? (in /usr/lib64/libgio-2.0.so.0.6000.6)
   by 0x570C7EC: ??? (in /usr/lib64/libgio-2.0.so.0.6000.6)
   by 0x559005D: call_async_cb (ovirt-proxy.c:279)
   by 0x55B5A07: ??? (in /usr/lib64/librest-0.7.so.0.0.0)

Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/ovirt-foreign-menu.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 190bb3b..98ab7b9 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -888,7 +888,7 @@ static void vms_fetched_cb(GObject *source_object,
 g_debug("failed to fetch VM list: %s", error->message);
 g_task_return_error(task, error);
 g_object_unref(task);
-return;
+goto end;
 }
 
 g_hash_table_iter_init(, ovirt_collection_get_resources(collection));
@@ -911,6 +911,9 @@ static void vms_fetched_cb(GObject *source_object,
 "Could not find a VM with guid \"%s\"", 
menu->priv->vm_guid);
 g_object_unref(task);
 }
+
+end:
+g_object_unref(collection);
 }
 
 
-- 
2.21.0

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer] ovirt-foreign-menu: Factor out code to set file collection

2019-08-26 Thread Eduardo Lima (Etrunko)
On 8/26/19 9:47 AM, Victor Toso wrote:
> Hi,
> 
> On Mon, Aug 26, 2019 at 09:38:03AM -0300, Eduardo Lima (Etrunko) wrote:
>> On 8/26/19 4:15 AM, Victor Toso wrote:
>>> Hi,
>>>
>>> On Fri, Aug 23, 2019 at 11:38:05AM -0300, Eduardo Lima (Etrunko) wrote:
>>>> Signed-off-by: Eduardo Lima (Etrunko) 
>>>> ---
>>>>  src/ovirt-foreign-menu.c | 25 +
>>>>  1 file changed, 17 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
>>>> index c2f43e6..190bb3b 100644
>>>> --- a/src/ovirt-foreign-menu.c
>>>> +++ b/src/ovirt-foreign-menu.c
>>>> @@ -674,6 +674,18 @@ static gboolean 
>>>> storage_domain_validate(OvirtForeignMenu *menu G_GNUC_UNUSED,
>>>>  return ret;
>>>>  }
>>>>  
>>>> +static gboolean ovirt_foreign_menu_set_file_collection(OvirtForeignMenu 
>>>> *menu, OvirtCollection *file_collection)
>>>> +{
>>>> +g_return_val_if_fail(file_collection != NULL, FALSE);
>>>
>>> I think this is the only additional behavior, if
>>> ovirt_storage_domain_get_files() returns NULL, we will issue a
>>> critical warning.
>>>
>>> If that's not intended, just return normally.
>>
>> This was intended yes, do you think it needs to be silent?
> 
> Up to you. I don't have the proper setup to check how verbose
> this could get or not. I'm asking just in case you might have
> added it out of habit of checking arguments, etc.

Thanks, it has been pushed without modifications.

> 
>>> IMHO, no need to send a v2,
>>> Acked-by: Victor Toso 
>>>
>>>> +
>>>> +if (menu->priv->files) {
>>>> +g_object_unref(G_OBJECT(menu->priv->files));
>>>> +}
>>>> +menu->priv->files = g_object_ref(G_OBJECT(file_collection));
>>>> +g_debug("Set VM files to %p", menu->priv->files);
>>>> +return TRUE;
>>>> +}
>>>> +
>>>>  static void storage_domains_fetched_cb(GObject *source_object,
>>>> GAsyncResult *result,
>>>> gpointer user_data)
>>>> @@ -705,14 +717,11 @@ static void storage_domains_fetched_cb(GObject 
>>>> *source_object,
>>>>  domain_valid = TRUE;
>>>>  
>>>>  file_collection = ovirt_storage_domain_get_files(domain);
>>>> -if (file_collection != NULL) {
>>>> -if (menu->priv->files) {
>>>> -g_object_unref(G_OBJECT(menu->priv->files));
>>>> -}
>>>> -menu->priv->files = g_object_ref(G_OBJECT(file_collection));
>>>> -g_debug("Set VM files to %p", menu->priv->files);
>>>> -break;
>>>> -}
>>>> +if (!ovirt_foreign_menu_set_file_collection(menu, 
>>>> file_collection))
>>>> +continue;
>>>> +
>>>> +break; /* There can only be one valid storage domain at a time,
>>>> +  no need to iterate more on the list */
>>>>  }
>>>>  
>>>>  if (menu->priv->files != NULL) {
>>>> -- 
>>>> 2.21.0
>>>>
>>>> ___
>>>> virt-tools-list mailing list
>>>> virt-tools-list@redhat.com
>>>> https://www.redhat.com/mailman/listinfo/virt-tools-list
>>
>>
>> -- 
>> Eduardo de Barros Lima (Etrunko)
>> Software Engineer - Red Hat
>> etru...@redhat.com


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - Red Hat
etru...@redhat.com



signature.asc
Description: OpenPGP digital signature
___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

Re: [virt-tools-list] [PATCH virt-viewer] ovirt-foreign-menu: Factor out code to set file collection

2019-08-26 Thread Eduardo Lima (Etrunko)
On 8/26/19 4:15 AM, Victor Toso wrote:
> Hi,
> 
> On Fri, Aug 23, 2019 at 11:38:05AM -0300, Eduardo Lima (Etrunko) wrote:
>> Signed-off-by: Eduardo Lima (Etrunko) 
>> ---
>>  src/ovirt-foreign-menu.c | 25 +
>>  1 file changed, 17 insertions(+), 8 deletions(-)
>>
>> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
>> index c2f43e6..190bb3b 100644
>> --- a/src/ovirt-foreign-menu.c
>> +++ b/src/ovirt-foreign-menu.c
>> @@ -674,6 +674,18 @@ static gboolean 
>> storage_domain_validate(OvirtForeignMenu *menu G_GNUC_UNUSED,
>>  return ret;
>>  }
>>  
>> +static gboolean ovirt_foreign_menu_set_file_collection(OvirtForeignMenu 
>> *menu, OvirtCollection *file_collection)
>> +{
>> +g_return_val_if_fail(file_collection != NULL, FALSE);
> 
> I think this is the only additional behavior, if
> ovirt_storage_domain_get_files() returns NULL, we will issue a
> critical warning.
> 
> If that's not intended, just return normally.

This was intended yes, do you think it needs to be silent?

> 
> IMHO, no need to send a v2,
> Acked-by: Victor Toso 
> 
>> +
>> +if (menu->priv->files) {
>> +g_object_unref(G_OBJECT(menu->priv->files));
>> +}
>> +menu->priv->files = g_object_ref(G_OBJECT(file_collection));
>> +g_debug("Set VM files to %p", menu->priv->files);
>> +return TRUE;
>> +}
>> +
>>  static void storage_domains_fetched_cb(GObject *source_object,
>> GAsyncResult *result,
>> gpointer user_data)
>> @@ -705,14 +717,11 @@ static void storage_domains_fetched_cb(GObject 
>> *source_object,
>>  domain_valid = TRUE;
>>  
>>  file_collection = ovirt_storage_domain_get_files(domain);
>> -if (file_collection != NULL) {
>> -if (menu->priv->files) {
>> -g_object_unref(G_OBJECT(menu->priv->files));
>> -}
>> -menu->priv->files = g_object_ref(G_OBJECT(file_collection));
>> -g_debug("Set VM files to %p", menu->priv->files);
>> -break;
>> -}
>> +if (!ovirt_foreign_menu_set_file_collection(menu, file_collection))
>> +continue;
>> +
>> +break; /* There can only be one valid storage domain at a time,
>> +  no need to iterate more on the list */
>>  }
>>  
>>  if (menu->priv->files != NULL) {
>> -- 
>> 2.21.0
>>
>> ___
>> virt-tools-list mailing list
>> virt-tools-list@redhat.com
>> https://www.redhat.com/mailman/listinfo/virt-tools-list


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - Red Hat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer] ovirt-foreign-menu: Factor out code to set file collection

2019-08-23 Thread Eduardo Lima (Etrunko)
Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/ovirt-foreign-menu.c | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index c2f43e6..190bb3b 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -674,6 +674,18 @@ static gboolean storage_domain_validate(OvirtForeignMenu 
*menu G_GNUC_UNUSED,
 return ret;
 }
 
+static gboolean ovirt_foreign_menu_set_file_collection(OvirtForeignMenu *menu, 
OvirtCollection *file_collection)
+{
+g_return_val_if_fail(file_collection != NULL, FALSE);
+
+if (menu->priv->files) {
+g_object_unref(G_OBJECT(menu->priv->files));
+}
+menu->priv->files = g_object_ref(G_OBJECT(file_collection));
+g_debug("Set VM files to %p", menu->priv->files);
+return TRUE;
+}
+
 static void storage_domains_fetched_cb(GObject *source_object,
GAsyncResult *result,
gpointer user_data)
@@ -705,14 +717,11 @@ static void storage_domains_fetched_cb(GObject 
*source_object,
 domain_valid = TRUE;
 
 file_collection = ovirt_storage_domain_get_files(domain);
-if (file_collection != NULL) {
-if (menu->priv->files) {
-g_object_unref(G_OBJECT(menu->priv->files));
-}
-menu->priv->files = g_object_ref(G_OBJECT(file_collection));
-g_debug("Set VM files to %p", menu->priv->files);
-break;
-}
+if (!ovirt_foreign_menu_set_file_collection(menu, file_collection))
+continue;
+
+break; /* There can only be one valid storage domain at a time,
+  no need to iterate more on the list */
 }
 
 if (menu->priv->files != NULL) {
-- 
2.21.0

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer v2] ovirt-foreign-menu: Only set domain_valid once

2019-08-21 Thread Eduardo Lima (Etrunko)
On 8/19/19 6:51 AM, Victor Toso wrote:
> Hi,
> 
> On Fri, Aug 16, 2019 at 03:25:54PM -0300, Eduardo Lima (Etrunko) wrote:
>> In the case of having a valid storage domain without any ISO files, this
>> variable can be reset to FALSE again in the next iteration of the loop,
>> resulting in a misleading error message presented to the user.
> 
> Sure,
> 
>>
>> Signed-off-by: Eduardo Lima (Etrunko) 
>> ---
>>  src/ovirt-foreign-menu.c | 7 +--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
>> index 4ec0858..c2f43e6 100644
>> --- a/src/ovirt-foreign-menu.c
>> +++ b/src/ovirt-foreign-menu.c
>> @@ -669,6 +669,7 @@ static gboolean storage_domain_validate(OvirtForeignMenu 
>> *menu G_GNUC_UNUSED,
>>  }
>>  #endif
>>  
>> +g_debug ("Storage domain '%s' is %s", name, ret ? "valid" : "not 
>> valid");
>>  g_free(name);
>>  return ret;
>>  }
>> @@ -697,10 +698,12 @@ static void storage_domains_fetched_cb(GObject 
>> *source_object,
>>  while (g_hash_table_iter_next(, NULL, (gpointer *))) {
>>  OvirtCollection *file_collection;
>>  
>> -domain_valid = storage_domain_validate(menu, domain);
>> -if (!domain_valid)
>> +if (!storage_domain_validate(menu, domain))
> 
> just note: reverts yours 1c9a9c12050

Yes, at first my tests were okay, but when I tested on another instance
of oVirt, the results were different. So I had to get back to the first
version of the patch.

> 
>>  continue;
>>  
>> +if (!domain_valid)
>> +domain_valid = TRUE;
> 
> I'd remove the if but up to you
> Acked-by: Victor Toso 
> 

Thanks, Pushed.

>> +
>>  file_collection = ovirt_storage_domain_get_files(domain);
>>  if (file_collection != NULL) {
>>  if (menu->priv->files) {
>> -- 
>> 2.21.0
>>
>> ___
>> virt-tools-list mailing list
>> virt-tools-list@redhat.com
>> https://www.redhat.com/mailman/listinfo/virt-tools-list


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - Red Hat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer v2] ovirt-foreign-menu: Only set domain_valid once

2019-08-16 Thread Eduardo Lima (Etrunko)
In the case of having a valid storage domain without any ISO files, this
variable can be reset to FALSE again in the next iteration of the loop,
resulting in a misleading error message presented to the user.

Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/ovirt-foreign-menu.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 4ec0858..c2f43e6 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -669,6 +669,7 @@ static gboolean storage_domain_validate(OvirtForeignMenu 
*menu G_GNUC_UNUSED,
 }
 #endif
 
+g_debug ("Storage domain '%s' is %s", name, ret ? "valid" : "not valid");
 g_free(name);
 return ret;
 }
@@ -697,10 +698,12 @@ static void storage_domains_fetched_cb(GObject 
*source_object,
 while (g_hash_table_iter_next(, NULL, (gpointer *))) {
 OvirtCollection *file_collection;
 
-domain_valid = storage_domain_validate(menu, domain);
-if (!domain_valid)
+if (!storage_domain_validate(menu, domain))
 continue;
 
+if (!domain_valid)
+domain_valid = TRUE;
+
 file_collection = ovirt_storage_domain_get_files(domain);
 if (file_collection != NULL) {
 if (menu->priv->files) {
-- 
2.21.0

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer 1/2] ovirt-foreign-menu: Debug message in case of valid storage domain

2019-08-16 Thread Eduardo Lima (Etrunko)
This patch series has been sent from a wrong branch, please disregard.

There should be only one patch which is a squashed version of both

On 8/16/19 2:44 PM, Eduardo Lima (Etrunko) wrote:
> Signed-off-by: Eduardo Lima (Etrunko) 
> ---
>  src/ovirt-foreign-menu.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
> index 4ec0858..48b7b34 100644
> --- a/src/ovirt-foreign-menu.c
> +++ b/src/ovirt-foreign-menu.c
> @@ -669,6 +669,7 @@ static gboolean storage_domain_validate(OvirtForeignMenu 
> *menu G_GNUC_UNUSED,
>  }
>  #endif
>  
> +g_debug("Storage domain '%s' is valid", name);
>  g_free(name);
>  return ret;
>  }
> 


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - Red Hat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer 1/2] ovirt-foreign-menu: Debug message in case of valid storage domain

2019-08-16 Thread Eduardo Lima (Etrunko)
Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/ovirt-foreign-menu.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 4ec0858..48b7b34 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -669,6 +669,7 @@ static gboolean storage_domain_validate(OvirtForeignMenu 
*menu G_GNUC_UNUSED,
 }
 #endif
 
+g_debug("Storage domain '%s' is valid", name);
 g_free(name);
 return ret;
 }
-- 
2.21.0

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer 2/2] ovirt-foreign-menu: Only set domain_valid once

2019-08-16 Thread Eduardo Lima (Etrunko)
In the case of having a valid storage domain without any ISO files, this
variable can be reset to FALSE again in the next iteration of the loop,
resulting in a misleading error message presented to the user.

Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/ovirt-foreign-menu.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 48b7b34..914cf0b 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -698,10 +698,12 @@ static void storage_domains_fetched_cb(GObject 
*source_object,
 while (g_hash_table_iter_next(, NULL, (gpointer *))) {
 OvirtCollection *file_collection;
 
-domain_valid = storage_domain_validate(menu, domain);
-if (!domain_valid)
+if (!storage_domain_validate(menu, domain))
 continue;
 
+if (!domain_valid)
+domain_valid = TRUE;
+
 file_collection = ovirt_storage_domain_get_files(domain);
 if (file_collection != NULL) {
 if (menu->priv->files) {
-- 
2.21.0

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [virt-viewer PATCH] ovirt-foreign-menu: Fix warnings on Rawhide

2019-08-15 Thread Eduardo Lima (Etrunko)
On 8/15/19 12:07 PM, Fabiano Fidêncio wrote:
> gmaovirt-foreign-menu.c: In function 'storage_domains_fetched_cb':
> ovirt-foreign-menu.c:721:9: error: format not a string literal and no format 
> arguments [-Werror=format-security]
>   721 | g_debug(msg);
>   | ^~~
> ovirt-foreign-menu.c:722:9: error: format not a string literal and no format 
> arguments [-Werror=format-security]
>   722 | g_task_return_new_error(task, OVIRT_ERROR, 
> OVIRT_ERROR_FAILED, msg);
>   | ^~~
> cc1: some warnings being treated as errors
> gmake[3]: *** [Makefile:963: libvirt_viewer_la-ovirt-foreign-menu.lo] Error 1
> gmake[2]: *** [Makefile:647: all] Error 2
> gmake[1]: *** [Makefile:482: all-recursive] Error 1
> make: *** [Makefile:410: all] Error 2
> error: Bad exit status from /var/tmp/rpm-tmp.f14Lmj (%build)
> 
> Errors have been caught by 
> https://ci.centos.org/job/virt-viewer-rpm/systems=libvirt-fedora-rawhide/589/
> 
> Signed-off-by: Fabiano Fidêncio 
> ---
>  src/ovirt-foreign-menu.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
> index 75f9ac4..4ec0858 100644
> --- a/src/ovirt-foreign-menu.c
> +++ b/src/ovirt-foreign-menu.c
> @@ -718,8 +718,8 @@ static void storage_domains_fetched_cb(GObject 
> *source_object,
>  const char *msg = domain_valid ? "Could not find ISO file collection"
> : "Could not find valid ISO storage 
> domain";
>  
> -g_debug(msg);
> -g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED, msg);
> +g_debug("%s", msg);
> +    g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED, "%s", 
> msg);
>  g_object_unref(task);
>  }
>  }
> 
Acked-by: Eduardo Lima (Etrunko) 

-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - Red Hat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

Re: [virt-tools-list] [PATCH virt-viewer v2] ovirt-foreign-menu: Fix endpoint for storage domains query

2019-08-12 Thread Eduardo Lima (Etrunko)
On 8/12/19 9:48 AM, Victor Toso wrote:
> On Mon, Aug 12, 2019 at 09:36:39AM -0300, Eduardo Lima (Etrunko) wrote:
>> Instead of fetching toplevel REST API query, we use the one relative
>> from the data center, which returns more detailed information,
>> especially the status of the storage domain.
>>
>> This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1427467
>>
>> Signed-off-by: Eduardo Lima (Etrunko) 
>> ---
>>
>> in V2:
>>  - Improve usage of boolean domain_valid
> 
> Sure,
> Acked-by: Victor Toso 

Thanks, pushed.

> 
>>
>> ---
>>  src/ovirt-foreign-menu.c | 26 --
>>  1 file changed, 20 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
>> index 59c3d48..75f9ac4 100644
>> --- a/src/ovirt-foreign-menu.c
>> +++ b/src/ovirt-foreign-menu.c
>> @@ -683,6 +683,7 @@ static void storage_domains_fetched_cb(GObject 
>> *source_object,
>>  OvirtCollection *collection = OVIRT_COLLECTION(source_object);
>>  GHashTableIter iter;
>>  OvirtStorageDomain *domain;
>> +gboolean domain_valid = FALSE;
>>  
>>  ovirt_collection_fetch_finish(collection, result, );
>>  if (error != NULL) {
>> @@ -696,7 +697,8 @@ static void storage_domains_fetched_cb(GObject 
>> *source_object,
>>  while (g_hash_table_iter_next(, NULL, (gpointer *))) {
>>  OvirtCollection *file_collection;
>>  
>> -if (!storage_domain_validate(menu, domain))
>> +domain_valid = storage_domain_validate(menu, domain);
>> +if (!domain_valid)
>>  continue;
>>  
>>  file_collection = ovirt_storage_domain_get_files(domain);
>> @@ -713,9 +715,11 @@ static void storage_domains_fetched_cb(GObject 
>> *source_object,
>>  if (menu->priv->files != NULL) {
>>  ovirt_foreign_menu_next_async_step(menu, task, 
>> STATE_STORAGE_DOMAIN);
>>  } else {
>> -g_debug("Could not find iso file collection");
>> -g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED,
>> -"Could not find ISO file collection");
>> +const char *msg = domain_valid ? "Could not find ISO file 
>> collection"
>> +   : "Could not find valid ISO storage 
>> domain";
>> +
>> +g_debug(msg);
>> +g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED, msg);
>>  g_object_unref(task);
>>  }
>>  }
>> @@ -724,9 +728,19 @@ static void storage_domains_fetched_cb(GObject 
>> *source_object,
>>  static void ovirt_foreign_menu_fetch_storage_domain_async(OvirtForeignMenu 
>> *menu,
>>GTask *task)
>>  {
>> -OvirtCollection *collection = 
>> ovirt_api_get_storage_domains(menu->priv->api);
>> +OvirtCollection *collection = NULL;
>> +
>> +#ifdef HAVE_OVIRT_DATA_CENTER
>> +g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
>> +g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
>> +g_return_if_fail(OVIRT_IS_DATA_CENTER(menu->priv->data_center));
>> +
>> +collection = 
>> ovirt_data_center_get_storage_domains(menu->priv->data_center);
>> +#else
>> +collection = ovirt_api_get_storage_domains(menu->priv->api);
>> +#endif
>>  
>> -g_debug("Start fetching oVirt REST collection");
>> +g_debug("Start fetching iso file collection");
>>  ovirt_collection_fetch_async(collection, menu->priv->proxy,
>>   g_task_get_cancellable(task),
>>   storage_domains_fetched_cb, task);
>> -- 
>> 2.21.0
>>
>> ___
>> virt-tools-list mailing list
>> virt-tools-list@redhat.com
>> https://www.redhat.com/mailman/listinfo/virt-tools-list


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - Red Hat
etru...@redhat.com



signature.asc
Description: OpenPGP digital signature
___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

[virt-tools-list] [PATCH virt-viewer v2] ovirt-foreign-menu: Fix endpoint for storage domains query

2019-08-12 Thread Eduardo Lima (Etrunko)
Instead of fetching toplevel REST API query, we use the one relative
from the data center, which returns more detailed information,
especially the status of the storage domain.

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1427467

Signed-off-by: Eduardo Lima (Etrunko) 
---

in V2:
 - Improve usage of boolean domain_valid

---
 src/ovirt-foreign-menu.c | 26 --
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 59c3d48..75f9ac4 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -683,6 +683,7 @@ static void storage_domains_fetched_cb(GObject 
*source_object,
 OvirtCollection *collection = OVIRT_COLLECTION(source_object);
 GHashTableIter iter;
 OvirtStorageDomain *domain;
+gboolean domain_valid = FALSE;
 
 ovirt_collection_fetch_finish(collection, result, );
 if (error != NULL) {
@@ -696,7 +697,8 @@ static void storage_domains_fetched_cb(GObject 
*source_object,
 while (g_hash_table_iter_next(, NULL, (gpointer *))) {
 OvirtCollection *file_collection;
 
-if (!storage_domain_validate(menu, domain))
+domain_valid = storage_domain_validate(menu, domain);
+if (!domain_valid)
 continue;
 
 file_collection = ovirt_storage_domain_get_files(domain);
@@ -713,9 +715,11 @@ static void storage_domains_fetched_cb(GObject 
*source_object,
 if (menu->priv->files != NULL) {
 ovirt_foreign_menu_next_async_step(menu, task, STATE_STORAGE_DOMAIN);
 } else {
-g_debug("Could not find iso file collection");
-g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED,
-"Could not find ISO file collection");
+const char *msg = domain_valid ? "Could not find ISO file collection"
+   : "Could not find valid ISO storage 
domain";
+
+g_debug(msg);
+g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED, msg);
 g_object_unref(task);
 }
 }
@@ -724,9 +728,19 @@ static void storage_domains_fetched_cb(GObject 
*source_object,
 static void ovirt_foreign_menu_fetch_storage_domain_async(OvirtForeignMenu 
*menu,
   GTask *task)
 {
-OvirtCollection *collection = 
ovirt_api_get_storage_domains(menu->priv->api);
+OvirtCollection *collection = NULL;
+
+#ifdef HAVE_OVIRT_DATA_CENTER
+g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
+g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
+g_return_if_fail(OVIRT_IS_DATA_CENTER(menu->priv->data_center));
+
+collection = 
ovirt_data_center_get_storage_domains(menu->priv->data_center);
+#else
+collection = ovirt_api_get_storage_domains(menu->priv->api);
+#endif
 
-g_debug("Start fetching oVirt REST collection");
+g_debug("Start fetching iso file collection");
 ovirt_collection_fetch_async(collection, menu->priv->proxy,
  g_task_get_cancellable(task),
  storage_domains_fetched_cb, task);
-- 
2.21.0

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer] ovirt-foreign-menu: Fix endpoint for storage domains query

2019-08-09 Thread Eduardo Lima (Etrunko)
Instead of fetching toplevel REST API query, we use the one relative
from the data center, which returns more detailed information,
especially the status of the storage domain.

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1427467

Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/ovirt-foreign-menu.c | 24 +++-
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 59c3d48..6fc05e7 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -683,6 +683,7 @@ static void storage_domains_fetched_cb(GObject 
*source_object,
 OvirtCollection *collection = OVIRT_COLLECTION(source_object);
 GHashTableIter iter;
 OvirtStorageDomain *domain;
+gboolean domain_valid = FALSE;
 
 ovirt_collection_fetch_finish(collection, result, );
 if (error != NULL) {
@@ -699,6 +700,7 @@ static void storage_domains_fetched_cb(GObject 
*source_object,
 if (!storage_domain_validate(menu, domain))
 continue;
 
+domain_valid = TRUE;
 file_collection = ovirt_storage_domain_get_files(domain);
 if (file_collection != NULL) {
 if (menu->priv->files) {
@@ -713,9 +715,11 @@ static void storage_domains_fetched_cb(GObject 
*source_object,
 if (menu->priv->files != NULL) {
 ovirt_foreign_menu_next_async_step(menu, task, STATE_STORAGE_DOMAIN);
 } else {
-g_debug("Could not find iso file collection");
-g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED,
-"Could not find ISO file collection");
+const char *msg = domain_valid ? "Could not find ISO file collection"
+   : "Could not find valid ISO storage 
domain";
+
+g_debug(msg);
+g_task_return_new_error(task, OVIRT_ERROR, OVIRT_ERROR_FAILED, msg);
 g_object_unref(task);
 }
 }
@@ -724,9 +728,19 @@ static void storage_domains_fetched_cb(GObject 
*source_object,
 static void ovirt_foreign_menu_fetch_storage_domain_async(OvirtForeignMenu 
*menu,
   GTask *task)
 {
-OvirtCollection *collection = 
ovirt_api_get_storage_domains(menu->priv->api);
+OvirtCollection *collection = NULL;
+
+#ifdef HAVE_OVIRT_DATA_CENTER
+g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
+g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
+g_return_if_fail(OVIRT_IS_DATA_CENTER(menu->priv->data_center));
+
+collection = 
ovirt_data_center_get_storage_domains(menu->priv->data_center);
+#else
+collection = ovirt_api_get_storage_domains(menu->priv->api);
+#endif
 
-g_debug("Start fetching oVirt REST collection");
+g_debug("Start fetching iso file collection");
 ovirt_collection_fetch_async(collection, menu->priv->proxy,
  g_task_get_cancellable(task),
  storage_domains_fetched_cb, task);
-- 
2.21.0

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer v3] ovirt-foreign-menu: Bypass errors from Host/Cluster/Data Center

2019-06-07 Thread Eduardo Lima (Etrunko)
On 6/7/19 10:37 AM, Christophe Fergeau wrote:
> On Fri, Jun 07, 2019 at 10:04:19AM -0300, Eduardo Lima (Etrunko) wrote:
>> On 6/6/19 1:22 PM, Christophe Fergeau wrote:
>>> Hey,
>>>
>>> I'm not really comfortable with that patch, which ignores some errors,
>>> and adds some code not to crash when we do that, in the hope that the
>>> end result will make sense. I'm under the impression that if the oVirt
>>> instance does not have the permissions issues that you mention, but if
>>> instead we get a temporary networking issue at the wrong time (for
>>> example), then rather than doing the proper checks, we'll just ignore
>>> the error, and assume the image we got is accessible to our VM?
>>
>> There is no crash avoidance, what this patch does is to replicate the
>> previous behavior when the code only did queries for VM and storage
>> domains, which depending on the setup can lead to showing wrong ISO
>> images for that VM. But those setups are not very common, and most of
>> the cases it was fine.
>>
>>>
>>> Isn't this a problem in the oVirt REST API if you can access a
>>> datacenter, a VM, but have no way to know if they are related?
>>>
>>
>> That's it, we need to know the common thing between the VM and a storage
>> domain, and that is the datacenter. It would indeed be much better if
>> the information about it was available right away in the VM xml, but at
>> the moment we need to send a few other requests to get to it:
>>
>> VM -> Host -> Cluster -> Data Center.
> 
> Is there a bug against the oVirt REST API for this?
> 

Not that I am aware of.

>>
>> Anyway, IMO, it is better to fallback to the old method and show the
>> available ISO images, than to not show any at all and  break in the
>> middle with an error message about insufficient permissions.
> 
> My complaint is that *all* errors are being ignored, even the ones which
> might be meaningful, not just the permissions errors.

I understand, but currently we get a generic "400 Bad Request" error,
which is also used in other cases, while it should be something like a
"401 Unauthorized". Using g_error_matches() would not help here, I think.

< HTTP/1.1 400 Bad Request
< Soup-Debug-Timestamp: 1559921229
< Soup-Debug: SoupMessage 1 (0x5570ecf0e8e0)
< Date: Fri, 07 Jun 2019 15:27:09 GMT
< Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips
mod_auth_gssapi/1.5.1 mod_nss/1.0.14 NSS/3.28.4 mod_wsgi/3.4 Python/2.7.5
< Content-Type: application/xml;charset=UTF-8
< Content-Length: 188
< Correlation-Id: 4417d860-9453-4e5e-94dc-fb1f7c964db8
< Connection: close
<
< 
< 
< Operation Failed
< query execution failed due to insufficient
permissions.
< 





> 
> Christophe
> 


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer v3] ovirt-foreign-menu: Bypass errors from Host/Cluster/Data Center

2019-06-07 Thread Eduardo Lima (Etrunko)
On 6/6/19 1:22 PM, Christophe Fergeau wrote:
> Hey,
> 
> I'm not really comfortable with that patch, which ignores some errors,
> and adds some code not to crash when we do that, in the hope that the
> end result will make sense. I'm under the impression that if the oVirt
> instance does not have the permissions issues that you mention, but if
> instead we get a temporary networking issue at the wrong time (for
> example), then rather than doing the proper checks, we'll just ignore
> the error, and assume the image we got is accessible to our VM?

There is no crash avoidance, what this patch does is to replicate the
previous behavior when the code only did queries for VM and storage
domains, which depending on the setup can lead to showing wrong ISO
images for that VM. But those setups are not very common, and most of
the cases it was fine.

> 
> Isn't this a problem in the oVirt REST API if you can access a
> datacenter, a VM, but have no way to know if they are related?
> 

That's it, we need to know the common thing between the VM and a storage
domain, and that is the datacenter. It would indeed be much better if
the information about it was available right away in the VM xml, but at
the moment we need to send a few other requests to get to it:

VM -> Host -> Cluster -> Data Center.

Anyway, IMO, it is better to fallback to the old method and show the
available ISO images, than to not show any at all and  break in the
middle with an error message about insufficient permissions.

Regards, Eduardo.

> A few small comments below,
> 

Fixed all leaks.

> On Tue, May 28, 2019 at 11:11:41AM -0300, Eduardo Lima (Etrunko) wrote:
>> ping
>>
>> On 4/10/19 5:20 PM, Eduardo Lima (Etrunko) wrote:
>>> When accessing ovirt as a regular user, it may happen that queries to
>>> Hosts, Clusters and Data Centers return errors due to insufficient
>>> permissions, while they will work fine if access is done by admin user.
>>> In this case, we skip the errors and fallback to the old method.
>>>
>>> Signed-off-by: Eduardo Lima (Etrunko) 
>>> ---
>>>  src/ovirt-foreign-menu.c | 51 ++--
>>>  1 file changed, 39 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
>>> index 59c3d48..83bdf5b 100644
>>> --- a/src/ovirt-foreign-menu.c
>>> +++ b/src/ovirt-foreign-menu.c
>>> @@ -627,12 +627,21 @@ G_GNUC_END_IGNORE_DEPRECATIONS
>>>  }
>>>  
>>>  static gboolean storage_domain_attached_to_data_center(OvirtStorageDomain 
>>> *domain,
>>> -  OvirtDataCenter 
>>> *data_center)
>>> +   OvirtDataCenter 
>>> *data_center)
>>>  {
>>>  GStrv data_center_ids;
>>>  char *data_center_guid;
>>>  gboolean match;
>>>  
>>> +/* For some reason we did not get data center information, so just 
>>> return
>>> + * TRUE as it will work like a fallback to old method, where we did not
>>> + * check relationship between data center and storage domain.
>>> + */
>>> +if (data_center == NULL) {
>>> +g_debug("Could not get data center info, considering storage 
>>> domain is attached to it");
>>> +return TRUE;
>>> +}
>>> +
>>>  g_object_get(domain, "data-center-ids", _center_ids, NULL);
>>>  g_object_get(data_center, "guid", _center_guid, NULL);
>>>  match = strv_contains((const gchar * const *) data_center_ids, 
>>> data_center_guid);
>>> @@ -746,9 +755,6 @@ static void data_center_fetched_cb(GObject 
>>> *source_object,
>>>  ovirt_resource_refresh_finish(resource, result, );
>>>  if (error != NULL) {
>>>  g_debug("failed to fetch Data Center: %s", error->message);
>>> -g_task_return_error(task, error);
>>> -g_object_unref(task);
>>> -return;
> 
> This leaks 'error'
> 
>>>  }
>>>  
>>>  ovirt_foreign_menu_next_async_step(menu, task, STATE_DATA_CENTER);
>>> @@ -763,6 +769,12 @@ static void 
>>> ovirt_foreign_menu_fetch_data_center_async(OvirtForeignMenu *menu,
>>>  g_return_if_fail(OVIRT_IS_CLUSTER(menu->priv->cluster));
>>>  
>>>  menu->priv->data_center = 
>>> ovirt_cluster_get_data_center(menu->priv->cluster);
>>> +
>>> +if (menu->priv->

[virt-tools-list] [PATCH virt-viewer] configure: Fix check for govirt functions

2019-05-31 Thread Eduardo Lima (Etrunko)
Use saved CFLAGS and LIBS to avoid errors in the check programs.

Signed-off-by: Eduardo Lima (Etrunko) 
---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7b61821..c787e1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -196,8 +196,8 @@ AS_IF([test "x$with_ovirt" = "xyes"],
   [AC_DEFINE([HAVE_OVIRT], 1, [Have libgovirt?])]
   [SAVED_CFLAGS="$CFLAGS"
SAVED_LIBS="$LIBS"
-   CFLAGS="$OVIRT_CFLAGS"
-   LIBS="$OVIRT_LIBS"
+   CFLAGS="$SAVED_CFLAGS $OVIRT_CFLAGS"
+   LIBS="$SAVED_LIBS $OVIRT_LIBS"
AC_CHECK_FUNCS([ovirt_api_search_vms ovirt_vm_get_host 
ovirt_host_get_cluster ovirt_cluster_get_data_center],
   [AC_DEFINE([HAVE_OVIRT_DATA_CENTER], 1, [Have support 
for data center])],
   []
-- 
2.21.0

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer v3] ovirt-foreign-menu: Bypass errors from Host/Cluster/Data Center

2019-05-28 Thread Eduardo Lima (Etrunko)
ping

On 4/10/19 5:20 PM, Eduardo Lima (Etrunko) wrote:
> When accessing ovirt as a regular user, it may happen that queries to
> Hosts, Clusters and Data Centers return errors due to insufficient
> permissions, while they will work fine if access is done by admin user.
> In this case, we skip the errors and fallback to the old method.
> 
> Signed-off-by: Eduardo Lima (Etrunko) 
> ---
>  src/ovirt-foreign-menu.c | 51 ++--
>  1 file changed, 39 insertions(+), 12 deletions(-)
> 
> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
> index 59c3d48..83bdf5b 100644
> --- a/src/ovirt-foreign-menu.c
> +++ b/src/ovirt-foreign-menu.c
> @@ -627,12 +627,21 @@ G_GNUC_END_IGNORE_DEPRECATIONS
>  }
>  
>  static gboolean storage_domain_attached_to_data_center(OvirtStorageDomain 
> *domain,
> -  OvirtDataCenter 
> *data_center)
> +   OvirtDataCenter 
> *data_center)
>  {
>  GStrv data_center_ids;
>  char *data_center_guid;
>  gboolean match;
>  
> +/* For some reason we did not get data center information, so just return
> + * TRUE as it will work like a fallback to old method, where we did not
> + * check relationship between data center and storage domain.
> + */
> +if (data_center == NULL) {
> +g_debug("Could not get data center info, considering storage domain 
> is attached to it");
> +return TRUE;
> +}
> +
>  g_object_get(domain, "data-center-ids", _center_ids, NULL);
>  g_object_get(data_center, "guid", _center_guid, NULL);
>  match = strv_contains((const gchar * const *) data_center_ids, 
> data_center_guid);
> @@ -746,9 +755,6 @@ static void data_center_fetched_cb(GObject *source_object,
>  ovirt_resource_refresh_finish(resource, result, );
>  if (error != NULL) {
>  g_debug("failed to fetch Data Center: %s", error->message);
> -g_task_return_error(task, error);
> -g_object_unref(task);
> -return;
>  }
>  
>  ovirt_foreign_menu_next_async_step(menu, task, STATE_DATA_CENTER);
> @@ -763,6 +769,12 @@ static void 
> ovirt_foreign_menu_fetch_data_center_async(OvirtForeignMenu *menu,
>  g_return_if_fail(OVIRT_IS_CLUSTER(menu->priv->cluster));
>  
>  menu->priv->data_center = 
> ovirt_cluster_get_data_center(menu->priv->cluster);
> +
> +if (menu->priv->data_center == NULL) {
> +ovirt_foreign_menu_next_async_step(menu, task, STATE_DATA_CENTER);
> +return;
> +}
> +
>  ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->priv->data_center),
>   menu->priv->proxy,
>   g_task_get_cancellable(task),
> @@ -783,9 +795,6 @@ static void cluster_fetched_cb(GObject *source_object,
>  ovirt_resource_refresh_finish(resource, result, );
>  if (error != NULL) {
>  g_debug("failed to fetch Cluster: %s", error->message);
> -g_task_return_error(task, error);
> -g_object_unref(task);
> -return;
>  }
>  
>  ovirt_foreign_menu_next_async_step(menu, task, STATE_CLUSTER);
> @@ -797,9 +806,21 @@ static void 
> ovirt_foreign_menu_fetch_cluster_async(OvirtForeignMenu *menu,
>  {
>  g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
>  g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
> -g_return_if_fail(OVIRT_IS_HOST(menu->priv->host));
>  
> -menu->priv->cluster = ovirt_host_get_cluster(menu->priv->host);
> +/* If there is no host information, we get cluster from the VM */
> +if (menu->priv->host == NULL) {
> +g_return_if_fail(OVIRT_IS_VM(menu->priv->vm));
> +menu->priv->cluster = ovirt_vm_get_cluster(menu->priv->vm);
> +} else {
> +g_return_if_fail(OVIRT_IS_HOST(menu->priv->host));
> +menu->priv->cluster = ovirt_host_get_cluster(menu->priv->host);
> +}
> +
> +if (menu->priv->cluster == NULL) {
> +ovirt_foreign_menu_next_async_step(menu, task, STATE_CLUSTER);
> +return;
> +}
> +
>  ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->priv->cluster),
>   menu->priv->proxy,
>   g_task_get_cancellable(task),
> @@ -820,9 +841,6 @@ static void host_fetched_cb(GObject *source_object,
>  ovirt_resource_refresh_finish(resource, result, );
>  if (error != NULL) {
>  g_debug("failed to fetch Ho

[virt-tools-list] [PATCH virt-viewer v3] ovirt-foreign-menu: Bypass errors from Host/Cluster/Data Center

2019-04-10 Thread Eduardo Lima (Etrunko)
When accessing ovirt as a regular user, it may happen that queries to
Hosts, Clusters and Data Centers return errors due to insufficient
permissions, while they will work fine if access is done by admin user.
In this case, we skip the errors and fallback to the old method.

Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/ovirt-foreign-menu.c | 51 ++--
 1 file changed, 39 insertions(+), 12 deletions(-)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 59c3d48..83bdf5b 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -627,12 +627,21 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 }
 
 static gboolean storage_domain_attached_to_data_center(OvirtStorageDomain 
*domain,
-  OvirtDataCenter 
*data_center)
+   OvirtDataCenter 
*data_center)
 {
 GStrv data_center_ids;
 char *data_center_guid;
 gboolean match;
 
+/* For some reason we did not get data center information, so just return
+ * TRUE as it will work like a fallback to old method, where we did not
+ * check relationship between data center and storage domain.
+ */
+if (data_center == NULL) {
+g_debug("Could not get data center info, considering storage domain is 
attached to it");
+return TRUE;
+}
+
 g_object_get(domain, "data-center-ids", _center_ids, NULL);
 g_object_get(data_center, "guid", _center_guid, NULL);
 match = strv_contains((const gchar * const *) data_center_ids, 
data_center_guid);
@@ -746,9 +755,6 @@ static void data_center_fetched_cb(GObject *source_object,
 ovirt_resource_refresh_finish(resource, result, );
 if (error != NULL) {
 g_debug("failed to fetch Data Center: %s", error->message);
-g_task_return_error(task, error);
-g_object_unref(task);
-return;
 }
 
 ovirt_foreign_menu_next_async_step(menu, task, STATE_DATA_CENTER);
@@ -763,6 +769,12 @@ static void 
ovirt_foreign_menu_fetch_data_center_async(OvirtForeignMenu *menu,
 g_return_if_fail(OVIRT_IS_CLUSTER(menu->priv->cluster));
 
 menu->priv->data_center = 
ovirt_cluster_get_data_center(menu->priv->cluster);
+
+if (menu->priv->data_center == NULL) {
+ovirt_foreign_menu_next_async_step(menu, task, STATE_DATA_CENTER);
+return;
+}
+
 ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->priv->data_center),
  menu->priv->proxy,
  g_task_get_cancellable(task),
@@ -783,9 +795,6 @@ static void cluster_fetched_cb(GObject *source_object,
 ovirt_resource_refresh_finish(resource, result, );
 if (error != NULL) {
 g_debug("failed to fetch Cluster: %s", error->message);
-g_task_return_error(task, error);
-g_object_unref(task);
-return;
 }
 
 ovirt_foreign_menu_next_async_step(menu, task, STATE_CLUSTER);
@@ -797,9 +806,21 @@ static void 
ovirt_foreign_menu_fetch_cluster_async(OvirtForeignMenu *menu,
 {
 g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
 g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
-g_return_if_fail(OVIRT_IS_HOST(menu->priv->host));
 
-menu->priv->cluster = ovirt_host_get_cluster(menu->priv->host);
+/* If there is no host information, we get cluster from the VM */
+if (menu->priv->host == NULL) {
+g_return_if_fail(OVIRT_IS_VM(menu->priv->vm));
+menu->priv->cluster = ovirt_vm_get_cluster(menu->priv->vm);
+} else {
+g_return_if_fail(OVIRT_IS_HOST(menu->priv->host));
+menu->priv->cluster = ovirt_host_get_cluster(menu->priv->host);
+}
+
+if (menu->priv->cluster == NULL) {
+ovirt_foreign_menu_next_async_step(menu, task, STATE_CLUSTER);
+return;
+}
+
 ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->priv->cluster),
  menu->priv->proxy,
  g_task_get_cancellable(task),
@@ -820,9 +841,6 @@ static void host_fetched_cb(GObject *source_object,
 ovirt_resource_refresh_finish(resource, result, );
 if (error != NULL) {
 g_debug("failed to fetch Host: %s", error->message);
-g_task_return_error(task, error);
-g_object_unref(task);
-return;
 }
 
 ovirt_foreign_menu_next_async_step(menu, task, STATE_HOST);
@@ -837,6 +855,15 @@ static void 
ovirt_foreign_menu_fetch_host_async(OvirtForeignMenu *menu,
 g_return_if_fail(OVIRT_IS_VM(menu->priv->vm));
 
 menu->priv->host = ovirt_vm_get_host(menu->priv->vm);
+
+/* In some cases the VM XML does not include host information, so we just
+ * skip to the next step
+ */
+if (menu->priv->host == NULL) {
+

Re: [virt-tools-list] [PATCH virt-viewer 3/3] ovirt-foreign-menu: Bypass errors from Host/Cluster/Data Center

2019-04-10 Thread Eduardo Lima (Etrunko)
Ouch, it looks like I missed this mail in my Inbox, somehow it slipped
through the filters and was not moved to the folder.

On 2/6/19 8:15 AM, Christophe Fergeau wrote:
> On Tue, Feb 05, 2019 at 03:38:35PM -0200, Eduardo Lima (Etrunko) wrote:
>> On 7/17/18 11:48 AM, Christophe Fergeau wrote:
>>> On Fri, Jul 06, 2018 at 09:59:23AM -0300, Eduardo Lima (Etrunko) wrote:
>>>> When accessing ovirt as a regular user, it may happen that queries to
>>>> Hosts, Clusters and Data Centers return errors due to insufficient
>>>> permissions, while they will work fine if access is done by admin user.
>>>> In this case, we skip the errors and fallback to the old method.
>>>>
>>>> Signed-off-by: Eduardo Lima (Etrunko) 
>>>> ---
>>>>  src/ovirt-foreign-menu.c | 43 +++
>>>>  1 file changed, 31 insertions(+), 12 deletions(-)
>>>>
>>>> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
>>>> index 70a0b50..8ed08c9 100644
>>>> --- a/src/ovirt-foreign-menu.c
>>>> +++ b/src/ovirt-foreign-menu.c
>>>> @@ -624,12 +624,20 @@ static void 
>>>> ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu,
>>>>  
>>>>  #ifdef HAVE_OVIRT_DATA_CENTER
>>>>  static gboolean storage_domain_attached_to_data_center(OvirtStorageDomain 
>>>> *domain,
>>>> -  OvirtDataCenter 
>>>> *data_center)
>>>> +   OvirtDataCenter 
>>>> *data_center)
>>>>  {
>>>>  GStrv data_center_ids;
>>>>  char *data_center_guid;
>>>>  gboolean match;
>>>>  
>>>> +/* For some reason we did not get data center information, so just 
>>>> return
>>>> + * TRUE as it will work like a fallback to old method, where we did 
>>>> not
>>>> + * check relationship with data center and storage domain.*/
>>>> +if (data_center == NULL) {
>>>> +g_debug("Could not get data center info, considering storage 
>>>> domain is attached to it");
>>>> +return TRUE;
>>>> +}
>>>> +
>>>>  g_object_get(domain, "data-center-ids", _center_ids, NULL);
>>>>  g_object_get(data_center, "guid", _center_guid, NULL);
>>>>  match = g_strv_contains((const gchar * const *) data_center_ids, 
>>>> data_center_guid);
>>>> @@ -743,9 +751,6 @@ static void data_center_fetched_cb(GObject 
>>>> *source_object,
>>>>  ovirt_resource_refresh_finish(resource, result, );
>>>>  if (error != NULL) {
>>>>  g_debug("failed to fetch Data Center: %s", error->message);
>>>> -g_task_return_error(task, error);
>>>> -g_object_unref(task);
>>>> -return;
>>>
>>> I don't think the hunk just above
>>> (storage_domain_attached_to_data_center) takes this situation into
>>> account, menu->priv->data_center is non-null, but it will be 'empty', so
>>> storage_domain_attached_to_data_center is probably not going to do the
>>> right thing.
>>
>> This callback function is only called if the previous condition tested
>> in the hunk below (function ovirt_foreign menu_fetch_data_center_async)
>> is valid.
> 
> Starting from ovirt_foreign_menu_fetch_data_center_async(), let's assume
> we trigger the
> if (menu->priv->data_center == NULL) {
> ovirt_foreign_menu_next_async_step(menu, task, STATE_DATA_CENTER);
> return;
> }
> codepath, which gets us to ovirt_foreign_menu_next_async_step():
>  case STATE_STORAGE_DOMAIN:
>   if (menu->priv->files == NULL) {
>   ovirt_foreign_menu_fetch_storage_domain_async(menu, task);
>   break;
>   }
> This calls
>   ovirt_collection_fetch_async(collection, menu->priv->proxy,
>g_task_get_cancellable(task),
>storage_domains_fetched_cb, task);
> 
> and, assuming this call is successful (even if fetching the data center
> was not), storage_domains_fetched_cb() will end up calling
> storage_domain_validate() which makes use of menu->priv->data_center
> even if it could be NULL
> 
> Did I get one of these steps wrong?
> 

You got the steps right, but in storage_domain_validate() the
dat

Re: [virt-tools-list] [PATCH virt-viewer v2 1/2] Update usage of GObject private structures

2019-02-22 Thread Eduardo Lima (Etrunko)
On 2/20/19 12:13 PM, Christophe Fergeau wrote:
> Series looks good to me,
> Reviewed-by: Christophe Fergeau 

Pushed, thanks

> 
> On Wed, Feb 20, 2019 at 11:05:36AM -0300, Eduardo Lima (Etrunko) wrote:
>> ping
>>
>> On 2/13/19 12:46 PM, Eduardo Lima (Etrunko) wrote:
>>> New functions and macros have been added in glib 2.38 to better handle
>>> this case.
>>>
>>> https://gitlab.gnome.org/GNOME/glib/blob/c8de2b11bbbf5705ee20bf68d0c11e455b441312/NEWS
>>>
>>> The old method is being deprecated as of version 2.58.
>>>
>>> https://gitlab.gnome.org/GNOME/glib/merge_requests/7/commits
>>>
>>> Signed-off-by: Eduardo Lima (Etrunko) 
>>> ---
>>>
>>> v2: Removed iso-list dialog patch which is dealt separately.
>>>
>>> ---
>>>
>>>  src/ovirt-foreign-menu.c   |  8 ++--
>>>  src/remote-viewer.c|  8 ++--
>>>  src/virt-viewer-app.c  |  8 ++--
>>>  src/virt-viewer-display-spice.c|  8 ++--
>>>  src/virt-viewer-display-vnc.c  |  8 ++--
>>>  src/virt-viewer-display-vte.c  |  8 ++--
>>>  src/virt-viewer-display.c  |  8 ++--
>>>  src/virt-viewer-file-transfer-dialog.c |  6 +-
>>>  src/virt-viewer-file.c |  7 ++-
>>>  src/virt-viewer-notebook.c | 11 +++
>>>  src/virt-viewer-session-spice.c|  8 ++--
>>>  src/virt-viewer-session-vnc.c  |  8 ++--
>>>  src/virt-viewer-session.c  |  9 ++---
>>>  src/virt-viewer-timed-revealer.c   | 11 +++
>>>  src/virt-viewer-window.c   | 11 +++
>>>  src/virt-viewer.c  |  8 ++--
>>>  16 files changed, 34 insertions(+), 101 deletions(-)
>>>
>>> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
>>> index d234a27..c6d360b 100644
>>> --- a/src/ovirt-foreign-menu.c
>>> +++ b/src/ovirt-foreign-menu.c
>>> @@ -59,8 +59,6 @@ static void 
>>> ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu, GTas
>>>  static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu 
>>> *menu, GTask *task);
>>>  static void ovirt_foreign_menu_fetch_iso_list_async(OvirtForeignMenu 
>>> *menu, GTask *task);
>>>  
>>> -G_DEFINE_TYPE (OvirtForeignMenu, ovirt_foreign_menu, G_TYPE_OBJECT)
>>> -
>>>  
>>>  struct _OvirtForeignMenuPrivate {
>>>  OvirtProxy *proxy;
>>> @@ -87,7 +85,7 @@ struct _OvirtForeignMenuPrivate {
>>>  };
>>>  
>>>  
>>> -#define OVIRT_FOREIGN_MENU_GET_PRIVATE(o) 
>>> (G_TYPE_INSTANCE_GET_PRIVATE((o), OVIRT_TYPE_FOREIGN_MENU, 
>>> OvirtForeignMenuPrivate))
>>> +G_DEFINE_TYPE_WITH_PRIVATE (OvirtForeignMenu, ovirt_foreign_menu, 
>>> G_TYPE_OBJECT)
>>>  
>>>  
>>>  enum {
>>> @@ -229,8 +227,6 @@ ovirt_foreign_menu_class_init(OvirtForeignMenuClass 
>>> *klass)
>>>  oclass->set_property = ovirt_foreign_menu_set_property;
>>>  oclass->dispose = ovirt_foreign_menu_dispose;
>>>  
>>> -g_type_class_add_private(klass, sizeof(OvirtForeignMenuPrivate));
>>> -
>>>  g_object_class_install_property(oclass,
>>>  PROP_PROXY,
>>>  g_param_spec_object("proxy",
>>> @@ -286,7 +282,7 @@ ovirt_foreign_menu_class_init(OvirtForeignMenuClass 
>>> *klass)
>>>  static void
>>>  ovirt_foreign_menu_init(OvirtForeignMenu *self)
>>>  {
>>> -self->priv = OVIRT_FOREIGN_MENU_GET_PRIVATE(self);
>>> +self->priv = ovirt_foreign_menu_get_instance_private(self);
>>>  }
>>>  
>>>  
>>> diff --git a/src/remote-viewer.c b/src/remote-viewer.c
>>> index 989466b..91eb39e 100644
>>> --- a/src/remote-viewer.c
>>> +++ b/src/remote-viewer.c
>>> @@ -54,9 +54,7 @@ struct _RemoteViewerPrivate {
>>>  gboolean open_recent_dialog;
>>>  };
>>>  
>>> -G_DEFINE_TYPE (RemoteViewer, remote_viewer, VIRT_VIEWER_TYPE_APP)
>>> -#define GET_PRIVATE(o) 
>>>\
>>> -(G_TYPE_INSTANCE_GET_PRIVATE ((o), REMOTE_VIEWER_TYPE, 
>>> RemoteViewerPrivate))
>>> +G_DEFINE_TYPE_WITH_PRIVATE (RemoteViewer, remote_viewer, 
>>> VIRT_VIEWER_TYP

Re: [virt-tools-list] [PATCH virt-viewer v2 1/2] Update usage of GObject private structures

2019-02-20 Thread Eduardo Lima (Etrunko)
ping

On 2/13/19 12:46 PM, Eduardo Lima (Etrunko) wrote:
> New functions and macros have been added in glib 2.38 to better handle
> this case.
> 
> https://gitlab.gnome.org/GNOME/glib/blob/c8de2b11bbbf5705ee20bf68d0c11e455b441312/NEWS
> 
> The old method is being deprecated as of version 2.58.
> 
> https://gitlab.gnome.org/GNOME/glib/merge_requests/7/commits
> 
> Signed-off-by: Eduardo Lima (Etrunko) 
> ---
> 
> v2: Removed iso-list dialog patch which is dealt separately.
> 
> ---
> 
>  src/ovirt-foreign-menu.c   |  8 ++--
>  src/remote-viewer.c|  8 ++--
>  src/virt-viewer-app.c  |  8 ++--
>  src/virt-viewer-display-spice.c|  8 ++--
>  src/virt-viewer-display-vnc.c  |  8 ++--
>  src/virt-viewer-display-vte.c  |  8 ++--
>  src/virt-viewer-display.c  |  8 ++--
>  src/virt-viewer-file-transfer-dialog.c |  6 +-
>  src/virt-viewer-file.c |  7 ++-
>  src/virt-viewer-notebook.c | 11 +++
>  src/virt-viewer-session-spice.c|  8 ++--
>  src/virt-viewer-session-vnc.c  |  8 ++--
>  src/virt-viewer-session.c  |  9 ++---
>  src/virt-viewer-timed-revealer.c   | 11 +++
>  src/virt-viewer-window.c   | 11 +++
>  src/virt-viewer.c  |  8 ++--
>  16 files changed, 34 insertions(+), 101 deletions(-)
> 
> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
> index d234a27..c6d360b 100644
> --- a/src/ovirt-foreign-menu.c
> +++ b/src/ovirt-foreign-menu.c
> @@ -59,8 +59,6 @@ static void 
> ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu, GTas
>  static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu 
> *menu, GTask *task);
>  static void ovirt_foreign_menu_fetch_iso_list_async(OvirtForeignMenu *menu, 
> GTask *task);
>  
> -G_DEFINE_TYPE (OvirtForeignMenu, ovirt_foreign_menu, G_TYPE_OBJECT)
> -
>  
>  struct _OvirtForeignMenuPrivate {
>  OvirtProxy *proxy;
> @@ -87,7 +85,7 @@ struct _OvirtForeignMenuPrivate {
>  };
>  
>  
> -#define OVIRT_FOREIGN_MENU_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), 
> OVIRT_TYPE_FOREIGN_MENU, OvirtForeignMenuPrivate))
> +G_DEFINE_TYPE_WITH_PRIVATE (OvirtForeignMenu, ovirt_foreign_menu, 
> G_TYPE_OBJECT)
>  
>  
>  enum {
> @@ -229,8 +227,6 @@ ovirt_foreign_menu_class_init(OvirtForeignMenuClass 
> *klass)
>  oclass->set_property = ovirt_foreign_menu_set_property;
>  oclass->dispose = ovirt_foreign_menu_dispose;
>  
> -g_type_class_add_private(klass, sizeof(OvirtForeignMenuPrivate));
> -
>  g_object_class_install_property(oclass,
>  PROP_PROXY,
>  g_param_spec_object("proxy",
> @@ -286,7 +282,7 @@ ovirt_foreign_menu_class_init(OvirtForeignMenuClass 
> *klass)
>  static void
>  ovirt_foreign_menu_init(OvirtForeignMenu *self)
>  {
> -self->priv = OVIRT_FOREIGN_MENU_GET_PRIVATE(self);
> +self->priv = ovirt_foreign_menu_get_instance_private(self);
>  }
>  
>  
> diff --git a/src/remote-viewer.c b/src/remote-viewer.c
> index 989466b..91eb39e 100644
> --- a/src/remote-viewer.c
> +++ b/src/remote-viewer.c
> @@ -54,9 +54,7 @@ struct _RemoteViewerPrivate {
>  gboolean open_recent_dialog;
>  };
>  
> -G_DEFINE_TYPE (RemoteViewer, remote_viewer, VIRT_VIEWER_TYPE_APP)
> -#define GET_PRIVATE(o)   
>  \
> -(G_TYPE_INSTANCE_GET_PRIVATE ((o), REMOTE_VIEWER_TYPE, 
> RemoteViewerPrivate))
> +G_DEFINE_TYPE_WITH_PRIVATE (RemoteViewer, remote_viewer, 
> VIRT_VIEWER_TYPE_APP)
>  
>  enum RemoteViewerProperties {
>  PROP_0,
> @@ -196,8 +194,6 @@ remote_viewer_class_init (RemoteViewerClass *klass)
>  VirtViewerAppClass *app_class = VIRT_VIEWER_APP_CLASS (klass);
>  GApplicationClass *g_app_class = G_APPLICATION_CLASS(klass);
>  
> -g_type_class_add_private (klass, sizeof (RemoteViewerPrivate));
> -
>  object_class->get_property = remote_viewer_get_property;
>  object_class->dispose = remote_viewer_dispose;
>  
> @@ -221,7 +217,7 @@ remote_viewer_class_init (RemoteViewerClass *klass)
>  static void
>  remote_viewer_init(RemoteViewer *self)
>  {
> -self->priv = GET_PRIVATE(self);
> +self->priv = remote_viewer_get_instance_private(self);
>  }
>  
>  RemoteViewer *
> diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
> index fd48014..861f8f3 100644
> --- a/src/virt-viewer-app.c
> +++ b/src/virt-viewer-app.c
> @@ -160,9 +160,7 @@ struct _

Re: [virt-tools-list] [virt-viewer PATCH 5/5] Switch to gnulib's compiler warning flags

2019-02-13 Thread Eduardo Lima (Etrunko)
On 2/13/19 3:27 PM, Marc-André Lureau wrote:
> Hi
> 
> On Wed, Feb 13, 2019 at 6:05 PM Daniel P. Berrangé  
> wrote:
>>
>> This enables many more compiler warnings than the current code. It also
>> ensures that -Werror is enabled by default when building from GIT so
>> that maintainers see regressions as hard failures.
>>
>> Signed-off-by: Daniel P. Berrangé 
> 
> Reviewed-by: Marc-André Lureau 
> 
> But soon we will switch to meson :) oh well!

I have a patch for spice that does the same for meson. I am just waiting
for it to be reviewed/acked so I can use it as base for virt-viewer as well.

> 
>> ---
>>  acinclude.m4   |  98 ---
>>  configure.ac   |   2 +-
>>  m4/manywarnings.m4 | 334 +
>>  m4/virt-viewer-warnings.m4 | 159 ++
>>  m4/warnings.m4 | 115 +
>>  prepare-release.sh |   2 +-
>>  6 files changed, 610 insertions(+), 100 deletions(-)
>>  delete mode 100644 acinclude.m4
>>  create mode 100644 m4/manywarnings.m4
>>  create mode 100644 m4/virt-viewer-warnings.m4
>>  create mode 100644 m4/warnings.m4
>>
>> diff --git a/acinclude.m4 b/acinclude.m4
>> deleted file mode 100644
>> index 68398a6..000
>> --- a/acinclude.m4
>> +++ /dev/null
>> @@ -1,98 +0,0 @@
>> -dnl
>> -dnl Taken from gnome-common/macros2/gnome-compiler-flags.m4
>> -dnl
>> -dnl We've added:
>> -dnl   -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return 
>> -Wstrict-prototypes -Winline -Wredundant-decls
>> -dnl We've removed
>> -dnl   CFLAGS="$realsave_CFLAGS"
>> -dnl   to avoid clobbering user-specified CFLAGS
>> -dnl
>> -AC_DEFUN([VIRT_VIEWER_COMPILE_WARNINGS],[
>> -dnl **
>> -dnl More compiler warnings
>> -dnl **
>> -
>> -AC_ARG_ENABLE(compile-warnings,
>> -  
>> AC_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
>> - [Turn on compiler warnings]),,
>> -  [enable_compile_warnings="m4_default([$1],[maximum])"])
>> -
>> -warnCFLAGS=
>> -
>> -try_compiler_flags="-fexceptions -fstack-protector 
>> --param=ssp-buffer-size=4 -fasynchronous-unwind-tables"
>> -
>> -case "$enable_compile_warnings" in
>> -no)
>> -   ;;
>> -minimum)
>> -   try_compiler_flags="$try_compiler_flags -Wall"
>> -   ;;
>> -yes)
>> -   try_compiler_flags="$try_compiler_flags -Wall -Wmissing-prototypes 
>> -std=c99"
>> -   ;;
>> -maximum|error)
>> -   try_compiler_flags="$try_compiler_flags -Wall -Wmissing-prototypes 
>> -std=c99 -Wnested-externs -Wpointer-arith"
>> -try_compiler_flags="$try_compiler_flags -Wextra -Wshadow 
>> -Wcast-align -Wwrite-strings -Waggregate-return"
>> -# Removed -Wstrict-prototypes to avoid GTK bug
>> -   try_compiler_flags="$try_compiler_flags -Winline -Wredundant-decls 
>> -Wdeprecated-declarations -Wno-sign-compare"
>> -   # Remove as glib function casts hit
>> -   try_compiler_flags="$try_compiler_flags -Wno-cast-function-type"
>> -   if test "$enable_compile_warnings" = "error" ; then
>> -   try_compiler_flags="$try_compiler_flags -Werror"
>> -   fi
>> -   ;;
>> -*)
>> -   AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to 
>> --enable-compile-warnings)
>> -   ;;
>> -esac
>> -
>> -AH_VERBATIM([FORTIFY_SOURCE],
>> -[/* Enable compile-time and run-time bounds-checking, and 
>> some warnings. */
>> - #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && 
>> __OPTIMIZE__
>> - # define _FORTIFY_SOURCE 2
>> - #endif
>> -])
>> -
>> -compiler_flags=
>> -for option in $try_compiler_flags; do
>> -   SAVE_CFLAGS="$CFLAGS"
>> -   CFLAGS="$CFLAGS $option"
>> -   AC_MSG_CHECKING([whether gcc understands $option])
>> -   AC_TRY_COMPILE([], [],
>> -   has_option=yes,
>> -   has_option=no,)
>> -   CFLAGS="$SAVE_CFLAGS"
>> -   AC_MSG_RESULT($has_option)
>> -   if test $has_option = yes; then
>> - compiler_flags="$compiler_flags $option"
>> -   fi
>> -   unset has_option
>> -   unset SAVE_CFLAGS
>> -done
>> -unset option
>> -unset try_compiler_flags
>> -
>> -AC_ARG_ENABLE(iso-c,
>> -  AC_HELP_STRING([--enable-iso-c],
>> - [Try to warn if code is not ISO C ]),,
>> -  [enable_iso_c=no])
>> -
>> -AC_MSG_CHECKING(what language compliance flags to pass to the C 
>> compiler)
>> -complCFLAGS=
>> -if test "x$enable_iso_c" != "xno"; then
>> -   if test "x$GCC" = "xyes"; then
>> -   case " $CFLAGS " in
>> -   *[\ \   ]-ansi[\ \  ]*) ;;
>> -   *) complCFLAGS="$complCFLAGS -ansi" ;;
>> -   esac
>> -   case " $CFLAGS " in
>> -   *[\ \   

Re: [virt-tools-list] [PATCH virt-viewer v2] Update usage of GObject private structures

2019-02-13 Thread Eduardo Lima (Etrunko)
On 2/11/19 3:31 PM, Daniel P. Berrangé wrote:
> On Mon, Feb 11, 2019 at 06:24:37PM +0100, Christophe Fergeau wrote:
>> Hey,
>>
>> Looks good to me, 2 comments below:
>>
>> On Thu, Feb 07, 2019 at 10:54:58AM -0200, Eduardo Lima (Etrunko) wrote:
>>
>>> diff --git a/src/remote-viewer-iso-list-dialog.c 
>>> b/src/remote-viewer-iso-list-dialog.c
>>> index 3505211..8e25b72 100644
>>> --- a/src/remote-viewer-iso-list-dialog.c
>>> +++ b/src/remote-viewer-iso-list-dialog.c
>>> @@ -114,7 +109,7 @@ 
>>> remote_viewer_iso_list_dialog_class_init(RemoteViewerISOListDialogClass 
>>> *klass)
>>>  static void
>>>  remote_viewer_iso_list_dialog_show_files(RemoteViewerISOListDialog *self)
>>>  {
>>> -self->priv = DIALOG_PRIVATE(self);
>>> +self->priv = remote_viewer_iso_list_dialog_get_instance_private(self);
>>
>> Is this really needed here when it's already done in
>> remote_viewer_iso_list_dialog_init? (such a change would belong in a
>> separate commit though)
>>
>>>  gtk_stack_set_visible_child_full(GTK_STACK(self->priv->stack), 
>>> "iso-list",
>>>   GTK_STACK_TRANSITION_TYPE_NONE);
>>>  gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, 
>>> TRUE);
>>> @@ -262,7 +257,8 @@ static void
>>>  remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self)
>>>  {
>>>  GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(self));
>>> -RemoteViewerISOListDialogPrivate *priv = self->priv = 
>>> DIALOG_PRIVATE(self);
>>> +RemoteViewerISOListDialogPrivate *priv = self->priv =
>>> +remote_viewer_iso_list_dialog_get_instance_private(self);
>>
>> Hiding the initialization of 'self->priv' in the middle of local
>> variable declaration/initialization is not the most readable thing ever,
>> this could be split too ;)
> 
> Unless the class is is intended to be derivable, best practice for glib
> is to not in fact use the FooPrivate struct paradigm. Instead the
> RemoteViewerISOListDialog struct would be defined in the .c file
> and just contain the private fields directly.

Yes, it makes sense. I changed the dialog code so that the struct
definitions are now in the source file instead of in the header.

> 
> This is what the G_DECLARE_FINAL_TYPE() macro from glib 2.44 does.
> 
> Only the G_DECLARE_DERIVABLE_TYPE() macro uses a "Private" struct.
> 
> We currently depend on glib 2.40 as min version, but if we don't
> want to bump to 2.444, we could easily backport this new macro
> and use it in our code. It eliminates lots of tedious boilerplate
> code in the headers.
> 
>> Apart from this, looks good to me,
>>
>> Reviewed-by: Christophe Fergeau 
> 
> Regards,
> Daniel
> 


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

[virt-tools-list] [PATCH virt-viewer v2 2/2] iso-dialog: Move type definitions from header to source file

2019-02-13 Thread Eduardo Lima (Etrunko)
There is no reason for this object to define a private structure, so it
is fine to make everything private to the dialog itself.

Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/remote-viewer-iso-list-dialog.c | 108 +---
 src/remote-viewer-iso-list-dialog.h |  13 
 2 files changed, 49 insertions(+), 72 deletions(-)

diff --git a/src/remote-viewer-iso-list-dialog.c 
b/src/remote-viewer-iso-list-dialog.c
index 3505211..c6fbe50 100644
--- a/src/remote-viewer-iso-list-dialog.c
+++ b/src/remote-viewer-iso-list-dialog.c
@@ -29,13 +29,9 @@
 static void ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu 
*foreign_menu, GAsyncResult *result, RemoteViewerISOListDialog *self);
 static void remote_viewer_iso_list_dialog_show_error(RemoteViewerISOListDialog 
*self, const gchar *message);
 
-G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, 
GTK_TYPE_DIALOG)
-
-#define DIALOG_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, 
RemoteViewerISOListDialogPrivate))
-
-struct _RemoteViewerISOListDialogPrivate
+struct _RemoteViewerISOListDialog
 {
+GtkDialog parent;
 GtkListStore *list_store;
 GtkWidget *status;
 GtkWidget *spinner;
@@ -45,6 +41,13 @@ struct _RemoteViewerISOListDialogPrivate
 GCancellable *cancellable;
 };
 
+struct _RemoteViewerISOListDialogClass
+{
+GtkDialogClass parent_class;
+};
+
+G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, 
GTK_TYPE_DIALOG)
+
 enum RemoteViewerISOListDialogModel
 {
 ISO_IS_ACTIVE = 0,
@@ -65,13 +68,12 @@ static void
 remote_viewer_iso_list_dialog_dispose(GObject *object)
 {
 RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object);
-RemoteViewerISOListDialogPrivate *priv = self->priv;
 
-g_clear_object(>cancellable);
+g_clear_object(>cancellable);
 
-if (priv->foreign_menu) {
-g_signal_handlers_disconnect_by_data(priv->foreign_menu, object);
-g_clear_object(>foreign_menu);
+if (self->foreign_menu) {
+g_signal_handlers_disconnect_by_data(self->foreign_menu, object);
+g_clear_object(>foreign_menu);
 }
 
G_OBJECT_CLASS(remote_viewer_iso_list_dialog_parent_class)->dispose(object);
 }
@@ -81,11 +83,10 @@ remote_viewer_iso_list_dialog_set_property(GObject *object, 
guint property_id,
const GValue *value, GParamSpec 
*pspec)
 {
 RemoteViewerISOListDialog *self = REMOTE_VIEWER_ISO_LIST_DIALOG(object);
-RemoteViewerISOListDialogPrivate *priv = self->priv;
 
 switch (property_id) {
 case PROP_FOREIGN_MENU:
-priv->foreign_menu = g_value_dup_object(value);
+self->foreign_menu = g_value_dup_object(value);
 break;
 default:
 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -97,8 +98,6 @@ 
remote_viewer_iso_list_dialog_class_init(RemoteViewerISOListDialogClass *klass)
 {
 GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
-g_type_class_add_private(klass, sizeof(RemoteViewerISOListDialogPrivate));
-
 object_class->dispose = remote_viewer_iso_list_dialog_dispose;
 object_class->set_property = remote_viewer_iso_list_dialog_set_property;
 
@@ -114,8 +113,7 @@ 
remote_viewer_iso_list_dialog_class_init(RemoteViewerISOListDialogClass *klass)
 static void
 remote_viewer_iso_list_dialog_show_files(RemoteViewerISOListDialog *self)
 {
-self->priv = DIALOG_PRIVATE(self);
-gtk_stack_set_visible_child_full(GTK_STACK(self->priv->stack), "iso-list",
+gtk_stack_set_visible_child_full(GTK_STACK(self->stack), "iso-list",
  GTK_STACK_TRANSITION_TYPE_NONE);
 gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, 
TRUE);
 }
@@ -123,22 +121,21 @@ 
remote_viewer_iso_list_dialog_show_files(RemoteViewerISOListDialog *self)
 static void
 remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog 
*self)
 {
-RemoteViewerISOListDialogPrivate *priv = self->priv;
-gchar *current_iso = 
ovirt_foreign_menu_get_current_iso_name(self->priv->foreign_menu);
+gchar *current_iso = 
ovirt_foreign_menu_get_current_iso_name(self->foreign_menu);
 gboolean active = (g_strcmp0(current_iso, name) == 0);
 gint weight = active ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL;
 GtkTreeIter iter;
 
-gtk_list_store_append(priv->list_store, );
-gtk_list_store_set(priv->list_store, ,
+gtk_list_store_append(self->list_store, );
+gtk_list_store_set(self->list_store, ,
ISO_IS_ACTIVE, active,
ISO_NAME, name,
FONT_WEIGHT, weight, -1);
 
 if (active) {
-GtkTreePath *path = 
gtk_tree_model_get_path(GTK_TREE_MODEL(priv->list_store), );
-gtk_tree_view_set_cursor(GTK_TREE_VIEW(priv->tree_view), p

[virt-tools-list] [PATCH virt-viewer v2 1/2] Update usage of GObject private structures

2019-02-13 Thread Eduardo Lima (Etrunko)
New functions and macros have been added in glib 2.38 to better handle
this case.

https://gitlab.gnome.org/GNOME/glib/blob/c8de2b11bbbf5705ee20bf68d0c11e455b441312/NEWS

The old method is being deprecated as of version 2.58.

https://gitlab.gnome.org/GNOME/glib/merge_requests/7/commits

Signed-off-by: Eduardo Lima (Etrunko) 
---

v2: Removed iso-list dialog patch which is dealt separately.

---

 src/ovirt-foreign-menu.c   |  8 ++--
 src/remote-viewer.c|  8 ++--
 src/virt-viewer-app.c  |  8 ++--
 src/virt-viewer-display-spice.c|  8 ++--
 src/virt-viewer-display-vnc.c  |  8 ++--
 src/virt-viewer-display-vte.c  |  8 ++--
 src/virt-viewer-display.c  |  8 ++--
 src/virt-viewer-file-transfer-dialog.c |  6 +-
 src/virt-viewer-file.c |  7 ++-
 src/virt-viewer-notebook.c | 11 +++
 src/virt-viewer-session-spice.c|  8 ++--
 src/virt-viewer-session-vnc.c  |  8 ++--
 src/virt-viewer-session.c  |  9 ++---
 src/virt-viewer-timed-revealer.c   | 11 +++
 src/virt-viewer-window.c   | 11 +++
 src/virt-viewer.c  |  8 ++--
 16 files changed, 34 insertions(+), 101 deletions(-)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index d234a27..c6d360b 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -59,8 +59,6 @@ static void 
ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu, GTas
 static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu 
*menu, GTask *task);
 static void ovirt_foreign_menu_fetch_iso_list_async(OvirtForeignMenu *menu, 
GTask *task);
 
-G_DEFINE_TYPE (OvirtForeignMenu, ovirt_foreign_menu, G_TYPE_OBJECT)
-
 
 struct _OvirtForeignMenuPrivate {
 OvirtProxy *proxy;
@@ -87,7 +85,7 @@ struct _OvirtForeignMenuPrivate {
 };
 
 
-#define OVIRT_FOREIGN_MENU_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), 
OVIRT_TYPE_FOREIGN_MENU, OvirtForeignMenuPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (OvirtForeignMenu, ovirt_foreign_menu, 
G_TYPE_OBJECT)
 
 
 enum {
@@ -229,8 +227,6 @@ ovirt_foreign_menu_class_init(OvirtForeignMenuClass *klass)
 oclass->set_property = ovirt_foreign_menu_set_property;
 oclass->dispose = ovirt_foreign_menu_dispose;
 
-g_type_class_add_private(klass, sizeof(OvirtForeignMenuPrivate));
-
 g_object_class_install_property(oclass,
 PROP_PROXY,
 g_param_spec_object("proxy",
@@ -286,7 +282,7 @@ ovirt_foreign_menu_class_init(OvirtForeignMenuClass *klass)
 static void
 ovirt_foreign_menu_init(OvirtForeignMenu *self)
 {
-self->priv = OVIRT_FOREIGN_MENU_GET_PRIVATE(self);
+self->priv = ovirt_foreign_menu_get_instance_private(self);
 }
 
 
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 989466b..91eb39e 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -54,9 +54,7 @@ struct _RemoteViewerPrivate {
 gboolean open_recent_dialog;
 };
 
-G_DEFINE_TYPE (RemoteViewer, remote_viewer, VIRT_VIEWER_TYPE_APP)
-#define GET_PRIVATE(o)\
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), REMOTE_VIEWER_TYPE, 
RemoteViewerPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (RemoteViewer, remote_viewer, VIRT_VIEWER_TYPE_APP)
 
 enum RemoteViewerProperties {
 PROP_0,
@@ -196,8 +194,6 @@ remote_viewer_class_init (RemoteViewerClass *klass)
 VirtViewerAppClass *app_class = VIRT_VIEWER_APP_CLASS (klass);
 GApplicationClass *g_app_class = G_APPLICATION_CLASS(klass);
 
-g_type_class_add_private (klass, sizeof (RemoteViewerPrivate));
-
 object_class->get_property = remote_viewer_get_property;
 object_class->dispose = remote_viewer_dispose;
 
@@ -221,7 +217,7 @@ remote_viewer_class_init (RemoteViewerClass *klass)
 static void
 remote_viewer_init(RemoteViewer *self)
 {
-self->priv = GET_PRIVATE(self);
+self->priv = remote_viewer_get_instance_private(self);
 }
 
 RemoteViewer *
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index fd48014..861f8f3 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -160,9 +160,7 @@ struct _VirtViewerAppPrivate {
 };
 
 
-G_DEFINE_ABSTRACT_TYPE(VirtViewerApp, virt_viewer_app, GTK_TYPE_APPLICATION)
-#define GET_PRIVATE(o)\
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), VIRT_VIEWER_TYPE_APP, 
VirtViewerAppPrivate))
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(VirtViewerApp, virt_viewer_app, 
GTK_TYPE_APPLICATION)
 
 enum {
 PROP_0,
@@ -1749,7 +1747,7 @@ static void
 virt_viewer_app_init(VirtViewerApp *self)
 {
 GError *error = NULL;
-self->priv = GET_PRIVATE(self);
+self->priv = virt_viewer_app_get_instance_private(self);
 
 gtk_window_set_default_icon_name("virt-viewer");

Re: [virt-tools-list] [PATCH virt-viewer] window: Use proper define from glib for ignoring deprecated warning

2019-02-13 Thread Eduardo Lima (Etrunko)
Please ignore this one, using the wrong define, it was sent from a wrong
branch.

On 2/13/19 11:00 AM, Eduardo Lima (Etrunko) wrote:
> Signed-off-by: Eduardo Lima (Etrunko) 
> ---
>  src/virt-viewer-window.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index 96b35f6..cbf3f29 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -600,11 +600,10 @@ virt_viewer_window_enter_fullscreen(VirtViewerWindow 
> *self, gint monitor)
>  // just go fullscreen on the current monitor
>  gtk_window_fullscreen(GTK_WINDOW(priv->window));
>  } else {
> -#pragma GCC diagnostic push
> -#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
> +G_GNUC_BEGIN_IGNORE_DEPRECATED_DECLARATIONS
>  gtk_window_fullscreen_on_monitor(GTK_WINDOW(priv->window),
>   gdk_screen_get_default(), monitor);
> -#pragma GCC diagnostic pop
> +G_GNUC_END_IGNORE_DEPRECATED_DECLARATIONS
>  }
>  #else
>  gtk_window_fullscreen(GTK_WINDOW(priv->window));
> 


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer v2] window: Use proper define from glib for ignoring deprecated warning

2019-02-13 Thread Eduardo Lima (Etrunko)
Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/virt-viewer-window.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 96b35f6..4bbe2ca 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -600,11 +600,10 @@ virt_viewer_window_enter_fullscreen(VirtViewerWindow 
*self, gint monitor)
 // just go fullscreen on the current monitor
 gtk_window_fullscreen(GTK_WINDOW(priv->window));
 } else {
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 gtk_window_fullscreen_on_monitor(GTK_WINDOW(priv->window),
  gdk_screen_get_default(), monitor);
-#pragma GCC diagnostic pop
+G_GNUC_END_IGNORE_DEPRECATIONS
 }
 #else
 gtk_window_fullscreen(GTK_WINDOW(priv->window));
-- 
2.20.1

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer] window: Use proper define from glib for ignoring deprecated warning

2019-02-13 Thread Eduardo Lima (Etrunko)
Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/virt-viewer-window.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 96b35f6..cbf3f29 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -600,11 +600,10 @@ virt_viewer_window_enter_fullscreen(VirtViewerWindow 
*self, gint monitor)
 // just go fullscreen on the current monitor
 gtk_window_fullscreen(GTK_WINDOW(priv->window));
 } else {
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+G_GNUC_BEGIN_IGNORE_DEPRECATED_DECLARATIONS
 gtk_window_fullscreen_on_monitor(GTK_WINDOW(priv->window),
  gdk_screen_get_default(), monitor);
-#pragma GCC diagnostic pop
+G_GNUC_END_IGNORE_DEPRECATED_DECLARATIONS
 }
 #else
 gtk_window_fullscreen(GTK_WINDOW(priv->window));
-- 
2.20.1

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer] Disable deprecation warnings for gtk_window_fullscreen_on_monitor

2019-02-13 Thread Eduardo Lima (Etrunko)
On 2/13/19 7:28 AM, Daniel P. Berrangé wrote:
> On Tue, Feb 12, 2019 at 05:34:44PM -0200, Eduardo Lima (Etrunko) wrote:
>> On 2/12/19 12:36 PM, Daniel P. Berrangé wrote:
>>> We use GLIB_VERSION_MAX_ALLOWED to prevent use of functions from
>>> GTK >= 3.12. When we do conditional compilation based on a GTK
>>> version check, we must thus suppress the warning:
>>>
>>>   CC   libvirt_viewer_la-virt-viewer-window.lo
>>> ../../src/virt-viewer-window.c: In function 
>>> 'virt_viewer_window_enter_fullscreen':
>>> ../../src/virt-viewer-window.c:608:9: error: 
>>> 'gtk_window_fullscreen_on_monitor' is deprecated: Not available before 3.18 
>>> [-Werror=deprecated-declarations]
>>>  gtk_window_fullscreen_on_monitor(GTK_WINDOW(priv->window),
>>>  ^~~~
>>> In file included from /usr/include/gtk-3.0/gtk/gtkdialog.h:32,
>>>  from /usr/include/gtk-3.0/gtk/gtkaboutdialog.h:30,
>>>  from /usr/include/gtk-3.0/gtk/gtk.h:31,
>>>  from ../../src/virt-viewer-window.c:28:
>>> /usr/include/gtk-3.0/gtk/gtkwindow.h:391:10: note: declared here
>>>  void gtk_window_fullscreen_on_monitor(GtkWindow *window,
>>>   ^~~~
>>> cc1: all warnings being treated as errors
>>>
>>> Signed-off-by: Daniel P. Berrangé 
>>> ---
>>>
>>> Pushed as a build breaker fix
>>>
>>>  src/virt-viewer-window.c | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
>>> index a7b2deb..d3e0fcf 100644
>>> --- a/src/virt-viewer-window.c
>>> +++ b/src/virt-viewer-window.c
>>> @@ -605,8 +605,11 @@ virt_viewer_window_enter_fullscreen(VirtViewerWindow 
>>> *self, gint monitor)
>>>  // just go fullscreen on the current monitor
>>>  gtk_window_fullscreen(GTK_WINDOW(priv->window));
>>>  } else {
>>> +#pragma GCC diagnostic push
>>> +#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
>>>  gtk_window_fullscreen_on_monitor(GTK_WINDOW(priv->window),
>>>   gdk_screen_get_default(), 
>>> monitor);
>>> +#pragma GCC diagnostic pop
>>>  }
>>>  #else
>>>  gtk_window_fullscreen(GTK_WINDOW(priv->window));
>>>
>>
>> I think it ould better to use
>> G_P{BEGIN,END}_IGNORE_DEPRECATED_DECLARATIONS instead.
> 
> If those are available in our min glib version please send a patch.
> I already pushed my patch since it was a build breaker fix blocking
> me doing the release.

The correct define is G_GNUC_BEGIN_IGNORE_DEPRECATIONS, and it is
available since 2.32.


> 
> Regards,
> Daniel
> 


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

Re: [virt-tools-list] [PATCH virt-viewer] Disable deprecation warnings for gtk_window_fullscreen_on_monitor

2019-02-12 Thread Eduardo Lima (Etrunko)
On 2/12/19 12:36 PM, Daniel P. Berrangé wrote:
> We use GLIB_VERSION_MAX_ALLOWED to prevent use of functions from
> GTK >= 3.12. When we do conditional compilation based on a GTK
> version check, we must thus suppress the warning:
> 
>   CC   libvirt_viewer_la-virt-viewer-window.lo
> ../../src/virt-viewer-window.c: In function 
> 'virt_viewer_window_enter_fullscreen':
> ../../src/virt-viewer-window.c:608:9: error: 
> 'gtk_window_fullscreen_on_monitor' is deprecated: Not available before 3.18 
> [-Werror=deprecated-declarations]
>  gtk_window_fullscreen_on_monitor(GTK_WINDOW(priv->window),
>  ^~~~
> In file included from /usr/include/gtk-3.0/gtk/gtkdialog.h:32,
>  from /usr/include/gtk-3.0/gtk/gtkaboutdialog.h:30,
>  from /usr/include/gtk-3.0/gtk/gtk.h:31,
>  from ../../src/virt-viewer-window.c:28:
> /usr/include/gtk-3.0/gtk/gtkwindow.h:391:10: note: declared here
>  void gtk_window_fullscreen_on_monitor(GtkWindow *window,
>   ^~~~
> cc1: all warnings being treated as errors
> 
> Signed-off-by: Daniel P. Berrangé 
> ---
> 
> Pushed as a build breaker fix
> 
>  src/virt-viewer-window.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index a7b2deb..d3e0fcf 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -605,8 +605,11 @@ virt_viewer_window_enter_fullscreen(VirtViewerWindow 
> *self, gint monitor)
>  // just go fullscreen on the current monitor
>  gtk_window_fullscreen(GTK_WINDOW(priv->window));
>  } else {
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
>  gtk_window_fullscreen_on_monitor(GTK_WINDOW(priv->window),
>   gdk_screen_get_default(), monitor);
> +#pragma GCC diagnostic pop
>  }
>  #else
>  gtk_window_fullscreen(GTK_WINDOW(priv->window));
> 

I think it ould better to use
G_P{BEGIN,END}_IGNORE_DEPRECATED_DECLARATIONS instead.


diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 648e769..1fd1c47 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -600,8 +600,10 @@
virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gint monitor)
 // just go fullscreen on the current monitor
 gtk_window_fullscreen(GTK_WINDOW(priv->window));
 } else {
+G_BEGIN_IGNORE_DEPRECATED_DECLARATIONS
 gtk_window_fullscreen_on_monitor(GTK_WINDOW(priv->window),
  gdk_screen_get_default(),
monitor);
+G_END_IGNORE_DEPRECATED_DECLARATIONS
 }
 #else
 gtk_window_fullscreen(GTK_WINDOW(priv->window));



-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

[virt-tools-list] [PATCH virt-viewer v2] Update usage of GObject private structures

2019-02-07 Thread Eduardo Lima (Etrunko)
New functions and macros have been added in glib 2.38 to better handle
this case.

https://gitlab.gnome.org/GNOME/glib/blob/c8de2b11bbbf5705ee20bf68d0c11e455b441312/NEWS

The old method is being deprecated as of version 2.58.

https://gitlab.gnome.org/GNOME/glib/merge_requests/7/commits

Signed-off-by: Eduardo Lima (Etrunko) 
---

in v2:
 - Replace GET_PRIVATE macros with appropriate _get_instance_private()

---
 src/ovirt-foreign-menu.c   |  8 ++--
 src/remote-viewer-iso-list-dialog.c| 14 +-
 src/remote-viewer.c|  8 ++--
 src/virt-viewer-app.c  |  8 ++--
 src/virt-viewer-display-spice.c|  8 ++--
 src/virt-viewer-display-vnc.c  |  8 ++--
 src/virt-viewer-display-vte.c  |  8 ++--
 src/virt-viewer-display.c  |  8 ++--
 src/virt-viewer-file-transfer-dialog.c |  6 +-
 src/virt-viewer-file.c |  7 ++-
 src/virt-viewer-notebook.c | 11 +++
 src/virt-viewer-session-spice.c|  8 ++--
 src/virt-viewer-session-vnc.c  |  8 ++--
 src/virt-viewer-session.c  |  9 ++---
 src/virt-viewer-timed-revealer.c   | 11 +++
 src/virt-viewer-window.c   | 11 +++
 src/virt-viewer.c  |  8 ++--
 17 files changed, 39 insertions(+), 110 deletions(-)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index d234a27..c6d360b 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -59,8 +59,6 @@ static void 
ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu, GTas
 static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu 
*menu, GTask *task);
 static void ovirt_foreign_menu_fetch_iso_list_async(OvirtForeignMenu *menu, 
GTask *task);
 
-G_DEFINE_TYPE (OvirtForeignMenu, ovirt_foreign_menu, G_TYPE_OBJECT)
-
 
 struct _OvirtForeignMenuPrivate {
 OvirtProxy *proxy;
@@ -87,7 +85,7 @@ struct _OvirtForeignMenuPrivate {
 };
 
 
-#define OVIRT_FOREIGN_MENU_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), 
OVIRT_TYPE_FOREIGN_MENU, OvirtForeignMenuPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (OvirtForeignMenu, ovirt_foreign_menu, 
G_TYPE_OBJECT)
 
 
 enum {
@@ -229,8 +227,6 @@ ovirt_foreign_menu_class_init(OvirtForeignMenuClass *klass)
 oclass->set_property = ovirt_foreign_menu_set_property;
 oclass->dispose = ovirt_foreign_menu_dispose;
 
-g_type_class_add_private(klass, sizeof(OvirtForeignMenuPrivate));
-
 g_object_class_install_property(oclass,
 PROP_PROXY,
 g_param_spec_object("proxy",
@@ -286,7 +282,7 @@ ovirt_foreign_menu_class_init(OvirtForeignMenuClass *klass)
 static void
 ovirt_foreign_menu_init(OvirtForeignMenu *self)
 {
-self->priv = OVIRT_FOREIGN_MENU_GET_PRIVATE(self);
+self->priv = ovirt_foreign_menu_get_instance_private(self);
 }
 
 
diff --git a/src/remote-viewer-iso-list-dialog.c 
b/src/remote-viewer-iso-list-dialog.c
index 3505211..8e25b72 100644
--- a/src/remote-viewer-iso-list-dialog.c
+++ b/src/remote-viewer-iso-list-dialog.c
@@ -29,11 +29,6 @@
 static void ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu 
*foreign_menu, GAsyncResult *result, RemoteViewerISOListDialog *self);
 static void remote_viewer_iso_list_dialog_show_error(RemoteViewerISOListDialog 
*self, const gchar *message);
 
-G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, 
GTK_TYPE_DIALOG)
-
-#define DIALOG_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE((o), REMOTE_VIEWER_TYPE_ISO_LIST_DIALOG, 
RemoteViewerISOListDialogPrivate))
-
 struct _RemoteViewerISOListDialogPrivate
 {
 GtkListStore *list_store;
@@ -45,6 +40,8 @@ struct _RemoteViewerISOListDialogPrivate
 GCancellable *cancellable;
 };
 
+G_DEFINE_TYPE_WITH_PRIVATE(RemoteViewerISOListDialog, 
remote_viewer_iso_list_dialog, GTK_TYPE_DIALOG)
+
 enum RemoteViewerISOListDialogModel
 {
 ISO_IS_ACTIVE = 0,
@@ -97,8 +94,6 @@ 
remote_viewer_iso_list_dialog_class_init(RemoteViewerISOListDialogClass *klass)
 {
 GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
-g_type_class_add_private(klass, sizeof(RemoteViewerISOListDialogPrivate));
-
 object_class->dispose = remote_viewer_iso_list_dialog_dispose;
 object_class->set_property = remote_viewer_iso_list_dialog_set_property;
 
@@ -114,7 +109,7 @@ 
remote_viewer_iso_list_dialog_class_init(RemoteViewerISOListDialogClass *klass)
 static void
 remote_viewer_iso_list_dialog_show_files(RemoteViewerISOListDialog *self)
 {
-self->priv = DIALOG_PRIVATE(self);
+self->priv = remote_viewer_iso_list_dialog_get_instance_private(self);
 gtk_stack_set_visible_child_full(GTK_STACK(self->priv->stack), "iso-list",
  GTK_STACK_TRANSITION_TYPE_NONE);
 gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESP

[virt-tools-list] [PATCH virt-viewer v2] ovirt-foreign-menu: Bypass errors from Host/Cluster/Data Center

2019-02-05 Thread Eduardo Lima (Etrunko)
When accessing ovirt as a regular user, it may happen that queries to
Hosts, Clusters and Data Centers return errors due to insufficient
permissions, while they will work fine if access is done by admin user.
In this case, we skip the errors and fallback to the old method.

Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/ovirt-foreign-menu.c | 46 +---
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index d234a27..36ec2ed 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -631,12 +631,21 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 }
 
 static gboolean storage_domain_attached_to_data_center(OvirtStorageDomain 
*domain,
-  OvirtDataCenter 
*data_center)
+   OvirtDataCenter 
*data_center)
 {
 GStrv data_center_ids;
 char *data_center_guid;
 gboolean match;
 
+/* For some reason we did not get data center information, so just return
+ * TRUE as it will work like a fallback to old method, where we did not
+ * check relationship between data center and storage domain.
+ */
+if (data_center == NULL) {
+g_debug("Could not get data center info, considering storage domain is 
attached to it");
+return TRUE;
+}
+
 g_object_get(domain, "data-center-ids", _center_ids, NULL);
 g_object_get(data_center, "guid", _center_guid, NULL);
 match = strv_contains((const gchar * const *) data_center_ids, 
data_center_guid);
@@ -750,9 +759,6 @@ static void data_center_fetched_cb(GObject *source_object,
 ovirt_resource_refresh_finish(resource, result, );
 if (error != NULL) {
 g_debug("failed to fetch Data Center: %s", error->message);
-g_task_return_error(task, error);
-g_object_unref(task);
-return;
 }
 
 ovirt_foreign_menu_next_async_step(menu, task, STATE_DATA_CENTER);
@@ -767,6 +773,12 @@ static void 
ovirt_foreign_menu_fetch_data_center_async(OvirtForeignMenu *menu,
 g_return_if_fail(OVIRT_IS_CLUSTER(menu->priv->cluster));
 
 menu->priv->data_center = 
ovirt_cluster_get_data_center(menu->priv->cluster);
+
+if (menu->priv->data_center == NULL) {
+ovirt_foreign_menu_next_async_step(menu, task, STATE_DATA_CENTER);
+return;
+}
+
 ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->priv->data_center),
  menu->priv->proxy,
  g_task_get_cancellable(task),
@@ -787,9 +799,6 @@ static void cluster_fetched_cb(GObject *source_object,
 ovirt_resource_refresh_finish(resource, result, );
 if (error != NULL) {
 g_debug("failed to fetch Cluster: %s", error->message);
-g_task_return_error(task, error);
-g_object_unref(task);
-return;
 }
 
 ovirt_foreign_menu_next_async_step(menu, task, STATE_CLUSTER);
@@ -801,9 +810,16 @@ static void 
ovirt_foreign_menu_fetch_cluster_async(OvirtForeignMenu *menu,
 {
 g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
 g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
-g_return_if_fail(OVIRT_IS_HOST(menu->priv->host));
 
-menu->priv->cluster = ovirt_host_get_cluster(menu->priv->host);
+/* If there is no host information, we get cluster from the VM */
+if (menu->priv->host == NULL) {
+g_return_if_fail(OVIRT_IS_VM(menu->priv->vm));
+menu->priv->cluster = ovirt_vm_get_cluster(menu->priv->vm);
+} else {
+g_return_if_fail(OVIRT_IS_HOST(menu->priv->host));
+menu->priv->cluster = ovirt_host_get_cluster(menu->priv->host);
+}
+
 ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->priv->cluster),
  menu->priv->proxy,
  g_task_get_cancellable(task),
@@ -824,9 +840,6 @@ static void host_fetched_cb(GObject *source_object,
 ovirt_resource_refresh_finish(resource, result, );
 if (error != NULL) {
 g_debug("failed to fetch Host: %s", error->message);
-g_task_return_error(task, error);
-g_object_unref(task);
-return;
 }
 
 ovirt_foreign_menu_next_async_step(menu, task, STATE_HOST);
@@ -841,6 +854,15 @@ static void 
ovirt_foreign_menu_fetch_host_async(OvirtForeignMenu *menu,
 g_return_if_fail(OVIRT_IS_VM(menu->priv->vm));
 
 menu->priv->host = ovirt_vm_get_host(menu->priv->vm);
+
+/* In some cases the VM XML does not include host information, so we just
+ * skip to the next step
+ */
+if (menu->priv->host == NULL) {
+ovirt_foreign_menu_next_async_step(menu, task, STATE_HOST);
+return;
+}
+
 ovirt_resource_refresh_async(OVIRT_RESOURCE

Re: [virt-tools-list] [PATCH virt-viewer 3/3] ovirt-foreign-menu: Bypass errors from Host/Cluster/Data Center

2019-02-05 Thread Eduardo Lima (Etrunko)
On 7/17/18 11:48 AM, Christophe Fergeau wrote:
> On Fri, Jul 06, 2018 at 09:59:23AM -0300, Eduardo Lima (Etrunko) wrote:
>> When accessing ovirt as a regular user, it may happen that queries to
>> Hosts, Clusters and Data Centers return errors due to insufficient
>> permissions, while they will work fine if access is done by admin user.
>> In this case, we skip the errors and fallback to the old method.
>>
>> Signed-off-by: Eduardo Lima (Etrunko) 
>> ---
>>  src/ovirt-foreign-menu.c | 43 +++
>>  1 file changed, 31 insertions(+), 12 deletions(-)
>>
>> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
>> index 70a0b50..8ed08c9 100644
>> --- a/src/ovirt-foreign-menu.c
>> +++ b/src/ovirt-foreign-menu.c
>> @@ -624,12 +624,20 @@ static void 
>> ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu,
>>  
>>  #ifdef HAVE_OVIRT_DATA_CENTER
>>  static gboolean storage_domain_attached_to_data_center(OvirtStorageDomain 
>> *domain,
>> -  OvirtDataCenter 
>> *data_center)
>> +   OvirtDataCenter 
>> *data_center)
>>  {
>>  GStrv data_center_ids;
>>  char *data_center_guid;
>>  gboolean match;
>>  
>> +/* For some reason we did not get data center information, so just 
>> return
>> + * TRUE as it will work like a fallback to old method, where we did not
>> + * check relationship with data center and storage domain.*/
>> +if (data_center == NULL) {
>> +g_debug("Could not get data center info, considering storage domain 
>> is attached to it");
>> +return TRUE;
>> +}
>> +
>>  g_object_get(domain, "data-center-ids", _center_ids, NULL);
>>  g_object_get(data_center, "guid", _center_guid, NULL);
>>  match = g_strv_contains((const gchar * const *) data_center_ids, 
>> data_center_guid);
>> @@ -743,9 +751,6 @@ static void data_center_fetched_cb(GObject 
>> *source_object,
>>  ovirt_resource_refresh_finish(resource, result, );
>>  if (error != NULL) {
>>  g_debug("failed to fetch Data Center: %s", error->message);
>> -g_task_return_error(task, error);
>> -g_object_unref(task);
>> -return;
> 
> I don't think the hunk just above
> (storage_domain_attached_to_data_center) takes this situation into
> account, menu->priv->data_center is non-null, but it will be 'empty', so
> storage_domain_attached_to_data_center is probably not going to do the
> right thing.

This callback function is only called if the previous condition tested
in the hunk below (function ovirt_foreign menu_fetch_data_center_async)
is valid.

> 
>>  }
>>  
>>  ovirt_foreign_menu_next_async_step(menu, task, STATE_DATA_CENTER);
>> @@ -760,6 +765,12 @@ static void 
>> ovirt_foreign_menu_fetch_data_center_async(OvirtForeignMenu *menu,
>>  g_return_if_fail(OVIRT_IS_CLUSTER(menu->priv->cluster));
>>  
>>  menu->priv->data_center = 
>> ovirt_cluster_get_data_center(menu->priv->cluster);
>> +
>> +if (menu->priv->data_center == NULL) {
>> +ovirt_foreign_menu_next_async_step(menu, task, STATE_DATA_CENTER);
>> +return;
>> +}
>> +
>>  ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->priv->data_center),
>>   menu->priv->proxy,
>>   g_task_get_cancellable(task),
>> @@ -780,9 +791,6 @@ static void cluster_fetched_cb(GObject *source_object,
>>  ovirt_resource_refresh_finish(resource, result, );
>>  if (error != NULL) {
>>  g_debug("failed to fetch Cluster: %s", error->message);
>> -g_task_return_error(task, error);
>> -g_object_unref(task);
>> -return;
>>  }
>>  
>>  ovirt_foreign_menu_next_async_step(menu, task, STATE_CLUSTER);
>> @@ -794,9 +802,14 @@ static void 
>> ovirt_foreign_menu_fetch_cluster_async(OvirtForeignMenu *menu,
>>  {
>>  g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
>>  g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
>> -g_return_if_fail(OVIRT_IS_HOST(menu->priv->host));
>> +g_return_if_fail(OVIRT_IS_VM(menu->priv->vm));
> 
> Maybe keep these 2, but in the right block in the if (menu->priv->host
> == NULL) below?
> 

Fixed.

@@ -801,9 +810,16 @@ static void

[virt-tools-list] [PATCH virt-viewer v2] Add missing G_MODULE_EXPORT to signal handler

2019-01-18 Thread Eduardo Lima (Etrunko)
Fixes the Windows case where the dialog fails to show with the following
message:

warning: "Could not find signal handler 
'virt_viewer_window_menu_change_cd_activate'"

Signed-off-by: Eduardo Lima (Etrunko) 
---

in v2:
 - Apply similar fix to handlers in remote-viewer-iso-list-dialog.c

---
 src/remote-viewer-iso-list-dialog.c | 4 ++--
 src/virt-viewer-window.c| 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/remote-viewer-iso-list-dialog.c 
b/src/remote-viewer-iso-list-dialog.c
index 745768a..3505211 100644
--- a/src/remote-viewer-iso-list-dialog.c
+++ b/src/remote-viewer-iso-list-dialog.c
@@ -216,7 +216,7 @@ remote_viewer_iso_list_dialog_response(GtkDialog *dialog,
 remote_viewer_iso_list_dialog_refresh_iso_list(self);
 }
 
-void
+G_MODULE_EXPORT void
 remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle *cell_renderer 
G_GNUC_UNUSED,
   gchar *path,
   gpointer user_data)
@@ -247,7 +247,7 @@ remote_viewer_iso_list_dialog_toggled(GtkCellRendererToggle 
*cell_renderer G_GNU
 g_free(name);
 }
 
-void
+G_MODULE_EXPORT void
 remote_viewer_iso_list_dialog_row_activated(GtkTreeView *view G_GNUC_UNUSED,
 GtkTreePath *path,
 GtkTreeViewColumn *col 
G_GNUC_UNUSED,
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 9b8e409..a7b2deb 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -1211,7 +1211,7 @@ iso_dialog_response(GtkDialog *dialog,
 }
 #endif
 
-void
+G_MODULE_EXPORT void
 virt_viewer_window_menu_change_cd_activate(GtkWidget *menu G_GNUC_UNUSED,
VirtViewerWindow *self 
G_GNUC_UNUSED)
 {
-- 
2.20.1

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer] Add missing G_MODULE_EXPORT to signal handler

2019-01-18 Thread Eduardo Lima (Etrunko)
On 1/18/19 5:30 PM, Marc-André Lureau wrote:
> On Fri, Jan 18, 2019 at 6:58 PM Eduardo Lima (Etrunko)
>  wrote:
>>
>> Fixes the Windows case where the dialog fails to show with the following
>> message:
>>
>> warning: "Could not find signal handler 
>> 'virt_viewer_window_menu_change_cd_activate'"
>>
>> Signed-off-by: Eduardo Lima (Etrunko) 
> 
> ack

There are couple of other places where this is missing as well, I will
send a follow up.

> 
>> ---
>>  src/virt-viewer-window.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
>> index 2be230a..b2f29a3 100644
>> --- a/src/virt-viewer-window.c
>> +++ b/src/virt-viewer-window.c
>> @@ -1131,7 +1131,7 @@ iso_dialog_response(GtkDialog *dialog,
>>  }
>>  #endif
>>
>> -void
>> +G_MODULE_EXPORT void
>>  virt_viewer_window_menu_change_cd_activate(GtkWidget *menu G_GNUC_UNUSED,
>> VirtViewerWindow *self 
>> G_GNUC_UNUSED)
>>  {
>> --
>> 2.20.1
>>
>> ___
>> virt-tools-list mailing list
>> virt-tools-list@redhat.com
>> https://www.redhat.com/mailman/listinfo/virt-tools-list


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

[virt-tools-list] [PATCH virt-viewer] Add missing G_MODULE_EXPORT to signal handler

2019-01-18 Thread Eduardo Lima (Etrunko)
Fixes the Windows case where the dialog fails to show with the following
message:

warning: "Could not find signal handler 
'virt_viewer_window_menu_change_cd_activate'"

Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/virt-viewer-window.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 2be230a..b2f29a3 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -1131,7 +1131,7 @@ iso_dialog_response(GtkDialog *dialog,
 }
 #endif
 
-void
+G_MODULE_EXPORT void
 virt_viewer_window_menu_change_cd_activate(GtkWidget *menu G_GNUC_UNUSED,
VirtViewerWindow *self 
G_GNUC_UNUSED)
 {
-- 
2.20.1

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [virt-viewer] ovirt: Fix initial connection

2018-12-06 Thread Eduardo Lima (Etrunko)
On 12/6/18 10:41 AM, Christophe Fergeau wrote:
> After commit df42f78d46 "remote-viewer: factor our
> remote_viewer_initial_connect()", the initial connection code only gets
> run in the !ovirt case. When ovirt is in use, the initial connection
> never happens, meaning all we get when using ovirt:// is a blank
> virt-viewer window.
> 
> This commit fixes that by moving creation of the ovirt session to
> remote_viewer_initial_connect, and unconditionnally calling the
> remote_viewer_initial_connect rather than only doing it in the !ovirt
> case.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1655537
> 
> Signed-off-by: Christophe Fergeau 
> ---
>  src/remote-viewer.c | 29 ++---
>  1 file changed, 14 insertions(+), 15 deletions(-)
> 
> diff --git a/src/remote-viewer.c b/src/remote-viewer.c
> index 4e1021b..989466b 100644
> --- a/src/remote-viewer.c
> +++ b/src/remote-viewer.c
> @@ -684,9 +684,18 @@ remote_viewer_initial_connect(RemoteViewer *self, const 
> gchar *type, const gchar
>  {
>  VirtViewerApp *app = VIRT_VIEWER_APP(self);
>  
> -if (!virt_viewer_app_create_session(app, type, error))
> -return FALSE;
> -
> +#ifdef HAVE_OVIRT
> +if (g_strcmp0(type, "ovirt") == 0) {
> +if (!create_ovirt_session(app, guri, error)) {
> +g_prefix_error(error, _("Couldn't open oVirt session: "));
> +return FALSE;
> +}
> +} else
> +#endif
> +{
> +if (!virt_viewer_app_create_session(app, type, error))
> +return FALSE;
> +}
>  
>  g_signal_connect(virt_viewer_app_get_session(app), "session-connected",
>   G_CALLBACK(remote_viewer_session_connected), 
> g_strdup(guri));
> @@ -782,18 +791,8 @@ retry_dialog:
>  _("Cannot determine the connection type from 
> URI"));
>  goto cleanup;
>  }
> -#ifdef HAVE_OVIRT
> -if (g_strcmp0(type, "ovirt") == 0) {
> -if (!create_ovirt_session(app, guri, )) {
> -g_prefix_error(, _("Couldn't open oVirt session: "));
> -goto cleanup;
> -}
> -} else
> -#endif
> -{
> -if (!remote_viewer_initial_connect(self, type, guri, vvfile, 
> ))
> -        goto cleanup;
> -}
> +if (!remote_viewer_initial_connect(self, type, guri, vvfile, ))
> +goto cleanup;
>  }
>  
>  ret = VIRT_VIEWER_APP_CLASS(remote_viewer_parent_class)->start(app, 
> );
> 
Acked-by: Eduardo Lima (Etrunko) 

-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer] Silence coverity warning about dead code

2018-12-04 Thread Eduardo Lima (Etrunko)
On 12/4/18 2:42 PM, Jonathon Jongsma wrote:
> For some reason, coverity was complaining that the definition of
> cred_type_to_str was dead code, even though it wasn't. Changing the
> storage to static silences the warning. Since that's a benficial change
> anyway, let's change it. At the same time, make the pointer constant as
> well and move it outside of the loop since it doesn't need to be inside
> the loop.
> 
> Signed-off-by: Jonathon Jongsma 
> ---
>  src/virt-viewer.c | 11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/src/virt-viewer.c b/src/virt-viewer.c
> index 5c321db..86d0c75 100644
> --- a/src/virt-viewer.c
> +++ b/src/virt-viewer.c
> @@ -1002,12 +1002,13 @@ 
> virt_viewer_auth_libvirt_credentials(virConnectCredentialPtr cred,
>  }
>  }
>  
> +static const char * const cred_type_to_str[] = {
> +[VIR_CRED_USERNAME] = "Identity to act as",
> +[VIR_CRED_AUTHNAME] = "Identify to authorize as",
> +[VIR_CRED_PASSPHRASE] = "Passphrase secret",
> +};
> +
>  for (i = 0 ; i < ncred ; i++) {
> -const char *cred_type_to_str[] = {
> -[VIR_CRED_USERNAME] = "Identity to act as",
> -[VIR_CRED_AUTHNAME] = "Identify to authorize as",
> -[VIR_CRED_PASSPHRASE] = "Passphrase secret",
> -};
>  switch (cred[i].type) {
>  case VIR_CRED_AUTHNAME:
>  case VIR_CRED_USERNAME:
> 
Acked-by: Eduardo Lima (Etrunko) 

-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer] Relax Gtk+ requirement slightly

2018-11-06 Thread Eduardo Lima (Etrunko)
On 11/6/18 2:18 PM, Jonathon Jongsma wrote:
> We previously bumped the gtk+ requirement to 3.18 for the function
> gtk_window_fullscreen_on_monitor(). But this function is only necessary
> in Wayland. So add some preprocessor version checks to allow it to
> compile on older distributions if they don't care about wayland support.
> ---
>  configure.ac | 4 ++--
>  src/virt-viewer-window.c | 4 
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 55aa2fa..bfbf27d 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -17,8 +17,8 @@ GLIB2_REQUIRED="2.40"
>  GLIB2_ENCODED_VERSION="GLIB_VERSION_2_40"
>  
>  # Keep these two definitions in agreement.
> -GTK_REQUIRED="3.18"
> -GTK_ENCODED_VERSION="GDK_VERSION_3_18"
> +GTK_REQUIRED="3.12"
> +GTK_ENCODED_VERSION="GDK_VERSION_3_12"
>  
>  LIBXML2_REQUIRED="2.6.0"
>  LIBVIRT_REQUIRED="0.10.0"
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index aace0f8..8e2589d 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -525,6 +525,7 @@ virt_viewer_window_enter_fullscreen(VirtViewerWindow 
> *self, gint monitor)
>  }
>  virt_viewer_window_move_to_monitor(self);
>  
> +#if GTK_CHECK_VERSION(3, 18, 0)
>  if (monitor == -1) {
>  // just go fullscreen on the current monitor
>  gtk_window_fullscreen(GTK_WINDOW(priv->window));
> @@ -532,6 +533,9 @@ virt_viewer_window_enter_fullscreen(VirtViewerWindow 
> *self, gint monitor)
>  gtk_window_fullscreen_on_monitor(GTK_WINDOW(priv->window),
>       gdk_screen_get_default(), monitor);
>  }
> +#else
> +gtk_window_fullscreen(GTK_WINDOW(priv->window));
> +#endif /* GTK_CHECK_VERSION */
>  }
>  
>  #define MAX_KEY_COMBO 4
> 
Acked-by: Eduardo Lima (Etrunko) 

-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer 0/2] Initial support for building with meson/ninja

2018-10-04 Thread Eduardo Lima (Etrunko)
On 10/4/18 9:41 AM, Eduardo Lima (Etrunko) wrote:
> On 10/4/18 7:48 AM, Daniel P. Berrangé wrote:
>> On Wed, Sep 12, 2018 at 11:07:57AM +0200, Eduardo Lima (Etrunko) wrote:
>>> The first patch is a preparation for the new build system. As it uses
>>> a built in function provided by meson for generating the enum files, it
>>> is not possible to run sed on the resulting file, so we need to keep it
>>> as is.
>>>
>>> As for the build itself, the only missing features are windows related,
>>> which I don't really know how to implement, but should not be difficult.
>>
>> IIUC, this series adds meson support, but leaves the autotools
>> support unchanged.
>>
> 
> Correct.
> 
>> I really don't like the idea of maintaining 2 build systems at
>> the same time. It will inevitably lead to obscure bugs that depend
>> on which build system is used. We've already suffered from this with
>> GTK itself supporting both and their developers & CI only ever testing
>> meson leading autotools to break.
>>
> 
> In SPICE we added meson support as a "unofficial", because there are
> still some unresolved issues in meson when it comes to distribution of
> source tarballs with generated files. The plan is to switch by the
> moment those are fixed.
> 
>> I'm a big fan of meson so I think we should simply do a straight
>> switch. The main question is when, and that's largely determined
>> by what platforms we care about.
>>
>>
> 
> It is easy enough to remove the autotools support, but I would first
> make sure meson will cover all the use cases, especially things that are
> done when autobuild.sh is run, and windows build, which this series
> don't cover.
> 

And btw, my github repository has the patches if someone may find it
easier to add the remote (branch is meson).

https://github.com/etrunko/virt-viewer.git

-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

Re: [virt-tools-list] [PATCH virt-viewer 0/2] Initial support for building with meson/ninja

2018-10-04 Thread Eduardo Lima (Etrunko)
On 10/4/18 7:48 AM, Daniel P. Berrangé wrote:
> On Wed, Sep 12, 2018 at 11:07:57AM +0200, Eduardo Lima (Etrunko) wrote:
>> The first patch is a preparation for the new build system. As it uses
>> a built in function provided by meson for generating the enum files, it
>> is not possible to run sed on the resulting file, so we need to keep it
>> as is.
>>
>> As for the build itself, the only missing features are windows related,
>> which I don't really know how to implement, but should not be difficult.
> 
> IIUC, this series adds meson support, but leaves the autotools
> support unchanged.
> 

Correct.

> I really don't like the idea of maintaining 2 build systems at
> the same time. It will inevitably lead to obscure bugs that depend
> on which build system is used. We've already suffered from this with
> GTK itself supporting both and their developers & CI only ever testing
> meson leading autotools to break.
> 

In SPICE we added meson support as a "unofficial", because there are
still some unresolved issues in meson when it comes to distribution of
source tarballs with generated files. The plan is to switch by the
moment those are fixed.

> I'm a big fan of meson so I think we should simply do a straight
> switch. The main question is when, and that's largely determined
> by what platforms we care about.
> 
> 

It is easy enough to remove the autotools support, but I would first
make sure meson will cover all the use cases, especially things that are
done when autobuild.sh is run, and windows build, which this series
don't cover.

-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

[virt-tools-list] [PATCH virt-viewer v2] Add support for building with meson/ninja

2018-09-28 Thread Eduardo Lima (Etrunko)
Signed-off-by: Eduardo Lima (Etrunko) 
---

In v2:

 - Add meson.build files to EXTRA_DIST
 - Fix typo meson meson_vesrion -> meson_version
 - Minimal cleanups

---
 Makefile.am   |   3 +
 data/Makefile.am  |   1 +
 data/meson.build  |  16 
 icons/Makefile.am |   2 +
 icons/meson.build |  14 
 man/Makefile.am   |   1 +
 man/meson.build   |  16 
 meson.build   | 203 ++
 meson_options.txt |  25 ++
 po/meson.build|   2 +
 src/Makefile.am   |   1 +
 src/meson.build   | 116 ++
 tests/Makefile.am |   2 +
 tests/meson.build |  16 
 14 files changed, 418 insertions(+)
 create mode 100644 data/meson.build
 create mode 100644 icons/meson.build
 create mode 100644 man/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 po/meson.build
 create mode 100644 src/meson.build
 create mode 100644 tests/meson.build

diff --git a/Makefile.am b/Makefile.am
index d33367a..dcbe49b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,9 @@ EXTRA_DIST =  \
build-aux/vc-list-files \
AUTHORS.in  \
README.md   \
+   meson.build \
+   meson_options.txt   \
+   po/meson.build  \
$(NULL)
 
 DISTCLEAN_FILES =  \
diff --git a/data/Makefile.am b/data/Makefile.am
index 54be2b1..afc3be8 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -4,6 +4,7 @@ MANUFACTURER = Virt Manager Project
 
 EXTRA_DIST =   \
virt-viewer.wxs.in  \
+   meson.build \
$(NULL)
 
 # this make sure those files are regenerated when they change
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 000..f57e751
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,16 @@
+intltool = find_program('intltool-merge')
+podir = join_paths(meson.source_root(), 'po')
+
+targets = {'remote-viewer.desktop' : 'applications',
+   'remote-viewer.appdata.xml' : 'appdata',
+   'virt-viewer-mime.xml' : 'mime/packages'}
+
+foreach target, dir : targets
+  style = target.split('.')[-1]
+  custom_target(target,
+input : '@0@.in'.format(target),
+output : target,
+command : [intltool, '--@0@-style'.format(style), podir, 
'@INPUT@', '@OUTPUT@'],
+install : true,
+install_dir : join_paths(virt_viewer_datadir, dir))
+endforeach
diff --git a/icons/Makefile.am b/icons/Makefile.am
index 0b4c247..978a0c0 100644
--- a/icons/Makefile.am
+++ b/icons/Makefile.am
@@ -10,4 +10,6 @@ ico_sizes = 16 32 48 256
 %.ico: $(foreach s,$(ico_sizes),$(s)x$(s)/%.png)
$(AM_V_GEN)$(ICOTOOL) -c -o $@ $^
 
+EXTRA_DIST = meson.build
+
 -include $(top_srcdir)/git.mk
diff --git a/icons/meson.build b/icons/meson.build
new file mode 100644
index 000..8a7741f
--- /dev/null
+++ b/icons/meson.build
@@ -0,0 +1,14 @@
+dirs = [
+  '16x16',
+  '22x22',
+  '24x24',
+  '32x32',
+  '48x48',
+  '256x256'
+]
+
+foreach d : dirs
+  file = files('@0@/virt-viewer.png'.format(d))
+  dir = join_paths(virt_viewer_datadir, 'icons', 'hicolor', d, 'apps')
+  install_data(file, install_dir : dir)
+endforeach
diff --git a/man/Makefile.am b/man/Makefile.am
index 39b6019..7db1b20 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -8,6 +8,7 @@ dist_man_MANS = \
 EXTRA_DIST =   \
remote-viewer.pod   \
virt-viewer.pod \
+   meson.build \
$(NULL)
 
 MAINTAINERCLEANFILES = $(dist_man_MANS)
diff --git a/man/meson.build b/man/meson.build
new file mode 100644
index 000..9d79bd0
--- /dev/null
+++ b/man/meson.build
@@ -0,0 +1,16 @@
+pod2man = find_program('pod2man')
+manuals = ['remote-viewer', 'virt-viewer']
+
+if pod2man.found()
+  foreach m : manuals
+  man = '@0@.1'.format(m)
+  pod = '@0@.pod'.format(m)
+  custom_target(man,
+output : man,
+input : pod,
+install : true,
+install_dir : join_paths(virt_viewer_datadir, 'man', 
'man1'),
+build_by_default : true,
+command : [pod2man, '-c', 'Virtualization Support', 
'@INPUT@', '@OUTPUT@'])
+  endforeach
+endif
diff --git a/meson.build b/meson.build
new file mode 100644
index 000..578a3d3
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,203 @@
+project('virt-viewer', 'c',
+version : '8.0',
+license : 'GPLv2',
+meson_version : '>= 0.47.0')
+
+#
+# globals
+#
+virt_viewer_deps = []
+virt_viewer_include = [include_directories('.')]
+virt_viewer_confi

Re: [virt-tools-list] [PATCH virt-viewer] fixup! Typo: meson_vesrion -> meson_version

2018-09-14 Thread Eduardo Lima (Etrunko)
On 09/14/2018 09:47 AM, Eduardo Lima (Etrunko) wrote:
> ---
>  meson.build   | 2 +-
>  subprojects/spice-single.wrap | 4 
>  2 files changed, 5 insertions(+), 1 deletion(-)
>  create mode 100644 subprojects/spice-single.wrap
> 
> diff --git a/meson.build b/meson.build
> index 4c6729d..3b7ed7e 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1,7 +1,7 @@
>  project('virt-viewer', 'c',
>  version : '8.0',
>  license : 'GPLv2',
> -meson_vesrion : '>= 0.47.0')
> +meson_version : '>= 0.47.0')
>  
>  #
>  # globals


Please disregard the hunk below, it was commited by mistake.

> diff --git a/subprojects/spice-single.wrap b/subprojects/spice-single.wrap
> new file mode 100644
> index 000..48704b7
> --- /dev/null
> +++ b/subprojects/spice-single.wrap
> @@ -0,0 +1,4 @@
> +[wrap-git]
> +directory=spice-single
> +url=https://gitlab.freedesktop.org/etrunko/spice-single.git
> +revision=master
> 


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer] fixup! Typo: meson_vesrion -> meson_version

2018-09-14 Thread Eduardo Lima (Etrunko)
---
 meson.build   | 2 +-
 subprojects/spice-single.wrap | 4 
 2 files changed, 5 insertions(+), 1 deletion(-)
 create mode 100644 subprojects/spice-single.wrap

diff --git a/meson.build b/meson.build
index 4c6729d..3b7ed7e 100644
--- a/meson.build
+++ b/meson.build
@@ -1,7 +1,7 @@
 project('virt-viewer', 'c',
 version : '8.0',
 license : 'GPLv2',
-meson_vesrion : '>= 0.47.0')
+meson_version : '>= 0.47.0')
 
 #
 # globals
diff --git a/subprojects/spice-single.wrap b/subprojects/spice-single.wrap
new file mode 100644
index 000..48704b7
--- /dev/null
+++ b/subprojects/spice-single.wrap
@@ -0,0 +1,4 @@
+[wrap-git]
+directory=spice-single
+url=https://gitlab.freedesktop.org/etrunko/spice-single.git
+revision=master
-- 
2.17.1

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer 0/2] Initial support for building with meson/ninja

2018-09-12 Thread Eduardo Lima (Etrunko)
The first patch is a preparation for the new build system. As it uses
a built in function provided by meson for generating the enum files, it
is not possible to run sed on the resulting file, so we need to keep it
as is.

As for the build itself, the only missing features are windows related,
which I don't really know how to implement, but should not be difficult.

Eduardo Lima (Etrunko) (2):
  build: Keep original type name as generated from glib-mkenums
  Add support for building with meson/ninja

 data/meson.build  |  16 +++
 icons/meson.build |  14 +++
 man/meson.build   |  16 +++
 meson.build   | 206 ++
 meson_options.txt |  25 +
 po/meson.build|   2 +
 src/Makefile.am   |   4 +-
 src/meson.build   | 116 +
 src/virt-viewer-display.c |   2 +-
 tests/meson.build |  16 +++
 10 files changed, 414 insertions(+), 3 deletions(-)
 create mode 100644 data/meson.build
 create mode 100644 icons/meson.build
 create mode 100644 man/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 po/meson.build
 create mode 100644 src/meson.build
 create mode 100644 tests/meson.build

-- 
2.17.1

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer 2/2] Add support for building with meson/ninja

2018-09-12 Thread Eduardo Lima (Etrunko)
Signed-off-by: Eduardo Lima (Etrunko) 
---
 data/meson.build  |  16 
 icons/meson.build |  14 
 man/meson.build   |  16 
 meson.build   | 206 ++
 meson_options.txt |  25 ++
 po/meson.build|   2 +
 src/meson.build   | 116 ++
 tests/meson.build |  16 
 8 files changed, 411 insertions(+)
 create mode 100644 data/meson.build
 create mode 100644 icons/meson.build
 create mode 100644 man/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 po/meson.build
 create mode 100644 src/meson.build
 create mode 100644 tests/meson.build

diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 000..f57e751
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,16 @@
+intltool = find_program('intltool-merge')
+podir = join_paths(meson.source_root(), 'po')
+
+targets = {'remote-viewer.desktop' : 'applications',
+   'remote-viewer.appdata.xml' : 'appdata',
+   'virt-viewer-mime.xml' : 'mime/packages'}
+
+foreach target, dir : targets
+  style = target.split('.')[-1]
+  custom_target(target,
+input : '@0@.in'.format(target),
+output : target,
+command : [intltool, '--@0@-style'.format(style), podir, 
'@INPUT@', '@OUTPUT@'],
+install : true,
+install_dir : join_paths(virt_viewer_datadir, dir))
+endforeach
diff --git a/icons/meson.build b/icons/meson.build
new file mode 100644
index 000..8a7741f
--- /dev/null
+++ b/icons/meson.build
@@ -0,0 +1,14 @@
+dirs = [
+  '16x16',
+  '22x22',
+  '24x24',
+  '32x32',
+  '48x48',
+  '256x256'
+]
+
+foreach d : dirs
+  file = files('@0@/virt-viewer.png'.format(d))
+  dir = join_paths(virt_viewer_datadir, 'icons', 'hicolor', d, 'apps')
+  install_data(file, install_dir : dir)
+endforeach
diff --git a/man/meson.build b/man/meson.build
new file mode 100644
index 000..9d79bd0
--- /dev/null
+++ b/man/meson.build
@@ -0,0 +1,16 @@
+pod2man = find_program('pod2man')
+manuals = ['remote-viewer', 'virt-viewer']
+
+if pod2man.found()
+  foreach m : manuals
+  man = '@0@.1'.format(m)
+  pod = '@0@.pod'.format(m)
+  custom_target(man,
+output : man,
+input : pod,
+install : true,
+install_dir : join_paths(virt_viewer_datadir, 'man', 
'man1'),
+build_by_default : true,
+command : [pod2man, '-c', 'Virtualization Support', 
'@INPUT@', '@OUTPUT@'])
+  endforeach
+endif
diff --git a/meson.build b/meson.build
new file mode 100644
index 000..4c6729d
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,206 @@
+project('virt-viewer', 'c',
+version : '8.0',
+license : 'GPLv2',
+meson_vesrion : '>= 0.47.0')
+
+#
+# globals
+#
+virt_viewer_deps = []
+virt_viewer_include = [include_directories('.')]
+virt_viewer_config_data = configuration_data()
+virt_viewer_package_name = meson.project_name()
+virt_viewer_version = meson.project_version()
+virt_viewer_datadir = join_paths(get_option('prefix'), get_option('datadir'))
+virt_viewer_localedir = join_paths(virt_viewer_datadir, 'locale')
+
+virt_viewer_cflags = ['-DG_LOG_DOMAIN="@0@"'.format(virt_viewer_package_name),
+  '-Wall',
+  '-Wmissing-prototypes',
+  '-std=c99',
+  '-Wnested-externs',
+  '-Wpointer-arith',
+  '-Wextra',
+  '-Wshadow',
+  '-Wcast-align',
+  '-Wwrite-strings',
+  '-Waggregate-return',
+  '-Winline',
+  '-Wredundant-decls',
+  '-Wdeprecated-declarations',
+  '-Wno-sign-compare',
+  '-Wno-cast-function-type',
+  '-Werror']
+
+compiler = meson.get_compiler('c')
+
+# dependency versions
+glib2_version='2.38'
+glib2_major_minor = glib2_version.split('.')
+glib2_required = '>= @0@'.format(glib2_version)
+glib2_encoded_version='GLIB_VERSION_@0@_@1@'.format(glib2_major_minor[0], 
glib2_major_minor[1])
+
+gtk_version='3.12'
+gtk_major_minor = gtk_version.split('.')
+gtk_required = '>= @0@'.format(gtk_version)
+gtk_encoded_version='GDK_VERSION_@0@_@1@'.format(gtk_major_minor[0], 
gtk_major_minor[1])
+
+libxml2_required='>= 2.6.0'
+libvirt_required='>= 0.10.0'
+libvirt_glib_required='>= 0.1.8'
+gtk_vnc_required='>= 0.4.0'
+spice_gtk_required='>= 0.35'
+spice_protocol_required='>= 0.12.7'
+govirt_required='>= 0.3.3'
+rest_required='>= 0.8'
+
+#
+# check system headers
+#
+headers = ['sys/socket.h', 'sys/un.h', 'windows.h']
+foreach header : headers
+  if compiler.has_header(header)
+
virt_viewer_config_data.set('HAVE_@0@'.format(header.underscorify().to_upper()),
 '1')
+  endif

[virt-tools-list] [PATCH virt-viewer 1/2] build: Keep original type name as generated from glib-mkenums

2018-09-12 Thread Eduardo Lima (Etrunko)
Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/Makefile.am   | 4 ++--
 src/virt-viewer-display.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 0a3cbbf..0472908 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -40,8 +40,8 @@ virt-viewer-resources.c virt-viewer-resources.h: 
resources/virt-viewer.gresource
 
 virt-viewer-enums.c virt-viewer-enums.h: %: %.etemplate $(ENUMS_FILES)
$(AM_V_GEN)LC_ALL= LANG=C LC_CTYPE=en_US.UTF-8 $(GLIB_MKENUMS) 
--template $^ | \
-sed -e 's/VIRT_TYPE_VIEWER/VIRT_VIEWER_TYPE/' \
--e 's,#include "$(srcdir)/,#include ",' > $@
+sed -e 's,#include "$(srcdir)/,#include ",' > $@
+
 
 CLEANFILES = \
$(BUILT_SOURCES)\
diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index 2dbaba1..d6f29d1 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -140,7 +140,7 @@ virt_viewer_display_class_init(VirtViewerDisplayClass 
*class)
 g_param_spec_flags("show-hint",
"Show hint",
"Show state hint",
-   
VIRT_VIEWER_TYPE_DISPLAY_SHOW_HINT_FLAGS,
+   
VIRT_TYPE_VIEWER_DISPLAY_SHOW_HINT_FLAGS, /* from generated file 
virt-viewer-enums.h */
0,
G_PARAM_READABLE));
 
-- 
2.17.1

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [virt-viewer] ovirt: Filter everything which does not end in .iso

2018-08-30 Thread Eduardo Lima (Etrunko)
On 08/28/2018 02:06 PM, Christophe Fergeau wrote:
> oVirt REST API does not provide a way to know what is a valid ISO image
> which can be assigned to a running VM. I've seen floppy disk images
> (.vfd) in a domain, which is already filtered. Now I've seen an ISO
> domain with .qcow2 files in it, which can't be assigned to a VM either.
> This commit filters every file which does not have a .iso extension as
> it's unlikely to be possible to use it.
> 
> Signed-off-by: Christophe Fergeau 

Acked-by: Eduardo Lima (Etrunko) 

> ---
>  src/ovirt-foreign-menu.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
> index f212861..69bf2b3 100644
> --- a/src/ovirt-foreign-menu.c
> +++ b/src/ovirt-foreign-menu.c
> @@ -489,7 +489,8 @@ static void ovirt_foreign_menu_set_files(OvirtForeignMenu 
> *menu,
>   * associated with file resources , but as of 3.2, this node
>   * is not present, so we do an extension check instead
>   * to differentiate between ISOs and floppy images */
> -if (g_str_has_suffix(name, ".vfd")) {
> +if (!g_str_has_suffix(name, ".iso")) {
> +g_debug("Ignoring %s which does not have a .iso extension", 
> name);
>  g_free(name);
>  continue;
>  }
> 

-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer 2/3] ovirt-foreign-menu: New function storage_domain_validate()

2018-07-06 Thread Eduardo Lima (Etrunko)
It may be useful to know why the storage domain has not been listed,
given that there are different reasons for that. To make it easier to
provide more detailed debug messages, we move code from the callback
function to this new one.

Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/ovirt-foreign-menu.c | 45 ++---
 1 file changed, 30 insertions(+), 15 deletions(-)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index cd1b8bd..70a0b50 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -640,6 +640,35 @@ static gboolean 
storage_domain_attached_to_data_center(OvirtStorageDomain *domai
 }
 #endif
 
+static gboolean storage_domain_validate(OvirtForeignMenu *menu,
+OvirtStorageDomain *domain)
+{
+char *name;
+int type, state;
+gboolean ret = TRUE;
+
+g_object_get(domain, "name", , "type", , "state", , NULL);
+
+if (type != OVIRT_STORAGE_DOMAIN_TYPE_ISO) {
+g_debug("Storage domain '%s' type is not ISO", name);
+ret = FALSE;
+}
+
+if (state != OVIRT_STORAGE_DOMAIN_STATE_ACTIVE) {
+g_debug("Storage domain '%s' state is not active", name);
+ret = FALSE;
+}
+
+#ifdef HAVE_OVIRT_DATA_CENTER
+if (!storage_domain_attached_to_data_center(domain, 
menu->priv->data_center)) {
+g_debug("Storage domain '%s' is not attached to data center", name);
+ret = FALSE;
+}
+#endif
+
+g_free(name);
+return ret;
+}
 
 static void storage_domains_fetched_cb(GObject *source_object,
GAsyncResult *result,
@@ -663,23 +692,9 @@ static void storage_domains_fetched_cb(GObject 
*source_object,
 g_hash_table_iter_init(, ovirt_collection_get_resources(collection));
 while (g_hash_table_iter_next(, NULL, (gpointer *))) {
 OvirtCollection *file_collection;
-int type;
-int state;
-
-g_object_get(domain, "type", , "state", , NULL);
-if (type != OVIRT_STORAGE_DOMAIN_TYPE_ISO) {
-continue;
-}
-
-if (state != OVIRT_STORAGE_DOMAIN_STATE_ACTIVE) {
-continue;
-}
 
-#ifdef HAVE_OVIRT_DATA_CENTER
-if (!storage_domain_attached_to_data_center(domain, 
menu->priv->data_center)) {
+if (!storage_domain_validate(menu, domain))
 continue;
-}
-#endif
 
 file_collection = ovirt_storage_domain_get_files(domain);
 if (file_collection != NULL) {
-- 
2.14.4

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer 1/3] build: Update govirt and rest requirements

2018-07-06 Thread Eduardo Lima (Etrunko)
With these new values, 0.3.3 for libgovirt and 0.8 for librest, we can
remove checks for OVIRT_REST_CALL_ERROR_CANCELLED and correspondent
rest_proxy_auth_cancel().

Signed-off-by: Eduardo Lima (Etrunko) 
---
 configure.ac| 11 ---
 src/remote-viewer.c |  4 
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/configure.ac b/configure.ac
index e262e31..8c334b5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,8 @@ LIBVIRT_GLIB_REQUIRED="0.1.8"
 GTK_VNC_REQUIRED="0.4.0"
 SPICE_GTK_REQUIRED="0.33"
 SPICE_PROTOCOL_REQUIRED="0.12.7"
-GOVIRT_REQUIRED="0.3.2"
+GOVIRT_REQUIRED="0.3.3"
+REST_REQUIRED="0.8"
 
 AC_SUBST([GLIB2_REQUIRED])
 AC_SUBST([LIBXML2_REQUIRED])
@@ -37,6 +38,7 @@ AC_SUBST([GTK_VNC_REQUIRED])
 AC_SUBST([SPICE_GTK_REQUIRED])
 AC_SUBST([SPICE_PROTOCOL_REQUIRED])
 AC_SUBST([GOVIRT_REQUIRED])
+AC_SUBST([REST_REQUIRED])
 
 AC_MSG_CHECKING([for native Win32])
 case "$host_os" in
@@ -178,17 +180,12 @@ AS_IF([test "x$with_ovirt" != "xno" && test 
"x$with_ovirt" != "xyes"],
 [with_ovirt=yes], [with_ovirt=no])])
 
 AS_IF([test "x$with_ovirt" = "xyes"],
-  [PKG_CHECK_MODULES([OVIRT], [govirt-1.0 >= $GOVIRT_REQUIRED])]
+  [PKG_CHECK_MODULES([OVIRT], [govirt-1.0 >= $GOVIRT_REQUIRED rest-0.7 >= 
REST_REQUIRED])]
   [AC_DEFINE([HAVE_OVIRT], 1, [Have libgovirt?])]
   [SAVED_CFLAGS="$CFLAGS"
SAVED_LIBS="$LIBS"
CFLAGS="$OVIRT_CFLAGS"
LIBS="$OVIRT_LIBS"
-   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]],
-[static int err = OVIRT_REST_CALL_ERROR_CANCELLED;
- void *fun = rest_proxy_auth_cancel;])],
-[AC_DEFINE([HAVE_OVIRT_CANCEL], 1, [Have rest_proxy_auth_cancel and 
OVIRT_REST_CALL_ERROR_CANCELLED?])],
-[])
AC_CHECK_FUNCS([ovirt_api_search_vms ovirt_vm_get_host 
ovirt_host_get_cluster ovirt_cluster_get_data_center],
   [AC_DEFINE([HAVE_OVIRT_DATA_CENTER], 1, [Have support 
for data center])],
   []
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index c52d20f..4e1021b 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -345,10 +345,8 @@ authenticate_cb(RestProxy *proxy, G_GNUC_UNUSED 
RestProxyAuth *auth,
  "username", username,
  "password", password,
  NULL);
-#ifdef HAVE_OVIRT_CANCEL
 } else {
 rest_proxy_auth_cancel(auth);
-#endif
 }
 
 g_free(username);
@@ -447,14 +445,12 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, 
GError **err)
 api = ovirt_proxy_fetch_api(proxy, );
 if (error != NULL) {
 g_debug("failed to get oVirt 'api' collection: %s", error->message);
-#ifdef HAVE_OVIRT_CANCEL
 if (g_error_matches(error, OVIRT_REST_CALL_ERROR, 
OVIRT_REST_CALL_ERROR_CANCELLED)) {
 g_clear_error();
 g_set_error_literal(,
 VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_CANCELLED,
 _("Authentication was cancelled"));
 }
-#endif
 goto error;
 }
 vms = ovirt_api_get_vms(api);
-- 
2.14.4

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer 3/3] ovirt-foreign-menu: Bypass errors from Host/Cluster/Data Center

2018-07-06 Thread Eduardo Lima (Etrunko)
When accessing ovirt as a regular user, it may happen that queries to
Hosts, Clusters and Data Centers return errors due to insufficient
permissions, while they will work fine if access is done by admin user.
In this case, we skip the errors and fallback to the old method.

Signed-off-by: Eduardo Lima (Etrunko) 
---
 src/ovirt-foreign-menu.c | 43 +++
 1 file changed, 31 insertions(+), 12 deletions(-)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 70a0b50..8ed08c9 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -624,12 +624,20 @@ static void 
ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu,
 
 #ifdef HAVE_OVIRT_DATA_CENTER
 static gboolean storage_domain_attached_to_data_center(OvirtStorageDomain 
*domain,
-  OvirtDataCenter 
*data_center)
+   OvirtDataCenter 
*data_center)
 {
 GStrv data_center_ids;
 char *data_center_guid;
 gboolean match;
 
+/* For some reason we did not get data center information, so just return
+ * TRUE as it will work like a fallback to old method, where we did not
+ * check relationship with data center and storage domain.*/
+if (data_center == NULL) {
+g_debug("Could not get data center info, considering storage domain is 
attached to it");
+return TRUE;
+}
+
 g_object_get(domain, "data-center-ids", _center_ids, NULL);
 g_object_get(data_center, "guid", _center_guid, NULL);
 match = g_strv_contains((const gchar * const *) data_center_ids, 
data_center_guid);
@@ -743,9 +751,6 @@ static void data_center_fetched_cb(GObject *source_object,
 ovirt_resource_refresh_finish(resource, result, );
 if (error != NULL) {
 g_debug("failed to fetch Data Center: %s", error->message);
-g_task_return_error(task, error);
-g_object_unref(task);
-return;
 }
 
 ovirt_foreign_menu_next_async_step(menu, task, STATE_DATA_CENTER);
@@ -760,6 +765,12 @@ static void 
ovirt_foreign_menu_fetch_data_center_async(OvirtForeignMenu *menu,
 g_return_if_fail(OVIRT_IS_CLUSTER(menu->priv->cluster));
 
 menu->priv->data_center = 
ovirt_cluster_get_data_center(menu->priv->cluster);
+
+if (menu->priv->data_center == NULL) {
+ovirt_foreign_menu_next_async_step(menu, task, STATE_DATA_CENTER);
+return;
+}
+
 ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->priv->data_center),
  menu->priv->proxy,
  g_task_get_cancellable(task),
@@ -780,9 +791,6 @@ static void cluster_fetched_cb(GObject *source_object,
 ovirt_resource_refresh_finish(resource, result, );
 if (error != NULL) {
 g_debug("failed to fetch Cluster: %s", error->message);
-g_task_return_error(task, error);
-g_object_unref(task);
-return;
 }
 
 ovirt_foreign_menu_next_async_step(menu, task, STATE_CLUSTER);
@@ -794,9 +802,14 @@ static void 
ovirt_foreign_menu_fetch_cluster_async(OvirtForeignMenu *menu,
 {
 g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
 g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
-g_return_if_fail(OVIRT_IS_HOST(menu->priv->host));
+g_return_if_fail(OVIRT_IS_VM(menu->priv->vm));
+
+/* If there is no host information, we get cluster from the VM */
+if (menu->priv->host == NULL)
+menu->priv->cluster = ovirt_vm_get_cluster(menu->priv->vm);
+else
+menu->priv->cluster = ovirt_host_get_cluster(menu->priv->host);
 
-menu->priv->cluster = ovirt_host_get_cluster(menu->priv->host);
 ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->priv->cluster),
  menu->priv->proxy,
  g_task_get_cancellable(task),
@@ -817,9 +830,6 @@ static void host_fetched_cb(GObject *source_object,
 ovirt_resource_refresh_finish(resource, result, );
 if (error != NULL) {
 g_debug("failed to fetch Host: %s", error->message);
-g_task_return_error(task, error);
-g_object_unref(task);
-return;
 }
 
 ovirt_foreign_menu_next_async_step(menu, task, STATE_HOST);
@@ -834,6 +844,15 @@ static void 
ovirt_foreign_menu_fetch_host_async(OvirtForeignMenu *menu,
 g_return_if_fail(OVIRT_IS_VM(menu->priv->vm));
 
 menu->priv->host = ovirt_vm_get_host(menu->priv->vm);
+
+/* In some cases the VM XML does not include host information, so we just
+ * skip to the next step
+ */
+if (menu->priv->host == NULL) {
+ovirt_foreign_menu_next_async_step(menu, task, STATE_HOST);
+return;
+}
+
 ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->p

Re: [virt-tools-list] [virt-viewer 2/4] spice: Stop using deprecated SpiceMainChannel API

2018-07-05 Thread Eduardo Lima (Etrunko)
On 29/06/18 05:12, Christophe Fergeau wrote:
> On Thu, Jun 28, 2018 at 05:09:48PM -0300, Eduardo Lima (Etrunko) wrote:
>> On 14/06/18 13:01, Christophe Fergeau wrote:
>>> spice_main_set_display and spice_main_set_display_enabled have been
>>> superseded by spice_main_channel_update_display and
>>> spice_main_channel_update_display_enabled
>>>
>>
>> May I ask the reasoning for keeping compatibility with older version
>> instead of simply replacing the calls with newer ones?
> 
> configure.ac only requires spice-gtk 0.33, and in general it makes
> life easier if you can upgrade spice-gtk and virt-viewer separately.
> In this case it's fairly easy to keep the compat, so we can as well do
> it.

Yeah, still not sure, but I have no real strong objections, so

Acked-by: Eduardo Lima (Etrunko) 
> 
> Christophe
> 
>>
>> Regards, Eduardo
>>
>>> Signed-off-by: Christophe Fergeau 
>>> ---
>>>  src/virt-viewer-display-spice.c |  7 ++-
>>>  src/virt-viewer-session-spice.c | 27 ++-
>>>  2 files changed, 24 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/src/virt-viewer-display-spice.c 
>>> b/src/virt-viewer-display-spice.c
>>> index a604230..6cec79f 100644
>>> --- a/src/virt-viewer-display-spice.c
>>> +++ b/src/virt-viewer-display-spice.c
>>> @@ -49,6 +49,11 @@ struct _VirtViewerDisplaySpicePrivate {
>>>  guint y;
>>>  };
>>>  
>>> +#if !SPICE_GTK_CHECK_VERSION(0, 34, 21)
>>> +#define spice_main_channel_update_display_enabled(channel, id, enabled, 
>>> update) \
>>> +spice_main_update_display_enabled((channel), (id), 
>>> (enabled), (update))
>>> +#endif
>>> +
>>>  #define VIRT_VIEWER_DISPLAY_SPICE_GET_PRIVATE(o) 
>>> (G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_DISPLAY_SPICE, 
>>> VirtViewerDisplaySpicePrivate))
>>>  
>>>  static void virt_viewer_display_spice_send_keys(VirtViewerDisplay *display,
>>> @@ -103,7 +108,7 @@ static void update_enabled(VirtViewerDisplay *self, 
>>> gboolean enabled, gboolean s
>>>  return;
>>>  
>>>  g_object_get(self, "nth-display", , NULL);
>>> -spice_main_update_display_enabled(main_channel, nth, enabled, send);
>>> +spice_main_channel_update_display_enabled(main_channel, nth, enabled, 
>>> send);
>>>  }
>>>  
>>>  static void
>>> diff --git a/src/virt-viewer-session-spice.c 
>>> b/src/virt-viewer-session-spice.c
>>> index f43ed65..526c637 100644
>>> --- a/src/virt-viewer-session-spice.c
>>> +++ b/src/virt-viewer-session-spice.c
>>> @@ -64,6 +64,14 @@ enum {
>>>  };
>>>  
>>>  
>>> +#if !SPICE_GTK_CHECK_VERSION(0, 34, 21)
>>> +#define spice_main_channel_update_display(channel, id, x, y, width, 
>>> height, update) \
>>> +spice_main_update_display((channel), (id), (x), (y), 
>>> (width), (height), (update))
>>> +#define spice_main_channel_update_display_enabled(channel, id, enabled, 
>>> update) \
>>> +spice_main_update_display_enabled((channel), (id), 
>>> (enabled), (update))
>>> +#define spice_main_channel_send_monitor_config 
>>> spice_main_send_monitor_config
>>> +#endif
>>> +
>>>  static void virt_viewer_session_spice_close(VirtViewerSession *session);
>>>  static gboolean virt_viewer_session_spice_open_fd(VirtViewerSession 
>>> *session, int fd);
>>>  static gboolean virt_viewer_session_spice_open_host(VirtViewerSession 
>>> *session, const gchar *host, const gchar *port, const gchar *tlsport);
>>> @@ -921,9 +929,9 @@ virt_viewer_session_spice_display_monitors(SpiceChannel 
>>> *channel,
>>>  !display_is_in_fullscreen_mode(self, 
>>> VIRT_VIEWER_DISPLAY(display))) {
>>>  g_debug("display %d should not be enabled, disabling",
>>>  
>>> virt_viewer_display_get_nth(VIRT_VIEWER_DISPLAY(display)) + 1);
>>> -
>>> spice_main_set_display_enabled(virt_viewer_session_spice_get_main_channel(self),
>>> -   
>>> virt_viewer_display_get_nth(VIRT_VIEWER_DISPLAY(display)),
>>> -   FALSE);
>>> +
>>> spice_main_channel_update_display_enabled(virt_viewer_session_spice_get_main_channel(self),
>>> +   

Re: [virt-tools-list] [virt-viewer v2] ovirt: Improve handling of g_strv_contains()

2018-06-29 Thread Eduardo Lima (Etrunko)


Acked-by: Eduardo Lima (Etrunko) 

On 29/06/18 05:13, Christophe Fergeau wrote:
> The ovirt code uses g_strv_contains() with fallback code in
> glib-compat.h when we are using a glib version where it's not available.
> However, when we use a glib version where g_strv_contains is available,
> we get a compilation warning since we are compiling GLIB_VERSION_MAX_ALLOWED
> set to 2.38.
> 
> This commit wraps both the compat code and the g_strv_contains() call in
> a strv_contains() helper where we can hide the magic needed to avoid
> deprecation warnings.
> 
> Signed-off-by: Christophe Fergeau 
> ---
>  src/ovirt-foreign-menu.c | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
> index cd1b8bd..f212861 100644
> --- a/src/ovirt-foreign-menu.c
> +++ b/src/ovirt-foreign-menu.c
> @@ -100,7 +100,6 @@ enum {
>  PROP_VM_GUID,
>  };
>  
> -
>  gchar *
>  ovirt_foreign_menu_get_current_iso_name(OvirtForeignMenu *foreign_menu)
>  {
> @@ -623,6 +622,13 @@ static void 
> ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu,
>  }
>  
>  #ifdef HAVE_OVIRT_DATA_CENTER
> +static gboolean strv_contains(const gchar * const *strv, const gchar *str)
> +{
> +G_GNUC_BEGIN_IGNORE_DEPRECATIONS
> +  return g_strv_contains (strv, str);
> +G_GNUC_END_IGNORE_DEPRECATIONS
> +}
> +
>  static gboolean storage_domain_attached_to_data_center(OvirtStorageDomain 
> *domain,
>OvirtDataCenter 
> *data_center)
>  {
> @@ -632,7 +638,7 @@ static gboolean 
> storage_domain_attached_to_data_center(OvirtStorageDomain *domai
>  
>  g_object_get(domain, "data-center-ids", _center_ids, NULL);
>  g_object_get(data_center, "guid", _center_guid, NULL);
> -match = g_strv_contains((const gchar * const *) data_center_ids, 
> data_center_guid);
> +match = strv_contains((const gchar * const *) data_center_ids, 
> data_center_guid);
>  g_strfreev(data_center_ids);
>  g_free(data_center_guid);
>  
> 


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [virt-viewer 2/4] spice: Stop using deprecated SpiceMainChannel API

2018-06-28 Thread Eduardo Lima (Etrunko)
On 14/06/18 13:01, Christophe Fergeau wrote:
> spice_main_set_display and spice_main_set_display_enabled have been
> superseded by spice_main_channel_update_display and
> spice_main_channel_update_display_enabled
> 

May I ask the reasoning for keeping compatibility with older version
instead of simply replacing the calls with newer ones?

Regards, Eduardo

> Signed-off-by: Christophe Fergeau 
> ---
>  src/virt-viewer-display-spice.c |  7 ++-
>  src/virt-viewer-session-spice.c | 27 ++-
>  2 files changed, 24 insertions(+), 10 deletions(-)
> 
> diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
> index a604230..6cec79f 100644
> --- a/src/virt-viewer-display-spice.c
> +++ b/src/virt-viewer-display-spice.c
> @@ -49,6 +49,11 @@ struct _VirtViewerDisplaySpicePrivate {
>  guint y;
>  };
>  
> +#if !SPICE_GTK_CHECK_VERSION(0, 34, 21)
> +#define spice_main_channel_update_display_enabled(channel, id, enabled, 
> update) \
> +spice_main_update_display_enabled((channel), (id), 
> (enabled), (update))
> +#endif
> +
>  #define VIRT_VIEWER_DISPLAY_SPICE_GET_PRIVATE(o) 
> (G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_DISPLAY_SPICE, 
> VirtViewerDisplaySpicePrivate))
>  
>  static void virt_viewer_display_spice_send_keys(VirtViewerDisplay *display,
> @@ -103,7 +108,7 @@ static void update_enabled(VirtViewerDisplay *self, 
> gboolean enabled, gboolean s
>  return;
>  
>  g_object_get(self, "nth-display", , NULL);
> -spice_main_update_display_enabled(main_channel, nth, enabled, send);
> +spice_main_channel_update_display_enabled(main_channel, nth, enabled, 
> send);
>  }
>  
>  static void
> diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
> index f43ed65..526c637 100644
> --- a/src/virt-viewer-session-spice.c
> +++ b/src/virt-viewer-session-spice.c
> @@ -64,6 +64,14 @@ enum {
>  };
>  
>  
> +#if !SPICE_GTK_CHECK_VERSION(0, 34, 21)
> +#define spice_main_channel_update_display(channel, id, x, y, width, height, 
> update) \
> +spice_main_update_display((channel), (id), (x), (y), 
> (width), (height), (update))
> +#define spice_main_channel_update_display_enabled(channel, id, enabled, 
> update) \
> +spice_main_update_display_enabled((channel), (id), 
> (enabled), (update))
> +#define spice_main_channel_send_monitor_config spice_main_send_monitor_config
> +#endif
> +
>  static void virt_viewer_session_spice_close(VirtViewerSession *session);
>  static gboolean virt_viewer_session_spice_open_fd(VirtViewerSession 
> *session, int fd);
>  static gboolean virt_viewer_session_spice_open_host(VirtViewerSession 
> *session, const gchar *host, const gchar *port, const gchar *tlsport);
> @@ -921,9 +929,9 @@ virt_viewer_session_spice_display_monitors(SpiceChannel 
> *channel,
>  !display_is_in_fullscreen_mode(self, 
> VIRT_VIEWER_DISPLAY(display))) {
>  g_debug("display %d should not be enabled, disabling",
>  
> virt_viewer_display_get_nth(VIRT_VIEWER_DISPLAY(display)) + 1);
> -
> spice_main_set_display_enabled(virt_viewer_session_spice_get_main_channel(self),
> -   
> virt_viewer_display_get_nth(VIRT_VIEWER_DISPLAY(display)),
> -   FALSE);
> +
> spice_main_channel_update_display_enabled(virt_viewer_session_spice_get_main_channel(self),
> +  
> virt_viewer_display_get_nth(VIRT_VIEWER_DISPLAY(display)),
> +  FALSE, TRUE);
>  disabled = TRUE;
>  }
>  
> @@ -1055,7 +1063,7 @@ 
> virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice *self)
>  return FALSE;
>  }
>  
> -spice_main_set_display_enabled(cmain, -1, FALSE);
> +spice_main_channel_update_display_enabled(cmain, -1, FALSE, TRUE);
>  
>  initial_displays = virt_viewer_app_get_initial_displays(app);
>  ndisplays = g_list_length(initial_displays);
> @@ -1079,15 +1087,15 @@ 
> virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice *self)
>  GdkRectangle *rect = value;
>  gint j = GPOINTER_TO_INT(key);
>  
> -spice_main_set_display(cmain, j, rect->x, rect->y, rect->width, 
> rect->height);
> -spice_main_set_display_enabled(cmain, j, TRUE);
> +spice_main_channel_update_display(cmain, j, rect->x, rect->y, 
> rect->width, rect->height, TRUE);
> +spice_main_channel_update_display_enabled(cmain, j, TRUE, TRUE);
>  g_debug("Set SPICE display %d to (%d,%d)-(%dx%d)",
>j, rect->x, rect->y, rect->width, rect->height);
>  }
>  g_list_free(initial_displays);
>  g_hash_table_unref(displays);
>  
> -spice_main_send_monitor_config(cmain);
> +spice_main_channel_send_monitor_config(cmain);
>  self->priv->did_auto_conf = 

Re: [virt-tools-list] [virt-viewer 4/4] ovirt: Improve handling of g_strv_contains()

2018-06-28 Thread Eduardo Lima (Etrunko)
On 14/06/18 13:01, Christophe Fergeau wrote:
> The ovirt code uses g_strv_contains() with fallback code in
> glib-compat.h when we are using a glib version where it's not available.
> However, when we use a glib version where g_strv_contains is available,
> we get a compilation warning since we are compiling GLIB_VERSION_MAX_ALLOWED
> set to 2.38.
> 
> This commit wraps both the compat code and the g_strv_contains() call in
> a strv_contains() helper where we can hide the magic needed in the 2
> cases to avoid compilation issues.
> 
> Signed-off-by: Christophe Fergeau 
> ---
>  src/Makefile.am  |  2 --
>  src/glib-compat.c| 35 ---
>  src/glib-compat.h| 39 ---
>  src/ovirt-foreign-menu.c | 22 --
>  4 files changed, 20 insertions(+), 78 deletions(-)
>  delete mode 100644 src/glib-compat.c
>  delete mode 100644 src/glib-compat.h
> 
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 0a3cbbf..f02fdb4 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -54,8 +54,6 @@ libvirt_viewer_util_la_SOURCES = \
>  
>  libvirt_viewer_la_SOURCES =  \
>   $(BUILT_SOURCES)\
> - glib-compat.h   \
> - glib-compat.c   \
>   virt-viewer-auth.h  \
>   virt-viewer-auth.c  \
>   virt-viewer-app.h   \
> diff --git a/src/glib-compat.c b/src/glib-compat.c
> deleted file mode 100644
> index 62ac87e..000
> --- a/src/glib-compat.c
> +++ /dev/null
> @@ -1,35 +0,0 @@
> -/*
> - * This library is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU Lesser General Public
> - * License as published by the Free Software Foundation; either
> - * version 2 of the License, or (at your option) any later version.
> - *
> - * This library is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with this library; if not, see 
> <http://www.gnu.org/licenses/>.
> - */
> -#include 
> -
> -#include "glib-compat.h"
> -
> -#if !GLIB_CHECK_VERSION(2,44,0)
> -gboolean
> -g_strv_contains (const gchar * const *strv,
> - const gchar *str)
> -{
> -  g_return_val_if_fail (strv != NULL, FALSE);
> -  g_return_val_if_fail (str != NULL, FALSE);
> -
> -  for (; *strv != NULL; strv++)
> -{
> -  if (g_str_equal (str, *strv))
> -return TRUE;
> -}
> -
> -  return FALSE;
> -}
> -#endif
> diff --git a/src/glib-compat.h b/src/glib-compat.h
> deleted file mode 100644
> index f1b43ae..000
> --- a/src/glib-compat.h
> +++ /dev/null
> @@ -1,39 +0,0 @@
> -/*
> - * Virt Viewer: A virtual machine console viewer
> - *
> - * Copyright (C) 2017 Red Hat, Inc.
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> - *
> - * Author: Eduardo Lima (Etrunko) 
> - */
> -
> -#include 
> -
> -#ifndef GLIB_COMPAT_H
> -#define GLIB_COMPAT_H 1
> -
> -#include 
> -
> -G_BEGIN_DECLS
> -
> -#if !GLIB_CHECK_VERSION(2,44,0)
> -gboolean  g_strv_contains  (const gchar * const *strv,
> -const gchar *str);
> -#endif
> -
> -G_END_DECLS
> -
> -#endif // GLIB_COMPAT_H
> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
> index cd1b8bd..8650d0c 100644
> --- a/src/ovirt-foreign-menu.c
> +++ b/src/ovirt-foreign-menu.c
> @@ -29,7 +29,6 @@
>  
>  #include "ovirt-foreign-menu.h"
>  #include "virt-viewer-ut

Re: [virt-tools-list] [virt-viewer 3/4] window: Adjust get_image_format() prototype

2018-06-28 Thread Eduardo Lima (Etrunko)
Acked-by: Eduardo Lima (Etrunko) 

On 14/06/18 13:01, Christophe Fergeau wrote:
> This adds an unused parameter, but lets us get rid of this new warning
> with gcc 8:
> 
> virt-viewer-window.c: In function 'get_image_format':
> virt-viewer-window.c:930:33: warning: cast between incompatible function 
> types from 'GHashTable * (*)(void)' {aka 'struct _GHashTable * (*)(void)'} to 
> 'void * (*)(void *)' [-Wcast-function-type]
>  g_once(_formats_once, (GThreadFunc)init_image_formats, NULL);
> 
> Signed-off-by: Christophe Fergeau 
> ---
>  src/virt-viewer-window.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index af3441f..2be230a 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -910,7 +910,7 @@ static void add_if_writable (GdkPixbufFormat *data, 
> GHashTable *formats)
>  }
>  }
>  
> -static GHashTable *init_image_formats(void)
> +static GHashTable *init_image_formats(G_GNUC_UNUSED gpointer user_data)
>  {
>  GHashTable *format_map;
>  GSList *formats = gdk_pixbuf_get_formats();
> 


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [virt-viewer 1/4] app: Remove VirtViewerApp::has-focus

2018-06-28 Thread Eduardo Lima (Etrunko)
Acked-by: Eduardo Lima (Etrunko) 

On 14/06/18 13:01, Christophe Fergeau wrote:
> This is no longer needed since 140cb84
> 'remote-viewer: remove --spice-controller'
> 
> Signed-off-by: Christophe Fergeau 
> ---
>  src/virt-viewer-app.c | 44 ---
>  1 file changed, 44 deletions(-)
> 
> diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
> index 2a2..cd0c7ad 100644
> --- a/src/virt-viewer-app.c
> +++ b/src/virt-viewer-app.c
> @@ -145,7 +145,6 @@ struct _VirtViewerAppPrivate {
>  char *title;
>  char *uuid;
>  
> -gint focused;
>  GKeyFile *config;
>  gchar *config_file;
>  
> @@ -170,7 +169,6 @@ enum {
>  PROP_FULLSCREEN,
>  PROP_TITLE,
>  PROP_ENABLE_ACCEL,
> -PROP_HAS_FOCUS,
>  PROP_KIOSK,
>  PROP_QUIT_ON_DISCONNECT,
>  PROP_UUID,
> @@ -818,33 +816,6 @@ viewer_window_visible_cb(GtkWidget *widget G_GNUC_UNUSED,
>  virt_viewer_app_update_menu_displays(VIRT_VIEWER_APP(user_data));
>  }
>  
> -static gboolean
> -viewer_window_focus_in_cb(GtkWindow *window G_GNUC_UNUSED,
> -  GdkEvent *event G_GNUC_UNUSED,
> -  VirtViewerApp *self)
> -{
> -self->priv->focused += 1;
> -
> -if (self->priv->focused == 1)
> -g_object_notify(G_OBJECT(self), "has-focus");
> -
> -return FALSE;
> -}
> -
> -static gboolean
> -viewer_window_focus_out_cb(GtkWindow *window G_GNUC_UNUSED,
> -   GdkEvent *event G_GNUC_UNUSED,
> -   VirtViewerApp *self)
> -{
> -self->priv->focused -= 1;
> -g_warn_if_fail(self->priv->focused >= 0);
> -
> -if (self->priv->focused <= 0)
> -g_object_notify(G_OBJECT(self), "has-focus");
> -
> -return FALSE;
> -}
> -
>  static gboolean
>  virt_viewer_app_has_usbredir(VirtViewerApp *self)
>  {
> @@ -881,8 +852,6 @@ virt_viewer_app_window_new(VirtViewerApp *self, gint nth)
>  
>  g_signal_connect(w, "hide", G_CALLBACK(viewer_window_visible_cb), self);
>  g_signal_connect(w, "show", G_CALLBACK(viewer_window_visible_cb), self);
> -g_signal_connect(w, "focus-in-event", 
> G_CALLBACK(viewer_window_focus_in_cb), self);
> -g_signal_connect(w, "focus-out-event", 
> G_CALLBACK(viewer_window_focus_out_cb), self);
>  return window;
>  }
>  
> @@ -1564,10 +1533,6 @@ virt_viewer_app_get_property (GObject *object, guint 
> property_id,
>  g_value_set_boolean(value, virt_viewer_app_get_enable_accel(self));
>  break;
>  
> -case PROP_HAS_FOCUS:
> -g_value_set_boolean(value, priv->focused > 0);
> -break;
> -
>  case PROP_KIOSK:
>  g_value_set_boolean(value, priv->kiosk);
>  break;
> @@ -1997,15 +1962,6 @@ virt_viewer_app_class_init (VirtViewerAppClass *klass)
>   G_PARAM_READWRITE |
>   
> G_PARAM_STATIC_STRINGS));
>  
> -g_object_class_install_property(object_class,
> -PROP_HAS_FOCUS,
> -g_param_spec_boolean("has-focus",
> - "Has Focus",
> - "Application has 
> focus",
> - FALSE,
> - G_PARAM_READABLE |
> - 
> G_PARAM_STATIC_STRINGS));
> -
>  g_object_class_install_property(object_class,
>  PROP_KIOSK,
>  g_param_spec_boolean("kiosk",
> 


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer] build: Explicitly link against librest

2018-05-31 Thread Eduardo Lima (Etrunko)
In remote-viewer, there is an explicit call to rest_proxy_auth_cancel(),
so we should be linking against librest as well. This patch fixes the
following error:

make[3]: Entering directory '/home/elima/projects/spice/virt-viewer/src'
  CCLD remote-viewer
/usr/bin/ld: remote_viewer-remote-viewer.o: undefined reference to symbol 
'rest_proxy_auth_cancel'
/home/elima/install/govirt-usr/lib/librest-0.7.so.0: error adding symbols: DSO 
missing from command line
collect2: error: ld returned 1 exit status

Signed-off-by: Eduardo Lima (Etrunko) 
---
 configure.ac| 3 ++-
 src/Makefile.am | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index e262e31..c6aeeda 100644
--- a/configure.ac
+++ b/configure.ac
@@ -187,7 +187,8 @@ AS_IF([test "x$with_ovirt" = "xyes"],
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]],
 [static int err = OVIRT_REST_CALL_ERROR_CANCELLED;
  void *fun = rest_proxy_auth_cancel;])],
-[AC_DEFINE([HAVE_OVIRT_CANCEL], 1, [Have rest_proxy_auth_cancel and 
OVIRT_REST_CALL_ERROR_CANCELLED?])],
+[AC_DEFINE([HAVE_OVIRT_CANCEL], 1, [Have rest_proxy_auth_cancel and 
OVIRT_REST_CALL_ERROR_CANCELLED?])
+ PKG_CHECK_MODULES([REST], [rest-0.7 >= 0.7.92])],
 [])
AC_CHECK_FUNCS([ovirt_api_search_vms ovirt_vm_get_host 
ovirt_host_get_cluster ovirt_cluster_get_data_center],
   [AC_DEFINE([HAVE_OVIRT_DATA_CENTER], 1, [Have support 
for data center])],
diff --git a/src/Makefile.am b/src/Makefile.am
index 0a3cbbf..501c688 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -113,6 +113,7 @@ COMMON_LIBS = \
$(SPICE_GTK_LIBS)   \
$(LIBXML2_LIBS) \
$(OVIRT_LIBS) \
+   $(REST_LIBS) \
$(NULL)
 
 COMMON_CFLAGS = \
@@ -124,6 +125,7 @@ COMMON_CFLAGS = \
$(SPICE_GTK_CFLAGS) \
$(LIBXML2_CFLAGS) \
$(OVIRT_CFLAGS) \
+   $(REST_CFLAGS) \
$(WARN_CFLAGS) \
$(NULL)
 
-- 
2.14.4

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [remote-viewer] remote-viewer-connect: centralize window

2018-05-31 Thread Eduardo Lima (Etrunko)
On 30/05/18 09:47, Victor Toso wrote:
> From: Victor Toso 
> 
> Instead of top-left corner.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1508274
> 
> Signed-off-by: Victor Toso 

Acked-by: Eduardo Lima (Etrunko) 

> ---
>  src/resources/ui/remote-viewer-connect.ui | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/resources/ui/remote-viewer-connect.ui 
> b/src/resources/ui/remote-viewer-connect.ui
> index 308d121..b2f3f09 100644
> --- a/src/resources/ui/remote-viewer-connect.ui
> +++ b/src/resources/ui/remote-viewer-connect.ui
> @@ -4,6 +4,7 @@
>
>  False
>  Connection details
> +3
>  
>
>  True
> 


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer v3] Fixes to spec file

2017-11-29 Thread Eduardo Lima (Etrunko)
On 27/11/17 07:37, Christophe Fergeau wrote:
> 
> Acked-by: Christophe Fergeau <cferg...@redhat.com>

Pushed, Thanks.

> 
> On Thu, Nov 23, 2017 at 11:52:53AM -0200, Eduardo Lima (Etrunko) wrote:
>> - Use macros for paths instead of absolute paths.
>> - Remove dangling %{gtk_arg} macro in configure.
>> - Fix scope of enable_autotools macro to avoid warning during build.
>>   warning: Macro %enable_autotools defined but not used within scope
>>
>> Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
>> ---
>>  virt-viewer.spec.in | 22 +++---
>>  1 file changed, 11 insertions(+), 11 deletions(-)
>>
>> diff --git a/virt-viewer.spec.in b/virt-viewer.spec.in
>> index 54e2121..86624d0 100644
>> --- a/virt-viewer.spec.in
>> +++ b/virt-viewer.spec.in
>> @@ -3,7 +3,7 @@
>>  # Default to skipping autoreconf.  Distros can change just this one line
>>  # (or provide a command-line override) if they backport any patches that
>>  # touch configure.ac or Makefile.am.
>> -%{!?enable_autotools:%define enable_autotools 0}
>> +%{!?enable_autotools:%global enable_autotools 0}
>>  
>>  %define with_spice 0
>>  %if 0%{?fedora} >= 17 || 0%{?rhel} >= 6
>> @@ -82,7 +82,7 @@ autoreconf -if
>>  %define govirt_arg --with-ovirt
>>  %endif
>>  
>> -%configure %{spice_arg} %{gtk_arg} %{govirt_arg} --with-buildid=%{release} 
>> --disable-update-mimedb
>> +%configure %{spice_arg} %{govirt_arg} --with-buildid=%{release} 
>> --disable-update-mimedb
>>  %__make %{?_smp_mflags}
>>  
>>  
>> @@ -95,21 +95,21 @@ rm -rf $RPM_BUILD_ROOT
>>  rm -rf $RPM_BUILD_ROOT
>>  
>>  %post
>> -/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
>> -/bin/touch --no-create %{_datadir}/mime/packages &> /dev/null || :
>> -/usr/bin/update-desktop-database -q %{_datadir}/applications
>> +%{_bindir}/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
>> +%{_bindir}/touch --no-create %{_datadir}/mime/packages &> /dev/null || :
>> +%{_bindir}/update-desktop-database -q %{_datadir}/applications
>>  
>>  %postun
>>  if [ $1 -eq 0 ] ; then
>> -  /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
>> -  /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
>> -  /usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :
>> +  %{_bindir}/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
>> +  %{_bindir}/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || 
>> :
>> +  %{_bindir}/update-mime-database %{_datadir}/mime &> /dev/null
>>  fi
>> -/usr/bin/update-desktop-database -q %{_datadir}/applications
>> +%{_bindir}/update-desktop-database -q %{_datadir}/applications
>>  
>>  %posttrans
>> -/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
>> -/usr/bin/update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null 
>> || :
>> +%{_bindir}/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
>> +%{_bindir}/update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null 
>> || :
>>  
>>  %files -f %{name}.lang
>>  %defattr(-,root,root,-)
>> -- 
>> 2.13.6
>>
>> ___
>> virt-tools-list mailing list
>> virt-tools-list@redhat.com
>> https://www.redhat.com/mailman/listinfo/virt-tools-list


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer v2] Fixes to spec file

2017-11-23 Thread Eduardo Lima (Etrunko)
On 22/11/17 16:35, Christophe Fergeau wrote:
> On Wed, Nov 22, 2017 at 04:21:49PM -0200, Eduardo Lima (Etrunko) wrote:
>> - Use macros for paths instead of absolute paths.
>> - Fix scope of enable_autotools macro to avoid warning during build.
>>   warning: Macro %enable_autotools defined but not used within scope
>>
>> Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
>> ---
>>  virt-viewer.spec.in | 23 ---
>>  1 file changed, 12 insertions(+), 11 deletions(-)
>>
>> diff --git a/virt-viewer.spec.in b/virt-viewer.spec.in
>> index 54e2121..23fb0e7 100644
>> --- a/virt-viewer.spec.in
>> +++ b/virt-viewer.spec.in
>> @@ -3,7 +3,7 @@
>>  # Default to skipping autoreconf.  Distros can change just this one line
>>  # (or provide a command-line override) if they backport any patches that
>>  # touch configure.ac or Makefile.am.
>> -%{!?enable_autotools:%define enable_autotools 0}
>> +%{!?enable_autotools:%global enable_autotools 0}
>>  
>>  %define with_spice 0
>>  %if 0%{?fedora} >= 17 || 0%{?rhel} >= 6
>> @@ -82,7 +82,7 @@ autoreconf -if
>>  %define govirt_arg --with-ovirt
>>  %endif
>>  
>> -%configure %{spice_arg} %{gtk_arg} %{govirt_arg} --with-buildid=%{release} 
>> --disable-update-mimedb
>> +%configure %{spice_arg} %{govirt_arg} --with-buildid=%{release} 
>> --disable-update-mimedb
>>  %__make %{?_smp_mflags}
>>  
>>  
>> @@ -95,21 +95,22 @@ rm -rf $RPM_BUILD_ROOT
>>  rm -rf $RPM_BUILD_ROOT
>>  
>>  %post
>> -/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
>> -/bin/touch --no-create %{_datadir}/mime/packages &> /dev/null || :
>> -/usr/bin/update-desktop-database -q %{_datadir}/applications
>> +touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
>> +touch --no-create %{_datadir}/mime/packages &> /dev/null || :
>> +%{_bindir}/update-desktop-database -q %{_datadir}/applications
>> +%{_bindir}/update-mime-database %{_datadir}/mime &> /dev/null
> 
> Here you added a call to update-mime-database which was not there
> before?
> A bit odd that you remove a /bin/, /bin and /usr/bin are the same these
> days on at least fedora..
> 
>>  
>>  %postun
>>  if [ $1 -eq 0 ] ; then
>> -  /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
>> -  /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
>> -  /usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :
>> +  touch --no-create %{_datadir}/icons/hicolor &>/dev/null
>> +  %{_bindir}/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || 
>> :
> 
> The call to update-mime-database is gone from here.
> 
>>  fi
>> -/usr/bin/update-desktop-database -q %{_datadir}/applications
>> +%{_bindir}/update-desktop-database -q %{_datadir}/applications
>> +%{_bindir}/update-mime-database %{_datadir}/mime &> /dev/null
> 
> And moved out of the conditional? I believe it's done this way because
> on upgrades, the mime database is unchanged so we don't need to call
> update-mime-database, while on removal, we remove a mime type, so need
> to update the database.
> 

All fixed, new version coming soon.

Thanks, Eduardo.


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com



signature.asc
Description: OpenPGP digital signature
___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

[virt-tools-list] [PATCH virt-viewer v3] Fixes to spec file

2017-11-23 Thread Eduardo Lima (Etrunko)
- Use macros for paths instead of absolute paths.
- Remove dangling %{gtk_arg} macro in configure.
- Fix scope of enable_autotools macro to avoid warning during build.
  warning: Macro %enable_autotools defined but not used within scope

Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
---
 virt-viewer.spec.in | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/virt-viewer.spec.in b/virt-viewer.spec.in
index 54e2121..86624d0 100644
--- a/virt-viewer.spec.in
+++ b/virt-viewer.spec.in
@@ -3,7 +3,7 @@
 # Default to skipping autoreconf.  Distros can change just this one line
 # (or provide a command-line override) if they backport any patches that
 # touch configure.ac or Makefile.am.
-%{!?enable_autotools:%define enable_autotools 0}
+%{!?enable_autotools:%global enable_autotools 0}
 
 %define with_spice 0
 %if 0%{?fedora} >= 17 || 0%{?rhel} >= 6
@@ -82,7 +82,7 @@ autoreconf -if
 %define govirt_arg --with-ovirt
 %endif
 
-%configure %{spice_arg} %{gtk_arg} %{govirt_arg} --with-buildid=%{release} 
--disable-update-mimedb
+%configure %{spice_arg} %{govirt_arg} --with-buildid=%{release} 
--disable-update-mimedb
 %__make %{?_smp_mflags}
 
 
@@ -95,21 +95,21 @@ rm -rf $RPM_BUILD_ROOT
 rm -rf $RPM_BUILD_ROOT
 
 %post
-/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
-/bin/touch --no-create %{_datadir}/mime/packages &> /dev/null || :
-/usr/bin/update-desktop-database -q %{_datadir}/applications
+%{_bindir}/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
+%{_bindir}/touch --no-create %{_datadir}/mime/packages &> /dev/null || :
+%{_bindir}/update-desktop-database -q %{_datadir}/applications
 
 %postun
 if [ $1 -eq 0 ] ; then
-  /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
-  /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
-  /usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :
+  %{_bindir}/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
+  %{_bindir}/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
+  %{_bindir}/update-mime-database %{_datadir}/mime &> /dev/null
 fi
-/usr/bin/update-desktop-database -q %{_datadir}/applications
+%{_bindir}/update-desktop-database -q %{_datadir}/applications
 
 %posttrans
-/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
-/usr/bin/update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
+%{_bindir}/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
+%{_bindir}/update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || 
:
 
 %files -f %{name}.lang
 %defattr(-,root,root,-)
-- 
2.13.6

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer v2] Fixes to spec file

2017-11-22 Thread Eduardo Lima (Etrunko)
- Use macros for paths instead of absolute paths.
- Fix scope of enable_autotools macro to avoid warning during build.
  warning: Macro %enable_autotools defined but not used within scope

Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
---
 virt-viewer.spec.in | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/virt-viewer.spec.in b/virt-viewer.spec.in
index 54e2121..23fb0e7 100644
--- a/virt-viewer.spec.in
+++ b/virt-viewer.spec.in
@@ -3,7 +3,7 @@
 # Default to skipping autoreconf.  Distros can change just this one line
 # (or provide a command-line override) if they backport any patches that
 # touch configure.ac or Makefile.am.
-%{!?enable_autotools:%define enable_autotools 0}
+%{!?enable_autotools:%global enable_autotools 0}
 
 %define with_spice 0
 %if 0%{?fedora} >= 17 || 0%{?rhel} >= 6
@@ -82,7 +82,7 @@ autoreconf -if
 %define govirt_arg --with-ovirt
 %endif
 
-%configure %{spice_arg} %{gtk_arg} %{govirt_arg} --with-buildid=%{release} 
--disable-update-mimedb
+%configure %{spice_arg} %{govirt_arg} --with-buildid=%{release} 
--disable-update-mimedb
 %__make %{?_smp_mflags}
 
 
@@ -95,21 +95,22 @@ rm -rf $RPM_BUILD_ROOT
 rm -rf $RPM_BUILD_ROOT
 
 %post
-/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
-/bin/touch --no-create %{_datadir}/mime/packages &> /dev/null || :
-/usr/bin/update-desktop-database -q %{_datadir}/applications
+touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
+touch --no-create %{_datadir}/mime/packages &> /dev/null || :
+%{_bindir}/update-desktop-database -q %{_datadir}/applications
+%{_bindir}/update-mime-database %{_datadir}/mime &> /dev/null
 
 %postun
 if [ $1 -eq 0 ] ; then
-  /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
-  /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
-  /usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :
+  touch --no-create %{_datadir}/icons/hicolor &>/dev/null
+  %{_bindir}/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 fi
-/usr/bin/update-desktop-database -q %{_datadir}/applications
+%{_bindir}/update-desktop-database -q %{_datadir}/applications
+%{_bindir}/update-mime-database %{_datadir}/mime &> /dev/null
 
 %posttrans
-/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
-/usr/bin/update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
+%{_bindir}/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
+%{_bindir}/update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || 
:
 
 %files -f %{name}.lang
 %defattr(-,root,root,-)
-- 
2.13.6

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer] doc: Adjust reference to spice-gtk man page for remote-viewer

2017-11-22 Thread Eduardo Lima (Etrunko)
Similar to last commit, as noticed by reporter in bugzilla:

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

Man page should reference spice-client, not spice-gtk.

Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
---
 man/remote-viewer.pod | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/man/remote-viewer.pod b/man/remote-viewer.pod
index 968ea70..8cf5ee4 100644
--- a/man/remote-viewer.pod
+++ b/man/remote-viewer.pod
@@ -382,6 +382,6 @@ to the extent permitted by law.
 
 =head1 SEE ALSO
 
-C<virt-viewer(1)>, C<spice-gtk(1)>, the project website 
C<http://virt-manager.org>
+C<virt-viewer(1)>, C<spice-client(1)>, the project website 
C<http://virt-manager.org>
 
 =cut
-- 
2.13.6

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [virt-viewer] doc: Adjust reference to spice-gtk man page

2017-11-17 Thread Eduardo Lima (Etrunko)
On 21/09/17 06:12, Daniel P. Berrange wrote:
> On Thu, Sep 21, 2017 at 10:16:56AM +0200, Christophe Fergeau wrote:
>> The man page spice-gtk ships is named "spice-client", not "spice-gtk"
>>
>> Signed-off-by: Christophe Fergeau 
>>
>> https://bugzilla.redhat.com/show_bug.cgi?id=1477966
>> ---
>>  man/virt-viewer.pod | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/man/virt-viewer.pod b/man/virt-viewer.pod
>> index 8463eb4..9ea5fb8 100644
>> --- a/man/virt-viewer.pod
>> +++ b/man/virt-viewer.pod
>> @@ -223,6 +223,6 @@ to the extent permitted by law.
>>  
>>  =head1 SEE ALSO
>>  
>> -C, C, C, the project website 
>> C
>> +C, C, C, the project website 
>> C
> 
> I was wondering what man page this is until I found it was in the
> spice-gtk RPM, not spice-gtk3.  The spice-gtk RPM seems entirely
> pointless to me - it used to contain the GTK2 build but thats now
> gone - can we just put the man page in spice-gtk3 RPM and kill
> the spice-gtk RPM entirely
> 
> Anyway
> 
> Reviewed-by: Daniel P. Berrange 
> 

This patch had never made upstream, so I just pushed it as
1b89efaa2805ddfd5e3eb8dc56d4509984cc2f76.

-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer] Fixes to spec file

2017-11-17 Thread Eduardo Lima (Etrunko)
On 17/11/17 11:39, Eduardo Lima (Etrunko) wrote:
> - Use macros for paths instead of absolute paths.
> - Fix scope of enable_autotools macro to avoid warning during build.
>   warning: Macro %enable_autotools defined but not used within scope
> - Remove references to spice-xpi-client
> 

I just noticed a commit by Marc-Andre that removes the spice-xpi-client
bits in the upstream repository, but I never got the mail about it. Is
it only me?

-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] Status of virt-viewer headerbar conversion ?

2017-11-17 Thread Eduardo Lima (Etrunko)
On 17/11/17 11:45, Daniel P. Berrange wrote:
> A while ago now we had patches going through review that switched over to
> use Gtk HeaderBar concept. I was wondering what the status of that is, as
> I think it would be a nice step forward for virt-viewer UI.
>

As far as I remember, the idea was to support both client and server
side decorations. It would be required to do something like
GtkAboutDialog does to detect if it should display the HeaderBar or not.

My opinion is that it would require too much work to keep two different
versions of the UI, and basically I did not went down that path, and
kept that branch dormant for a while until the subject was raised once
again.

I took the work started by Sagar Ghuge, who changed the main window,
while I ported the dialogs. The work is pushed to my github repository,
branches are headerbar (for the main window) and dialogs.

https://github.com/etrunko/virt-viewer


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer] Fixes to spec file

2017-11-17 Thread Eduardo Lima (Etrunko)
- Use macros for paths instead of absolute paths.
- Fix scope of enable_autotools macro to avoid warning during build.
  warning: Macro %enable_autotools defined but not used within scope
- Remove references to spice-xpi-client

Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
---
 virt-viewer.spec.in | 31 ---
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/virt-viewer.spec.in b/virt-viewer.spec.in
index 44ef92e..9fec917 100644
--- a/virt-viewer.spec.in
+++ b/virt-viewer.spec.in
@@ -3,7 +3,7 @@
 # Default to skipping autoreconf.  Distros can change just this one line
 # (or provide a command-line override) if they backport any patches that
 # touch configure.ac or Makefile.am.
-%{!?enable_autotools:%define enable_autotools 0}
+%{!?enable_autotools:%global enable_autotools 0}
 
 %define with_spice 0
 %if 0%{?fedora} >= 17 || 0%{?rhel} >= 6
@@ -82,40 +82,35 @@ autoreconf -if
 %define govirt_arg --with-ovirt
 %endif
 
-%configure %{spice_arg} %{gtk_arg} %{govirt_arg} --with-buildid=%{release} 
--disable-update-mimedb
+%configure %{spice_arg} %{govirt_arg} --with-buildid=%{release} 
--disable-update-mimedb
 %__make %{?_smp_mflags}
 
 
 %install
 rm -rf $RPM_BUILD_ROOT
 %__make install  DESTDIR=$RPM_BUILD_ROOT
-mkdir -p %{buildroot}%{_libexecdir}
-touch %{buildroot}%{_libexecdir}/spice-xpi-client
-install -m 0755 data/spice-xpi-client-remote-viewer %{buildroot}%{_libexecdir}/
 %find_lang %{name}
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 %post
-/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
-/bin/touch --no-create %{_datadir}/mime/packages &> /dev/null || :
-%{_sbindir}/update-alternatives --install %{_libexecdir}/spice-xpi-client \
-  spice-xpi-client %{_libexecdir}/spice-xpi-client-remote-viewer 25
-/usr/bin/update-desktop-database -q %{_datadir}/applications
+touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
+touch --no-create %{_datadir}/mime/packages &> /dev/null || :
+%{_bindir}update-desktop-database -q %{_datadir}/applications
+%{_bindir}/update-mime-database %{_datadir}/mime &> /dev/null
 
 %postun
 if [ $1 -eq 0 ] ; then
-  /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
-  /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
-  /usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :
-  %{_sbindir}/update-alternatives --remove spice-xpi-client 
%{_libexecdir}/spice-xpi-client-remote-viewer
+  touch --no-create %{_datadir}/icons/hicolor &>/dev/null
+  %{_bindir}/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 fi
-/usr/bin/update-desktop-database -q %{_datadir}/applications
+%{_bindir}/update-desktop-database -q %{_datadir}/applications
+%{_bindir}/update-mime-database %{_datadir}/mime &> /dev/null
 
 %posttrans
-/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
-/usr/bin/update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
+%{_bindir}/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
+%{_bindir}/update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || 
:
 
 %files -f %{name}.lang
 %defattr(-,root,root,-)
@@ -127,8 +122,6 @@ fi
 %{_datadir}/applications/remote-viewer.desktop
 %{_datadir}/appdata/remote-viewer.appdata.xml
 %{_datadir}/mime/packages/virt-viewer-mime.xml
-%ghost %{_libexecdir}/spice-xpi-client
-%{_libexecdir}/spice-xpi-client-remote-viewer
 %{_mandir}/man1/virt-viewer.1*
 %{_mandir}/man1/remote-viewer.1*
 
-- 
2.13.6

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer v3] remote-viewer: Pass guri to remote_viewer_session_connected

2017-11-14 Thread Eduardo Lima (Etrunko)
On 14/11/17 15:01, Victor Toso wrote:
> Hi,
> 
> On Tue, Nov 14, 2017 at 02:54:30PM -0200, Eduardo Lima (Etrunko) wrote:
>> When connecting to a VM via oVirt instance, the original uri can not be
>> retrieved using virt_viewer_session_get_uri(). Consequently, it was
>> never saved, even though the connection succeeds and the actual callback
>> for "session-connected" signal, which saves the URI, is invoked.
>>
>> To solve this problem, we always pass a copy of the guri as user-data
>> parameter for the callback, and if the call to
>> virt_viewer_session_get_uri() returns NULL, the parameter is used
>> instead.
>>
>> Resolves: https://bugzilla.redhat.com/1459792
>>
>> Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
> 
> Reviewed-by: Victor Toso <victort...@redhat.com>
> 

Pushed, thanks.


> Thanks,
>> ---
>>  src/remote-viewer.c | 21 ++---
>>  1 file changed, 10 insertions(+), 11 deletions(-)
>>
>> diff --git a/src/remote-viewer.c b/src/remote-viewer.c
>> index fb5376c..786b26b 100644
>> --- a/src/remote-viewer.c
>> +++ b/src/remote-viewer.c
>> @@ -85,10 +85,6 @@ static void spice_foreign_menu_updated(RemoteViewer 
>> *self);
>>  static void foreign_menu_title_changed(SpiceCtrlForeignMenu *menu, 
>> GParamSpec *pspec, RemoteViewer *self);
>>  #endif
>>  
>> -static gboolean
>> -remote_viewer_initial_connect(RemoteViewer *self, const gchar *type,
>> -  VirtViewerFile *vvfile, GError **error);
>> -
>>  static void
>>  remote_viewer_dispose (GObject *object)
>>  {
>> @@ -1064,8 +1060,7 @@ remote_viewer_recent_add(gchar *uri, const gchar 
>> *mime_type)
>>  .mime_type= (char*)mime_type,
>>  };
>>  
>> -if (uri == NULL)
>> -return;
>> +g_return_if_fail(uri != NULL);
>>  
>>  recent = gtk_recent_manager_get_default();
>>  meta.display_name = uri;
>> @@ -1075,17 +1070,21 @@ remote_viewer_recent_add(gchar *uri, const gchar 
>> *mime_type)
>>  
>>  static void
>>  remote_viewer_session_connected(VirtViewerSession *session,
>> -VirtViewerApp *self G_GNUC_UNUSED)
>> +gchar *guri)
>>  {
>>  gchar *uri = virt_viewer_session_get_uri(session);
>>  const gchar *mime = virt_viewer_session_mime_type(session);
>>  
>> +if (uri == NULL)
>> +uri = g_strdup(guri);
>> +
>>  remote_viewer_recent_add(uri, mime);
>>  g_free(uri);
>> +g_free(guri);
>>  }
>>  
>>  static gboolean
>> -remote_viewer_initial_connect(RemoteViewer *self, const gchar *type,
>> +remote_viewer_initial_connect(RemoteViewer *self, const gchar *type, const 
>> gchar *guri,
>>VirtViewerFile *vvfile, GError **error)
>>  {
>>  VirtViewerApp *app = VIRT_VIEWER_APP(self);
>> @@ -1093,8 +1092,9 @@ remote_viewer_initial_connect(RemoteViewer *self, 
>> const gchar *type,
>>  if (!virt_viewer_app_create_session(app, type, error))
>>  return FALSE;
>>  
>> +
>>  g_signal_connect(virt_viewer_app_get_session(app), "session-connected",
>> - G_CALLBACK(remote_viewer_session_connected), app);
>> + G_CALLBACK(remote_viewer_session_connected), 
>> g_strdup(guri));
>>  
>>  virt_viewer_session_set_file(virt_viewer_app_get_session(app), vvfile);
>>  #ifdef HAVE_OVIRT
>> @@ -1200,12 +1200,11 @@ retry_dialog:
>>  } else
>>  #endif
>>  {
>> -if (!remote_viewer_initial_connect(self, type, vvfile, ))
>> +if (!remote_viewer_initial_connect(self, type, guri, vvfile, 
>> ))
>>  goto cleanup;
>>  }
>>  }
>>  
>> -
>>  ret = VIRT_VIEWER_APP_CLASS(remote_viewer_parent_class)->start(app, 
>> );
>>  
>>  cleanup:
>> -- 
>> 2.13.6
>>
>> ___
>> virt-tools-list mailing list
>> virt-tools-list@redhat.com
>> https://www.redhat.com/mailman/listinfo/virt-tools-list


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com



signature.asc
Description: OpenPGP digital signature
___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

[virt-tools-list] [PATCH virt-viewer v3] remote-viewer: Pass guri to remote_viewer_session_connected

2017-11-14 Thread Eduardo Lima (Etrunko)
When connecting to a VM via oVirt instance, the original uri can not be
retrieved using virt_viewer_session_get_uri(). Consequently, it was
never saved, even though the connection succeeds and the actual callback
for "session-connected" signal, which saves the URI, is invoked.

To solve this problem, we always pass a copy of the guri as user-data
parameter for the callback, and if the call to
virt_viewer_session_get_uri() returns NULL, the parameter is used
instead.

Resolves: https://bugzilla.redhat.com/1459792

Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
---
 src/remote-viewer.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index fb5376c..786b26b 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -85,10 +85,6 @@ static void spice_foreign_menu_updated(RemoteViewer *self);
 static void foreign_menu_title_changed(SpiceCtrlForeignMenu *menu, GParamSpec 
*pspec, RemoteViewer *self);
 #endif
 
-static gboolean
-remote_viewer_initial_connect(RemoteViewer *self, const gchar *type,
-  VirtViewerFile *vvfile, GError **error);
-
 static void
 remote_viewer_dispose (GObject *object)
 {
@@ -1064,8 +1060,7 @@ remote_viewer_recent_add(gchar *uri, const gchar 
*mime_type)
 .mime_type= (char*)mime_type,
 };
 
-if (uri == NULL)
-return;
+g_return_if_fail(uri != NULL);
 
 recent = gtk_recent_manager_get_default();
 meta.display_name = uri;
@@ -1075,17 +1070,21 @@ remote_viewer_recent_add(gchar *uri, const gchar 
*mime_type)
 
 static void
 remote_viewer_session_connected(VirtViewerSession *session,
-VirtViewerApp *self G_GNUC_UNUSED)
+gchar *guri)
 {
 gchar *uri = virt_viewer_session_get_uri(session);
 const gchar *mime = virt_viewer_session_mime_type(session);
 
+if (uri == NULL)
+uri = g_strdup(guri);
+
 remote_viewer_recent_add(uri, mime);
 g_free(uri);
+g_free(guri);
 }
 
 static gboolean
-remote_viewer_initial_connect(RemoteViewer *self, const gchar *type,
+remote_viewer_initial_connect(RemoteViewer *self, const gchar *type, const 
gchar *guri,
   VirtViewerFile *vvfile, GError **error)
 {
 VirtViewerApp *app = VIRT_VIEWER_APP(self);
@@ -1093,8 +1092,9 @@ remote_viewer_initial_connect(RemoteViewer *self, const 
gchar *type,
 if (!virt_viewer_app_create_session(app, type, error))
 return FALSE;
 
+
 g_signal_connect(virt_viewer_app_get_session(app), "session-connected",
- G_CALLBACK(remote_viewer_session_connected), app);
+ G_CALLBACK(remote_viewer_session_connected), 
g_strdup(guri));
 
 virt_viewer_session_set_file(virt_viewer_app_get_session(app), vvfile);
 #ifdef HAVE_OVIRT
@@ -1200,12 +1200,11 @@ retry_dialog:
 } else
 #endif
 {
-if (!remote_viewer_initial_connect(self, type, vvfile, ))
+if (!remote_viewer_initial_connect(self, type, guri, vvfile, 
))
 goto cleanup;
 }
 }
 
-
 ret = VIRT_VIEWER_APP_CLASS(remote_viewer_parent_class)->start(app, 
);
 
 cleanup:
-- 
2.13.6

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer v2] remote-viewer: Pass guri to remote_viewer_session_connected

2017-11-14 Thread Eduardo Lima (Etrunko)
On 14/11/17 14:38, Victor Toso wrote:
> Hi,
> 
> On Tue, Nov 14, 2017 at 02:14:25PM -0200, Eduardo Lima (Etrunko) wrote:
>> On 14/11/17 13:47, Victor Toso wrote:
>>> On Thu, Oct 26, 2017 at 03:39:31PM +0200, Eduardo Lima (Etrunko) wrote:
>>>> When connecting to a VM via oVirt instance, the original uri can not be
>>>> retrieved using virt_viewer_session_get_uri(). Consequently, it was
>>>> never saved, even though the connection succeeds and the actual callback
>>>> for "session-connected" signal, which saves the URI, is invoked.
>>>>
>>>> To solve this problem, we always pass a copy of the guri as user-data
>>>> parameter for the callback, and if the call to
>>>> virt_viewer_session_get_uri() returns NULL, the parameter is used
>>>> instead.
>>>>
>>>> Resolves: https://bugzilla.redhat.com/1459792
>>>>
>>>> Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
>>>> ---
>>>>  src/remote-viewer.c | 18 +-
>>>>  1 file changed, 9 insertions(+), 9 deletions(-)
>>>>
>>>> diff --git a/src/remote-viewer.c b/src/remote-viewer.c
>>>> index fb5376c..58dc04f 100644
>>>> --- a/src/remote-viewer.c
>>>> +++ b/src/remote-viewer.c
>>>> @@ -85,10 +85,6 @@ static void spice_foreign_menu_updated(RemoteViewer 
>>>> *self);
>>>>  static void foreign_menu_title_changed(SpiceCtrlForeignMenu *menu, 
>>>> GParamSpec *pspec, RemoteViewer *self);
>>>>  #endif
>>>>  
>>>> -static gboolean
>>>> -remote_viewer_initial_connect(RemoteViewer *self, const gchar *type,
>>>> -  VirtViewerFile *vvfile, GError **error);
>>>> -
>>>>  static void
>>>>  remote_viewer_dispose (GObject *object)
>>>>  {
>>>> @@ -1075,17 +1071,21 @@ remote_viewer_recent_add(gchar *uri, const gchar 
>>>> *mime_type)
>>>>  
>>>>  static void
>>>>  remote_viewer_session_connected(VirtViewerSession *session,
>>>> -VirtViewerApp *self G_GNUC_UNUSED)
>>>> +gchar *guri)
>>>>  {
>>>>  gchar *uri = virt_viewer_session_get_uri(session);
>>>>  const gchar *mime = virt_viewer_session_mime_type(session);
>>>>  
>>>> +if (uri == NULL)
>>>> +uri = g_strdup(guri);
>>>> +
>>>>  remote_viewer_recent_add(uri, mime);
>>>
>>> Could you also change the if (uri == NULL) in above function to a
>>> g_return_if_fail(uri != NULL) as it should not happen anymore...
>>>
>>
>> I don't really get what you mean here, as I explained on the commit
>> message, uri *can* be NULL. In this case, we will use the guri, which is
>> now passed as user_data argument to the callback.
> 
> You are right, you just did not get what I mean here.
> 
> If virt_viewer_session_get_uri() returns NULL we use the guri which
> *cannot be null* - That means that we can change the check in
> remote_viewer_recent_add() from if (uri == NULL) return; to
> g_return_if_fail() instead.
> 
> This is more like a suggestion. Another possibility is just to remove
> the check (in remote_viewer_recent_add()) entirely) as we should have
> critical messages elsewhere if guri is null.
> 

Now I got it, you were talking about the other function, but commented
on this block of code in remote_viewer_session_connected(), thus my
confusion. I will change the check as suggested.

Thanks, Eduardo.

> Cheers,
> 
>>
>>> Either way,
>>> Reviewed-by: Victor Toso <victort...@redhat.com>
>>>
>>>>  g_free(uri);
>>>> +g_free(guri);
>>>>  }
>>>>  
>>>>  static gboolean
>>>> -remote_viewer_initial_connect(RemoteViewer *self, const gchar *type,
>>>> +remote_viewer_initial_connect(RemoteViewer *self, const gchar *type, 
>>>> const gchar *guri,
>>>>VirtViewerFile *vvfile, GError **error)
>>>>  {
>>>>  VirtViewerApp *app = VIRT_VIEWER_APP(self);
>>>> @@ -1093,8 +1093,9 @@ remote_viewer_initial_connect(RemoteViewer *self, 
>>>> const gchar *type,
>>>>  if (!virt_viewer_app_create_session(app, type, error))
>>>>  return FALSE;
>>>>  
>>>> +
>>>>  g_signal_connect(virt_viewer_app_get_ses

Re: [virt-tools-list] [PATCH virt-viewer v2] remote-viewer: Pass guri to remote_viewer_session_connected

2017-11-14 Thread Eduardo Lima (Etrunko)
On 14/11/17 13:47, Victor Toso wrote:
> On Thu, Oct 26, 2017 at 03:39:31PM +0200, Eduardo Lima (Etrunko) wrote:
>> When connecting to a VM via oVirt instance, the original uri can not be
>> retrieved using virt_viewer_session_get_uri(). Consequently, it was
>> never saved, even though the connection succeeds and the actual callback
>> for "session-connected" signal, which saves the URI, is invoked.
>>
>> To solve this problem, we always pass a copy of the guri as user-data
>> parameter for the callback, and if the call to
>> virt_viewer_session_get_uri() returns NULL, the parameter is used
>> instead.
>>
>> Resolves: https://bugzilla.redhat.com/1459792
>>
>> Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
>> ---
>>  src/remote-viewer.c | 18 +-
>>  1 file changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/src/remote-viewer.c b/src/remote-viewer.c
>> index fb5376c..58dc04f 100644
>> --- a/src/remote-viewer.c
>> +++ b/src/remote-viewer.c
>> @@ -85,10 +85,6 @@ static void spice_foreign_menu_updated(RemoteViewer 
>> *self);
>>  static void foreign_menu_title_changed(SpiceCtrlForeignMenu *menu, 
>> GParamSpec *pspec, RemoteViewer *self);
>>  #endif
>>  
>> -static gboolean
>> -remote_viewer_initial_connect(RemoteViewer *self, const gchar *type,
>> -  VirtViewerFile *vvfile, GError **error);
>> -
>>  static void
>>  remote_viewer_dispose (GObject *object)
>>  {
>> @@ -1075,17 +1071,21 @@ remote_viewer_recent_add(gchar *uri, const gchar 
>> *mime_type)
>>  
>>  static void
>>  remote_viewer_session_connected(VirtViewerSession *session,
>> -VirtViewerApp *self G_GNUC_UNUSED)
>> +gchar *guri)
>>  {
>>  gchar *uri = virt_viewer_session_get_uri(session);
>>  const gchar *mime = virt_viewer_session_mime_type(session);
>>  
>> +if (uri == NULL)
>> +uri = g_strdup(guri);
>> +
>>  remote_viewer_recent_add(uri, mime);
> 
> Could you also change the if (uri == NULL) in above function to a
> g_return_if_fail(uri != NULL) as it should not happen anymore...
> 

I don't really get what you mean here, as I explained on the commit
message, uri *can* be NULL. In this case, we will use the guri, which is
now passed as user_data argument to the callback.

> Either way,
> Reviewed-by: Victor Toso <victort...@redhat.com>
> 
>>  g_free(uri);
>> +g_free(guri);
>>  }
>>  
>>  static gboolean
>> -remote_viewer_initial_connect(RemoteViewer *self, const gchar *type,
>> +remote_viewer_initial_connect(RemoteViewer *self, const gchar *type, const 
>> gchar *guri,
>>VirtViewerFile *vvfile, GError **error)
>>  {
>>  VirtViewerApp *app = VIRT_VIEWER_APP(self);
>> @@ -1093,8 +1093,9 @@ remote_viewer_initial_connect(RemoteViewer *self, 
>> const gchar *type,
>>  if (!virt_viewer_app_create_session(app, type, error))
>>  return FALSE;
>>  
>> +
>>  g_signal_connect(virt_viewer_app_get_session(app), "session-connected",
>> - G_CALLBACK(remote_viewer_session_connected), app);
>> + G_CALLBACK(remote_viewer_session_connected), 
>> g_strdup(guri));
>>  
>>  virt_viewer_session_set_file(virt_viewer_app_get_session(app), vvfile);
>>  #ifdef HAVE_OVIRT
>> @@ -1200,12 +1201,11 @@ retry_dialog:
>>  } else
>>  #endif
>>  {
>> -if (!remote_viewer_initial_connect(self, type, vvfile, ))
>> +if (!remote_viewer_initial_connect(self, type, guri, vvfile, 
>> ))
>>  goto cleanup;
>>  }
>>  }
>>  
>> -
>>  ret = VIRT_VIEWER_APP_CLASS(remote_viewer_parent_class)->start(app, 
>> );
>>  
>>  cleanup:
>> -- 
>> 2.13.6
>>
>> ___
>> virt-tools-list mailing list
>> virt-tools-list@redhat.com
>> https://www.redhat.com/mailman/listinfo/virt-tools-list


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] virt-viewer 6.0 download problems

2017-10-31 Thread Eduardo Lima (Etrunko)
On 31/10/17 17:32, Wow Zaza wrote:
> Thank you for the replies. I was able to download using Firefox. I tried
> using Chrome, Edge, and Internet Explorer. None of them worked. Although
> my problem is solved, could it be a compilation issue on your end? Only
> one of the major browser is able to download this file; I am sure a lot
> of people trying to download are having issues.


I don't think it has anything to do with how the package is build, but
maybe an issue with the web server not setting the correct mime-type? I
am just shooting in the dark here, not sure how this should work.

Regards, Eduardo.

-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] virt-viewer 6.0 download problems

2017-10-31 Thread Eduardo Lima (Etrunko)
On 31/10/17 16:13, Daniel P. Berrange wrote:
> On Mon, Oct 30, 2017 at 08:27:46PM +, Wow Zaza wrote:
>> I want to bring to your attention that the virt-viewer 6.0 (x86 and x64)
>> download aren't currently accessible via the download link. When you
>> click on the download link, all you see is gibberish. Can you please
>> look into it?
> 
> It works just fine when I try it.
> 

It may be something with browser configuration, when I try the link with
Chrome, it will dump the binary file as a web page, but it works if you
save it "Ctrl+S". With Firefox, it shows the dialog asking what I want
to do with that file.


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer v2] remote-viewer: Pass guri to remote_viewer_session_connected

2017-10-26 Thread Eduardo Lima (Etrunko)
When connecting to a VM via oVirt instance, the original uri can not be
retrieved using virt_viewer_session_get_uri(). Consequently, it was
never saved, even though the connection succeeds and the actual callback
for "session-connected" signal, which saves the URI, is invoked.

To solve this problem, we always pass a copy of the guri as user-data
parameter for the callback, and if the call to
virt_viewer_session_get_uri() returns NULL, the parameter is used
instead.

Resolves: https://bugzilla.redhat.com/1459792

Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
---
 src/remote-viewer.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index fb5376c..58dc04f 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -85,10 +85,6 @@ static void spice_foreign_menu_updated(RemoteViewer *self);
 static void foreign_menu_title_changed(SpiceCtrlForeignMenu *menu, GParamSpec 
*pspec, RemoteViewer *self);
 #endif
 
-static gboolean
-remote_viewer_initial_connect(RemoteViewer *self, const gchar *type,
-  VirtViewerFile *vvfile, GError **error);
-
 static void
 remote_viewer_dispose (GObject *object)
 {
@@ -1075,17 +1071,21 @@ remote_viewer_recent_add(gchar *uri, const gchar 
*mime_type)
 
 static void
 remote_viewer_session_connected(VirtViewerSession *session,
-VirtViewerApp *self G_GNUC_UNUSED)
+gchar *guri)
 {
 gchar *uri = virt_viewer_session_get_uri(session);
 const gchar *mime = virt_viewer_session_mime_type(session);
 
+if (uri == NULL)
+uri = g_strdup(guri);
+
 remote_viewer_recent_add(uri, mime);
 g_free(uri);
+g_free(guri);
 }
 
 static gboolean
-remote_viewer_initial_connect(RemoteViewer *self, const gchar *type,
+remote_viewer_initial_connect(RemoteViewer *self, const gchar *type, const 
gchar *guri,
   VirtViewerFile *vvfile, GError **error)
 {
 VirtViewerApp *app = VIRT_VIEWER_APP(self);
@@ -1093,8 +1093,9 @@ remote_viewer_initial_connect(RemoteViewer *self, const 
gchar *type,
 if (!virt_viewer_app_create_session(app, type, error))
 return FALSE;
 
+
 g_signal_connect(virt_viewer_app_get_session(app), "session-connected",
- G_CALLBACK(remote_viewer_session_connected), app);
+ G_CALLBACK(remote_viewer_session_connected), 
g_strdup(guri));
 
 virt_viewer_session_set_file(virt_viewer_app_get_session(app), vvfile);
 #ifdef HAVE_OVIRT
@@ -1200,12 +1201,11 @@ retry_dialog:
 } else
 #endif
 {
-if (!remote_viewer_initial_connect(self, type, vvfile, ))
+if (!remote_viewer_initial_connect(self, type, guri, vvfile, 
))
 goto cleanup;
 }
 }
 
-
 ret = VIRT_VIEWER_APP_CLASS(remote_viewer_parent_class)->start(app, 
);
 
 cleanup:
-- 
2.13.6

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer] remote-viewer: Pass guri to remote_viewer_session_connected

2017-10-20 Thread Eduardo Lima (Etrunko)
On 20/10/17 15:10, Eduardo Lima (Etrunko) wrote:
> When connecting to a VM via oVirt instance, the original uri can not be
> retrieved using virt_viewer_session_get_uri(). Consequently, it was
> never saved, even though the connection succeeds and the actual callback
> for "session-connected" signal, which saves the URI, is invoked.
> 
> To solve this problem, we always pass a copy of the guri as user-data
> parameter for the callback, and if the call to
> virt_viewer_session_get_uri() returns NULL, the parameter is used
> instead.
> 
> Resolves: https://bugzilla.redhat.com/1459792
> 
> Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
> ---
>  src/remote-viewer.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/remote-viewer.c b/src/remote-viewer.c
> index 7834dac..7366fa1 100644
> --- a/src/remote-viewer.c
> +++ b/src/remote-viewer.c
> @@ -1075,13 +1075,17 @@ remote_viewer_recent_add(gchar *uri, const gchar 
> *mime_type)
>  
>  static void
>  remote_viewer_session_connected(VirtViewerSession *session,
> -VirtViewerApp *self G_GNUC_UNUSED)
> +gchar *guri)
>  {
>  gchar *uri = virt_viewer_session_get_uri(session);
>  const gchar *mime = virt_viewer_session_mime_type(session);
>  
> +if (uri == NULL)
> +uri = g_strdup(guri);
> +
>  remote_viewer_recent_add(uri, mime);
>  g_free(uri);
> +g_free(guri);
>  }
>  


I know this block looks a bit strange (at least to my eyes), but at
first it was like:

-remote_viewer_recent_add(uri, mime);
+if (uri == NULL)
+remote_viewer_recent_add(guri, mime);
+else
+remote_viewer_recent_add(uri, mime);
+
 g_free(uri);
+g_free(guri);
 }

Which also feels kind of odd, so I decided to go with the first one.
Either way, no preference here, either way is fine for me.


Regards, Eduardo.

-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer] remote-viewer: Pass guri to remote_viewer_session_connected

2017-10-20 Thread Eduardo Lima (Etrunko)
When connecting to a VM via oVirt instance, the original uri can not be
retrieved using virt_viewer_session_get_uri(). Consequently, it was
never saved, even though the connection succeeds and the actual callback
for "session-connected" signal, which saves the URI, is invoked.

To solve this problem, we always pass a copy of the guri as user-data
parameter for the callback, and if the call to
virt_viewer_session_get_uri() returns NULL, the parameter is used
instead.

Resolves: https://bugzilla.redhat.com/1459792

Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
---
 src/remote-viewer.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 7834dac..7366fa1 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -1075,13 +1075,17 @@ remote_viewer_recent_add(gchar *uri, const gchar 
*mime_type)
 
 static void
 remote_viewer_session_connected(VirtViewerSession *session,
-VirtViewerApp *self G_GNUC_UNUSED)
+gchar *guri)
 {
 gchar *uri = virt_viewer_session_get_uri(session);
 const gchar *mime = virt_viewer_session_mime_type(session);
 
+if (uri == NULL)
+uri = g_strdup(guri);
+
 remote_viewer_recent_add(uri, mime);
 g_free(uri);
+g_free(guri);
 }
 
 static gboolean
@@ -1169,7 +1173,7 @@ retry_dialog:
 }
 
 g_signal_connect(virt_viewer_app_get_session(app), "session-connected",
- G_CALLBACK(remote_viewer_session_connected), app);
+ G_CALLBACK(remote_viewer_session_connected), 
g_strdup(guri));
 
 virt_viewer_session_set_file(virt_viewer_app_get_session(app), vvfile);
 #ifdef HAVE_OVIRT
-- 
2.13.6

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer v2 0/4] Support for ovirt data center related functions

2017-10-06 Thread Eduardo Lima (Etrunko)
On 06/10/17 09:43, Victor Toso wrote:
> Ack
> 

Pushed, thanks

> - Original Message -
>> v2:
>>  - Check for new functions in configure.
>>  - Added #ifdef guards for the new functions.
>>
>> Eduardo Lima (Etrunko) (4):
>>   configure: check for new functions in libgovirt
>>   foreign-menu: Use query for fetching virtual machines
>>   ovirt-foreign-menu: Fetch host, cluster and data center information
>>   foreign-menu: Check if storage domain is active for data center
>>
>>  configure.ac |   4 +
>>  src/Makefile.am  |   2 +
>>  src/glib-compat.c|  35 +
>>  src/glib-compat.h|  39 ++
>>  src/ovirt-foreign-menu.c | 185
>>  +++
>>  5 files changed, 265 insertions(+)
>>  create mode 100644 src/glib-compat.c
>>  create mode 100644 src/glib-compat.h
>>
>> --
>> 2.13.6
>>
>> ___
>> virt-tools-list mailing list
>> virt-tools-list@redhat.com
>> https://www.redhat.com/mailman/listinfo/virt-tools-list
>>


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer v2 0/4] Support for ovirt data center related functions

2017-09-29 Thread Eduardo Lima (Etrunko)
v2:
 - Check for new functions in configure.
 - Added #ifdef guards for the new functions.

Eduardo Lima (Etrunko) (4):
  configure: check for new functions in libgovirt
  foreign-menu: Use query for fetching virtual machines
  ovirt-foreign-menu: Fetch host, cluster and data center information
  foreign-menu: Check if storage domain is active for data center

 configure.ac |   4 +
 src/Makefile.am  |   2 +
 src/glib-compat.c|  35 +
 src/glib-compat.h|  39 ++
 src/ovirt-foreign-menu.c | 185 +++
 5 files changed, 265 insertions(+)
 create mode 100644 src/glib-compat.c
 create mode 100644 src/glib-compat.h

-- 
2.13.6

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer v2 3/4] ovirt-foreign-menu: Fetch host, cluster and data center information

2017-09-29 Thread Eduardo Lima (Etrunko)
It is possible that the data center the VM is associated with has more
than one storage domain associated with it as well, when only one is
active while the others are not.

The current ovir-foreign-menu code does not take it into consideration,
thus the ISO dialog may show invalid results with that scenario. We fix
this problem by making use of new functions in libgovirt, adding support
or hosts, clusters and data centers.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1427467
 https://bugzilla.redhat.com/show_bug.cgi?id=1428401

Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
---
 src/ovirt-foreign-menu.c | 153 +++
 1 file changed, 153 insertions(+)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 8af3716..46486e6 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -34,6 +34,11 @@ typedef enum {
 STATE_0,
 STATE_API,
 STATE_VM,
+#ifdef HAVE_OVIRT_DATA_CENTER
+STATE_HOST,
+STATE_CLUSTER,
+STATE_DATA_CENTER,
+#endif
 STATE_STORAGE_DOMAIN,
 STATE_VM_CDROM,
 STATE_CDROM_FILE,
@@ -43,6 +48,11 @@ typedef enum {
 static void ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, GTask 
*task, OvirtForeignMenuState state);
 static void ovirt_foreign_menu_fetch_api_async(OvirtForeignMenu *menu, GTask 
*task);
 static void ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu, GTask 
*task);
+#ifdef HAVE_OVIRT_DATA_CENTER
+static void ovirt_foreign_menu_fetch_host_async(OvirtForeignMenu *menu, GTask 
*task);
+static void ovirt_foreign_menu_fetch_cluster_async(OvirtForeignMenu *menu, 
GTask *task);
+static void ovirt_foreign_menu_fetch_data_center_async(OvirtForeignMenu *menu, 
GTask *task);
+#endif
 static void ovirt_foreign_menu_fetch_storage_domain_async(OvirtForeignMenu 
*menu, GTask *task);
 static void ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu, 
GTask *task);
 static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu 
*menu, GTask *task);
@@ -55,6 +65,11 @@ struct _OvirtForeignMenuPrivate {
 OvirtProxy *proxy;
 OvirtApi *api;
 OvirtVm *vm;
+#ifdef HAVE_OVIRT_DATA_CENTER
+OvirtHost *host;
+OvirtCluster *cluster;
+OvirtDataCenter *data_center;
+#endif
 char *vm_guid;
 
 OvirtCollection *files;
@@ -184,6 +199,11 @@ ovirt_foreign_menu_dispose(GObject *obj)
 g_clear_object(>priv->proxy);
 g_clear_object(>priv->api);
 g_clear_object(>priv->vm);
+#ifdef HAVE_OVIRT_DATA_CENTER
+g_clear_object(>priv->host);
+g_clear_object(>priv->cluster);
+g_clear_object(>priv->data_center);
+#endif
 g_clear_pointer(>priv->vm_guid, g_free);
 g_clear_object(>priv->files);
 g_clear_object(>priv->cdrom);
@@ -300,6 +320,26 @@ ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu,
 ovirt_foreign_menu_fetch_vm_async(menu, task);
 break;
 }
+#ifdef HAVE_OVIRT_DATA_CENTER
+/* fall through */
+case STATE_HOST:
+if (menu->priv->host == NULL) {
+ovirt_foreign_menu_fetch_host_async(menu, task);
+break;
+}
+/* fall through */
+case STATE_CLUSTER:
+if (menu->priv->cluster == NULL) {
+ovirt_foreign_menu_fetch_cluster_async(menu, task);
+break;
+}
+/* fall through */
+case STATE_DATA_CENTER:
+if (menu->priv->data_center == NULL) {
+ovirt_foreign_menu_fetch_data_center_async(menu, task);
+break;
+}
+#endif
 /* fall through */
 case STATE_STORAGE_DOMAIN:
 if (menu->priv->files == NULL) {
@@ -650,6 +690,119 @@ static void 
ovirt_foreign_menu_fetch_storage_domain_async(OvirtForeignMenu *menu
 }
 
 
+#ifdef HAVE_OVIRT_DATA_CENTER
+static void data_center_fetched_cb(GObject *source_object,
+   GAsyncResult *result,
+   gpointer user_data)
+{
+GError *error = NULL;
+GTask *task = G_TASK(user_data);
+OvirtForeignMenu *menu = 
OVIRT_FOREIGN_MENU(g_task_get_source_object(task));
+OvirtResource *resource = OVIRT_RESOURCE(source_object);
+
+ovirt_resource_refresh_finish(resource, result, );
+if (error != NULL) {
+g_debug("failed to fetch Data Center: %s", error->message);
+g_task_return_error(task, error);
+g_object_unref(task);
+return;
+}
+
+ovirt_foreign_menu_next_async_step(menu, task, STATE_DATA_CENTER);
+}
+
+
+static void ovirt_foreign_menu_fetch_data_center_async(OvirtForeignMenu *menu,
+   GTask *task)
+{
+g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
+g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
+g_return_if_fail(OVIRT_IS_CLUSTER(menu->priv->cluster));
+
+menu->priv->data_

[virt-tools-list] [PATCH virt-viewer v2 2/4] foreign-menu: Use query for fetching virtual machines

2017-09-29 Thread Eduardo Lima (Etrunko)
This can save us some bandwidth, as we are searching for the specific
virtual machine instead of retrieving the collection with all VMs, and
then iterating over the results after the transfer finishes.

Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
---
 src/ovirt-foreign-menu.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index fdfd327..8af3716 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -701,7 +701,14 @@ static void 
ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu,
 g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
 g_return_if_fail(OVIRT_IS_API(menu->priv->api));
 
+#ifdef HAVE_OVIRT_API_SEARCH_VMS
+char * query = g_strdup_printf("id=%s", menu->priv->vm_guid);
+vms = ovirt_api_search_vms(menu->priv->api, query);
+g_free(query);
+#else
 vms = ovirt_api_get_vms(menu->priv->api);
+#endif
+
 ovirt_collection_fetch_async(vms, menu->priv->proxy,
  g_task_get_cancellable(task),
  vms_fetched_cb, task);
-- 
2.13.6

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer v2 1/4] configure: check for new functions in libgovirt

2017-09-29 Thread Eduardo Lima (Etrunko)
These functions will be used in ovirt-foreign-menu code and guarded
by #ifdef blocks so that we can keep compatibility with older libgovirt
versions.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1427467
 https://bugzilla.redhat.com/show_bug.cgi?id=1428401

Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
---
 configure.ac | 4 
 1 file changed, 4 insertions(+)

diff --git a/configure.ac b/configure.ac
index 9ca6cb6..61374fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -190,6 +190,10 @@ AS_IF([test "x$with_ovirt" = "xyes"],
  void *fun = rest_proxy_auth_cancel;])],
 [AC_DEFINE([HAVE_OVIRT_CANCEL], 1, [Have rest_proxy_auth_cancel and 
OVIRT_REST_CALL_ERROR_CANCELLED?])],
 [])
+   AC_CHECK_FUNCS([ovirt_api_search_vms ovirt_vm_get_host 
ovirt_host_get_cluster ovirt_cluster_get_data_center],
+  [AC_DEFINE([HAVE_OVIRT_DATA_CENTER], 1, [Have support 
for data center])],
+  []
+  )
CFLAGS="$SAVED_CFLAGS"
LIBS="$SAVED_LIBS"]
 )
-- 
2.13.6

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer v2 4/4] foreign-menu: Check if storage domain is active for data center

2017-09-29 Thread Eduardo Lima (Etrunko)
This last patch of the series is where we actually check if the storage
domain is active in the data center the VM is associated with. It makes
use of g_strv_contains(), which is available only in glib version 2.44.
Compatibility code has been added if building against older versions
than required.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1427467
 https://bugzilla.redhat.com/show_bug.cgi?id=1428401

Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
---
 src/Makefile.am  |  2 ++
 src/glib-compat.c| 35 +++
 src/glib-compat.h| 39 +++
 src/ovirt-foreign-menu.c | 25 +
 4 files changed, 101 insertions(+)
 create mode 100644 src/glib-compat.c
 create mode 100644 src/glib-compat.h

diff --git a/src/Makefile.am b/src/Makefile.am
index e87bcc7..b9e3421 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,6 +54,8 @@ libvirt_viewer_util_la_SOURCES = \
 
 libvirt_viewer_la_SOURCES =\
$(BUILT_SOURCES)\
+   glib-compat.h   \
+   glib-compat.c   \
virt-viewer-auth.h  \
virt-viewer-auth.c  \
virt-viewer-app.h   \
diff --git a/src/glib-compat.c b/src/glib-compat.c
new file mode 100644
index 000..62ac87e
--- /dev/null
+++ b/src/glib-compat.c
@@ -0,0 +1,35 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+#include 
+
+#include "glib-compat.h"
+
+#if !GLIB_CHECK_VERSION(2,44,0)
+gboolean
+g_strv_contains (const gchar * const *strv,
+ const gchar *str)
+{
+  g_return_val_if_fail (strv != NULL, FALSE);
+  g_return_val_if_fail (str != NULL, FALSE);
+
+  for (; *strv != NULL; strv++)
+{
+  if (g_str_equal (str, *strv))
+return TRUE;
+}
+
+  return FALSE;
+}
+#endif
diff --git a/src/glib-compat.h b/src/glib-compat.h
new file mode 100644
index 000..f1b43ae
--- /dev/null
+++ b/src/glib-compat.h
@@ -0,0 +1,39 @@
+/*
+ * Virt Viewer: A virtual machine console viewer
+ *
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Eduardo Lima (Etrunko) <etru...@redhat.com>
+ */
+
+#include 
+
+#ifndef GLIB_COMPAT_H
+#define GLIB_COMPAT_H 1
+
+#include 
+
+G_BEGIN_DECLS
+
+#if !GLIB_CHECK_VERSION(2,44,0)
+gboolean  g_strv_contains  (const gchar * const *strv,
+const gchar *str);
+#endif
+
+G_END_DECLS
+
+#endif // GLIB_COMPAT_H
diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 46486e6..cd1b8bd 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -29,6 +29,7 @@
 
 #include "ovirt-foreign-menu.h"
 #include "virt-viewer-util.h"
+#include "glib-compat.h"
 
 typedef enum {
 STATE_0,
@@ -621,6 +622,24 @@ static void 
ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu,
  cdroms_fetched_cb, task);
 }
 
+#ifdef HAVE_OVIRT_DATA_CENTER
+static gboolean storage_domain_attached_to_data_center(OvirtStorageDomain 
*domain,
+  OvirtDataCenter 
*data_center)
+{
+GStrv data_center_ids;
+char *data_center_guid;
+gboolean match;
+
+g_object_get(domain, "data-center-ids", _center_ids, NULL);
+g_object_get(data_center, "guid", _center_guid, NULL);
+match = g_strv_contain

Re: [virt-tools-list] [PATCH virt-viewer 1/3] foreign-menu: Use query for fetching virtual machines

2017-08-07 Thread Eduardo Lima (Etrunko)
On 06/08/17 18:53, Pavel Grunt wrote:
> Hi,
> 
> 2017-08-04 23:53 GMT+02:00 Eduardo Lima (Etrunko) <etru...@redhat.com
> <mailto:etru...@redhat.com>>:
> 
> This can save us some bandwidth, as we are searching for the specific
> virtual machine instead of retrieving the collection with all VMs, and
> then iterating over the results after the transfer finishes.
> 
> Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com
> <mailto:etru...@redhat.com>>
> ---
>  src/ovirt-foreign-menu.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
> index fdfd327..539f716 100644
> --- a/src/ovirt-foreign-menu.c
> +++ b/src/ovirt-foreign-menu.c
> @@ -696,12 +696,16 @@ static void
> ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu,
>GTask *task)
>  {
>  OvirtCollection *vms;
> +char *query;
> 
> g_strdup_printf returns gchar *

Fixed.

>  
> 
> 
>  g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
>  g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
>  g_return_if_fail(OVIRT_IS_API(menu->priv->api));
> 
> -vms = ovirt_api_get_vms(menu->priv->api);
> +query = g_strdup_printf("id=%s", menu->priv->vm_guid);
> +vms = ovirt_api_search_vms(menu->priv->api, query);
> 
> it looks like api from unreleased version of libgovirt, remote-viewer
> depends on libgovirt 0.3.2
>  
> 
> +g_free(query);
> +
>  ovirt_collection_fetch_async(vms, menu->priv->proxy,
>   g_task_get_cancellable(task),
>   vms_fetched_cb, task);
> 
> 
> You can go for AC_CHECK_FUNCS and do it conditionally based on the
> function presence to keep it builldable on distros not shipping the very
> recent libgovirt
> 
> IMHO would be better to have a release of libgovirt to make the new api
> stable :) (However I'd still consider using the `#ifdef
> |HAVE_OVIRT_API_SEARCH_VMS` check)

Yeah, the idea is to release libgovirt soon and update the requirements
in configure.ac, but there are still some pending patches there to be
merged. I've sent this patch series because most of the API changes have
already been merged and it is possible to test against the latest git
master.

Regards, Eduardo.

-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [PATCH virt-viewer 3/3] foreign-menu: Check if storage domain is active for data center

2017-08-04 Thread Eduardo Lima (Etrunko)
This patch makes use of g_strv_contains(), which is available only in
glib version 2.44. Compatibility code has been added if building against
older versions than required.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1427467
 https://bugzilla.redhat.com/show_bug.cgi?id=1428401

Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
---
 src/Makefile.am  |  2 ++
 src/glib-compat.c| 35 +++
 src/glib-compat.h| 39 +++
 src/ovirt-foreign-menu.c | 22 ++
 4 files changed, 98 insertions(+)
 create mode 100644 src/glib-compat.c
 create mode 100644 src/glib-compat.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 9748277..b3eea67 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,6 +54,8 @@ libvirt_viewer_util_la_SOURCES = \
 
 libvirt_viewer_la_SOURCES =\
$(BUILT_SOURCES)\
+   glib-compat.h   \
+   glib-compat.c   \
virt-viewer-auth.h  \
virt-viewer-auth.c  \
virt-viewer-app.h   \
diff --git a/src/glib-compat.c b/src/glib-compat.c
new file mode 100644
index 000..62ac87e
--- /dev/null
+++ b/src/glib-compat.c
@@ -0,0 +1,35 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+#include 
+
+#include "glib-compat.h"
+
+#if !GLIB_CHECK_VERSION(2,44,0)
+gboolean
+g_strv_contains (const gchar * const *strv,
+ const gchar *str)
+{
+  g_return_val_if_fail (strv != NULL, FALSE);
+  g_return_val_if_fail (str != NULL, FALSE);
+
+  for (; *strv != NULL; strv++)
+{
+  if (g_str_equal (str, *strv))
+return TRUE;
+}
+
+  return FALSE;
+}
+#endif
diff --git a/src/glib-compat.h b/src/glib-compat.h
new file mode 100644
index 000..f1b43ae
--- /dev/null
+++ b/src/glib-compat.h
@@ -0,0 +1,39 @@
+/*
+ * Virt Viewer: A virtual machine console viewer
+ *
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Eduardo Lima (Etrunko) <etru...@redhat.com>
+ */
+
+#include 
+
+#ifndef GLIB_COMPAT_H
+#define GLIB_COMPAT_H 1
+
+#include 
+
+G_BEGIN_DECLS
+
+#if !GLIB_CHECK_VERSION(2,44,0)
+gboolean  g_strv_contains  (const gchar * const *strv,
+const gchar *str);
+#endif
+
+G_END_DECLS
+
+#endif // GLIB_COMPAT_H
diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 32c6452..6403a0b 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -29,6 +29,7 @@
 
 #include "ovirt-foreign-menu.h"
 #include "virt-viewer-util.h"
+#include "glib-compat.h"
 
 typedef enum {
 STATE_0,
@@ -612,6 +613,23 @@ static void 
ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu,
 }
 
 
+static gboolean storage_domain_active_for_data_center(OvirtStorageDomain 
*domain,
+  OvirtDataCenter 
*data_center)
+{
+GStrv data_center_ids;
+char *data_center_guid;
+gboolean match;
+
+g_object_get(domain, "data-center-ids", _center_ids, NULL);
+g_object_get(data_center, "guid", _center_guid, NULL);
+match = g_strv_contains((const gchar * const *) data_center_ids, 
data_center_guid);
+g_strfreev(data_center_ids);
+g_free(data_center_guid);
+
+return match;
+}
+
+
 static void storage_domains_fetched_cb(GObjec

[virt-tools-list] [PATCH virt-viewer 2/3] ovirt-foreign-menu: Fetch host, cluster and data center information

2017-08-04 Thread Eduardo Lima (Etrunko)
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1427467
 https://bugzilla.redhat.com/show_bug.cgi?id=1428401

Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
---
 src/ovirt-foreign-menu.c | 141 +++
 1 file changed, 141 insertions(+)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 539f716..32c6452 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -34,6 +34,9 @@ typedef enum {
 STATE_0,
 STATE_API,
 STATE_VM,
+STATE_HOST,
+STATE_CLUSTER,
+STATE_DATA_CENTER,
 STATE_STORAGE_DOMAIN,
 STATE_VM_CDROM,
 STATE_CDROM_FILE,
@@ -43,6 +46,9 @@ typedef enum {
 static void ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu, GTask 
*task, OvirtForeignMenuState state);
 static void ovirt_foreign_menu_fetch_api_async(OvirtForeignMenu *menu, GTask 
*task);
 static void ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu, GTask 
*task);
+static void ovirt_foreign_menu_fetch_host_async(OvirtForeignMenu *menu, GTask 
*task);
+static void ovirt_foreign_menu_fetch_cluster_async(OvirtForeignMenu *menu, 
GTask *task);
+static void ovirt_foreign_menu_fetch_data_center_async(OvirtForeignMenu *menu, 
GTask *task);
 static void ovirt_foreign_menu_fetch_storage_domain_async(OvirtForeignMenu 
*menu, GTask *task);
 static void ovirt_foreign_menu_fetch_vm_cdrom_async(OvirtForeignMenu *menu, 
GTask *task);
 static void ovirt_foreign_menu_refresh_cdrom_file_async(OvirtForeignMenu 
*menu, GTask *task);
@@ -55,6 +61,9 @@ struct _OvirtForeignMenuPrivate {
 OvirtProxy *proxy;
 OvirtApi *api;
 OvirtVm *vm;
+OvirtHost *host;
+OvirtCluster *cluster;
+OvirtDataCenter *data_center;
 char *vm_guid;
 
 OvirtCollection *files;
@@ -184,6 +193,9 @@ ovirt_foreign_menu_dispose(GObject *obj)
 g_clear_object(>priv->proxy);
 g_clear_object(>priv->api);
 g_clear_object(>priv->vm);
+g_clear_object(>priv->host);
+g_clear_object(>priv->cluster);
+g_clear_object(>priv->data_center);
 g_clear_pointer(>priv->vm_guid, g_free);
 g_clear_object(>priv->files);
 g_clear_object(>priv->cdrom);
@@ -301,6 +313,24 @@ ovirt_foreign_menu_next_async_step(OvirtForeignMenu *menu,
 break;
 }
 /* fall through */
+case STATE_HOST:
+if (menu->priv->host == NULL) {
+ovirt_foreign_menu_fetch_host_async(menu, task);
+break;
+}
+/* fall through */
+case STATE_CLUSTER:
+if (menu->priv->cluster == NULL) {
+ovirt_foreign_menu_fetch_cluster_async(menu, task);
+break;
+}
+/* fall through */
+case STATE_DATA_CENTER:
+if (menu->priv->data_center == NULL) {
+ovirt_foreign_menu_fetch_data_center_async(menu, task);
+break;
+}
+/* fall through */
 case STATE_STORAGE_DOMAIN:
 if (menu->priv->files == NULL) {
 ovirt_foreign_menu_fetch_storage_domain_async(menu, task);
@@ -650,6 +680,117 @@ static void 
ovirt_foreign_menu_fetch_storage_domain_async(OvirtForeignMenu *menu
 }
 
 
+static void data_center_fetched_cb(GObject *source_object,
+   GAsyncResult *result,
+   gpointer user_data)
+{
+GError *error = NULL;
+GTask *task = G_TASK(user_data);
+OvirtForeignMenu *menu = 
OVIRT_FOREIGN_MENU(g_task_get_source_object(task));
+OvirtResource *resource = OVIRT_RESOURCE(source_object);
+
+ovirt_resource_refresh_finish(resource, result, );
+if (error != NULL) {
+g_debug("failed to fetch Data Center: %s", error->message);
+g_task_return_error(task, error);
+g_object_unref(task);
+return;
+}
+
+ovirt_foreign_menu_next_async_step(menu, task, STATE_DATA_CENTER);
+}
+
+
+static void ovirt_foreign_menu_fetch_data_center_async(OvirtForeignMenu *menu,
+   GTask *task)
+{
+g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
+g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
+g_return_if_fail(OVIRT_IS_CLUSTER(menu->priv->cluster));
+
+menu->priv->data_center = 
ovirt_cluster_get_data_center(menu->priv->cluster);
+ovirt_resource_refresh_async(OVIRT_RESOURCE(menu->priv->data_center),
+ menu->priv->proxy,
+ g_task_get_cancellable(task),
+ data_center_fetched_cb,
+ task);
+}
+
+
+static void cluster_fetched_cb(GObject *source_object,
+   GAsyncResult *result,
+   gpointer user_data)
+{
+GError *error = NULL;
+GTask *task = G_TASK(user_data);
+Ovir

[virt-tools-list] [PATCH virt-viewer 1/3] foreign-menu: Use query for fetching virtual machines

2017-08-04 Thread Eduardo Lima (Etrunko)
This can save us some bandwidth, as we are searching for the specific
virtual machine instead of retrieving the collection with all VMs, and
then iterating over the results after the transfer finishes.

Signed-off-by: Eduardo Lima (Etrunko) <etru...@redhat.com>
---
 src/ovirt-foreign-menu.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index fdfd327..539f716 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -696,12 +696,16 @@ static void 
ovirt_foreign_menu_fetch_vm_async(OvirtForeignMenu *menu,
   GTask *task)
 {
 OvirtCollection *vms;
+char *query;
 
 g_return_if_fail(OVIRT_IS_FOREIGN_MENU(menu));
 g_return_if_fail(OVIRT_IS_PROXY(menu->priv->proxy));
 g_return_if_fail(OVIRT_IS_API(menu->priv->api));
 
-vms = ovirt_api_get_vms(menu->priv->api);
+query = g_strdup_printf("id=%s", menu->priv->vm_guid);
+vms = ovirt_api_search_vms(menu->priv->api, query);
+g_free(query);
+
 ovirt_collection_fetch_async(vms, menu->priv->proxy,
  g_task_get_cancellable(task),
  vms_fetched_cb, task);
-- 
2.13.4

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [PATCH virt-viewer 5/6] remote-viewer: add a --dbus-controller

2017-06-28 Thread Eduardo Lima (Etrunko)
On 23/06/17 12:30, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Allow to set connection details via DBus, and add a Connect method.
> This is intended to replace the Spice controller.
> 
> Sample usage:
> 
> DEST=`remote-viewer --dbus-controller`
> 
> gdbus call --session --dest $DEST --object-path 
> /org/virt_manager/remote_viewer \
>   --method org.freedesktop.DBus.Properties.Set 
> org.VirtManager.RemoteViewer.Controller \
>   host ''
> gdbus call --session --dest $DEST --object-path 
> /org/virt_manager/remote_viewer \
>   --method org.freedesktop.DBus.Properties.Set 
> org.VirtManager.RemoteViewer.Controller \
>   port ''
> gdbus call --session --dest $DEST --object-path 
> /org/virt_manager/remote_viewer \
>   --method org.freedesktop.DBus.Properties.Set 
> org.VirtManager.RemoteViewer.Controller \
>   type ''()
> gdbus call --session --dest $DEST --object-path 
> /org/virt_manager/remote_viewer \
>   --method org.VirtManager.RemoteViewer.Controller.Connect()
> 

Please consider spliting this patch, as I said on my comment on patch 3
of the series.

> Signed-off-by: Marc-André Lureau 
> ---
>  src/remote-viewer.c | 198 
> +++-
>  src/remote-viewer.h |   1 +
>  2 files changed, 196 insertions(+), 3 deletions(-)
> 
> diff --git a/src/remote-viewer.c b/src/remote-viewer.c
> index fb5376c..f0f9531 100644
> --- a/src/remote-viewer.c
> +++ b/src/remote-viewer.c
> @@ -57,6 +57,7 @@ struct _RemoteViewerPrivate {
>  OvirtForeignMenu *ovirt_foreign_menu;
>  #endif
>  gboolean open_recent_dialog;
> +VirtViewerFile *dbus_file;
>  };
>  
>  G_DEFINE_TYPE (RemoteViewer, remote_viewer, VIRT_VIEWER_TYPE_APP)
> @@ -137,6 +138,7 @@ remote_viewer_deactivated(VirtViewerApp *app, gboolean 
> connect_error)
>  static gchar **opt_args = NULL;
>  static char *opt_title = NULL;
>  static gboolean opt_controller = FALSE;
> +static gboolean opt_dbus_ctrl = FALSE;
>  
>  static void
>  remote_viewer_add_option_entries(VirtViewerApp *self, GOptionContext 
> *context, GOptionGroup *group)
> @@ -144,6 +146,8 @@ remote_viewer_add_option_entries(VirtViewerApp *self, 
> GOptionContext *context, G
>  static const GOptionEntry options[] = {
>  { "title", 't', 0, G_OPTION_ARG_STRING, _title,
>N_("Set window title"), NULL },
> +{ "dbus-controller", '\0', 0, G_OPTION_ARG_NONE, _dbus_ctrl,
> +  N_("Open connection using DBus controller"), NULL },
>  #ifdef HAVE_SPICE_GTK
>  { "spice-controller", '\0', 0, G_OPTION_ARG_NONE, _controller,
>N_("Open connection using Spice controller communication"), NULL },
> @@ -175,7 +179,17 @@ remote_viewer_local_command_line (GApplication   *gapp,
>  if (ret)
>  goto end;
>  
> -if (!opt_args) {
> +if (opt_dbus_ctrl) {
> +if (opt_args || opt_controller) {
> +g_printerr(_("\nError: extra arguments given while using 
> --dbus\n\n"));
> +ret = TRUE;
> +*status = 1;
> +goto end;
> +}
> +self->priv->dbus_file = virt_viewer_file_new(NULL, NULL);
> +virt_viewer_app_set_dbus_ctrl(app, TRUE);
> +return FALSE;
> +} else if (!opt_args) {
>  self->priv->open_recent_dialog = TRUE;
>  } else {
>  if (g_strv_length(opt_args) > 1) {
> @@ -190,7 +204,7 @@ remote_viewer_local_command_line (GApplication   *gapp,
>  
>  #ifdef HAVE_SPICE_GTK
>  if (opt_controller) {
> -if (opt_args) {
> +if (opt_args || opt_dbus_ctrl) {
>  g_printerr(_("\nError: extra arguments given while using Spice 
> controller\n\n"));
>  ret = TRUE;
>  *status = 1;
> @@ -241,6 +255,180 @@ remote_viewer_get_property(GObject *object, guint 
> property_id,
>  }
>  }
>  
> +static void
> +handle_method_call (GDBusConnection   *connection G_GNUC_UNUSED,
> +const gchar   *sender G_GNUC_UNUSED,
> +const gchar   *object_path G_GNUC_UNUSED,
> +const gchar   *interface_name G_GNUC_UNUSED,
> +const gchar   *method_name,
> +GVariant  *parameters G_GNUC_UNUSED,
> +GDBusMethodInvocation *invocation,
> +gpointer   user_data)
> +{
> +RemoteViewer *self = REMOTE_VIEWER(user_data);
> +
> +if (g_str_equal(method_name, "Connect")) {
> +GError *error = NULL;
> +char *type = virt_viewer_file_get_file_type(self->priv->dbus_file);
> +g_debug("Connect! %s", type);
> +if (!remote_viewer_initial_connect(self, type, 
> self->priv->dbus_file, )) {
> +g_dbus_method_invocation_return_gerror(invocation, error);
> +g_clear_error();
> +} else {
> +g_dbus_method_invocation_return_value (invocation, NULL);
> +}
> +   

Re: [virt-tools-list] [PATCH virt-viewer 4/6] remote-viewer: factor our remote_viewer_initial_connect()

2017-06-28 Thread Eduardo Lima (Etrunko)
On 23/06/17 12:30, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lur...@redhat.com>
> 

Acked-by: Eduardo Lima (Etrunko) <etru...@redhat.com>

> Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com>
> ---
>  src/remote-viewer.c | 70 
> -
>  1 file changed, 43 insertions(+), 27 deletions(-)
> 
> diff --git a/src/remote-viewer.c b/src/remote-viewer.c
> index b132214..fb5376c 100644
> --- a/src/remote-viewer.c
> +++ b/src/remote-viewer.c
> @@ -85,6 +85,10 @@ static void spice_foreign_menu_updated(RemoteViewer *self);
>  static void foreign_menu_title_changed(SpiceCtrlForeignMenu *menu, 
> GParamSpec *pspec, RemoteViewer *self);
>  #endif
>  
> +static gboolean
> +remote_viewer_initial_connect(RemoteViewer *self, const gchar *type,
> +  VirtViewerFile *vvfile, GError **error);
> +
>  static void
>  remote_viewer_dispose (GObject *object)
>  {
> @@ -1080,6 +1084,41 @@ remote_viewer_session_connected(VirtViewerSession 
> *session,
>  g_free(uri);
>  }
>  
> +static gboolean
> +remote_viewer_initial_connect(RemoteViewer *self, const gchar *type,
> +  VirtViewerFile *vvfile, GError **error)
> +{
> +VirtViewerApp *app = VIRT_VIEWER_APP(self);
> +
> +if (!virt_viewer_app_create_session(app, type, error))
> +return FALSE;
> +
> +g_signal_connect(virt_viewer_app_get_session(app), "session-connected",
> + G_CALLBACK(remote_viewer_session_connected), app);
> +
> +virt_viewer_session_set_file(virt_viewer_app_get_session(app), vvfile);
> +#ifdef HAVE_OVIRT
> +if (vvfile != NULL) {
> +OvirtForeignMenu *ovirt_menu;
> +ovirt_menu = ovirt_foreign_menu_new_from_file(vvfile);
> +if (ovirt_menu != NULL) {
> +virt_viewer_app_set_ovirt_foreign_menu(app, ovirt_menu);
> +}
> +}
> +#endif
> +
> +if (!virt_viewer_app_initial_connect(app, error)) {
> +if (*error == NULL) {
> +g_set_error_literal(error,
> +VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_FAILED,
> +_("Failed to initiate connection"));
> +}
> +return FALSE;
> +}
> +
> +return TRUE;
> +}
> +
>  static gboolean
>  remote_viewer_start(VirtViewerApp *app, GError **err)
>  {
> @@ -1114,8 +1153,9 @@ remote_viewer_start(VirtViewerApp *app, GError **err)
>  spice_ctrl_foreign_menu_listen(priv->ctrl_foreign_menu, NULL, 
> spice_ctrl_listen_async_cb, self);
>  
>  virt_viewer_app_show_status(VIRT_VIEWER_APP(self), _("Setting up 
> Spice session..."));
> -} else {
> +} else
>  #endif
> +{
>  retry_dialog:
>  if (priv->open_recent_dialog) {
>  VirtViewerWindow *main_window = 
> virt_viewer_app_get_main_window(app);
> @@ -1160,35 +1200,11 @@ retry_dialog:
>  } else
>  #endif
>  {
> -if (!virt_viewer_app_create_session(app, type, ))
> +if (!remote_viewer_initial_connect(self, type, vvfile, ))
>  goto cleanup;
>  }
> -
> -g_signal_connect(virt_viewer_app_get_session(app), 
> "session-connected",
> - G_CALLBACK(remote_viewer_session_connected), app);
> -
> -virt_viewer_session_set_file(virt_viewer_app_get_session(app), 
> vvfile);
> -#ifdef HAVE_OVIRT
> -if (vvfile != NULL) {
> -OvirtForeignMenu *ovirt_menu;
> -ovirt_menu = ovirt_foreign_menu_new_from_file(vvfile);
> -if (ovirt_menu != NULL) {
> -virt_viewer_app_set_ovirt_foreign_menu(app, ovirt_menu);
> -}
> -}
> -#endif
> -
> -if (!virt_viewer_app_initial_connect(app, )) {
> -if (error == NULL) {
> -g_set_error_literal(,
> -VIRT_VIEWER_ERROR, 
> VIRT_VIEWER_ERROR_FAILED,
> -_("Failed to initiate connection"));
> -}
> -goto cleanup;
> -}
> -#ifdef HAVE_SPICE_GTK
>  }
> -#endif
> +
>  
>  ret = VIRT_VIEWER_APP_CLASS(remote_viewer_parent_class)->start(app, 
> );
>  
> 


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

Re: [virt-tools-list] [PATCH virt-viewer 3/6] app: add dbus-ctrl property

2017-06-28 Thread Eduardo Lima (Etrunko)
On 23/06/17 12:30, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> If the dbus-ctrl property is set, we should call open_uri() without
> guri set.
> 

My general feeling is that this patch could be merged with the option
parsing on the follow up patch, while that one should split in two, the
first one adding the dbus handlers and the only after that option
parsing/property setting/open_uri() call.

> Signed-off-by: Marc-André Lureau 
> ---
>  src/virt-viewer-app.c | 12 
>  src/virt-viewer-app.h |  1 +
>  2 files changed, 13 insertions(+)
> 
> diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
> index 2a2..c770cc0 100644
> --- a/src/virt-viewer-app.c
> +++ b/src/virt-viewer-app.c
> @@ -130,6 +130,7 @@ struct _VirtViewerAppPrivate {
>  gboolean active;
>  gboolean connected;
>  gboolean cancelled;
> +gboolean dbus_ctrl;
>  char *unixsock;
>  char *guri; /* prefered over ghost:gport */
>  char *ghost;
> @@ -1225,6 +1226,9 @@ virt_viewer_app_default_activate(VirtViewerApp *self, 
> GError **error)
>  
>  if (fd >= 0) {
>  return 
> virt_viewer_session_open_fd(VIRT_VIEWER_SESSION(priv->session), fd);
> +} else if (priv->dbus_ctrl) {
> +/* open_uri handles session set with vv file */
> +return 
> virt_viewer_session_open_uri(VIRT_VIEWER_SESSION(priv->session), NULL, error);
>  } else if (priv->guri) {
>  virt_viewer_app_trace(self, "Opening connection to display at %s", 
> priv->guri);
>  return 
> virt_viewer_session_open_uri(VIRT_VIEWER_SESSION(priv->session), priv->guri, 
> error);
> @@ -2036,6 +2040,14 @@ virt_viewer_app_class_init (VirtViewerAppClass *klass)
>  
> G_PARAM_STATIC_STRINGS));
>  }
>  
> +void
> +virt_viewer_app_set_dbus_ctrl(VirtViewerApp *self, gboolean dbus_ctrl)
> +{
> +g_return_if_fail(VIRT_VIEWER_IS_APP(self));
> +
> +self->priv->dbus_ctrl = dbus_ctrl;
> +}
> +
>  void
>  virt_viewer_app_set_direct(VirtViewerApp *self, gboolean direct)
>  {
> diff --git a/src/virt-viewer-app.h b/src/virt-viewer-app.h
> index 16b1c8c..6f6d9c8 100644
> --- a/src/virt-viewer-app.h
> +++ b/src/virt-viewer-app.h
> @@ -98,6 +98,7 @@ void virt_viewer_app_set_enable_accel(VirtViewerApp *app, 
> gboolean enable);
>  void virt_viewer_app_show_preferences(VirtViewerApp *app, GtkWidget *parent);
>  void virt_viewer_app_set_menus_sensitive(VirtViewerApp *self, gboolean 
> sensitive);
>  gboolean virt_viewer_app_get_session_cancelled(VirtViewerApp *self);
> +void virt_viewer_app_set_dbus_ctrl(VirtViewerApp *self, gboolean dbus_ctrl);
>  
>  G_END_DECLS
>  
> 


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

Re: [virt-tools-list] [PATCH virt-viewer 2/6] session: remove virt_viewer_session_new() declaration

2017-06-28 Thread Eduardo Lima (Etrunko)
On 23/06/17 12:30, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lur...@redhat.com>
> 
> The function was removed in commit
> 05333f0e93fb988c2fd9302e67671490941aedb0.

Acked-by: Eduardo Lima (Etrunko) <etru...@redhat.com>

> 
> Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com>
> ---
>  src/virt-viewer-session.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/src/virt-viewer-session.h b/src/virt-viewer-session.h
> index d3a9ccc..8ee4d8a 100644
> --- a/src/virt-viewer-session.h
> +++ b/src/virt-viewer-session.h
> @@ -102,7 +102,6 @@ struct _VirtViewerSessionClass {
>  
>  GType virt_viewer_session_get_type(void);
>  
> -GtkWidget *virt_viewer_session_new(void);
>  const gchar* virt_viewer_session_mime_type(VirtViewerSession *session);
>  
>  void virt_viewer_session_add_display(VirtViewerSession *session,
> 


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etru...@redhat.com

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

  1   2   3   4   >