Commit Graph

1660 Commits

Author SHA1 Message Date
Yonit Halperin
b71ccec83e red_channel: on migration target, start sending ping messages only after the client's migration has completed
The connection to the target server is established before migration
starts. However, the client reads and replies to messages from the server only after
migration completes. Thus, we better not send ping msgs from the target
before migration completes (because the observed roundtrip duration will
be bigger than the real one).
2013-05-01 13:04:15 -04:00
Yonit Halperin
df26036552 red_channel: stop sending ping messages after migration has completed
We mustn't send any msg to the client, besides MSG_MIGRATE_DATA, after
we send MSG_MIGRATE.
2013-05-01 13:01:43 -04:00
Yonit Halperin
1c154ea5ec reds: fix not sending the mm-time after migration when there is no audio playback
This bug results in the client dropping all the video frames after
migration in case that (1) the hosts involved in migration have different
mm-time; and that (2) there is no audio playback.
This is relvant only for the client that was connected during the
migration.

rhbz#958276
2013-05-01 11:36:10 -04:00
Yonit Halperin
f0f8d7dd52 red_channel: fix not handling self pipe items in red_channel_client_release_item
When a client disconnects, red_channel_client_pipe_clear is called.
Releasing pipe items of type == MIGRATE||EMPTY_MSG||PING
wasn't handled, and was passed to channel_cbs.release_item.
There, an error occured since the pipe items were not recognized.
2013-04-30 14:56:35 -04:00
Hans de Goede
f7f876a3cb server: Add public spice_qxl_driver_unload method
With a SPICE_DISPLAY_CAP_MONITORS_CONFIG capable client, the client needs to
know what part of the primary to use for each monitor. If the guest driver
does not support this, the server sends messages to the client for a
single monitor spanning the entire primary.

As soon as the guest calls spice_qxl_monitors_config_async once, we set
the red_worker driver_has_monitors_config flag and stop doing this.

This is a problem when the driver gets unloaded, for example after a reboot
or when switching to a text vc with usermode mode-setting under Linux.

To reproduce this start a multi-mon capable Linux guest which uses
usermode mode-setting and then once X has started switch to a text vc. Note
how the client window does not only not resize, if you try to resize it
manually you always keep blackborders since the aspect is wrong.

This patch is the spice-server side of fixing this, it adds a new
spice_qxl_driver_unload method which clears the driver_has_monitors_config
flag.

The other patch needed to fix this is in qemu, and will calls this new method
from qxl_enter_vga_mode.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-04-24 09:31:27 +02:00
Yonit Halperin
1013b7a5e4 red_worker: assign mm_time to vga frames 2013-04-22 16:30:55 -04:00
Yonit Halperin
473d41b9f2 red_worker: increase the interval limit for stream frames 2013-04-22 16:30:55 -04:00
Yonit Halperin
1d760551ec collect and print video stream statistics 2013-04-22 16:30:55 -04:00
Yonit Halperin
167f999992 server/red_worker: add an option to supply the bandwidth via env var
SPICE_BIT_RATE can be set for supplying red_worker the available
bandwidth (in Mbps).
2013-04-22 16:30:55 -04:00
Yonit Halperin
4c79f325e2 server/red_worker.c: use the bit rate of old streams as a start point for new streams
mjpeg_encoder modify the initial bit we supply it, according to the
client feedback. If it reaches a bit rate which is higher than the
initial one, we use the higher bit rate as the new bit rate estimation.
2013-04-22 16:30:55 -04:00
Yonit Halperin
bf9e210b21 red_worker: video streams - adjust client playback latency 2013-04-22 16:30:55 -04:00
Yonit Halperin
073aeec569 reds: support mm_time latency adjustments
When there is no audio playback, we set the mm_time in the client to be older
than the one in the server by at least the requested latency (the delta is
actually bigger, due to the network latency).
When there is an audio playback, we adjust the mm_time in the client by
adjusting the playback buffer using SPICE_MSG_PLAYBACK_LATENCY.
2013-04-22 16:30:55 -04:00
Yonit Halperin
a9087c4c8a snd_worker: support sending SPICE_MSG_PLAYBACK_LATENCY
also update spice-common submodule
2013-04-22 16:30:54 -04:00
Yonit Halperin
ba1aaef0fe dispatcher.h: fix - s/#define MAIN_DISPATCHER_H/#define DISPATCHER_H 2013-04-22 16:30:54 -04:00
Yonit Halperin
23730a6c80 red_worker: ignoring video frame drops that are not due to pipe congestion
A frame can be dropped if a new frame was added during the same
call to red_process_command (we didn't attempt to send the older
frame). Such drops are ignored.
2013-04-22 16:30:54 -04:00
Yonit Halperin
ed1654eb11 red_worker: notify mjpeg_encoder on server frame drops 2013-04-22 16:30:54 -04:00
Yonit Halperin
0df9450399 red_worker: support SPICE_MSGC_DISPLAY_STREAM_REPORT
update mjpeg_encoder with reports from the client about
the playback quality.
The patch also updates the spice-common submodule.
2013-04-22 16:30:54 -04:00
Yonit Halperin
ade45ed93a red_worker: start using mjpeg_encoder rate control capabilities
This patch only employs setting the stream parameters based on
the initial given bit-rate, the latency, and the encoding size.
Later patches will also employ mjpeg_encoder response to client reports,
and its control over frame drops.

The patch also removes old stream bit rate calculations that weren't
used.
2013-04-22 16:30:54 -04:00
Yonit Halperin
b0fb03f0ae server/red_worker: enable latency monitoring in the display channel 2013-04-22 16:30:54 -04:00
Yonit Halperin
86fbcf1ddb red_worker: stream - update periodically the input frame rate
Periodically calculate the rate of frames arriving from the guest to the
server.
2013-04-22 16:30:54 -04:00
Yonit Halperin
9a62a9a809 red_channel: monitor connection latency using MSG_PING 2013-04-22 16:30:54 -04:00
Yonit Halperin
d146ae0d92 server/red_worker: assign timer callbacks to worker_core, using spice_timer_queue
display channel - supplying timeouts interface to red_channel, in order to allow
periodic latency monitoring (see next patch).
2013-04-22 16:30:54 -04:00
Yonit Halperin
e3bc219570 server: spice_timer_queue
Each thread can create a spice_timer_queue, for managing its
own timers.
2013-04-22 16:30:54 -04:00
Yonit Halperin
622d7159c2 mjpeg_encoder: add stream warmup time, in which we avoid server and client drops
The stream starts after lossless frames were sent to the client,
and without rate control (except for pipe congestion). Thus, on the beginning
of the stream, we might observe frame drops on the client and server side which
are not necessarily related to mis-estimation of the bit rate, and we would
like to wait till the stream stabilizes.
2013-04-22 16:30:53 -04:00
Yonit Halperin
ff1bde1d81 mjpeg_encoder: keep the average observed fps similar to the defined fps
The actual frames distribution does not necessarily fit the
condition "at least one frame every (1000/rate_contorl->fps)
milliseconds".
For keeping the average frame rate close to the defined fps, we
periodically measure the current average fps, and modify
rate_control->adjusted_fps accordingly. Then, we use
(1000/rate_control->adjusted_fps) as the interval between the
frames.
2013-04-22 16:30:53 -04:00
Yonit Halperin
6f883d0eb5 mjpeg_encoder: move the control over frame drops to mjpeg_encoder 2013-04-22 16:30:53 -04:00
Yonit Halperin
44ce87b55a mjpeg_encoder: update the client with estimations for the required playback latency
The required client playback latency is assessed based on the current
estimation of the bit rate, the network latency, and the encoding size
of the frames. When the playback delay that is reported by the client
seems too small, or when the stream parameters change, we send the
client an updated playback latency estimation.
2013-04-22 16:30:53 -04:00
Yonit Halperin
3bbde4b3a6 mjpeg_encoder: modify stream bit rate based on server side pipe congestion
Downgrading stream bit rate when the input frame rate in the server
exceeds the output frame rate, and frames are being dropped from the
output pipe.
2013-04-22 16:30:53 -04:00
Yonit Halperin
b490635130 mjpeg_encoder: adjust the stream bit rate based on periodic client feedback
mjpeg_encoder can receive periodic reports about the playback status on
the client side. Then, mjpeg_encoder analyses the report and can
increase or decrease the stream bit rate, depending on the report.
When the bit rate is changed, the quality and frame rate of the stream
are re-evaluated.
2013-04-22 16:30:51 -04:00
Yonit Halperin
2025494af5 mjpeg_encoder: re-configure stream parameters when the frame's encoding size changes
If the encoding size seems to get smaller/bigger, re-evaluate the
stream quality and frame rate.
2013-04-22 11:45:59 -04:00
Yonit Halperin
f68b539d70 mjpeg_encoder: configure mjpeg quality and frame rate according to a given bit rate
Previously, the mjpeg quality was always 70. The frame rate was
tuned according to the frames' congestion in the pipe.
This patch sets the quality and frame rate according to
a given bit rate and the size of the first encoded frames.

The following patches will introduce an adaptive video streaming, in which
the bit rate, the quality, and the frame rate, change in response to
different parameters.

Patches that make red_worker adopt this feature will also follow.
2013-04-22 11:45:59 -04:00
Yonit Halperin
41d7400758 server/red_worker: streams: moving mjpeg_encoder from Stream to StreamAgent
The mjpeg_encoder should be client specific, and not shared between
different clients**, for the following reasons:
(1) Since we use abbreviated jpeg datastream for mjpeg, employing the same
    mjpeg_encoder for different clients might cause errors when the
    clients decode the jpeg data.
(2) The next patch introduces bit rate control to the mjpeg_encoder.
    This feature depends on the bandwidth available, which is client
    specific.

** at least till we change multi-clients not to re-encode the same
   streams.
2013-04-22 11:45:58 -04:00
Yonit Halperin
317471fc0b red_worker: stream agent - fix miscounting of frames
Frames counting was skipped when the previous frame was already
sent completely to the client.
2013-04-22 11:45:58 -04:00
Hans de Goede
38999db39b snd_worker: Make sure we never send an empty volume message
My commit 71315b2e "snd_worker: Don't send empty audio-volume messages",
fixes only one case of sending an empty volume message, if the client connects
to a vm early during its boot sequence, while the snd hardware is being reset
by the guest driver, qemu will call spice_server_playback_set_volume() with
0 channels from the reset handler.

This patch also applies both fixes to the record channel.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-04-19 13:57:31 +02:00
Hans de Goede
bde9387804 spice-common: Update
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-04-10 12:39:32 +02:00
Yonit Halperin
c7e8198091 red_worker.c: fix not destroying streams before sending MSG_MIGRATE
When qemu migration completes, we need to stop the streams, and to send
the corresponding upgrade_items to the client.
Otherwise, (1) the client might display lossy regions that we don't track
(streams are not part of the migration data).
(2) streams_timeout may occur after MSG_MIGRATE has been sent, leading
to messages being sent to the client after MSG_MIGRATE and before
MSG_MIGRATE_DATA (e.g., STREAM_CLIP, STREAM_DESTROY, DRAW_COPY).
No message besides MSG_MIGRATE_DATA should be sent after
MSG_MIGRATE.

When a msg other than MIGRATE_DATA reached spice-gtk after MSG_MIGRATE,
spice-gtk sent it to dest server as the migration data, and the dest
server crashed with a "bad message size" assert.
2013-04-08 16:16:05 -04:00
Yonit Halperin
21123f34e7 red_worker.c: s/red_display_destroy_streams/red_display_destroy_streams_agents
In order not to confuse it with red_destroy_streams in the following
patch.
2013-04-08 16:15:27 -04:00
Hans de Goede
71315b2e09 snd_worker: Don't send empty audio-volume messages
If no volume has been set it, we end up sending a volume message with
audio-volume for 0 channels (iow an empty message). This is not useful
and triggers the following warning in spice-gtk:

(remote-viewer:8726): GSpice-WARNING **: set_sink_input_volume() failed:
Invalid argument

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-04-01 22:10:55 +02:00
Hans de Goede
baa7cab700 char_device: Don't set active when stopped and don't access dev after unref
2 closely related changes in one:
1) When leaving the read or write loop because the chardev has been stopped
active should not be updated. It has been set to FALSE by
spice_char_device_stop and should stay FALSE
2) The updating of dev->active should be done *before* unref-ing dev

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-03-29 10:07:26 +01:00
Hans de Goede
3d775594b5 char_device: Don't set the write-retry timer when not running
The write-retry timer should not be set when we're leaving
spice_char_device_write_to_device because the char-dev has been stopped.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-03-29 10:05:24 +01:00
Hans de Goede
e3c6f793f7 char_device: Properly update buffer status when leaving the write loop on stop
Before this patch the write-loop in spice_char_device_write_to_device would
break on running becoming 0, after having written some data, without updating
the buffer status, causing the same data to be written *again* when started.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-03-29 10:05:11 +01:00
Hans de Goede
25f84a2d6e inputs-channel: Don't send insecure keyb notify to in migrate client
This fixes spice-gtk printing message like these on migration:
(remote-viewer:18402): GSpice-CRITICAL **: spice_channel_iterate_read: assertion `c->state != SPICE_CHANNEL_STATE_MIGRATING' failed

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-03-15 09:44:50 +01:00
Hans de Goede
8d44aa0328 inputs-channel: Handle printing of insecure keyboard notify
This is clearly something which should be handled in the inputs_channel code,
rather then having a special case for it in the generic channel handling
code in reds.c. Moving it here also fixes the TODO we had on only sending
this message to new clients.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-03-15 09:44:50 +01:00
Hans de Goede
0711a4a464 main-channel: Add a main_channel_client_push_notify function
Sometimes we want to send a notify to a single client, rather then to
all of them.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-03-15 09:44:50 +01:00
Hans de Goede
3a2f42555d main-channel: Make main_channel_push_notify deal with dynamic memory
Currently main_channel_push_notify only gets passed a static string, but
chances are in the future it may get passed dynamically allocated strings,
prepare it for this.

While at it also make clear that its argument is a string, and simplify
things a bit by making use of this knowledge (pushing the strlen call down).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-03-15 09:44:26 +01:00
Hans de Goede
89d2a68cb7 server/reds: Send the agent a CLIENT_DISCONNECTED msg on client disconnect
Client -> agent messages can spawn multiple VDIChunks. When this happens
the agent re-assembles the chunks into a complete VDAgentMessage before
processing it. The server only guarentees coherency at the chunk level,
so it is not possible for a partial chunk to get delivered to the agent.

But it is possible for some chunks of a VDAgentMessage to be delivered to
the agent followed by a client to disconnect without the rest of the
VDAgentMessage being delivered!

This will leave the agent in a wrong state, and the first messages send to it
by the next client to connect will get seen as the rest of the VDAgentMessage
from the previous client.

This patch sends the agent a new VD_AGENT_CLIENT_DISCONNECTED message from the
VDP_SERVER_PORT, on which the agent can then reset its VDP_CLIENT_PORT state.

Note that no capability check is done for this, since the capabilities are
something negotiated between client and agent. The server will simply always
send this message on client disconnect, relying on older agents discarding the
message since it has an unknown type (which both the windows and linux agents
already do).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-03-07 11:52:23 +01:00
Hans de Goede
4476c99452 char_device: Add spice_char_device_write_buffer_get_server_no_token()
To allow the server to send agent messages without needing to wait for a
self-token. IE for sending VD_AGENT_CLIENT_DISCONNECTED messages.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-03-07 11:52:23 +01:00
Hans de Goede
e67e47fb33 Update spice-common
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-03-07 11:52:23 +01:00
Hans de Goede
b42f2e1fc9 Silence __spice_char_device_write_buffer_get: internal buf is not available
These messages are printed when the server tries to push a mouse event to
the agent before the previous one has been flushed. This is a normal condition
(which gets tracked by the reds->pending_mouse_event boolean), and as such
it should *not* trigger the printing of error messages.

I've seen these messages occasionally before, but with agent file-xfer they
are trivial to trigger, simply send a large file to the agent and while it
is transferring move the mouse over the client window. Note that due to the
client tokens not allowing the client to completely saturate the agent
channel mouse events do still get send to the agent, just with a slightly
larger interval. So everything is working as designed and this spice_printerr
is just leading to people chasing ghosts.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-03-04 16:35:54 +01:00
Hans de Goede
50efe1e48d worker_update_monitors_config: Drop bogus real_count accounting
1) This does not buy us much, as red_marshall_monitors_config() also
   removes 0x0 sized monitors and does a much better job at it
   (also removing intermediate ones, not only tailing ones)
2) The code is wrong, as it allocs space for real_count heads, where
   real_count always <= monitors_config->count and then stores
   monitors_config->count in worker->monitors_config->count, causing
   red_marshall_monitors_config to potentially walk
   worker->monitors_config->heads past its boundaries.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-01-15 14:30:59 +01:00