Commit Graph

122 Commits

Author SHA1 Message Date
Daniel P. Berrangé
db827dedc9 Add a --shared / -s flag for shared session access
By default when connecting with VNC, an existing viewer will be kicked
off. This adds a --shared / -s flag which tells the server we are
willing the share the session with other clients.

This is wired up for VNC only.

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

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-11-26 09:55:58 +00:00
Pino Toscano
4b7f2ac0ec Use VM descriptions if available
When listing the running VMs in a libvirt connection, use the
descriptions as tooltips if available.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2020-07-24 13:01:57 +00:00
Pino Toscano
e2abe953ed VM selection: expand models for tooltip column
Add a new column in the list models for the VM selection dialog, and use
this new column to hold the tooltip of the items in the list.

At the moment nothing is set in the new column, so there is no behavior
change.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2020-07-24 13:01:57 +00:00
Pino Toscano
2e46ffc08d Use VM titles if available
When listing the running VMs in a libvirt connection, use the titles if
available.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2020-07-24 13:01:57 +00:00
Pino Toscano
74d25742ea VM selection: expand models for UI/key columns
Add a new column in the list models for the VM selection dialog, and use
this new column to hold the key of the VM. This way, the first column
represents the UI representation of the VM without affecting the key.

At the moment the VM name is set for both, so there is no behavior
change.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2020-07-24 13:01:57 +00:00
Pino Toscano
c28374d8a8 Unconditionally use virDomainOpenGraphicsFD
libvirt 1.2.8 is required now.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2020-07-24 11:38:16 +02:00
Pino Toscano
8db413e689 Fix few spellings
"ID", "oVirt", "SSH", "UNIX", "URI", "UUID"

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2020-07-23 12:01:52 +02:00
Eduardo Lima (Etrunko)
ed4768d589 Update usage of GObject private structures
New functions and macros have been added in glib 2.38 to better handle
this case.

c8de2b11bb/NEWS

The old method is being deprecated as of version 2.58.

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

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2019-02-22 09:19:27 -03:00
Daniel P. Berrangé
9e16ee09cf Fix signed/unsigned mixup in format args
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-02-19 14:51:29 +00:00
Ben Mathews
564b03e3d6 Set window title to VM name
The attached patch address an issue with virt-view not setting the
titlebar text to be the title of the VM (previously discussed on:
https://www.redhat.com/archives/virt-tools-list/2018-September/msg00064.html).
2018-12-05 17:23:08 +01:00
Jonathon Jongsma
49e219335b Silence coverity warning about dead code
For some reason, coverity was complaining that the definition of
cred_type_to_str was dead code, even though it wasn't. Changing the
storage to static silences the warning. Since that's a benficial change
anyway, let's change it. At the same time, make the pointer constant as
well and move it outside of the loop since it doesn't need to be inside
the loop.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2018-12-04 11:33:30 -06:00
Pavel Grunt
209c80375b virt-viewer: Ensure to not close during migration
Take a look at the shutdown event detail before killing
the connection. Otherwise it breaks the SPICE seamless migration
feature.

Regression since commit a62827d28c

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1442929
Signed-off-by: Pavel Grunt <pgrunt@redhat.com>
Acked-by: Daniel P. Berrange <berrange@redhat.com>
2017-05-18 13:46:01 +02:00
Pavel Grunt
effa832ca5 virt-viewer: Support newer libvirt xml format
Since libvirt 0.9.4 there is a new listen element which can be used
to specify address instead of using the attributes of graphics element.

Also add support for listen type socket - available for Qemu since
libvirt 2.0.0

Resolves: rhbz#1411765

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-04-19 11:06:58 +02:00
Pavel Grunt
66b2cbb8a4 virt-viewer: Fix comparison in domain selection
Related: rhbz#1399077

Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2017-03-16 14:21:58 +01:00
Pavel Grunt
11d8676ba4 virt-viewer: Adjust name-id-uuid comment
virt-viewer by default chooses the VM by its id, then uuid
and then by name. Adjust the comment to match the implementation.

Related: rhbz#1399077
2017-03-09 12:59:10 +01:00
Pavel Grunt
61292f3063 virt-viewer: Allow more precise VM selection
Theoretically a VM name can be a valid VM id or uuid. In that case
connecting to the VMs may be problematic since virt-viewer selects
the VM by its id then by uuid if not found then by its name.

Introduce new command line options to cover this situation:
 "--id" to connect to the VM by its id
 "--uuid" to connect to the VM by its uuid
 "--domain-name" to connect to the VM by its name
The options are mutually exclusive

Resolves: rhbz#1399077
2017-03-09 12:59:03 +01:00
Pavel Grunt
b7f8644429 Do not print password in the debug log
Do not show a length since it is sensitive info as well.

Resolves: rhbz#1410030

Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-07 17:29:59 +01:00
Pavel Grunt
965286d699 Set guest name at the same time as uuid
Avoid showing the "Unknown" name in the guest detail dialog when
waiting for the domain to be started.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-01-05 17:31:05 +01:00
Daniel P. Berrange
a62827d28c virt-viewer: ensure we close when seeing domain stop event
Normally virt-viewer relies on the VNC/SPICE widget seeing
an EOF on its underlying connection to detect when the
session is closed.

When tunnelling to a remote guest over SSH though, this
EOF can be delayed for a very long time, leaving a dead
session open.

This can be seen with

   virt-viewer -c qemu+ssh://remotehost/system guestname

when on the remote shell run

   virsh destroy guestname

and notice that virt-viewer does not see the shutdown
immediately.

When we get a domain stopped event we know the session
should be dead, so forceably close it, if not already
closed.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 13:54:15 +01:00
Pavel Grunt
40d1fff271 Include virt-viewer-util.h only in source files
It doesn't have any symbols to be used in headers

Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-05-31 16:52:46 +02:00
Fabiano Fidêncio
51ce01dfdd Bring back libvirt-glib dependency
libvirt-glib dependency was dropped in commit 296f91c in favor to
maintain the full glib event loop integration into virt-viewer tree.
This decision was taken because libvirt-glib was not mature enough at
that time, which is not the case nowadays.

The libvirt-glib version chosen as dependency (0.1.8) is the first
release that includes the fixes for the glib event loop integration that
were backported to virt-viewer last year.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-02-25 22:17:37 +01:00
Eduardo Lima (Etrunko)
a9ce19f848 Port to GtkApplication API's
Most of this patch consists in code being shuffled around to fit the
expected flow while using the new APIs. I tried my best to make this
patch the less intrusive as possible. Main changes are:

- Updated build requirements
   * glib version 2.38
   * gtk+ version 3.10
   * gio

- VirtViewerApp is now a subclass of GtkApplication.
  Some mainloop calls were replaced:
   * gtk_main() -> g_application_run()
   * gtk_quit() -> g_application_quit()

- Unified command line option handling.
  The logic has moved from the main functions and split in common
  options, and specific ones for each application. With this, the main
  functions were highly simplified, and now basically responsible for
  instantiating the App object and running the main loop.

- All Window objects must be associated with the Application.
  With this, there is no need to emit our own 'window-added'/'window-
  removed' signals, as those will be emited by GtkApplication whenever
  gtk_application_add_window() and gtk_application_remove_window() are
  called. Also, 'window-removed' was not being used anywhere.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2016-02-18 21:45:56 +01:00
Eduardo Lima (Etrunko)
8684961d2d Remove useless {get,set}_property functions
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2015-11-04 12:17:16 -02:00
Eduardo Lima (Etrunko)
95773ca5e1 Move declaration to the beginning of the file
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2015-11-04 12:17:16 -02:00
Christophe Fergeau
c1e72c1be1 Stop polling after reconnecting to libvirtd
When the connection to libvirtd is lost, virt-viewer starts polling for
libvirtd to come back. The polling mechanism is also used when
connecting to very old libvirtd which don't support
virConnectDomainEventDeregisterAny().

Currently, once we could reconnect to libvirtd, virt-viewer will keep
polling, thus behaving as if the libvirtd connection does not support
virConnectDomainEventDeregisterAny(). This commit makes sure we stop
polling once the new libvirtd connection is established.

This has the side-effect of preventing
https://bugzilla.redhat.com/show_bug.cgi?id=1271519 from occurring with
recent libvirt as it's caused by some race occurring when using the
polling code.
2015-10-20 10:20:23 +02:00
Pavel Hrdina
08378ec4dc virt-viewer: set keepAlive on libvirt connection
Setting the keepAlive on libvirt connection is needed in order to
receive the CloseCallback event.

Resolves: rhbz#1164052
2015-07-09 02:45:12 +02:00
Jonathon Jongsma
c33f37efe3 Don't wait for reconnect when user cancels auth
When starting virt-viewer with the --reconnect switch to a guest that
has a password, if the user cancels the authentication dialog (e.g.
pressing 'Esc'), the window will display "Waiting for guest domain to
restart".  Obviously, the domain will never restart because it's already
running.

After this fix, the application will simply exit when the user cancels
authentication, even if the --reconnect switch is used.
2015-06-19 14:39:48 -05:00
Lukas Venhoda
82d6280e5c virt-viewer: Set toolbar buttons not sensitive when needed
File->Screenshot, File->Preferences, View->Zoom and Send keys are now
sensitive only while quest is connected.

Changed behaviour of zoom:

Previously, zoom could be set while quest wasn't connected. The zoom
would then be set on connection. There was no indication of current zoom
level while not connected to guest.

Now, the menu is not sensitive while not connected to guest. Zoom can
now be only modified while connected to guest, or from the command line.
2015-04-22 11:03:13 +02:00
Fabiano Fidêncio
69dcde3c89 virt-viewer: Make update_display() more readable 2015-03-27 16:53:44 +01:00
Fabiano Fidêncio
dc2dd055d4 virt-viewer: Do not wait for a guest that will never show up
All the situations where virt_viewer_update_display() can fail are
those when we won't be able to connect regardless of what changes on the
remote host. So, propagate the error instead of waiting for the guest to
start.

Related: rhbz#1085216
2015-03-27 16:52:54 +01:00
Fabiano Fidêncio
ffe19f6ece virt-viewer: Avoid simple_message_dialog() when errors can be propagated
Remove all the dialogs used to report errors on extract_connect_info()
and just propagate the errors we got from it.
The only exception is virt_viewer_domain_event(), that is a callback
that doesn't have GError as argument. In this specific case, we show the
error dialog instead of propagating it.

Related: rhbz#1085216
2015-03-27 16:48:31 +01:00
Fabiano Fidêncio
f1204f0e69 virt-viewer-app: create_session() should return a boolean
By convention functions that take GError parameters should return FALSE
(or NULL) or error.

Related: rhbz#1085216
2015-03-27 16:35:35 +01:00
Fabiano Fidêncio
f9c4a03bd7 virt-viewer-app: Add a GError arg to create_session()
This is part of a small re-factoring that will have all connection
errors, when we won't be able to connect regardless of what changes on
the remote host, being treated by virt_viewer_app_initial_connect(),
avoiding weird behaviors as we have nowadays (like more than one error
dialog being shown or having the virt-viewer waiting forever for a guest
that will never show up).

Related: rhbz#1085216
2015-03-27 16:12:58 +01:00
Fabiano Fidêncio
cab8f7450b virt-viewer: Add a GError arg to update_display()
This is part of a small re-factoring that will have all connection
errors, when we won't be able to connect regardless of what changes on
the remote host, being treated by virt_viewer_app_initial_connect(),
avoiding weird behaviors as we have nowadays (like more than one error
dialog being shown or having the virt-viewer waiting forever for a guest
that will never show up).

Related: rhbz#1085216
2015-03-27 16:06:27 +01:00
Fabiano Fidêncio
2c03eacc2d virt-viewer: Add a GError arg to extract_connect_info()
This is part of a small re-factoring that will have all connection
errors, when we won't be able to connect regardless of what changes on
the remote host, being treated by virt_viewer_app_initial_connect(),
avoiding weird behaviors as we have nowadays (like more than one error
dialog being shown or having the virt-viewer waiting forever for a guest
that will never show up).

Related: rhbz#1085216
2015-03-27 16:05:05 +01:00
Fabiano Fidêncio
e212514b13 Do not use comments that are not in English 2015-03-26 14:26:05 +01:00
Pavel Grunt
66afac53b6 virt-viewer: Clean up if no vm was chosen
It is safe to clean up when running virt-viewer without specifying
vm name if no vm was chosen. It brings back behavior before 88f6341.

The 'if (dom == NULL && err != NULL)' part was affected by commits
824c4b9, 1eaaf8c, 15c7d17 so the check for 'err' is not needed anymore.
2015-03-24 08:04:19 +01:00
Pavel Grunt
1a619f2383 Report errors in one place
Since the error is propagated to the main, report the error there.
To make it work GError VIRT_VIEWER_ERROR_FAILED is set for all
failing states and it is reported using virt_viewer_app_simple_message_dialog().
2015-03-23 19:32:02 +01:00
Pavel Grunt
1bcd8d0fe6 Exit normally when canceling dialog
This applies for:
 libvirt authentication dialog (e.g. virt-viewer --attach guest)
 'recent connection' dialog (e.g. remote-viewer)
 'vm choose' dialog when connecting without specifying the vm name

This is done by using a new GError VIRT_VIEWER_ERROR_CANCELLED.
2015-03-23 19:32:02 +01:00
Pavel Grunt
aec2248cf8 virt-viewer: Bring back debug log about nonexistent guest
Although commit 88f6341 allowed to use virt-viewer with a wrong guest name,
the user is informed about the nonexistent guest only by a dialog showing
the list of running machines or informing about the connection error.

Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1201177
2015-03-23 19:32:02 +01:00
Fabiano Fidêncio
21306d13f9 Take --direct into consideration when checking if a guest is reachable
When connecting to a remote host (using qemu+ssh://...) that has a
virtual machine listening to "127.0.0.1", virt_viewer_is_reachable() must
take --direct into account, otherwise it can end up connecting to a local
virtual machine listening to "0.0.0.0" instead of returning that the
guest is not reachable.

Resolves: rhbz#1085216
2015-03-12 01:54:30 +01:00
Fabiano Fidêncio
fa952ad9b2 Avoid 'Dereference of a null pointer'
Caught by Covscan.
2015-03-11 11:52:43 +01:00
Fabiano Fidêncio
a51c70771a virt-viewer: set transient parent for connection's error dialog
Commit c3d24f8b sets transient parent for the most part of the
GtkDialogs, but seems like this one was forgotten.
2015-01-08 16:13:35 +01:00
Christophe Fergeau
5a07c59e8f virt-viewer: Don't connect to localhost displays with qemu+tcp://
When connecting to a remote libvirt instance, a VM may only be listening
on localhost for SPICE/VNC connections. In such a situation, virt-viewer
then tries to connect to localhost, which is not correct as this
'localhost' referred to the remote libvirt host it connected to.
This commit adds a couple of tests on the libvirt URI used and the
<graphics> listen address to error out in this situation.

Resolves: rhbz#1108523
2015-01-06 15:38:09 -06:00
Pavel Grunt
c3d24f8bb6 Set a transient parent for GtkDialogs
Silence the Gtk 3.14 message:
"GtkDialog mapped without a transient parent. This is discouraged."
2014-12-19 17:39:53 +01:00
Marc-André Lureau
824c4b9c0d Do not show twice error dialog when no VM are found
When running virt-viewer without argument, and no VM are found, you get
two error dialogs. Only one is enough.
2014-12-01 11:09:14 +01:00
Marc-André Lureau
3d5627d79a virt-viewer: allow connection to unix socket only server
Even when the server doesn't provide a display connection address,
virt-viewer is able to connect to guest with libvirt attach.
2014-11-25 15:07:32 +01:00
Marc-André Lureau
1eaaf8c3ab Report error in dialog
Use a UI dialog to inform of connection error.
2014-11-25 13:00:50 +01:00
Marc-André Lureau
6100d08dd3 Simplify virt_viewer_initial_connect()
- do not overwrite err if ->initial_connect() sets it
- remove need for waitvm if the display server isn't yet started (note:
  this function might be untested, I am not sure relying on libvirt events
  is enough)
2014-11-25 13:00:50 +01:00
Marc-André Lureau
9e2f9ea064 Simplify virt_viewer_initial_connect()
- remove need for waitvm if the display server isn't yet started (note:
  this function might be untested, I am not sure relying on libvirt events
  is enough)
2014-11-25 13:00:50 +01:00