Commit Graph

1165 Commits

Author SHA1 Message Date
Yonit Halperin
aefe01c02c Release 0.9.2 2011-11-02 11:30:33 +02:00
Yonit Halperin
c39d842ff1 client: support semi-seamless migration between spice servers with different protocols.
It can't actually happen right now, since switch-host migration scheme will take
place if the src/target server has protocol 1.
(cherry picked from commit 4b2bf4d88c branch 0.8)
2011-11-02 11:30:31 +02:00
Yonit Halperin
3a1473760c client: display channel - destroy all surfaces on disconnect
Fix not destroying surfaces and other data (e.g., streams) upon disconnection.
(cherry picked from commit 010b22cd77 branch 0.8)
2011-11-02 11:30:30 +02:00
Yonit Halperin
00ff038cc9 client: display channel migration
(cherry picked from commit cad3c58544 branch 0.8)

Conflicts:

	client/display_channel.cpp
2011-11-02 11:30:29 +02:00
Yonit Halperin
87664af999 client: playback/record channels: implement on_disconnect
(cherry picked from commit d3ed9d5e9d branch 0.8)
2011-11-02 11:30:27 +02:00
Yonit Halperin
0a5e9cbbcf client: main channel migration: do partial cleanup when switching hosts
Implement on_disconnect_mig_src and on_connect_mig_target in order to avoid
unnecessary cleanups done in on_(disconnet|connect).
In addition, do not request guest display settings changes after migration.
(cherry picked from commit f91d202eb3 branch 0.8)
2011-11-02 11:30:26 +02:00
Yonit Halperin
c73d5c10e6 client: handle SPICE_MSG_MAIN_MIGRATE_END
(1) disconnect all channels from the migration src
(2) after all channels are disconnected, clean global resources
(3) send SPICE_MSGC_MAIN_MIGRATE_END to migration target
(4) wait for SPICE_MSG_MAIN_INIT
(4) switch all channels to migration target
(cherry picked from commit 510a4ff7c4 branch 0.8)

Conflicts:

	client/red_channel.h
2011-11-02 11:30:24 +02:00
Yonit Halperin
6cd3ffba6f client: handle SpiceMsgMainMigrationBegin (semi-seamless migration)
RHBZ 725009, 738270
(cherry picked from commit 31ed2519a7 branch 0.8)

Conflicts:

	client/red_client.cpp
2011-11-02 11:30:23 +02:00
Yonit Halperin
f22caf9aee client: rewrite surfaces cache
use std::map instead of a specific template (CHash).
There is no need for special template. Moreover, using
std::map will allow easy iteration over the surfaces.
(cherry picked from commit fcb3b4ce52 branch 0.8)

Conflicts:

	client/display_channel.cpp
2011-11-02 11:30:21 +02:00
Yonit Halperin
7696657174 server: turn spice_server_migrate_start into a valid call
We will add a qemu call to spice_server_migrate_start when migration starts.
For now, it does nothing, but we may need this notification in the future.
(cherry picked from commit b821316771 branch 0.8)
2011-11-02 11:30:18 +02:00
Yonit Halperin
f683815ad5 server: handling semi-seamless migration in the target side
(1) not sending anything to a migrated client till we recieve SPICE_MSGC_MIGRATE_END
(2) start a new client migration (handle client_migrate_info) only after SPICE_MSGC_MIGRATE_END
    from the previous migration was received for this client
(3) use the correct ticket

Note: we assume the same channles are linked before and ater migration. i.e.,
      SPICE_MSGC_MAIN_ATTACH_CHANNELS is not sent from the clients.
2011-11-02 11:25:59 +02:00
Yonit Halperin
c88e927fc7 server: move the linking of channels to a separate routine 2011-11-02 11:21:58 +02:00
Yonit Halperin
e62521ca51 server: handle spice_server_migrate_end
If the migration has completed successfully:
(1) send MSG_MAIN_MIGRATE_END to the clients that are connected to the target
(2) send MSG_MAIN_SWITCH_HOST to all the other clients

If the migration failed, send MSG_MAIN_MIGRATE_CANCEL to clients that are
connected to the target.

(cherry picked from commit 4b82580fc3 branch 0.8;
 Was modified to support multiple clients, and the separation of main_channel from reds)

Conflicts:

	server/reds.c
2011-11-02 11:21:41 +02:00
Yonit Halperin
fdb464bb05 spice.proto: add SPICE_MSG_MAIN_MIGRATE_END & SPICE_MSGC_MAIN_MIGRATE_END
(cherry picked from commit cfbd077105 branch 0.8)
2011-11-02 11:21:19 +02:00
Yonit Halperin
70d1161430 server,proto: tell the clients to connect to the migration target before migraton starts
(1) send SPICE_MSG_MAIN_MIGRATE_BEGIN upon spice_server_migrate_connect
    (to all the clients that support it)
(2) wait for SPICE_MSGC_MAIN_MIGRATE_(CONNECTED|CONNECT_ERROR) from all the relevant clients,
    or a timeout, in order to complete client_migrate_info monitor command
(cherry picked from commit 5560c56ef0 branch 0.8;
 Was modified to support the separation of main channel from reds, and multiple clients)

Conflicts:

	server/reds.c
2011-11-02 11:21:08 +02:00
Yonit Halperin
fc3aa53211 configure: spice-protocol >= 0.9.1 (semi-seamless migration protocol)
(cherry picked from commit 55ccc022ec branch 0.8)

Conflicts:

	configure.ac
2011-11-02 11:20:38 +02:00
Yonit Halperin
38a96b4084 server: handle migration interface addition
(cherry picked from commit 3ac0075cda branch 0.8)

Conflicts:

	server/reds.h
2011-11-02 11:20:25 +02:00
Yonit Halperin
cd402151de server/spice.h: semi-seamless migration interface, RHBZ #738266
semi-seamless migration details:

migration source side
---------------------
(1) spice_server_migrate_connect (*): tell client to link
    to the target side - send SPICE_MSG_MAIN_MIGRATE_BEGIN.
    This should be called upon client_migrate_info cmd.
    client_migrate_info is asynchronous.
(2) Complete spice_server_migrate_connect only when the client has been connected
    to the target - wait for SPICE_MSGC_MAIN_MIGRATE_(CONNECTED|CONNECT_ERROR) or a timeout.
(3) spice_server_migrate_end: tell client migration it can switch to the target - send
    SPICE_MSG_MAIN_MIGRATE_END.
(4) client cleans up all data related to the connection to the source and switches to the target.
    It sends SPICE_MSGC_MAIN_MIGRATE_END.

migration target side
---------------------
(1) the server identifies itself as a migraiton target since the client is linked with (connection_id != 0)
(2) server doesn't start the channels' logic (channel->link) till it receives SPICE_MSGC_MAIN_MIGRATE_END
    from the client.

*   After migration starts, the target qemu is blocked and cannot accept new spice client
    connections. Thus, we trigger the connection to the target upon client_migrate_info
    command.
(cherry picked from commit 6e56bea67c branch 0.8)

Conflicts:

	server/spice.h
2011-11-02 11:20:08 +02:00
Yonit Halperin
0bf518cd3d server: set & test channel capabilities in red_channel
The code for setting and testing channel capabilities was
unnecessarily duplicated. Now it is in red_channel.
RedsChannel was dropped from Reds; It was used only for holding
the channels common capabilities, which are now held in RedChannel.
2011-11-02 11:19:48 +02:00
Alon Levy
bd8771adbc [0.8 branch] server: add main_dispatcher
add main_dispatcher, a message passing mechanism for sending messages to
the main thread. The main thread is the thread that implements
SpiceCoreInterface, which is assumed to be a single thread.

Similar to the async operation of red_worker, a socket pair is created
and used to pass messages. The messages are a fixed size to ease
parsing. A single message is defined to pass a channel_event.

RHBZ: 746950
FDBZ: 41858

This patch is 0.8 branch only, for the master branch there should be a
better approach to share code with red_dispatcher and ready the way for
later adding more threads.

cherry-pick from 0.8 80caf07e09

Conflicts:

	server/reds.c
2011-10-31 17:35:54 +02:00
Liang Guo
edb91ccc09 spice-server.pc.in: move Requires to Requires.private
When using pkg-config, Requires and Requires.private field list
packages required by this package, but packages listed under
Requires.private are not taken into account when a flag list is
computed for dynamically linked executable. In the situation
where each .pc file corresponds to a library, Requires.private
shall be used exclusively to specify the dependencies between
the libraries.
2011-10-23 11:26:30 +02:00
Yonit Halperin
86576aec6a server/red_worker: fix placing of ASSERT(red_channel_client_no_item_being_sent) (fdbz #41523)
Call ASSERT(red_channel_client_no_item_being_sent) only if
red_wait_outgoing_item/s did not timeout.
2011-10-18 15:16:46 +02:00
Christophe Fergeau
bc9306852d client/x11: reset screen positions in XMonitor::do_restore
XMonitor::do_restore (called for example when going out of
fullscreen) restore the screen resolution to its previous state,
but it doesn't take care of repositioning the screen to their
previous position, which is one of the advantages of using randr
1.2.
Since MultyMonScreen::restore handles all of this for us, just call
it to restore the monitor position/resolutions to their previous
settings. Before doing any changes, MultyMonScreen::restore checks
if there's something to do, so calling it once per monitor won't be
an issue, the resolution/position will only be set the first time.

This has the side-effect of fixing bug #693431. This bug occurs when
closing the client after the client went in and out of fullscreen.
MultyMonScreen::~MultyMonScreen calls MultyMonScreen::restore, which
decides to change the screen positions since they were lost when going
to fullscreen because XMonitor::restore didn't restore the positions.
After this change, the positions will be properly restored and
MultyMonScreen::restore won't be needlessly called upon client
shutdown.
2011-10-05 15:09:48 +02:00
Christophe Fergeau
e3e04b0a2a client/x11: fix mode setting in MultyMonScreen::restore
MultyMonScreen::restore changes the X11 Screen resolution, but it
doesn't use MultyMonScreen::set_size. This means
MultyMonScreen::_width and MultyMonScreen::_height don't get
updated to reflect the new resolution settings, which could cause
issues later on. Until now this was safe since the only caller of
MultyMonScreen::restore was MultyMonScreen destructor.
2011-10-05 15:09:47 +02:00
Christophe Fergeau
ae3e63a9d8 client/x11: fix typos (finde => find) 2011-10-05 15:09:46 +02:00
Christophe Fergeau
45ef140e23 client: fix typo commnad=>command 2011-09-20 14:51:45 +02:00
Christophe Fergeau
26e172e4be client: don't crash when booting a Xinerama setup
In a Xinerama setup, when X starts up and creates one of the
secondary screens, first a non-primary surface is created on the
secondary screen, and then the primary surface for this screen is
created.
This causes a crash when the guest uses Xinerama and the client
is attached to the VM before X starts (ie while the guest is
booting).
This happens because DisplayChannel::create_canvas (which is called
when creating a non-primary surface) assumes a screen has already been
set for the DisplayChannel while this only happens upon primary surface
creation. However, it uses the screen for non important stuff, so we
can test if screen() is non NULL before using it. This is what is done
in other parts of this file.

Fixes rhbz #732423
2011-09-19 18:33:33 +02:00
Christophe Fergeau
6a20050352 replace warning with comment in glz_usr_free_image
When running some xinerama tests, I got several
glz_usr_free_image: error
messages. Looking at the code, this error is reported when this
function is called from a different DisplayChannelClient than the
one which created the glz compressed image.
When this happens, the backtrace is
    at glz_encoder_dictionary.c:362
    0x7fff940b6670) at glz_encoder_dictionary.c:449
    image_type=LZ_IMAGE_TYPE_RGB32, image_width=512, image_height=256, image_stride=2048, first_lines=0x0,
    num_first_lines=0, usr_image_context=0x7fff7420da40, image_head_dist=0x7fff9b2a3194)
    at glz_encoder_dictionary.c:570
    top_down=4, lines=0x0, num_lines=0, stride=2048, io_ptr=0x7fff740ea7c0 "  ZL", num_io_bytes=65536, usr_context=
    0x7fff7420da40, o_enc_dict_context=0x7fff7420da60) at glz_encoder.c:255
    drawable=0x7fff9b46bc08, o_comp_data=0x7fff9b2a3350) at red_worker.c:5753
    0x7fff9b46bc08, can_lossy=0, o_comp_data=0x7fff9b2a3350) at red_worker.c:6211
    0x7fff9b46bc08, can_lossy=0) at red_worker.c:6344
    0x7fff74085c50, dpi=0x7fff7445b890, src_allowed_lossy=0) at red_worker.c:7046
    0x7fff7445b890) at red_worker.c:7720
    at red_worker.c:7964
    at red_worker.c:8431

Since the glz dictionary is shared between all the
DisplayChannelClient instances that belong to the same client, it can
happen that the glz dictionary code decides to free an image from one
thread while it was added from another thread (thread ==
DisplayChannelClient), so the error message that is printed is not an
actual error. This commit removes this message and adds a comment
explaining what's going on.
2011-09-19 18:33:32 +02:00
Christophe Fergeau
a20e6bb012 fix typos
applicaion => application
Attache => Attach
Detache => Detach
_layes => _layers
2011-09-15 10:24:45 +02:00
Christophe Fergeau
011266555a server: fix function prototypes
Several functions in server/ were not specifying an argument list,
ie they were declared as void foo(); When compiling with
-Wstrict-prototypes, this leads to:
test_playback.c:93:5: erreur: function declaration isn’t a prototype
[-Werror=strict-prototypes]
2011-09-05 07:52:20 +02:00
Marc-André Lureau
7e1c773325 fix bug #692833 2011-09-01 03:58:01 +02:00
Christophe Fergeau
6a718d9b0d add C++ guards to backtrace.h
Without these, spice_backtrace() can't be used from the C++ client
code.
2011-09-01 03:58:01 +02:00
Christophe Fergeau
41174221fb server: init all fields on SpiceMsgDisplayStreamCreate
red_display_marshall_stream_start initializes a
SpiceMsgDisplayStreamCreate structure before marshalling it and
sending it on the wire. However, it never fills
SpiceMsgDisplayStreamCreate::stamp which then causes a complaint
from valgrind. This patch sets this value to 0, it's not used
by the client so the value shouldn't matter.
2011-09-01 03:57:35 +02:00
Christophe Fergeau
a26f5714e4 fix valgrind warning in test_display__stream
create_test_primary_surface::test_display_base.c creates a
QXLDevSurfaceCreate structure and initialize it, but doesn't set
the position field. Moreover, this structure has 4 bytes of padding
to the end (as shown by pahole from dwarves), so initialize the whole
structure to 0 before using it.
2011-09-01 03:57:35 +02:00
Hans de Goede
b4c14b3bd8 Fixup NEWS entry for multiclient 2011-08-25 15:44:29 +02:00
Hans de Goede
75dacb8d62 Release 0.9.1 2011-08-25 14:55:52 +02:00
Hans de Goede
731c44d752 fix more inverted memset parameters
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-08-25 14:55:39 +02:00
Christophe Fergeau
8c9404374a fix leak in do_jpeg_encode
Issue found by the Coverity scanner.

HDG: Fixup don't free RGB24_line if it was not allocated by do_jpeg_encode

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-08-25 14:48:01 +02:00
Christophe Fergeau
a09052b83c fix memory leak in error path
Issue found by the Coverity scanner
2011-08-25 14:37:08 +02:00
Christophe Fergeau
2abd83c203 fix inverted memset parameters
Issue found by the Coverity scanner.
2011-08-25 14:37:08 +02:00
Hans de Goede
c030382abb Rename usbredir channel code to spicevmc
While discussing various things with Alon in Vancouver, it came up that
having a channel which simply passes through data coming out of a qemu
chardev frontend unmodified, like the usbredir channel does, can be used
for a lot of other cases too. To facilitate this the usbredir channel code
will be turned into a generic spicevmc channel, which is just a passthrough
to the client, from the spicevmc chardev.

This patch renames usbredir.c to spicevmc.c and changes the prefix of all
functions / structs to match. This should make clear that the code is not
usbredir specific.

Some examples of why having a generic spicevmc pass through is good:
1) We could add a monitor channel, allowing access to the qemu monitor from
the spice client, since the monitor is a chardev frontend we could re-use
the generic spicevmc channel server code, so all that is needed to add this
(server side) would be reserving a new channel id for this.

2) We could allow users to come up with new channels of their own, without
requiring qemu or server modification. The idea is to allow doing something
like this on the qemu startup cmdline:
-chardev spicevmc,name=generic,channelid=128

To ensure these new "generic" channels cannot conflict with newly added
official types, they must start at the SPICE_CHANNEL_USER_DEFINED_START value
(128).

These new user defined channels could then either be used with a special
modified client, with client plugins (if we add support for those), or
by exporting them on the client side for use by an external ap, see below.

3) We could also add support to the client to make user-defined channels
end in a unix socket / pipe, allowing handling of the data by an external app,
we could for example have a new spice client cmdline argument like this:
--custom-channel unixsocket=/tmp/mysocket,channelid=128

This would allow for something like:
$random app on guest -> virtio-serial -> spicevmc chardev ->
 -> spicevmc channel -> unix socket -> $random app on client

4) On hind sight this could also have been used for the smartcard stuff,
with a 1 channel / reader model, rather then the current multiplexing code
where we've our own multiplexing protocol wrapper over the libcacard
smartcard protocol.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-08-25 14:04:27 +02:00
Hans de Goede
073cf20ac5 usbredir: Merge UsbRedirState and UsbRedirChannel
Now that the Channel struct is gone and the RedChannel has the same lifetime
as the chardev interface there is no need to have these 2 separate.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-08-25 14:04:27 +02:00
Hans de Goede
22a6eef60d usbredir: Fix crash caused by MC changes
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-08-25 14:04:27 +02:00
Hans de Goede
e1570ce519 usbredir: Ensure that our msg_rcv_buf is not used re-entrantly
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-08-25 14:04:27 +02:00
Hans de Goede
e9d6e86fc8 red_channel: Fix msg buf memleak on parser error
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2011-08-25 14:04:27 +02:00
Yonit Halperin
c5b6bacee1 client: setting monitors resolution before resizing screens, RHBZ #728252
fix for "client: fix endless recursion in rearrange_monitors, RHBZ #692976"
2011-08-25 14:27:24 +03:00
Alon Levy
51ac99dbf4 server: add tester and todo for multiple client support 2011-08-23 19:18:23 +03:00
Alon Levy
0b169b7014 server/snd_worker.c: add reference counting to SndChannel
Fixes a valgrind discovered possible bug in spice-server - valgrind on
test_playback saw it, didn't see it happen with qemu.

The problem is that the frames buffers returned by spice_server_playback_get_buffer
are part of the malloc'ed SndChannel, whose lifetime is smaller then that of SndWorker.
As a result a pointer to a previously returned spice_server_playback_get_buffer could
remain and be used after SndChannel has been freed because the client disconnected.
2011-08-23 18:30:26 +03:00
Alon Levy
1078dc04ed server/reds: reds_client_disconnect: remove wrong check for reds_main_channel_connected
The "channel->disconnecting" parameter already protects against recursion.

Removed fixed TODOs.
2011-08-23 18:30:06 +03:00
Alon Levy
f15cac7d7d server/reds: fix reds_main_channel_connected
instead of checking just for reds->main_channel check that there is at least
one client as well.
2011-08-23 18:29:45 +03:00