Commit Graph

655 Commits

Author SHA1 Message Date
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
Pavel Grunt
68148e1bd1 display-vnc: fix zoom-level set by command line
Setting the zoom-level using the command line option '--zoom' is not
working for vnc guests. This problem can be solved by emitting
the "display-desktop-resize" signal when vnc is initialized.

https://bugzilla.redhat.com/show_bug.cgi?id=1170071
2014-12-10 14:11:57 +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
c0774f725a spice: calling VirtViewerSession:close() can destroy self
SpiceSession in spice-gtk v0.27 will remove channels from session during
disconnect (and not when they are actually disposed). When no channels
are left, session-disconnected is emitted, and the VirtViewerSession
will be unref from the application. Use a weak reference to self to
avoid crashing after calling spice_session_disconnect()

As a workaround for existing clients, spice-gtk v0.27 will defer the
disconnection to idle time.  But the fix still makes sense and would
prevent potentially future issues if spice-gtk changes back to sync
disconnection.

(the alternative of calling ref/unref would needlessly recreate a
SpiceSession with a call to create_spice_session(), which is something
we can avoid when leaving the application)
2014-12-01 11:07:57 +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
8addab251e Report error on attach-only display
Provide error details if the display can only be access through libvirt
--attach method.
2014-11-25 13:00:50 +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
Marc-André Lureau
7931161d59 Simplify virt_viewer_initial_connect()
Some refactoring to make the code easier to read, mostly code
movement/reindenting and introduction of a "wait" label which has the
same purpose as "done".
This also adds a "goto wait" within an if block, but this does not
change the initial code flow, just makes it more explicit.
2014-11-25 13:00:50 +01:00
Marc-André Lureau
15c7d17b96 Remove VIRT_VIEWER_VM_CHOOSE_DIALOG_CANCELLED
This error type isn't really an error, it is used to skip error report
code. The functions can simply return FALSE on failure, without GError
set, to indicate that program should quit normally.
2014-11-25 13:00:49 +01:00
Marc-André Lureau
71f156caf5 Limit HAVE_SOCKETPAIR to directly concerned code 2014-11-25 13:00:49 +01:00
Marc-André Lureau
5a444f106d Move libvirt reconnect polling to VirtViewer
This is libvirt specific, no need to share it in the VirtViewerApp base
class.
2014-11-25 13:00:49 +01:00
Marc-André Lureau
dbbd72676a spice: use virt_viewer_signal_connect_object
This isn't required, but makes it easier to track reference issues, as
you have guarantee that callbacks won't be executed if the objects are
disposed.
2014-11-25 12:56:51 +01:00
Fabiano Fidêncio
a7e95e8f3c Replace priv->withEvents usage for priv->domain_event
Once we have priv->domain_event, we don't need priv->withEvents anymore
2014-11-20 11:15:05 +01:00
Fabiano Fidêncio
fe95067c85 Prefer to use virConnectDomainEventRegisterAny()
The usage of virConnectDomainEventRegister() is no longer recommended
according to the libvirt's documentation.
2014-11-20 11:15:05 +01:00
Fabiano Fidêncio
333ba4fe51 Set freed priv->dom to NULL in _dispose()
Avoid a possible use/free after the object has been freed.
2014-11-20 11:15:05 +01:00
Fabiano Fidêncio
de8b381fa4 Make sure conn exists before use it
Although all the used functions have a explicit check for a valid
virConnPtr, let's be safe and only use priv->conn when its value is
non-NULL.
2014-11-20 11:15:05 +01:00
Christophe Fergeau
1c69f3cf40 VirtViewerApp: Never remove main window
It's currently possible to destroy any virt-viewer window, including the
main window. However, some part of the code expects that the main window
is always present, for example to present status messages.

In particular, stopping the guest (or running virsh destroy) will close
all windows: virt_viewer_session_clear_displays will get called, which
will call into virt_viewer_app_remove_display_removed, and finally into
virt_viewer_app_remove_nth_window, which will destroy the window being
removed if it holds the last reference to it.

So going through virt_viewer_session_clear_displays, all
VirtViewerWindow instances and their corresponding GtkWindow have been
destroyed. This is already an issue as VirtViewerApp::main_window will
be pointing to freed memory.

When using virt-viewer --reconnect, this will cause a crash when
restarting the guest in virt_viewer_app_create_session as it tries to
get a valid GtkWindow through:
GtkWindow *window = virt_viewer_window_get_window(priv->main_window);

This commit avoids this issue by special casing the main window in
virt_viewer_app_remove_nth_window to ensure it never gets removed.
This is similar to what is done in virt_viewer_app_hide_all_windows.
2014-11-18 14:30:01 +01:00
Christophe Fergeau
1c341e8cb3 Fix check of virt_viewer_app_initial_connect return value
Commit 13f493200 changed virt_viewer_app_initial_connect to return a
gboolean rather than an int, but one call site was not updated to the
new convention, and was still checking for a negative value rather than
for FALSE in order to detect failures.
2014-11-14 10:32:31 +01:00
Daniel P. Berrange
b94859e30d Check for spice-gtk 0.26 instead of a git snapshot of 0.25
As spice-gtk macro for checking the version numbers was broken, let's
check for 0.26 and avoid to have virt-viewer broken on a few distros
for a good long time.
2014-11-04 00:06:08 +01:00
Christophe Fergeau
161de0fd32 Don't use virGetLastErrorMessage()
This was introduced in libvirt 1.0.6 but we only require libvirt 0.10.0
2014-10-31 13:46:43 +01:00
Christophe Fergeau
ffd2065724 Don't call local variable 'select'
This causes warnings with older compilers
virt-viewer-vm-connection.c:52: warning: declaration of 'select' shadows
a global declaration
/usr/include/sys/select.h:109: warning: shadowed declaration is here
2014-10-31 13:46:43 +01:00
Daniel P. Berrange
80a3ee5d5a Avoid log message warning messages due to incorrect int format
The G_N_ELEMENTS() type is size_t but this was being passed to
a format string with '%lu' which is of a different size on many
platforms. Just delete this part of the warning message since
it was not hugely useful.
2014-10-27 16:53:57 +00:00
Daniel P. Berrange
041a39f97f Avoid use of non-literal string with g_debug 2014-10-27 16:43:13 +00:00
Daniel P. Berrange
bd6fd964f9 Remove useless 'if (...)' before free()
The 'free()' function accepts NULL, so you should not
check for NULL before calling it.
2014-10-27 16:38:06 +00:00
Jonathon Jongsma
f0d662994f Don't try to re-configure displays when there are none
virt_viewer_session_on_monitor_geometry_changed() gets called
immediately upon agent connection, but sometimes this is before any
displays have been received. Simply return early when this is the case.
2014-10-27 10:37:31 -05:00
Jonathon Jongsma
8fa5e004ec Shift top-left display to origin
When using a custom fullscreen display configuration, it's possible to
specify that e.g. a single screen should be fullscreen on client
monitor #4. Since we send down absolute positions and disable alignment
when all windows are in fullscreen, we can send configurations with a
very large offset to the top-left corner. This could result in the guest
trying to create a screen that was much larger than necessary. For
example when sending a configuration of 1280x1024+4240+0, the guest
would need to allocate a screen of size 5520x1024, which might fail if
video memory was too low. To avoid this issue, we shift all displays
so that the minimum X coordinate for all screens is at x=0, and the
minimum y coordinate is at y=0.
2014-10-27 10:37:31 -05:00
Jonathon Jongsma
221d5f5cd4 Move monitor alignment function to util header 2014-10-24 09:14:09 -05:00
Fabiano Fidêncio
ccc3fbe16a Check for the right spice version in session-spice.c
We have to check for the spice version where the
SPICE_CLIENT_ERROR_AUTH_NEEDS_PASSWORD_AND_USERNAME was introduced and
not for the one where spice_channel_get_error() was introduced.
2014-10-16 16:25:23 +02:00
Jonathon Jongsma
65560fa466 Don't disable "send key" menu when display isn't ready
The ability to send a keystroke should not depend on whether a display
is ready or not, it only depends on whether the display exists or not.

See https://bugzilla.redhat.com/show_bug.cgi?id=1152574
2014-10-16 16:09:25 +02:00
Jonathon Jongsma
c64a3c8f70 Fix bug with initial placement of fullscreen windows
The function app_window_try_fullscreen() will lookup the initial monitor
for the nth monitor internally, so we should pass in the display ID to the function
rather than the mapped monitor ID. This was causing 2 monitors on the
same monitor with a configuration like this:

    monitor-mapping=1:2;2:1
2014-10-15 23:48:50 +02:00
Fabiano Fidêncio
910ee34248 Force display_show_hint() when the display is set
Since a window is not created at startup for each display, the first
display(s) set when the application is opened will never receive and
treat the "notify::show-hint" signal on VirtViewerWindow, once the
callback is only set when the display is set to the specific window.
It causes problems like the "Send Key" menu not activated till an extra
display is added. To avoid this problem, let's force a call to
display_show_hint() everytime a display is set.

Resolves: rhbz#1152468
https://bugzilla.redhat.com/show_bug.cgi?id=1152468
2014-10-15 23:48:50 +02:00
Marc-André Lureau
3eaecbb3a4 Use socat instead of nc if possible
It turns out that nc does not leave on server disconnect, and there
doesn't seem to be any option to do that, leaving client open, and
a bunch of idle processes.

Replacing nc with socat solves that, client is disconnected when
the VM is shut down, when the sever connection is closed.

https://bugzilla.redhat.com/show_bug.cgi?id=1030487
2014-10-10 15:14:18 +02:00
Fabiano Fidêncio
9886055a4a Prefill the username in the authentication dialog
Lets prefill the username entry using the user name of the
current user.
2014-10-10 12:57:08 +02:00
Fabiano Fidêncio
69b3096f51 Use 'username' property from .vv file for spice-session 2014-10-10 12:57:08 +02:00
Fabiano Fidêncio
04e02148b2 Ask for username when connecting with SASL
When connecting with SASL for authentication, some authentication
mechanisms need a username (the plain text and md5 ones, for example).
2014-10-10 12:57:08 +02:00
Pavel Grunt
88f634179e Show VM chooser dialog when starting virt-viewer with no arg
When user starts virt-viewer without specifying VM domain name
or with a wrong name a list of running machines is shown
and user may choose one of them.
2014-10-10 12:57:08 +02:00
Pavel Grunt
7a47a4da08 Show VM chooser dialog when oVirt VM name is missing
When a user tries to connect to ovirt without specifying
VM name (remote-viewer ovirt://ovirt.example.com) or with
wrong VM name a list of available virtual machines is shown,
and the user may pick a machine he wants to connect to.
2014-10-10 12:57:08 +02:00
Christophe Fergeau
d2fb85642a Fix 'seperate' typo in man page/comments 2014-10-09 17:21:26 +02:00
Christophe Fergeau
9803f9cb42 ovirt: Allow to remove CD images
It turns out this is supposed to be done through update requests with a
CD image with an empty name, which is what the current code tries to do.
The only reason it's not working is because of server-side bugs with
oVirt < 3.5
The requirement on libgovirt is raised to 0.3.2 as
a small change is needed as well in libgovirt to allow empty filenames:
https://git.gnome.org/browse/libgovirt/commit/?id=bdb788fcc

Without this change, nothing too bad will happen, but the CD won't be
removed and warnings will be logged in the console.
2014-10-09 17:19:12 +02:00
Ján Tomko
bb44ce0a1f Prefer virDomainOpenGraphicsFD for --attach
The virDomainOpenGraphics API cannot label the socket
we pass to it. Prefer virDomainOpenGraphicsFD (if building
with libvirt 1.2.8 or later) which creates the socket for us
and works with SELinux too.

Fall back to the old API if the new one is unsupported
(i.e. the libvirtd on the host is older than the libvirt version
virt-viewer was compiled against).

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2014-10-01 18:58:13 +02:00
Fabiano Fidêncio
ec5a661469 Let the user cancel the SPICE auth dialog
virt_viewer_auth_collect_credentials() was recently changed to return
a boolean instead of an integer (2561c171). This change introduced a
regression in the authentication dialog behavior, making it impossible
for the user to cancel.
2014-09-26 16:30:43 +02:00
Fabiano Fidêncio
141d69b7f5 Improve authentication error messages
Adding a better error message to our default error message, based on the
libvirt error. Also, the libvirt error is shown as debug.

https://bugzilla.redhat.com/show_bug.cgi?id=1142742
2014-09-26 16:30:43 +02:00
Fabiano Fidêncio
42ffe6f8b4 Simplify virt_viewer_auth_libvirt_credentials() return value logic
As the function should return < 0 in error cases, let's explicitly
return/set the return value to -1 in error cases. Otherwise, the
function will return 0.

This patch also fixes a regression introduced by (a5ce2ed3).

https://bugzilla.redhat.com/show_bug.cgi?id=1142742
2014-09-26 16:30:43 +02:00
Jonathon Jongsma
55172bd8a7 Initialize fullscreen display map to fallback
If uuid was never set, we never checked the 'fallback' monitor map.
Initializing the monitor map to the fallback value at startup solves
this issue. This allows fallback mode to work with older servers that
don't send the UUID.
2014-09-26 09:22:12 -05:00
Jonathon Jongsma
c4d1347a6d Unset app 'fullscreen' when leaving fullscreen
Previously, the fullscreen floating toolbar and the "toggle-fullscreen"
hotkey (which maps to the menu item action) had slightly different
methods of exiting fullscreen. The floating toolbar method unset the
'fullscreen' property on the application (which causes all windows to
simultaneously exit fullscreen), whereas the hotkey did not. This had a
side-effect of preventing the display from auto re-sizing if it was
fullscreened again.  After this change, both the hotkey and the toolbar
button will unset the application-level 'fullscreen' property when
exiting fullscreen mode.

Resolves: rhbz#1022608
2014-09-26 09:20:55 -05:00
Jonathon Jongsma
804564e246 VirtViewerDisplayVnc: set 'session' property
Set the display's session property in the constructor. If the session is
not set, then virt_viewer_display_get_session() doesn't return anything
useful.
2014-09-24 10:21:22 -05:00
Jonathon Jongsma
a15bbac320 Make default window size a bit more useful
Currently, windows have a default size of 400x400 pixels. This is a
strange aspect ratio for a display, and it is also too small to be
useful for much. Since the default window size determines the initial
size of newly-enabled displays, it would be nice if we used a slightly
better size.
2014-09-24 10:21:22 -05:00
Jonathon Jongsma
29c8cadd40 Set initial window size to display desktop size
When setting the 'display' for a VirtViewerWindow, the initial size for
that window should be the size of the remote display. So we synthesize a
desktop resize event when setting a new display for a window.  This is
only done for enabled displays. Disabled displays generally have a size
of 0x0, which would result in the window being at it's minimum size, so
just allow the window to use its default size.
2014-09-24 10:21:22 -05:00