[virt-tools-list] [PATCH] build-sys: lower spice-gtk requirement to 0.35 again

2019-02-04 Thread marcandre . lureau
From: Marc-André Lureau 

Compile out QMP channel support if spice-gtk version < 0.36.

(note: I didn't bother adding configure switch to enable it
explicitly, this could be added later if necessary)

Signed-off-by: Marc-André Lureau 
---
 configure.ac|  2 +-
 src/virt-viewer-session-spice.c | 18 --
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 50cd91a..5598c61 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,7 @@ 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.36"
+SPICE_GTK_REQUIRED="0.35"
 SPICE_PROTOCOL_REQUIRED="0.12.7"
 GOVIRT_REQUIRED="0.3.3"
 REST_REQUIRED="0.8"
diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index 0c58133..c28afc5 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -37,6 +37,10 @@
 #include "virt-viewer-display-vte.h"
 #include "virt-viewer-auth.h"
 
+#if SPICE_GTK_CHECK_VERSION(0,36,0)
+#define WITH_QMP_PORT 1
+#endif
+
 G_DEFINE_TYPE (VirtViewerSessionSpice, virt_viewer_session_spice, 
VIRT_VIEWER_TYPE_SESSION)
 
 struct _VirtViewerSessionSpicePrivate {
@@ -52,7 +56,9 @@ struct _VirtViewerSessionSpicePrivate {
 gboolean did_auto_conf;
 VirtViewerFileTransferDialog *file_transfer_dialog;
 GError *disconnect_error;
+#ifdef WITH_QMP_PORT
 SpiceQmpPort *qmp;
+#endif
 };
 
 #define VIRT_VIEWER_SESSION_SPICE_GET_PRIVATE(o) 
(G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_SESSION_SPICE, 
VirtViewerSessionSpicePrivate))
@@ -464,8 +470,9 @@ virt_viewer_session_spice_close(VirtViewerSession *session)
 
 g_object_add_weak_pointer(G_OBJECT(self), (gpointer*)&self);
 
+#ifdef WITH_QMP_PORT
 g_clear_object(&self->priv->qmp);
-
+#endif
 virt_viewer_session_spice_clear_displays(self);
 
 if (self->priv->session) {
@@ -1016,8 +1023,10 @@ port_name_to_vte_name(const char *name)
 }
 
 static void
-virt_viewer_session_spice_vm_action(VirtViewerSession *sess, gint action)
+virt_viewer_session_spice_vm_action(VirtViewerSession *sess G_GNUC_UNUSED,
+gint action G_GNUC_UNUSED)
 {
+#ifdef WITH_QMP_PORT
 VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(sess);
 
 switch (action) {
@@ -1041,8 +1050,10 @@ virt_viewer_session_spice_vm_action(VirtViewerSession 
*sess, gint action)
 }
 
 spice_qmp_port_vm_action_async(self->priv->qmp, action, NULL, NULL, NULL);
+#endif
 }
 
+#ifdef WITH_QMP_PORT
 static void
 set_vm_running(VirtViewerSessionSpice *self, gboolean running)
 {
@@ -1093,6 +1104,7 @@ static void qmp_event_cb(VirtViewerSessionSpice *self, 
const gchar *event,
 set_vm_running(self, TRUE);
 }
 }
+#endif /* WITH_QMP_PORT */
 
 static void
 spice_port_opened(SpiceChannel *channel, GParamSpec *pspec G_GNUC_UNUSED,
@@ -1115,6 +1127,7 @@ spice_port_opened(SpiceChannel *channel, GParamSpec 
*pspec G_GNUC_UNUSED,
 g_debug("port#%d %s: %s", id, name, opened ? "opened" : "closed");
 vte_name = port_name_to_vte_name(name);
 
+#ifdef WITH_QMP_PORT
 if (g_str_equal(name, "org.qemu.monitor.qmp.0")) {
 if (opened) {
 g_return_if_fail(!self->priv->qmp);
@@ -1133,6 +1146,7 @@ spice_port_opened(SpiceChannel *channel, GParamSpec 
*pspec G_GNUC_UNUSED,
 g_free(name);
 return;
 }
+#endif
 
 g_free(name);
 vte = g_object_get_data(G_OBJECT(port), "virt-viewer-vte");
-- 
2.20.1.98.gecbdaf0899

___
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 2/3] spice: hook into port channel to create VTE terminals

2019-01-18 Thread marcandre . lureau
From: Marc-André Lureau 

QEMU defines a few Spice port channel names in
docs/spice-port-fqdn.txt that can be interacted with a terminal.

Create VirtViewerDisplayVte display for all known terminal channel,
and redirect read/write signals.

Note that if VTE support is disabled, or if the VTE console isn't
shown, spice-gtk will still process those port channels (discarding
the read if VTE is disabled).

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-session-spice.c | 118 +++-
 1 file changed, 116 insertions(+), 2 deletions(-)

diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index 4aa7c73..49a7775 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -34,6 +34,7 @@
 #include "virt-viewer-util.h"
 #include "virt-viewer-session-spice.h"
 #include "virt-viewer-display-spice.h"
+#include "virt-viewer-display-vte.h"
 #include "virt-viewer-auth.h"
 
 G_DEFINE_TYPE (VirtViewerSessionSpice, virt_viewer_session_spice, 
VIRT_VIEWER_TYPE_SESSION)
@@ -962,20 +963,115 @@ on_new_file_transfer(SpiceMainChannel *channel 
G_GNUC_UNUSED,
   task);
 }
 
+static void
+spice_port_write_finished(GObject *source_object,
+  GAsyncResult *res,
+  gpointer dup)
+{
+SpicePortChannel *port = SPICE_PORT_CHANNEL(source_object);
+GError *err = NULL;
+
+spice_port_channel_write_finish(port, res, &err);
+if (err) {
+g_warning("Spice port write failed: %s", err->message);
+g_error_free(err);
+}
+g_free(dup);
+}
+
+static void
+spice_vte_commit(SpicePortChannel *port, const char *text,
+ guint size, gpointer user_data G_GNUC_UNUSED)
+{
+void *dup = g_memdup(text, size);
+
+/* note: spice-gtk queues write */
+spice_port_channel_write_async(port, dup, size,
+   NULL, spice_port_write_finished, dup);
+}
+
+static void
+spice_port_data(VirtViewerDisplayVte *vte, gpointer data, int size,
+SpicePortChannel *port G_GNUC_UNUSED)
+{
+virt_viewer_display_vte_feed(vte, data, size);
+}
+
+static const char *
+port_name_to_vte_name(const char *name)
+{
+if (g_str_equal(name, "org.qemu.console.serial.0"))
+return _("Serial");
+else if (g_str_equal(name, "org.qemu.monitor.hmp.0"))
+return _("QEMU human monitor");
+else if (g_str_equal(name, "org.qemu.console.debug.0"))
+return _("QEMU debug console");
+
+return NULL;
+}
+
+static void
+spice_port_opened(SpiceChannel *channel, GParamSpec *pspec G_GNUC_UNUSED,
+  VirtViewerSessionSpice *self)
+{
+SpicePortChannel *port = SPICE_PORT_CHANNEL(channel);
+int id;
+gchar *name = NULL;
+gboolean opened = FALSE;
+const char *vte_name;
+GtkWidget *vte;
+
+g_object_get(G_OBJECT(port),
+ "channel-id", &id,
+ "port-name", &name,
+ "port-opened", &opened,
+ NULL);
+
+g_return_if_fail(name != NULL);
+g_debug("port#%d %s: %s", id, name, opened ? "opened" : "closed");
+vte_name = port_name_to_vte_name(name);
+g_free(name);
+
+vte = g_object_get_data(G_OBJECT(port), "virt-viewer-vte");
+if (vte) {
+if (opened)
+return;
+
+g_object_set_data(G_OBJECT(port), "virt-viewer-vte", NULL);
+virt_viewer_session_remove_display(VIRT_VIEWER_SESSION(self), 
VIRT_VIEWER_DISPLAY(vte));
+g_object_unref(vte);
+
+} else if (opened) {
+if (!vte_name)
+return;
+
+vte = virt_viewer_display_vte_new(VIRT_VIEWER_SESSION(self), vte_name);
+g_object_set_data(G_OBJECT(port), "virt-viewer-vte", 
g_object_ref_sink(vte));
+virt_viewer_session_add_display(VIRT_VIEWER_SESSION(self), 
VIRT_VIEWER_DISPLAY(vte));
+virt_viewer_signal_connect_object(vte, "commit",
+  G_CALLBACK(spice_vte_commit), port, 
G_CONNECT_SWAPPED);
+virt_viewer_signal_connect_object(port, "port-data",
+  G_CALLBACK(spice_port_data), vte, 
G_CONNECT_SWAPPED);
+}
+}
+
 static void
 virt_viewer_session_spice_channel_new(SpiceSession *s,
   SpiceChannel *channel,
   VirtViewerSession *session)
 {
 VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
-int id;
+int id, type;
 
 g_return_if_fail(self != NULL);
 
 virt_viewer_signal_connect_object(channel, "open-fd",
   
G_CALLBACK(virt_viewer_session_spice_channel_open_fd_request), self, 0);
 
-g_object_get(channel, "channel-id", &id, NULL);
+g_object_get(channel,
+ "channel-id", &id,
+ "channel-type", &type,
+ NULL);
 
 g_debug("New spice channel %p %s %d", channel, 
g_type_name(G_OBJ

[virt-tools-list] [PATCH virt-viewer v3 3/3] spice: hook into QMP port

2019-01-18 Thread marcandre . lureau
From: Marc-André Lureau 

If the "org.qemu.monitor.qmp.0" port is available:
- enable the VM UI
- get and follow the VM state
- send the requested VM actions

This requires spice-gtk version 0.36 with SpiceQmpPort helper.

Signed-off-by: Marc-André Lureau 
Acked-by: Victor Toso 
---
 configure.ac|   2 +-
 src/virt-viewer-session-spice.c | 105 +++-
 2 files changed, 105 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5598c61..50cd91a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,7 @@ 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_GTK_REQUIRED="0.36"
 SPICE_PROTOCOL_REQUIRED="0.12.7"
 GOVIRT_REQUIRED="0.3.3"
 REST_REQUIRED="0.8"
diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index 49a7775..31447dc 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -52,6 +52,7 @@ struct _VirtViewerSessionSpicePrivate {
 gboolean did_auto_conf;
 VirtViewerFileTransferDialog *file_transfer_dialog;
 GError *disconnect_error;
+SpiceQmpPort *qmp;
 };
 
 #define VIRT_VIEWER_SESSION_SPICE_GET_PRIVATE(o) 
(G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_SESSION_SPICE, 
VirtViewerSessionSpicePrivate))
@@ -82,6 +83,7 @@ static void 
virt_viewer_session_spice_smartcard_insert(VirtViewerSession *sessio
 static void virt_viewer_session_spice_smartcard_remove(VirtViewerSession 
*session);
 static gboolean 
virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice *self);
 static void virt_viewer_session_spice_apply_monitor_geometry(VirtViewerSession 
*self, GHashTable *monitors);
+static void virt_viewer_session_spice_vm_action(VirtViewerSession *self, gint 
action);
 
 static void virt_viewer_session_spice_clear_displays(VirtViewerSessionSpice 
*self)
 {
@@ -262,6 +264,7 @@ 
virt_viewer_session_spice_class_init(VirtViewerSessionSpiceClass *klass)
 dclass->apply_monitor_geometry = 
virt_viewer_session_spice_apply_monitor_geometry;
 dclass->can_share_folder = virt_viewer_session_spice_can_share_folder;
 dclass->can_retry_auth = virt_viewer_session_spice_can_retry_auth;
+dclass->vm_action = virt_viewer_session_spice_vm_action;
 
 g_type_class_add_private(klass, sizeof(VirtViewerSessionSpicePrivate));
 
@@ -461,6 +464,8 @@ virt_viewer_session_spice_close(VirtViewerSession *session)
 
 g_object_add_weak_pointer(G_OBJECT(self), (gpointer*)&self);
 
+g_clear_object(&self->priv->qmp);
+
 virt_viewer_session_spice_clear_displays(self);
 
 if (self->priv->session) {
@@ -1010,6 +1015,85 @@ port_name_to_vte_name(const char *name)
 return NULL;
 }
 
+static void
+virt_viewer_session_spice_vm_action(VirtViewerSession *sess, gint action)
+{
+VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(sess);
+
+switch (action) {
+case VIRT_VIEWER_SESSION_VM_ACTION_QUIT:
+action = SPICE_QMP_PORT_VM_ACTION_QUIT;
+break;
+case VIRT_VIEWER_SESSION_VM_ACTION_RESET:
+action = SPICE_QMP_PORT_VM_ACTION_RESET;
+break;
+case VIRT_VIEWER_SESSION_VM_ACTION_POWER_DOWN:
+action = SPICE_QMP_PORT_VM_ACTION_POWER_DOWN;
+break;
+case VIRT_VIEWER_SESSION_VM_ACTION_PAUSE:
+action = SPICE_QMP_PORT_VM_ACTION_PAUSE;
+break;
+case VIRT_VIEWER_SESSION_VM_ACTION_CONTINUE:
+action = SPICE_QMP_PORT_VM_ACTION_CONTINUE;
+break;
+default:
+g_return_if_reached();
+}
+
+spice_qmp_port_vm_action_async(self->priv->qmp, action, NULL, NULL, NULL);
+}
+
+static void
+set_vm_running(VirtViewerSessionSpice *self, gboolean running)
+{
+g_object_set(virt_viewer_session_get_app(VIRT_VIEWER_SESSION(self)),
+ "vm-running", running, NULL);
+}
+
+static void
+query_status_cb(GObject *source_object G_GNUC_UNUSED,
+GAsyncResult *res, gpointer user_data)
+{
+VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(user_data);
+SpiceQmpStatus *status;
+gboolean running = TRUE;
+GError *error = NULL;
+
+status = spice_qmp_port_query_status_finish(self->priv->qmp, res, &error);
+if (!status) {
+g_warning("failed to query VM status: %s", error->message);
+g_error_free(error);
+return;
+}
+
+if (g_str_equal(status->status, "paused")) {
+running = FALSE;
+}
+
+set_vm_running(self, running);
+
+spice_qmp_status_unref(status);
+}
+
+static void qmp_ready_cb(VirtViewerSessionSpice *self,
+ GParamSpec *pspec G_GNUC_UNUSED,
+ GObject *object G_GNUC_UNUSED)
+{
+spice_qmp_port_query_status_async(self->priv->qmp, NULL, query_status_cb, 
self);
+}
+
+static void qmp_event_cb(VirtViewerSessionSpice *self, const gchar *event,
+ void *data G_GNUC_UNUSED, GObject *object 
G_GNUC_UNUSED)
+{
+g_d

[virt-tools-list] [PATCH virt-viewer v3 1/3] session: do not take VTE display into account for geometry changes

2019-01-18 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-session.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c
index 596d1e3..3590c6d 100644
--- a/src/virt-viewer-session.c
+++ b/src/virt-viewer-session.c
@@ -29,6 +29,7 @@
 
 #include "virt-viewer-session.h"
 #include "virt-viewer-util.h"
+#include "virt-viewer-display-vte.h"
 
 #define VIRT_VIEWER_SESSION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), 
VIRT_VIEWER_TYPE_SESSION, VirtViewerSessionPrivate))
 
@@ -417,6 +418,10 @@ 
virt_viewer_session_on_monitor_geometry_changed(VirtViewerSession* self,
 
 for (l = self->priv->displays; l; l = l->next) {
 VirtViewerDisplay *d = VIRT_VIEWER_DISPLAY(l->data);
+
+if (VIRT_VIEWER_IS_DISPLAY_VTE(d))
+continue;
+
 guint nth = 0;
 GdkRectangle *rect = g_new0(GdkRectangle, 1);
 
-- 
2.20.1.98.gecbdaf0899

___
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 0/3] Add QEMU-like UI: VT console & basic VM state

2019-01-18 Thread marcandre . lureau
From: Marc-André Lureau 

Hi,

QEMU provides multiple display backend, with different set of
features. One of the richest UI is the -display gtk. It is quite
minimal, and comparable to remote-viewer UI wrt fullscreen, zooming,
grabbing. I haven't done a detailed comparison, but for regular use, I
prefer the remote-viewer UI. The fullscreen mode has a popup toolbar,
there is a send-key menu, it provides better desktop integration
support: USB redirection, folder sharing, more complete multi-monitor
configuration, screenshot. remote-viewer also allows hotkey
configuration, and has an experimental "kiosk" mode.

However, remote-viewer is lacking 2 important features compared to
QEMU UI: VT console (for serials, and monitors) and basic VM state
commands (power off, reset, pause..).

This is remaining patches from the series, creating the VTE consoles
and hooking into QMP channels

Another RFC series for QEMU "[PATCH 00/10] RFC: spice: add -display
app to launch external UI" provides a new "-display app" backend, that
will configure QEMU appropriately, and start remote-viewer (actually
any client handling spice+unix://). The result is that the "QEMU UI
experience" is out of qemu code base and process.

thanks

v3:
 - code cleanup suggest by Victor in "spice: hook into port channel to create 
VTE terminals"
 - add Victor a-b on "spice: hook into QMP port"
 - rebased

Marc-André Lureau (3):
  session: do not take VTE display into account for geometry changes
  spice: hook into port channel to create VTE terminals
  spice: hook into QMP port

 configure.ac|   2 +-
 src/virt-viewer-session-spice.c | 221 +++-
 src/virt-viewer-session.c   |   5 +
 3 files changed, 225 insertions(+), 3 deletions(-)

-- 
2.20.1.98.gecbdaf0899

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

[virt-tools-list] [PATCH] spice: add unix-path in .vv file support

2018-12-21 Thread marcandre . lureau
From: Marc-André Lureau 

This will allow to connect to a Spice server using a unix socket path,
for example:

[virt-viewer]
type=spice
unix-path=/var/run/user/1000/qemu/test/spice.sock

Signed-off-by: Marc-André Lureau 
---
 man/remote-viewer.pod   |  8 +++-
 src/virt-viewer-file.c  | 21 +
 src/virt-viewer-file.h  |  2 ++
 src/virt-viewer-session-spice.c | 33 -
 4 files changed, 50 insertions(+), 14 deletions(-)

diff --git a/man/remote-viewer.pod b/man/remote-viewer.pod
index 4296fcc..2e596ce 100644
--- a/man/remote-viewer.pod
+++ b/man/remote-viewer.pod
@@ -161,7 +161,13 @@ fails.
 
 The session type, either "spice", "vnc" or "ovirt".
 
-=item C (string, mandatory)
+=item C (string)
+
+The server to connect to, using a Unix socket path. (supported with spice, 
since 8.0)
+
+This option is incompatible with C, C and C.
+
+=item C (string)
 
 The server host to connect to.
 
diff --git a/src/virt-viewer-file.c b/src/virt-viewer-file.c
index 1b0c310..d88f4f8 100644
--- a/src/virt-viewer-file.c
+++ b/src/virt-viewer-file.c
@@ -43,6 +43,7 @@
  * - newer-version-url: string specifying an URL to display when the minimum
  *   version check fails
  * - type: string, mandatory, values: "spice" (later "vnc" etc..)
+ * - unix-path: string
  * - host: string
  * - port: int
  * - tls-port: int
@@ -104,6 +105,7 @@ G_DEFINE_TYPE(VirtViewerFile, virt_viewer_file, 
G_TYPE_OBJECT);
 enum  {
 PROP_DUMMY_PROPERTY,
 PROP_TYPE,
+PROP_UNIX_PATH,
 PROP_HOST,
 PROP_PORT,
 PROP_TLS_PORT,
@@ -326,6 +328,19 @@ virt_viewer_file_set_host(VirtViewerFile* self, const 
gchar* value)
 g_object_notify(G_OBJECT(self), "host");
 }
 
+gchar*
+virt_viewer_file_get_unix_path(VirtViewerFile* self)
+{
+return virt_viewer_file_get_string(self, MAIN_GROUP, "unix-path");
+}
+
+void
+virt_viewer_file_set_unix_path(VirtViewerFile* self, const gchar* value)
+{
+virt_viewer_file_set_string(self, MAIN_GROUP, "unix-path", value);
+g_object_notify(G_OBJECT(self), "unix-path");
+}
+
 gchar*
 virt_viewer_file_get_file_type(VirtViewerFile* self)
 {
@@ -939,6 +954,9 @@ virt_viewer_file_set_property(GObject* object, guint 
property_id,
 case PROP_TYPE:
 virt_viewer_file_set_type(self, g_value_get_string(value));
 break;
+case PROP_UNIX_PATH:
+virt_viewer_file_set_unix_path(self, g_value_get_string(value));
+break;
 case PROP_HOST:
 virt_viewer_file_set_host(self, g_value_get_string(value));
 break;
@@ -1054,6 +1072,9 @@ virt_viewer_file_get_property(GObject* object, guint 
property_id,
 case PROP_TYPE:
 g_value_take_string(value, virt_viewer_file_get_file_type(self));
 break;
+case PROP_UNIX_PATH:
+g_value_take_string(value, virt_viewer_file_get_unix_path(self));
+break;
 case PROP_HOST:
 g_value_take_string(value, virt_viewer_file_get_host(self));
 break;
diff --git a/src/virt-viewer-file.h b/src/virt-viewer-file.h
index 15c61d0..108bcbf 100644
--- a/src/virt-viewer-file.h
+++ b/src/virt-viewer-file.h
@@ -54,6 +54,8 @@ VirtViewerFile* virt_viewer_file_new_from_buffer(const gchar* 
buf, gsize len,
  GError** error);
 gboolean virt_viewer_file_is_set(VirtViewerFile* self, const gchar* key);
 
+gchar* virt_viewer_file_get_unix_path(VirtViewerFile* self);
+void virt_viewer_file_set_unix_path(VirtViewerFile* self, const gchar* value);
 gchar* virt_viewer_file_get_ca(VirtViewerFile* self);
 void virt_viewer_file_set_ca(VirtViewerFile* self, const gchar* value);
 gchar* virt_viewer_file_get_host(VirtViewerFile* self);
diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index 8bb3bf9..c0c8d6c 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -511,21 +511,28 @@ fill_session(VirtViewerFile *file, SpiceSession *session)
 g_return_if_fail(VIRT_VIEWER_IS_FILE(file));
 g_return_if_fail(SPICE_IS_SESSION(session));
 
-if (virt_viewer_file_is_set(file, "host")) {
-gchar *val = virt_viewer_file_get_host(file);
-g_object_set(G_OBJECT(session), "host", val, NULL);
+if (virt_viewer_file_is_set(file, "unix-path")) {
+gchar *val = virt_viewer_file_get_unix_path(file);
+g_object_set(G_OBJECT(session), "unix-path", val, NULL);
 g_free(val);
-}
+} else {
+if (virt_viewer_file_is_set(file, "host")) {
+gchar *val = virt_viewer_file_get_host(file);
+g_object_set(G_OBJECT(session), "host", val, NULL);
+g_free(val);
+}
 
-if (virt_viewer_file_is_set(file, "port")) {
-gchar *port = g_strdup_printf("%d", virt_viewer_file_get_port(file));
-g_object_set(G_OBJECT(session), "port", port, NULL);
-g_free(port);
-}
-if (virt_viewer_file_is_set(file, "tls-port")) {
-gchar *tls_port = g_strdup_pri

[virt-tools-list] [PATCH v2 15/16] app: add "vm-running" property

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

Add "vm-running" property and modify "menu-vm-pause" check button
state when the running state changes.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-app.c| 19 +++
 src/virt-viewer-window.c | 16 
 2 files changed, 35 insertions(+)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 402c80b..452395b 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -128,6 +128,7 @@ struct _VirtViewerAppPrivate {
 gboolean quitting;
 gboolean kiosk;
 gboolean vm_ui;
+gboolean vm_running;
 
 VirtViewerSession *session;
 gboolean active;
@@ -176,6 +177,7 @@ enum {
 PROP_QUIT_ON_DISCONNECT,
 PROP_UUID,
 PROP_VM_UI,
+PROP_VM_RUNNING,
 };
 
 void
@@ -1584,6 +1586,10 @@ virt_viewer_app_get_property (GObject *object, guint 
property_id,
 g_value_set_boolean(value, priv->vm_ui);
 break;
 
+case PROP_VM_RUNNING:
+g_value_set_boolean(value, priv->vm_running);
+break;
+
 default:
 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 }
@@ -1642,6 +1648,10 @@ virt_viewer_app_set_property (GObject *object, guint 
property_id,
 priv->vm_ui = g_value_get_boolean(value);
 break;
 
+case PROP_VM_RUNNING:
+priv->vm_running = g_value_get_boolean(value);
+break;
+
 default:
 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 }
@@ -2042,6 +2052,15 @@ virt_viewer_app_class_init (VirtViewerAppClass *klass)
  FALSE,
  G_PARAM_READWRITE |
  
G_PARAM_STATIC_STRINGS));
+
+g_object_class_install_property(object_class,
+PROP_VM_RUNNING,
+g_param_spec_boolean("vm-running",
+ "VM running",
+ "VM running",
+ FALSE,
+ G_PARAM_READWRITE |
+ 
G_PARAM_STATIC_STRINGS));
 }
 
 void
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 514a410..d90aa7c 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -237,6 +237,20 @@ vm_ui_changed(GObject*gobject G_GNUC_UNUSED,
 
gtk_widget_set_visible(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, 
"menu-machine")), vm_ui);
 }
 
+static void
+vm_running_changed(GObject*gobject G_GNUC_UNUSED,
+   GParamSpec *pspec G_GNUC_UNUSED,
+   gpointeruser_data)
+{
+VirtViewerWindow *self = user_data;
+GtkCheckMenuItem *check = 
GTK_CHECK_MENU_ITEM(gtk_builder_get_object(self->priv->builder, 
"menu-vm-pause"));
+gboolean running;
+
+g_object_get(G_OBJECT(self->priv->app), "vm-running", &running, NULL);
+
+gtk_check_menu_item_set_active(check, !running);
+}
+
 static void
 virt_viewer_window_constructed(GObject *object)
 {
@@ -249,6 +263,8 @@ virt_viewer_window_constructed(GObject *object)
  G_CALLBACK(rebuild_combo_menu), object);
 g_signal_connect(priv->app, "notify::vm-ui",
  G_CALLBACK(vm_ui_changed), object);
+g_signal_connect(priv->app, "notify::vm-running",
+ G_CALLBACK(vm_running_changed), object);
 rebuild_combo_menu(NULL, NULL, object);
 }
 
-- 
2.19.0.271.gfe8321ec05

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

[virt-tools-list] [PATCH v2 16/16] spice: hook into QMP port

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

If the "org.qemu.monitor.qmp.0" port is available:
- enable the VM UI
- get and follow the VM state
- send the requested VM actions

This requires upcoming spice-gtk version 0.36 with SpiceQmpPort
helper.

Signed-off-by: Marc-André Lureau 
---
 configure.ac|   2 +-
 src/virt-viewer-session-spice.c | 102 
 2 files changed, 103 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index e2d86a6..3782937 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,7 @@ 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_GTK_REQUIRED="0.36"
 SPICE_PROTOCOL_REQUIRED="0.12.7"
 GOVIRT_REQUIRED="0.3.3"
 REST_REQUIRED="0.8"
diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index 8aa2351..7b7bd24 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -52,6 +52,7 @@ struct _VirtViewerSessionSpicePrivate {
 gboolean did_auto_conf;
 VirtViewerFileTransferDialog *file_transfer_dialog;
 GError *disconnect_error;
+SpiceQmpPort *qmp;
 };
 
 #define VIRT_VIEWER_SESSION_SPICE_GET_PRIVATE(o) 
(G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_SESSION_SPICE, 
VirtViewerSessionSpicePrivate))
@@ -82,6 +83,7 @@ static void 
virt_viewer_session_spice_smartcard_insert(VirtViewerSession *sessio
 static void virt_viewer_session_spice_smartcard_remove(VirtViewerSession 
*session);
 static gboolean 
virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice *self);
 static void virt_viewer_session_spice_apply_monitor_geometry(VirtViewerSession 
*self, GHashTable *monitors);
+static void virt_viewer_session_spice_vm_action(VirtViewerSession *self, gint 
action);
 
 static void virt_viewer_session_spice_clear_displays(VirtViewerSessionSpice 
*self)
 {
@@ -262,6 +264,7 @@ 
virt_viewer_session_spice_class_init(VirtViewerSessionSpiceClass *klass)
 dclass->apply_monitor_geometry = 
virt_viewer_session_spice_apply_monitor_geometry;
 dclass->can_share_folder = virt_viewer_session_spice_can_share_folder;
 dclass->can_retry_auth = virt_viewer_session_spice_can_retry_auth;
+dclass->vm_action = virt_viewer_session_spice_vm_action;
 
 g_type_class_add_private(klass, sizeof(VirtViewerSessionSpicePrivate));
 
@@ -461,6 +464,8 @@ virt_viewer_session_spice_close(VirtViewerSession *session)
 
 g_object_add_weak_pointer(G_OBJECT(self), (gpointer*)&self);
 
+g_clear_object(&self->priv->qmp);
+
 virt_viewer_session_spice_clear_displays(self);
 
 if (self->priv->session) {
@@ -1003,6 +1008,85 @@ port_name_to_vte_name(const char *name)
 return NULL;
 }
 
+static void
+virt_viewer_session_spice_vm_action(VirtViewerSession *sess, gint action)
+{
+VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(sess);
+
+switch (action) {
+case VIRT_VIEWER_SESSION_VM_ACTION_QUIT:
+action = SPICE_QMP_PORT_VM_ACTION_QUIT;
+break;
+case VIRT_VIEWER_SESSION_VM_ACTION_RESET:
+action = SPICE_QMP_PORT_VM_ACTION_RESET;
+break;
+case VIRT_VIEWER_SESSION_VM_ACTION_POWER_DOWN:
+action = SPICE_QMP_PORT_VM_ACTION_POWER_DOWN;
+break;
+case VIRT_VIEWER_SESSION_VM_ACTION_PAUSE:
+action = SPICE_QMP_PORT_VM_ACTION_PAUSE;
+break;
+case VIRT_VIEWER_SESSION_VM_ACTION_CONTINUE:
+action = SPICE_QMP_PORT_VM_ACTION_CONTINUE;
+break;
+default:
+g_return_if_reached();
+}
+
+spice_qmp_port_vm_action_async(self->priv->qmp, action, NULL, NULL, NULL);
+}
+
+static void
+set_vm_running(VirtViewerSessionSpice *self, gboolean running)
+{
+g_object_set(virt_viewer_session_get_app(VIRT_VIEWER_SESSION(self)),
+ "vm-running", running, NULL);
+}
+
+static void
+query_status_cb(GObject *source_object G_GNUC_UNUSED,
+GAsyncResult *res, gpointer user_data)
+{
+VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(user_data);
+SpiceQmpStatus *status;
+gboolean running = TRUE;
+GError *error = NULL;
+
+status = spice_qmp_port_query_status_finish(self->priv->qmp, res, &error);
+if (!status) {
+g_warning("failed to query VM status: %s", error->message);
+g_error_free(error);
+return;
+}
+
+if (g_str_equal(status->status, "paused")) {
+running = FALSE;
+}
+
+set_vm_running(self, running);
+
+spice_qmp_status_unref(status);
+}
+
+static void qmp_ready_cb(VirtViewerSessionSpice *self,
+ GParamSpec *pspec G_GNUC_UNUSED,
+ GObject *object G_GNUC_UNUSED)
+{
+spice_qmp_port_query_status_async(self->priv->qmp, NULL, query_status_cb, 
self);
+}
+
+static void qmp_event_cb(VirtViewerSessionSpice *self, const gchar *event,
+ void *data G_GNUC_UNUSED, GObject *object 
G_GNUC_UNUSED)
+{
+g_debug("QMP event

[virt-tools-list] [PATCH v2 13/16] spice: hook into port channel to create VTE terminals

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

QEMU defines a few Spice port channel names in
docs/spice-port-fqdn.txt that can be interacted with a terminal.

Create VirtViewerDisplayVte display for all known terminal channel,
and redirect read/write signals.

Note that if VTE support is disabled, or if the VTE console isn't
shown, spice-gtk will still process those port channels (discarding
the read if VTE is disabled).

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-session-spice.c | 118 +++-
 1 file changed, 116 insertions(+), 2 deletions(-)

diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index cb06af2..8aa2351 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -34,6 +34,7 @@
 #include "virt-viewer-util.h"
 #include "virt-viewer-session-spice.h"
 #include "virt-viewer-display-spice.h"
+#include "virt-viewer-display-vte.h"
 #include "virt-viewer-auth.h"
 
 G_DEFINE_TYPE (VirtViewerSessionSpice, virt_viewer_session_spice, 
VIRT_VIEWER_TYPE_SESSION)
@@ -955,20 +956,116 @@ on_new_file_transfer(SpiceMainChannel *channel 
G_GNUC_UNUSED,
   task);
 }
 
+static void
+spice_port_write_finished(GObject *source_object,
+  GAsyncResult *res,
+  gpointer dup)
+{
+SpicePortChannel *port = SPICE_PORT_CHANNEL(source_object);
+GError *err = NULL;
+
+spice_port_channel_write_finish(port, res, &err);
+if (err) {
+g_warning("Spice port write failed: %s", err->message);
+g_error_free(err);
+}
+g_free(dup);
+}
+
+static void
+spice_vte_commit(SpicePortChannel *port, const char *text,
+ guint size, gpointer user_data G_GNUC_UNUSED)
+{
+void *dup = g_memdup(text, size);
+
+/* note: spice-gtk queues write */
+spice_port_channel_write_async(port, dup, size,
+   NULL, spice_port_write_finished, dup);
+}
+
+static void
+spice_port_data(VirtViewerDisplayVte *vte, gpointer data, int size,
+SpicePortChannel *port G_GNUC_UNUSED)
+{
+virt_viewer_display_vte_feed(vte, data, size);
+}
+
+static const char *
+port_name_to_vte_name(const char *name)
+{
+if (g_str_equal(name, "org.qemu.console.serial.0"))
+return _("Serial");
+else if (g_str_equal(name, "org.qemu.monitor.hmp.0"))
+return _("QEMU human monitor");
+else if (g_str_equal(name, "org.qemu.console.debug.0"))
+return _("QEMU debug console");
+
+return NULL;
+}
+
+static void
+spice_port_opened(SpiceChannel *channel, GParamSpec *pspec G_GNUC_UNUSED,
+  VirtViewerSessionSpice *self)
+{
+SpicePortChannel *port = SPICE_PORT_CHANNEL(channel);
+int id;
+gchar *name = NULL;
+gboolean opened = FALSE;
+const char *vte_name;
+GtkWidget *vte;
+
+g_object_get(G_OBJECT(port),
+ "channel-id", &id,
+ "port-name", &name,
+ "port-opened", &opened,
+ NULL);
+
+g_return_if_fail(name != NULL);
+g_debug("port#%d %s: %s", id, name, opened ? "opened" : "closed");
+
+vte = g_object_get_data(G_OBJECT(port), "virt-viewer-vte");
+if (vte) {
+if (opened)
+goto end;
+
+g_object_set_data(G_OBJECT(port), "virt-viewer-vte", NULL);
+virt_viewer_session_remove_display(VIRT_VIEWER_SESSION(self), 
VIRT_VIEWER_DISPLAY(vte));
+
+} else if (opened) {
+vte_name = port_name_to_vte_name(name);
+if (!vte_name)
+goto end;
+
+vte = virt_viewer_display_vte_new(VIRT_VIEWER_SESSION(self), vte_name);
+g_object_set_data(G_OBJECT(port), "virt-viewer-vte", 
g_object_ref_sink(vte));
+virt_viewer_session_add_display(VIRT_VIEWER_SESSION(self), 
VIRT_VIEWER_DISPLAY(vte));
+virt_viewer_signal_connect_object(vte, "commit",
+  G_CALLBACK(spice_vte_commit), port, 
G_CONNECT_SWAPPED);
+virt_viewer_signal_connect_object(port, "port-data",
+  G_CALLBACK(spice_port_data), vte, 
G_CONNECT_SWAPPED);
+}
+
+end:
+g_free(name);
+}
+
 static void
 virt_viewer_session_spice_channel_new(SpiceSession *s,
   SpiceChannel *channel,
   VirtViewerSession *session)
 {
 VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
-int id;
+int id, type;
 
 g_return_if_fail(self != NULL);
 
 virt_viewer_signal_connect_object(channel, "open-fd",
   
G_CALLBACK(virt_viewer_session_spice_channel_open_fd_request), self, 0);
 
-g_object_get(channel, "channel-id", &id, NULL);
+g_object_get(channel,
+ "channel-id", &id,
+ "channel-type", &type,
+ NULL);
 
 g_debug("New spice channel %p %s %d", channel, 
g_type_name(G_OBJECT_TYPE(chann

[virt-tools-list] [PATCH v2 14/16] app: add "machine" UI

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

Add a new "Machine" menu, which allows to Pause/Reset/Power Down a VM.

The menu is only visible if "vm-ui" app property is set.

When the application quits, it will also send a quit action to the VM.

This is a similar behaviour/UI as qemu -display gtk.

Signed-off-by: Marc-André Lureau 
---
 src/resources/ui/virt-viewer.ui | 46 ++
 src/virt-viewer-app.c   | 24 
 src/virt-viewer-session.c   | 11 
 src/virt-viewer-session.h   | 11 
 src/virt-viewer-window.c| 50 +
 5 files changed, 142 insertions(+)

diff --git a/src/resources/ui/virt-viewer.ui b/src/resources/ui/virt-viewer.ui
index 9da1403..93471a4 100644
--- a/src/resources/ui/virt-viewer.ui
+++ b/src/resources/ui/virt-viewer.ui
@@ -113,6 +113,52 @@
 
   
 
+
+  
+False
+_Machine
+True
+
+  
+True
+False
+
+  
+True
+False
+_Pause
+True
+
+  
+
+
+  
+True
+False
+  
+
+
+  
+True
+False
+_Reset
+True
+
+  
+
+
+  
+True
+False
+_Power 
down
+True
+
+  
+
+  
+
+  
+
 
   
 True
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 376fe98..402c80b 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -127,6 +127,7 @@ struct _VirtViewerAppPrivate {
 gboolean attach;
 gboolean quitting;
 gboolean kiosk;
+gboolean vm_ui;
 
 VirtViewerSession *session;
 gboolean active;
@@ -174,6 +175,7 @@ enum {
 PROP_KIOSK,
 PROP_QUIT_ON_DISCONNECT,
 PROP_UUID,
+PROP_VM_UI,
 };
 
 void
@@ -286,6 +288,11 @@ virt_viewer_app_quit(VirtViewerApp *self)
 
 virt_viewer_app_save_config(self);
 
+if (priv->vm_ui) {
+virt_viewer_session_vm_action(VIRT_VIEWER_SESSION(priv->session),
+  VIRT_VIEWER_SESSION_VM_ACTION_QUIT);
+}
+
 if (priv->session) {
 virt_viewer_session_close(VIRT_VIEWER_SESSION(priv->session));
 if (priv->connected) {
@@ -1573,6 +1580,10 @@ virt_viewer_app_get_property (GObject *object, guint 
property_id,
 g_value_set_string(value, priv->uuid);
 break;
 
+case PROP_VM_UI:
+g_value_set_boolean(value, priv->vm_ui);
+break;
+
 default:
 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 }
@@ -1627,6 +1638,10 @@ virt_viewer_app_set_property (GObject *object, guint 
property_id,
 virt_viewer_app_set_uuid_string(self, g_value_get_string(value));
 break;
 
+case PROP_VM_UI:
+priv->vm_ui = g_value_get_boolean(value);
+break;
+
 default:
 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 }
@@ -2018,6 +2033,15 @@ virt_viewer_app_class_init (VirtViewerAppClass *klass)
 G_PARAM_READABLE |
 G_PARAM_WRITABLE |
 
G_PARAM_STATIC_STRINGS));
+
+g_object_class_install_property(object_class,
+PROP_VM_UI,
+g_param_spec_boolean("vm-ui",
+ "VM UI",
+ "QEMU UI & behaviour",
+ FALSE,
+ G_PARAM_READWRITE |
+ 
G_PARAM_STATIC_STRINGS));
 }
 
 void
diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c
index a40b0bb..3336abe 100644
--- a/src/virt-viewer-session.c
+++ b/src/virt-viewer-session.c
@@ -688,6 +688,17 @@ gboolean 
virt_viewer_session_can_retry_auth(VirtViewer

[virt-tools-list] [PATCH v2 12/16] app: create a window for VTE displays

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

virt_viewer_app_display_added() now handles VTE displays. They should
be skipped for monitor configuration, and they don't emit "show-hint".

(a VTE display has a monitor nth == -1, which is now a valid value)

The associated window will be hidden when virt-viewer is started.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-app.c | 69 ---
 1 file changed, 52 insertions(+), 17 deletions(-)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 568af47..376fe98 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -112,7 +112,7 @@ struct _VirtViewerAppPrivate {
 VirtViewerWindow *main_window;
 GtkWidget *main_notebook;
 GList *windows;
-GHashTable *displays;
+GHashTable *displays; /* !vte */
 GHashTable *initial_display_map;
 gchar *clipboard;
 GtkWidget *preferences;
@@ -822,9 +822,11 @@ virt_viewer_app_window_new(VirtViewerApp *self, gint nth)
 VirtViewerWindow* window;
 GtkWindow *w;
 
-window = virt_viewer_app_get_nth_window(self, nth);
-if (window)
-return window;
+if (nth >= 0) {
+window = virt_viewer_app_get_nth_window(self, nth);
+if (window)
+return window;
+}
 
 window = g_object_new(VIRT_VIEWER_TYPE_WINDOW, "app", self, NULL);
 virt_viewer_window_set_kiosk(window, self->priv->kiosk);
@@ -848,11 +850,27 @@ virt_viewer_app_window_new(VirtViewerApp *self, gint nth)
 return window;
 }
 
+static void
+window_weak_notify(gpointer data, GObject *where_was G_GNUC_UNUSED)
+{
+VirtViewerDisplay *display = VIRT_VIEWER_DISPLAY(data);
+
+g_object_set_data(G_OBJECT(display), "virt-viewer-window", NULL);
+}
+
 static VirtViewerWindow *
 ensure_window_for_display(VirtViewerApp *self, VirtViewerDisplay *display)
 {
-gint nth = virt_viewer_display_get_nth(display);
-VirtViewerWindow *win = virt_viewer_app_get_nth_window(self, nth);
+VirtViewerWindow *win = NULL;
+gint nth = -1;
+
+if (VIRT_VIEWER_IS_DISPLAY_VTE(display)) {
+win = g_object_get_data(G_OBJECT(display), "virt-viewer-window");
+} else {
+nth = virt_viewer_display_get_nth(display);
+win = virt_viewer_app_get_nth_window(self, nth);
+}
+
 if (win == NULL) {
 GList *l = self->priv->windows;
 
@@ -874,12 +892,26 @@ ensure_window_for_display(VirtViewerApp *self, 
VirtViewerDisplay *display)
 }
 
 virt_viewer_window_set_display(win, display);
+if (VIRT_VIEWER_IS_DISPLAY_VTE(display)) {
+g_object_set_data(G_OBJECT(display), "virt-viewer-window", win);
+g_object_weak_ref(G_OBJECT(win), window_weak_notify, display);
+}
 }
 virt_viewer_app_set_window_subtitle(self, win, nth);
 
 return win;
 }
 
+static VirtViewerWindow *
+display_show_get_window(VirtViewerApp *self, VirtViewerDisplay *display)
+{
+VirtViewerWindow *win = ensure_window_for_display(self, display);
+VirtViewerNotebook *nb = virt_viewer_window_get_notebook(win);
+
+virt_viewer_notebook_show_display(nb);
+return win;
+}
+
 static void
 display_show_hint(VirtViewerDisplay *display,
   GParamSpec *pspec G_GNUC_UNUSED,
@@ -907,9 +939,7 @@ display_show_hint(VirtViewerDisplay *display,
 virt_viewer_window_hide(win);
 } else {
 if (hint & VIRT_VIEWER_DISPLAY_SHOW_HINT_READY) {
-win = ensure_window_for_display(self, display);
-nb = virt_viewer_window_get_notebook(win);
-virt_viewer_notebook_show_display(nb);
+win = display_show_get_window(self, display);
 virt_viewer_window_show(win);
 } else {
 if (!self->priv->kiosk && win) {
@@ -926,19 +956,24 @@ virt_viewer_app_display_added(VirtViewerSession *session 
G_GNUC_UNUSED,
   VirtViewerDisplay *display,
   VirtViewerApp *self)
 {
-gint nth;
+if (VIRT_VIEWER_IS_DISPLAY_VTE(display)) {
+VirtViewerWindow *win = display_show_get_window(self, display);
+virt_viewer_window_hide(win);
+virt_viewer_app_update_menu_displays(self);
+} else {
+gint nth;
 
-g_object_get(display, "nth-display", &nth, NULL);
+g_object_get(display, "nth-display", &nth, NULL);
 
-g_debug("Insert display %d %p", nth, display);
-g_hash_table_insert(self->priv->displays, GINT_TO_POINTER(nth), 
g_object_ref(display));
+g_debug("Insert display %d %p", nth, display);
+g_hash_table_insert(self->priv->displays, GINT_TO_POINTER(nth), 
g_object_ref(display));
 
-g_signal_connect(display, "notify::show-hint",
- G_CALLBACK(display_show_hint), NULL);
-g_object_notify(G_OBJECT(display), "show-hint"); /* call display_show_hint 
*/
+g_signal_connect(display, "notify::show-hint",
+ G_CALLBACK(display_show_hint), NULL);
+g_object_notify(G_OBJE

[virt-tools-list] [PATCH v2 11/16] session: do not take VTE display into account for geometry changes

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-session.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c
index cd1f037..a40b0bb 100644
--- a/src/virt-viewer-session.c
+++ b/src/virt-viewer-session.c
@@ -29,6 +29,7 @@
 
 #include "virt-viewer-session.h"
 #include "virt-viewer-util.h"
+#include "virt-viewer-display-vte.h"
 
 #define VIRT_VIEWER_SESSION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), 
VIRT_VIEWER_TYPE_SESSION, VirtViewerSessionPrivate))
 
@@ -417,6 +418,10 @@ 
virt_viewer_session_on_monitor_geometry_changed(VirtViewerSession* self,
 
 for (l = self->priv->displays; l; l = l->next) {
 VirtViewerDisplay *d = VIRT_VIEWER_DISPLAY(l->data);
+
+if (VIRT_VIEWER_IS_DISPLAY_VTE(d))
+continue;
+
 guint nth = 0;
 GdkRectangle *rect = g_new0(GdkRectangle, 1);
 
-- 
2.19.0.271.gfe8321ec05

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

[virt-tools-list] [PATCH v2 10/16] display: allow display without associated monitor number

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

The VTE display will have monitor id -1.

Eventually, having a base "console" class without monitor id could
avoid this allowance.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index a1fcb82..98d4edd 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -129,7 +129,7 @@ virt_viewer_display_class_init(VirtViewerDisplayClass 
*class)
 g_param_spec_int("nth-display",
  "Nth display",
  "Nth display",
- 0,
+ -1,
  G_MAXINT32,
  0,
  G_PARAM_READWRITE |
-- 
2.19.0.271.gfe8321ec05

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

[virt-tools-list] [PATCH v2 08/16] app: set subtitle using VTE name

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

Currently, subtitle indicate the monitor number, ex: "Fedora (1)".

Custom subtitle use %d to place the monitor number.

Let's make this placeholder more generic to place the name of the
console, ex: "Fedora (Serial)".

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-app.c | 22 +-
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 889cc6b..7b750c6 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -62,6 +62,8 @@
 #include "virt-viewer-session-spice.h"
 #endif
 
+#include "virt-viewer-display-vte.h"
+
 gboolean doDebug = FALSE;
 
 /* Signal handlers for about dialog */
@@ -701,15 +703,25 @@ virt_viewer_app_set_window_subtitle(VirtViewerApp *app,
 {
 gchar *subtitle = NULL;
 const gchar *title = virt_viewer_app_get_title(app);
+VirtViewerDisplay *display = virt_viewer_window_get_display(window);
 
 if (title != NULL) {
 gchar *d = strstr(title, "%d");
+gchar *desc = NULL;
+
+if (display && VIRT_VIEWER_IS_DISPLAY_VTE(display)) {
+g_object_get(display, "name", &desc, NULL);
+} else  {
+desc = g_strdup_printf("%d", nth + 1);
+}
+
 if (d != NULL) {
 *d = '\0';
-subtitle = g_strdup_printf("%s%d%s", title, nth + 1, d + 2);
+subtitle = g_strdup_printf("%s%s%s", title, desc, d + 2);
 *d = '%';
 } else
-subtitle = g_strdup_printf("%s (%d)", title, nth + 1);
+subtitle = g_strdup_printf("%s (%s)", title, desc);
+g_free(desc);
 }
 
 g_object_set(window, "subtitle", subtitle, NULL);
@@ -717,8 +729,8 @@ virt_viewer_app_set_window_subtitle(VirtViewerApp *app,
 }
 
 static void
-set_title(gpointer value,
-  gpointer user_data)
+set_subtitle(gpointer value,
+ gpointer user_data)
 {
 VirtViewerApp *app = user_data;
 VirtViewerWindow *window = value;
@@ -734,7 +746,7 @@ set_title(gpointer value,
 static void
 virt_viewer_app_set_all_window_subtitles(VirtViewerApp *app)
 {
-g_list_foreach(app->priv->windows, set_title, app);
+g_list_foreach(app->priv->windows, set_subtitle, app);
 }
 
 static void update_title(gpointer value,
-- 
2.19.0.271.gfe8321ec05

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

[virt-tools-list] [PATCH v2 09/16] app: append VTE consoles to display submenu

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

Get the name of the console, and set the subtitle with it.

Rename "set_title" to "set_subtitle" while at it, since it is more
appropriate.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-app.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 7b750c6..568af47 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -2294,6 +2294,26 @@ window_update_menu_displays_cb(gpointer value,
 tmp = tmp->next;
 }
 
+for (GList *l = self->priv->windows; l; l = l->next) {
+VirtViewerWindow *win = VIRT_VIEWER_WINDOW(l->data);
+VirtViewerDisplay *display = virt_viewer_window_get_display(win);
+
+if (VIRT_VIEWER_IS_DISPLAY_VTE(display)) {
+gchar *name = NULL;
+GtkWidget *item;
+
+g_object_get(display, "name", &name, NULL);
+item = gtk_check_menu_item_new_with_label(name);
+g_free(name);
+
+virt_viewer_signal_connect_object(G_OBJECT(item), "toggled",
+G_CALLBACK(menu_display_visible_toggled_cb), display, 0);
+gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
+
gtk_widget_get_visible(GTK_WIDGET(virt_viewer_window_get_window(win;
+gtk_menu_shell_append(submenu, item);
+}
+}
+
 gtk_widget_show_all(GTK_WIDGET(submenu));
 g_list_free(keys);
 }
-- 
2.19.0.271.gfe8321ec05

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

[virt-tools-list] [PATCH v2 07/16] session: skip monitor changes if there is no sized monitors

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

spice-gtk discards configurations without any sized monitors.

Also shuts extra warnings when shifting the monitors.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-session.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c
index 5bac3d9..cd1f037 100644
--- a/src/virt-viewer-session.c
+++ b/src/virt-viewer-session.c
@@ -406,6 +406,7 @@ 
virt_viewer_session_on_monitor_geometry_changed(VirtViewerSession* self,
 gboolean all_fullscreen = TRUE;
 /* GHashTable */
 GHashTable *monitors;
+gint n_sized_monitors = 0;
 GList *l;
 
 klass = VIRT_VIEWER_SESSION_GET_CLASS(self);
@@ -421,6 +422,8 @@ 
virt_viewer_session_on_monitor_geometry_changed(VirtViewerSession* self,
 
 g_object_get(d, "nth-display", &nth, NULL);
 virt_viewer_display_get_preferred_monitor_geometry(d, rect);
+if (rect->width > 0 && rect->height > 0)
+n_sized_monitors++;
 
 if (virt_viewer_display_get_enabled(d) &&
 !virt_viewer_display_get_fullscreen(d))
@@ -428,6 +431,9 @@ 
virt_viewer_session_on_monitor_geometry_changed(VirtViewerSession* self,
 g_hash_table_insert(monitors, GINT_TO_POINTER(nth), rect);
 }
 
+if (!n_sized_monitors)
+return;
+
 if (!all_fullscreen)
 virt_viewer_align_monitors_linear(monitors);
 
-- 
2.19.0.271.gfe8321ec05

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

[virt-tools-list] [PATCH v2 06/16] display: ignore display that do not have toplevel window

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

virt_viewer_display_get_preferred_monitor_geometry() may be called
during application initialization (when the VTE console is being
shown, virt_viewer_session_update_displays_geometry() is called when
the visibility menu item is toggled). But the other displays may not
yet be associated with a window, ignore them.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-display.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index b3cc095..a1fcb82 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -687,7 +687,9 @@ void 
virt_viewer_display_get_preferred_monitor_geometry(VirtViewerDisplay* self,
 
 g_return_if_fail(preferred != NULL);
 
-if (!virt_viewer_display_get_enabled(self)) {
+top = gtk_widget_get_toplevel(GTK_WIDGET(self));
+if (!virt_viewer_display_get_enabled(self) ||
+!GTK_IS_WINDOW(top)) {
 preferred->width = 0;
 preferred->height = 0;
 preferred->x = 0;
@@ -695,7 +697,6 @@ void 
virt_viewer_display_get_preferred_monitor_geometry(VirtViewerDisplay* self,
 return;
 }
 
-top = gtk_widget_get_toplevel(GTK_WIDGET(self));
 gtk_window_get_position(GTK_WINDOW(top), &topx, &topy);
 topx = MAX(topx, 0);
 topy = MAX(topy, 0);
-- 
2.19.0.271.gfe8321ec05

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

[virt-tools-list] [PATCH v2 05/16] window/zoom: deal with VTE display differently

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

VTE display doesn't use the desktop / window aspect ratio, let's just
call directly the functions handling zoom.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-window.c | 28 ++--
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index e50ac54..67e6f4f 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -42,6 +42,7 @@
 #include "virt-viewer-app.h"
 #include "virt-viewer-util.h"
 #include "virt-viewer-timed-revealer.h"
+#include "virt-viewer-display-vte.h"
 
 #include "remote-viewer-iso-list-dialog.h"
 
@@ -383,23 +384,35 @@ G_MODULE_EXPORT void
 virt_viewer_window_menu_view_zoom_out(GtkWidget *menu G_GNUC_UNUSED,
   VirtViewerWindow *self)
 {
-virt_viewer_window_set_zoom_level(self,
-  
virt_viewer_window_get_real_zoom_level(self) - ZOOM_STEP);
+if (VIRT_VIEWER_IS_DISPLAY_VTE(self->priv->display)) {
+
virt_viewer_display_vte_zoom_out(VIRT_VIEWER_DISPLAY_VTE(self->priv->display));
+} else {
+virt_viewer_window_set_zoom_level(self,
+  
virt_viewer_window_get_real_zoom_level(self) - ZOOM_STEP);
+}
 }
 
 G_MODULE_EXPORT void
 virt_viewer_window_menu_view_zoom_in(GtkWidget *menu G_GNUC_UNUSED,
  VirtViewerWindow *self)
 {
-virt_viewer_window_set_zoom_level(self,
-  
virt_viewer_window_get_real_zoom_level(self) + ZOOM_STEP);
+if (VIRT_VIEWER_IS_DISPLAY_VTE(self->priv->display)) {
+
virt_viewer_display_vte_zoom_in(VIRT_VIEWER_DISPLAY_VTE(self->priv->display));
+} else {
+virt_viewer_window_set_zoom_level(self,
+  
virt_viewer_window_get_real_zoom_level(self) + ZOOM_STEP);
+}
 }
 
 G_MODULE_EXPORT void
 virt_viewer_window_menu_view_zoom_reset(GtkWidget *menu G_GNUC_UNUSED,
 VirtViewerWindow *self)
 {
-virt_viewer_window_set_zoom_level(self, NORMAL_ZOOM_LEVEL);
+if (VIRT_VIEWER_IS_DISPLAY_VTE(self->priv->display)) {
+
virt_viewer_display_vte_zoom_reset(VIRT_VIEWER_DISPLAY_VTE(self->priv->display));
+} else {
+virt_viewer_window_set_zoom_level(self, NORMAL_ZOOM_LEVEL);
+}
 }
 
 /* Kick GtkWindow to tell it to adjust to our new widget sizes */
@@ -1521,7 +1534,10 @@ virt_viewer_window_set_zoom_level(VirtViewerWindow 
*self, gint zoom_level)
 
 virt_viewer_display_set_zoom_level(VIRT_VIEWER_DISPLAY(priv->display), 
priv->zoomlevel);
 
-virt_viewer_window_queue_resize(self);
+if (VIRT_VIEWER_IS_DISPLAY_VTE(priv->display)) {
+} else {
+virt_viewer_window_queue_resize(self);
+}
 }
 
 gint virt_viewer_window_get_zoom_level(VirtViewerWindow *self)
-- 
2.19.0.271.gfe8321ec05

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

[virt-tools-list] [PATCH v2 04/16] Add a VirtViewerDisplayVte display kind

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

This is not a graphical display, so the application will have to deal
with it with care.

You may argue that we need a large refactoring to introduce a more
generic "console" object, that could be either graphical or textual.
For now, this does work well enough for me.

Signed-off-by: Marc-André Lureau 
---
 src/Makefile.am   |   4 +
 src/virt-viewer-display-vte.c | 319 ++
 src/virt-viewer-display-vte.h |  81 +
 3 files changed, 404 insertions(+)
 create mode 100644 src/virt-viewer-display-vte.c
 create mode 100644 src/virt-viewer-display-vte.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 0a3cbbf..3a5d90d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -72,6 +72,8 @@ libvirt_viewer_la_SOURCES =   
\
virt-viewer-window.c\
virt-viewer-vm-connection.h \
virt-viewer-vm-connection.c \
+   virt-viewer-display-vte.h   \
+   virt-viewer-display-vte.c   \
virt-viewer-timed-revealer.c \
virt-viewer-timed-revealer.h \
$(NULL)
@@ -110,6 +112,7 @@ COMMON_LIBS = \
$(GLIB2_LIBS)   \
$(GTK_LIBS) \
$(GTK_VNC_LIBS) \
+   $(VTE_LIBS) \
$(SPICE_GTK_LIBS)   \
$(LIBXML2_LIBS) \
$(OVIRT_LIBS) \
@@ -121,6 +124,7 @@ COMMON_CFLAGS = \
$(GLIB2_CFLAGS) \
$(GTK_CFLAGS) \
$(GTK_VNC_CFLAGS) \
+   $(VTE_CFLAGS) \
$(SPICE_GTK_CFLAGS) \
$(LIBXML2_CFLAGS) \
$(OVIRT_CFLAGS) \
diff --git a/src/virt-viewer-display-vte.c b/src/virt-viewer-display-vte.c
new file mode 100644
index 000..bd7ac7d
--- /dev/null
+++ b/src/virt-viewer-display-vte.c
@@ -0,0 +1,319 @@
+/*
+ * Virt Viewer: A virtual machine console viewer
+ *
+ * Copyright (C) 2018 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: Marc-André Lureau 
+ */
+
+#include 
+#include 
+
+#ifdef HAVE_VTE
+#include 
+#endif
+
+#include "virt-viewer-auth.h"
+#include "virt-viewer-display-vte.h"
+#include "virt-viewer-util.h"
+
+G_DEFINE_TYPE(VirtViewerDisplayVte, virt_viewer_display_vte, 
VIRT_VIEWER_TYPE_DISPLAY)
+
+struct _VirtViewerDisplayVtePrivate {
+#ifdef HAVE_VTE
+VteTerminal *vte;
+#endif
+GtkWidget *scroll;
+gchar *name;
+};
+
+#define VIRT_VIEWER_DISPLAY_VTE_GET_PRIVATE(o) 
(G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_DISPLAY_VTE, 
VirtViewerDisplayVtePrivate))
+
+enum {
+PROP_0,
+
+PROP_NAME,
+};
+
+static void
+virt_viewer_display_vte_finalize(GObject *obj)
+{
+G_OBJECT_CLASS(virt_viewer_display_vte_parent_class)->finalize(obj);
+}
+
+static void
+virt_viewer_display_vte_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+VirtViewerDisplayVte *self = VIRT_VIEWER_DISPLAY_VTE(object);
+
+switch (prop_id) {
+case PROP_NAME:
+g_free(self->priv->name);
+self->priv->name = g_value_dup_string(value);
+break;
+default:
+G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+break;
+}
+}
+
+static void
+virt_viewer_display_vte_get_property(GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+VirtViewerDisplayVte *self = VIRT_VIEWER_DISPLAY_VTE(object);
+
+switch (prop_id) {
+case PROP_NAME:
+g_value_set_string(value, self->priv->name);
+break;
+default:
+G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+break;
+}
+}
+
+static void
+virt_viewer_display_vte_size_allocate(GtkWidget *widget G_GNUC_UNUSED,
+  GtkAllocation *allocation G_GNUC_UNUSED)
+{
+GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget));
+
+if (child && gtk_widget_get_visible(child))
+gtk_widget_size_allocate(child, a

[virt-tools-list] [PATCH v2 03/16] build-sys: check for VTE library

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 configure.ac | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/configure.ac b/configure.ac
index 9b52eb4..e2d86a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -172,6 +172,18 @@ AS_IF([test "x$with_spice_gtk" = "xyes"],
 )
 AM_CONDITIONAL([HAVE_SPICE_GTK], [test "x$with_spice_gtk" = "xyes"])
 
+AC_ARG_WITH([vte],
+AS_HELP_STRING([--without-vte], [Ignore presence of vte and disable it]))
+
+AS_IF([test "x$with_vte" != "xno" && test "x$with_vte" != "xyes"],
+  [PKG_CHECK_EXISTS([vte-2.91], [with_vte=yes], [with_vte=no])])
+
+AS_IF([test "x$with_vte" = "xyes"],
+  [PKG_CHECK_MODULES(VTE, [vte-2.91])]
+  [AC_DEFINE([HAVE_VTE], 1, [Have vte?])]
+)
+AM_CONDITIONAL([HAVE_VTE], [test "x$with_vte" = "xyes"])
+
 AC_ARG_WITH([ovirt],
 AS_HELP_STRING([--without-ovirt], [Ignore presence of librest and disable 
oVirt support]))
 
@@ -271,6 +283,8 @@ AC_MSG_NOTICE([ GTK_VNC: $GTK_VNC_CFLAGS $GTK_VNC_LIBS])
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([   SPICE_GTK: $SPICE_GTK_CFLAGS $SPICE_GTK_LIBS])
 AC_MSG_NOTICE([])
+AC_MSG_NOTICE([ VTE: $VTE_CFLAGS $VTE_LIBS])
+AC_MSG_NOTICE([])
 AC_MSG_NOTICE([ LIBXML2: $LIBXML2_CFLAGS $LIBXML2_LIBS])
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([ LIBVIRT: $LIBVIRT_CFLAGS $LIBVIRT_LIBS])
-- 
2.19.0.271.gfe8321ec05

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

[virt-tools-list] [PATCH v2 02/16] window: set sensitivity based on display capability

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

A following patch is adding a new display (VTE) that won't have the
send_key() or screenshot() callbacks. Activating those menu/actions
would lead to nothing or a crash. I chose to keep the UI consistent
for all display, but disable the menu sensitivity.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-display.h |  6 ++
 src/virt-viewer-window.c  | 14 ++
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/virt-viewer-display.h b/src/virt-viewer-display.h
index 7016a85..2de17db 100644
--- a/src/virt-viewer-display.h
+++ b/src/virt-viewer-display.h
@@ -86,6 +86,12 @@ struct _VirtViewerDisplayClass {
 void (*disable)(VirtViewerDisplay *display);
 };
 
+#define VIRT_VIEWER_DISPLAY_CAN_SCREENSHOT(display) \
+(display && (VIRT_VIEWER_DISPLAY_GET_CLASS(display)->get_pixbuf != NULL))
+
+#define VIRT_VIEWER_DISPLAY_CAN_SEND_KEYS(display) \
+(display && (VIRT_VIEWER_DISPLAY_GET_CLASS(display)->send_keys != NULL))
+
 GType virt_viewer_display_get_type(void);
 
 GtkWidget *virt_viewer_display_new(void);
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 74afb32..e50ac54 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -1339,15 +1339,21 @@ virt_viewer_window_set_menus_sensitive(VirtViewerWindow 
*self, gboolean sensitiv
 gtk_widget_set_sensitive(menu, sensitive);
 
 menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, 
"menu-file-screenshot"));
-gtk_widget_set_sensitive(menu, sensitive);
+gtk_widget_set_sensitive(menu, sensitive &&
+ 
VIRT_VIEWER_DISPLAY_CAN_SCREENSHOT(self->priv->display));
 
 menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-view-zoom"));
 gtk_widget_set_sensitive(menu, sensitive);
 
-menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-send"));
-gtk_widget_set_sensitive(menu, sensitive);
+{
+gboolean can_send = sensitive &&
+VIRT_VIEWER_DISPLAY_CAN_SEND_KEYS(self->priv->display);
 
-gtk_widget_set_sensitive(self->priv->toolbar_send_key, sensitive);
+menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-send"));
+gtk_widget_set_sensitive(menu, can_send);
+
+gtk_widget_set_sensitive(self->priv->toolbar_send_key, can_send);
+}
 }
 
 static void
-- 
2.19.0.271.gfe8321ec05

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

[virt-tools-list] [PATCH v2 01/16] window: do not reset sensitivity of menu-send in rebuild

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

The sensitivy of "menu-send" is getting more complex in the following
patch. Let's have the logic in a single place,
virt_viewer_window_set_menus_sensitive().

rebuild_combo_menu() is called in 2 cases:

1. notify::enable-accel: there is no need to update the sensitivy of
   "menu-send"

2. on construction: default to false since display == NULL. It will be
   later updated when virt_viewer_window_set_menus_sensitive(). The
   default sensitivity is covered by previous .ui patch change.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-window.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 241b627..74afb32 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -219,7 +219,6 @@ rebuild_combo_menu(GObject*gobject G_GNUC_UNUSED,
 menu = GTK_WIDGET(gtk_builder_get_object(self->priv->builder, 
"menu-send"));
 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu),
   
GTK_WIDGET(virt_viewer_window_get_keycombo_menu(self)));
-gtk_widget_set_sensitive(menu, (self->priv->display != NULL));
 }
 
 static void
-- 
2.19.0.271.gfe8321ec05

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

[virt-tools-list] [PATCH v2 00/16] Add QEMU-like UI: VT console & basic VM state

2018-09-26 Thread marcandre . lureau
From: Marc-André Lureau 

Hi,

QEMU provides multiple display backend, with different set of
features. One of the richest UI is the -display gtk. It is quite
minimal, and comparable to remote-viewer UI wrt fullscreen, zooming,
grabbing. I haven't done a detailed comparison, but for regular use, I
prefer the remote-viewer UI. The fullscreen mode has a popup toolbar,
there is a send-key menu, it provides better desktop integration
support: USB redirection, folder sharing, more complete multi-monitor
configuration, screenshot. remote-viewer also allows hotkey
configuration, and has an experimental "kiosk" mode.

However, remote-viewer is lacking 2 important features compared to
QEMU UI: VT console (for serials, and monitors) and basic VM state
commands (power off, reset, pause..).

This series add support for VT console over Spice ports, and QMP
monitor to provide a similar user experience as QEMU -display gtk.
Another RFC series for QEMU "[PATCH 00/10] RFC: spice: add -display
app to launch external UI" provides a new "-display app" backend, that
will configure QEMU appropriately, and start remote-viewer (actually
any client handling spice+unix://). The result is that the "QEMU UI
experience" is entirely out of qemu code base and process.

thanks

v2:
 - rebased
 - "spice: hook into QMP port" now uses spice-gtk v0.36 SpiceQmpPort
 - commit message updates

Marc-André Lureau (16):
  window: do not reset sensitivity of menu-send in rebuild
  window: set sensitivity based on display capability
  build-sys: check for VTE library
  Add a VirtViewerDisplayVte display kind
  window/zoom: deal with VTE display differently
  display: ignore display that do not have toplevel window
  session: skip monitor changes if there is no sized monitors
  app: set subtitle using VTE name
  app: append VTE consoles to display submenu
  display: allow display without associated monitor number
  session: do not take VTE display into account for geometry changes
  app: create a window for VTE displays
  spice: hook into port channel to create VTE terminals
  app: add "machine" UI
  app: add "vm-running" property
  spice: hook into QMP port

 configure.ac|  16 +-
 src/Makefile.am |   4 +
 src/resources/ui/virt-viewer.ui |  46 +
 src/virt-viewer-app.c   | 154 ---
 src/virt-viewer-display-vte.c   | 319 
 src/virt-viewer-display-vte.h   |  81 
 src/virt-viewer-display.c   |   7 +-
 src/virt-viewer-display.h   |   6 +
 src/virt-viewer-session-spice.c | 220 +-
 src/virt-viewer-session.c   |  22 +++
 src/virt-viewer-session.h   |  11 ++
 src/virt-viewer-window.c| 107 ++-
 12 files changed, 955 insertions(+), 38 deletions(-)
 create mode 100644 src/virt-viewer-display-vte.c
 create mode 100644 src/virt-viewer-display-vte.h

-- 
2.19.0.271.gfe8321ec05

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

[virt-tools-list] [PATCH] cli: add memory backing access_mode & source_type

2018-09-17 Thread marcandre . lureau
From: Marc-André Lureau 

Allow to set some memory backing options, ex:
--memorybacking access_mode=shared,source_type=anonymous

Signed-off-by: Marc-André Lureau 
---
 .../cli-test-xml/compare/virt-install-singleton-config-2.xml  | 4 
 tests/clitest.py  | 2 +-
 virtinst/cli.py   | 2 ++
 virtinst/domain/memorybacking.py  | 2 ++
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml 
b/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
index 4e14ef04..b166a889 100644
--- a/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
+++ b/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
@@ -29,6 +29,8 @@
 
   
 
+
+
   
   4
   
@@ -212,6 +214,8 @@
 
   
 
+
+
   
   4
   
diff --git a/tests/clitest.py b/tests/clitest.py
index bdc916a7..daf7f9de 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -390,7 +390,7 @@ cache.mode=emulate,cache.level=3 \
 --numatune 1-3,4,mode=strict \
 --memtune hard_limit=10,soft_limit=20,swap_hard_limit=30,min_guarantee=40 \
 --blkiotune weight=100,device_path=/home/test/1.img,device_weight=200 \
---memorybacking size=1,unit='G',nodeset='1,2-5',nosharepages=yes,locked=yes \
+--memorybacking 
size=1,unit='G',nodeset='1,2-5',nosharepages=yes,locked=yes,access_mode=shared,source_type=memfd
 \
 --features 
acpi=off,eoi=on,privnet=on,hyperv_synic=on,hyperv_reset=on,hyperv_spinlocks=on,hyperv_spinlocks_retries=1234,vmport=off,pmu=off,vmcoreinfo=on
 \
 --clock offset=utc,hpet_present=no,rtc_tickpolicy=merge \
 --sysinfo type=smbios,bios_vendor="Acme 
LLC",bios_version=1.2.3,bios_date=01/01/1970,bios_release=10.22 \
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 3986bef8..e6ef5f68 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -1417,6 +1417,8 @@ ParserMemoryBacking.add_arg("page_unit", "unit")
 ParserMemoryBacking.add_arg("page_nodeset", "nodeset", can_comma=True)
 ParserMemoryBacking.add_arg("nosharepages", "nosharepages", is_onoff=True)
 ParserMemoryBacking.add_arg("locked", "locked", is_onoff=True)
+ParserMemoryBacking.add_arg("access_mode", "access_mode")
+ParserMemoryBacking.add_arg("source_type", "source_type")
 
 
 #
diff --git a/virtinst/domain/memorybacking.py b/virtinst/domain/memorybacking.py
index cef95337..c0967687 100644
--- a/virtinst/domain/memorybacking.py
+++ b/virtinst/domain/memorybacking.py
@@ -22,3 +22,5 @@ class DomainMemoryBacking(XMLBuilder):
 page_nodeset = XMLProperty("./hugepages/page/@nodeset")
 nosharepages = XMLProperty("./nosharepages", is_bool=True)
 locked = XMLProperty("./locked", is_bool=True)
+access_mode = XMLProperty("./access/@mode")
+source_type = XMLProperty("./source/@type")
-- 
2.19.0

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

[virt-tools-list] [PATCH 22/22] spice: hook into QMP port

2018-08-05 Thread marcandre . lureau
From: Marc-André Lureau 

If the "org.qemu.monitor.qmp.0" port is available:
- enable the VM UI
- get and follow the VM state
- send the requested VM actions

This adds a json-glib dependency on spice-gtk display. If necessary,
we could make it optional.

Signed-off-by: Marc-André Lureau 
---
 configure.ac|   8 +-
 src/Makefile.am |   2 +
 src/virt-viewer-session-spice.c | 166 
 3 files changed, 175 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 3c7522d..c5aa0dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,6 +27,7 @@ GTK_VNC_REQUIRED="0.4.0"
 SPICE_GTK_REQUIRED="0.35"
 SPICE_PROTOCOL_REQUIRED="0.12.7"
 GOVIRT_REQUIRED="0.3.2"
+JSON_GLIB_REQUIRED="1.0"
 
 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([JSON_GLIB_REQUIRED])
 
 AC_MSG_CHECKING([for native Win32])
 case "$host_os" in
@@ -159,13 +161,15 @@ AC_ARG_WITH([spice-gtk],
 AS_IF([test "x$with_spice_gtk" != "xno" && test "x$with_spice_gtk" != "xyes"],
   [PKG_CHECK_EXISTS([spice-client-gtk-3.0 >= $SPICE_GTK_REQUIRED
  spice-client-glib-2.0 >= $SPICE_GTK_REQUIRED
- spice-protocol >= $SPICE_PROTOCOL_REQUIRED],
+ spice-protocol >= $SPICE_PROTOCOL_REQUIRED
+ json-glib-1.0 >= $JSON_GLIB_REQUIRED],
 [with_spice_gtk=yes], [with_spice_gtk=no])])
 
 AS_IF([test "x$with_spice_gtk" = "xyes"],
   [PKG_CHECK_MODULES(SPICE_GTK, [spice-client-gtk-3.0 >= 
$SPICE_GTK_REQUIRED
  spice-client-glib-2.0 >= 
$SPICE_GTK_REQUIRED])]
   [PKG_CHECK_MODULES(SPICE_PROTOCOL, [spice-protocol >= 
$SPICE_PROTOCOL_REQUIRED])]
+  [PKG_CHECK_MODULES(JSON_GLIB, [json-glib-1.0 >= JSON_GLIB_REQUIRED])]
   [AC_DEFINE([HAVE_SPICE_GTK], 1, [Have spice-gtk?])]
 )
 AM_CONDITIONAL([HAVE_SPICE_GTK], [test "x$with_spice_gtk" = "xyes"])
@@ -294,3 +298,5 @@ AC_MSG_NOTICE([ LIBVIRT: $LIBVIRT_CFLAGS $LIBVIRT_LIBS])
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([   OVIRT: $OVIRT_CFLAGS $OVIRT_LIBS])
 AC_MSG_NOTICE([])
+AC_MSG_NOTICE([   JSON_GLIB: $JSON_GLIB_CFLAGS $JSON_GLIB_LIBS])
+AC_MSG_NOTICE([])
diff --git a/src/Makefile.am b/src/Makefile.am
index 3a5d90d..b2dc786 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -114,6 +114,7 @@ COMMON_LIBS = \
$(GTK_VNC_LIBS) \
$(VTE_LIBS) \
$(SPICE_GTK_LIBS)   \
+   $(JSON_GLIB_LIBS)   \
$(LIBXML2_LIBS) \
$(OVIRT_LIBS) \
$(NULL)
@@ -125,6 +126,7 @@ COMMON_CFLAGS = \
$(GTK_CFLAGS) \
$(GTK_VNC_CFLAGS) \
$(VTE_CFLAGS) \
+   $(JSON_GLIB_CFLAGS) \
$(SPICE_GTK_CFLAGS) \
$(LIBXML2_CFLAGS) \
$(OVIRT_CFLAGS) \
diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index 1c622e6..39aae1d 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -27,6 +27,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 #include "virt-viewer-file.h"
@@ -39,6 +40,8 @@
 
 G_DEFINE_TYPE (VirtViewerSessionSpice, virt_viewer_session_spice, 
VIRT_VIEWER_TYPE_SESSION)
 
+typedef void (QMPCb)(VirtViewerSessionSpice *self, JsonNode *node);
+
 struct _VirtViewerSessionSpicePrivate {
 GtkWindow *main_window;
 SpiceSession *session;
@@ -51,7 +54,11 @@ struct _VirtViewerSessionSpicePrivate {
 guint pass_try;
 gboolean did_auto_conf;
 VirtViewerFileTransferDialog *file_transfer_dialog;
+SpicePortChannel *qmp;
 
+GString *qmp_data;
+JsonParser *qmp_parser;
+GHashTable *qmp_cb;
 };
 
 #define VIRT_VIEWER_SESSION_SPICE_GET_PRIVATE(o) 
(G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_SESSION_SPICE, 
VirtViewerSessionSpicePrivate))
@@ -80,6 +87,7 @@ static void 
virt_viewer_session_spice_smartcard_insert(VirtViewerSession *sessio
 static void virt_viewer_session_spice_smartcard_remove(VirtViewerSession 
*session);
 static gboolean 
virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice *self);
 static void virt_viewer_session_spice_apply_monitor_geometry(VirtViewerSession 
*self, GHashTable *monitors);
+static void virt_viewer_session_spice_vm_action(VirtViewerSession *self, gint 
action);
 
 static void virt_viewer_session_spice_clear_displays(VirtViewerSessionSpice 
*self)
 {
@@ -236,6 +244,16 @@ virt_viewer_session_spice_constructed(GObject *obj)
 G_OBJECT_CLASS(virt_viewer_session_spice_parent_class)->constructed(obj);
 }
 
+static void
+virt_viewer_session_spice_finalize(GObject *obj)
+{
+VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(obj);
+
+g_string_free(self->priv->qmp_data, TRUE);
+g_object_unref(self->priv->qm

[virt-tools-list] [PATCH 20/22] app: add "machine" UI

2018-08-05 Thread marcandre . lureau
From: Marc-André Lureau 

Add a new "Machine" menu, which allows to Pause/Reset/Power Down a VM.

The menu is only visible if "vm-ui" app property is set.

When the application quits, it will also send a quit action to the VM.

This is a similar behaviour/UI as qemu -display gtk.

Signed-off-by: Marc-André Lureau 
---
 src/resources/ui/virt-viewer.ui | 46 ++
 src/virt-viewer-app.c   | 24 
 src/virt-viewer-session.c   | 11 
 src/virt-viewer-session.h   | 11 
 src/virt-viewer-window.c| 50 +
 5 files changed, 142 insertions(+)

diff --git a/src/resources/ui/virt-viewer.ui b/src/resources/ui/virt-viewer.ui
index 9da1403..93471a4 100644
--- a/src/resources/ui/virt-viewer.ui
+++ b/src/resources/ui/virt-viewer.ui
@@ -113,6 +113,52 @@
 
   
 
+
+  
+False
+_Machine
+True
+
+  
+True
+False
+
+  
+True
+False
+_Pause
+True
+
+  
+
+
+  
+True
+False
+  
+
+
+  
+True
+False
+_Reset
+True
+
+  
+
+
+  
+True
+False
+_Power 
down
+True
+
+  
+
+  
+
+  
+
 
   
 True
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 39a147f..445702d 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -127,6 +127,7 @@ struct _VirtViewerAppPrivate {
 gboolean attach;
 gboolean quitting;
 gboolean kiosk;
+gboolean vm_ui;
 
 VirtViewerSession *session;
 gboolean active;
@@ -176,6 +177,7 @@ enum {
 PROP_KIOSK,
 PROP_QUIT_ON_DISCONNECT,
 PROP_UUID,
+PROP_VM_UI,
 };
 
 void
@@ -284,6 +286,11 @@ virt_viewer_app_quit(VirtViewerApp *self)
 
 virt_viewer_app_save_config(self);
 
+if (priv->vm_ui) {
+virt_viewer_session_vm_action(VIRT_VIEWER_SESSION(priv->session),
+  VIRT_VIEWER_SESSION_VM_ACTION_QUIT);
+}
+
 if (priv->session) {
 virt_viewer_session_close(VIRT_VIEWER_SESSION(priv->session));
 if (priv->connected) {
@@ -1604,6 +1611,10 @@ virt_viewer_app_get_property (GObject *object, guint 
property_id,
 g_value_set_string(value, priv->uuid);
 break;
 
+case PROP_VM_UI:
+g_value_set_boolean(value, priv->vm_ui);
+break;
+
 default:
 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 }
@@ -1658,6 +1669,10 @@ virt_viewer_app_set_property (GObject *object, guint 
property_id,
 virt_viewer_app_set_uuid_string(self, g_value_get_string(value));
 break;
 
+case PROP_VM_UI:
+priv->vm_ui = g_value_get_boolean(value);
+break;
+
 default:
 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 }
@@ -2058,6 +2073,15 @@ virt_viewer_app_class_init (VirtViewerAppClass *klass)
 G_PARAM_READABLE |
 G_PARAM_WRITABLE |
 
G_PARAM_STATIC_STRINGS));
+
+g_object_class_install_property(object_class,
+PROP_VM_UI,
+g_param_spec_boolean("vm-ui",
+ "VM UI",
+ "QEMU UI & behaviour",
+ FALSE,
+ G_PARAM_READWRITE |
+ 
G_PARAM_STATIC_STRINGS));
 }
 
 void
diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c
index a40b0bb..3336abe 100644
--- a/src/virt-viewer-session.c
+++ b/src/virt-viewer-session.c
@@ -688,6 +688,17 @@ gboolean 
virt_viewer_session_can_retry_auth(VirtViewer

[virt-tools-list] [PATCH 12/22] display: ignore display that do not have toplevel window

2018-08-05 Thread marcandre . lureau
From: Marc-André Lureau 

virt_viewer_display_get_preferred_monitor_geometry() may be called
during application initialization (when the VTE console is being
shown, virt_viewer_session_update_displays_geometry() is called when
the visibility menu item is toggled). But the other displays may not
yet be associated with a window, ignore them.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-display.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index b3cc095..a1fcb82 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -687,7 +687,9 @@ void 
virt_viewer_display_get_preferred_monitor_geometry(VirtViewerDisplay* self,
 
 g_return_if_fail(preferred != NULL);
 
-if (!virt_viewer_display_get_enabled(self)) {
+top = gtk_widget_get_toplevel(GTK_WIDGET(self));
+if (!virt_viewer_display_get_enabled(self) ||
+!GTK_IS_WINDOW(top)) {
 preferred->width = 0;
 preferred->height = 0;
 preferred->x = 0;
@@ -695,7 +697,6 @@ void 
virt_viewer_display_get_preferred_monitor_geometry(VirtViewerDisplay* self,
 return;
 }
 
-top = gtk_widget_get_toplevel(GTK_WIDGET(self));
 gtk_window_get_position(GTK_WINDOW(top), &topx, &topy);
 topx = MAX(topx, 0);
 topy = MAX(topy, 0);
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 10/22] Add a VirtViewerDisplayVte display kind

2018-08-05 Thread marcandre . lureau
From: Marc-André Lureau 

This is not a graphical display, so the application will have to deal
with it with care.

You may argue that we need a large refactoring to introduce a more
generic "console" object, that could be either graphical or textual.
For now, this does work well enough for me.

Signed-off-by: Marc-André Lureau 
---
 src/Makefile.am   |   4 +
 src/virt-viewer-display-vte.c | 319 ++
 src/virt-viewer-display-vte.h |  81 +
 3 files changed, 404 insertions(+)
 create mode 100644 src/virt-viewer-display-vte.c
 create mode 100644 src/virt-viewer-display-vte.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 0a3cbbf..3a5d90d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -72,6 +72,8 @@ libvirt_viewer_la_SOURCES =   
\
virt-viewer-window.c\
virt-viewer-vm-connection.h \
virt-viewer-vm-connection.c \
+   virt-viewer-display-vte.h   \
+   virt-viewer-display-vte.c   \
virt-viewer-timed-revealer.c \
virt-viewer-timed-revealer.h \
$(NULL)
@@ -110,6 +112,7 @@ COMMON_LIBS = \
$(GLIB2_LIBS)   \
$(GTK_LIBS) \
$(GTK_VNC_LIBS) \
+   $(VTE_LIBS) \
$(SPICE_GTK_LIBS)   \
$(LIBXML2_LIBS) \
$(OVIRT_LIBS) \
@@ -121,6 +124,7 @@ COMMON_CFLAGS = \
$(GLIB2_CFLAGS) \
$(GTK_CFLAGS) \
$(GTK_VNC_CFLAGS) \
+   $(VTE_CFLAGS) \
$(SPICE_GTK_CFLAGS) \
$(LIBXML2_CFLAGS) \
$(OVIRT_CFLAGS) \
diff --git a/src/virt-viewer-display-vte.c b/src/virt-viewer-display-vte.c
new file mode 100644
index 000..bd7ac7d
--- /dev/null
+++ b/src/virt-viewer-display-vte.c
@@ -0,0 +1,319 @@
+/*
+ * Virt Viewer: A virtual machine console viewer
+ *
+ * Copyright (C) 2018 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: Marc-André Lureau 
+ */
+
+#include 
+#include 
+
+#ifdef HAVE_VTE
+#include 
+#endif
+
+#include "virt-viewer-auth.h"
+#include "virt-viewer-display-vte.h"
+#include "virt-viewer-util.h"
+
+G_DEFINE_TYPE(VirtViewerDisplayVte, virt_viewer_display_vte, 
VIRT_VIEWER_TYPE_DISPLAY)
+
+struct _VirtViewerDisplayVtePrivate {
+#ifdef HAVE_VTE
+VteTerminal *vte;
+#endif
+GtkWidget *scroll;
+gchar *name;
+};
+
+#define VIRT_VIEWER_DISPLAY_VTE_GET_PRIVATE(o) 
(G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_DISPLAY_VTE, 
VirtViewerDisplayVtePrivate))
+
+enum {
+PROP_0,
+
+PROP_NAME,
+};
+
+static void
+virt_viewer_display_vte_finalize(GObject *obj)
+{
+G_OBJECT_CLASS(virt_viewer_display_vte_parent_class)->finalize(obj);
+}
+
+static void
+virt_viewer_display_vte_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+VirtViewerDisplayVte *self = VIRT_VIEWER_DISPLAY_VTE(object);
+
+switch (prop_id) {
+case PROP_NAME:
+g_free(self->priv->name);
+self->priv->name = g_value_dup_string(value);
+break;
+default:
+G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+break;
+}
+}
+
+static void
+virt_viewer_display_vte_get_property(GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+VirtViewerDisplayVte *self = VIRT_VIEWER_DISPLAY_VTE(object);
+
+switch (prop_id) {
+case PROP_NAME:
+g_value_set_string(value, self->priv->name);
+break;
+default:
+G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+break;
+}
+}
+
+static void
+virt_viewer_display_vte_size_allocate(GtkWidget *widget G_GNUC_UNUSED,
+  GtkAllocation *allocation G_GNUC_UNUSED)
+{
+GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget));
+
+if (child && gtk_widget_get_visible(child))
+gtk_widget_size_allocate(child, a

[virt-tools-list] [PATCH 02/22] Remove class signal handlers

2018-08-05 Thread marcandre . lureau
From: Marc-André Lureau 

We don't use class signal handlers, remove the extra pointers.

g_signal_override_class_handler() could be used instead when needed.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-display.c | 10 +-
 src/virt-viewer-display.h |  8 
 src/virt-viewer-session.c | 26 +-
 src/virt-viewer-session.h | 19 ---
 4 files changed, 18 insertions(+), 45 deletions(-)

diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index 2dbaba1..011328e 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -183,7 +183,7 @@ virt_viewer_display_class_init(VirtViewerDisplayClass 
*class)
 g_signal_new("display-pointer-grab",
  G_OBJECT_CLASS_TYPE(object_class),
  G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
- G_STRUCT_OFFSET(VirtViewerDisplayClass, display_pointer_grab),
+ 0,
  NULL,
  NULL,
  g_cclosure_marshal_VOID__VOID,
@@ -193,7 +193,7 @@ virt_viewer_display_class_init(VirtViewerDisplayClass 
*class)
 g_signal_new("display-pointer-ungrab",
  G_OBJECT_CLASS_TYPE(object_class),
  G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
- G_STRUCT_OFFSET(VirtViewerDisplayClass, 
display_pointer_ungrab),
+ 0,
  NULL,
  NULL,
  g_cclosure_marshal_VOID__VOID,
@@ -203,7 +203,7 @@ virt_viewer_display_class_init(VirtViewerDisplayClass 
*class)
 g_signal_new("display-keyboard-grab",
  G_OBJECT_CLASS_TYPE(object_class),
  G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
- G_STRUCT_OFFSET(VirtViewerDisplayClass, 
display_keyboard_grab),
+ 0,
  NULL,
  NULL,
  g_cclosure_marshal_VOID__VOID,
@@ -213,7 +213,7 @@ virt_viewer_display_class_init(VirtViewerDisplayClass 
*class)
 g_signal_new("display-keyboard-ungrab",
  G_OBJECT_CLASS_TYPE(object_class),
  G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
- G_STRUCT_OFFSET(VirtViewerDisplayClass, 
display_keyboard_ungrab),
+ 0,
  NULL,
  NULL,
  g_cclosure_marshal_VOID__VOID,
@@ -223,7 +223,7 @@ virt_viewer_display_class_init(VirtViewerDisplayClass 
*class)
 g_signal_new("display-desktop-resize",
  G_OBJECT_CLASS_TYPE(object_class),
  G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
- G_STRUCT_OFFSET(VirtViewerDisplayClass, 
display_desktop_resize),
+ 0,
  NULL,
  NULL,
  g_cclosure_marshal_VOID__VOID,
diff --git a/src/virt-viewer-display.h b/src/virt-viewer-display.h
index 7b55ca5..7016a85 100644
--- a/src/virt-viewer-display.h
+++ b/src/virt-viewer-display.h
@@ -82,14 +82,6 @@ struct _VirtViewerDisplayClass {
 
 void (*close)(VirtViewerDisplay *display);
 gboolean (*selectable)(VirtViewerDisplay *display);
-
-/* signals */
-void (*display_pointer_grab)(VirtViewerDisplay *display);
-void (*display_pointer_ungrab)(VirtViewerDisplay *display);
-void (*display_keyboard_grab)(VirtViewerDisplay *display);
-void (*display_keyboard_ungrab)(VirtViewerDisplay *display);
-
-void (*display_desktop_resize)(VirtViewerDisplay *display);
 void (*enable)(VirtViewerDisplay *display);
 void (*disable)(VirtViewerDisplay *display);
 };
diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c
index 92ffd3f..5bac3d9 100644
--- a/src/virt-viewer-session.c
+++ b/src/virt-viewer-session.c
@@ -259,7 +259,7 @@ virt_viewer_session_class_init(VirtViewerSessionClass 
*class)
 g_signal_new("session-connected",
  G_OBJECT_CLASS_TYPE(object_class),
  G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET(VirtViewerSessionClass, session_connected),
+ 0,
  NULL, NULL,
  g_cclosure_marshal_VOID__VOID,
  G_TYPE_NONE,
@@ -268,7 +268,7 @@ virt_viewer_session_class_init(VirtViewerSessionClass 
*class)
 g_signal_new("session-initialized",
  G_OBJECT_CLASS_TYPE(object_class),
  G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET(VirtViewerSessionClass, session_initialized),
+ 0,
  NULL, NULL,
  g_cclosure_marshal_VOID__VOID,
  G_TYPE_NONE,
@@ -277,7 +277,7 @@ virt_viewer_session_class_init(VirtViewerSessionClass 
*class)
 g_signal_new("session-disconnected",
  G_OBJECT_CLASS_TYPE(object_class),
  G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET(VirtViewerSessionClass, session_disconnected),
+ 0,
  NULL, NULL,
  g_cclosure_marshal_VOID__STRING,
  G_TYPE_

[virt-tools-list] [PATCH 21/22] app: add "vm-running" property

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

Add "vm-running" property and modify "menu-vm-pause" check button
state when the running state changes.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-app.c| 19 +++
 src/virt-viewer-window.c | 16 
 2 files changed, 35 insertions(+)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 445702d..c4dfb51 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -128,6 +128,7 @@ struct _VirtViewerAppPrivate {
 gboolean quitting;
 gboolean kiosk;
 gboolean vm_ui;
+gboolean vm_running;
 
 VirtViewerSession *session;
 gboolean active;
@@ -178,6 +179,7 @@ enum {
 PROP_QUIT_ON_DISCONNECT,
 PROP_UUID,
 PROP_VM_UI,
+PROP_VM_RUNNING,
 };
 
 void
@@ -1615,6 +1617,10 @@ virt_viewer_app_get_property (GObject *object, guint 
property_id,
 g_value_set_boolean(value, priv->vm_ui);
 break;
 
+case PROP_VM_RUNNING:
+g_value_set_boolean(value, priv->vm_running);
+break;
+
 default:
 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 }
@@ -1673,6 +1679,10 @@ virt_viewer_app_set_property (GObject *object, guint 
property_id,
 priv->vm_ui = g_value_get_boolean(value);
 break;
 
+case PROP_VM_RUNNING:
+priv->vm_running = g_value_get_boolean(value);
+break;
+
 default:
 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 }
@@ -2082,6 +2092,15 @@ virt_viewer_app_class_init (VirtViewerAppClass *klass)
  FALSE,
  G_PARAM_READWRITE |
  
G_PARAM_STATIC_STRINGS));
+
+g_object_class_install_property(object_class,
+PROP_VM_RUNNING,
+g_param_spec_boolean("vm-running",
+ "VM running",
+ "VM running",
+ FALSE,
+ G_PARAM_READWRITE |
+ 
G_PARAM_STATIC_STRINGS));
 }
 
 void
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index e2be675..2d7adba 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -237,6 +237,20 @@ vm_ui_changed(GObject*gobject G_GNUC_UNUSED,
 
gtk_widget_set_visible(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, 
"menu-machine")), vm_ui);
 }
 
+static void
+vm_running_changed(GObject*gobject G_GNUC_UNUSED,
+   GParamSpec *pspec G_GNUC_UNUSED,
+   gpointeruser_data)
+{
+VirtViewerWindow *self = user_data;
+GtkCheckMenuItem *check = 
GTK_CHECK_MENU_ITEM(gtk_builder_get_object(self->priv->builder, 
"menu-vm-pause"));
+gboolean running;
+
+g_object_get(G_OBJECT(self->priv->app), "vm-running", &running, NULL);
+
+gtk_check_menu_item_set_active(check, !running);
+}
+
 static void
 virt_viewer_window_constructed(GObject *object)
 {
@@ -249,6 +263,8 @@ virt_viewer_window_constructed(GObject *object)
  G_CALLBACK(rebuild_combo_menu), object);
 g_signal_connect(priv->app, "notify::vm-ui",
  G_CALLBACK(vm_ui_changed), object);
+g_signal_connect(priv->app, "notify::vm-running",
+ G_CALLBACK(vm_running_changed), object);
 rebuild_combo_menu(NULL, NULL, object);
 }
 
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 18/22] app: create a window for VTE displays

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

virt_viewer_app_display_added() now handles VTE displays. They should
be skipped for monitor configuration, and they don't emit "show-hint".

(a VTE display has a monitor nth == -1, which is now a valid value)

The associated window will be hidden when virt-viewer is started.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-app.c | 69 ---
 1 file changed, 52 insertions(+), 17 deletions(-)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 50d1e6c..39a147f 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -112,7 +112,7 @@ struct _VirtViewerAppPrivate {
 VirtViewerWindow *main_window;
 GtkWidget *main_notebook;
 GList *windows;
-GHashTable *displays;
+GHashTable *displays; /* !vte */
 GHashTable *initial_display_map;
 gchar *clipboard;
 GtkWidget *preferences;
@@ -847,9 +847,11 @@ virt_viewer_app_window_new(VirtViewerApp *self, gint nth)
 VirtViewerWindow* window;
 GtkWindow *w;
 
-window = virt_viewer_app_get_nth_window(self, nth);
-if (window)
-return window;
+if (nth >= 0) {
+window = virt_viewer_app_get_nth_window(self, nth);
+if (window)
+return window;
+}
 
 window = g_object_new(VIRT_VIEWER_TYPE_WINDOW, "app", self, NULL);
 virt_viewer_window_set_kiosk(window, self->priv->kiosk);
@@ -875,11 +877,27 @@ virt_viewer_app_window_new(VirtViewerApp *self, gint nth)
 return window;
 }
 
+static void
+window_weak_notify(gpointer data, GObject *where_was G_GNUC_UNUSED)
+{
+VirtViewerDisplay *display = VIRT_VIEWER_DISPLAY(data);
+
+g_object_set_data(G_OBJECT(display), "virt-viewer-window", NULL);
+}
+
 static VirtViewerWindow *
 ensure_window_for_display(VirtViewerApp *self, VirtViewerDisplay *display)
 {
-gint nth = virt_viewer_display_get_nth(display);
-VirtViewerWindow *win = virt_viewer_app_get_nth_window(self, nth);
+VirtViewerWindow *win = NULL;
+gint nth = -1;
+
+if (VIRT_VIEWER_IS_DISPLAY_VTE(display)) {
+win = g_object_get_data(G_OBJECT(display), "virt-viewer-window");
+} else {
+nth = virt_viewer_display_get_nth(display);
+win = virt_viewer_app_get_nth_window(self, nth);
+}
+
 if (win == NULL) {
 GList *l = self->priv->windows;
 
@@ -901,12 +919,26 @@ ensure_window_for_display(VirtViewerApp *self, 
VirtViewerDisplay *display)
 }
 
 virt_viewer_window_set_display(win, display);
+if (VIRT_VIEWER_IS_DISPLAY_VTE(display)) {
+g_object_set_data(G_OBJECT(display), "virt-viewer-window", win);
+g_object_weak_ref(G_OBJECT(win), window_weak_notify, display);
+}
 }
 virt_viewer_app_set_window_subtitle(self, win, nth);
 
 return win;
 }
 
+static VirtViewerWindow *
+display_show_get_window(VirtViewerApp *self, VirtViewerDisplay *display)
+{
+VirtViewerWindow *win = ensure_window_for_display(self, display);
+VirtViewerNotebook *nb = virt_viewer_window_get_notebook(win);
+
+virt_viewer_notebook_show_display(nb);
+return win;
+}
+
 static void
 display_show_hint(VirtViewerDisplay *display,
   GParamSpec *pspec G_GNUC_UNUSED,
@@ -934,9 +966,7 @@ display_show_hint(VirtViewerDisplay *display,
 virt_viewer_window_hide(win);
 } else {
 if (hint & VIRT_VIEWER_DISPLAY_SHOW_HINT_READY) {
-win = ensure_window_for_display(self, display);
-nb = virt_viewer_window_get_notebook(win);
-virt_viewer_notebook_show_display(nb);
+win = display_show_get_window(self, display);
 virt_viewer_window_show(win);
 } else {
 if (!self->priv->kiosk && win) {
@@ -953,19 +983,24 @@ virt_viewer_app_display_added(VirtViewerSession *session 
G_GNUC_UNUSED,
   VirtViewerDisplay *display,
   VirtViewerApp *self)
 {
-gint nth;
+if (VIRT_VIEWER_IS_DISPLAY_VTE(display)) {
+VirtViewerWindow *win = display_show_get_window(self, display);
+virt_viewer_window_hide(win);
+virt_viewer_app_update_menu_displays(self);
+} else {
+gint nth;
 
-g_object_get(display, "nth-display", &nth, NULL);
+g_object_get(display, "nth-display", &nth, NULL);
 
-g_debug("Insert display %d %p", nth, display);
-g_hash_table_insert(self->priv->displays, GINT_TO_POINTER(nth), 
g_object_ref(display));
+g_debug("Insert display %d %p", nth, display);
+g_hash_table_insert(self->priv->displays, GINT_TO_POINTER(nth), 
g_object_ref(display));
 
-g_signal_connect(display, "notify::show-hint",
- G_CALLBACK(display_show_hint), NULL);
-g_object_notify(G_OBJECT(display), "show-hint"); /* call display_show_hint 
*/
+g_signal_connect(display, "notify::show-hint",
+ G_CALLBACK(display_show_hint), NULL);
+g_object_notify(G_OBJE

[virt-tools-list] [PATCH 19/22] spice: hook into port channel to create VTE terminals

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

QEMU defines a few Spice port channel names in
docs/spice-port-fqdn.txt that can be interacted with a terminal.

Create VirtViewerDisplayVte display for all known terminal channel,
and redirect read/write signals.

Note that if VTE support is disabled, or if the VTE console isn't
shown, spice-gtk will still process those port channels (discarding
the read if VTE is disabled).

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-session-spice.c | 118 +++-
 1 file changed, 116 insertions(+), 2 deletions(-)

diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index fdc7004..1c622e6 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -34,6 +34,7 @@
 #include "virt-viewer-util.h"
 #include "virt-viewer-session-spice.h"
 #include "virt-viewer-display-spice.h"
+#include "virt-viewer-display-vte.h"
 #include "virt-viewer-auth.h"
 
 G_DEFINE_TYPE (VirtViewerSessionSpice, virt_viewer_session_spice, 
VIRT_VIEWER_TYPE_SESSION)
@@ -950,20 +951,116 @@ on_new_file_transfer(SpiceMainChannel *channel 
G_GNUC_UNUSED,
   task);
 }
 
+static void
+spice_port_write_finished(GObject *source_object,
+  GAsyncResult *res,
+  gpointer dup)
+{
+SpicePortChannel *port = SPICE_PORT_CHANNEL(source_object);
+GError *err = NULL;
+
+spice_port_channel_write_finish(port, res, &err);
+if (err) {
+g_warning("Spice port write failed: %s", err->message);
+g_error_free(err);
+}
+g_free(dup);
+}
+
+static void
+spice_vte_commit(SpicePortChannel *port, const char *text,
+ guint size, gpointer user_data G_GNUC_UNUSED)
+{
+void *dup = g_memdup(text, size);
+
+/* note: spice-gtk queues write */
+spice_port_channel_write_async(port, dup, size,
+   NULL, spice_port_write_finished, dup);
+}
+
+static void
+spice_port_data(VirtViewerDisplayVte *vte, gpointer data, int size,
+SpicePortChannel *port G_GNUC_UNUSED)
+{
+virt_viewer_display_vte_feed(vte, data, size);
+}
+
+static const char *
+port_name_to_vte_name(const char *name)
+{
+if (g_str_equal(name, "org.qemu.console.serial.0"))
+return _("Serial");
+else if (g_str_equal(name, "org.qemu.monitor.hmp.0"))
+return _("QEMU human monitor");
+else if (g_str_equal(name, "org.qemu.console.debug.0"))
+return _("QEMU debug console");
+
+return NULL;
+}
+
+static void
+spice_port_opened(SpiceChannel *channel, GParamSpec *pspec G_GNUC_UNUSED,
+  VirtViewerSessionSpice *self)
+{
+SpicePortChannel *port = SPICE_PORT_CHANNEL(channel);
+int id;
+gchar *name = NULL;
+gboolean opened = FALSE;
+const char *vte_name;
+GtkWidget *vte;
+
+g_object_get(G_OBJECT(port),
+ "channel-id", &id,
+ "port-name", &name,
+ "port-opened", &opened,
+ NULL);
+
+g_return_if_fail(name != NULL);
+g_debug("port#%d %s: %s", id, name, opened ? "opened" : "closed");
+
+vte = g_object_get_data(G_OBJECT(port), "virt-viewer-vte");
+if (vte) {
+if (opened)
+goto end;
+
+g_object_set_data(G_OBJECT(port), "virt-viewer-vte", NULL);
+virt_viewer_session_remove_display(VIRT_VIEWER_SESSION(self), 
VIRT_VIEWER_DISPLAY(vte));
+
+} else if (opened) {
+vte_name = port_name_to_vte_name(name);
+if (!vte_name)
+goto end;
+
+vte = virt_viewer_display_vte_new(VIRT_VIEWER_SESSION(self), vte_name);
+g_object_set_data(G_OBJECT(port), "virt-viewer-vte", 
g_object_ref_sink(vte));
+virt_viewer_session_add_display(VIRT_VIEWER_SESSION(self), 
VIRT_VIEWER_DISPLAY(vte));
+virt_viewer_signal_connect_object(vte, "commit",
+  G_CALLBACK(spice_vte_commit), port, 
G_CONNECT_SWAPPED);
+virt_viewer_signal_connect_object(port, "port-data",
+  G_CALLBACK(spice_port_data), vte, 
G_CONNECT_SWAPPED);
+}
+
+end:
+g_free(name);
+}
+
 static void
 virt_viewer_session_spice_channel_new(SpiceSession *s,
   SpiceChannel *channel,
   VirtViewerSession *session)
 {
 VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
-int id;
+int id, type;
 
 g_return_if_fail(self != NULL);
 
 virt_viewer_signal_connect_object(channel, "open-fd",
   
G_CALLBACK(virt_viewer_session_spice_channel_open_fd_request), self, 0);
 
-g_object_get(channel, "channel-id", &id, NULL);
+g_object_get(channel,
+ "channel-id", &id,
+ "channel-type", &type,
+ NULL);
 
 g_debug("New spice channel %p %s %d", channel, 
g_type_name(G_OBJECT_TYPE(chann

[virt-tools-list] [PATCH 17/22] session: do not take VTE display into account for geometry changes

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-session.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c
index cd1f037..a40b0bb 100644
--- a/src/virt-viewer-session.c
+++ b/src/virt-viewer-session.c
@@ -29,6 +29,7 @@
 
 #include "virt-viewer-session.h"
 #include "virt-viewer-util.h"
+#include "virt-viewer-display-vte.h"
 
 #define VIRT_VIEWER_SESSION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), 
VIRT_VIEWER_TYPE_SESSION, VirtViewerSessionPrivate))
 
@@ -417,6 +418,10 @@ 
virt_viewer_session_on_monitor_geometry_changed(VirtViewerSession* self,
 
 for (l = self->priv->displays; l; l = l->next) {
 VirtViewerDisplay *d = VIRT_VIEWER_DISPLAY(l->data);
+
+if (VIRT_VIEWER_IS_DISPLAY_VTE(d))
+continue;
+
 guint nth = 0;
 GdkRectangle *rect = g_new0(GdkRectangle, 1);
 
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 15/22] app: append VTE consoles to display submenu

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

Get the name of the console, and set the subtitle with it.

Rename "set_title" to "set_subtitle" while at it, since it is more
appropriate.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-app.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index a14c92d..50d1e6c 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -2334,6 +2334,26 @@ window_update_menu_displays_cb(gpointer value,
 tmp = tmp->next;
 }
 
+for (GList *l = self->priv->windows; l; l = l->next) {
+VirtViewerWindow *win = VIRT_VIEWER_WINDOW(l->data);
+VirtViewerDisplay *display = virt_viewer_window_get_display(win);
+
+if (VIRT_VIEWER_IS_DISPLAY_VTE(display)) {
+gchar *name = NULL;
+GtkWidget *item;
+
+g_object_get(display, "name", &name, NULL);
+item = gtk_check_menu_item_new_with_label(name);
+g_free(name);
+
+virt_viewer_signal_connect_object(G_OBJECT(item), "toggled",
+G_CALLBACK(menu_display_visible_toggled_cb), display, 0);
+gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
+
gtk_widget_get_visible(GTK_WIDGET(virt_viewer_window_get_window(win;
+gtk_menu_shell_append(submenu, item);
+}
+}
+
 gtk_widget_show_all(GTK_WIDGET(submenu));
 g_list_free(keys);
 }
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 14/22] app: set subtitle using VTE name

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

Currently, subtitle indicate the monitor number, ex: "Fedora (1)".

Custom subtitle use %d to place the monitor number.

Let's make this placeholder more generic to place the name of the
console, ex: "Fedora (Serial)".

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-app.c | 22 +-
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 62dbf19..a14c92d 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -62,6 +62,8 @@
 #include "virt-viewer-session-spice.h"
 #endif
 
+#include "virt-viewer-display-vte.h"
+
 gboolean doDebug = FALSE;
 
 /* Signal handlers for about dialog */
@@ -699,15 +701,25 @@ virt_viewer_app_set_window_subtitle(VirtViewerApp *app,
 {
 gchar *subtitle = NULL;
 const gchar *title = virt_viewer_app_get_title(app);
+VirtViewerDisplay *display = virt_viewer_window_get_display(window);
 
 if (title != NULL) {
 gchar *d = strstr(title, "%d");
+gchar *desc = NULL;
+
+if (display && VIRT_VIEWER_IS_DISPLAY_VTE(display)) {
+g_object_get(display, "name", &desc, NULL);
+} else  {
+desc = g_strdup_printf("%d", nth + 1);
+}
+
 if (d != NULL) {
 *d = '\0';
-subtitle = g_strdup_printf("%s%d%s", title, nth + 1, d + 2);
+subtitle = g_strdup_printf("%s%s%s", title, desc, d + 2);
 *d = '%';
 } else
-subtitle = g_strdup_printf("%s (%d)", title, nth + 1);
+subtitle = g_strdup_printf("%s (%s)", title, desc);
+g_free(desc);
 }
 
 g_object_set(window, "subtitle", subtitle, NULL);
@@ -715,8 +727,8 @@ virt_viewer_app_set_window_subtitle(VirtViewerApp *app,
 }
 
 static void
-set_title(gpointer value,
-  gpointer user_data)
+set_subtitle(gpointer value,
+ gpointer user_data)
 {
 VirtViewerApp *app = user_data;
 VirtViewerWindow *window = value;
@@ -732,7 +744,7 @@ set_title(gpointer value,
 static void
 virt_viewer_app_set_all_window_subtitles(VirtViewerApp *app)
 {
-g_list_foreach(app->priv->windows, set_title, app);
+g_list_foreach(app->priv->windows, set_subtitle, app);
 }
 
 static void update_title(gpointer value,
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 16/22] display: allow display without associated monitor number

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

The VTE display will have monitor id -1.

Eventually, having a base "console" class without monitor id could
avoid this allowance.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index a1fcb82..98d4edd 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -129,7 +129,7 @@ virt_viewer_display_class_init(VirtViewerDisplayClass 
*class)
 g_param_spec_int("nth-display",
  "Nth display",
  "Nth display",
- 0,
+ -1,
  G_MAXINT32,
  0,
  G_PARAM_READWRITE |
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 13/22] session: skip monitor changes if there is no sized monitors

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

spice-gtk discards configurations without any sized monitors.

Also shuts extra warnings when shifting the monitors.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-session.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/virt-viewer-session.c b/src/virt-viewer-session.c
index 5bac3d9..cd1f037 100644
--- a/src/virt-viewer-session.c
+++ b/src/virt-viewer-session.c
@@ -406,6 +406,7 @@ 
virt_viewer_session_on_monitor_geometry_changed(VirtViewerSession* self,
 gboolean all_fullscreen = TRUE;
 /* GHashTable */
 GHashTable *monitors;
+gint n_sized_monitors = 0;
 GList *l;
 
 klass = VIRT_VIEWER_SESSION_GET_CLASS(self);
@@ -421,6 +422,8 @@ 
virt_viewer_session_on_monitor_geometry_changed(VirtViewerSession* self,
 
 g_object_get(d, "nth-display", &nth, NULL);
 virt_viewer_display_get_preferred_monitor_geometry(d, rect);
+if (rect->width > 0 && rect->height > 0)
+n_sized_monitors++;
 
 if (virt_viewer_display_get_enabled(d) &&
 !virt_viewer_display_get_fullscreen(d))
@@ -428,6 +431,9 @@ 
virt_viewer_session_on_monitor_geometry_changed(VirtViewerSession* self,
 g_hash_table_insert(monitors, GINT_TO_POINTER(nth), rect);
 }
 
+if (!n_sized_monitors)
+return;
+
 if (!all_fullscreen)
 virt_viewer_align_monitors_linear(monitors);
 
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 08/22] display: make klass->close() optional

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

Spice and VTE display do not need to implement it.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-display-spice.c | 8 
 src/virt-viewer-display.c   | 5 ++---
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
index f9b383b..68be8ac 100644
--- a/src/virt-viewer-display-spice.c
+++ b/src/virt-viewer-display-spice.c
@@ -56,7 +56,6 @@ static void 
virt_viewer_display_spice_send_keys(VirtViewerDisplay *display,
 int nkeyvals);
 static GdkPixbuf *virt_viewer_display_spice_get_pixbuf(VirtViewerDisplay 
*display);
 static void virt_viewer_display_spice_release_cursor(VirtViewerDisplay 
*display);
-static void virt_viewer_display_spice_close(VirtViewerDisplay *display 
G_GNUC_UNUSED);
 static gboolean virt_viewer_display_spice_selectable(VirtViewerDisplay 
*display);
 static void virt_viewer_display_spice_enable(VirtViewerDisplay *display);
 static void virt_viewer_display_spice_disable(VirtViewerDisplay *display);
@@ -69,7 +68,6 @@ 
virt_viewer_display_spice_class_init(VirtViewerDisplaySpiceClass *klass)
 dclass->send_keys = virt_viewer_display_spice_send_keys;
 dclass->get_pixbuf = virt_viewer_display_spice_get_pixbuf;
 dclass->release_cursor = virt_viewer_display_spice_release_cursor;
-dclass->close = virt_viewer_display_spice_close;
 dclass->selectable = virt_viewer_display_spice_selectable;
 dclass->enable = virt_viewer_display_spice_enable;
 dclass->disable = virt_viewer_display_spice_disable;
@@ -348,12 +346,6 @@ virt_viewer_display_spice_release_cursor(VirtViewerDisplay 
*display)
 spice_display_mouse_ungrab(self->priv->display);
 }
 
-
-static void
-virt_viewer_display_spice_close(VirtViewerDisplay *display G_GNUC_UNUSED)
-{
-}
-
 static gboolean
 virt_viewer_display_spice_selectable(VirtViewerDisplay *self)
 {
diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index 011328e..b3cc095 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -657,9 +657,8 @@ void virt_viewer_display_close(VirtViewerDisplay *self)
 g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(self));
 
 klass = VIRT_VIEWER_DISPLAY_GET_CLASS(self);
-g_return_if_fail(klass->close != NULL);
-
-klass->close(self);
+if (klass->close)
+klass->close(self);
 }
 
 void virt_viewer_display_set_fullscreen(VirtViewerDisplay *self, gboolean 
fullscreen)
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 09/22] build-sys: check for VTE library

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 configure.ac | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/configure.ac b/configure.ac
index 5496860..3c7522d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -170,6 +170,18 @@ AS_IF([test "x$with_spice_gtk" = "xyes"],
 )
 AM_CONDITIONAL([HAVE_SPICE_GTK], [test "x$with_spice_gtk" = "xyes"])
 
+AC_ARG_WITH([vte],
+AS_HELP_STRING([--without-vte], [Ignore presence of vte and disable it]))
+
+AS_IF([test "x$with_vte" != "xno" && test "x$with_vte" != "xyes"],
+  [PKG_CHECK_EXISTS([vte-2.91], [with_vte=yes], [with_vte=no])])
+
+AS_IF([test "x$with_vte" = "xyes"],
+  [PKG_CHECK_MODULES(VTE, [vte-2.91])]
+  [AC_DEFINE([HAVE_VTE], 1, [Have vte?])]
+)
+AM_CONDITIONAL([HAVE_VTE], [test "x$with_vte" = "xyes"])
+
 AC_ARG_WITH([ovirt],
 AS_HELP_STRING([--without-ovirt], [Ignore presence of librest and disable 
oVirt support]))
 
@@ -274,6 +286,8 @@ AC_MSG_NOTICE([ GTK_VNC: $GTK_VNC_CFLAGS $GTK_VNC_LIBS])
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([   SPICE_GTK: $SPICE_GTK_CFLAGS $SPICE_GTK_LIBS])
 AC_MSG_NOTICE([])
+AC_MSG_NOTICE([ VTE: $VTE_CFLAGS $VTE_LIBS])
+AC_MSG_NOTICE([])
 AC_MSG_NOTICE([ LIBXML2: $LIBXML2_CFLAGS $LIBXML2_LIBS])
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([ LIBVIRT: $LIBVIRT_CFLAGS $LIBVIRT_LIBS])
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 11/22] window/zoom: deal with VTE display differently

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

VTE display doesn't use the desktop / window aspect ratio, let's just
call directly the functions handling zoom.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-window.c | 28 ++--
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index ec9bae6..ef97452 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -42,6 +42,7 @@
 #include "virt-viewer-app.h"
 #include "virt-viewer-util.h"
 #include "virt-viewer-timed-revealer.h"
+#include "virt-viewer-display-vte.h"
 
 #include "remote-viewer-iso-list-dialog.h"
 
@@ -383,23 +384,35 @@ G_MODULE_EXPORT void
 virt_viewer_window_menu_view_zoom_out(GtkWidget *menu G_GNUC_UNUSED,
   VirtViewerWindow *self)
 {
-virt_viewer_window_set_zoom_level(self,
-  
virt_viewer_window_get_real_zoom_level(self) - ZOOM_STEP);
+if (VIRT_VIEWER_IS_DISPLAY_VTE(self->priv->display)) {
+
virt_viewer_display_vte_zoom_out(VIRT_VIEWER_DISPLAY_VTE(self->priv->display));
+} else {
+virt_viewer_window_set_zoom_level(self,
+  
virt_viewer_window_get_real_zoom_level(self) - ZOOM_STEP);
+}
 }
 
 G_MODULE_EXPORT void
 virt_viewer_window_menu_view_zoom_in(GtkWidget *menu G_GNUC_UNUSED,
  VirtViewerWindow *self)
 {
-virt_viewer_window_set_zoom_level(self,
-  
virt_viewer_window_get_real_zoom_level(self) + ZOOM_STEP);
+if (VIRT_VIEWER_IS_DISPLAY_VTE(self->priv->display)) {
+
virt_viewer_display_vte_zoom_in(VIRT_VIEWER_DISPLAY_VTE(self->priv->display));
+} else {
+virt_viewer_window_set_zoom_level(self,
+  
virt_viewer_window_get_real_zoom_level(self) + ZOOM_STEP);
+}
 }
 
 G_MODULE_EXPORT void
 virt_viewer_window_menu_view_zoom_reset(GtkWidget *menu G_GNUC_UNUSED,
 VirtViewerWindow *self)
 {
-virt_viewer_window_set_zoom_level(self, NORMAL_ZOOM_LEVEL);
+if (VIRT_VIEWER_IS_DISPLAY_VTE(self->priv->display)) {
+
virt_viewer_display_vte_zoom_reset(VIRT_VIEWER_DISPLAY_VTE(self->priv->display));
+} else {
+virt_viewer_window_set_zoom_level(self, NORMAL_ZOOM_LEVEL);
+}
 }
 
 /* Kick GtkWindow to tell it to adjust to our new widget sizes */
@@ -1521,7 +1534,10 @@ virt_viewer_window_set_zoom_level(VirtViewerWindow 
*self, gint zoom_level)
 
 virt_viewer_display_set_zoom_level(VIRT_VIEWER_DISPLAY(priv->display), 
priv->zoomlevel);
 
-virt_viewer_window_queue_resize(self);
+if (VIRT_VIEWER_IS_DISPLAY_VTE(priv->display)) {
+} else {
+virt_viewer_window_queue_resize(self);
+}
 }
 
 gint virt_viewer_window_get_zoom_level(VirtViewerWindow *self)
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 07/22] window: set sensitivity based on display capability

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-display.h |  6 ++
 src/virt-viewer-window.c  | 14 ++
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/virt-viewer-display.h b/src/virt-viewer-display.h
index 7016a85..eadc333 100644
--- a/src/virt-viewer-display.h
+++ b/src/virt-viewer-display.h
@@ -86,6 +86,12 @@ struct _VirtViewerDisplayClass {
 void (*disable)(VirtViewerDisplay *display);
 };
 
+#define VIRT_VIEWER_DISPLAY_CAN_SCREENSHOT(display) \
+(VIRT_VIEWER_DISPLAY_GET_CLASS(display)->get_pixbuf != NULL)
+
+#define VIRT_VIEWER_DISPLAY_CAN_SEND_KEYS(display) \
+(VIRT_VIEWER_DISPLAY_GET_CLASS(display)->send_keys != NULL)
+
 GType virt_viewer_display_get_type(void);
 
 GtkWidget *virt_viewer_display_new(void);
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index b9b8ce9..ec9bae6 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -1339,15 +1339,21 @@ virt_viewer_window_set_menus_sensitive(VirtViewerWindow 
*self, gboolean sensitiv
 gtk_widget_set_sensitive(menu, sensitive);
 
 menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, 
"menu-file-screenshot"));
-gtk_widget_set_sensitive(menu, sensitive);
+gtk_widget_set_sensitive(menu, sensitive && self->priv->display != NULL &&
+ 
VIRT_VIEWER_DISPLAY_CAN_SCREENSHOT(self->priv->display));
 
 menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-view-zoom"));
 gtk_widget_set_sensitive(menu, sensitive);
 
-menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-send"));
-gtk_widget_set_sensitive(menu, sensitive);
+{
+gboolean can_send = sensitive && self->priv->display != NULL &&
+VIRT_VIEWER_DISPLAY_CAN_SEND_KEYS(self->priv->display);
 
-gtk_widget_set_sensitive(self->priv->toolbar_send_key, sensitive);
+menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-send"));
+gtk_widget_set_sensitive(menu, can_send);
+
+gtk_widget_set_sensitive(self->priv->toolbar_send_key, can_send);
+}
 }
 
 static void
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 05/22] window: move default sensitivity in .ui

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

Instead of modifying it in object initialization.

Signed-off-by: Marc-André Lureau 
---
 src/resources/ui/virt-viewer.ui | 4 
 src/virt-viewer-window.c| 5 -
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/resources/ui/virt-viewer.ui b/src/resources/ui/virt-viewer.ui
index e9609ec..9da1403 100644
--- a/src/resources/ui/virt-viewer.ui
+++ b/src/resources/ui/virt-viewer.ui
@@ -34,6 +34,7 @@
 accelgroup
 
   
+False
 True
 False
 False
@@ -83,6 +84,7 @@
 
 
   
+False
 True
 False
 _Preferences
@@ -136,6 +138,7 @@
 
 
   
+False
 True
 False
 False
@@ -214,6 +217,7 @@
 
 
   
+False
 True
 False
 False
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 4b48e31..301a3bf 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -313,11 +313,6 @@ virt_viewer_window_init (VirtViewerWindow *self)
 
 priv->builder = virt_viewer_util_load_ui("virt-viewer.ui");
 
-
gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, 
"menu-send")), FALSE);
-
gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, 
"menu-view-zoom")), FALSE);
-
gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, 
"menu-file-screenshot")), FALSE);
-
gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, 
"menu-preferences")), FALSE);
-
 gtk_builder_connect_signals(priv->builder, self);
 
 priv->accel_group = GTK_ACCEL_GROUP(gtk_builder_get_object(priv->builder, 
"accelgroup"));
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 06/22] window: do not reset sensitivity of menu-send in rebuild

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

A mere app::enable-accel notification shouldn't modify the
sensitivity, which is handled for all menu items elsewhere, leave the
current state untouched.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-window.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 301a3bf..b9b8ce9 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -219,7 +219,6 @@ rebuild_combo_menu(GObject*gobject G_GNUC_UNUSED,
 menu = GTK_WIDGET(gtk_builder_get_object(self->priv->builder, 
"menu-send"));
 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu),
   
GTK_WIDGET(virt_viewer_window_get_keycombo_menu(self)));
-gtk_widget_set_sensitive(menu, (self->priv->display != NULL));
 }
 
 static void
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 04/22] window: use virt_viewer_window_set_menus_sensitive()

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

virt_viewer_window_set_menus_sensitive() is the common function to set
sensitivity on menu items.

It was lacking "toolbar_send_key", so add it there too.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-window.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index af3441f..4b48e31 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -1352,6 +1352,8 @@ virt_viewer_window_set_menus_sensitive(VirtViewerWindow 
*self, gboolean sensitiv
 
 menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-send"));
 gtk_widget_set_sensitive(menu, sensitive);
+
+gtk_widget_set_sensitive(self->priv->toolbar_send_key, sensitive);
 }
 
 static void
@@ -1432,10 +1434,7 @@ virt_viewer_window_set_display(VirtViewerWindow *self, 
VirtViewerDisplay *displa
 if (virt_viewer_display_get_enabled(display))
 virt_viewer_window_desktop_resize(display, self);
 
-
gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, 
"menu-preferences")), TRUE);
-
gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, 
"menu-view-zoom")), TRUE);
-
gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, 
"menu-send")), TRUE);
-gtk_widget_set_sensitive(self->priv->toolbar_send_key, TRUE);
+virt_viewer_window_set_menus_sensitive(self, TRUE);
 }
 }
 
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 03/22] app: simplify toggling visibility

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

There is a hack to maintain the the toggle state to a desired state
within the "toggled" handler. (since there is no way to hook a signal
handler on "clicked" before "toggled" is emitted and handled by Gtk,
to avoid the recursion)

However it is only necessary for the ask-quit case. In this case, we
want to maintain the item active, which is simpler to handle than the
general case. Simplify the code by folding
virt_viewer_app_window_set_visible() and removing the static
"reentering" hack, only maintaining "active" on the last item.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-app.c | 43 +++
 src/virt-viewer-app.h |  2 +-
 2 files changed, 12 insertions(+), 33 deletions(-)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 2a2..62dbf19 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -502,29 +502,6 @@ virt_viewer_app_get_n_windows_visible(VirtViewerApp *self)
 return n;
 }
 
-gboolean
-virt_viewer_app_window_set_visible(VirtViewerApp *self,
-   VirtViewerWindow *window,
-   gboolean visible)
-{
-g_return_val_if_fail(VIRT_VIEWER_IS_APP(self), FALSE);
-g_return_val_if_fail(VIRT_VIEWER_IS_WINDOW(window), FALSE);
-
-if (visible) {
-virt_viewer_window_show(window);
-return TRUE;
-} else {
-if (virt_viewer_app_get_n_windows_visible(self) > 1) {
-virt_viewer_window_hide(window);
-return FALSE;
-}
-
-virt_viewer_app_maybe_quit(self, window);
-}
-
-return FALSE;
-}
-
 static void hide_one_window(gpointer value,
 gpointer user_data G_GNUC_UNUSED)
 {
@@ -2232,19 +2209,21 @@ menu_display_visible_toggled_cb(GtkCheckMenuItem 
*checkmenuitem,
 {
 VirtViewerApp *self = 
virt_viewer_session_get_app(virt_viewer_display_get_session(display));
 gboolean visible = gtk_check_menu_item_get_active(checkmenuitem);
-static gboolean reentering = FALSE;
 VirtViewerWindow *vwin;
 
-if (reentering) /* do not reenter if I switch you back */
-return;
-
-reentering = TRUE;
-
 vwin = ensure_window_for_display(self, display);
-visible = virt_viewer_app_window_set_visible(self, vwin, visible);
 
-gtk_check_menu_item_set_active(checkmenuitem, /* will be toggled again */ 
!visible);
-reentering = FALSE;
+if (visible) {
+virt_viewer_window_show(vwin);
+} else {
+if (virt_viewer_app_get_n_windows_visible(self) > 1) {
+virt_viewer_window_hide(vwin);
+} else {
+virt_viewer_app_maybe_quit(self, vwin);
+/* the last item remains active, doesn't matter if we quit */
+gtk_check_menu_item_set_active(checkmenuitem, TRUE);
+}
+}
 
 
virt_viewer_session_update_displays_geometry(virt_viewer_display_get_session(display));
 }
diff --git a/src/virt-viewer-app.h b/src/virt-viewer-app.h
index 16b1c8c..0321229 100644
--- a/src/virt-viewer-app.h
+++ b/src/virt-viewer-app.h
@@ -84,7 +84,7 @@ void virt_viewer_app_set_connect_info(VirtViewerApp *self,
   const gchar *user,
   gint port,
   const gchar *guri);
-gboolean virt_viewer_app_window_set_visible(VirtViewerApp *self, 
VirtViewerWindow *window, gboolean visible);
+
 void virt_viewer_app_show_status(VirtViewerApp *self, const gchar *fmt, ...);
 void virt_viewer_app_show_display(VirtViewerApp *self);
 GList* virt_viewer_app_get_windows(VirtViewerApp *self);
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 01/22] remote-viewer: add handling of spice+unix and spice+tls schemes

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

- spice+unix:// was added in spice-gtk v0.28
- spice+tls:// was added in spice-gtk v0.35

This allows launchers to start remote-viewer when they encounter a
Spice URI with +unix or +tls.

Signed-off-by: Marc-André Lureau 
---
 data/remote-viewer.desktop.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/data/remote-viewer.desktop.in b/data/remote-viewer.desktop.in
index 213642c..24bcf6a 100644
--- a/data/remote-viewer.desktop.in
+++ b/data/remote-viewer.desktop.in
@@ -4,7 +4,7 @@ _Comment=Access remote desktops
 Exec=remote-viewer %u
 Type=Application
 Terminal=false
-MimeType=x-scheme-handler/spice;application/x-virt-viewer;
+MimeType=x-scheme-handler/spice;x-scheme-handler/spice+unix;x-scheme-handler/spice+tls;application/x-virt-viewer;
 StartupNotify=true
 Categories=GNOME;GTK;Network;RemoteAccess;
 Icon=virt-viewer
-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [PATCH 00/22] Add QEMU-like UI: VT console & basic VM state

2018-07-31 Thread marcandre . lureau
From: Marc-André Lureau 

Hi,

QEMU provides multiple display backend, with different set of
features. One of the richest UI is the -display gtk. It is quite
minimal, and comparable to remote-viewer UI wrt fullscreen, zooming,
grabbing. I haven't done a detailed comparison, but for regular use, I
prefer the remote-viewer UI. The fullscreen mode has a popup toolbar,
there is a send-key menu, it provides better desktop integration
support: USB redirection, folder sharing, more complete multi-monitor
configuration, screenshot. remote-viewer also allows hotkey
configuration, and has an experimental "kiosk" mode.

However, remote-viewer is lacking 2 important features compared to
QEMU UI: VT console (for serials, and monitors) and basic VM state
commands (power off, reset, pause..).

This series add support for VT console over Spice ports, and QMP
monitor to provide a similar user experience as QEMU -display gtk.
Another WIP series (fairly small, everything is there already) for
QEMU will provide a new "-display app" backend, that will configure
QEMU appropriately, and start remote-viewer (actually any client
handling spice+unix://). The result is that the "QEMU UI experience"
is entirely out of qemu code base and process.

thanks

Marc-André Lureau (22):
  remote-viewer: add handling of spice+unix and spice+tls schemes
  Remove class signal handlers
  app: simplify toggling visibility
  window: use virt_viewer_window_set_menus_sensitive()
  window: move default sensitivity in .ui
  window: do not reset sensitivity of menu-send in rebuild
  window: set sensitivity based on display capability
  display: make klass->close() optional
  build-sys: check for VTE library
  Add a VirtViewerDisplayVte display kind
  window/zoom: deal with VTE display differently
  display: ignore display that do not have toplevel window
  session: skip monitor changes if there is no sized monitors
  app: set subtitle using VTE name
  app: append VTE consoles to display submenu
  display: allow display without associated monitor number
  session: do not take VTE display into account for geometry changes
  app: create a window for VTE displays
  spice: hook into port channel to create VTE terminals
  app: add "machine" UI
  app: add "vm-running" property
  spice: hook into QMP port

 configure.ac|  22 ++-
 data/remote-viewer.desktop.in   |   2 +-
 src/Makefile.am |   6 +
 src/resources/ui/virt-viewer.ui |  50 +
 src/virt-viewer-app.c   | 197 ++--
 src/virt-viewer-app.h   |   2 +-
 src/virt-viewer-display-spice.c |   8 -
 src/virt-viewer-display-vte.c   | 319 
 src/virt-viewer-display-vte.h   |  81 
 src/virt-viewer-display.c   |  22 +--
 src/virt-viewer-display.h   |  14 +-
 src/virt-viewer-session-spice.c | 284 +++-
 src/virt-viewer-session.c   |  48 +++--
 src/virt-viewer-session.h   |  30 ++-
 src/virt-viewer-window.c| 117 ++--
 15 files changed, 1066 insertions(+), 136 deletions(-)
 create mode 100644 src/virt-viewer-display-vte.c
 create mode 100644 src/virt-viewer-display-vte.h

-- 
2.18.0.321.gffc6fa0e39

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

[virt-tools-list] [virt-manager PATCH 0/5] WIP: Various TPM improvements

2018-05-24 Thread marcandre . lureau
From: Marc-André Lureau 

Hi,

The following series depend on the patches being reviewed for libvirt
"[PATCH 00/12] Add support for TPM emulator" (currently at v6).

They allow to configure a CRB device (more TPM 2.0 compliant), and to
setup an emulated TPM.

Feeback welcome

Marc-André Lureau (5):
  addhardware: learn to choose a TPM model
  tpm: add CRB device model
  tpm: add TPM emulator backend
  addhardware: learn to set emulated TPM version
  details: show TPM version

 .../virt-install-singleton-config-2.xml   | 16 +
 tests/clitest.py  |  2 +
 tests/xmlparse-xml/change-tpm-out.xml |  2 +-
 tests/xmlparse.py |  2 +-
 ui/addhardware.ui | 66 ---
 ui/details.ui | 24 +++
 virtManager/addhardware.py| 24 ++-
 virtManager/details.py|  3 +
 virtinst/cli.py   |  1 +
 virtinst/devices/tpm.py   | 37 ++-
 10 files changed, 161 insertions(+), 16 deletions(-)

-- 
2.17.0.253.g3dd125b46d

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

[virt-tools-list] [virt-manager PATCH 2/5] tpm: add CRB device model

2018-05-24 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 .../compare/virt-install-singleton-config-2.xml| 10 ++
 tests/clitest.py   |  1 +
 tests/xmlparse-xml/change-tpm-out.xml  |  2 +-
 tests/xmlparse.py  |  2 +-
 virtinst/devices/tpm.py|  5 -
 5 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml 
b/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
index ec36f215..8cd92544 100644
--- a/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
+++ b/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
@@ -143,6 +143,11 @@
 
   
 
+
+  
+
+  
+
 
 
 
@@ -312,6 +317,11 @@
 
   
 
+
+  
+
+  
+
 
 
 
diff --git a/tests/clitest.py b/tests/clitest.py
index a62a9105..5271935f 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -449,6 +449,7 @@ cache.mode=emulate,cache.level=3 \
 --memballoon virtio \
 --watchdog ib700,action=pause \
 --tpm passthrough,model=tpm-tis,path=/dev/tpm0 \
+--tpm passthrough,model=tpm-crb,path=/dev/tpm0 \
 --rng 
egd,backend_host=127.0.0.1,backend_service=8000,backend_type=udp,backend_mode=bind,backend_connect_host=foo,backend_connect_service=708
 \
 --panic iobase=0x506 \
 """, "singleton-config-2")
diff --git a/tests/xmlparse-xml/change-tpm-out.xml 
b/tests/xmlparse-xml/change-tpm-out.xml
index 47d0dfdc..7bdd0226 100644
--- a/tests/xmlparse-xml/change-tpm-out.xml
+++ b/tests/xmlparse-xml/change-tpm-out.xml
@@ -50,7 +50,7 @@
 
 
 
-
+
   
 
   
diff --git a/tests/xmlparse.py b/tests/xmlparse.py
index 3e02a5c1..4b5b3026 100644
--- a/tests/xmlparse.py
+++ b/tests/xmlparse.py
@@ -909,7 +909,7 @@ class XMLParseTest(unittest.TestCase):
 
 check = self._make_checker(dev1)
 check("type", "passthrough", "foo", "passthrough")
-check("model", "tpm-tis", "tpm-tis")
+check("model", "tpm-tis", "tpm-crb")
 check("device_path", "/dev/tpm0", "frob")
 
 self._alter_compare(guest.get_xml_config(), outfile)
diff --git a/virtinst/devices/tpm.py b/virtinst/devices/tpm.py
index 634f8b52..ab7492ed 100644
--- a/virtinst/devices/tpm.py
+++ b/virtinst/devices/tpm.py
@@ -21,8 +21,9 @@ class DeviceTpm(Device):
 TYPES = [TYPE_PASSTHROUGH]
 
 MODEL_TIS = "tpm-tis"
+MODEL_CRB = "tpm-crb"
 MODEL_DEFAULT = "default"
-MODELS = [MODEL_TIS]
+MODELS = [MODEL_TIS, MODEL_CRB]
 
 @staticmethod
 def get_pretty_type(tpm_type):
@@ -34,6 +35,8 @@ class DeviceTpm(Device):
 def get_pretty_model(tpm_model):
 if tpm_model == DeviceTpm.MODEL_TIS:
 return _("TIS")
+if tpm_model == DeviceTpm.MODEL_CRB:
+return _("CRB")
 return tpm_model
 
 def supports_property(self, propname):
-- 
2.17.0.253.g3dd125b46d

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

[virt-tools-list] [virt-manager PATCH 4/5] addhardware: learn to set emulated TPM version

2018-05-24 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 ui/addhardware.ui  | 24 
 virtManager/addhardware.py | 20 +---
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/ui/addhardware.ui b/ui/addhardware.ui
index b4cc35ea..4c266826 100644
--- a/ui/addhardware.ui
+++ b/ui/addhardware.ui
@@ -1477,6 +1477,30 @@
 0
   
 
+
+  
+True
+False
+end
+_Version:
+True
+tpm-version
+  
+  
+0
+3
+  
+
+
+  
+True
+False
+  
+  
+1
+3
+  
+
 
   
 tpm-tab
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 901ed5fb..6fd6a5eb 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -684,6 +684,10 @@ class vmmAddHardware(vmmGObjectUI):
 for t in DeviceTpm.MODELS:
 values.append([t, DeviceTpm.get_pretty_model(t)])
 _build_combo(self.widget("tpm-model"), values)
+values = []
+for t in DeviceTpm.VERSIONS:
+values.append([t, t])
+_build_combo(self.widget("tpm-version"), values)
 
 
 def _build_panic_model_combo(self):
@@ -897,6 +901,7 @@ class vmmAddHardware(vmmGObjectUI):
 
 tpm_widget_mappings = {
 "device_path": "tpm-device-path",
+"version": "tpm-version",
 }
 
 self._dev = DeviceTpm(self.conn.get_backend())
@@ -1446,10 +1451,19 @@ class vmmAddHardware(vmmGObjectUI):
 typ = uiutil.get_list_selection(self.widget("tpm-type"))
 model = uiutil.get_list_selection(self.widget("tpm-model"))
 device_path = self.widget("tpm-device-path").get_text()
+version = uiutil.get_list_selection(self.widget("tpm-version"))
+
+value_mappings = {
+"type": typ,
+"model": model,
+"device_path": device_path,
+"version": version,
+}
+
 self._dev = DeviceTpm(self.conn.get_backend())
-self._dev.type = typ
-self._dev.model = model
-self._dev.device_path = device_path
+for param_name, val in value_mappings.items():
+if self._dev.supports_property(param_name) and val is not None:
+setattr(self._dev, param_name, val)
 
 def _validate_page_panic(self):
 model = uiutil.get_list_selection(self.widget("panic-model"))
-- 
2.17.0.253.g3dd125b46d

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

[virt-tools-list] [virt-manager PATCH 1/5] addhardware: learn to choose a TPM model

2018-05-24 Thread marcandre . lureau
From: Marc-André Lureau 

There is only one for now, but we are adding CRB next (and SPAPR is
being added too in qemu/libvirt).

Signed-off-by: Marc-André Lureau 
---
 ui/addhardware.ui  | 42 ++
 virtManager/addhardware.py |  6 ++
 virtinst/devices/tpm.py|  6 ++
 3 files changed, 45 insertions(+), 9 deletions(-)

diff --git a/ui/addhardware.ui b/ui/addhardware.ui
index cec4e439..b4cc35ea 100644
--- a/ui/addhardware.ui
+++ b/ui/addhardware.ui
@@ -1402,6 +1402,20 @@
 False
 6
 6
+
+  
+True
+False
+start
+Device _Path:
+True
+tpm-device-path
+  
+  
+0
+2
+  
+
 
   
 True
@@ -1411,17 +1425,17 @@
   
   
 1
-1
+2
   
 
 
-  
+  
 True
 False
-start
-Device _Path:
+end
+_Backend:
 True
-tpm-device-path
+tpm-type
   
   
 0
@@ -1436,23 +1450,33 @@
   
   
 1
-0
+1
   
 
 
-  
+  
 True
 False
 end
-_Backend:
+_Model:
 True
-tpm-type
+tpm-model
   
   
 0
 0
   
 
+
+  
+True
+False
+  
+  
+1
+0
+  
+
 
   
 tpm-tab
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 1fa832c5..901ed5fb 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -680,6 +680,10 @@ class vmmAddHardware(vmmGObjectUI):
 for t in DeviceTpm.TYPES:
 values.append([t, DeviceTpm.get_pretty_type(t)])
 _build_combo(self.widget("tpm-type"), values)
+values = []
+for t in DeviceTpm.MODELS:
+values.append([t, DeviceTpm.get_pretty_model(t)])
+_build_combo(self.widget("tpm-model"), values)
 
 
 def _build_panic_model_combo(self):
@@ -1440,9 +1444,11 @@ class vmmAddHardware(vmmGObjectUI):
 
 def _validate_page_tpm(self):
 typ = uiutil.get_list_selection(self.widget("tpm-type"))
+model = uiutil.get_list_selection(self.widget("tpm-model"))
 device_path = self.widget("tpm-device-path").get_text()
 self._dev = DeviceTpm(self.conn.get_backend())
 self._dev.type = typ
+self._dev.model = model
 self._dev.device_path = device_path
 
 def _validate_page_panic(self):
diff --git a/virtinst/devices/tpm.py b/virtinst/devices/tpm.py
index a09b08e1..634f8b52 100644
--- a/virtinst/devices/tpm.py
+++ b/virtinst/devices/tpm.py
@@ -30,6 +30,12 @@ class DeviceTpm(Device):
 return _("Passthrough device")
 return tpm_type
 
+@staticmethod
+def get_pretty_model(tpm_model):
+if tpm_model == DeviceTpm.MODEL_TIS:
+return _("TIS")
+return tpm_model
+
 def supports_property(self, propname):
 """
 Whether the TPM dev type supports the passed property

[virt-tools-list] [virt-manager PATCH 3/5] tpm: add TPM emulator backend

2018-05-24 Thread marcandre . lureau
From: Marc-André Lureau 

Support is being added to libvirt. An emulated backend doesn't require
any path, since libvirt will take care of finding the emulator and
managing the storage. However, the version to emulate can be specified.

Signed-off-by: Marc-André Lureau 
---
 .../virt-install-singleton-config-2.xml   |  6 +
 tests/clitest.py  |  1 +
 virtinst/cli.py   |  1 +
 virtinst/devices/tpm.py   | 26 +--
 4 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml 
b/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
index 8cd92544..674eebe4 100644
--- a/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
+++ b/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
@@ -148,6 +148,9 @@
 
   
 
+
+  
+
 
 
 
@@ -322,6 +325,9 @@
 
   
 
+
+  
+
 
 
 
diff --git a/tests/clitest.py b/tests/clitest.py
index 5271935f..d323aace 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -450,6 +450,7 @@ cache.mode=emulate,cache.level=3 \
 --watchdog ib700,action=pause \
 --tpm passthrough,model=tpm-tis,path=/dev/tpm0 \
 --tpm passthrough,model=tpm-crb,path=/dev/tpm0 \
+--tpm emulator,model=tpm-crb,version=2 \
 --rng 
egd,backend_host=127.0.0.1,backend_service=8000,backend_type=udp,backend_mode=bind,backend_connect_host=foo,backend_connect_service=708
 \
 --panic iobase=0x506 \
 """, "singleton-config-2")
diff --git a/virtinst/cli.py b/virtinst/cli.py
index a2624e66..a20cdb23 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -2440,6 +2440,7 @@ _register_virt_parser(ParserTPM)
 _add_device_address_args(ParserTPM)
 ParserTPM.add_arg("type", "type")
 ParserTPM.add_arg("model", "model")
+ParserTPM.add_arg("version", "version")
 ParserTPM.add_arg("device_path", "path")
 
 
diff --git a/virtinst/devices/tpm.py b/virtinst/devices/tpm.py
index ab7492ed..54cd3517 100644
--- a/virtinst/devices/tpm.py
+++ b/virtinst/devices/tpm.py
@@ -16,9 +16,15 @@ from ..xmlbuilder import XMLProperty
 class DeviceTpm(Device):
 XML_NAME = "tpm"
 
+VERSION_1_2 = "1.2"
+VERSION_2 = "2"
+VERSION_DEFAULT = "default"
+VERSIONS = [VERSION_1_2, VERSION_2]
+
 TYPE_PASSTHROUGH = "passthrough"
+TYPE_EMULATOR = "emulator"
 TYPE_DEFAULT = "default"
-TYPES = [TYPE_PASSTHROUGH]
+TYPES = [TYPE_PASSTHROUGH, TYPE_EMULATOR]
 
 MODEL_TIS = "tpm-tis"
 MODEL_CRB = "tpm-crb"
@@ -29,6 +35,8 @@ class DeviceTpm(Device):
 def get_pretty_type(tpm_type):
 if tpm_type == DeviceTpm.TYPE_PASSTHROUGH:
 return _("Passthrough device")
+if tpm_type == DeviceTpm.TYPE_EMULATOR:
+return _("Emulated device")
 return tpm_type
 
 @staticmethod
@@ -45,6 +53,7 @@ class DeviceTpm(Device):
 """
 users = {
 "device_path": [self.TYPE_PASSTHROUGH],
+"version": [self.TYPE_EMULATOR],
 }
 
 if users.get(propname):
@@ -54,7 +63,20 @@ class DeviceTpm(Device):
 
 type = XMLProperty("./backend/@type",
default_cb=lambda s: s.TYPE_PASSTHROUGH)
+
+def _get_default_version(self):
+if not self.supports_property("version"):
+return None
+return self.VERSION_1_2
+version = XMLProperty("./backend/@version",
+  default_cb=_get_default_version)
 model = XMLProperty("./@model",
default_cb=lambda s: s.MODEL_TIS)
+
+
+def _get_default_device_path(self):
+if not self.supports_property("device_path"):
+return None
+return "/dev/tpm0"
 device_path = XMLProperty("./backend/device/@path",
-  default_cb=lambda s: "/dev/tpm0")
+  default_cb=_get_default_device_path)
-- 
2.17.0.253.g3dd125b46d

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

[virt-tools-list] [virt-manager PATCH 5/5] details: show TPM version

2018-05-24 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 ui/details.ui  | 24 
 virtManager/details.py |  3 +++
 2 files changed, 27 insertions(+)

diff --git a/ui/details.ui b/ui/details.ui
index 2e7b253b..efc2748f 100644
--- a/ui/details.ui
+++ b/ui/details.ui
@@ -5445,6 +5445,30 @@
 1
   
 
+
+  
+True
+False
+end
+Version:
+  
+  
+0
+2
+  
+
+
+  
+True
+False
+start
+tpm-version
+  
+  
+1
+2
+  
+
   
 
   
diff --git a/virtManager/details.py b/virtManager/details.py
index b78a2385..d2996bd1 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -249,6 +249,8 @@ def _label_for_device(dev):
 label = _("TPM")
 if dev.device_path:
 label += (" %s" % dev.device_path)
+else:
+label += (" v%s" % dev.version)
 return label
 
 devmap = {
@@ -2781,6 +2783,7 @@ class vmmDetails(vmmGObjectUI):
 
 # Device type specific properties, only show if apply to the cur dev
 show_ui("device_path")
+show_ui("version")
 
 def refresh_panic_page(self):
 dev = self.get_hw_selection(HW_LIST_COL_DEVICE)
-- 
2.17.0.253.g3dd125b46d

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

[virt-tools-list] [PATCH v2 2/6] connection: support checking for a list of features

2018-02-22 Thread marcandre . lureau
From: Marc-André Lureau 

Make check_support() accept a list of features.

This will let tests have more complex conditions on the features they
require.

Signed-off-by: Marc-André Lureau 
---
 virtinst/connection.py | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/virtinst/connection.py b/virtinst/connection.py
index 3d1f73d2..40438d9a 100644
--- a/virtinst/connection.py
+++ b/virtinst/connection.py
@@ -409,7 +409,7 @@ class VirtualConnection(object):
  _supportname.startswith("SUPPORT_")]:
 locals()[_supportname] = getattr(support, _supportname)
 
-def check_support(self, feature, data=None):
+def _check_support(self, feature, data=None):
 key = feature
 data = data or self
 if key not in self._support_cache:
@@ -417,6 +417,16 @@ class VirtualConnection(object):
 self, feature, data)
 return self._support_cache[key]
 
+def check_support(self, features, data=None):
+if isinstance(features, list):
+# 'and' condition over the feature list
+for f in features:
+if not self._check_support(f, data):
+return False
+return True
+else:
+return self._check_support(features, data)
+
 def support_remote_url_install(self):
 if self._magic_uri:
 return False
-- 
2.16.1.73.g5832b7e9f2

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

[virt-tools-list] [PATCH v2 0/6] virtinst: add feature support

2018-02-22 Thread marcandre . lureau
From: Marc-André Lureau 

Hi,

The  feature allows a guest to provide debug details when
producing dump. It's useful in particular for Linux guests with KASLR
enabled, as otherwise the dump are difficult to analyze.

This patch set adds virt-install support for vmcoreinfo domain
feature. Whenever the host libvirt/qemu is recent enough, and the VM
is x86 or arm-virt, we can assume  is supported and
enable it by default (unless --feature vmcoreinfo=on/off is given, or
changed via API)

Marc-André Lureau (6):
  tests/virtconv: ignore skip exceptions
  connection: support checking for a list of features
  virtinst: add  feature
  virtinst/support: add SUPPORT_CONN_VMCOREINFO check
  tests: add xmlparse/change vmcoreinfo test
  virtinst: add  by default on x86 & arm-virt

 .../compare/virt-convert-ovf-compare.xml   |  1 +
 .../compare/virt-convert-vmx-compare.xml   |  1 +
 .../compare/virt-install-aarch64-cdrom.xml |  6 
 .../compare/virt-install-aarch64-graphics.xml  |  3 ++
 .../compare/virt-install-aarch64-kvm-gic.xml   |  1 +
 .../compare/virt-install-aarch64-kvm-import.xml|  3 ++
 .../compare/virt-install-aarch64-machdefault.xml   |  3 ++
 .../compare/virt-install-aarch64-machvirt.xml  |  3 ++
 .../compare/virt-install-arm-defaultmach-f20.xml   |  3 ++
 .../compare/virt-install-arm-kvm-import.xml|  3 ++
 .../compare/virt-install-arm-virt-f20.xml  |  3 ++
 .../compare/virt-install-boot-uefi.xml |  1 +
 .../compare/virt-install-f21-kvm-remote.xml|  1 +
 .../compare/virt-install-features-vmcoreinfo.xml   | 28 +++
 .../compare/virt-install-kvm-centos7.xml   |  2 ++
 .../compare/virt-install-kvm-f14-url.xml   |  2 ++
 .../compare/virt-install-kvm-rhel6.xml |  2 ++
 .../compare/virt-install-kvm-rhel7.xml |  2 ++
 .../compare/virt-install-kvm-session-defaults.xml  |  2 ++
 .../compare/virt-install-kvm-win2k3-cdrom.xml  |  2 ++
 .../compare/virt-install-location-iso.xml  |  2 ++
 .../compare/virt-install-location-nfs.xml  |  2 ++
 .../compare/virt-install-many-devices.xml  |  1 +
 .../compare/virt-install-panic-default.xml |  1 +
 .../compare/virt-install-panic-isa-iobase.xml  |  1 +
 .../compare/virt-install-panic-isa.xml |  1 +
 .../compare/virt-install-q35-defaults.xml  |  2 ++
 .../compare/virt-install-qemu-32-on-64.xml |  1 +
 .../compare/virt-install-qemu-plain.xml|  1 +
 .../compare/virt-install-singleton-config-1.xml|  1 +
 .../compare/virt-install-solaris10-defaults.xml|  1 +
 .../cli-test-xml/compare/virt-install-spice-gl.xml |  1 +
 .../compare/virt-install-win7-uefi.xml |  2 ++
 tests/clitest.py   | 42 --
 .../ovf2libvirt_ovf_directory.libvirt  |  1 +
 .../libvirt_output/ovf2libvirt_test1.libvirt   |  1 +
 .../ovf2libvirt_test1.libvirt.disk_qcow2   |  1 +
 .../libvirt_output/ovf2libvirt_test2.libvirt   |  1 +
 .../libvirt_output/ovf2libvirt_test_gzip.libvirt   |  1 +
 .../ovf2libvirt_test_gzip.libvirt.disk_raw |  1 +
 .../vmx2libvirt_test-nodisks.libvirt   |  1 +
 .../vmx2libvirt_test-vmx-zip.libvirt   |  1 +
 .../libvirt_output/vmx2libvirt_test1.libvirt   |  1 +
 .../vmx2libvirt_test1.libvirt.disk_raw |  1 +
 .../libvirt_output/vmx2libvirt_vmx-dir.libvirt |  1 +
 tests/virtconvtest.py  |  4 +++
 tests/xmlparse-xml/change-guest-out.xml|  1 +
 tests/xmlparse.py  |  4 ++-
 virtinst/cli.py|  1 +
 virtinst/connection.py | 12 ++-
 virtinst/domainfeatures.py |  2 ++
 virtinst/guest.py  |  5 +++
 virtinst/support.py|  2 ++
 53 files changed, 152 insertions(+), 21 deletions(-)
 create mode 100644 
tests/cli-test-xml/compare/virt-install-features-vmcoreinfo.xml

-- 
2.16.1.73.g5832b7e9f2

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

[virt-tools-list] [PATCH v2 1/6] tests/virtconv: ignore skip exceptions

2018-02-22 Thread marcandre . lureau
From: Marc-André Lureau 

Instead of reporting an error and traceback, we could ignore skip
errors. The drawback is that they are now silent.

Signed-off-by: Marc-André Lureau 
---
 tests/virtconvtest.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/virtconvtest.py b/tests/virtconvtest.py
index dbb35612..188b4fd0 100644
--- a/tests/virtconvtest.py
+++ b/tests/virtconvtest.py
@@ -82,6 +82,8 @@ class TestVirtConv(unittest.TestCase):
 for in_path in glob.glob(os.path.join(in_dir, "*")):
 try:
 self._compare_single_file(in_path, in_type)
+except unittest.case.SkipTest:
+continue
 except Exception:
 import traceback
 err += traceback.format_exc()
-- 
2.16.1.73.g5832b7e9f2

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

[virt-tools-list] [PATCH v2 4/6] virtinst/support: add SUPPORT_CONN_VMCOREINFO check

2018-02-22 Thread marcandre . lureau
From: Marc-André Lureau 

It is supported since qemu 2.11 and libvirt 3.10.

Signed-off-by: Marc-André Lureau 
---
 virtinst/support.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/virtinst/support.py b/virtinst/support.py
index fdc1dcb8..5e48cdf0 100644
--- a/virtinst/support.py
+++ b/virtinst/support.py
@@ -326,6 +326,8 @@ SUPPORT_CONN_USB3_PORTS = _make(version="1.3.5")
 SUPPORT_CONN_MACHVIRT_PCI_DEFAULT = _make(version="3.0.0")
 SUPPORT_CONN_QEMU_XHCI = _make(version="3.3.0")
 SUPPORT_CONN_VNC_NONE_AUTH = _make(hv_version={"qemu": "2.9.0"})
+SUPPORT_CONN_VMCOREINFO = _make(
+version="3.10.0", hv_version={"qemu": "2.11.0"})
 
 
 # This is for disk . xen supports this, but it's
-- 
2.16.1.73.g5832b7e9f2

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

[virt-tools-list] [PATCH v2 3/6] virtinst: add feature

2018-02-22 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 .../compare/virt-install-features-vmcoreinfo.xml   | 28 ++
 tests/clitest.py   |  1 +
 virtinst/cli.py|  1 +
 virtinst/domainfeatures.py |  2 ++
 4 files changed, 32 insertions(+)
 create mode 100644 
tests/cli-test-xml/compare/virt-install-features-vmcoreinfo.xml

diff --git a/tests/cli-test-xml/compare/virt-install-features-vmcoreinfo.xml 
b/tests/cli-test-xml/compare/virt-install-features-vmcoreinfo.xml
new file mode 100644
index ..a149c753
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-install-features-vmcoreinfo.xml
@@ -0,0 +1,28 @@
+
+  foobar
+  ----
+  65536
+  65536
+  1
+  
+hvm
+
+  
+  
+
+
+  
+  
+  
+
+
+  
+  
+/usr/bin/test-hv
+
+
+  
+
+
+  
+
diff --git a/tests/clitest.py b/tests/clitest.py
index abdd9b92..90f9c995 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -576,6 +576,7 @@ c.add_compare(""" \
 c = vinst.add_category("features", "--nographics --noautoconsole --import 
--disk none --controller usb,model=none")
 c.add_compare("--features smm=on", "features-smm")
 c.add_invalid("--features smm=on --machine pc")
+c.add_compare("--features vmcoreinfo=on", "features-vmcoreinfo")
 
 
 
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 2bcd8855..16ad81a9 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -1795,6 +1795,7 @@ ParserFeatures.add_arg("pvspinlock", "pvspinlock", 
is_onoff=True)
 ParserFeatures.add_arg("gic_version", "gic_version")
 
 ParserFeatures.add_arg("smm", "smm", is_onoff=True, 
cb=ParserFeatures.set_smm_cb)
+ParserFeatures.add_arg("vmcoreinfo", "vmcoreinfo", is_onoff=True)
 
 
 ###
diff --git a/virtinst/domainfeatures.py b/virtinst/domainfeatures.py
index e4f3165b..df7fe6cf 100644
--- a/virtinst/domainfeatures.py
+++ b/virtinst/domainfeatures.py
@@ -56,3 +56,5 @@ class DomainFeatures(XMLBuilder):
 pvspinlock = XMLProperty("./pvspinlock/@state", is_onoff=True)
 
 smm = XMLProperty("./smm/@state", is_onoff=True)
+vmcoreinfo = XMLProperty("./vmcoreinfo", is_bool=True,
+   default_name="default", default_cb=lambda s: False)
-- 
2.16.1.73.g5832b7e9f2

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

[virt-tools-list] [PATCH v2 5/6] tests: add xmlparse/change vmcoreinfo test

2018-02-22 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 tests/xmlparse-xml/change-guest-out.xml | 1 +
 tests/xmlparse.py   | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/xmlparse-xml/change-guest-out.xml 
b/tests/xmlparse-xml/change-guest-out.xml
index 6c1b29ee..016eb5ad 100644
--- a/tests/xmlparse-xml/change-guest-out.xml
+++ b/tests/xmlparse-xml/change-guest-out.xml
@@ -22,6 +22,7 @@
 
 
 
+
 
   
 
diff --git a/tests/xmlparse.py b/tests/xmlparse.py
index ef12eb51..feeec103 100644
--- a/tests/xmlparse.py
+++ b/tests/xmlparse.py
@@ -163,6 +163,7 @@ class XMLParseTest(unittest.TestCase):
 check("hyperv_spinlocks", True, True)
 check("hyperv_spinlocks_retries", 12287, 54321)
 check("vmport", False, True)
+check("vmcoreinfo", False, True)
 check("kvm_hidden", None, True)
 check("pvspinlock", None, True)
 check("gic_version", None, False)
@@ -223,7 +224,8 @@ class XMLParseTest(unittest.TestCase):
 check("locked", False, True)
 
 self._alter_compare(guest.get_xml_config(), outfile,
-support_check=conn.SUPPORT_CONN_VMPORT)
+support_check=[conn.SUPPORT_CONN_VMPORT,
+   conn.SUPPORT_CONN_VMCOREINFO])
 
 def testSeclabel(self):
 guest, outfile = self._get_test_content("change-seclabel")
-- 
2.16.1.73.g5832b7e9f2

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

[virt-tools-list] [PATCH v2 6/6] virtinst: add by default on x86 & arm-virt

2018-02-22 Thread marcandre . lureau
From: Marc-André Lureau 

If the host and guest support , add it by default.

Update the tests.

Signed-off-by: Marc-André Lureau 
---
 .../compare/virt-convert-ovf-compare.xml   |  1 +
 .../compare/virt-convert-vmx-compare.xml   |  1 +
 .../compare/virt-install-aarch64-cdrom.xml |  6 
 .../compare/virt-install-aarch64-graphics.xml  |  3 ++
 .../compare/virt-install-aarch64-kvm-gic.xml   |  1 +
 .../compare/virt-install-aarch64-kvm-import.xml|  3 ++
 .../compare/virt-install-aarch64-machdefault.xml   |  3 ++
 .../compare/virt-install-aarch64-machvirt.xml  |  3 ++
 .../compare/virt-install-arm-defaultmach-f20.xml   |  3 ++
 .../compare/virt-install-arm-kvm-import.xml|  3 ++
 .../compare/virt-install-arm-virt-f20.xml  |  3 ++
 .../compare/virt-install-boot-uefi.xml |  1 +
 .../compare/virt-install-f21-kvm-remote.xml|  1 +
 .../compare/virt-install-kvm-centos7.xml   |  2 ++
 .../compare/virt-install-kvm-f14-url.xml   |  2 ++
 .../compare/virt-install-kvm-rhel6.xml |  2 ++
 .../compare/virt-install-kvm-rhel7.xml |  2 ++
 .../compare/virt-install-kvm-session-defaults.xml  |  2 ++
 .../compare/virt-install-kvm-win2k3-cdrom.xml  |  2 ++
 .../compare/virt-install-location-iso.xml  |  2 ++
 .../compare/virt-install-location-nfs.xml  |  2 ++
 .../compare/virt-install-many-devices.xml  |  1 +
 .../compare/virt-install-panic-default.xml |  1 +
 .../compare/virt-install-panic-isa-iobase.xml  |  1 +
 .../compare/virt-install-panic-isa.xml |  1 +
 .../compare/virt-install-q35-defaults.xml  |  2 ++
 .../compare/virt-install-qemu-32-on-64.xml |  1 +
 .../compare/virt-install-qemu-plain.xml|  1 +
 .../compare/virt-install-singleton-config-1.xml|  1 +
 .../compare/virt-install-solaris10-defaults.xml|  1 +
 .../cli-test-xml/compare/virt-install-spice-gl.xml |  1 +
 .../compare/virt-install-win7-uefi.xml |  2 ++
 tests/clitest.py   | 41 --
 .../ovf2libvirt_ovf_directory.libvirt  |  1 +
 .../libvirt_output/ovf2libvirt_test1.libvirt   |  1 +
 .../ovf2libvirt_test1.libvirt.disk_qcow2   |  1 +
 .../libvirt_output/ovf2libvirt_test2.libvirt   |  1 +
 .../libvirt_output/ovf2libvirt_test_gzip.libvirt   |  1 +
 .../ovf2libvirt_test_gzip.libvirt.disk_raw |  1 +
 .../vmx2libvirt_test-nodisks.libvirt   |  1 +
 .../vmx2libvirt_test-vmx-zip.libvirt   |  1 +
 .../libvirt_output/vmx2libvirt_test1.libvirt   |  1 +
 .../vmx2libvirt_test1.libvirt.disk_raw |  1 +
 .../libvirt_output/vmx2libvirt_vmx-dir.libvirt |  1 +
 tests/virtconvtest.py  |  2 ++
 virtinst/guest.py  |  5 +++
 46 files changed, 101 insertions(+), 19 deletions(-)

diff --git a/tests/cli-test-xml/compare/virt-convert-ovf-compare.xml 
b/tests/cli-test-xml/compare/virt-convert-ovf-compare.xml
index 2d90abfc..b42452e9 100644
--- a/tests/cli-test-xml/compare/virt-convert-ovf-compare.xml
+++ b/tests/cli-test-xml/compare/virt-convert-ovf-compare.xml
@@ -13,6 +13,7 @@
 
 
 
+
   
   
 Opteron_G4
diff --git a/tests/cli-test-xml/compare/virt-convert-vmx-compare.xml 
b/tests/cli-test-xml/compare/virt-convert-vmx-compare.xml
index 21dbcd65..deafc161 100644
--- a/tests/cli-test-xml/compare/virt-convert-vmx-compare.xml
+++ b/tests/cli-test-xml/compare/virt-convert-vmx-compare.xml
@@ -12,6 +12,7 @@
 
 
 
+
   
   
 Opteron_G4
diff --git a/tests/cli-test-xml/compare/virt-install-aarch64-cdrom.xml 
b/tests/cli-test-xml/compare/virt-install-aarch64-cdrom.xml
index 86eebdc0..16849454 100644
--- a/tests/cli-test-xml/compare/virt-install-aarch64-cdrom.xml
+++ b/tests/cli-test-xml/compare/virt-install-aarch64-cdrom.xml
@@ -11,6 +11,9 @@
 
 
   
+  
+
+  
   
   restart
   destroy
@@ -50,6 +53,9 @@
 
 
   
+  
+
+  
   
   restart
   destroy
diff --git a/tests/cli-test-xml/compare/virt-install-aarch64-graphics.xml 
b/tests/cli-test-xml/compare/virt-install-aarch64-graphics.xml
index 9ee6ced3..092668a9 100644
--- a/tests/cli-test-xml/compare/virt-install-aarch64-graphics.xml
+++ b/tests/cli-test-xml/compare/virt-install-aarch64-graphics.xml
@@ -9,6 +9,9 @@
 /usr/share/AAVMF/AAVMF_CODE.fd
 
   
+  
+
+  
   
   
   
diff --git a/tests/cli-test-xml/compare/virt-install-aarch64-kvm-gic.xml 
b/tests/cli-test-xml/compare/virt-install-aarch64-kvm-gic.xml
index 3a761902..08d84623 100644
--- a/tests/cli-test-xml/compare/virt-install-aarch64-kvm-gic.xml
+++ b/tests/cli-test-xml/compare/virt-install-aarch64-kvm-gic.xml
@@ -11,6 +11,7 @@
   
   
 
+
   
   
   
diff --git a/tests/cli-test-xml/compare/virt-install-aarch64-kvm-import.xml 
b/tests/cli-test-xml/compare/virt-install-aarch64-kvm-import.xml
index 447741f1..0e1faad4 10

[virt-tools-list] [PATCH] virtinst: add feature support

2018-02-20 Thread marcandre . lureau
From: Marc-André Lureau 

The  feature allows a guest to provide debug details when
producing dump. It's useful in particular for Linux guests with KASLR
enabled, as otherwise the dump are difficult to analyze.

This patch adds virt-install support for vmcoreinfo domain
feature. Whenever the host libvirt/qemu is recent enough, and the VM
is x86 or arm-virt, we can assume  is supported and
enable it safely by default (unless --feature vmcoreinfo=on/off is
given, or changed via API)

Note: I am not quite sure if the tests update require
compare_check=support.SUPPORT_CONN_VMCOREINFO has was done for vmport
in commit 2d572e02bd619460f9db3bd671147600926d.

Signed-off-by: Marc-André Lureau 
---
 tests/cli-test-xml/compare/virt-convert-ovf-compare.xml | 1 +
 tests/cli-test-xml/compare/virt-convert-vmx-compare.xml | 1 +
 tests/cli-test-xml/compare/virt-install-aarch64-cdrom.xml   | 6 ++
 tests/cli-test-xml/compare/virt-install-aarch64-graphics.xml| 3 +++
 tests/cli-test-xml/compare/virt-install-aarch64-kvm-gic.xml | 1 +
 tests/cli-test-xml/compare/virt-install-aarch64-kvm-import.xml  | 3 +++
 tests/cli-test-xml/compare/virt-install-aarch64-machdefault.xml | 3 +++
 tests/cli-test-xml/compare/virt-install-aarch64-machvirt.xml| 3 +++
 tests/cli-test-xml/compare/virt-install-arm-defaultmach-f20.xml | 3 +++
 tests/cli-test-xml/compare/virt-install-arm-kvm-import.xml  | 3 +++
 tests/cli-test-xml/compare/virt-install-arm-virt-f20.xml| 3 +++
 tests/cli-test-xml/compare/virt-install-boot-uefi.xml   | 1 +
 tests/cli-test-xml/compare/virt-install-f21-kvm-remote.xml  | 1 +
 tests/cli-test-xml/compare/virt-install-kvm-centos7.xml | 2 ++
 tests/cli-test-xml/compare/virt-install-kvm-f14-url.xml | 2 ++
 tests/cli-test-xml/compare/virt-install-kvm-rhel6.xml   | 2 ++
 tests/cli-test-xml/compare/virt-install-kvm-rhel7.xml   | 2 ++
 tests/cli-test-xml/compare/virt-install-kvm-session-defaults.xml| 2 ++
 tests/cli-test-xml/compare/virt-install-kvm-win2k3-cdrom.xml| 2 ++
 tests/cli-test-xml/compare/virt-install-location-iso.xml| 2 ++
 tests/cli-test-xml/compare/virt-install-location-nfs.xml| 2 ++
 tests/cli-test-xml/compare/virt-install-many-devices.xml| 1 +
 tests/cli-test-xml/compare/virt-install-panic-default.xml   | 1 +
 tests/cli-test-xml/compare/virt-install-panic-isa-iobase.xml| 1 +
 tests/cli-test-xml/compare/virt-install-panic-isa.xml   | 1 +
 tests/cli-test-xml/compare/virt-install-q35-defaults.xml| 2 ++
 tests/cli-test-xml/compare/virt-install-qemu-32-on-64.xml   | 1 +
 tests/cli-test-xml/compare/virt-install-qemu-plain.xml  | 1 +
 tests/cli-test-xml/compare/virt-install-singleton-config-1.xml  | 1 +
 tests/cli-test-xml/compare/virt-install-solaris10-defaults.xml  | 1 +
 tests/cli-test-xml/compare/virt-install-spice-gl.xml| 1 +
 tests/cli-test-xml/compare/virt-install-win7-uefi.xml   | 2 ++
 tests/clitest.py| 2 +-
 .../virtconv-files/libvirt_output/ovf2libvirt_ovf_directory.libvirt | 1 +
 tests/virtconv-files/libvirt_output/ovf2libvirt_test1.libvirt   | 1 +
 .../libvirt_output/ovf2libvirt_test1.libvirt.disk_qcow2 | 1 +
 tests/virtconv-files/libvirt_output/ovf2libvirt_test2.libvirt   | 1 +
 tests/virtconv-files/libvirt_output/ovf2libvirt_test_gzip.libvirt   | 1 +
 .../libvirt_output/ovf2libvirt_test_gzip.libvirt.disk_raw   | 1 +
 .../virtconv-files/libvirt_output/vmx2libvirt_test-nodisks.libvirt  | 1 +
 .../virtconv-files/libvirt_output/vmx2libvirt_test-vmx-zip.libvirt  | 1 +
 tests/virtconv-files/libvirt_output/vmx2libvirt_test1.libvirt   | 1 +
 .../libvirt_output/vmx2libvirt_test1.libvirt.disk_raw   | 1 +
 tests/virtconv-files/libvirt_output/vmx2libvirt_vmx-dir.libvirt | 1 +
 tests/xmlparse-xml/change-guest-out.xml | 1 +
 tests/xmlparse.py   | 1 +
 virtinst/cli.py | 1 +
 virtinst/domainfeatures.py  | 2 ++
 virtinst/guest.py   | 5 +
 virtinst/support.py | 2 ++
 50 files changed, 85 insertions(+), 1 deletion(-)

diff --git a/tests/cli-test-xml/compare/virt-convert-ovf-compare.xml 
b/tests/cli-test-xml/compare/virt-convert-ovf-compare.xml
index 2d90abfc..b42452e9 100644
--- a/tests/cli-test-xml/compare/virt-convert-ovf-compare.xml
+++ b/tests/cli-test-xml/compare/virt-convert-ovf-compare.xml
@@ -13,6 +13,7 @@
 
 
 
+
   
   
 Opteron_G4
diff --git a/tests/cli-test-xml/compare/virt-convert-vmx-compare.xml 
b/tests/cli-test-xml/compare/virt-conve

[virt-tools-list] [PATCH v2 2/3] remote-viewer: remove --spice-controller

2017-11-14 Thread marcandre . lureau
From: Marc-André Lureau 

spice controller interface is being removed from spice-gtk.

Signed-off-by: Marc-André Lureau 
Reviewed-by: Victor Toso 
---
 configure.ac|   3 +-
 data/Makefile.am|   1 -
 data/spice-xpi-client-remote-viewer |   6 -
 data/virt-viewer.wxs.in |  11 -
 man/remote-viewer.pod   |   6 -
 src/Makefile.am |   2 -
 src/remote-viewer.c | 447 +---
 7 files changed, 5 insertions(+), 471 deletions(-)
 delete mode 100644 data/spice-xpi-client-remote-viewer

diff --git a/configure.ac b/configure.ac
index 61374fa..e262e31 100644
--- a/configure.ac
+++ b/configure.ac
@@ -159,13 +159,12 @@ AC_ARG_WITH([spice-gtk],
 AS_IF([test "x$with_spice_gtk" != "xno" && test "x$with_spice_gtk" != "xyes"],
   [PKG_CHECK_EXISTS([spice-client-gtk-3.0 >= $SPICE_GTK_REQUIRED
  spice-client-glib-2.0 >= $SPICE_GTK_REQUIRED
- spice-controller spice-protocol >= 
$SPICE_PROTOCOL_REQUIRED],
+ spice-protocol >= $SPICE_PROTOCOL_REQUIRED],
 [with_spice_gtk=yes], [with_spice_gtk=no])])
 
 AS_IF([test "x$with_spice_gtk" = "xyes"],
   [PKG_CHECK_MODULES(SPICE_GTK, [spice-client-gtk-3.0 >= 
$SPICE_GTK_REQUIRED
  spice-client-glib-2.0 >= 
$SPICE_GTK_REQUIRED])]
-  [PKG_CHECK_MODULES(SPICE_CONTROLLER, [spice-controller])]
   [PKG_CHECK_MODULES(SPICE_PROTOCOL, [spice-protocol >= 
$SPICE_PROTOCOL_REQUIRED])]
   [AC_DEFINE([HAVE_SPICE_GTK], 1, [Have spice-gtk?])]
 )
diff --git a/data/Makefile.am b/data/Makefile.am
index 55718d9..54be2b1 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -3,7 +3,6 @@ CLEANFILES =
 MANUFACTURER = Virt Manager Project
 
 EXTRA_DIST =   \
-   spice-xpi-client-remote-viewer  \
virt-viewer.wxs.in  \
$(NULL)
 
diff --git a/data/spice-xpi-client-remote-viewer 
b/data/spice-xpi-client-remote-viewer
deleted file mode 100644
index 3109c66..000
--- a/data/spice-xpi-client-remote-viewer
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-logger -t spice "starting remote-viewer --spice-controller $@..."
-env | logger -t spice
-exec remote-viewer --spice-controller "$@" 2>&1 | logger -t spice
-logger -t spice "remote-viewer execution failed"
diff --git a/data/virt-viewer.wxs.in b/data/virt-viewer.wxs.in
index 9838265..2047720 100644
--- a/data/virt-viewer.wxs.in
+++ b/data/virt-viewer.wxs.in
@@ -55,16 +55,6 @@
 NOT 
NEWERVERSIONDETECTED
 
 
-  
-
-  
-  
-  
-
-
-  
-
-  
   
 
   
@@ -129,7 +119,6 @@
   
   
   
-  
   
   
 
diff --git a/man/remote-viewer.pod b/man/remote-viewer.pod
index 8428c80..968ea70 100644
--- a/man/remote-viewer.pod
+++ b/man/remote-viewer.pod
@@ -58,12 +58,6 @@ CONFIGURATION section below.
 
 Set the window title to B
 
-=item --spice-controller
-
-Use the SPICE controller to initialize the connection with the SPICE
-server. This option is used by the SPICE browser addons to allow web
-page to start a client.
-
 =item --debug
 
 Print debugging information
diff --git a/src/Makefile.am b/src/Makefile.am
index b9e3421..a6807b6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -180,11 +180,9 @@ remote_viewer_SOURCES =\
$(NULL)
 remote_viewer_LDFLAGS =\
$(COMMON_LIBS)  \
-   $(SPICE_CONTROLLER_LIBS)\
$(NULL)
 remote_viewer_CFLAGS = \
$(COMMON_CFLAGS)\
-   $(SPICE_CONTROLLER_CFLAGS)  \
$(NULL)
 remote_viewer_LDADD = \
libvirt-viewer-util.la \
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index e082178..0a026c1 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -36,7 +36,6 @@
 #endif
 
 #ifdef HAVE_SPICE_GTK
-#include 
 #include "virt-viewer-session-spice.h"
 #endif
 
@@ -49,10 +48,6 @@
 #include "remote-viewer-connect.h"
 
 struct _RemoteViewerPrivate {
-#ifdef HAVE_SPICE_GTK
-SpiceCtrlController *controller;
-SpiceCtrlForeignMenu *ctrl_foreign_menu;
-#endif
 #ifdef HAVE_OVIRT
 OvirtForeignMenu *ovirt_foreign_menu;
 #endif
@@ -78,12 +73,6 @@ static OvirtVm * choose_vm(GtkWindow *main_window,
 #endif
 
 static gboolean remote_viewer_start(VirtViewerApp *self, GError **error);
-#ifdef HAVE_SPICE_GTK
-static gboolean remote_viewer_activate(VirtViewerApp *self, GError **error);
-static void remote_viewer_window_added(GtkApplication *app, GtkWindow *w);
-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_i

[virt-tools-list] [PATCH v2 3/3] win32: remove debug-helper.exe

2017-11-14 Thread marcandre . lureau
From: Marc-André Lureau 

This helper was useful to debug spice controller & activex plugin. Now
that the controller is gone, it is no longer needed.

Signed-off-by: Marc-André Lureau 
---
 mingw-virt-viewer.spec.in |  2 --
 src/Makefile.am   |  5 ---
 src/debug-helper.c| 83 ---
 3 files changed, 90 deletions(-)
 delete mode 100644 src/debug-helper.c

diff --git a/mingw-virt-viewer.spec.in b/mingw-virt-viewer.spec.in
index 06f1992..f4344a1 100644
--- a/mingw-virt-viewer.spec.in
+++ b/mingw-virt-viewer.spec.in
@@ -138,7 +138,6 @@ rm -rf $RPM_BUILD_ROOT
 %{mingw32_bindir}/virt-viewer.exe
 %{mingw32_bindir}/remote-viewer.exe
 %{mingw32_bindir}/windows-cmdline-wrapper.exe
-%{mingw32_bindir}/debug-helper.exe
 
 %dir %{mingw32_datadir}/virt-viewer/
 %{mingw32_datadir}/icons/hicolor/*/apps/*
@@ -155,7 +154,6 @@ rm -rf $RPM_BUILD_ROOT
 %{mingw64_bindir}/virt-viewer.exe
 %{mingw64_bindir}/remote-viewer.exe
 %{mingw64_bindir}/windows-cmdline-wrapper.exe
-%{mingw64_bindir}/debug-helper.exe
 
 %dir %{mingw64_datadir}/virt-viewer/
 %{mingw64_datadir}/icons/hicolor/*/apps/*
diff --git a/src/Makefile.am b/src/Makefile.am
index a6807b6..0a3cbbf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -210,11 +210,6 @@ virt-viewer_rc.$(OBJEXT): $(VIRT_VIEWER_RES) 
$(ICONDIR)/virt-viewer.ico
-i $< -o $@
 LDADD += virt-viewer_rc.$(OBJEXT)
 MAINTAINERCLEANFILES += virt-viewer_rc.$(OBJEXT)
-
-bin_PROGRAMS += debug-helper
-debug_helper_SOURCES = debug-helper.c
-debug_helper_LDFLAGS = $(GLIB2_LIBS) -Wl,--subsystem,windows
-debug_helper_CFLAGS = $(GLIB2_CFLAGS)
 endif
 
 -include $(top_srcdir)/git.mk
diff --git a/src/debug-helper.c b/src/debug-helper.c
deleted file mode 100644
index 01909da..000
--- a/src/debug-helper.c
+++ /dev/null
@@ -1,83 +0,0 @@
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-static gchar*
-get_program_path(void)
-{
-gchar *utf8_buf, *path = NULL;
-wchar_t buf[MAX_PATH+1];
-
-if (GetModuleFileNameW(GetModuleHandle (NULL), buf, G_N_ELEMENTS (buf)) > 
0) {
-utf8_buf = g_utf16_to_utf8(buf, -1, NULL, NULL, NULL);
-path = g_path_get_dirname(utf8_buf);
-g_free(utf8_buf);
-}
-
-return path;
-}
-
-int
-main(int argc, char *argv[])
-{
-char pipe[2048];
-MSG msg;
-STARTUPINFO si = { 0, };
-PROCESS_INFORMATION pi = { 0, };
-gchar *program_path = get_program_path();
-gchar *command;
-int rv = 0;
-
-argv[0] = "gdb -ex run --args";
-command = g_strjoinv(" ", argv);
-
-snprintf(pipe, sizeof(pipe), ".\\pipe\\SpiceController-%lu", 
GetCurrentProcessId());
-
-SetEnvironmentVariable("SPICE_DEBUG", "1");
-SetEnvironmentVariable("G_MESSAGES_DEBUG", "all");
-SetEnvironmentVariable("SPICE_XPI_NAMEDPIPE", pipe);
-
-si.cb = sizeof(si);
-if (!CreateProcess(NULL,
-   command,
-   NULL,
-   NULL,
-   FALSE,
-   0,
-   NULL,
-   program_path,
-   &si,
-   &pi)) {
-printf("CreateProcess failed (%ld).\n", GetLastError());
-rv = 1;
-goto end;
-}
-
-
-while (1) {
-DWORD reason = MsgWaitForMultipleObjects(1, &pi.hProcess, FALSE,
- INFINITE, QS_ALLINPUT);
-if (reason == WAIT_OBJECT_0)
-break;
-else {
-if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
-TranslateMessage(&msg);
-DispatchMessage(&msg);
-}
-}
-}
-
-// Close process and thread handles
-CloseHandle(pi.hProcess);
-CloseHandle(pi.hThread);
-
-end:
-g_free(program_path);
-g_free(command);
-
-exit(rv);
-return rv;
-}
-- 
2.15.0.125.g8f49766d64

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

[virt-tools-list] [PATCH v2 1/3] remote-viewer: learn '-' as URI for standard input connection file

2017-11-14 Thread marcandre . lureau
From: Marc-André Lureau 

Some users want the ability to set connection details without writing
to a file or passing command line arguments.

Learn to read the connection file from standard input for such use
case.

This allows a parent process to set the connection details without
intermediary file.

Signed-off-by: Marc-André Lureau 
Reviewed-by: Victor Toso 
---
 man/remote-viewer.pod  |  3 +++
 src/remote-viewer.c| 46 --
 src/virt-viewer-file.c | 31 +--
 src/virt-viewer-file.h |  2 ++
 4 files changed, 70 insertions(+), 12 deletions(-)

diff --git a/man/remote-viewer.pod b/man/remote-viewer.pod
index 60ea3a6..8428c80 100644
--- a/man/remote-viewer.pod
+++ b/man/remote-viewer.pod
@@ -18,6 +18,9 @@ entry and a list of previously successfully accessed URI.
 The URI can also point to a connection settings file, see the CONNECTION FILE
 section for a description of the format.
 
+If URI is '-', then remote-viewer will read the standard input as a
+connection settings file and attempt to connect using it.
+
 =head1 OPTIONS
 
 The following options are accepted when running C:
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index fb5376c..e082178 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -1084,6 +1084,22 @@ remote_viewer_session_connected(VirtViewerSession 
*session,
 g_free(uri);
 }
 
+static gchar *
+read_all_stdin(gsize *len, GError **err)
+{
+GIOChannel *ioc = g_io_channel_unix_new(fileno(stdin));
+gchar *content = NULL;
+GIOStatus status;
+
+status = g_io_channel_read_to_end(ioc, &content, len, err);
+g_assert(status != G_IO_STATUS_AGAIN && status != G_IO_STATUS_EOF);
+
+g_io_channel_unref(ioc);
+g_assert((content && !*err) || (!content && *err));
+
+return content;
+}
+
 static gboolean
 remote_viewer_initial_connect(RemoteViewer *self, const gchar *type,
   VirtViewerFile *vvfile, GError **error)
@@ -1174,16 +1190,34 @@ retry_dialog:
 
 g_debug("Opening display to %s", guri);
 
-file = g_file_new_for_commandline_arg(guri);
-if (g_file_query_exists(file, NULL)) {
-gchar *path = g_file_get_path(file);
-vvfile = virt_viewer_file_new(path, &error);
-g_free(path);
+if (!g_strcmp0(guri, "-")) {
+gsize len = 0;
+gchar *buf = read_all_stdin(&len, &error);
+
 if (error) {
-g_prefix_error(&error, _("Invalid file %s: "), guri);
+g_prefix_error(&error, _("Failed to read stdin: "));
 g_warning("%s", error->message);
 goto cleanup;
 }
+
+vvfile = virt_viewer_file_new_from_buffer(buf, len, &error);
+g_free(buf);
+} else {
+file = g_file_new_for_commandline_arg(guri);
+if (g_file_query_exists(file, NULL)) {
+gchar *path = g_file_get_path(file);
+vvfile = virt_viewer_file_new(path, &error);
+g_free(path);
+}
+}
+
+if (error) {
+g_prefix_error(&error, _("Invalid file %s: "), guri);
+g_warning("%s", error->message);
+goto cleanup;
+}
+
+if (vvfile) {
 g_object_get(G_OBJECT(vvfile), "type", &type, NULL);
 } else if (virt_viewer_util_extract_host(guri, &type, NULL, NULL, 
NULL, NULL) < 0 || type == NULL) {
 g_set_error_literal(&error,
diff --git a/src/virt-viewer-file.c b/src/virt-viewer-file.c
index 9ff2a05..1b0c310 100644
--- a/src/virt-viewer-file.c
+++ b/src/virt-viewer-file.c
@@ -139,16 +139,15 @@ enum  {
 };
 
 VirtViewerFile*
-virt_viewer_file_new(const gchar* location, GError** error)
+virt_viewer_file_new_from_buffer(const gchar* data, gsize len,
+ GError** error)
 {
 GError* inner_error = NULL;
-
-g_return_val_if_fail (location != NULL, NULL);
-
 VirtViewerFile* self = 
VIRT_VIEWER_FILE(g_object_new(VIRT_VIEWER_TYPE_FILE, NULL));
 GKeyFile* keyfile = self->priv->keyfile;
 
-g_key_file_load_from_file(keyfile, location,
+g_return_val_if_fail(data != NULL, NULL);
+g_key_file_load_from_data(keyfile, data, len,
   G_KEY_FILE_KEEP_COMMENTS | 
G_KEY_FILE_KEEP_TRANSLATIONS,
   &inner_error);
 if (inner_error != NULL) {
@@ -166,7 +165,27 @@ virt_viewer_file_new(const gchar* location, GError** error)
 return NULL;
 }
 
-if (virt_viewer_file_get_delete_this_file(self) &&
+return self;
+}
+
+VirtViewerFile*
+virt_viewer_file_new(const gchar* location, GError** error)
+{
+VirtViewerFile *self;
+gchar *buf;
+gsize len;
+
+g_return_val_if_fail (location != NULL, NULL);
+
+if (!g_file_get_contents(location, &buf, &len, error)) {
+return NULL;
+}
+
+self = virt_viewer_file_new_from_buffer(buf, len, error);

[virt-tools-list] [PATCH v2 0/3] virt-viewer: remove spice-controller support

2017-11-14 Thread marcandre . lureau
From: Marc-André Lureau 

Hi,

The spice-controller library is no longer part of spice-gtk upstream
(upcoming 0.35 release). Instead, we long have provided the .vv file
to setup the connection & ovirt menu for additional runtime
interactons.

There are users who requested to be able to pass the connection
details without creating a file on the filesystem. The first patch
allows the parent process to setup the connection by passing the .vv
file via stdin.

v2:
- improve error handling
- remove some more spice-controller leftovers
- fix some compilation warning
- add a patch to remove debug-helper
- add Victor r-b tags

Marc-André Lureau (3):
  remote-viewer: learn '-' as URI for standard input connection file
  remote-viewer: remove --spice-controller
  win32: remove debug-helper.exe

 configure.ac|   3 +-
 data/Makefile.am|   1 -
 data/spice-xpi-client-remote-viewer |   6 -
 data/virt-viewer.wxs.in |  11 -
 man/remote-viewer.pod   |   9 +-
 mingw-virt-viewer.spec.in   |   2 -
 src/Makefile.am |   7 -
 src/debug-helper.c  |  83 --
 src/remote-viewer.c | 493 
 src/virt-viewer-file.c  |  31 ++-
 src/virt-viewer-file.h  |   2 +
 11 files changed, 75 insertions(+), 573 deletions(-)
 delete mode 100644 data/spice-xpi-client-remote-viewer
 delete mode 100644 src/debug-helper.c

-- 
2.15.0.125.g8f49766d64

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

[virt-tools-list] [PATCH 1/2] RFC: remote-viewer: learn '-' as URI for standard input connection file

2017-07-28 Thread marcandre . lureau
From: Marc-André Lureau 

Some users want the ability to set connection details without writing
to a file or passing command line arguments.

Learn to read the connection file from standard input for such use
case.

This allows a parent process to set the connection details without
intermediary file.

Signed-off-by: Marc-André Lureau 
---
 man/remote-viewer.pod  |  3 +++
 src/remote-viewer.c| 32 +++-
 src/virt-viewer-file.c | 31 +--
 src/virt-viewer-file.h |  2 ++
 4 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/man/remote-viewer.pod b/man/remote-viewer.pod
index 60ea3a6..8428c80 100644
--- a/man/remote-viewer.pod
+++ b/man/remote-viewer.pod
@@ -18,6 +18,9 @@ entry and a list of previously successfully accessed URI.
 The URI can also point to a connection settings file, see the CONNECTION FILE
 section for a description of the format.
 
+If URI is '-', then remote-viewer will read the standard input as a
+connection settings file and attempt to connect using it.
+
 =head1 OPTIONS
 
 The following options are accepted when running C:
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index b132214..39fe9c3 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -1080,6 +1080,18 @@ remote_viewer_session_connected(VirtViewerSession 
*session,
 g_free(uri);
 }
 
+static gchar *
+read_all_stdin(gsize *len)
+{
+GIOChannel *ioc = g_io_channel_unix_new(fileno(stdin));
+gchar *content = NULL;
+
+g_io_channel_read_to_end(ioc, &content, len, NULL);
+g_io_channel_unref(ioc);
+
+return content;
+}
+
 static gboolean
 remote_viewer_start(VirtViewerApp *app, GError **err)
 {
@@ -1134,11 +1146,21 @@ retry_dialog:
 
 g_debug("Opening display to %s", guri);
 
-file = g_file_new_for_commandline_arg(guri);
-if (g_file_query_exists(file, NULL)) {
-gchar *path = g_file_get_path(file);
-vvfile = virt_viewer_file_new(path, &error);
-g_free(path);
+if (!g_strcmp0(guri, "-")) {
+gsize len = 0;
+gchar *buf = read_all_stdin(&len);
+vvfile = virt_viewer_file_new_from_buffer(buf, len, &error);
+g_free(buf);
+} else {
+file = g_file_new_for_commandline_arg(guri);
+if (g_file_query_exists(file, NULL)) {
+gchar *path = g_file_get_path(file);
+vvfile = virt_viewer_file_new(path, &error);
+g_free(path);
+}
+}
+
+if (vvfile) {
 if (error) {
 g_prefix_error(&error, _("Invalid file %s: "), guri);
 g_warning("%s", error->message);
diff --git a/src/virt-viewer-file.c b/src/virt-viewer-file.c
index 9ff2a05..a511f21 100644
--- a/src/virt-viewer-file.c
+++ b/src/virt-viewer-file.c
@@ -139,16 +139,15 @@ enum  {
 };
 
 VirtViewerFile*
-virt_viewer_file_new(const gchar* location, GError** error)
+virt_viewer_file_new_from_buffer(const gchar* data, gsize len,
+ GError** error)
 {
 GError* inner_error = NULL;
-
-g_return_val_if_fail (location != NULL, NULL);
-
 VirtViewerFile* self = 
VIRT_VIEWER_FILE(g_object_new(VIRT_VIEWER_TYPE_FILE, NULL));
 GKeyFile* keyfile = self->priv->keyfile;
 
-g_key_file_load_from_file(keyfile, location,
+
+g_key_file_load_from_data(keyfile, data, len,
   G_KEY_FILE_KEEP_COMMENTS | 
G_KEY_FILE_KEEP_TRANSLATIONS,
   &inner_error);
 if (inner_error != NULL) {
@@ -166,7 +165,27 @@ virt_viewer_file_new(const gchar* location, GError** error)
 return NULL;
 }
 
-if (virt_viewer_file_get_delete_this_file(self) &&
+return self;
+}
+
+VirtViewerFile*
+virt_viewer_file_new(const gchar* location, GError** error)
+{
+VirtViewerFile *self;
+gchar *buf;
+gsize len;
+
+g_return_val_if_fail (location != NULL, NULL);
+
+if (!g_file_get_contents(location, &buf, &len, error)) {
+return NULL;
+}
+
+self = virt_viewer_file_new_from_buffer(buf, len, error);
+g_free(buf);
+
+
+if (self && virt_viewer_file_get_delete_this_file(self) &&
 !g_getenv("VIRT_VIEWER_KEEP_FILE")) {
 if (g_unlink(location) != 0)
 g_warning("failed to remove %s", location);
diff --git a/src/virt-viewer-file.h b/src/virt-viewer-file.h
index 6b783f9..15c61d0 100644
--- a/src/virt-viewer-file.h
+++ b/src/virt-viewer-file.h
@@ -50,6 +50,8 @@ struct _VirtViewerFileClass
 GType virt_viewer_file_get_type(void);
 
 VirtViewerFile* virt_viewer_file_new(const gchar* path, GError** error);
+VirtViewerFile* virt_viewer_file_new_from_buffer(const gchar* buf, gsize len,
+ GError** error);
 gboolean virt_viewer_file_is_set(VirtViewerFile* self, const gchar* key);
 
 gchar* virt_viewer_file_get_ca(VirtViewerFile* self);
-- 
2.14.0.rc0.1.g40ca67566

___

[virt-tools-list] [PATCH 0/2] Remove spice controller

2017-07-28 Thread marcandre . lureau
From: Marc-André Lureau 

Hi,

The series is a second attempt at removing the Spice controller from
remote-viewer. The first attempt was to replace it with a dbus
controller. But I realize that didn't make much sense, as the parent
process setting up the connection may as well just use stdin to do so
with the existing virt-viewer-file format.

Marc-André Lureau (2):
  RFC: remote-viewer: learn '-' as URI for standard input connection
file
  remote-viewer: remove --spice-controller

 configure.ac|   3 +-
 data/Makefile.am|   1 -
 data/spice-xpi-client-remote-viewer |   6 -
 data/virt-viewer.wxs.in |  11 -
 man/remote-viewer.pod   |   9 +-
 src/remote-viewer.c | 476 +++-
 src/virt-viewer-file.c  |  31 ++-
 src/virt-viewer-file.h  |   2 +
 8 files changed, 60 insertions(+), 479 deletions(-)
 delete mode 100644 data/spice-xpi-client-remote-viewer

-- 
2.14.0.rc0.1.g40ca67566

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

[virt-tools-list] [PATCH 2/2] remote-viewer: remove --spice-controller

2017-07-28 Thread marcandre . lureau
From: Marc-André Lureau 

spice controller interface is being removed from spice-gtk.

Signed-off-by: Marc-André Lureau 
---
 configure.ac|   3 +-
 data/Makefile.am|   1 -
 data/spice-xpi-client-remote-viewer |   6 -
 data/virt-viewer.wxs.in |  11 -
 man/remote-viewer.pod   |   6 -
 src/remote-viewer.c | 444 +---
 6 files changed, 3 insertions(+), 468 deletions(-)
 delete mode 100644 data/spice-xpi-client-remote-viewer

diff --git a/configure.ac b/configure.ac
index d5eb258..4f5e3df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -159,13 +159,12 @@ AC_ARG_WITH([spice-gtk],
 AS_IF([test "x$with_spice_gtk" != "xno" && test "x$with_spice_gtk" != "xyes"],
   [PKG_CHECK_EXISTS([spice-client-gtk-3.0 >= $SPICE_GTK_REQUIRED
  spice-client-glib-2.0 >= $SPICE_GTK_REQUIRED
- spice-controller spice-protocol >= 
$SPICE_PROTOCOL_REQUIRED],
+ spice-protocol >= $SPICE_PROTOCOL_REQUIRED],
 [with_spice_gtk=yes], [with_spice_gtk=no])])
 
 AS_IF([test "x$with_spice_gtk" = "xyes"],
   [PKG_CHECK_MODULES(SPICE_GTK, [spice-client-gtk-3.0 >= 
$SPICE_GTK_REQUIRED
  spice-client-glib-2.0 >= 
$SPICE_GTK_REQUIRED])]
-  [PKG_CHECK_MODULES(SPICE_CONTROLLER, [spice-controller])]
   [PKG_CHECK_MODULES(SPICE_PROTOCOL, [spice-protocol >= 
$SPICE_PROTOCOL_REQUIRED])]
   [AC_DEFINE([HAVE_SPICE_GTK], 1, [Have spice-gtk?])]
 )
diff --git a/data/Makefile.am b/data/Makefile.am
index 55718d9..54be2b1 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -3,7 +3,6 @@ CLEANFILES =
 MANUFACTURER = Virt Manager Project
 
 EXTRA_DIST =   \
-   spice-xpi-client-remote-viewer  \
virt-viewer.wxs.in  \
$(NULL)
 
diff --git a/data/spice-xpi-client-remote-viewer 
b/data/spice-xpi-client-remote-viewer
deleted file mode 100644
index 3109c66..000
--- a/data/spice-xpi-client-remote-viewer
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-logger -t spice "starting remote-viewer --spice-controller $@..."
-env | logger -t spice
-exec remote-viewer --spice-controller "$@" 2>&1 | logger -t spice
-logger -t spice "remote-viewer execution failed"
diff --git a/data/virt-viewer.wxs.in b/data/virt-viewer.wxs.in
index 9838265..2047720 100644
--- a/data/virt-viewer.wxs.in
+++ b/data/virt-viewer.wxs.in
@@ -55,16 +55,6 @@
 NOT 
NEWERVERSIONDETECTED
 
 
-  
-
-  
-  
-  
-
-
-  
-
-  
   
 
   
@@ -129,7 +119,6 @@
   
   
   
-  
   
   
 
diff --git a/man/remote-viewer.pod b/man/remote-viewer.pod
index 8428c80..968ea70 100644
--- a/man/remote-viewer.pod
+++ b/man/remote-viewer.pod
@@ -58,12 +58,6 @@ CONFIGURATION section below.
 
 Set the window title to B
 
-=item --spice-controller
-
-Use the SPICE controller to initialize the connection with the SPICE
-server. This option is used by the SPICE browser addons to allow web
-page to start a client.
-
 =item --debug
 
 Print debugging information
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 39fe9c3..ae81560 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -36,7 +36,6 @@
 #endif
 
 #ifdef HAVE_SPICE_GTK
-#include 
 #include "virt-viewer-session-spice.h"
 #endif
 
@@ -49,10 +48,6 @@
 #include "remote-viewer-connect.h"
 
 struct _RemoteViewerPrivate {
-#ifdef HAVE_SPICE_GTK
-SpiceCtrlController *controller;
-SpiceCtrlForeignMenu *ctrl_foreign_menu;
-#endif
 #ifdef HAVE_OVIRT
 OvirtForeignMenu *ovirt_foreign_menu;
 #endif
@@ -78,12 +73,6 @@ static OvirtVm * choose_vm(GtkWindow *main_window,
 #endif
 
 static gboolean remote_viewer_start(VirtViewerApp *self, GError **error);
-#ifdef HAVE_SPICE_GTK
-static gboolean remote_viewer_activate(VirtViewerApp *self, GError **error);
-static void remote_viewer_window_added(GtkApplication *app, GtkWindow *w);
-static void spice_foreign_menu_updated(RemoteViewer *self);
-static void foreign_menu_title_changed(SpiceCtrlForeignMenu *menu, GParamSpec 
*pspec, RemoteViewer *self);
-#endif
 
 static void
 remote_viewer_dispose (GObject *object)
@@ -93,18 +82,6 @@ remote_viewer_dispose (GObject *object)
 RemoteViewerPrivate *priv = self->priv;
 #endif
 
-#ifdef HAVE_SPICE_GTK
-if (priv->controller) {
-g_object_unref(priv->controller);
-priv->controller = NULL;
-}
-
-if (priv->ctrl_foreign_menu) {
-g_object_unref(priv->ctrl_foreign_menu);
-priv->ctrl_foreign_menu = NULL;
-}
-#endif
-
 #ifdef HAVE_OVIRT
 if (priv->ovirt_foreign_menu) {
 g_object_unref(priv->ovirt_foreign_menu);
@@ -132,7 +109,6 @@ remote_viewer_deactivated(VirtViewerApp *app, gboolean 
connect_error)
 
 static gchar **opt_args = NULL;
 static char *opt_title = NULL

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

2017-06-23 Thread marcandre . lureau
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()

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, &opt_title,
   N_("Set window title"), NULL },
+{ "dbus-controller", '\0', 0, G_OPTION_ARG_NONE, &opt_dbus_ctrl,
+  N_("Open connection using DBus controller"), NULL },
 #ifdef HAVE_SPICE_GTK
 { "spice-controller", '\0', 0, G_OPTION_ARG_NONE, &opt_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, 
&error)) {
+g_dbus_method_invocation_return_gerror(invocation, error);
+g_clear_error(&error);
+} else {
+g_dbus_method_invocation_return_value (invocation, NULL);
+}
+}
+}
+
+
+static GVariant *
+handle_get_property (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  *property_name,
+ GError  **error G_GNUC_UNUSED,
+   

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

2017-06-23 Thread marcandre . lureau
From: Marc-André Lureau 

If the dbus-ctrl property is set, we should call open_uri() without
guri set.

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
 
-- 
2.13.1.395.gf7b71de06

___
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/6] RFC: add dbus-controller, remove spice-controller

2017-06-23 Thread marcandre . lureau
From: Marc-André Lureau 

Hi,

For the reasons explained in this spice-gtk patch series:
https://patchwork.freedesktop.org/patch/161676/, spice-controller
should eventually be removed. We developped the .vv file format as an
alternative for browsers (and other users) to configure the viewer.

But Jeremy White expressed some concerns about setting up connections
with .vv file. I proposed such use case be covered with a new dbus
interface. See --dbus-controller for more details.

Comments welcome,

Marc-André Lureau (6):
  file: make constructor accept NULL location
  session: remove virt_viewer_session_new() declaration
  app: add dbus-ctrl property
  remote-viewer: factor our remote_viewer_initial_connect()
  remote-viewer: add a --dbus-controller
  remote-viewer: remove --spice-controller

 configure.ac|   3 +-
 data/Makefile.am|   1 -
 data/spice-xpi-client-remote-viewer |   6 -
 data/virt-viewer.wxs.in |   3 -
 man/remote-viewer.pod   |   6 -
 src/remote-viewer.c | 698 
 src/remote-viewer.h |   1 +
 src/virt-viewer-app.c   |  12 +
 src/virt-viewer-app.h   |   1 +
 src/virt-viewer-file.c  |   8 +-
 src/virt-viewer-session.h   |   1 -
 11 files changed, 255 insertions(+), 485 deletions(-)
 delete mode 100644 data/spice-xpi-client-remote-viewer

-- 
2.13.1.395.gf7b71de06

___
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 6/6] remote-viewer: remove --spice-controller

2017-06-23 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 configure.ac|   3 +-
 data/Makefile.am|   1 -
 data/spice-xpi-client-remote-viewer |   6 -
 data/virt-viewer.wxs.in |   3 -
 man/remote-viewer.pod   |   6 -
 src/remote-viewer.c | 440 +---
 6 files changed, 3 insertions(+), 456 deletions(-)
 delete mode 100644 data/spice-xpi-client-remote-viewer

diff --git a/configure.ac b/configure.ac
index d5eb258..4f5e3df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -159,13 +159,12 @@ AC_ARG_WITH([spice-gtk],
 AS_IF([test "x$with_spice_gtk" != "xno" && test "x$with_spice_gtk" != "xyes"],
   [PKG_CHECK_EXISTS([spice-client-gtk-3.0 >= $SPICE_GTK_REQUIRED
  spice-client-glib-2.0 >= $SPICE_GTK_REQUIRED
- spice-controller spice-protocol >= 
$SPICE_PROTOCOL_REQUIRED],
+ spice-protocol >= $SPICE_PROTOCOL_REQUIRED],
 [with_spice_gtk=yes], [with_spice_gtk=no])])
 
 AS_IF([test "x$with_spice_gtk" = "xyes"],
   [PKG_CHECK_MODULES(SPICE_GTK, [spice-client-gtk-3.0 >= 
$SPICE_GTK_REQUIRED
  spice-client-glib-2.0 >= 
$SPICE_GTK_REQUIRED])]
-  [PKG_CHECK_MODULES(SPICE_CONTROLLER, [spice-controller])]
   [PKG_CHECK_MODULES(SPICE_PROTOCOL, [spice-protocol >= 
$SPICE_PROTOCOL_REQUIRED])]
   [AC_DEFINE([HAVE_SPICE_GTK], 1, [Have spice-gtk?])]
 )
diff --git a/data/Makefile.am b/data/Makefile.am
index 55718d9..54be2b1 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -3,7 +3,6 @@ CLEANFILES =
 MANUFACTURER = Virt Manager Project
 
 EXTRA_DIST =   \
-   spice-xpi-client-remote-viewer  \
virt-viewer.wxs.in  \
$(NULL)
 
diff --git a/data/spice-xpi-client-remote-viewer 
b/data/spice-xpi-client-remote-viewer
deleted file mode 100644
index 3109c66..000
--- a/data/spice-xpi-client-remote-viewer
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-logger -t spice "starting remote-viewer --spice-controller $@..."
-env | logger -t spice
-exec remote-viewer --spice-controller "$@" 2>&1 | logger -t spice
-logger -t spice "remote-viewer execution failed"
diff --git a/data/virt-viewer.wxs.in b/data/virt-viewer.wxs.in
index 9838265..f046d4b 100644
--- a/data/virt-viewer.wxs.in
+++ b/data/virt-viewer.wxs.in
@@ -61,9 +61,6 @@
   
   
 
-
-  
-
   
   
 
diff --git a/man/remote-viewer.pod b/man/remote-viewer.pod
index 60ea3a6..a050f4c 100644
--- a/man/remote-viewer.pod
+++ b/man/remote-viewer.pod
@@ -55,12 +55,6 @@ CONFIGURATION section below.
 
 Set the window title to B
 
-=item --spice-controller
-
-Use the SPICE controller to initialize the connection with the SPICE
-server. This option is used by the SPICE browser addons to allow web
-page to start a client.
-
 =item --debug
 
 Print debugging information
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index f0f9531..936246c 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -36,7 +36,6 @@
 #endif
 
 #ifdef HAVE_SPICE_GTK
-#include 
 #include "virt-viewer-session-spice.h"
 #endif
 
@@ -49,10 +48,6 @@
 #include "remote-viewer-connect.h"
 
 struct _RemoteViewerPrivate {
-#ifdef HAVE_SPICE_GTK
-SpiceCtrlController *controller;
-SpiceCtrlForeignMenu *ctrl_foreign_menu;
-#endif
 #ifdef HAVE_OVIRT
 OvirtForeignMenu *ovirt_foreign_menu;
 #endif
@@ -80,10 +75,7 @@ static OvirtVm * choose_vm(GtkWindow *main_window,
 
 static gboolean remote_viewer_start(VirtViewerApp *self, GError **error);
 #ifdef HAVE_SPICE_GTK
-static gboolean remote_viewer_activate(VirtViewerApp *self, GError **error);
-static void remote_viewer_window_added(GtkApplication *app, GtkWindow *w);
 static void spice_foreign_menu_updated(RemoteViewer *self);
-static void foreign_menu_title_changed(SpiceCtrlForeignMenu *menu, GParamSpec 
*pspec, RemoteViewer *self);
 #endif
 
 static gboolean
@@ -98,18 +90,6 @@ remote_viewer_dispose (GObject *object)
 RemoteViewerPrivate *priv = self->priv;
 #endif
 
-#ifdef HAVE_SPICE_GTK
-if (priv->controller) {
-g_object_unref(priv->controller);
-priv->controller = NULL;
-}
-
-if (priv->ctrl_foreign_menu) {
-g_object_unref(priv->ctrl_foreign_menu);
-priv->ctrl_foreign_menu = NULL;
-}
-#endif
-
 #ifdef HAVE_OVIRT
 if (priv->ovirt_foreign_menu) {
 g_object_unref(priv->ovirt_foreign_menu);
@@ -137,7 +117,6 @@ 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
@@ -148,10 +127,6 @@ remote_viewer_add_option_entries(VirtViewerApp *self, 
GOptionContext *context, G
   N_("Set window title"), NULL },
 { "dbus-c

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

2017-06-23 Thread marcandre . lureau
From: Marc-André Lureau 

The function was removed in commit
05333f0e93fb988c2fd9302e67671490941aedb0.

Signed-off-by: Marc-André Lureau 
---
 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,
-- 
2.13.1.395.gf7b71de06

___
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 4/6] remote-viewer: factor our remote_viewer_initial_connect()

2017-06-23 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 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, &error))
+if (!remote_viewer_initial_connect(self, type, vvfile, &error))
 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, &error)) {
-if (error == NULL) {
-g_set_error_literal(&error,
-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, 
&error);
 
-- 
2.13.1.395.gf7b71de06

___
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/6] file: make constructor accept NULL location

2017-06-23 Thread marcandre . lureau
From: Marc-André Lureau 

We are going to make empty/fake VirtViewerFile.

Signed-off-by: Marc-André Lureau 
---
 src/virt-viewer-file.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/virt-viewer-file.c b/src/virt-viewer-file.c
index 9ff2a05..dfc6164 100644
--- a/src/virt-viewer-file.c
+++ b/src/virt-viewer-file.c
@@ -141,11 +141,13 @@ enum  {
 VirtViewerFile*
 virt_viewer_file_new(const gchar* location, GError** error)
 {
-GError* inner_error = NULL;
+VirtViewerFile* self = 
VIRT_VIEWER_FILE(g_object_new(VIRT_VIEWER_TYPE_FILE, NULL));
 
-g_return_val_if_fail (location != NULL, NULL);
+if (!location) {
+return self;
+}
 
-VirtViewerFile* self = 
VIRT_VIEWER_FILE(g_object_new(VIRT_VIEWER_TYPE_FILE, NULL));
+GError* inner_error = NULL;
 GKeyFile* keyfile = self->priv->keyfile;
 
 g_key_file_load_from_file(keyfile, location,
-- 
2.13.1.395.gf7b71de06

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

[virt-tools-list] [PATCH 11/12] virtManager/ui: add rendernode selection

2017-02-21 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 ui/gfxdetails.ui   | 35 +++
 virtManager/addhardware.py |  3 ++-
 virtManager/details.py |  9 +++--
 virtManager/domain.py  |  4 +++-
 virtManager/gfxdetails.py  | 34 +++---
 5 files changed, 78 insertions(+), 7 deletions(-)

diff --git a/ui/gfxdetails.ui b/ui/gfxdetails.ui
index 9e3b6cd3..ca719bb7 100644
--- a/ui/gfxdetails.ui
+++ b/ui/gfxdetails.ui
@@ -425,5 +425,40 @@
 1
   
 
+
+  
+True
+False
+GPU:
+True
+graphics-rendernode
+1
+  
+  
+0
+10
+  
+
+
+  
+True
+False
+start
+False
+True
+
+
+  
+True
+start
+True
+  
+
+  
+  
+1
+10
+  
+
   
 
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 8d6c815a..7645cf97 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -1555,12 +1555,13 @@ class vmmAddHardware(vmmGObjectUI):
 def _validate_page_graphics(self):
 try:
 (gtype, port, tlsport, listen,
- addr, passwd, keymap, gl) = self._gfxdetails.get_values()
+ addr, passwd, keymap, gl, rendernode) = 
self._gfxdetails.get_values()
 
 self._dev = virtinst.VirtualGraphics(self.conn.get_backend())
 self._dev.type = gtype
 self._dev.passwd = passwd
 self._dev.gl = gl
+self._dev.rendernode = rendernode
 
 if not listen or listen == "none":
 self._dev.set_listen_none()
diff --git a/virtManager/details.py b/virtManager/details.py
index 2e6f413c..3e37a12c 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -92,6 +92,7 @@ EDIT_GFX_ADDRESS,
 EDIT_GFX_TLSPORT,
 EDIT_GFX_PORT,
 EDIT_GFX_OPENGL,
+EDIT_GFX_RENDERNODE,
 
 EDIT_VIDEO_MODEL,
 
@@ -106,7 +107,7 @@ EDIT_FS,
 
 EDIT_HOSTDEV_ROMBAR,
 
-) = range(1, 47)
+) = range(1, 48)
 
 
 # Columns in hw list model
@@ -397,6 +398,8 @@ class vmmDetails(vmmGObjectUI):
 lambda *x: self.enable_apply(x, EDIT_GFX_PORT))
 self.gfxdetails.connect("changed-opengl",
 lambda *x: self.enable_apply(x, EDIT_GFX_OPENGL))
+self.gfxdetails.connect("changed-rendernode",
+lambda *x: self.enable_apply(x, EDIT_GFX_RENDERNODE))
 self.gfxdetails.connect("changed-tlsport",
 lambda *x: self.enable_apply(x, EDIT_GFX_TLSPORT))
 self.gfxdetails.connect("changed-listen",
@@ -2156,7 +2159,7 @@ class vmmDetails(vmmGObjectUI):
 
 def config_graphics_apply(self, devobj):
 (gtype, port, tlsport, listen,
- addr, passwd, keymap, gl) = self.gfxdetails.get_values()
+ addr, passwd, keymap, gl, rendernode) = self.gfxdetails.get_values()
 
 kwargs = {}
 
@@ -2174,6 +2177,8 @@ class vmmDetails(vmmGObjectUI):
 kwargs["gl"] = gl
 if self.edited(EDIT_GFX_TLSPORT) or self.edited(EDIT_GFX_LISTEN):
 kwargs["tlsport"] = tlsport
+if self.edited(EDIT_GFX_RENDERNODE):
+kwargs["rendernode"] = rendernode
 if self.edited(EDIT_GFX_TYPE):
 kwargs["gtype"] = gtype
 
diff --git a/virtManager/domain.py b/virtManager/domain.py
index 23585e4d..58580861 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -826,7 +826,7 @@ class vmmDomain(vmmLibvirtObject):
 def define_graphics(self, devobj, do_hotplug,
 listen=_SENTINEL, addr=_SENTINEL, port=_SENTINEL, tlsport=_SENTINEL,
 passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL,
-gl=_SENTINEL):
+gl=_SENTINEL, rendernode=_SENTINEL):
 xmlobj = self._make_xmlobj_to_define()
 editdev = self._lookup_device_to_define(xmlobj, devobj, do_hotplug)
 if not editdev:
@@ -846,6 +846,8 @@ class vmmDomain(vmmLibvirtObject):
 editdev.type = gtype
 if gl != _SENTINEL:
 editdev.gl = gl
+if rendernode != _SENTINEL:
+editdev.rendernode = rendernode
 if listen != _SENTINEL:
 listentype = editdev.get_first_listen_type()
 if listen == 'none':
diff --git a/virtManager/gfxdetails.py b/virtManager/gfxdetails.py
index fa3d9ea6..b96dbd9c 100644
--- a/virtManager/gfxdetails.py
+++ b/virtManager/gfxdetails.py
@@ -37,6 +37,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
 "changed-address": (GObject.SignalFlags.RUN_FIRST, None, []),
 "changed-keymap": (GObject.SignalFlags.RUN_FIRST, None, []),
 "changed-opengl": (GObject.SignalFlags.RUN_FIRST, None, []),
+"changed-rendernode": (GObject.SignalFlags.RUN_FIRST, None, []),
 }
 
 def __init__(self, vm, builder, topwin):
@@ -57,7 +58,8 @@ class vmmGraphicsDetails(vmmGObjectUI):
 "on_graphics_tlsport

[virt-tools-list] [PATCH 06/12] virtManager/ui: add opengl graphics option

2017-02-21 Thread marcandre . lureau
From: Marc-André Lureau 

Add an OpenGL checkbox to the Spice graphics options (only available if
SUPPORT_CONN_SPICE_GL).

Signed-off-by: Marc-André Lureau 
---
 ui/gfxdetails.ui   | 30 ++
 virtManager/addhardware.py |  3 ++-
 virtManager/details.py |  9 +++--
 virtManager/domain.py  |  5 -
 virtManager/gfxdetails.py  | 11 +--
 5 files changed, 52 insertions(+), 6 deletions(-)

diff --git a/ui/gfxdetails.ui b/ui/gfxdetails.ui
index ad84ca99..78e75b74 100644
--- a/ui/gfxdetails.ui
+++ b/ui/gfxdetails.ui
@@ -363,5 +363,35 @@
 0
   
 
+
+  
+True
+False
+1
+Open_GL:
+True
+graphics-opengl
+  
+  
+0
+8
+  
+
+
+  
+True
+True
+False
+True
+
+
+  
+
+  
+  
+1
+8
+  
+
   
 
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index e63ad3d0..15292b0c 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -1555,7 +1555,7 @@ class vmmAddHardware(vmmGObjectUI):
 def _validate_page_graphics(self):
 try:
 (gtype, port,
- tlsport, addr, passwd, keymap) = self._gfxdetails.get_values()
+ tlsport, addr, passwd, keymap, gl) = self._gfxdetails.get_values()
 
 self._dev = virtinst.VirtualGraphics(self.conn.get_backend())
 self._dev.type = gtype
@@ -1563,6 +1563,7 @@ class vmmAddHardware(vmmGObjectUI):
 self._dev.passwd = passwd
 self._dev.listen = addr
 self._dev.tlsPort = tlsport
+self._dev.gl = gl
 if keymap:
 self._dev.keymap = keymap
 except ValueError, e:
diff --git a/virtManager/details.py b/virtManager/details.py
index 0503a444..9899a54f 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -90,6 +90,7 @@ EDIT_GFX_KEYMAP,
 EDIT_GFX_ADDRESS,
 EDIT_GFX_TLSPORT,
 EDIT_GFX_PORT,
+EDIT_GFX_OPENGL,
 
 EDIT_VIDEO_MODEL,
 
@@ -104,7 +105,7 @@ EDIT_FS,
 
 EDIT_HOSTDEV_ROMBAR,
 
-) = range(1, 45)
+) = range(1, 46)
 
 
 # Columns in hw list model
@@ -393,6 +394,8 @@ class vmmDetails(vmmGObjectUI):
 lambda *x: self.enable_apply(x, EDIT_GFX_TYPE))
 self.gfxdetails.connect("changed-port",
 lambda *x: self.enable_apply(x, EDIT_GFX_PORT))
+self.gfxdetails.connect("changed-opengl",
+lambda *x: self.enable_apply(x, EDIT_GFX_OPENGL))
 self.gfxdetails.connect("changed-tlsport",
 lambda *x: self.enable_apply(x, EDIT_GFX_TLSPORT))
 self.gfxdetails.connect("changed-address",
@@ -2150,7 +2153,7 @@ class vmmDetails(vmmGObjectUI):
 
 def config_graphics_apply(self, devobj):
 (gtype, port,
- tlsport, addr, passwd, keymap) = self.gfxdetails.get_values()
+ tlsport, addr, passwd, keymap, gl) = self.gfxdetails.get_values()
 
 kwargs = {}
 
@@ -2162,6 +2165,8 @@ class vmmDetails(vmmGObjectUI):
 kwargs["keymap"] = keymap
 if self.edited(EDIT_GFX_PORT):
 kwargs["port"] = port
+if self.edited(EDIT_GFX_OPENGL):
+kwargs["gl"] = gl
 if self.edited(EDIT_GFX_TLSPORT):
 kwargs["tlsport"] = tlsport
 if self.edited(EDIT_GFX_TYPE):
diff --git a/virtManager/domain.py b/virtManager/domain.py
index 83784f25..420202dc 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -825,7 +825,8 @@ class vmmDomain(vmmLibvirtObject):
 
 def define_graphics(self, devobj, do_hotplug,
 listen=_SENTINEL, port=_SENTINEL, tlsport=_SENTINEL,
-passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL):
+passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL,
+gl=_SENTINEL):
 xmlobj = self._make_xmlobj_to_define()
 editdev = self._lookup_device_to_define(xmlobj, devobj, do_hotplug)
 if not editdev:
@@ -843,6 +844,8 @@ class vmmDomain(vmmLibvirtObject):
 editdev.keymap = keymap
 if gtype != _SENTINEL:
 editdev.type = gtype
+if gl != _SENTINEL:
+editdev.gl = gl
 
 if do_hotplug:
 self.hotplug(device=editdev)
diff --git a/virtManager/gfxdetails.py b/virtManager/gfxdetails.py
index 0ae76c95..f3cd3a9d 100644
--- a/virtManager/gfxdetails.py
+++ b/virtManager/gfxdetails.py
@@ -35,6 +35,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
 "changed-type": (GObject.SignalFlags.RUN_FIRST, None, []),
 "changed-address": (GObject.SignalFlags.RUN_FIRST, None, []),
 "changed-keymap": (GObject.SignalFlags.RUN_FIRST, None, []),
+"changed-opengl": (GObject.SignalFlags.RUN_FIRST, None, []),
 }
 
 def __init__(self, vm, builder, topwin):
@@ -54,6 +55,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
 "on_graphics_tlsport_changed": lambda ignore: 
self.emit("changed-tlspor

[virt-tools-list] [PATCH 09/12] virtManager/ui: add listen type option

2017-02-21 Thread marcandre . lureau
From: Marc-André Lureau 

Similarly to virt-install --listen=none, add a combobox to select
the listen type: "address" or "none" for now, as suggested by Pavel
Hrdina.

Signed-off-by: Marc-André Lureau 
---
 ui/gfxdetails.ui   | 64 ++
 virtManager/addhardware.py | 16 
 virtManager/details.py | 19 +-
 virtManager/domain.py  | 12 ++---
 virtManager/gfxdetails.py  | 38 ++-
 virtinst/devicegraphics.py |  5 
 6 files changed, 117 insertions(+), 37 deletions(-)

diff --git a/ui/gfxdetails.ui b/ui/gfxdetails.ui
index 78e75b74..9e3b6cd3 100644
--- a/ui/gfxdetails.ui
+++ b/ui/gfxdetails.ui
@@ -67,7 +67,7 @@
   
   
 1
-4
+5
   
 
 
@@ -95,7 +95,7 @@
   
   
 0
-1
+2
   
 
 
@@ -109,7 +109,7 @@
   
   
 0
-4
+5
   
 
 
@@ -123,7 +123,7 @@
   
   
 0
-2
+3
   
 
 
@@ -145,7 +145,7 @@
   
   
 0
-3
+4
   
 
 
@@ -193,7 +193,7 @@
   
   
 1
-3
+4
   
 
 
@@ -207,7 +207,7 @@
   
   
 0
-5
+6
   
 
 
@@ -228,7 +228,7 @@
   
   
 1
-5
+6
   
 
 
@@ -276,7 +276,7 @@
   
   
 1
-2
+3
   
 
 
@@ -288,7 +288,7 @@
   
   
 0
-6
+7
   
 
 
@@ -300,7 +300,7 @@
   
   
 0
-7
+8
   
 
 
@@ -312,7 +312,7 @@
   
   
 1
-6
+7
   
 
 
@@ -324,7 +324,7 @@
   
   
 1
-7
+8
   
 
 
@@ -342,7 +342,7 @@
   
   
 1
-1
+2
   
 
 
@@ -374,7 +374,7 @@
   
   
 0
-8
+9
   
 
 
@@ -390,7 +390,39 @@
   
   
 1
-8
+9
+  
+
+
+  
+True
+False
+L_isten type:
+True
+graphics-listen-type
+1
+  
+  
+0
+1
+  
+
+
+  
+True
+False
+start
+True
+
+
+  
+True
+  
+
+  
+  
+1
+1
   
 
   
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 15292b0c..8d6c815a 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -1554,16 +1554,22 @@ class vmmAddHardware(vmmGObjectUI):
 
 def _validate_page_graphics(self):
 try:
-(gtype, port,
- tlsport, addr, passwd, keymap, gl) = self._gfxdetails.get_values()
+(gtype, port, tlsport, listen,
+ addr, passwd, keymap, gl) = self._gfxdetails.get_values()
 
 self._dev = virtinst.VirtualGraphics(self.conn.get_backend())
 self._dev.type = gtype
-self._dev.port = port
 self._dev.passwd = passwd
-self._dev.listen = addr
-self._dev.tlsPort = tlsport
 self._dev.gl = gl
+
+if not listen or listen == "none":
+self._dev.set_listen_none()
+elif listen == "address":
+self._dev.listen = addr
+self._dev.port = port
+self._dev.tlsPort = tlsport
+else:
+raise ValueError(_("invalid listen type"))
 if keymap:
 self._dev.keymap = keymap
 except ValueError, e:
diff --git a/virtManager/details.py b/virtManager/details.py
index 9899a54f..2e6f413c 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -87,6 +87,7 @@ EDIT_NET_MAC,
 EDIT_GFX_PASSWD,
 EDIT_GFX_TYPE,
 EDIT_GFX_KEYMAP,
+EDIT_GFX_LISTEN,
 EDIT_GFX_ADDRESS,
 EDIT_GFX_TLSPORT,
 EDIT_GFX_PORT,
@@ -105,7 +106,7 @@ EDIT_FS,
 
 EDIT_HOSTDEV_ROMBAR,
 
-) = range(1, 46)
+) = range(1, 47)
 
 
 # Columns in hw list model
@@ -398,6 +399,8 @@ class vmmDetails(vmmGObjectUI):
 lambda *x: self.enable_apply(x, EDIT_GFX_OPENGL))
 self.gfxdetails.connect("changed-tlsport",
 lambda *x: self.enable_apply(x, EDIT_GFX_TLSPORT))
+self.gfxdetails.connect("changed-listen",
+lambda *x: self.enable_apply(x, EDIT_GFX_LISTEN))
 self.gfxdetails.connect("changed-address",
 lambda *x: self.enable_apply(x, EDIT_GFX_ADDRESS))
 self.gfxdetails.connect("changed-keymap",
@@ -2152,22 +2155,24 @@ class vmmDetails(vmmGObjectUI):
   devobj=devobj)
 
 def config_graphics_apply(self, devobj):
-(gtype, port,
- tlsport, addr, passwd, keymap, gl) = self.gfxdetails.get_values()
+(gtype, port, tlsport, listen,
+ addr, passwd, k

[virt-tools-list] [PATCH 12/12] virtManager/ui: add 3d acceleration checkbox to virtio video

2017-02-21 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 ui/details.ui  | 203 +
 virtManager/details.py |  25 +-
 virtManager/domain.py  |   6 +-
 3 files changed, 132 insertions(+), 102 deletions(-)

diff --git a/ui/details.ui b/ui/details.ui
index c85e0e4b..d22e2624 100644
--- a/ui/details.ui
+++ b/ui/details.ui
@@ -4664,114 +4664,121 @@ if you know what you are 
doing.
 0
 none
 
-  
+  
 True
 False
-3
-12
+12
+3
+6
+6
 
-  
+  
 True
 False
-2
-8
-4
-
-  
-True
-False
-label
-True
-0
-  
-  
-1
-2
-2
-3
-GTK_FILL
-
-  
-
-
-  
-True
-False
-label
-True
-0
-  
-  
-1
-2
-1
-2
-GTK_FILL
-
-  
-
-
-  
-True
-False
-RAM:
-1
-  
-  
-1
-2
-GTK_FILL
-
-  
-
-
-  
-True
-False
-M_odel:
-True
-combobox-entry13
-1
+M_odel:
+True
+combobox-entry13
+1
+  
+  
+0
+0
+  
+
+
+  
+True
+False
+True
+
+
+  
+True
   
-  
-GTK_FILL
-
-   

[virt-tools-list] [PATCH 03/12] nodedev: add DevNode children and helper

2017-02-21 Thread marcandre . lureau
From: Marc-André Lureau 

 have been proposed for libvirt 3.1, it provides device /dev/
path when available.

The get_devnode() helper will return the by-path/ path preferably, as
they should be stable.

Signed-off-by: Marc-André Lureau 
---
 tests/nodedev.py |  3 +++
 tests/testdriver.xml |  1 +
 virtinst/nodedev.py  | 20 +++-
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/tests/nodedev.py b/tests/nodedev.py
index 1a69c823..0d214afe 100644
--- a/tests/nodedev.py
+++ b/tests/nodedev.py
@@ -181,6 +181,9 @@ class TestNodeDev(unittest.TestCase):
 devname = "storage_serial_SATA_WDC_WD1600AAJS__WD_WCAP95119685"
 vals = {"name": "storage_serial_SATA_WDC_WD1600AAJS__WD_WCAP95119685",
 "parent": "pci_8086_27c0_scsi_host_scsi_device_lun0",
+"devnodes": [
+{"path": "/dev/sda", "node_type": "dev"}
+],
 "device_type": NodeDevice.CAPABILITY_TYPE_STORAGE,
 "block": "/dev/sda", "bus": "scsi", "drive_type": "disk",
 "model": "WDC WD1600AAJS-2", "vendor": "ATA",
diff --git a/tests/testdriver.xml b/tests/testdriver.xml
index c5cdac9a..daf74f26 100644
--- a/tests/testdriver.xml
+++ b/tests/testdriver.xml
@@ -2974,6 +2974,7 @@ ba
 
   storage_serial_SATA_WDC_WD1600AAJS__WD_WCAP95119685
   pci_8086_27c0_scsi_host_scsi_device_lun0
+  /dev/sda
   
 /dev/sda
 scsi
diff --git a/virtinst/nodedev.py b/virtinst/nodedev.py
index 6147d70d..07ffe01e 100644
--- a/virtinst/nodedev.py
+++ b/virtinst/nodedev.py
@@ -18,8 +18,9 @@
 # MA 02110-1301 USA.
 
 import logging
+import os
 
-from .xmlbuilder import XMLBuilder, XMLProperty
+from .xmlbuilder import XMLBuilder, XMLProperty, XMLChildProperty
 
 
 def _compare_int(nodedev_val, hostdev_val):
@@ -37,6 +38,13 @@ def _compare_int(nodedev_val, hostdev_val):
 return (nodedev_val == hostdev_val or hostdev_val == -1)
 
 
+class DevNode(XMLBuilder):
+_XML_ROOT_NAME = "devnode"
+
+node_type = XMLProperty("./@type")
+path = XMLProperty(".")
+
+
 class NodeDevice(XMLBuilder):
 CAPABILITY_TYPE_SYSTEM = "system"
 CAPABILITY_TYPE_NET = "net"
@@ -104,6 +112,16 @@ class NodeDevice(XMLBuilder):
 name = XMLProperty("./name")
 parent = XMLProperty("./parent")
 device_type = XMLProperty("./capability/@type")
+devnodes = XMLChildProperty(DevNode)
+
+def get_devnode(self, parent="by-path"):
+for d in self.devnodes:
+paths = d.path.split(os.sep)
+if len(paths) > 2 and paths[-2] == parent:
+return d
+if len(self.devnodes) > 0:
+return self.devnodes[0]
+return None
 
 def pretty_name(self):
 """
-- 
2.11.0.295.gd7dffce1c.dirty

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

[virt-tools-list] [PATCH 05/12] virtinst: bump libvirt requirements for GL

2017-02-21 Thread marcandre . lureau
From: Marc-André Lureau 

libvirt 3.1.0 improves spice/GL support with rendernode options, file
cgroup/namespace rights etc, that are required for qemu:///system to
work without additional tweaking.

Signed-off-by: Marc-André Lureau 
---
 virtinst/support.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virtinst/support.py b/virtinst/support.py
index 0a57fb87..5a62cc8b 100644
--- a/virtinst/support.py
+++ b/virtinst/support.py
@@ -311,7 +311,7 @@ SUPPORT_CONN_VCPU_PLACEMENT = _make(
 SUPPORT_CONN_MEM_STATS_PERIOD = _make(
 function="virDomain.setMemoryStatsPeriod",
 version="1.1.1", hv_version={"qemu": 0})
-SUPPORT_CONN_SPICE_GL = _make(version="1.3.3",
+SUPPORT_CONN_SPICE_GL = _make(version="3.1.0",
 hv_version={"qemu": "2.6.0", "test": 0})
 SUPPORT_CONN_VIDEO_VIRTIO_ACCEL3D = _make(version="1.3.0",
 hv_version={"qemu": "2.5.0", "test": 0})
-- 
2.11.0.295.gd7dffce1c.dirty

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

[virt-tools-list] [PATCH 04/12] virtinst: add DRMDevice

2017-02-21 Thread marcandre . lureau
From: Marc-André Lureau 

drm capability has been proposed for libvirt 3.1, it provide Direct
Rendering Manager (DRM) devices.

Signed-off-by: Marc-André Lureau 
---
 tests/nodedev.py | 15 +++
 tests/testdriver.xml | 27 +++
 virtinst/nodedev.py  | 12 
 3 files changed, 54 insertions(+)

diff --git a/tests/nodedev.py b/tests/nodedev.py
index 0d214afe..15e54b1d 100644
--- a/tests/nodedev.py
+++ b/tests/nodedev.py
@@ -236,6 +236,21 @@ class TestNodeDev(unittest.TestCase):
 "type": "disk"}
 self._testCompare(devname, vals)
 
+def testDRMDevice(self):
+devname = "drm_renderD129"
+vals = {"name": "drm_renderD129",
+"parent": "pci__00_02_0",
+"devnodes": [
+{"path": "/dev/dri/renderD129", "node_type": "dev"},
+{"path": "/dev/dri/by-path/pci-:00:02.0-render", 
"node_type": "link"},
+{"path": "/dev/dri/by-id/foo-render", "node_type": "link"}
+],
+"device_type": NodeDevice.CAPABILITY_TYPE_DRM,
+"drm_type": "render"}
+dev = self._testCompare(devname, vals)
+self.assertEqual(dev.drm_pretty_name(conn),
+ ":00:02:0 Intel Corporation HD Graphics 530 
(render)")
+
 def testUnknownDevice(self):
 vals = {"name": "foodevice", "parent": "computer",
 "device_type": "frobtype"}
diff --git a/tests/testdriver.xml b/tests/testdriver.xml
index daf74f26..ff1f97a7 100644
--- a/tests/testdriver.xml
+++ b/tests/testdriver.xml
@@ -3469,7 +3469,34 @@ ba
 
 
 
+
+  pci__00_02_0
+  /sys/devices/pci:00/:00:02.0
+  computer
+  
+i915
+  
+  
+0
+0
+2
+0
+HD Graphics 530
+Intel Corporation
+  
+
 
+
+  drm_renderD129
+  /sys/devices/pci:00/:00:02.0/drm/renderD129
+  /dev/dri/renderD129
+  /dev/dri/by-path/pci-:00:02.0-render
+  /dev/dri/by-id/foo-render
+  pci__00_02_0
+  
+render
+  
+
 
 
 
diff --git a/virtinst/nodedev.py b/virtinst/nodedev.py
index 07ffe01e..f27cfbb2 100644
--- a/virtinst/nodedev.py
+++ b/virtinst/nodedev.py
@@ -54,6 +54,7 @@ class NodeDevice(XMLBuilder):
 CAPABILITY_TYPE_STORAGE = "storage"
 CAPABILITY_TYPE_SCSIBUS = "scsi_host"
 CAPABILITY_TYPE_SCSIDEV = "scsi"
+CAPABILITY_TYPE_DRM = "drm"
 
 @staticmethod
 def lookupNodedevFromString(conn, idstring):
@@ -328,6 +329,15 @@ class SCSIBus(NodeDevice):
 wwpn = XMLProperty("./capability/capability[@type='fc_host']/wwpn")
 
 
+class DRMDevice(NodeDevice):
+drm_type = XMLProperty("./capability/type")
+
+def drm_pretty_name(self, conn):
+parent = NodeDevice.lookupNodedevFromString(conn, self.parent)
+
+return "%s (%s)" % (parent.pretty_name(), self.drm_type)
+
+
 def _AddressStringToHostdev(conn, addrstr):
 from .devicehostdev import VirtualHostDevice
 hostdev = VirtualHostDevice(conn)
@@ -410,5 +420,7 @@ def _typeToDeviceClass(t):
 return SCSIBus
 elif t == NodeDevice.CAPABILITY_TYPE_SCSIDEV:
 return SCSIDevice
+elif t == NodeDevice.CAPABILITY_TYPE_DRM:
+return DRMDevice
 else:
 return NodeDevice
-- 
2.11.0.295.gd7dffce1c.dirty

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

[virt-tools-list] [PATCH 02/12] tests/nodedev: make compare recursive

2017-02-21 Thread marcandre . lureau
From: Marc-André Lureau 

This will allow to have nested dict for childrens. See the following
commits.

Signed-off-by: Marc-André Lureau 
---
 tests/nodedev.py | 22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/tests/nodedev.py b/tests/nodedev.py
index 5d9fdec8..1a69c823 100644
--- a/tests/nodedev.py
+++ b/tests/nodedev.py
@@ -68,18 +68,26 @@ class TestNodeDev(unittest.TestCase):
 return NodeDevice.parse(conn, xml)
 
 def _testCompare(self, devname, vals, devxml=None):
+def _compare(dev, vals, root=""):
+for attr in vals.keys():
+expect = vals[attr]
+actual = getattr(dev, attr)
+if isinstance(expect, list):
+for adev, exp in zip(actual, expect):
+_compare(adev, exp, attr + ".")
+else:
+if expect != actual:
+raise AssertionError("devname=%s attribute=%s%s did 
not match:\n"
+"expect=%s\nactual=%s" % (devname, root, attr, 
expect, actual))
+self.assertEqual(vals[attr], getattr(dev, attr))
+
 if devxml:
 dev = NodeDevice.parse(conn, devxml)
 else:
 dev = self._nodeDevFromName(devname)
 
-for attr in vals.keys():
-expect = vals[attr]
-actual = getattr(dev, attr)
-if expect != actual:
-raise AssertionError("devname=%s attribute=%s did not match:\n"
-"expect=%s\nactual=%s" % (devname, attr, expect, actual))
-self.assertEqual(vals[attr], getattr(dev, attr))
+_compare(dev, vals)
+return dev
 
 def _testNode2DeviceCompare(self, nodename, devfile, nodedev=None):
 devfile = os.path.join("tests/nodedev-xml/devxml", devfile)
-- 
2.11.0.295.gd7dffce1c.dirty

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

[virt-tools-list] [PATCH 10/12] virtinst/cli: add spice rendernode argument

2017-02-21 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 man/virt-install.pod | 4 
 tests/cli-test-xml/compare/virt-install-many-devices.xml | 5 +
 tests/clitest.py | 1 +
 tests/xmlparse-xml/change-graphics-out.xml   | 2 +-
 tests/xmlparse.py| 1 +
 virtinst/cli.py  | 7 +++
 virtinst/devicegraphics.py   | 1 +
 virtinst/support.py  | 2 ++
 8 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/man/virt-install.pod b/man/virt-install.pod
index 27524f88..7f3b52c5 100644
--- a/man/virt-install.pod
+++ b/man/virt-install.pod
@@ -1010,6 +1010,10 @@ is used by 'vnc' and 'spice'
 Whether to use OpenGl accelerated rendering. Value is 'yes' or 'no'. This is
 used by 'spice'.
 
+=item B
+
+DRM render node path to use. This is used when 'gl' is enabled.
+
 =back
 
 Use --graphics=? to see a list of all available sub options. Complete details 
at L
diff --git a/tests/cli-test-xml/compare/virt-install-many-devices.xml 
b/tests/cli-test-xml/compare/virt-install-many-devices.xml
index 45010e0e..345dd270 100644
--- a/tests/cli-test-xml/compare/virt-install-many-devices.xml
+++ b/tests/cli-test-xml/compare/virt-install-many-devices.xml
@@ -246,6 +246,11 @@
   
   
 
+
+  
+  
+  
+
 
   
   
diff --git a/tests/clitest.py b/tests/clitest.py
index 7b4e259d..c70d0d97 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -485,6 +485,7 @@ c.add_compare(""" \
 --graphics 
spice,image_compression=foo,streaming_mode=bar,clipboard_copypaste=yes,mouse_mode=client,filetransfer_enable=on
 \
 --graphics spice,gl=yes,listen=socket \
 --graphics spice,gl=yes,listen=none \
+--graphics spice,gl=yes,listen=none,rendernode=/dev/dri/foo \
 \
 --controller usb,model=ich9-ehci1,address=0:0:4.7,index=0 \
 --controller usb,model=ich9-uhci1,address=0:0:4.0,index=0,master=0 \
diff --git a/tests/xmlparse-xml/change-graphics-out.xml 
b/tests/xmlparse-xml/change-graphics-out.xml
index 0c084587..72cc136e 100644
--- a/tests/xmlparse-xml/change-graphics-out.xml
+++ b/tests/xmlparse-xml/change-graphics-out.xml
@@ -39,7 +39,7 @@
   
   
   
-  
+  
   
   
   
diff --git a/tests/xmlparse.py b/tests/xmlparse.py
index 9697fbf8..5c8ab0be 100644
--- a/tests/xmlparse.py
+++ b/tests/xmlparse.py
@@ -651,6 +651,7 @@ class XMLParseTest(unittest.TestCase):
 check("mouse_mode", None, "client")
 check("filetransfer_enable", None, False)
 check("gl", None, True)
+check("rendernode", None, "/dev/dri/foo")
 
 self._alter_compare(guest.get_xml_config(), outfile)
 
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 94ba5cbb..423d8723 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -2183,6 +2183,12 @@ class ParserGraphics(VirtCLIParser):
 elif not inst.conn.check_support(
 inst.conn.SUPPORT_CONN_SPICE_GL):
 logging.warn("qemu/libvirt version may not support spice GL")
+if inst.conn.is_qemu() and inst.rendernode:
+if inst.type != "spice":
+logging.warn("graphics type=%s does not support rendernode", 
inst.type)
+elif not inst.conn.check_support(
+inst.conn.SUPPORT_CONN_SPICE_RENDERNODE):
+logging.warn("qemu/libvirt version may not support rendernode")
 
 return ret
 
@@ -2206,6 +2212,7 @@ ParserGraphics.add_arg("mouse_mode", "mouse_mode")
 ParserGraphics.add_arg("filetransfer_enable", "filetransfer_enable",
 is_onoff=True)
 ParserGraphics.add_arg("gl", "gl", is_onoff=True)
+ParserGraphics.add_arg("rendernode", "rendernode")
 
 
 
diff --git a/virtinst/devicegraphics.py b/virtinst/devicegraphics.py
index 3741e9d7..ac69df5e 100644
--- a/virtinst/devicegraphics.py
+++ b/virtinst/devicegraphics.py
@@ -249,5 +249,6 @@ class VirtualGraphics(VirtualDevice):
 mouse_mode = XMLProperty("./mouse/@mode")
 filetransfer_enable = XMLProperty("./filetransfer/@enable", is_yesno=True)
 gl = XMLProperty("./gl/@enable", is_yesno=True)
+rendernode = XMLProperty("./gl/@rendernode")
 
 VirtualGraphics.register_type()
diff --git a/virtinst/support.py b/virtinst/support.py
index 5a62cc8b..a35dec7a 100644
--- a/virtinst/support.py
+++ b/virtinst/support.py
@@ -313,6 +313,8 @@ SUPPORT_CONN_MEM_STATS_PERIOD = _make(
 version="1.1.1", hv_version={"qemu": 0})
 SUPPORT_CONN_SPICE_GL = _make(version="3.1.0",
 hv_version={"qemu": "2.6.0", "test": 0})
+SUPPORT_CONN_SPICE_RENDERNODE = _make(version="3.1.0",
+hv_version={"qemu": "2.9.0", "test": 0})
 SUPPORT_CONN_VIDEO_VIRTIO_ACCEL3D = _make(version="1.3.0",
 hv_version={"qemu": "2.5.0", "test": 0})
 SUPPORT_CONN_GRAPHICS_LIS

[virt-tools-list] [PATCH 08/12] virtinst: clean @listen attribute on listen=none

2017-02-21 Thread marcandre . lureau
From: Marc-André Lureau 

Clear the obsolete @listen attribute when setting listen to none.

Signed-off-by: Marc-André Lureau 
---
 virtinst/devicegraphics.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/virtinst/devicegraphics.py b/virtinst/devicegraphics.py
index 277a020b..634b6df0 100644
--- a/virtinst/devicegraphics.py
+++ b/virtinst/devicegraphics.py
@@ -226,6 +226,7 @@ class VirtualGraphics(VirtualDevice):
 
 def set_listen_none(self):
 self.remove_all_listens()
+self.listen = None
 self.port = None
 self.tlsPort = None
 self.autoport = None
-- 
2.11.0.295.gd7dffce1c.dirty

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

[virt-tools-list] [PATCH 07/12] virtinst: remove unnecessary autoport when listen=none

2017-02-21 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 tests/cli-test-xml/compare/virt-install-many-devices.xml  | 2 +-
 tests/cli-test-xml/compare/virt-xml-edit-graphics-listen-none.xml | 2 +-
 tests/cli-test-xml/compare/virt-xml-edit-graphics-spice-gl.xml| 2 +-
 virtinst/devicegraphics.py| 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/cli-test-xml/compare/virt-install-many-devices.xml 
b/tests/cli-test-xml/compare/virt-install-many-devices.xml
index baa21141..45010e0e 100644
--- a/tests/cli-test-xml/compare/virt-install-many-devices.xml
+++ b/tests/cli-test-xml/compare/virt-install-many-devices.xml
@@ -241,7 +241,7 @@
   
   
 
-
+
   
   
   
diff --git a/tests/cli-test-xml/compare/virt-xml-edit-graphics-listen-none.xml 
b/tests/cli-test-xml/compare/virt-xml-edit-graphics-listen-none.xml
index c86e45b4..539fcb39 100644
--- a/tests/cli-test-xml/compare/virt-xml-edit-graphics-listen-none.xml
+++ b/tests/cli-test-xml/compare/virt-xml-edit-graphics-listen-none.xml
@@ -3,7 +3,7 @@
  
 -
 -  
-+
++
 +  
  
  
diff --git a/tests/cli-test-xml/compare/virt-xml-edit-graphics-spice-gl.xml 
b/tests/cli-test-xml/compare/virt-xml-edit-graphics-spice-gl.xml
index 1fef55fb..b748ecb7 100644
--- a/tests/cli-test-xml/compare/virt-xml-edit-graphics-spice-gl.xml
+++ b/tests/cli-test-xml/compare/virt-xml-edit-graphics-spice-gl.xml
@@ -3,7 +3,7 @@
  
 -
 -  
-+
++
 +  
 +  
  
diff --git a/virtinst/devicegraphics.py b/virtinst/devicegraphics.py
index 07b554e8..277a020b 100644
--- a/virtinst/devicegraphics.py
+++ b/virtinst/devicegraphics.py
@@ -228,7 +228,7 @@ class VirtualGraphics(VirtualDevice):
 self.remove_all_listens()
 self.port = None
 self.tlsPort = None
-self.autoport = False
+self.autoport = None
 self.socket = None
 
 if self.conn.check_support(
-- 
2.11.0.295.gd7dffce1c.dirty

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

[virt-tools-list] [PATCH 01/12] xmlbuilder: add a __repr__ for XMLBuilder object

2017-02-21 Thread marcandre . lureau
From: Marc-André Lureau 

To help with debugging.

Signed-off-by: Marc-André Lureau 
---
 virtinst/xmlbuilder.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/virtinst/xmlbuilder.py b/virtinst/xmlbuilder.py
index 5183b323..7b041683 100644
--- a/virtinst/xmlbuilder.py
+++ b/virtinst/xmlbuilder.py
@@ -1168,3 +1168,6 @@ class XMLBuilder(object):
 elif key in childprops:
 for obj in util.listify(getattr(self, key)):
 obj._add_parse_bits(node)
+
+def __repr__(self):
+return "" % (self._XML_ROOT_NAME, id(self))
-- 
2.11.0.295.gd7dffce1c.dirty

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

[virt-tools-list] [PATCH 00/12] virt-manager: improve spice/virgl support

2017-02-21 Thread marcandre . lureau
From: Marc-André Lureau 

Hi

Now that upcoming libvirt and qemu releases will support running virgl
with qemu:///system, mostly thanks to rendernode selection and file
namespace, add some support to configure a VM with spice+virgl
locally.

- bump requirement for GL option, since otherwise it is harder to configure
- add rendernode selection/configuration
- add 'none' listen type
- add 3d acceleration option to virtio gpu device

Marc-André Lureau (12):
  xmlbuilder: add a __repr__ for XMLBuilder object
  tests/nodedev: make compare recursive
  nodedev: add DevNode children and helper
  virtinst: add DRMDevice
  virtinst: bump libvirt requirements for GL
  virtManager/ui: add opengl graphics option
  virtinst: remove unnecessary autoport when listen=none
  virtinst: clean @listen attribute on listen=none
  virtManager/ui: add listen type option
  virtinst/cli: add spice rendernode argument
  virtManager/ui: add rendernode selection
  virtManager/ui: add 3d acceleration checkbox to virtio video

 man/virt-install.pod   |   4 +
 .../compare/virt-install-many-devices.xml  |   7 +-
 .../compare/virt-xml-edit-graphics-listen-none.xml |   2 +-
 .../compare/virt-xml-edit-graphics-spice-gl.xml|   2 +-
 tests/clitest.py   |   1 +
 tests/nodedev.py   |  40 +++-
 tests/testdriver.xml   |  28 +++
 tests/xmlparse-xml/change-graphics-out.xml |   2 +-
 tests/xmlparse.py  |   1 +
 ui/details.ui  | 203 +++--
 ui/gfxdetails.ui   | 125 +++--
 virtManager/addhardware.py |  18 +-
 virtManager/details.py |  52 +-
 virtManager/domain.py  |  25 ++-
 virtManager/gfxdetails.py  |  75 +++-
 virtinst/cli.py|   7 +
 virtinst/devicegraphics.py |   9 +-
 virtinst/nodedev.py|  32 +++-
 virtinst/support.py|   4 +-
 virtinst/xmlbuilder.py |   3 +
 20 files changed, 488 insertions(+), 152 deletions(-)

-- 
2.11.0.295.gd7dffce1c.dirty

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

[virt-tools-list] [PATCH v4 2/2] gfxdetails: add listen type option

2016-11-28 Thread marcandre . lureau
From: Marc-André Lureau 

Similarly to virt-install --listen=none, add a combobox to select
the listen type: "address" or "none" for now, as suggested by Pavel
Hrdina.

Signed-off-by: Marc-André Lureau 
---
 ui/gfxdetails.ui   | 64 ++
 virtManager/addhardware.py | 14 ++
 virtManager/details.py |  7 ++---
 virtManager/domain.py  | 11 +---
 virtManager/gfxdetails.py  | 38 ++-
 virtinst/devicegraphics.py | 16 +++-
 6 files changed, 115 insertions(+), 35 deletions(-)

diff --git a/ui/gfxdetails.ui b/ui/gfxdetails.ui
index 5a4ddf8..3e82f84 100644
--- a/ui/gfxdetails.ui
+++ b/ui/gfxdetails.ui
@@ -67,7 +67,7 @@
   
   
 1
-4
+5
   
 
 
@@ -95,7 +95,7 @@
   
   
 0
-1
+2
   
 
 
@@ -109,7 +109,7 @@
   
   
 0
-4
+5
   
 
 
@@ -123,7 +123,7 @@
   
   
 0
-2
+3
   
 
 
@@ -145,7 +145,7 @@
   
   
 0
-3
+4
   
 
 
@@ -193,7 +193,7 @@
   
   
 1
-3
+4
   
 
 
@@ -207,7 +207,7 @@
   
   
 0
-5
+6
   
 
 
@@ -228,7 +228,7 @@
   
   
 1
-5
+6
   
 
 
@@ -276,7 +276,7 @@
   
   
 1
-2
+3
   
 
 
@@ -288,7 +288,7 @@
   
   
 0
-6
+7
   
 
 
@@ -300,7 +300,7 @@
   
   
 0
-7
+8
   
 
 
@@ -312,7 +312,7 @@
   
   
 1
-6
+7
   
 
 
@@ -324,7 +324,7 @@
   
   
 1
-7
+8
   
 
 
@@ -342,7 +342,7 @@
   
   
 1
-1
+2
   
 
 
@@ -373,7 +373,7 @@
   
   
 0
-8
+9
   
 
 
@@ -389,7 +389,39 @@
   
   
 1
-8
+9
+  
+
+
+  
+True
+False
+L_isten type:
+True
+graphics-listen-type
+1
+  
+  
+0
+1
+  
+
+
+  
+True
+False
+start
+True
+
+
+  
+True
+  
+
+  
+  
+1
+1
   
 
   
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 7a3c8f2..3f868aa 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -1541,16 +1541,20 @@ class vmmAddHardware(vmmGObjectUI):
 
 def _validate_page_graphics(self):
 try:
-(gtype, port,
- tlsport, addr, passwd, keymap, gl) = self._gfxdetails.get_values()
+(gtype, port, tlsport, listen,
+ addr, passwd, keymap, gl) = self._gfxdetails.get_values()
 
 self._dev = virtinst.VirtualGraphics(self.conn.get_backend())
 self._dev.type = gtype
-self._dev.port = port
 self._dev.passwd = passwd
-self._dev.listen = addr
-self._dev.tlsPort = tlsport
 self._dev.gl = gl
+
+if not listen:
+self._dev.set_listen_none()
+else:
+self._dev.listen = addr
+self._dev.port = port
+self._dev.tlsPort = tlsport
 if keymap:
 self._dev.keymap = keymap
 except ValueError, e:
diff --git a/virtManager/details.py b/virtManager/details.py
index d803d52..d4e6629 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -2135,15 +2135,16 @@ class vmmDetails(vmmGObjectUI):
   devobj=devobj)
 
 def config_graphics_apply(self, devobj):
-(gtype, port,
- tlsport, addr, passwd, keymap, gl) = self.gfxdetails.get_values()
+(gtype, port, tlsport, listen,
+ addr, passwd, keymap, gl) = self.gfxdetails.get_values()
 
 kwargs = {}
 
 if self.edited(EDIT_GFX_PASSWD):
 kwargs["passwd"] = passwd
 if self.edited(EDIT_GFX_ADDRESS):
-kwargs["listen"] = addr
+kwargs["listen"] = listen
+kwargs["addr"] = addr
 if self.edited(EDIT_GFX_KEYMAP):
 kwargs["keymap"] = keymap
 if self.edited(EDIT_GFX_PORT):
diff --git a/virtManager/domain.py b/virtManager/domain.py
index 6e742b9..f5159d6 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -824,7 +824,7 @@ class vmmDomain(vmmLibvirtObject):
 self._redefine_xmlobj(xmlobj)
 
 def define_graphics(self, devobj, do_hotplug,
-listen=_SENTINEL, port=_SENTINEL, tlsport=_SENTINEL,
+listen=_SENTINEL, addr=_SENTINEL, port=_SENTINEL, tlsport=_SENTINEL,
 passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL,

[virt-tools-list] [PATCH v4 1/2] virt-manager: add opengl graphics option

2016-11-28 Thread marcandre . lureau
From: Marc-André Lureau 

Add an OpenGL checkbox to the Spice graphics options (only available if
SUPPORT_CONN_SPICE_GL).

Signed-off-by: Marc-André Lureau 
---
 ui/gfxdetails.ui   | 29 +
 virtManager/addhardware.py |  3 ++-
 virtManager/details.py |  9 +++--
 virtManager/domain.py  |  5 -
 virtManager/gfxdetails.py  | 11 +--
 5 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/ui/gfxdetails.ui b/ui/gfxdetails.ui
index ad84ca9..5a4ddf8 100644
--- a/ui/gfxdetails.ui
+++ b/ui/gfxdetails.ui
@@ -363,5 +363,34 @@
 0
   
 
+
+  
+True
+False
+Open_GL
+True
+graphics-opengl
+  
+  
+0
+8
+  
+
+
+  
+True
+True
+False
+True
+
+
+  
+
+  
+  
+1
+8
+  
+
   
 
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index aab9095..7a3c8f2 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -1542,7 +1542,7 @@ class vmmAddHardware(vmmGObjectUI):
 def _validate_page_graphics(self):
 try:
 (gtype, port,
- tlsport, addr, passwd, keymap) = self._gfxdetails.get_values()
+ tlsport, addr, passwd, keymap, gl) = self._gfxdetails.get_values()
 
 self._dev = virtinst.VirtualGraphics(self.conn.get_backend())
 self._dev.type = gtype
@@ -1550,6 +1550,7 @@ class vmmAddHardware(vmmGObjectUI):
 self._dev.passwd = passwd
 self._dev.listen = addr
 self._dev.tlsPort = tlsport
+self._dev.gl = gl
 if keymap:
 self._dev.keymap = keymap
 except ValueError, e:
diff --git a/virtManager/details.py b/virtManager/details.py
index b2f451d..d803d52 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -90,6 +90,7 @@ EDIT_GFX_KEYMAP,
 EDIT_GFX_ADDRESS,
 EDIT_GFX_TLSPORT,
 EDIT_GFX_PORT,
+EDIT_GFX_OPENGL,
 
 EDIT_VIDEO_MODEL,
 
@@ -104,7 +105,7 @@ EDIT_FS,
 
 EDIT_HOSTDEV_ROMBAR,
 
-) = range(1, 45)
+) = range(1, 46)
 
 
 # Columns in hw list model
@@ -376,6 +377,8 @@ class vmmDetails(vmmGObjectUI):
 lambda *x: self.enable_apply(x, EDIT_GFX_TYPE))
 self.gfxdetails.connect("changed-port",
 lambda *x: self.enable_apply(x, EDIT_GFX_PORT))
+self.gfxdetails.connect("changed-opengl",
+lambda *x: self.enable_apply(x, EDIT_GFX_OPENGL))
 self.gfxdetails.connect("changed-tlsport",
 lambda *x: self.enable_apply(x, EDIT_GFX_TLSPORT))
 self.gfxdetails.connect("changed-address",
@@ -2133,7 +2136,7 @@ class vmmDetails(vmmGObjectUI):
 
 def config_graphics_apply(self, devobj):
 (gtype, port,
- tlsport, addr, passwd, keymap) = self.gfxdetails.get_values()
+ tlsport, addr, passwd, keymap, gl) = self.gfxdetails.get_values()
 
 kwargs = {}
 
@@ -2145,6 +2148,8 @@ class vmmDetails(vmmGObjectUI):
 kwargs["keymap"] = keymap
 if self.edited(EDIT_GFX_PORT):
 kwargs["port"] = port
+if self.edited(EDIT_GFX_OPENGL):
+kwargs["gl"] = gl
 if self.edited(EDIT_GFX_TLSPORT):
 kwargs["tlsport"] = tlsport
 if self.edited(EDIT_GFX_TYPE):
diff --git a/virtManager/domain.py b/virtManager/domain.py
index 582de64..6e742b9 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -825,7 +825,8 @@ class vmmDomain(vmmLibvirtObject):
 
 def define_graphics(self, devobj, do_hotplug,
 listen=_SENTINEL, port=_SENTINEL, tlsport=_SENTINEL,
-passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL):
+passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL,
+gl=_SENTINEL):
 xmlobj = self._make_xmlobj_to_define()
 editdev = self._lookup_device_to_define(xmlobj, devobj, do_hotplug)
 if not editdev:
@@ -843,6 +844,8 @@ class vmmDomain(vmmLibvirtObject):
 editdev.keymap = keymap
 if gtype != _SENTINEL:
 editdev.type = gtype
+if gl != _SENTINEL:
+editdev.gl = gl
 
 if do_hotplug:
 self.hotplug(device=editdev)
diff --git a/virtManager/gfxdetails.py b/virtManager/gfxdetails.py
index 0ae76c9..f3cd3a9 100644
--- a/virtManager/gfxdetails.py
+++ b/virtManager/gfxdetails.py
@@ -35,6 +35,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
 "changed-type": (GObject.SignalFlags.RUN_FIRST, None, []),
 "changed-address": (GObject.SignalFlags.RUN_FIRST, None, []),
 "changed-keymap": (GObject.SignalFlags.RUN_FIRST, None, []),
+"changed-opengl": (GObject.SignalFlags.RUN_FIRST, None, []),
 }
 
 def __init__(self, vm, builder, topwin):
@@ -54,6 +55,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
 "on_graphics_tlsport_changed": lambda ignore: 
self.emit("changed-tlsport"),
 "on_g

[virt-tools-list] [PATCH v4 0/2] virt-manager: add spice+virgl support

2016-11-28 Thread marcandre . lureau
From: Marc-André Lureau 

Hi

This is the remaining patches of the previous series to add basic
support to configure a VM with spice+virgl locally.

v4:
- fix OpenGL label accelerator
- use a combobox for selecting the listen type

v3:
- changed 'none' address for a new 'listen' checkbox
- rebased, dropping already merged patches
- fix pylint

v2:
- fix domain xml for spice gl parameter (changed during libvirt patches review)
- fix gfx.gl usage after Cole review

Marc-André Lureau (2):
  virt-manager: add opengl graphics option
  gfxdetails: add listen type option

 ui/gfxdetails.ui   | 89 ++
 virtManager/addhardware.py | 15 +---
 virtManager/details.py | 14 +---
 virtManager/domain.py  | 16 ++---
 virtManager/gfxdetails.py  | 47 +++-
 virtinst/devicegraphics.py | 16 -
 6 files changed, 161 insertions(+), 36 deletions(-)

-- 
2.10.0

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

[virt-tools-list] [PATCH v3 2/2] gfxdetails: add listen option

2016-11-18 Thread marcandre . lureau
From: Marc-André Lureau 

Similarly to virt-install --listen=none, add a checkbox to disable all
extra display server listening interface/ports.

Signed-off-by: Marc-André Lureau 
---
 ui/gfxdetails.ui   | 45 ++---
 virtManager/addhardware.py | 14 +-
 virtManager/details.py |  7 ---
 virtManager/domain.py  | 11 ---
 virtManager/gfxdetails.py  | 38 ++
 virtinst/devicegraphics.py | 16 +++-
 6 files changed, 100 insertions(+), 31 deletions(-)

diff --git a/ui/gfxdetails.ui b/ui/gfxdetails.ui
index b6f54aa..84099dd 100644
--- a/ui/gfxdetails.ui
+++ b/ui/gfxdetails.ui
@@ -214,15 +214,11 @@
   
 True
 False
-start
-False
 True
 
 
   
 True
-start
-False
   
 
   
@@ -328,16 +324,44 @@
   
 
 
-  
+  
 True
 False
-start
-True
-
-
-  
+
+  
+Listen
+True
 True
+False
+True
+0
+True
+
+  
+  
+True
+True
+0
+  
+
+
+  
+True
+False
+start
+True
+
+
+  
+True
+  
+
   
+  
+False
+True
+1
+  
 
   
   
@@ -349,7 +373,6 @@
   
 True
 False
-start
 True
 
 
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 7a3c8f2..3f868aa 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -1541,16 +1541,20 @@ class vmmAddHardware(vmmGObjectUI):
 
 def _validate_page_graphics(self):
 try:
-(gtype, port,
- tlsport, addr, passwd, keymap, gl) = self._gfxdetails.get_values()
+(gtype, port, tlsport, listen,
+ addr, passwd, keymap, gl) = self._gfxdetails.get_values()
 
 self._dev = virtinst.VirtualGraphics(self.conn.get_backend())
 self._dev.type = gtype
-self._dev.port = port
 self._dev.passwd = passwd
-self._dev.listen = addr
-self._dev.tlsPort = tlsport
 self._dev.gl = gl
+
+if not listen:
+self._dev.set_listen_none()
+else:
+self._dev.listen = addr
+self._dev.port = port
+self._dev.tlsPort = tlsport
 if keymap:
 self._dev.keymap = keymap
 except ValueError, e:
diff --git a/virtManager/details.py b/virtManager/details.py
index d803d52..d4e6629 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -2135,15 +2135,16 @@ class vmmDetails(vmmGObjectUI):
   devobj=devobj)
 
 def config_graphics_apply(self, devobj):
-(gtype, port,
- tlsport, addr, passwd, keymap, gl) = self.gfxdetails.get_values()
+(gtype, port, tlsport, listen,
+ addr, passwd, keymap, gl) = self.gfxdetails.get_values()
 
 kwargs = {}
 
 if self.edited(EDIT_GFX_PASSWD):
 kwargs["passwd"] = passwd
 if self.edited(EDIT_GFX_ADDRESS):
-kwargs["listen"] = addr
+kwargs["listen"] = listen
+kwargs["addr"] = addr
 if self.edited(EDIT_GFX_KEYMAP):
 kwargs["keymap"] = keymap
 if self.edited(EDIT_GFX_PORT):
diff --git a/virtManager/domain.py b/virtManager/domain.py
index 6e742b9..40b28db 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -824,7 +824,7 @@ class vmmDomain(vmmLibvirtObject):
 self._redefine_xmlobj(xmlobj)
 
 def define_graphics(self, devobj, do_hotplug,
-listen=_SENTINEL, port=_SENTINEL, tlsport=_SENTINEL,
+listen=_SENTINEL, addr=_SENTINEL, port=_SENTINEL, tlsport=_SENTINEL,
 passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL,
 gl=_SENTINEL):
 xmlobj = self._make_xmlobj_to_define()
@@ -832,8 +832,8 @@ class vmmDomain(vmmLibvirtObject):
 if not editdev:
 return
 
-if listen != _SENTINEL:
-editdev.listen = listen
+if addr != _SENTINEL:
+editdev.listen = addr
 if port != _SENTINEL:
 editdev.port = port
 if tlsport != _SENTINEL:
@@ -846,6 +846,11 @@ class vmmDomain(vmmLibvirtObject):
 editdev.type = gtype
 if gl != _SENTINEL:
 editdev.gl = gl
+if listen != _SENTINEL:
+if not listen:
+editdev.set_listen_none()
+else:
+editdev.remove_listen_none()
 
 if do_hotpl

[virt-tools-list] [PATCH v3 1/2] virt-manager: add opengl graphics option

2016-11-18 Thread marcandre . lureau
From: Marc-André Lureau 

Add an OpenGL checkbox to the Spice graphics options (only available if
SUPPORT_CONN_SPICE_GL).

Signed-off-by: Marc-André Lureau 
---
 ui/gfxdetails.ui   | 29 +
 virtManager/addhardware.py |  3 ++-
 virtManager/details.py |  9 +++--
 virtManager/domain.py  |  5 -
 virtManager/gfxdetails.py  | 11 +--
 5 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/ui/gfxdetails.ui b/ui/gfxdetails.ui
index ad84ca9..b6f54aa 100644
--- a/ui/gfxdetails.ui
+++ b/ui/gfxdetails.ui
@@ -363,5 +363,34 @@
 0
   
 
+
+  
+True
+False
+_OpenGL
+True
+graphics-opengl
+  
+  
+0
+8
+  
+
+
+  
+True
+True
+False
+True
+
+
+  
+
+  
+  
+1
+8
+  
+
   
 
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index aab9095..7a3c8f2 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -1542,7 +1542,7 @@ class vmmAddHardware(vmmGObjectUI):
 def _validate_page_graphics(self):
 try:
 (gtype, port,
- tlsport, addr, passwd, keymap) = self._gfxdetails.get_values()
+ tlsport, addr, passwd, keymap, gl) = self._gfxdetails.get_values()
 
 self._dev = virtinst.VirtualGraphics(self.conn.get_backend())
 self._dev.type = gtype
@@ -1550,6 +1550,7 @@ class vmmAddHardware(vmmGObjectUI):
 self._dev.passwd = passwd
 self._dev.listen = addr
 self._dev.tlsPort = tlsport
+self._dev.gl = gl
 if keymap:
 self._dev.keymap = keymap
 except ValueError, e:
diff --git a/virtManager/details.py b/virtManager/details.py
index b2f451d..d803d52 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -90,6 +90,7 @@ EDIT_GFX_KEYMAP,
 EDIT_GFX_ADDRESS,
 EDIT_GFX_TLSPORT,
 EDIT_GFX_PORT,
+EDIT_GFX_OPENGL,
 
 EDIT_VIDEO_MODEL,
 
@@ -104,7 +105,7 @@ EDIT_FS,
 
 EDIT_HOSTDEV_ROMBAR,
 
-) = range(1, 45)
+) = range(1, 46)
 
 
 # Columns in hw list model
@@ -376,6 +377,8 @@ class vmmDetails(vmmGObjectUI):
 lambda *x: self.enable_apply(x, EDIT_GFX_TYPE))
 self.gfxdetails.connect("changed-port",
 lambda *x: self.enable_apply(x, EDIT_GFX_PORT))
+self.gfxdetails.connect("changed-opengl",
+lambda *x: self.enable_apply(x, EDIT_GFX_OPENGL))
 self.gfxdetails.connect("changed-tlsport",
 lambda *x: self.enable_apply(x, EDIT_GFX_TLSPORT))
 self.gfxdetails.connect("changed-address",
@@ -2133,7 +2136,7 @@ class vmmDetails(vmmGObjectUI):
 
 def config_graphics_apply(self, devobj):
 (gtype, port,
- tlsport, addr, passwd, keymap) = self.gfxdetails.get_values()
+ tlsport, addr, passwd, keymap, gl) = self.gfxdetails.get_values()
 
 kwargs = {}
 
@@ -2145,6 +2148,8 @@ class vmmDetails(vmmGObjectUI):
 kwargs["keymap"] = keymap
 if self.edited(EDIT_GFX_PORT):
 kwargs["port"] = port
+if self.edited(EDIT_GFX_OPENGL):
+kwargs["gl"] = gl
 if self.edited(EDIT_GFX_TLSPORT):
 kwargs["tlsport"] = tlsport
 if self.edited(EDIT_GFX_TYPE):
diff --git a/virtManager/domain.py b/virtManager/domain.py
index 582de64..6e742b9 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -825,7 +825,8 @@ class vmmDomain(vmmLibvirtObject):
 
 def define_graphics(self, devobj, do_hotplug,
 listen=_SENTINEL, port=_SENTINEL, tlsport=_SENTINEL,
-passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL):
+passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL,
+gl=_SENTINEL):
 xmlobj = self._make_xmlobj_to_define()
 editdev = self._lookup_device_to_define(xmlobj, devobj, do_hotplug)
 if not editdev:
@@ -843,6 +844,8 @@ class vmmDomain(vmmLibvirtObject):
 editdev.keymap = keymap
 if gtype != _SENTINEL:
 editdev.type = gtype
+if gl != _SENTINEL:
+editdev.gl = gl
 
 if do_hotplug:
 self.hotplug(device=editdev)
diff --git a/virtManager/gfxdetails.py b/virtManager/gfxdetails.py
index 0ae76c9..f3cd3a9 100644
--- a/virtManager/gfxdetails.py
+++ b/virtManager/gfxdetails.py
@@ -35,6 +35,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
 "changed-type": (GObject.SignalFlags.RUN_FIRST, None, []),
 "changed-address": (GObject.SignalFlags.RUN_FIRST, None, []),
 "changed-keymap": (GObject.SignalFlags.RUN_FIRST, None, []),
+"changed-opengl": (GObject.SignalFlags.RUN_FIRST, None, []),
 }
 
 def __init__(self, vm, builder, topwin):
@@ -54,6 +55,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
 "on_graphics_tlsport_changed": lambda ignore: 
self.emit("changed-tlsport"),
 "on_g

[virt-tools-list] [PATCH v3 0/2] virt-manager: add spice+virgl support

2016-11-18 Thread marcandre . lureau
From: Marc-André Lureau 

Hi

This is the remaining patches of the previous series to add basic
support to configure a VM with spice+virgl locally.

v3:
- changed 'none' address for a new 'listen' checkbox
- rebased, dropping already merged patches
- fix pylint

v2:
- fix domain xml for spice gl parameter (changed during libvirt patches review)
- fix gfx.gl usage after Cole review

Marc-André Lureau (2):
  virt-manager: add opengl graphics option
  gfxdetails: add listen option

 ui/gfxdetails.ui   | 74 +++---
 virtManager/addhardware.py | 15 ++
 virtManager/details.py | 14 ++---
 virtManager/domain.py  | 16 +++---
 virtManager/gfxdetails.py  | 47 +++--
 virtinst/devicegraphics.py | 16 +-
 6 files changed, 148 insertions(+), 34 deletions(-)

-- 
2.10.0

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

[virt-tools-list] [PATCH 0/4] virt-manager: more spice+virgl support

2016-11-09 Thread marcandre . lureau
From: Marc-André Lureau 

Hi

This small series:
- fixes a small regression wrt qemu version checking
- adds a checkbox to enable/disable spice opengl
- adds an option to disable display server listening

This series allows to setup and configure a VM with spice/virgl with
qemu:///session.

Even though qemu:///system isn't yet supported by libvirt, it should
be compatible when libvirt gains supports, in the meatime, an error is
reported when starting the VM.

Marc-André Lureau (4):
  virtinst: fix bad version check regression from 55327c81b7
  virtinst: error out if spice+gl is not supported
  virt-manager: add opengl graphics option
  gfxdetails: add listen "None" option

 ui/gfxdetails.ui   | 29 +
 virtManager/addhardware.py | 12 
 virtManager/details.py |  9 +++--
 virtManager/domain.py  |  9 -
 virtManager/gfxdetails.py  | 39 ++-
 virtinst/devicegraphics.py | 16 +++-
 virtinst/guest.py  |  5 +
 virtinst/support.py|  4 ++--
 8 files changed, 104 insertions(+), 19 deletions(-)

-- 
2.10.0

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

[virt-tools-list] [PATCH 2/4] virtinst: error out if spice+gl is not supported

2016-11-08 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 virtinst/guest.py | 5 +
 1 file changed, 5 insertions(+)

diff --git a/virtinst/guest.py b/virtinst/guest.py
index 252da22..3366fcb 100644
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -1089,6 +1089,11 @@ class Guest(XMLBuilder):
 if dev.image_compression is None:
 dev.image_compression = "off"
 
+if (dev.type == "spice" and dev.gl and
+ not self.conn.check_support(
+ self.conn.SUPPORT_CONN_SPICE_GL)):
+ raise ValueError(_("Host does not support spice GL"))
+
 def _add_spice_channels(self):
 if self.skip_default_channel:
 return
-- 
2.10.0

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

[virt-tools-list] [PATCH 3/4] virt-manager: add opengl graphics option

2016-11-08 Thread marcandre . lureau
From: Marc-André Lureau 

Add an OpenGL checkbox to the Spice graphics options (only available if
SUPPORT_CONN_SPICE_GL).

Signed-off-by: Marc-André Lureau 
---
 ui/gfxdetails.ui   | 29 +
 virtManager/addhardware.py |  2 +-
 virtManager/details.py |  9 +++--
 virtManager/domain.py  |  5 -
 virtManager/gfxdetails.py  | 11 +--
 5 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/ui/gfxdetails.ui b/ui/gfxdetails.ui
index ad84ca9..14aca6e 100644
--- a/ui/gfxdetails.ui
+++ b/ui/gfxdetails.ui
@@ -363,5 +363,34 @@
 0
   
 
+
+  
+True
+False
+OpenGL
+  
+  
+0
+8
+  
+
+
+  
+True
+True
+False
+0.0500074505806
+0.5501192092896
+True
+
+
+  
+
+  
+  
+1
+8
+  
+
   
 
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index aab9095..60b9157 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -1542,7 +1542,7 @@ class vmmAddHardware(vmmGObjectUI):
 def _validate_page_graphics(self):
 try:
 (gtype, port,
- tlsport, addr, passwd, keymap) = self._gfxdetails.get_values()
+ tlsport, addr, passwd, keymap, gl) = self._gfxdetails.get_values()
 
 self._dev = virtinst.VirtualGraphics(self.conn.get_backend())
 self._dev.type = gtype
diff --git a/virtManager/details.py b/virtManager/details.py
index b2f451d..d803d52 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -90,6 +90,7 @@ EDIT_GFX_KEYMAP,
 EDIT_GFX_ADDRESS,
 EDIT_GFX_TLSPORT,
 EDIT_GFX_PORT,
+EDIT_GFX_OPENGL,
 
 EDIT_VIDEO_MODEL,
 
@@ -104,7 +105,7 @@ EDIT_FS,
 
 EDIT_HOSTDEV_ROMBAR,
 
-) = range(1, 45)
+) = range(1, 46)
 
 
 # Columns in hw list model
@@ -376,6 +377,8 @@ class vmmDetails(vmmGObjectUI):
 lambda *x: self.enable_apply(x, EDIT_GFX_TYPE))
 self.gfxdetails.connect("changed-port",
 lambda *x: self.enable_apply(x, EDIT_GFX_PORT))
+self.gfxdetails.connect("changed-opengl",
+lambda *x: self.enable_apply(x, EDIT_GFX_OPENGL))
 self.gfxdetails.connect("changed-tlsport",
 lambda *x: self.enable_apply(x, EDIT_GFX_TLSPORT))
 self.gfxdetails.connect("changed-address",
@@ -2133,7 +2136,7 @@ class vmmDetails(vmmGObjectUI):
 
 def config_graphics_apply(self, devobj):
 (gtype, port,
- tlsport, addr, passwd, keymap) = self.gfxdetails.get_values()
+ tlsport, addr, passwd, keymap, gl) = self.gfxdetails.get_values()
 
 kwargs = {}
 
@@ -2145,6 +2148,8 @@ class vmmDetails(vmmGObjectUI):
 kwargs["keymap"] = keymap
 if self.edited(EDIT_GFX_PORT):
 kwargs["port"] = port
+if self.edited(EDIT_GFX_OPENGL):
+kwargs["gl"] = gl
 if self.edited(EDIT_GFX_TLSPORT):
 kwargs["tlsport"] = tlsport
 if self.edited(EDIT_GFX_TYPE):
diff --git a/virtManager/domain.py b/virtManager/domain.py
index 582de64..6e742b9 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -825,7 +825,8 @@ class vmmDomain(vmmLibvirtObject):
 
 def define_graphics(self, devobj, do_hotplug,
 listen=_SENTINEL, port=_SENTINEL, tlsport=_SENTINEL,
-passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL):
+passwd=_SENTINEL, keymap=_SENTINEL, gtype=_SENTINEL,
+gl=_SENTINEL):
 xmlobj = self._make_xmlobj_to_define()
 editdev = self._lookup_device_to_define(xmlobj, devobj, do_hotplug)
 if not editdev:
@@ -843,6 +844,8 @@ class vmmDomain(vmmLibvirtObject):
 editdev.keymap = keymap
 if gtype != _SENTINEL:
 editdev.type = gtype
+if gl != _SENTINEL:
+editdev.gl = gl
 
 if do_hotplug:
 self.hotplug(device=editdev)
diff --git a/virtManager/gfxdetails.py b/virtManager/gfxdetails.py
index 0ae76c9..f3cd3a9 100644
--- a/virtManager/gfxdetails.py
+++ b/virtManager/gfxdetails.py
@@ -35,6 +35,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
 "changed-type": (GObject.SignalFlags.RUN_FIRST, None, []),
 "changed-address": (GObject.SignalFlags.RUN_FIRST, None, []),
 "changed-keymap": (GObject.SignalFlags.RUN_FIRST, None, []),
+"changed-opengl": (GObject.SignalFlags.RUN_FIRST, None, []),
 }
 
 def __init__(self, vm, builder, topwin):
@@ -54,6 +55,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
 "on_graphics_tlsport_changed": lambda ignore: 
self.emit("changed-tlsport"),
 "on_graphics_port_changed": lambda ignore: 
self.emit("changed-port"),
 "on_graphics_keymap_changed": lambda ignore: 
self.emit("changed-keymap"),
+"on_graphics_opengl_toggled": lambda ignore: 
self.emit("changed-opengl"),
 })
 
 self._init_ui()
@@ -14

[virt-tools-list] [PATCH 1/4] virtinst: fix bad version check regression from 55327c81b7

2016-11-08 Thread marcandre . lureau
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
 virtinst/support.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/virtinst/support.py b/virtinst/support.py
index 9516d83..ad7bb12 100644
--- a/virtinst/support.py
+++ b/virtinst/support.py
@@ -312,9 +312,9 @@ SUPPORT_CONN_MEM_STATS_PERIOD = _make(
 function="virDomain.setMemoryStatsPeriod",
 version="1.1.1", hv_version={"qemu": 0})
 SUPPORT_CONN_SPICE_GL = _make(version="1.3.3",
-hv_version={"qemu": "2.7.92", "test": 0})
+hv_version={"qemu": "2.5.92", "test": 0})
 SUPPORT_CONN_VIDEO_VIRTIO_ACCEL3D = _make(version="1.3.0",
-hv_version={"qemu": "2.7.0", "test": 0})
+hv_version={"qemu": "2.5.0", "test": 0})
 SUPPORT_CONN_GRAPHICS_LISTEN_NONE = _make(version="2.0.0")
 
 
-- 
2.10.0

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

[virt-tools-list] [PATCH 4/4] gfxdetails: add listen "None" option

2016-11-08 Thread marcandre . lureau
From: Marc-André Lureau 

Similarly to virt-install --listen=none, add an option to disable all
extra display server listening interface/ports.

Signed-off-by: Marc-André Lureau 
---
 virtManager/addhardware.py | 10 +++---
 virtManager/domain.py  |  4 
 virtManager/gfxdetails.py  | 28 +---
 virtinst/devicegraphics.py | 16 +++-
 4 files changed, 47 insertions(+), 11 deletions(-)

diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 60b9157..87f397e 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -1546,10 +1546,14 @@ class vmmAddHardware(vmmGObjectUI):
 
 self._dev = virtinst.VirtualGraphics(self.conn.get_backend())
 self._dev.type = gtype
-self._dev.port = port
 self._dev.passwd = passwd
-self._dev.listen = addr
-self._dev.tlsPort = tlsport
+
+if addr == "none":
+self._dev.set_listen_none()
+else:
+self._dev.listen = addr
+self._dev.port = port
+self._dev.tlsPort = tlsport
 if keymap:
 self._dev.keymap = keymap
 except ValueError, e:
diff --git a/virtManager/domain.py b/virtManager/domain.py
index 6e742b9..96bae64 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -847,6 +847,10 @@ class vmmDomain(vmmLibvirtObject):
 if gl != _SENTINEL:
 editdev.gl = gl
 
+if listen == "none":
+editdev.set_listen_none()
+else:
+editdev.remove_listen_none()
 if do_hotplug:
 self.hotplug(device=editdev)
 else:
diff --git a/virtManager/gfxdetails.py b/virtManager/gfxdetails.py
index f3cd3a9..40e0cd8 100644
--- a/virtManager/gfxdetails.py
+++ b/virtManager/gfxdetails.py
@@ -51,7 +51,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
 "on_graphics_use_password": self._change_password_chk,
 
 "on_graphics_password_changed": lambda ignore: 
self.emit("changed-password"),
-"on_graphics_address_changed": lambda ignore: 
self.emit("changed-address"),
+"on_graphics_address_changed": self._change_graphics_address,
 "on_graphics_tlsport_changed": lambda ignore: 
self.emit("changed-tlsport"),
 "on_graphics_port_changed": lambda ignore: 
self.emit("changed-port"),
 "on_graphics_keymap_changed": lambda ignore: 
self.emit("changed-keymap"),
@@ -86,6 +86,7 @@ class vmmGraphicsDetails(vmmGObjectUI):
 model.append([None, _("Hypervisor default")])
 model.append(["127.0.0.1", _("Localhost only")])
 model.append(["0.0.0.0", _("All interfaces")])
+model.append(["none", _("None")])
 
 # Keymap
 combo = self.widget("graphics-keymap")
@@ -181,8 +182,12 @@ class vmmGraphicsDetails(vmmGObjectUI):
 use_passwd = gfx.passwd is not None
 
 set_port("graphics-port", gfx.port)
-uiutil.set_list_selection(
-self.widget("graphics-address"), gfx.listen)
+if gfx.has_listen_none():
+uiutil.set_list_selection(
+self.widget("graphics-address"), "none")
+else:
+uiutil.set_list_selection(
+self.widget("graphics-address"), gfx.listen)
 uiutil.set_list_selection(
 self.widget("graphics-keymap"), gfx.keymap or None)
 
@@ -211,15 +216,20 @@ class vmmGraphicsDetails(vmmGObjectUI):
 #
 
 def _show_rows_from_type(self):
-hide_all = ["graphics-xauth", "graphics-display", "graphics-address",
+hide_all = ["graphics-xauth", "graphics-display",
 "graphics-password-box", "graphics-keymap", "graphics-port-box",
 "graphics-tlsport-box", "graphics-opengl"]
 
 gtype = uiutil.get_list_selection(self.widget("graphics-type"))
+addr = uiutil.get_list_selection(self.widget("graphics-address"))
+
 sdl_rows = ["graphics-xauth", "graphics-display"]
-vnc_rows = ["graphics-password-box", "graphics-address",
-"graphics-port-box", "graphics-keymap"]
-spice_rows = vnc_rows[:] + ["graphics-tlsport-box"]
+vnc_rows = ["graphics-password-box", "graphics-keymap"]
+if addr != "none":
+vnc_rows.extend(["graphics-port-box"])
+spice_rows = vnc_rows[:]
+if addr != "none":
+spice_rows.extend(["graphics-tlsport-box"])
 if self.conn.check_support(self.conn.SUPPORT_CONN_SPICE_GL):
 spice_rows.extend(["graphics-opengl"])
 
@@ -238,6 +248,10 @@ class vmmGraphicsDetails(vmmGObjectUI):
 self._show_rows_from_type()
 self.emit("changed-type")
 
+def _change_graphics_address(self, ignore):
+self._show_rows_from_type()
+self.emit("changed-address")
+
 def _change_port_auto(self, ignore):
 self.widget("