summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2012-03-14 19:34:35 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2012-03-25 19:00:00 +0200
commitb34fd7432d61b992446a3cd9c6f8eb7747ba0a76 (patch)
tree60a5b34a3e37177ea6a54da9fd8d2b475bfe9257
parent359fc1cb5dbbcf32132c3e8ee6f881a23deff684 (diff)
Use the spice-common logging functions
It will abort by default for critical level messages. That behaviour can be tuned at runtime.
-rw-r--r--.gitignore1
-rw-r--r--server/agent-msg-filter.c8
-rw-r--r--server/dispatcher.c34
-rw-r--r--server/inputs_channel.c34
-rw-r--r--server/jpeg_encoder.c14
-rw-r--r--server/main_channel.c66
-rw-r--r--server/mjpeg_encoder.c2
-rw-r--r--server/red_channel.c96
-rw-r--r--server/red_client_cache.h4
-rw-r--r--server/red_client_shared_cache.h8
-rw-r--r--server/red_dispatcher.c37
-rw-r--r--server/red_memslots.c28
-rw-r--r--server/red_parse_qxl.c45
-rw-r--r--server/red_tunnel_worker.c240
-rw-r--r--server/red_worker.c602
-rw-r--r--server/red_worker.h4
-rw-r--r--server/reds.c448
-rw-r--r--server/smartcard.c24
-rw-r--r--server/snd_worker.c98
-rw-r--r--server/spicevmc.c6
-rw-r--r--server/zlib_encoder.c16
21 files changed, 907 insertions, 908 deletions
diff --git a/.gitignore b/.gitignore
index 6c15c13..e66f617 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,3 +23,4 @@ Makefile
Makefile.in
spice-server.pc
stamp-h1
+INSTALL
diff --git a/server/agent-msg-filter.c b/server/agent-msg-filter.c
index 71ff49b..7584b52 100644
--- a/server/agent-msg-filter.c
+++ b/server/agent-msg-filter.c
@@ -39,7 +39,7 @@ int agent_msg_filter_process_data(struct AgentMsgFilter *filter,
struct VDAgentMessage msg_header;
if (len > VD_AGENT_MAX_DATA_SIZE) {
- red_printf("invalid agent message: too large");
+ spice_printerr("invalid agent message: too large");
return AGENT_MSG_FILTER_PROTO_ERROR;
}
@@ -47,7 +47,7 @@ int agent_msg_filter_process_data(struct AgentMsgFilter *filter,
if (filter->msg_data_to_read) {
data_to_read:
if (len > filter->msg_data_to_read) {
- red_printf("invalid agent message: data exceeds size from header");
+ spice_printerr("invalid agent message: data exceeds size from header");
return AGENT_MSG_FILTER_PROTO_ERROR;
}
filter->msg_data_to_read -= len;
@@ -55,14 +55,14 @@ data_to_read:
}
if (len < sizeof(msg_header)) {
- red_printf("invalid agent message: incomplete header");
+ spice_printerr("invalid agent message: incomplete header");
return AGENT_MSG_FILTER_PROTO_ERROR;
}
memcpy(&msg_header, data, sizeof(msg_header));
len -= sizeof(msg_header);
if (msg_header.protocol != VD_AGENT_PROTOCOL) {
- red_printf("invalid agent protocol: %u", msg_header.protocol);
+ spice_printerr("invalid agent protocol: %u", msg_header.protocol);
return AGENT_MSG_FILTER_PROTO_ERROR;
}
diff --git a/server/dispatcher.c b/server/dispatcher.c
index c15a7a1..cc20f89 100644
--- a/server/dispatcher.c
+++ b/server/dispatcher.c
@@ -27,14 +27,12 @@
#include <fcntl.h>
#include <poll.h>
+#define SPICE_LOG_DOMAIN "SpiceDispatcher"
+
#include "common/mem.h"
#include "common/spice_common.h"
-
#include "dispatcher.h"
-#define DISPATCHER_DEBUG_PRINTF(level, ...) \
- red_printf_debug(level, "DISP", ##__VA_ARGS__)
-
//#define DEBUG_DISPATCHER
#ifdef DEBUG_DISPATCHER
@@ -64,10 +62,10 @@ static int read_safe(int fd, void *buf, size_t size, int block)
if (!block) {
while ((ret = poll(&pollfd, 1, 0)) == -1) {
if (errno == EINTR) {
- DISPATCHER_DEBUG_PRINTF(3, "EINTR in poll");
+ spice_debug("EINTR in poll");
continue;
}
- red_error("poll failed");
+ spice_error("poll failed");
return -1;
}
if (!(pollfd.revents & POLLIN)) {
@@ -78,13 +76,13 @@ static int read_safe(int fd, void *buf, size_t size, int block)
ret = read(fd, buf + read_size, size - read_size);
if (ret == -1) {
if (errno == EINTR) {
- DISPATCHER_DEBUG_PRINTF(3, "EINTR in read");
+ spice_debug("EINTR in read");
continue;
}
return -1;
}
if (ret == 0) {
- red_error("broken pipe on read");
+ spice_error("broken pipe on read");
return -1;
}
read_size += ret;
@@ -105,7 +103,7 @@ static int write_safe(int fd, void *buf, size_t size)
ret = write(fd, buf + written_size, size - written_size);
if (ret == -1) {
if (errno != EINTR) {
- DISPATCHER_DEBUG_PRINTF(3, "EINTR in write\n");
+ spice_debug("EINTR in write");
return -1;
}
continue;
@@ -124,7 +122,7 @@ static int dispatcher_handle_single_read(Dispatcher *dispatcher)
uint32_t ack = ACK;
if ((ret = read_safe(dispatcher->recv_fd, &type, sizeof(type), 0)) == -1) {
- red_printf("error reading from dispatcher: %d", errno);
+ spice_printerr("error reading from dispatcher: %d", errno);
return 0;
}
if (ret == 0) {
@@ -133,19 +131,19 @@ static int dispatcher_handle_single_read(Dispatcher *dispatcher)
}
msg = &dispatcher->messages[type];
if (read_safe(dispatcher->recv_fd, payload, msg->size, 1) == -1) {
- red_printf("error reading from dispatcher: %d", errno);
+ spice_printerr("error reading from dispatcher: %d", errno);
/* TODO: close socketpair? */
return 0;
}
if (msg->handler) {
msg->handler(dispatcher->opaque, (void *)payload);
} else {
- red_printf("error: no handler for message type %d", type);
+ spice_printerr("error: no handler for message type %d", type);
}
if (msg->ack == DISPATCHER_ACK) {
if (write_safe(dispatcher->recv_fd,
&ack, sizeof(ack)) == -1) {
- red_printf("error writing ack for message %d", type);
+ spice_printerr("error writing ack for message %d", type);
/* TODO: close socketpair? */
}
} else if (msg->ack == DISPATCHER_ASYNC && dispatcher->handle_async_done) {
@@ -177,20 +175,20 @@ void dispatcher_send_message(Dispatcher *dispatcher, uint32_t message_type,
msg = &dispatcher->messages[message_type];
pthread_mutex_lock(&dispatcher->lock);
if (write_safe(send_fd, &message_type, sizeof(message_type)) == -1) {
- red_printf("error: failed to send message type for message %d",
+ spice_printerr("error: failed to send message type for message %d",
message_type);
goto unlock;
}
if (write_safe(send_fd, payload, msg->size) == -1) {
- red_printf("error: failed to send message body for message %d",
+ spice_printerr("error: failed to send message body for message %d",
message_type);
goto unlock;
}
if (msg->ack == DISPATCHER_ACK) {
if (read_safe(send_fd, &ack, sizeof(ack), 1) == -1) {
- red_printf("error: failed to read ack");
+ spice_printerr("error: failed to read ack");
} else if (ack != ACK) {
- red_printf("error: got wrong ack value in dispatcher "
+ spice_printerr("error: got wrong ack value in dispatcher "
"for message %d\n", message_type);
/* TODO handling error? */
}
@@ -259,7 +257,7 @@ void dispatcher_init(Dispatcher *dispatcher, size_t max_message_type,
#endif
dispatcher->opaque = opaque;
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, channels) == -1) {
- red_error("socketpair failed %s", strerror(errno));
+ spice_error("socketpair failed %s", strerror(errno));
return;
}
pthread_mutex_init(&dispatcher->lock, NULL);
diff --git a/server/inputs_channel.c b/server/inputs_channel.c
index da4c53c..ad247f4 100644
--- a/server/inputs_channel.c
+++ b/server/inputs_channel.c
@@ -115,7 +115,7 @@ int inputs_inited(void)
int inputs_set_keyboard(SpiceKbdInstance *_keyboard)
{
if (keyboard) {
- red_printf("already have keyboard");
+ spice_printerr("already have keyboard");
return -1;
}
keyboard = _keyboard;
@@ -126,7 +126,7 @@ int inputs_set_keyboard(SpiceKbdInstance *_keyboard)
int inputs_set_mouse(SpiceMouseInstance *_mouse)
{
if (mouse) {
- red_printf("already have mouse");
+ spice_printerr("already have mouse");
return -1;
}
mouse = _mouse;
@@ -137,7 +137,7 @@ int inputs_set_mouse(SpiceMouseInstance *_mouse)
int inputs_set_tablet(SpiceTabletInstance *_tablet)
{
if (tablet) {
- red_printf("already have tablet");
+ spice_printerr("already have tablet");
return -1;
}
tablet = _tablet;
@@ -152,7 +152,7 @@ int inputs_has_tablet(void)
void inputs_detach_tablet(SpiceTabletInstance *_tablet)
{
- red_printf("");
+ spice_printerr("");
tablet = NULL;
}
@@ -166,7 +166,7 @@ void inputs_set_tablet_logical_size(int x_res, int y_res)
const VDAgentMouseState *inputs_get_mouse_state(void)
{
- ASSERT(g_inputs_channel);
+ spice_assert(g_inputs_channel);
return &g_inputs_channel->mouse_state;
}
@@ -177,7 +177,7 @@ static uint8_t *inputs_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
InputsChannel *inputs_channel = SPICE_CONTAINEROF(rcc->channel, InputsChannel, base);
if (size > RECEIVE_BUF_SIZE) {
- red_printf("error: too large incoming message");
+ spice_printerr("error: too large incoming message");
return NULL;
}
return inputs_channel->recv_buf;
@@ -291,7 +291,7 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
InputsChannelClient *icc = (InputsChannelClient *)rcc;
uint8_t *buf = (uint8_t *)message;
- ASSERT(g_inputs_channel == inputs_channel);
+ spice_assert(g_inputs_channel == inputs_channel);
switch (type) {
case SPICE_MSGC_INPUTS_KEY_DOWN: {
SpiceMsgcKeyDown *key_up = (SpiceMsgcKeyDown *)buf;
@@ -333,7 +333,7 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
if (reds_get_mouse_mode() != SPICE_MOUSE_MODE_CLIENT) {
break;
}
- ASSERT((reds_get_agent_mouse() && reds_has_vdagent()) || tablet);
+ spice_assert((reds_get_agent_mouse() && reds_has_vdagent()) || tablet);
if (!reds_get_agent_mouse() || !reds_has_vdagent()) {
SpiceTabletInterface *sif;
sif = SPICE_CONTAINEROF(tablet->base.sif, SpiceTabletInterface, base);
@@ -425,7 +425,7 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
case SPICE_MSGC_DISCONNECTING:
break;
default:
- red_printf("unexpected type %d", type);
+ spice_printerr("unexpected type %d", type);
return FALSE;
}
return TRUE;
@@ -451,7 +451,7 @@ static void inputs_channel_on_disconnect(RedChannelClient *rcc)
static void inputs_migrate(RedChannelClient *rcc)
{
- ASSERT(g_inputs_channel == (InputsChannel *)rcc->channel);
+ spice_assert(g_inputs_channel == (InputsChannel *)rcc->channel);
red_channel_client_pipe_add_type(rcc, PIPE_ITEM_MIGRATE);
}
@@ -473,7 +473,7 @@ static int inputs_channel_config_socket(RedChannelClient *rcc)
if (setsockopt(stream->socket, IPPROTO_TCP, TCP_NODELAY,
&delay_val, sizeof(delay_val)) == -1) {
if (errno != ENOTSUP && errno != ENOPROTOOPT) {
- red_printf("setsockopt failed, %s", strerror(errno));
+ spice_printerr("setsockopt failed, %s", strerror(errno));
return FALSE;
}
}
@@ -492,10 +492,10 @@ static void inputs_connect(RedChannel *channel, RedClient *client,
{
InputsChannelClient *icc;
- ASSERT(g_inputs_channel);
- ASSERT(channel == &g_inputs_channel->base);
+ spice_assert(g_inputs_channel);
+ spice_assert(channel == &g_inputs_channel->base);
- red_printf("inputs channel client create");
+ spice_printerr("inputs channel client create");
icc = (InputsChannelClient*)red_channel_client_create(sizeof(InputsChannelClient),
channel,
client,
@@ -530,7 +530,7 @@ void inputs_init(void)
ChannelCbs channel_cbs = { NULL, };
ClientCbs client_cbs = { NULL, };
- ASSERT(!g_inputs_channel);
+ spice_assert(!g_inputs_channel);
channel_cbs.config_socket = inputs_channel_config_socket;
channel_cbs.on_disconnect = inputs_channel_on_disconnect;
@@ -551,7 +551,7 @@ void inputs_init(void)
&channel_cbs);
if (!g_inputs_channel) {
- red_error("failed to allocate Inputs Channel");
+ spice_error("failed to allocate Inputs Channel");
}
client_cbs.connect = inputs_connect;
@@ -561,6 +561,6 @@ void inputs_init(void)
reds_register_channel(&g_inputs_channel->base);
if (!(key_modifiers_timer = core->timer_add(key_modifiers_sender, NULL))) {
- red_error("key modifiers timer create failed");
+ spice_error("key modifiers timer create failed");
}
}
diff --git a/server/jpeg_encoder.c b/server/jpeg_encoder.c
index d0e2fc1..01732ff 100644
--- a/server/jpeg_encoder.c
+++ b/server/jpeg_encoder.c
@@ -49,7 +49,7 @@ static void dest_mgr_init_destination(j_compress_ptr cinfo)
&enc->dest_mgr.next_output_byte);
if (enc->dest_mgr.free_in_buffer == 0) {
- red_error("not enough space");
+ spice_error("not enough space");
}
}
@@ -63,7 +63,7 @@ static boolean dest_mgr_empty_output_buffer(j_compress_ptr cinfo)
&enc->dest_mgr.next_output_byte);
if (enc->dest_mgr.free_in_buffer == 0) {
- red_error("not enough space");
+ spice_error("not enough space");
}
enc->cur_image.out_size += enc->dest_mgr.free_in_buffer;
return TRUE;
@@ -110,7 +110,7 @@ static void convert_RGB16_to_RGB24(uint8_t *line, int width, uint8_t **out_line)
uint8_t *out_pix;
int x;
- ASSERT(out_line && *out_line);
+ spice_assert(out_line && *out_line);
out_pix = *out_line;
@@ -127,7 +127,7 @@ static void convert_BGR24_to_RGB24(uint8_t *line, int width, uint8_t **out_line)
int x;
uint8_t *out_pix;
- ASSERT(out_line && *out_line);
+ spice_assert(out_line && *out_line);
out_pix = *out_line;
@@ -145,7 +145,7 @@ static void convert_BGRX32_to_RGB24(uint8_t *line, int width, uint8_t **out_line
uint8_t *out_pix;
int x;
- ASSERT(out_line && *out_line);
+ spice_assert(out_line && *out_line);
out_pix = *out_line;
@@ -167,7 +167,7 @@ static void convert_RGB24_to_RGB24(uint8_t *line, int width, uint8_t **out_line)
if (lines == lines_end) { \
int n = jpeg->usr->more_lines(jpeg->usr, &lines); \
if (n <= 0) { \
- red_error("more lines failed\n"); \
+ spice_error("more lines failed"); \
} \
lines_end = lines + n * stride; \
} \
@@ -226,7 +226,7 @@ int jpeg_encode(JpegEncoderContext *jpeg, int quality, JpegEncoderImageType type
enc->cur_image.convert_line_to_RGB24 = convert_BGRX32_to_RGB24;
break;
default:
- red_error("bad image type");
+ spice_error("bad image type");
}
enc->cinfo.image_width = width;
diff --git a/server/main_channel.c b/server/main_channel.c
index 7a2938c..713f121 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -162,7 +162,7 @@ int main_channel_is_connected(MainChannel *main_chan)
// real disconnection of main channel
static void main_channel_client_on_disconnect(RedChannelClient *rcc)
{
- red_printf("rcc=%p", rcc);
+ spice_printerr("rcc=%p", rcc);
reds_client_disconnect(rcc->client);
// red_channel_client_disconnect(rcc);
}
@@ -333,7 +333,7 @@ static PipeItem *main_multi_media_time_item_new(
static void main_channel_push_channels(MainChannelClient *mcc)
{
if (red_client_during_migrate_at_target(mcc->base.client)) {
- red_printf("warning: ignoring unexpected SPICE_MSGC_MAIN_ATTACH_CHANNELS"
+ spice_printerr("warning: ignoring unexpected SPICE_MSGC_MAIN_ATTACH_CHANNELS"
"during migration");
return;
}
@@ -482,7 +482,7 @@ static uint64_t main_channel_handle_migrate_data_get_serial(RedChannelClient *ba
MainMigrateData *data = message;
if (size < sizeof(*data)) {
- red_printf("bad message size");
+ spice_printerr("bad message size");
return 0;
}
return data->serial;
@@ -495,7 +495,7 @@ static uint64_t main_channel_handle_migrate_data(RedChannelClient *base,
MainMigrateData *data = message;
if (size < sizeof(*data)) {
- red_printf("bad message size");
+ spice_printerr("bad message size");
return FALSE;
}
mcc->ping_id = data->ping_id;
@@ -636,7 +636,7 @@ void main_channel_push_multi_media_time(MainChannel *main_chan, int time)
static void main_channel_fill_mig_target(MainChannel *main_channel, RedsMigSpice *mig_target)
{
- ASSERT(mig_target);
+ spice_assert(mig_target);
free(main_channel->mig_target.host);
main_channel->mig_target.host = spice_strdup(mig_target->host);
free(main_channel->mig_target.cert_subject);
@@ -658,7 +658,7 @@ static void main_channel_marshall_migrate_switch(SpiceMarshaller *m, RedChannelC
SpiceMsgMainMigrationSwitchHost migrate;
MainChannel *main_ch;
- red_printf("");
+ spice_printerr("");
main_ch = SPICE_CONTAINEROF(rcc->channel, MainChannel, base);
migrate.port = main_ch->mig_target.port;
migrate.sport = main_ch->mig_target.sport;
@@ -689,7 +689,7 @@ static void main_channel_send_item(RedChannelClient *rcc, PipeItem *base)
SpiceMarshaller *m = red_channel_client_get_marshaller(rcc);
if (!mcc->init_sent && base->type != SPICE_MSG_MAIN_INIT) {
- red_printf("Init msg for client %p was not sent yet "
+ spice_printerr("Init msg for client %p was not sent yet "
"(client is probably during migration). Ignoring msg type %d",
rcc->client, base->type);
main_channel_release_pipe_item(rcc, base, FALSE);
@@ -769,8 +769,8 @@ static void main_channel_release_pipe_item(RedChannelClient *rcc,
case SPICE_MSG_MAIN_AGENT_DATA: {
AgentDataPipeItem *data = (AgentDataPipeItem*)base;
if (!--data->refs->refs) {
- red_printf_debug(1, "MAIN", "SPICE_MSG_MAIN_AGENT_DATA %p %p, %d",
- data, data->refs, data->refs->refs);
+ spice_debug("SPICE_MSG_MAIN_AGENT_DATA %p %p, %d",
+ data, data->refs, data->refs->refs);
free(data->refs);
data->free_data(data->data, data->opaque);
}
@@ -784,19 +784,19 @@ static void main_channel_release_pipe_item(RedChannelClient *rcc,
void main_channel_client_handle_migrate_connected(MainChannelClient *mcc, int success)
{
- red_printf("client %p connected: %d", mcc->base.client, success);
+ spice_printerr("client %p connected: %d", mcc->base.client, success);
if (mcc->mig_wait_connect) {
MainChannel *main_channel = SPICE_CONTAINEROF(mcc->base.channel, MainChannel, base);
mcc->mig_wait_connect = FALSE;
mcc->mig_connect_ok = success;
- ASSERT(main_channel->num_clients_mig_wait);
+ spice_assert(main_channel->num_clients_mig_wait);
if (!--main_channel->num_clients_mig_wait) {
reds_on_main_migrate_connected();
}
} else {
if (success) {
- red_printf("client %p MIGRATE_CANCEL", mcc->base.client);
+ spice_printerr("client %p MIGRATE_CANCEL", mcc->base.client);
red_channel_client_pipe_add_type(&mcc->base, SPICE_MSG_MAIN_MIGRATE_CANCEL);
}
}
@@ -805,12 +805,12 @@ void main_channel_client_handle_migrate_connected(MainChannelClient *mcc, int su
void main_channel_client_handle_migrate_end(MainChannelClient *mcc)
{
if (!red_client_during_migrate_at_target(mcc->base.client)) {
- red_printf("unexpected SPICE_MSGC_MIGRATE_END");
+ spice_printerr("unexpected SPICE_MSGC_MIGRATE_END");
return;
}
if (!red_channel_client_test_remote_cap(&mcc->base,
SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE)) {
- red_printf("unexpected SPICE_MSGC_MIGRATE_END, "
+ spice_printerr("unexpected SPICE_MSGC_MIGRATE_END, "
"client does not support semi-seamless migration");
return;
}
@@ -829,7 +829,7 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
switch (type) {
case SPICE_MSGC_MAIN_AGENT_START:
- red_printf("agent start");
+ spice_printerr("agent start");
if (!main_chan) {
return FALSE;
}
@@ -877,14 +877,14 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
if (roundtrip <= mcc->latency) {
// probably high load on client or server result with incorrect values
mcc->latency = 0;
- red_printf("net test: invalid values, latency %" PRIu64
+ spice_printerr("net test: invalid values, latency %" PRIu64
" roundtrip %" PRIu64 ". assuming high"
"bandwidth", mcc->latency, roundtrip);
break;
}
mcc->bitrate_per_sec = (uint64_t)(NET_TEST_BYTES * 8) * 1000000
/ (roundtrip - mcc->latency);
- red_printf("net test: latency %f ms, bitrate %"PRIu64" bps (%f Mbps)%s",
+ spice_printerr("net test: latency %f ms, bitrate %"PRIu64" bps (%f Mbps)%s",
(double)mcc->latency / 1000,
mcc->bitrate_per_sec,
(double)mcc->bitrate_per_sec / 1024 / 1024,
@@ -892,7 +892,7 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
mcc->net_test_stage = NET_TEST_STAGE_INVALID;
break;
default:
- red_printf("invalid net test stage, ping id %d test id %d stage %d",
+ spice_printerr("invalid net test stage, ping id %d test id %d stage %d",
ping->id,
mcc->net_test_id,
mcc->net_test_stage);
@@ -914,7 +914,7 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
main_channel_client_handle_migrate_end(mcc);
break;
default:
- red_printf("unexpected type %d", type);
+ spice_printerr("unexpected type %d", type);
}
return TRUE;
}
@@ -955,7 +955,7 @@ static int main_channel_handle_migrate_flush_mark(RedChannelClient *rcc)
static void do_ping_client(MainChannelClient *mcc,
const char *opt, int has_interval, int interval)
{
- red_printf("");
+ spice_printerr("");
if (!opt) {
main_channel_client_push_ping(mcc, 0);
} else if (!strcmp(opt, "on")) {
@@ -975,7 +975,7 @@ static void ping_timer_cb(void *opaque)
MainChannelClient *mcc = opaque;
if (!red_channel_client_is_connected(&mcc->base)) {
- red_printf("not connected to peer, ping off");
+ spice_printerr("not connected to peer, ping off");
core->timer_cancel(mcc->ping_timer);
return;
}
@@ -1003,7 +1003,7 @@ static MainChannelClient *main_channel_client_create(MainChannel *main_chan, Red
mcc->bitrate_per_sec = ~0;
#ifdef RED_STATISTICS
if (!(mcc->ping_timer = core->timer_add(ping_timer_cb, NULL))) {
- red_error("ping timer create failed");
+ spice_error("ping timer create failed");
}
mcc->ping_interval = PING_INTERVAL;
#endif
@@ -1017,12 +1017,12 @@ MainChannelClient *main_channel_link(MainChannel *channel, RedClient *client,
{
MainChannelClient *mcc;
- ASSERT(channel);
+ spice_assert(channel);
// TODO - migration - I removed it from channel creation, now put it
// into usage somewhere (not an issue until we return migration to it's
// former glory)
- red_printf("add main channel client");
+ spice_printerr("add main channel client");
mcc = main_channel_client_create(channel, client, stream, connection_id,
num_common_caps, common_caps,
num_caps, caps);
@@ -1083,14 +1083,14 @@ MainChannel* main_channel_init(void)
spice_get_client_channel_parser(SPICE_CHANNEL_MAIN, NULL),
main_channel_handle_parsed,
&channel_cbs);
- ASSERT(channel);
+ spice_assert(channel);
red_channel_set_cap(channel, SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE);
return (MainChannel *)channel;
}
RedChannelClient* main_channel_client_get_base(MainChannelClient* mcc)
{
- ASSERT(mcc);
+ spice_assert(mcc);
return &mcc->base;
}
@@ -1107,7 +1107,7 @@ int main_channel_migrate_connect(MainChannel *main_channel, RedsMigSpice *mig_ta
if (red_channel_client_test_remote_cap(&mcc->base,
SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE)) {
if (red_client_during_migrate_at_target(mcc->base.client)) {
- red_printf("client %p: wait till previous migration completes", mcc->base.client);
+ spice_printerr("client %p: wait till previous migration completes", mcc->base.client);
mcc->mig_wait_prev_complete = TRUE;
} else {
red_channel_client_pipe_add_type(&mcc->base, SPICE_MSG_MAIN_MIGRATE_BEGIN);
@@ -1129,7 +1129,7 @@ void main_channel_migrate_cancel_wait(MainChannel *main_chan)
mcc = SPICE_CONTAINEROF(client_link, MainChannelClient, base.channel_link);
if (mcc->mig_wait_connect) {
- red_printf("client %p cancel wait connect", mcc->base.client);
+ spice_printerr("client %p cancel wait connect", mcc->base.client);
mcc->mig_wait_connect = FALSE;
mcc->mig_connect_ok = FALSE;
}
@@ -1143,10 +1143,10 @@ int main_channel_migrate_complete(MainChannel *main_chan, int success)
RingItem *client_link;
int semi_seamless_count = 0;
- red_printf("");
+ spice_printerr("");
if (ring_is_empty(&main_chan->base.clients)) {
- red_printf("no peer connected");
+ spice_printerr("no peer connected");
return 0;
}
@@ -1159,16 +1159,16 @@ int main_channel_migrate_complete(MainChannel *main_chan, int success)
SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE);
if (semi_seamless_support && mcc->mig_connect_ok) {
if (success) {
- red_printf("client %p MIGRATE_END", mcc->base.client);
+ spice_printerr("client %p MIGRATE_END", mcc->base.client);
red_channel_client_pipe_add_type(&mcc->base, SPICE_MSG_MAIN_MIGRATE_END);
semi_seamless_count++;
} else {
- red_printf("client %p MIGRATE_CANCEL", mcc->base.client);
+ spice_printerr("client %p MIGRATE_CANCEL", mcc->base.client);
red_channel_client_pipe_add_type(&mcc->base, SPICE_MSG_MAIN_MIGRATE_CANCEL);
}
} else {
if (success) {
- red_printf("client %p SWITCH_HOST", mcc->base.client);
+ spice_printerr("client %p SWITCH_HOST", mcc->base.client);
red_channel_client_pipe_add_type(&mcc->base, SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST);
}
}
diff --git a/server/mjpeg_encoder.c b/server/mjpeg_encoder.c
index 6b68549..4692315 100644
--- a/server/mjpeg_encoder.c
+++ b/server/mjpeg_encoder.c
@@ -228,7 +228,7 @@ int mjpeg_encoder_start_frame(MJpegEncoder *encoder, SpiceBitmapFmt format,
#endif
break;
default:
- red_printf_some(1000, "unsupported format %d", format);
+ spice_warning("unsupported format %d", format);
return FALSE;
}
diff --git a/server/red_channel.c b/server/red_channel.c
index f27abed..4858bb5 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -89,7 +89,7 @@ static void full_header_set_msg_serial(SpiceDataHeaderOpaque *header, uint64_t s
static void mini_header_set_msg_serial(SpiceDataHeaderOpaque *header, uint64_t serial)
{
- red_error("attempt to set header serial on mini header");
+ spice_error("attempt to set header serial on mini header");
}
static void full_header_set_msg_sub_list(SpiceDataHeaderOpaque *header, uint32_t sub_list)
@@ -99,7 +99,7 @@ static void full_header_set_msg_sub_list(SpiceDataHeaderOpaque *header, uint32_t
static void mini_header_set_msg_sub_list(SpiceDataHeaderOpaque *header, uint32_t sub_list)
{
- red_error("attempt to set header sub list on mini header");
+ spice_error("attempt to set header sub list on mini header");
}
static SpiceDataHeaderOpaque full_header_wrapper = {NULL, sizeof(SpiceDataHeader),
@@ -132,7 +132,7 @@ static int red_peer_receive(RedsStream *stream, uint8_t *buf, uint32_t size)
if (now == 0) {
return -1;
}
- ASSERT(now == -1);
+ spice_assert(now == -1);
if (errno == EAGAIN) {
break;
} else if (errno == EINTR) {
@@ -140,7 +140,7 @@ static int red_peer_receive(RedsStream *stream, uint8_t *buf, uint32_t size)
} else if (errno == EPIPE) {
return -1;
} else {
- red_printf("%s", strerror(errno));
+ spice_printerr("%s", strerror(errno));
return -1;
}
} else {
@@ -193,7 +193,7 @@ static void red_peer_handle_incoming(RedsStream *stream, IncomingHandler *handle
if (!handler->msg) {
handler->msg = handler->cb->alloc_msg_buf(handler->opaque, msg_type, msg_size);
if (handler->msg == NULL) {
- red_printf("ERROR: channel refused to allocate buffer.");
+ spice_printerr("ERROR: channel refused to allocate buffer.");
handler->cb->on_error(handler->opaque);
return;
}
@@ -218,7 +218,7 @@ static void red_peer_handle_incoming(RedsStream *stream, IncomingHandler *handle
handler->msg + msg_size, msg_type,
SPICE_VERSION_MINOR, &parsed_size, &parsed_free);
if (parsed == NULL) {
- red_printf("failed to parse message type %d", msg_type);
+ spice_printerr("failed to parse message type %d", msg_type);
handler->cb->release_msg_buf(handler->opaque, msg_type, msg_size, handler->msg);
handler->cb->on_error(handler->opaque);
return;
@@ -285,7 +285,7 @@ static void red_peer_handle_outgoing(RedsStream *stream, OutgoingHandler *handle
handler->cb->on_error(handler->opaque);
return;
default:
- red_printf("%s", strerror(errno));
+ spice_printerr("%s", strerror(errno));
handler->cb->on_error(handler->opaque);
return;
}
@@ -362,7 +362,7 @@ static void red_channel_client_reset_send_data(RedChannelClient *rcc)
* has been called before, but no message has been sent since then.
*/
if (rcc->send_data.last_sent_serial != rcc->send_data.serial) {
- ASSERT(rcc->send_data.serial - rcc->send_data.last_sent_serial == 1);
+ spice_assert(rcc->send_data.serial - rcc->send_data.last_sent_serial == 1);
/* When the urgent marshaller is active, the serial was incremented by
* the call to reset_send_data that was made for the main marshaller.
* The urgent msg receives this serial, and the main msg serial is
@@ -375,7 +375,7 @@ static void red_channel_client_reset_send_data(RedChannelClient *rcc)
rcc->send_data.serial++;
if (!rcc->is_mini_header) {
- ASSERT(rcc->send_data.marshaller != rcc->send_data.urgent.marshaller);
+ spice_assert(rcc->send_data.marshaller != rcc->send_data.urgent.marshaller);
rcc->send_data.header.set_msg_sub_list(&rcc->send_data.header, 0);
rcc->send_data.header.set_msg_serial(&rcc->send_data.header, rcc->send_data.serial);
}
@@ -395,7 +395,7 @@ static void red_channel_client_send_set_ack(RedChannelClient *rcc)
{
SpiceMsgSetAck ack;
- ASSERT(rcc);
+ spice_assert(rcc);
red_channel_client_init_send_data(rcc, SPICE_MSG_SET_ACK, NULL);
ack.generation = ++rcc->ack_data.generation;
ack.window = rcc->ack_data.client_window;
@@ -410,7 +410,7 @@ static void red_channel_client_send_item(RedChannelClient *rcc, PipeItem *item)
{
int handled = TRUE;
- ASSERT(red_channel_client_no_item_being_sent(rcc));
+ spice_assert(red_channel_client_no_item_being_sent(rcc));
red_channel_client_reset_send_data(rcc);
switch (item->type) {
case PIPE_ITEM_TYPE_SET_ACK:
@@ -463,7 +463,7 @@ static void red_channel_peer_on_out_msg_done(void *opaque)
if (red_channel_client_urgent_marshaller_is_active(rcc)) {
red_channel_client_restore_main_sender(rcc);
- ASSERT(rcc->send_data.header.data != NULL);
+ spice_assert(rcc->send_data.header.data != NULL);
red_channel_client_begin_send_message(rcc);
}
}
@@ -476,7 +476,7 @@ static void red_channel_client_pipe_remove(RedChannelClient *rcc, PipeItem *item
static void red_channel_add_client(RedChannel *channel, RedChannelClient *rcc)
{
- ASSERT(rcc);
+ spice_assert(rcc);
ring_add(&channel->clients, &rcc->channel_link);
channel->clients_num++;
}
@@ -521,7 +521,7 @@ RedChannelClient *red_channel_client_create(int size, RedChannel *channel, RedCl
{
RedChannelClient *rcc;
- ASSERT(stream && channel && size >= sizeof(RedChannelClient));
+ spice_assert(stream && channel && size >= sizeof(RedChannelClient));
rcc = spice_malloc0(size);
rcc->stream = stream;
rcc->channel = channel;
@@ -583,7 +583,7 @@ static void red_channel_client_default_connect(RedChannel *channel, RedClient *c
int num_common_caps, uint32_t *common_caps,
int num_caps, uint32_t *caps)
{
- red_error("not implemented");
+ spice_error("not implemented");
}
static void red_channel_client_default_disconnect(RedChannelClient *base)
@@ -605,8 +605,8 @@ RedChannel *red_channel_create(int size,
RedChannel *channel;
ClientCbs client_cbs = { NULL, };
- ASSERT(size >= sizeof(*channel));
- ASSERT(channel_cbs->config_socket && channel_cbs->on_disconnect && handle_message &&
+ spice_assert(size >= sizeof(*channel));
+ spice_assert(channel_cbs->config_socket && channel_cbs->on_disconnect && handle_message &&
channel_cbs->alloc_recv_buf && channel_cbs->release_item);
channel = spice_malloc0(size);
channel->type = type;
@@ -672,7 +672,7 @@ RedChannel *red_channel_create_dummy(int size, uint32_t type, uint32_t id)
RedChannel *channel;
ClientCbs client_cbs = { NULL, };
- ASSERT(size >= sizeof(*channel));
+ spice_assert(size >= sizeof(*channel));
channel = spice_malloc0(size);
channel->type = type;
channel->id = id;
@@ -723,7 +723,7 @@ RedChannel *red_channel_create_parser(int size,
void red_channel_register_client_cbs(RedChannel *channel, ClientCbs *client_cbs)
{
- ASSERT(client_cbs->connect);
+ spice_assert(client_cbs->connect);
channel->client_cbs.connect = client_cbs->connect;
if (client_cbs->disconnect) {
@@ -769,7 +769,7 @@ void red_channel_set_cap(RedChannel *channel, uint32_t cap)
void red_channel_set_data(RedChannel *channel, void *data)
{
- ASSERT(channel);
+ spice_assert(channel);
channel->data = data;
}
@@ -876,7 +876,7 @@ void red_channel_client_push(RedChannelClient *rcc)
if (!red_channel_client_no_item_being_sent(rcc) && !rcc->send_data.blocked) {
rcc->send_data.blocked = TRUE;
- red_printf("ERROR: an item waiting to be sent and not blocked");
+ spice_printerr("ERROR: an item waiting to be sent and not blocked");
}
while ((pipe_item = red_channel_client_pipe_item_get(rcc))) {
@@ -938,7 +938,7 @@ static void red_channel_handle_migrate_data(RedChannelClient *rcc, uint32_t size
if (!rcc->channel->channel_cbs.handle_migrate_data) {
return;
}
- ASSERT(red_channel_client_get_message_serial(rcc) == 0);
+ spice_assert(red_channel_client_get_message_serial(rcc) == 0);
red_channel_client_set_message_serial(rcc,
rcc->channel->channel_cbs.handle_migrate_data_get_serial(rcc, size, message));
rcc->channel->channel_cbs.handle_migrate_data(rcc, size, message);
@@ -950,7 +950,7 @@ int red_channel_client_handle_message(RedChannelClient *rcc, uint32_t size,
switch (type) {
case SPICE_MSGC_ACK_SYNC:
if (size != sizeof(uint32_t)) {
- red_printf("bad message size");
+ spice_printerr("bad message size");
return FALSE;
}
rcc->ack_data.client_generation = *(uint32_t *)(message);
@@ -970,7 +970,7 @@ int red_channel_client_handle_message(RedChannelClient *rcc, uint32_t size,
red_channel_handle_migrate_data(rcc, size, message);
break;
default:
- red_printf("invalid message type %u", type);
+ spice_printerr("invalid message type %u", type);
return FALSE;
}
return TRUE;
@@ -990,8 +990,8 @@ static void red_channel_client_event(int fd, int event, void *data)
void red_channel_client_init_send_data(RedChannelClient *rcc, uint16_t msg_type, PipeItem *item)
{
- ASSERT(red_channel_client_no_item_being_sent(rcc));
- ASSERT(msg_type != 0);
+ spice_assert(red_channel_client_no_item_being_sent(rcc));
+ spice_assert(msg_type != 0);
rcc->send_data.header.set_msg_type(&rcc->send_data.header, msg_type);
rcc->send_data.item = item;
if (item) {
@@ -1005,7 +1005,7 @@ void red_channel_client_begin_send_message(RedChannelClient *rcc)
// TODO - better check: type in channel_allowed_types. Better: type in channel_allowed_types(channel_state)
if (rcc->send_data.header.get_msg_type(&rcc->send_data.header) == 0) {
- red_printf("BUG: header->type == 0");
+ spice_printerr("BUG: header->type == 0");
return;
}
spice_marshaller_flush(m);
@@ -1020,8 +1020,8 @@ void red_channel_client_begin_send_message(RedChannelClient *rcc)
SpiceMarshaller *red_channel_client_switch_to_urgent_sender(RedChannelClient *rcc)
{
- ASSERT(red_channel_client_no_item_being_sent(rcc));
- ASSERT(rcc->send_data.header.data != NULL);
+ spice_assert(red_channel_client_no_item_being_sent(rcc));
+ spice_assert(rcc->send_data.header.data != NULL);
rcc->send_data.main.header_data = rcc->send_data.header.data;
rcc->send_data.main.item = rcc->send_data.item;
@@ -1060,7 +1060,7 @@ void red_channel_pipe_item_init(RedChannel *channel, PipeItem *item, int type)
void red_channel_client_pipe_add(RedChannelClient *rcc, PipeItem *item)
{
- ASSERT(rcc && item);
+ spice_assert(rcc && item);
rcc->pipe_size++;
ring_add(&rcc->pipe, &item->link);
}
@@ -1074,9 +1074,9 @@ void red_channel_client_pipe_add_push(RedChannelClient *rcc, PipeItem *item)
void red_channel_client_pipe_add_after(RedChannelClient *rcc,
PipeItem *item, PipeItem *pos)
{
- ASSERT(rcc);
- ASSERT(pos);
- ASSERT(item);
+ spice_assert(rcc);
+ spice_assert(pos);
+ spice_assert(item);
rcc->pipe_size++;
ring_add_after(&item->link, &pos->link);
@@ -1091,14 +1091,14 @@ int red_channel_client_pipe_item_is_linked(RedChannelClient *rcc,
void red_channel_client_pipe_add_tail_no_push(RedChannelClient *rcc,
PipeItem *item)
{
- ASSERT(rcc);
+ spice_assert(rcc);
rcc->pipe_size++;
ring_add_before(&item->link, &rcc->pipe);
}
void red_channel_client_pipe_add_tail(RedChannelClient *rcc, PipeItem *item)
{
- ASSERT(rcc);
+ spice_assert(rcc);
rcc->pipe_size++;
ring_add_before(&item->link, &rcc->pipe);
red_channel_client_push(rcc);
@@ -1170,9 +1170,9 @@ void red_channel_client_ack_set_client_window(RedChannelClient *rcc, int client_
static void red_channel_remove_client(RedChannelClient *rcc)
{
- ASSERT(pthread_equal(pthread_self(), rcc->channel->thread_id));
+ spice_assert(pthread_equal(pthread_self(), rcc->channel->thread_id));
ring_remove(&rcc->channel_link);
- ASSERT(rcc->channel->clients_num > 0);
+ spice_assert(rcc->channel->clients_num > 0);
rcc->channel->clients_num--;
// TODO: should we set rcc->channel to NULL???
}
@@ -1187,7 +1187,7 @@ static void red_client_remove_channel(RedChannelClient *rcc)
void red_channel_client_disconnect(RedChannelClient *rcc)
{
- red_printf("%p (channel %p type %d id %d)", rcc, rcc->channel,
+ spice_printerr("%p (channel %p type %d id %d)", rcc, rcc->channel,
rcc->channel->type, rcc->channel->id);
if (!red_channel_client_is_connected(rcc)) {
return;
@@ -1222,7 +1222,7 @@ RedChannelClient *red_channel_client_create_dummy(int size,
{
RedChannelClient *rcc;
- ASSERT(size >= sizeof(RedChannelClient));
+ spice_assert(size >= sizeof(RedChannelClient));
rcc = spice_malloc0(size);
rcc->client = client;
rcc->channel = channel;
@@ -1416,8 +1416,8 @@ void red_client_migrate(RedClient *client)
RingItem *link, *next;
RedChannelClient *rcc;
- red_printf("migrate client with #channels %d", client->channels_num);
- ASSERT(pthread_equal(pthread_self(), client->thread_id));
+ spice_printerr("migrate client with #channels %d", client->channels_num);
+ spice_assert(pthread_equal(pthread_self(), client->thread_id));
RING_FOREACH_SAFE(link, next, &client->channels) {
rcc = SPICE_CONTAINEROF(link, RedChannelClient, client_link);
if (red_channel_client_is_connected(rcc)) {
@@ -1431,8 +1431,8 @@ void red_client_destroy(RedClient *client)
RingItem *link, *next;
RedChannelClient *rcc;
- red_printf("destroy client with #channels %d", client->channels_num);
- ASSERT(pthread_equal(pthread_self(), client->thread_id));
+ spice_printerr("destroy client with #channels %d", client->channels_num);
+ spice_assert(pthread_equal(pthread_self(), client->thread_id));
RING_FOREACH_SAFE(link, next, &client->channels) {
// some channels may be in other threads, so disconnection
// is not synchronous.
@@ -1444,9 +1444,9 @@ void red_client_destroy(RedClient *client)
// TODO: should we go back to async. For this we need to use
// ref count for channel clients.
rcc->channel->client_cbs.disconnect(rcc);
- ASSERT(ring_is_empty(&rcc->pipe));
- ASSERT(rcc->pipe_size == 0);
- ASSERT(rcc->send_data.size == 0);
+ spice_assert(ring_is_empty(&rcc->pipe));
+ spice_assert(rcc->pipe_size == 0);
+ spice_assert(rcc->send_data.size == 0);
red_channel_client_destroy(rcc);
}
@@ -1456,7 +1456,7 @@ void red_client_destroy(RedClient *client)
static void red_client_add_channel(RedClient *client, RedChannelClient *rcc)
{
- ASSERT(rcc && client);
+ spice_assert(rcc && client);
pthread_mutex_lock(&client->lock);
ring_add(&client->channels, &rcc->client_link);
client->channels_num++;
@@ -1473,7 +1473,7 @@ void red_client_set_main(RedClient *client, MainChannelClient *mcc) {
void red_client_migrate_complete(RedClient *client)
{
- ASSERT(client->migrated);
+ spice_assert(client->migrated);
client->migrated = FALSE;
reds_on_client_migrate_complete(client);
}
diff --git a/server/red_client_cache.h b/server/red_client_cache.h
index 0da11a6..dc314c0 100644
--- a/server/red_client_cache.h
+++ b/server/red_client_cache.h
@@ -63,11 +63,11 @@ static void FUNC_NAME(remove)(CHANNELCLIENT *channel_client, CacheItem *item)
{
CacheItem **now;
CHANNEL *channel = CHANNEL_FROM_RCC(&channel_client->common.base);
- ASSERT(item);
+ spice_assert(item);
now = &channel_client->CACHE_NAME[CACHE_HASH_KEY(item->id)];
for (;;) {
- ASSERT(*now);
+ spice_assert(*now);
if (*now == item) {
*now = item->u.cache_data.next;
break;
diff --git a/server/red_client_shared_cache.h b/server/red_client_shared_cache.h
index fb405c3..821ee18 100644
--- a/server/red_client_shared_cache.h
+++ b/server/red_client_shared_cache.h
@@ -49,7 +49,7 @@ static int FUNC_NAME(hit)(CACHE *cache, uint64_t id, int *lossy, DisplayChannelC
if (item->id == id) {
ring_remove(&item->lru_link);
ring_add(&cache->lru, &item->lru_link);
- ASSERT(dcc->common.id < MAX_CACHE_CLIENTS)
+ spice_assert(dcc->common.id < MAX_CACHE_CLIENTS);
item->sync[dcc->common.id] = serial;
cache->sync[dcc->common.id] = serial;
*lossy = item->lossy;
@@ -86,7 +86,7 @@ static int FUNC_NAME(add)(CACHE *cache, uint64_t id, uint32_t size, int lossy, D
uint64_t serial;
int key;
- ASSERT(size > 0);
+ spice_assert(size > 0);
item = spice_new(NewCacheItem, 1);
serial = red_channel_client_get_message_serial(&dcc->common.base);
@@ -119,7 +119,7 @@ static int FUNC_NAME(add)(CACHE *cache, uint64_t id, uint32_t size, int lossy, D
now = &cache->hash_table[CACHE_HASH_KEY(tail->id)];
for (;;) {
- ASSERT(*now);
+ spice_assert(*now);
if (*now == tail) {
*now = tail->next;
break;
@@ -217,7 +217,7 @@ static int FUNC_NAME(freeze)(CACHE *cache)
static void FUNC_NAME(destroy)(CACHE *cache)
{
- ASSERT(cache);
+ spice_assert(cache);
pthread_mutex_lock(&cache->lock);
PRIVATE_FUNC_NAME(clear)(cache);
diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c
index 9a04948..6b96a2e 100644
--- a/server/red_dispatcher.c
+++ b/server/red_dispatcher.c
@@ -44,13 +44,6 @@
static int num_active_workers = 0;
-//volatile
-
-#define DBG_ASYNC(s, ...) \
- do { \
- red_printf_debug(2, "ASYNC", s, ##__VA_ARGS__); \
- } while (0)
-
struct AsyncCommand {
RingItem link;
RedWorkerMessage message;
@@ -98,7 +91,7 @@ static void red_dispatcher_set_display_peer(RedChannel *channel, RedClient *clie
RedWorkerMessageDisplayConnect payload;
RedDispatcher *dispatcher;
- red_printf("");
+ spice_printerr("");
dispatcher = (RedDispatcher *)channel->data;
payload.client = client;
payload.stream = stream;
@@ -127,7 +120,7 @@ static void red_dispatcher_disconnect_display_peer(RedChannelClient *rcc)
dispatcher = (RedDispatcher *)rcc->channel->data;
- red_printf("");
+ spice_printerr("");
payload.rcc = rcc;
// TODO: we turned it to be sync, due to client_destroy . Should we support async? - for this we will need ref count
@@ -145,7 +138,7 @@ static void red_dispatcher_display_migrate(RedChannelClient *rcc)
return;
}
dispatcher = (RedDispatcher *)rcc->channel->data;
- red_printf("channel type %u id %u", rcc->channel->type, rcc->channel->id);
+ spice_printerr("channel type %u id %u", rcc->channel->type, rcc->channel->id);
payload.rcc = rcc;
dispatcher_send_message(&dispatcher->dispatcher,
RED_WORKER_MESSAGE_DISPLAY_MIGRATE,
@@ -159,7 +152,7 @@ static void red_dispatcher_set_cursor_peer(RedChannel *channel, RedClient *clien
{
RedWorkerMessageCursorConnect payload;
RedDispatcher *dispatcher = (RedDispatcher *)channel->data;
- red_printf("");
+ spice_printerr("");
payload.client = client;
payload.stream = stream;
payload.migration = migration;
@@ -186,7 +179,7 @@ static void red_dispatcher_disconnect_cursor_peer(RedChannelClient *rcc)
}
dispatcher = (RedDispatcher *)rcc->channel->data;
- red_printf("");
+ spice_printerr("");
payload.rcc = rcc;
dispatcher_send_message(&dispatcher->dispatcher,
@@ -203,7 +196,7 @@ static void red_dispatcher_cursor_migrate(RedChannelClient *rcc)
return;
}
dispatcher = (RedDispatcher *)rcc->channel->data;
- red_printf("channel type %u id %u", rcc->channel->type, rcc->channel->id);
+ spice_printerr("channel type %u id %u", rcc->channel->type, rcc->channel->id);
payload.rcc = rcc;
dispatcher_send_message(&dispatcher->dispatcher,
RED_WORKER_MESSAGE_CURSOR_MIGRATE,
@@ -313,7 +306,7 @@ static AsyncCommand *async_command_alloc(RedDispatcher *dispatcher,
async_command->message = message;
ring_add(&dispatcher->async_commands, &async_command->link);
pthread_mutex_unlock(&dispatcher->async_lock);
- DBG_ASYNC("%p", async_command);
+ spice_debug("%p", async_command);
return async_command;
}
@@ -675,7 +668,7 @@ static void red_dispatcher_loadvm_commands(RedDispatcher *dispatcher,
{
RedWorkerMessageLoadvmCommands payload;
- red_printf("");
+ spice_printerr("");
payload.count = count;
payload.ext = ext;
dispatcher_send_message(&dispatcher->dispatcher,
@@ -701,7 +694,7 @@ void red_dispatcher_set_mm_time(uint32_t mm_time)
static inline int calc_compression_level(void)
{
- ASSERT(streaming_video != STREAM_VIDEO_INVALID);
+ spice_assert(streaming_video != STREAM_VIDEO_INVALID);
if ((streaming_video != STREAM_VIDEO_OFF) ||
(image_compression != SPICE_IMAGE_COMPRESS_QUIC)) {
return 0;
@@ -920,9 +913,9 @@ void red_dispatcher_async_complete(struct RedDispatcher *dispatcher,
{
pthread_mutex_lock(&dispatcher->async_lock);
ring_remove(&async_command->link);
- DBG_ASYNC("%p: cookie %" PRId64, async_command, async_command->cookie);
+ spice_debug("%p: cookie %" PRId64, async_command, async_command->cookie);
if (ring_is_empty(&dispatcher->async_commands)) {
- red_printf_debug(2, "ASYNC", "no more async commands");
+ spice_debug("no more async commands");
}
pthread_mutex_unlock(&dispatcher->async_lock);
switch (async_command->message) {
@@ -943,7 +936,7 @@ void red_dispatcher_async_complete(struct RedDispatcher *dispatcher,
case RED_WORKER_MESSAGE_FLUSH_SURFACES_ASYNC:
break;
default:
- WARN("unexpected message");
+ spice_warning("unexpected message %d", async_command->message);
}
dispatcher->qxl->st->qif->async_complete(dispatcher->qxl,
async_command->cookie);
@@ -995,7 +988,7 @@ RedDispatcher *red_dispatcher_init(QXLInstance *qxl)
red_dispatcher = spice_new0(RedDispatcher, 1);
ring_init(&red_dispatcher->async_commands);
- DBG_ASYNC("red_dispatcher->async_commands.next %p", red_dispatcher->async_commands.next);
+ spice_debug("red_dispatcher->async_commands.next %p", red_dispatcher->async_commands.next);
dispatcher_init(&red_dispatcher->dispatcher, RED_WORKER_MESSAGE_COUNT, NULL);
init_data.qxl = red_dispatcher->qxl = qxl;
init_data.id = qxl->id;
@@ -1046,12 +1039,12 @@ RedDispatcher *red_dispatcher_init(QXLInstance *qxl)
sigdelset(&thread_sig_mask, SIGSEGV);
pthread_sigmask(SIG_SETMASK, &thread_sig_mask, &curr_sig_mask);
if ((r = pthread_create(&red_dispatcher->worker_thread, NULL, red_worker_main, &init_data))) {
- red_error("create thread failed %d", r);
+ spice_error("create thread failed %d", r);
}
pthread_sigmask(SIG_SETMASK, &curr_sig_mask, NULL);
read_message(red_dispatcher->dispatcher.send_fd, &message);
- ASSERT(message == RED_WORKER_MESSAGE_READY);
+ spice_assert(message == RED_WORKER_MESSAGE_READY);
display_channel = red_dispatcher_display_channel_create(red_dispatcher);
diff --git a/server/red_memslots.c b/server/red_memslots.c
index 249b241..ae2c6e4 100644
--- a/server/red_memslots.c
+++ b/server/red_memslots.c
@@ -55,19 +55,19 @@ unsigned long get_virt_delta(RedMemSlotInfo *info, QXLPHYSICAL addr, int group_i
int generation;
if (group_id > info->num_memslots_groups) {
- PANIC("group_id %d too big", group_id);
+ spice_critical("group_id %d too big", group_id);
}
slot_id = get_memslot_id(info, addr);
if (slot_id > info->num_memslots) {
- PANIC("slot_id %d too big", slot_id);
+ spice_critical("slot_id %d too big", slot_id);
}
slot = &info->mem_slots[group_id][slot_id];
generation = get_generation(info, addr);
if (generation != slot->generation) {
- PANIC("address generation is not valid");
+ spice_critical("address generation is not valid");
}
return (slot->address_delta - (addr - __get_clean_virt(info, addr)));
@@ -80,12 +80,12 @@ void validate_virt(RedMemSlotInfo *info, unsigned long virt, int slot_id,
slot = &info->mem_slots[group_id][slot_id];
if ((virt + add_size) < virt) {
- PANIC("virtual address overlap");
+ spice_critical("virtual address overlap");
}
if (virt < slot->virt_start_addr || (virt + add_size) > slot->virt_end_addr) {
print_memslots(info);
- PANIC("virtual address out of range\n"
+ spice_critical("virtual address out of range\n"
" virt=0x%lx+0x%x slot_id=%d group_id=%d\n"
" slot=0x%lx-0x%lx delta=0x%lx",
virt, add_size, slot_id, group_id,
@@ -103,13 +103,13 @@ unsigned long get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size
MemSlot *slot;
if (group_id > info->num_memslots_groups) {
- PANIC("group_id too big");
+ spice_critical("group_id too big");
}
slot_id = get_memslot_id(info, addr);
if (slot_id > info->num_memslots) {
print_memslots(info);
- PANIC("slot_id too big, addr=%" PRIx64, addr);
+ spice_critical("slot_id too big, addr=%" PRIx64, addr);
}
slot = &info->mem_slots[group_id][slot_id];
@@ -117,7 +117,7 @@ unsigned long get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size
generation = get_generation(info, addr);
if (generation != slot->generation) {
print_memslots(info);
- PANIC("address generation is not valid, group_id %d, slot_id %d, gen %d, slot_gen %d\n",
+ spice_critical("address generation is not valid, group_id %d, slot_id %d, gen %d, slot_gen %d\n",
group_id, slot_id, generation, slot->generation);
}
@@ -152,8 +152,8 @@ void red_memslot_info_init(RedMemSlotInfo *info,
{
uint32_t i;
- ASSERT(num_slots > 0);
- ASSERT(num_groups > 0);
+ spice_assert(num_slots > 0);
+ spice_assert(num_groups > 0);
info->num_memslots_groups = num_groups;
info->num_memslots = num_slots;
@@ -179,8 +179,8 @@ void red_memslot_info_add_slot(RedMemSlotInfo *info, uint32_t slot_group_id, uin
uint64_t addr_delta, unsigned long virt_start, unsigned long virt_end,
uint32_t generation)
{
- ASSERT(info->num_memslots_groups > slot_group_id);
- ASSERT(info->num_memslots > slot_id);
+ spice_assert(info->num_memslots_groups > slot_group_id);
+ spice_assert(info->num_memslots > slot_id);
info->mem_slots[slot_group_id][slot_id].address_delta = addr_delta;
info->mem_slots[slot_group_id][slot_id].virt_start_addr = virt_start;
@@ -190,8 +190,8 @@ void red_memslot_info_add_slot(RedMemSlotInfo *info, uint32_t slot_group_id, uin
void red_memslot_info_del_slot(RedMemSlotInfo *info, uint32_t slot_group_id, uint32_t slot_id)
{
- ASSERT(info->num_memslots_groups > slot_group_id);
- ASSERT(info->num_memslots > slot_id);
+ spice_assert(info->num_memslots_groups > slot_group_id);
+ spice_assert(info->num_memslots > slot_id);
info->mem_slots[slot_group_id][slot_id].virt_start_addr = 0;
info->mem_slots[slot_group_id][slot_id].virt_end_addr = 0;
diff --git a/server/red_parse_qxl.c b/server/red_parse_qxl.c
index 201e683..811e427 100644
--- a/server/red_parse_qxl.c
+++ b/server/red_parse_qxl.c
@@ -66,7 +66,7 @@ static uint8_t *red_linearize_chunk(RedDataChunk *head, size_t size, bool *free_
uint32_t copy;
if (head->next_chunk == NULL) {
- ASSERT(size <= head->data_size);
+ spice_assert(size <= head->data_size);
*free_chunk = false;
return head->data;
}
@@ -79,7 +79,7 @@ static uint8_t *red_linearize_chunk(RedDataChunk *head, size_t size, bool *free_
ptr += copy;
size -= copy;
}
- ASSERT(size == 0);
+ spice_assert(size == 0);
return data;
}
@@ -205,15 +205,15 @@ static SpicePath *red_get_path(RedMemSlotInfo *slots, int group_id,
/* Protect against overflow in size calculations before
writing to memory */
- ASSERT(mem_size2 + sizeof(SpicePathSeg) > mem_size2);
+ spice_assert(mem_size2 + sizeof(SpicePathSeg) > mem_size2);
mem_size2 += sizeof(SpicePathSeg);
- ASSERT(count < UINT32_MAX / sizeof(SpicePointFix));
+ spice_assert(count < UINT32_MAX / sizeof(SpicePointFix));
dsize = count * sizeof(SpicePointFix);
- ASSERT(mem_size2 + dsize > mem_size2);
+ spice_assert(mem_size2 + dsize > mem_size2);
mem_size2 += dsize;
/* Verify that we didn't overflow due to guest changing data */
- ASSERT(mem_size2 <= mem_size);
+ spice_assert(mem_size2 <= mem_size);
seg->flags = start->flags;
seg->count = count;
@@ -225,7 +225,7 @@ static SpicePath *red_get_path(RedMemSlotInfo *slots, int group_id,
seg = (SpicePathSeg*)(&seg->points[i]);
}
/* Ensure guest didn't tamper with segment count */
- ASSERT(n_segments == red->num_segments);
+ spice_assert(n_segments == red->num_segments);
if (free_data) {
free(data);
@@ -252,7 +252,7 @@ static SpiceClipRects *red_get_clip_rects(RedMemSlotInfo *slots, int group_id,
data = red_linearize_chunk(&chunks, size, &free_data);
red_put_data_chunks(&chunks);
- ASSERT(qxl->num_rects * sizeof(QXLRect) == size);
+ spice_assert(qxl->num_rects * sizeof(QXLRect) == size);
red = spice_malloc(sizeof(*red) + qxl->num_rects * sizeof(SpiceRect));
red->num_rects = qxl->num_rects;
@@ -299,7 +299,7 @@ static SpiceChunks *red_get_image_data_chunked(RedMemSlotInfo *slots, int group_
data->chunk[i].len = chunk->data_size;
data->data_size += chunk->data_size;
}
- ASSERT(i == data->num_chunks);
+ spice_assert(i == data->num_chunks);
return data;
}
@@ -373,7 +373,7 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id,
} else {
size = red_get_data_chunks(slots, group_id,
&chunks, qxl->bitmap.data);
- ASSERT(size == bitmap_size);
+ spice_assert(size == bitmap_size);
red->u.bitmap.data = red_get_image_data_chunked(slots, group_id,
&chunks);
red_put_data_chunks(&chunks);
@@ -390,14 +390,13 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id,
size = red_get_data_chunks_ptr(slots, group_id,
get_memslot_id(slots, addr),
&chunks, (QXLDataChunk *)qxl->quic.data);
- ASSERT(size == red->u.quic.data_size);
+ spice_assert(size == red->u.quic.data_size);
red->u.quic.data = red_get_image_data_chunked(slots, group_id,
&chunks);
red_put_data_chunks(&chunks);
break;
default:
- red_error("%s: unknown type %d", __FUNCTION__, red->descriptor.type);
- abort();
+ spice_error("unknown type %d", red->descriptor.type);
}
return red;
}
@@ -593,7 +592,7 @@ static void red_get_stroke_ptr(RedMemSlotInfo *slots, int group_id,
style_nseg = qxl->attr.style_nseg;
red->attr.style = spice_malloc_n(style_nseg, sizeof(SPICE_FIXED28_4));
red->attr.style_nseg = style_nseg;
- ASSERT(qxl->attr.style);
+ spice_assert(qxl->attr.style);
buf = (uint8_t *)get_virt(slots, qxl->attr.style,
style_nseg * sizeof(QXLFIXED), group_id);
memcpy(red->attr.style, buf, style_nseg * sizeof(QXLFIXED));
@@ -636,7 +635,7 @@ static SpiceString *red_get_string(RedMemSlotInfo *slots, int group_id,
red_put_data_chunks(&chunks);
qxl_size = qxl->data_size;
- ASSERT(chunk_size == qxl_size);
+ spice_assert(chunk_size == qxl_size);
if (qxl->flags & SPICE_STRING_FLAGS_RASTER_A1) {
bpp = 1;
@@ -645,21 +644,21 @@ static SpiceString *red_get_string(RedMemSlotInfo *slots, int group_id,
} else if (qxl->flags & SPICE_STRING_FLAGS_RASTER_A8) {
bpp = 8;
}
- ASSERT(bpp != 0);
+ spice_assert(bpp != 0);
start = (QXLRasterGlyph*)data;
end = (QXLRasterGlyph*)(data + chunk_size);
red_size = sizeof(SpiceString);
glyphs = 0;
while (start < end) {
- ASSERT((QXLRasterGlyph*)(&start->data[0]) <= end);
+ spice_assert((QXLRasterGlyph*)(&start->data[0]) <= end);
glyphs++;
glyph_size = start->height * ((start->width * bpp + 7) / 8);
red_size += sizeof(SpiceRasterGlyph *) + SPICE_ALIGN(sizeof(SpiceRasterGlyph) + glyph_size, 4);
start = (QXLRasterGlyph*)(&start->data[glyph_size]);
}
- ASSERT(start <= end);
- ASSERT(glyphs == qxl->length);
+ spice_assert(start <= end);
+ spice_assert(glyphs == qxl->length);
red = spice_malloc(red_size);
red->length = qxl->length;
@@ -669,14 +668,14 @@ static SpiceString *red_get_string(RedMemSlotInfo *slots, int group_id,
end = (QXLRasterGlyph*)(data + chunk_size);
glyph = (SpiceRasterGlyph *)&red->glyphs[red->length];
for (i = 0; i < red->length; i++) {
- ASSERT((QXLRasterGlyph*)(&start->data[0]) <= end);
+ spice_assert((QXLRasterGlyph*)(&start->data[0]) <= end);
red->glyphs[i] = glyph;
glyph->width = start->width;
glyph->height = start->height;
red_get_point_ptr(&glyph->render_pos, &start->render_pos);
red_get_point_ptr(&glyph->glyph_origin, &start->glyph_origin);
glyph_size = glyph->height * ((glyph->width * bpp + 7) / 8);
- ASSERT((QXLRasterGlyph*)(&start->data[glyph_size]) <= end);
+ spice_assert((QXLRasterGlyph*)(&start->data[glyph_size]) <= end);
memcpy(glyph->data, start->data, glyph_size);
start = (QXLRasterGlyph*)(&start->data[glyph_size]);
glyph = (SpiceRasterGlyph*)
@@ -831,7 +830,7 @@ static void red_get_native_drawable(RedMemSlotInfo *slots, int group_id,
&red->u.whiteness, &qxl->u.whiteness, flags);
break;
default:
- red_error("%s: unknown type %d", __FUNCTION__, red->type);
+ spice_error("unknown type %d", red->type);
break;
};
}
@@ -911,7 +910,7 @@ static void red_get_compat_drawable(RedMemSlotInfo *slots, int group_id,
&red->u.whiteness, &qxl->u.whiteness, flags);
break;
default:
- red_error("%s: unknown type %d", __FUNCTION__, red->type);
+ spice_error("unknown type %d", red->type);
break;
};
}
diff --git a/server/red_tunnel_worker.c b/server/red_tunnel_worker.c
index 45bf6e1..384c36d 100644
--- a/server/red_tunnel_worker.c
+++ b/server/red_tunnel_worker.c
@@ -44,7 +44,7 @@
//#define DEBUG_NETWORK
#ifdef DEBUG_NETWORK
-#define PRINT_SCKT(sckt) red_printf("TUNNEL_DBG SOCKET(connection_id=%d port=%d, service=%d)",\
+#define PRINT_SCKT(sckt) spice_printerr("TUNNEL_DBG SOCKET(connection_id=%d port=%d, service=%d)",\
sckt->connection_id, ntohs(sckt->local_port), \
sckt->far_service->id)
#endif
@@ -479,7 +479,7 @@ static inline void tunnel_channel_activate_migrated_sockets(TunnelChannelClient
failed (which triggered from a call to slirp) */
#define SET_TUNNEL_ERROR(channel,format, ...) { \
channel->tunnel_error = TRUE; \
- red_printf(format, ## __VA_ARGS__); \
+ spice_printerr(format, ## __VA_ARGS__); \
}
/* should be checked after each subroutine that may cause error or after calls to slirp routines */
@@ -614,7 +614,7 @@ static void red_tunnel_channel_create(TunnelWorker *worker);
static void tunnel_shutdown(TunnelWorker *worker)
{
int i;
- red_printf("");
+ spice_printerr("");
/* shutdown input from channel */
if (worker->channel_client) {
red_channel_client_shutdown(&worker->channel_client->base);
@@ -695,7 +695,7 @@ static void snd_tunnled_buffer_release(RawTunneledBuffer *buf)
static inline void tunnel_socket_assign_rcv_buf(RedSocket *sckt,
RedSocketRawRcvBuf *recv_buf, int buf_size)
{
- ASSERT(!recv_buf->base.usr_opaque);
+ spice_assert(!recv_buf->base.usr_opaque);
// the rcv buffer was allocated by tunnel_channel_alloc_msg_rcv_buf
// before we could know which of the sockets it belongs to, so the
// assignment to the socket is performed now
@@ -824,7 +824,7 @@ static void process_queue_append(TunneledBufferProcessQueue *queue, uint8_t *dat
static void process_queue_pop(TunneledBufferProcessQueue *queue)
{
RawTunneledBuffer *prev_head;
- ASSERT(queue->head && queue->tail);
+ spice_assert(queue->head && queue->tail);
prev_head = queue->head;
queue->head = queue->head->next;
if (!queue->head) {
@@ -868,7 +868,7 @@ static void ready_queue_add_orig_chunk(ReadyTunneledChunkQueue *queue, RawTunnel
static void ready_queue_pop_chunk(ReadyTunneledChunkQueue *queue)
{
ReadyTunneledChunk *chunk = queue->head;
- ASSERT(queue->head);
+ spice_assert(queue->head);
queue->head = queue->head->next;
if (!queue->head) {
@@ -892,8 +892,8 @@ static void ready_queue_clear(ReadyTunneledChunkQueue *queue)
static void process_queue_simple_analysis(TunneledBufferProcessQueue *queue,
RawTunneledBuffer *start_last_added, int offset, int len)
{
- ASSERT(offset == 0);
- ASSERT(start_last_added == queue->head);
+ spice_assert(offset == 0);
+ spice_assert(start_last_added == queue->head);
while (queue->head) {
ready_queue_add_orig_chunk(queue->ready_chunks_queue, queue->head, queue->head->data,
@@ -912,7 +912,7 @@ static int process_queue_simple_get_migrate_data(TunneledBufferProcessQueue *que
static void process_queue_simple_release_migrate_data(TunneledBufferProcessQueue *queue,
void *migrate_data)
{
- ASSERT(!migrate_data);
+ spice_assert(!migrate_data);
}
static void process_queue_simple_restore(TunneledBufferProcessQueue *queue, uint8_t *migrate_data)
@@ -971,7 +971,7 @@ SPICE_GNUC_VISIBLE void spice_server_net_wire_recv_packet(SpiceNetWireInstance *
const uint8_t *pkt, int pkt_len)
{
TunnelWorker *worker = sin->st->worker;
- ASSERT(worker);
+ spice_assert(worker);
if (worker->channel_client && worker->channel_client->base.channel->migrate) {
return; // during migration and the tunnel state hasn't been restored yet.
@@ -1054,7 +1054,7 @@ static inline TunnelService *__tunnel_worker_add_service(TunnelWorker *worker, u
TunnelService *service_of_same_group;
if (!(service_of_same_group = __tunnel_worker_find_service_of_group(worker, group))) {
if (!net_slirp_allocate_virtual_ip(&new_service->virt_ip)) {
- red_printf("failed to allocate virtual ip");
+ spice_printerr("failed to allocate virtual ip");
free(new_service);
return NULL;
}
@@ -1062,7 +1062,7 @@ static inline TunnelService *__tunnel_worker_add_service(TunnelWorker *worker, u
if (strcmp(name, service_of_same_group->name) == 0) {
new_service->virt_ip.s_addr = service_of_same_group->virt_ip.s_addr;
} else {
- red_printf("inconsistent name for service group %d", group);
+ spice_printerr("inconsistent name for service group %d", group);
free(new_service);
return NULL;
}
@@ -1084,7 +1084,7 @@ static inline TunnelService *__tunnel_worker_add_service(TunnelWorker *worker, u
worker->num_services++;
#ifdef DEBUG_NETWORK
- red_printf("TUNNEL_DBG: ==>SERVICE ADDED: id=%d virt ip=%s port=%d name=%s desc=%s",
+ spice_printerr("TUNNEL_DBG: ==>SERVICE ADDED: id=%d virt ip=%s port=%d name=%s desc=%s",
new_service->id, inet_ntoa(new_service->virt_ip),
new_service->port, new_service->name, new_service->description);
#endif
@@ -1137,12 +1137,12 @@ static TunnelPrintService *tunnel_worker_add_print_service(TunnelWorker *worker,
if (redc_service->type == SPICE_TUNNEL_IP_TYPE_IPv4) {
memcpy(service->ip, redc_service->u.ip.data, sizeof(SpiceTunnelIPv4));
} else {
- red_printf("unexpected ip type=%d", redc_service->type);
+ spice_printerr("unexpected ip type=%d", redc_service->type);
tunnel_worker_free_print_service(worker, service);
return NULL;
}
#ifdef DEBUG_NETWORK
- red_printf("TUNNEL_DBG: ==>PRINT SERVICE ADDED: ip=%d.%d.%d.%d", service->ip[0],
+ spice_printerr("TUNNEL_DBG: ==>PRINT SERVICE ADDED: ip=%d.%d.%d.%d", service->ip[0],
service->ip[1], service->ip[2], service->ip[3]);
#endif
return service;
@@ -1159,7 +1159,7 @@ static int tunnel_channel_handle_service_add(TunnelChannelClient *channel,
out_service = tunnel_worker_add_service(channel->worker, sizeof(TunnelService),
service_msg);
} else {
- red_printf("invalid service type");
+ spice_printerr("invalid service type");
}
free(service_msg);
@@ -1205,7 +1205,7 @@ static inline void tunnel_worker_clear_routed_network(TunnelWorker *worker)
} else if (service->type == SPICE_TUNNEL_SERVICE_TYPE_IPP) {
tunnel_worker_free_print_service(worker, (TunnelPrintService *)service);
} else {
- red_error("unexpected service type");
+ spice_error("unexpected service type");
}
}
@@ -1229,13 +1229,13 @@ static inline RedSocket *__tunnel_worker_find_free_socket(TunnelWorker *worker)
}
}
- ASSERT(ret);
+ spice_assert(ret);
return ret;
}
static inline void __tunnel_worker_add_socket(TunnelWorker *worker, RedSocket *sckt)
{
- ASSERT(!sckt->allocated);
+ spice_assert(!sckt->allocated);
sckt->allocated = TRUE;
worker->num_sockets++;
}
@@ -1244,7 +1244,7 @@ static inline void tunnel_worker_alloc_socket(TunnelWorker *worker, RedSocket *s
uint16_t local_port, TunnelService *far_service,
SlirpSocket *slirp_s)
{
- ASSERT(far_service);
+ spice_assert(far_service);
sckt->worker = worker;
sckt->local_port = local_port;
sckt->far_service = far_service;
@@ -1272,11 +1272,11 @@ static RedSocket *tunnel_worker_create_socket(TunnelWorker *worker, uint16_t loc
SlirpSocket *slirp_s)
{
RedSocket *new_socket;
- ASSERT(worker);
+ spice_assert(worker);
new_socket = __tunnel_worker_find_free_socket(worker);
if (!new_socket) {
- red_error("creation of RedSocket failed");
+ spice_error("creation of RedSocket failed");
}
tunnel_worker_alloc_socket(worker, new_socket, local_port, far_service, slirp_s);
@@ -1341,17 +1341,17 @@ static inline RedSocket *tunnel_worker_find_socket(TunnelWorker *worker,
static inline void __tunnel_socket_add_fin_to_pipe(TunnelChannelClient *channel, RedSocket *sckt)
{
- ASSERT(!red_channel_client_pipe_item_is_linked(&channel->base, &sckt->out_data.status_pipe_item));
+ spice_assert(!red_channel_client_pipe_item_is_linked(&channel->base, &sckt->out_data.status_pipe_item));
sckt->out_data.status_pipe_item.type = PIPE_ITEM_TYPE_SOCKET_FIN;
red_channel_client_pipe_add(&channel->base, &sckt->out_data.status_pipe_item);
}
static inline void __tunnel_socket_add_close_to_pipe(TunnelChannelClient *channel, RedSocket *sckt)
{
- ASSERT(!channel->mig_inprogress);
+ spice_assert(!channel->mig_inprogress);
if (red_channel_client_pipe_item_is_linked(&channel->base, &sckt->out_data.status_pipe_item)) {
- ASSERT(sckt->out_data.status_pipe_item.type == PIPE_ITEM_TYPE_SOCKET_FIN);
+ spice_assert(sckt->out_data.status_pipe_item.type == PIPE_ITEM_TYPE_SOCKET_FIN);
// close is stronger than FIN
red_channel_client_pipe_remove_and_release(&channel->base,
&sckt->out_data.status_pipe_item);
@@ -1363,10 +1363,10 @@ static inline void __tunnel_socket_add_close_to_pipe(TunnelChannelClient *channe
static inline void __tunnel_socket_add_close_ack_to_pipe(TunnelChannelClient *channel, RedSocket *sckt)
{
- ASSERT(!channel->mig_inprogress);
+ spice_assert(!channel->mig_inprogress);
if (red_channel_client_pipe_item_is_linked(&channel->base, &sckt->out_data.status_pipe_item)) {
- ASSERT(sckt->out_data.status_pipe_item.type == PIPE_ITEM_TYPE_SOCKET_FIN);
+ spice_assert(sckt->out_data.status_pipe_item.type == PIPE_ITEM_TYPE_SOCKET_FIN);
// close is stronger than FIN
red_channel_client_pipe_remove_and_release(&channel->base,
&sckt->out_data.status_pipe_item);
@@ -1414,7 +1414,7 @@ static int tunnel_channel_handle_socket_connect_ack(TunnelChannelClient *channel
uint32_t tokens)
{
#ifdef DEBUG_NETWORK
- red_printf("TUNNEL_DBG");
+ spice_printerr("TUNNEL_DBG");
#endif
if (channel->mig_inprogress || channel->base.channel->migrate) {
sckt->mig_client_status_msg = SPICE_MSGC_TUNNEL_SOCKET_OPEN_ACK;
@@ -1423,21 +1423,21 @@ static int tunnel_channel_handle_socket_connect_ack(TunnelChannelClient *channel
}
if (sckt->client_status != CLIENT_SCKT_STATUS_WAIT_OPEN) {
- red_printf("unexpected SPICE_MSGC_TUNNEL_SOCKET_OPEN_ACK status=%d", sckt->client_status);
+ spice_printerr("unexpected SPICE_MSGC_TUNNEL_SOCKET_OPEN_ACK status=%d", sckt->client_status);
return FALSE;
}
sckt->client_status = CLIENT_SCKT_STATUS_OPEN;
// SLIRP_SCKT_STATUS_CLOSED is possible after waiting for a connection has timed out
if (sckt->slirp_status == SLIRP_SCKT_STATUS_CLOSED) {
- ASSERT(!sckt->pushed_close);
+ spice_assert(!sckt->pushed_close);
__tunnel_socket_add_close_to_pipe(channel, sckt);
} else if (sckt->slirp_status == SLIRP_SCKT_STATUS_OPEN) {
sckt->out_data.window_size = tokens;
sckt->out_data.num_tokens = tokens;
net_slirp_socket_connected_notify(sckt->slirp_sckt);
} else {
- red_printf("unexpected slirp status status=%d", sckt->slirp_status);
+ spice_printerr("unexpected slirp status status=%d", sckt->slirp_status);
return FALSE;
}
@@ -1455,7 +1455,7 @@ static int tunnel_channel_handle_socket_connect_nack(TunnelChannelClient *channe
}
if (sckt->client_status != CLIENT_SCKT_STATUS_WAIT_OPEN) {
- red_printf("unexpected SPICE_MSGC_TUNNEL_SOCKET_OPEN_NACK status=%d", sckt->client_status);
+ spice_printerr("unexpected SPICE_MSGC_TUNNEL_SOCKET_OPEN_NACK status=%d", sckt->client_status);
return FALSE;
}
sckt->client_status = CLIENT_SCKT_STATUS_CLOSED;
@@ -1480,7 +1480,7 @@ static int tunnel_channel_handle_socket_fin(TunnelChannelClient *channel, RedSoc
}
if (sckt->client_status != CLIENT_SCKT_STATUS_OPEN) {
- red_printf("unexpected SPICE_MSGC_TUNNEL_SOCKET_FIN status=%d", sckt->client_status);
+ spice_printerr("unexpected SPICE_MSGC_TUNNEL_SOCKET_FIN status=%d", sckt->client_status);
return FALSE;
}
sckt->client_status = CLIENT_SCKT_STATUS_SHUTDOWN_SEND;
@@ -1497,7 +1497,7 @@ static int tunnel_channel_handle_socket_fin(TunnelChannelClient *channel, RedSoc
net_slirp_socket_can_receive_notify(sckt->slirp_sckt);
} else if (sckt->slirp_status == SLIRP_SCKT_STATUS_SHUTDOWN_RECV) {
// it already received the FIN
- red_printf("unexpected slirp status=%d", sckt->slirp_status);
+ spice_printerr("unexpected slirp status=%d", sckt->slirp_status);
return FALSE;
}
@@ -1546,7 +1546,7 @@ static int tunnel_channel_handle_socket_closed(TunnelChannelClient *channel, Red
// slirp can be in wait close if both slirp and client sent fin previously
// otherwise, the prev client status would also have been wait close, and this
// case was handled above
- red_printf("unexpected slirp_status=%d", sckt->slirp_status);
+ spice_printerr("unexpected slirp_status=%d", sckt->slirp_status);
return FALSE;
}
@@ -1571,7 +1571,7 @@ static int tunnel_channel_handle_socket_closed_ack(TunnelChannelClient *channel,
}
if (sckt->slirp_status != SLIRP_SCKT_STATUS_CLOSED) {
- red_printf("unexpected SPICE_MSGC_TUNNEL_SOCKET_CLOSED_ACK slirp_status=%d",
+ spice_printerr("unexpected SPICE_MSGC_TUNNEL_SOCKET_CLOSED_ACK slirp_status=%d",
sckt->slirp_status);
return FALSE;
}
@@ -1585,7 +1585,7 @@ static int tunnel_channel_handle_socket_receive_data(TunnelChannelClient *channe
{
if ((sckt->client_status == CLIENT_SCKT_STATUS_SHUTDOWN_SEND) ||
(sckt->client_status == CLIENT_SCKT_STATUS_CLOSED)) {
- red_printf("unexpected SPICE_MSGC_TUNNEL_SOCKET_DATA client_status=%d",
+ spice_printerr("unexpected SPICE_MSGC_TUNNEL_SOCKET_DATA client_status=%d",
sckt->client_status);
return FALSE;
}
@@ -1597,7 +1597,7 @@ static int tunnel_channel_handle_socket_receive_data(TunnelChannelClient *channe
return (!CHECK_TUNNEL_ERROR(channel));
} else if ((sckt->in_data.num_buffers == MAX_SOCKET_IN_BUFFERS) &&
!channel->mig_inprogress && !channel->base.channel->migrate) {
- red_printf("socket in buffers overflow, socket will be closed"
+ spice_printerr("socket in buffers overflow, socket will be closed"
" (local_port=%d, service_id=%d)",
ntohs(sckt->local_port), sckt->far_service->id);
__tunnel_worker_free_socket_rcv_buf(sckt->worker, recv_data);
@@ -1607,7 +1607,7 @@ static int tunnel_channel_handle_socket_receive_data(TunnelChannelClient *channe
tunnel_socket_assign_rcv_buf(sckt, recv_data, buf_size);
if (!sckt->in_data.client_total_num_tokens) {
- red_printf("token violation");
+ spice_printerr("token violation");
return FALSE;
}
@@ -1665,7 +1665,7 @@ static void tunnel_channel_release_msg_rcv_buf(RedChannelClient *rcc, uint16_t t
TunnelChannelClient *tunnel_channel = (TunnelChannelClient *)rcc->channel;
if (type == SPICE_MSGC_TUNNEL_SOCKET_DATA) {
- ASSERT(!(SPICE_CONTAINEROF(msg, RedSocketRawRcvBuf, buf)->base.usr_opaque));
+ spice_assert(!(SPICE_CONTAINEROF(msg, RedSocketRawRcvBuf, buf)->base.usr_opaque));
__tunnel_worker_free_socket_rcv_buf(tunnel_channel->worker,
SPICE_CONTAINEROF(msg, RedSocketRawRcvBuf, buf));
}
@@ -1683,7 +1683,8 @@ static void __tunnel_channel_fill_service_migrate_item(TunnelChannelClient *chan
general_data = &migrate_item->u.print_service.base;
memcpy(migrate_item->u.print_service.ip, ((TunnelPrintService *)service)->ip, 4);
} else {
- red_error("unexpected service type");
+ spice_error("unexpected service type");
+ abort();
}
general_data->type = service->type;
@@ -1755,7 +1756,7 @@ static int tunnel_channel_handle_migrate_mark(RedChannelClient *base)
RedSocket *sckt;
if (!channel->expect_migrate_mark) {
- red_printf("unexpected");
+ spice_printerr("unexpected");
return FALSE;
}
channel->expect_migrate_mark = FALSE;
@@ -1764,7 +1765,7 @@ static int tunnel_channel_handle_migrate_mark(RedChannelClient *base)
migrate_item->slirp_state_size = net_slirp_state_export(&migrate_item->slirp_state);
if (!migrate_item->slirp_state) {
- red_printf("failed export slirp state");
+ spice_printerr("failed export slirp state");
goto error;
}
@@ -1897,7 +1898,7 @@ RawTunneledBuffer *__tunnel_socket_alloc_restore_tokens_buf(RedSocket *sckt, int
buf->base.base.release_proc = restore_tokens_buf_release;
buf->num_tokens = num_tokens;
#ifdef DEBUG_NETWORK
- red_printf("TUNNEL DBG: num_tokens=%d", num_tokens);
+ spice_printerr("TUNNEL DBG: num_tokens=%d", num_tokens);
#endif
return &buf->base.base;
}
@@ -1982,7 +1983,7 @@ static void tunnel_channel_restore_migrated_socket(TunnelChannelClient *channel,
TunnelService *service;
sckt = channel->worker->sockets + mig_socket->connection_id;
sckt->connection_id = mig_socket->connection_id;
- ASSERT(!sckt->allocated);
+ spice_assert(!sckt->allocated);
/* Services must be restored before sockets */
service = tunnel_worker_find_service_by_id(channel->worker, mig_socket->far_service_id);
@@ -2061,7 +2062,7 @@ static void tunnel_channel_restore_migrated_socket(TunnelChannelClient *channel,
static void tunnel_channel_restore_socket_state(TunnelChannelClient *channel, RedSocket *sckt)
{
int ret = TRUE;
- red_printf("");
+ spice_printerr("");
// handling client status msgs that were received during migration
switch (sckt->mig_client_status_msg) {
case 0:
@@ -2183,18 +2184,18 @@ static uint64_t tunnel_channel_handle_migrate_data(RedChannelClient *base,
int i;
if (size < sizeof(TunnelMigrateData)) {
- red_printf("bad message size");
+ spice_printerr("bad message size");
goto error;
}
if (!channel->expect_migrate_data) {
- red_printf("unexpected");
+ spice_printerr("unexpected");
goto error;
}
channel->expect_migrate_data = FALSE;
if (migrate_data->magic != TUNNEL_MIGRATE_DATA_MAGIC ||
migrate_data->version != TUNNEL_MIGRATE_DATA_VERSION) {
- red_printf("invalid content");
+ spice_printerr("invalid content");
goto error;
}
@@ -2208,7 +2209,7 @@ static uint64_t tunnel_channel_handle_migrate_data(RedChannelClient *base,
services_list->services[i]),
migrate_data->data);
if (CHECK_TUNNEL_ERROR(channel)) {
- red_printf("failed restoring service");
+ spice_printerr("failed restoring service");
goto error;
}
}
@@ -2221,7 +2222,7 @@ static uint64_t tunnel_channel_handle_migrate_data(RedChannelClient *base,
sockets_list->sockets[i]),
migrate_data->data);
if (CHECK_TUNNEL_ERROR(channel)) {
- red_printf("failed restoring socket");
+ spice_printerr("failed restoring socket");
goto error;
}
}
@@ -2265,7 +2266,7 @@ static int tunnel_channel_handle_message(RedChannelClient *rcc, uint16_t type,
// the first field in these messages is connection id
sckt = tunnel_channel->worker->sockets + (*((uint16_t *)msg));
if (!sckt->allocated) {
- red_printf("red socket not found");
+ spice_printerr("red socket not found");
return FALSE;
}
break;
@@ -2276,18 +2277,18 @@ static int tunnel_channel_handle_message(RedChannelClient *rcc, uint16_t type,
switch (type) {
case SPICE_MSGC_TUNNEL_SERVICE_ADD:
if (size < sizeof(SpiceMsgcTunnelAddGenericService)) {
- red_printf("bad message size");
+ spice_printerr("bad message size");
free(msg);
return FALSE;
}
return tunnel_channel_handle_service_add(tunnel_channel,
(SpiceMsgcTunnelAddGenericService *)msg);
case SPICE_MSGC_TUNNEL_SERVICE_REMOVE:
- red_printf("REDC_TUNNEL_REMOVE_SERVICE not supported yet");
+ spice_printerr("REDC_TUNNEL_REMOVE_SERVICE not supported yet");
return FALSE;
case SPICE_MSGC_TUNNEL_SOCKET_OPEN_ACK:
if (size != sizeof(SpiceMsgcTunnelSocketOpenAck)) {
- red_printf("bad message size");
+ spice_printerr("bad message size");
return FALSE;
}
@@ -2296,7 +2297,7 @@ static int tunnel_channel_handle_message(RedChannelClient *rcc, uint16_t type,
case SPICE_MSGC_TUNNEL_SOCKET_OPEN_NACK:
if (size != sizeof(SpiceMsgcTunnelSocketOpenNack)) {
- red_printf("bad message size");
+ spice_printerr("bad message size");
return FALSE;
}
@@ -2304,7 +2305,7 @@ static int tunnel_channel_handle_message(RedChannelClient *rcc, uint16_t type,
case SPICE_MSGC_TUNNEL_SOCKET_DATA:
{
if (size < sizeof(SpiceMsgcTunnelSocketData)) {
- red_printf("bad message size");
+ spice_printerr("bad message size");
return FALSE;
}
@@ -2314,25 +2315,25 @@ static int tunnel_channel_handle_message(RedChannelClient *rcc, uint16_t type,
}
case SPICE_MSGC_TUNNEL_SOCKET_FIN:
if (size != sizeof(SpiceMsgcTunnelSocketFin)) {
- red_printf("bad message size");
+ spice_printerr("bad message size");
return FALSE;
}
return tunnel_channel_handle_socket_fin(tunnel_channel, sckt);
case SPICE_MSGC_TUNNEL_SOCKET_CLOSED:
if (size != sizeof(SpiceMsgcTunnelSocketClosed)) {
- red_printf("bad message size");
+ spice_printerr("bad message size");
return FALSE;
}
return tunnel_channel_handle_socket_closed(tunnel_channel, sckt);
case SPICE_MSGC_TUNNEL_SOCKET_CLOSED_ACK:
if (size != sizeof(SpiceMsgcTunnelSocketClosedAck)) {
- red_printf("bad message size");
+ spice_printerr("bad message size");
return FALSE;
}
return tunnel_channel_handle_socket_closed_ack(tunnel_channel, sckt);
case SPICE_MSGC_TUNNEL_SOCKET_TOKEN:
if (size != sizeof(SpiceMsgcTunnelSocketTokens)) {
- red_printf("bad message size");
+ spice_printerr("bad message size");
return FALSE;
}
@@ -2352,7 +2353,7 @@ static void tunnel_channel_marshall_migrate(RedChannelClient *rcc, SpiceMarshall
{
TunnelChannelClient *tunnel_channel;
- ASSERT(rcc);
+ spice_assert(rcc);
tunnel_channel = SPICE_CONTAINEROF(rcc->channel, TunnelChannelClient, base);
tunnel_channel->send_data.u.migrate.flags =
SPICE_MIGRATE_NEED_FLUSH | SPICE_MIGRATE_NEED_DATA_TRANSFER;
@@ -2417,7 +2418,8 @@ static int __tunnel_channel_marshall_service_migrate_data(TunnelChannelClient *c
sizeof(item->u.print_service));
cur_offset += sizeof(item->u.print_service);
} else {
- red_error("unexpected service type");
+ spice_error("unexpected service type");
+ abort();
}
generic_data->name = cur_offset;
@@ -2506,7 +2508,7 @@ static void tunnel_channel_marshall_migrate_data(RedChannelClient *rcc,
int i;
uint32_t data_buf_offset = 0; // current location in data[0] field
- ASSERT(rcc);
+ spice_assert(rcc);
tunnel_channel = SPICE_CONTAINEROF(rcc->channel, TunnelChannelClient, base);
migrate_data = &tunnel_channel->send_data.u.migrate_data;
@@ -2550,7 +2552,7 @@ static void tunnel_channel_marshall_init(RedChannelClient *rcc, SpiceMarshaller
{
TunnelChannelClient *channel;
- ASSERT(rcc);
+ spice_assert(rcc);
channel = SPICE_CONTAINEROF(rcc->channel, TunnelChannelClient, base);
channel->send_data.u.init.max_socket_data_size = MAX_SOCKET_DATA_SIZE;
channel->send_data.u.init.max_num_of_sockets = MAX_SOCKETS_NUM;
@@ -2601,11 +2603,11 @@ static void tunnel_channel_marshall_socket_fin(RedChannelClient *rcc, SpiceMarsh
RedSocketOutData *sckt_out_data = SPICE_CONTAINEROF(item, RedSocketOutData, status_pipe_item);
RedSocket *sckt = SPICE_CONTAINEROF(sckt_out_data, RedSocket, out_data);
- ASSERT(!sckt->out_data.ready_chunks_queue.head);
+ spice_assert(!sckt->out_data.ready_chunks_queue.head);
tunnel_channel = SPICE_CONTAINEROF(rcc->channel, TunnelChannelClient, base);
if (sckt->out_data.process_queue->head) {
- red_printf("socket sent FIN but there are still buffers in outgoing process queue"
+ spice_printerr("socket sent FIN but there are still buffers in outgoing process queue"
"(local_port=%d, service_id=%d)",
ntohs(sckt->local_port), sckt->far_service->id);
}
@@ -2629,14 +2631,14 @@ static void tunnel_channel_marshall_socket_close(RedChannelClient *rcc, SpiceMar
tunnel_channel = SPICE_CONTAINEROF(rcc->channel, TunnelChannelClient, base);
// can happen when it is a forced close
if (sckt->out_data.ready_chunks_queue.head) {
- red_printf("socket closed but there are still buffers in outgoing ready queue"
+ spice_printerr("socket closed but there are still buffers in outgoing ready queue"
"(local_port=%d, service_id=%d)",
ntohs(sckt->local_port),
sckt->far_service->id);
}
if (sckt->out_data.process_queue->head) {
- red_printf("socket closed but there are still buffers in outgoing process queue"
+ spice_printerr("socket closed but there are still buffers in outgoing process queue"
"(local_port=%d, service_id=%d)",
ntohs(sckt->local_port), sckt->far_service->id);
}
@@ -2668,7 +2670,7 @@ static void tunnel_channel_marshall_socket_closed_ack(RedChannelClient *rcc, Spi
PRINT_SCKT(sckt);
#endif
- ASSERT(sckt->client_waits_close_ack && (sckt->client_status == CLIENT_SCKT_STATUS_CLOSED));
+ spice_assert(sckt->client_waits_close_ack && (sckt->client_status == CLIENT_SCKT_STATUS_CLOSED));
tunnel_worker_free_socket(tunnel_channel->worker, sckt);
if (CHECK_TUNNEL_ERROR(tunnel_channel)) {
tunnel_shutdown(tunnel_channel->worker);
@@ -2690,12 +2692,12 @@ static void tunnel_channel_marshall_socket_token(RedChannelClient *rcc, SpiceMar
if (sckt->in_data.num_tokens > 0) {
tunnel_channel->send_data.u.socket_token.num_tokens = sckt->in_data.num_tokens;
} else {
- ASSERT(!sckt->in_data.client_total_num_tokens && !sckt->in_data.ready_chunks_queue.head);
+ spice_assert(!sckt->in_data.client_total_num_tokens && !sckt->in_data.ready_chunks_queue.head);
tunnel_channel->send_data.u.socket_token.num_tokens = SOCKET_TOKENS_TO_SEND_FOR_PROCESS;
}
sckt->in_data.num_tokens -= tunnel_channel->send_data.u.socket_token.num_tokens;
sckt->in_data.client_total_num_tokens += tunnel_channel->send_data.u.socket_token.num_tokens;
- ASSERT(sckt->in_data.client_total_num_tokens <= SOCKET_WINDOW_SIZE);
+ spice_assert(sckt->in_data.client_total_num_tokens <= SOCKET_WINDOW_SIZE);
red_channel_client_init_send_data(rcc, SPICE_MSG_TUNNEL_SOCKET_TOKEN, item);
spice_marshaller_add_ref(m, (uint8_t*)&tunnel_channel->send_data.u.socket_token,
@@ -2712,7 +2714,7 @@ static void tunnel_channel_marshall_socket_out_data(RedChannelClient *rcc, Spice
uint32_t total_push_size = 0;
uint32_t pushed_bufs_num = 0;
- ASSERT(!sckt->pushed_close);
+ spice_assert(!sckt->pushed_close);
if (sckt->client_status == CLIENT_SCKT_STATUS_CLOSED) {
return;
}
@@ -2721,9 +2723,9 @@ static void tunnel_channel_marshall_socket_out_data(RedChannelClient *rcc, Spice
return; // only when an we will receive tokens, data will be sent again.
}
- ASSERT(sckt->out_data.ready_chunks_queue.head);
- ASSERT(!sckt->out_data.push_tail);
- ASSERT(sckt->out_data.ready_chunks_queue.head->size <= MAX_SOCKET_DATA_SIZE);
+ spice_assert(sckt->out_data.ready_chunks_queue.head);
+ spice_assert(!sckt->out_data.push_tail);
+ spice_assert(sckt->out_data.ready_chunks_queue.head->size <= MAX_SOCKET_DATA_SIZE);
tunnel_channel->send_data.u.socket_data.connection_id = sckt->connection_id;
@@ -2763,7 +2765,7 @@ static void tunnel_worker_release_socket_out_data(TunnelWorker *worker, PipeItem
RedSocketOutData *sckt_out_data = SPICE_CONTAINEROF(item, RedSocketOutData, data_pipe_item);
RedSocket *sckt = SPICE_CONTAINEROF(sckt_out_data, RedSocket, out_data);
- ASSERT(sckt_out_data->ready_chunks_queue.head);
+ spice_assert(sckt_out_data->ready_chunks_queue.head);
while (sckt_out_data->ready_chunks_queue.head != sckt_out_data->push_tail) {
sckt_out_data->data_size -= sckt_out_data->ready_chunks_queue.head->size;
@@ -2850,7 +2852,7 @@ static void tunnel_channel_send_item(RedChannelClient *rcc, PipeItem *item)
tunnel_channel_marshall_migrate_data(rcc, m, item);
break;
default:
- red_error("invalid pipe item type");
+ spice_error("invalid pipe item type");
}
red_channel_client_begin_send_message(rcc);
}
@@ -2886,7 +2888,7 @@ static void tunnel_channel_release_pipe_item(RedChannelClient *rcc, PipeItem *it
release_migrate_item((TunnelMigrateItem *)item);
break;
default:
- red_error("invalid pipe item type");
+ spice_error("invalid pipe item type");
}
}
@@ -2924,14 +2926,14 @@ static int tunnel_socket_connect(SlirpUsrNetworkInterface *usr_interface,
RedSocket *sckt;
TunnelService *far_service;
- ASSERT(usr_interface);
+ spice_assert(usr_interface);
#ifdef DEBUG_NETWORK
- red_printf("TUNNEL_DBG");
+ spice_printerr("TUNNEL_DBG");
#endif
worker = ((RedSlirpNetworkInterface *)usr_interface)->worker;
- ASSERT(worker->channel_client);
- ASSERT(!worker->channel_client->mig_inprogress);
+ spice_assert(worker->channel_client);
+ spice_assert(!worker->channel_client->mig_inprogress);
far_service = tunnel_worker_find_service_by_addr(worker, &dst_addr, (uint32_t)ntohs(dst_port));
@@ -2941,13 +2943,13 @@ static int tunnel_socket_connect(SlirpUsrNetworkInterface *usr_interface,
}
if (tunnel_worker_find_socket(worker, src_port, far_service->id)) {
- red_printf("slirp tried to open a socket that is still opened");
+ spice_printerr("slirp tried to open a socket that is still opened");
errno = EADDRINUSE;
return -1;
}
if (worker->num_sockets == MAX_SOCKETS_NUM) {
- red_printf("number of tunneled sockets exceeds the limit");
+ spice_printerr("number of tunneled sockets exceeds the limit");
errno = ENFILE;
return -1;
}
@@ -2979,12 +2981,12 @@ static int tunnel_socket_send(SlirpUsrNetworkInterface *usr_interface, UserSocke
RedSocket *sckt;
size_t size_to_send;
- ASSERT(usr_interface);
- ASSERT(opaque);
+ spice_assert(usr_interface);
+ spice_assert(opaque);
worker = ((RedSlirpNetworkInterface *)usr_interface)->worker;
- ASSERT(!worker->channel_client->mig_inprogress);
+ spice_assert(!worker->channel_client->mig_inprogress);
sckt = (RedSocket *)opaque;
@@ -2995,7 +2997,7 @@ static int tunnel_socket_send(SlirpUsrNetworkInterface *usr_interface, UserSocke
if ((sckt->client_status != CLIENT_SCKT_STATUS_OPEN) &&
(sckt->client_status != CLIENT_SCKT_STATUS_SHUTDOWN_SEND)) {
- red_printf("client socket is unable to receive data");
+ spice_printerr("client socket is unable to receive data");
errno = ECONNRESET;
return -1;
}
@@ -3003,7 +3005,7 @@ static int tunnel_socket_send(SlirpUsrNetworkInterface *usr_interface, UserSocke
if ((sckt->slirp_status == SLIRP_SCKT_STATUS_SHUTDOWN_SEND) ||
(sckt->slirp_status == SLIRP_SCKT_STATUS_WAIT_CLOSE)) {
- red_printf("send was shutdown");
+ spice_printerr("send was shutdown");
errno = EPIPE;
return -1;
}
@@ -3026,10 +3028,10 @@ static int tunnel_socket_send(SlirpUsrNetworkInterface *usr_interface, UserSocke
// and buffers will be released, we will try to send again.
size_to_send = 0;
} else {
- ASSERT(sckt->out_data.process_queue->head);
+ spice_assert(sckt->out_data.process_queue->head);
if ((sckt->out_data.data_size + len) >
(MAX_SOCKET_OUT_BUFFERS * MAX_SOCKET_DATA_SIZE)) {
- red_printf("socket out buffers overflow, socket will be closed"
+ spice_printerr("socket out buffers overflow, socket will be closed"
" (local_port=%d, service_id=%d)",
ntohs(sckt->local_port), sckt->far_service->id);
tunnel_socket_force_close(worker->channel_client, sckt);
@@ -3084,11 +3086,11 @@ static int tunnel_socket_recv(SlirpUsrNetworkInterface *usr_interface, UserSocke
RedSocket *sckt;
int copied = 0;
- ASSERT(usr_interface);
- ASSERT(opaque);
+ spice_assert(usr_interface);
+ spice_assert(opaque);
worker = ((RedSlirpNetworkInterface *)usr_interface)->worker;
- ASSERT(!worker->channel_client->mig_inprogress);
+ spice_assert(!worker->channel_client->mig_inprogress);
sckt = (RedSocket *)opaque;
@@ -3112,7 +3114,7 @@ static int tunnel_socket_recv(SlirpUsrNetworkInterface *usr_interface, UserSocke
return -1;
}
- ASSERT((sckt->client_status == CLIENT_SCKT_STATUS_OPEN) ||
+ spice_assert((sckt->client_status == CLIENT_SCKT_STATUS_OPEN) ||
(sckt->client_status == CLIENT_SCKT_STATUS_SHUTDOWN_SEND) ||
((sckt->client_status == CLIENT_SCKT_STATUS_CLOSED) &&
(sckt->slirp_status == SLIRP_SCKT_STATUS_SHUTDOWN_SEND)));
@@ -3121,7 +3123,7 @@ static int tunnel_socket_recv(SlirpUsrNetworkInterface *usr_interface, UserSocke
// if there is data in ready queue, when it is acked, slirp will call recv and get 0
if (__should_send_fin_to_guest(sckt)) {
if (sckt->in_data.process_queue->head) {
- red_printf("client socket sent FIN but there are still buffers in incoming process"
+ spice_printerr("client socket sent FIN but there are still buffers in incoming process"
"queue (local_port=%d, service_id=%d)",
ntohs(sckt->local_port), sckt->far_service->id);
}
@@ -3139,7 +3141,7 @@ static int tunnel_socket_recv(SlirpUsrNetworkInterface *usr_interface, UserSocke
ready_queue_pop_chunk(&sckt->in_data.ready_chunks_queue);
sckt->in_data.ready_chunks_queue.offset = 0;
} else {
- ASSERT(copied == len);
+ spice_assert(copied == len);
sckt->in_data.ready_chunks_queue.offset += copy_count;
}
}
@@ -3164,15 +3166,15 @@ static void tunnel_socket_shutdown_send(SlirpUsrNetworkInterface *usr_interface,
TunnelWorker *worker;
RedSocket *sckt;
- ASSERT(usr_interface);
- ASSERT(opaque);
+ spice_assert(usr_interface);
+ spice_assert(opaque);
worker = ((RedSlirpNetworkInterface *)usr_interface)->worker;
sckt = (RedSocket *)opaque;
#ifdef DEBUG_NETWORK
PRINT_SCKT(sckt);
#endif
- ASSERT(!worker->channel_client->mig_inprogress);
+ spice_assert(!worker->channel_client->mig_inprogress);
if (sckt->slirp_status == SLIRP_SCKT_STATUS_DELAY_ABORT) {
return;
@@ -3181,7 +3183,7 @@ static void tunnel_socket_shutdown_send(SlirpUsrNetworkInterface *usr_interface,
if (sckt->slirp_status == SLIRP_SCKT_STATUS_OPEN) {
sckt->slirp_status = SLIRP_SCKT_STATUS_SHUTDOWN_SEND;
} else if (sckt->slirp_status == SLIRP_SCKT_STATUS_SHUTDOWN_RECV) {
- ASSERT(sckt->client_status == CLIENT_SCKT_STATUS_SHUTDOWN_SEND);
+ spice_assert(sckt->client_status == CLIENT_SCKT_STATUS_SHUTDOWN_SEND);
sckt->slirp_status = SLIRP_SCKT_STATUS_WAIT_CLOSE;
} else {
SET_TUNNEL_ERROR(worker->channel_client, "unexpected tunnel_socket_shutdown_send slirp_status=%d",
@@ -3216,15 +3218,15 @@ static void tunnel_socket_shutdown_recv(SlirpUsrNetworkInterface *usr_interface,
TunnelWorker *worker;
RedSocket *sckt;
- ASSERT(usr_interface);
- ASSERT(opaque);
+ spice_assert(usr_interface);
+ spice_assert(opaque);
worker = ((RedSlirpNetworkInterface *)usr_interface)->worker;
sckt = (RedSocket *)opaque;
#ifdef DEBUG_NETWORK
PRINT_SCKT(sckt);
#endif
- ASSERT(!worker->channel_client->mig_inprogress);
+ spice_assert(!worker->channel_client->mig_inprogress);
/* failure in recv can happen after the client sckt was shutdown
(after client sent FIN, or after slirp sent FIN and client socket was closed */
@@ -3253,8 +3255,8 @@ static void null_tunnel_socket_close(SlirpUsrNetworkInterface *usr_interface, Us
TunnelWorker *worker;
RedSocket *sckt;
- ASSERT(usr_interface);
- ASSERT(opaque);
+ spice_assert(usr_interface);
+ spice_assert(opaque);
worker = ((RedSlirpNetworkInterface *)usr_interface)->worker;
@@ -3278,8 +3280,8 @@ static void tunnel_socket_close(SlirpUsrNetworkInterface *usr_interface, UserSoc
TunnelWorker *worker;
RedSocket *sckt;
- ASSERT(usr_interface);
- ASSERT(opaque);
+ spice_assert(usr_interface);
+ spice_assert(opaque);
worker = ((RedSlirpNetworkInterface *)usr_interface)->worker;
@@ -3313,7 +3315,7 @@ static UserTimer *create_timer(SlirpUsrNetworkInterface *usr_interface,
{
TunnelWorker *worker;
- ASSERT(usr_interface);
+ spice_assert(usr_interface);
worker = ((RedSlirpNetworkInterface *)usr_interface)->worker;
@@ -3324,12 +3326,12 @@ static void arm_timer(SlirpUsrNetworkInterface *usr_interface, UserTimer *timer,
{
TunnelWorker *worker;
- ASSERT(usr_interface);
+ spice_assert(usr_interface);
worker = ((RedSlirpNetworkInterface *)usr_interface)->worker;
#ifdef DEBUG_NETWORK
if (!worker->channel_client) {
- red_printf("channel not connected");
+ spice_printerr("channel not connected");
}
#endif
if (worker->channel_client && worker->channel_client->mig_inprogress) {
@@ -3352,12 +3354,12 @@ static int tunnel_channel_config_socket(RedChannelClient *rcc)
RedsStream *stream = red_channel_client_get_stream(rcc);
if ((flags = fcntl(stream->socket, F_GETFL)) == -1) {
- red_printf("accept failed, %s", strerror(errno)); // can't we just use red_error?
+ spice_printerr("accept failed, %s", strerror(errno)); // can't we just use spice_error?
return FALSE;
}
if (fcntl(stream->socket, F_SETFL, flags | O_NONBLOCK) == -1) {
- red_printf("accept failed, %s", strerror(errno));
+ spice_printerr("accept failed, %s", strerror(errno));
return FALSE;
}
@@ -3366,7 +3368,7 @@ static int tunnel_channel_config_socket(RedChannelClient *rcc)
if (setsockopt(stream->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val,
sizeof(delay_val)) == -1) {
if (errno != ENOTSUP) {
- red_printf("setsockopt failed, %s", strerror(errno));
+ spice_printerr("setsockopt failed, %s", strerror(errno));
}
}
@@ -3401,7 +3403,7 @@ static void tunnel_channel_on_disconnect(RedChannel *channel)
if (!channel) {
return;
}
- red_printf("");
+ spice_printerr("");
worker = (TunnelWorker *)channel->data;
tunnel_worker_disconnect_slirp(worker);
@@ -3444,7 +3446,7 @@ static void handle_tunnel_channel_link(RedChannel *channel, RedClient *client,
TunnelWorker *worker = (TunnelWorker *)channel->data;
if (worker->channel_client) {
- red_error("tunnel does not support multiple client");
+ spice_error("tunnel does not support multiple client");
}
tcc = (TunnelChannelClient*)red_channel_client_create(sizeof(TunnelChannelClient),
@@ -3462,10 +3464,10 @@ static void handle_tunnel_channel_client_migrate(RedChannelClient *rcc)
{
TunnelChannelClient *tunnel_channel;
#ifdef DEBUG_NETWORK
- red_printf("TUNNEL_DBG: MIGRATE STARTED");
+ spice_printerr("TUNNEL_DBG: MIGRATE STARTED");
#endif
tunnel_channel = (TunnelChannelClient *)rcc;
- ASSERT(tunnel_channel == tunnel_channel->worker->channel_client);
+ spice_assert(tunnel_channel == tunnel_channel->worker->channel_client);
tunnel_channel->mig_inprogress = TRUE;
net_slirp_freeze();
red_channel_client_pipe_add_type(rcc, PIPE_ITEM_TYPE_MIGRATE);
diff --git a/server/red_worker.c b/server/red_worker.c
index 172a571..c17a7d0 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -19,6 +19,8 @@
#include <config.h>
#endif
+#define SPICE_LOG_DOMAIN "SpiceWorker"
+
/* Common variable abberiviations:
*
* rcc - RedChannelClient
@@ -1113,46 +1115,46 @@ static void print_compress_stats(DisplayChannel *display_channel)
display_channel->zlib_glz_stat.comp_size :
display_channel->glz_stat.comp_size;
- red_printf("==> Compression stats for display %u", display_channel->common.id);
- red_printf("Method \t count \torig_size(MB)\tenc_size(MB)\tenc_time(s)");
- red_printf("QUIC \t%8d\t%13.2f\t%12.2f\t%12.2f",
+ spice_printerr("==> Compression stats for display %u", display_channel->common.id);
+ spice_printerr("Method \t count \torig_size(MB)\tenc_size(MB)\tenc_time(s)");
+ spice_printerr("QUIC \t%8d\t%13.2f\t%12.2f\t%12.2f",
display_channel->quic_stat.count,
stat_byte_to_mega(display_channel->quic_stat.orig_size),
stat_byte_to_mega(display_channel->quic_stat.comp_size),
stat_cpu_time_to_sec(display_channel->quic_stat.total)
);
- red_printf("GLZ \t%8d\t%13.2f\t%12.2f\t%12.2f",
+ spice_printerr("GLZ \t%8d\t%13.2f\t%12.2f\t%12.2f",
display_channel->glz_stat.count,
stat_byte_to_mega(display_channel->glz_stat.orig_size),
stat_byte_to_mega(display_channel->glz_stat.comp_size),
stat_cpu_time_to_sec(display_channel->glz_stat.total)
);
- red_printf("ZLIB GLZ \t%8d\t%13.2f\t%12.2f\t%12.2f",
+ spice_printerr("ZLIB GLZ \t%8d\t%13.2f\t%12.2f\t%12.2f",
display_channel->zlib_glz_stat.count,
stat_byte_to_mega(display_channel->zlib_glz_stat.orig_size),
stat_byte_to_mega(display_channel->zlib_glz_stat.comp_size),
stat_cpu_time_to_sec(display_channel->zlib_glz_stat.total)
);
- red_printf("LZ \t%8d\t%13.2f\t%12.2f\t%12.2f",
+ spice_printerr("LZ \t%8d\t%13.2f\t%12.2f\t%12.2f",
display_channel->lz_stat.count,
stat_byte_to_mega(display_channel->lz_stat.orig_size),
stat_byte_to_mega(display_channel->lz_stat.comp_size),
stat_cpu_time_to_sec(display_channel->lz_stat.total)
);
- red_printf("JPEG \t%8d\t%13.2f\t%12.2f\t%12.2f",
+ spice_printerr("JPEG \t%8d\t%13.2f\t%12.2f\t%12.2f",
display_channel->jpeg_stat.count,
stat_byte_to_mega(display_channel->jpeg_stat.orig_size),
stat_byte_to_mega(display_channel->jpeg_stat.comp_size),
stat_cpu_time_to_sec(display_channel->jpeg_stat.total)
);
- red_printf("JPEG-RGBA\t%8d\t%13.2f\t%12.2f\t%12.2f",
+ spice_printerr("JPEG-RGBA\t%8d\t%13.2f\t%12.2f\t%12.2f",
display_channel->jpeg_alpha_stat.count,
stat_byte_to_mega(display_channel->jpeg_alpha_stat.orig_size),
stat_byte_to_mega(display_channel->jpeg_alpha_stat.comp_size),
stat_cpu_time_to_sec(display_channel->jpeg_alpha_stat.total)
);
- red_printf("-------------------------------------------------------------------");
- red_printf("Total \t%8d\t%13.2f\t%12.2f\t%12.2f",
+ spice_printerr("-------------------------------------------------------------------");
+ spice_printerr("Total \t%8d\t%13.2f\t%12.2f\t%12.2f",
display_channel->lz_stat.count + display_channel->glz_stat.count +
display_channel->quic_stat.count +
display_channel->jpeg_stat.count +
@@ -1188,15 +1190,15 @@ static inline int is_primary_surface(RedWorker *worker, uint32_t surface_id)
static inline void __validate_surface(RedWorker *worker, uint32_t surface_id)
{
- PANIC_ON(surface_id >= worker->n_surfaces);
+ spice_warn_if(surface_id >= worker->n_surfaces);
}
static inline void validate_surface(RedWorker *worker, uint32_t surface_id)
{
- PANIC_ON(surface_id >= worker->n_surfaces);
+ spice_warn_if(surface_id >= worker->n_surfaces);
if (!worker->surfaces[surface_id].context.canvas) {
- red_printf("failed on %d", surface_id);
- PANIC_ON(!worker->surfaces[surface_id].context.canvas);
+ spice_printerr("failed on %d", surface_id);
+ spice_warn_if(!worker->surfaces[surface_id].context.canvas);
}
}
@@ -1264,7 +1266,7 @@ static void show_red_drawable(RedWorker *worker, RedDrawable *drawable, const ch
case QXL_DRAW_TEXT:
break;
default:
- red_error("bad drawable type");
+ spice_error("bad drawable type");
}
printf("\n");
}
@@ -1363,8 +1365,8 @@ static void put_drawable_pipe_item(DrawablePipeItem *dpi)
return;
}
- ASSERT(!ring_item_is_linked(&dpi->dpi_pipe_item.link));
- ASSERT(!ring_item_is_linked(&dpi->base));
+ spice_assert(!ring_item_is_linked(&dpi->dpi_pipe_item.link));
+ spice_assert(!ring_item_is_linked(&dpi->base));
release_drawable(worker, dpi->drawable);
free(dpi);
}
@@ -1387,7 +1389,7 @@ static inline DrawablePipeItem *get_drawable_pipe_item(DisplayChannelClient *dcc
static inline DrawablePipeItem *ref_drawable_pipe_item(DrawablePipeItem *dpi)
{
- ASSERT(dpi->drawable);
+ spice_assert(dpi->drawable);
dpi->refs++;
return dpi;
}
@@ -1406,7 +1408,7 @@ static inline void red_pipes_add_drawable(RedWorker *worker, Drawable *drawable)
DisplayChannelClient *dcc;
RingItem *dcc_ring_item;
- PANIC_ON(!ring_is_empty(&drawable->pipes));
+ spice_warn_if(!ring_is_empty(&drawable->pipes));
WORKER_FOREACH_DCC(worker, dcc_ring_item, dcc) {
red_pipe_add_drawable(dcc, drawable);
}
@@ -1446,7 +1448,7 @@ static inline void red_pipes_add_drawable_after(RedWorker *worker,
}
if (num_other_linked != worker->display_channel->common.base.clients_num) {
RingItem *worker_item;
- red_printf("TODO: not O(n^2)");
+ spice_printerr("TODO: not O(n^2)");
WORKER_FOREACH_DCC(worker, worker_item, dcc) {
int sent = 0;
DRAWABLE_FOREACH_DPI(pos_after, dpi_link, dpi_pos_after) {
@@ -1592,7 +1594,7 @@ static SurfaceDestroyItem *get_surface_destroy_item(RedChannel *channel,
SurfaceDestroyItem *destroy;
destroy = (SurfaceDestroyItem *)malloc(sizeof(SurfaceDestroyItem));
- PANIC_ON(!destroy);
+ spice_warn_if(!destroy);
destroy->surface_destroy.surface_id = surface_id;
@@ -1628,7 +1630,7 @@ static inline void red_destroy_surface(RedWorker *worker, uint32_t surface_id)
if (is_primary_surface(worker, surface_id)) {
red_reset_stream_trace(worker);
}
- ASSERT(surface->context.canvas);
+ spice_assert(surface->context.canvas);
surface->context.canvas->ops->destroy(surface->context.canvas);
if (surface->create.info) {
@@ -1644,7 +1646,7 @@ static inline void red_destroy_surface(RedWorker *worker, uint32_t surface_id)
red_destroy_surface_item(worker, dcc, surface_id);
}
- PANIC_ON(!ring_is_empty(&surface->depend_on_me));
+ spice_warn_if(!ring_is_empty(&surface->depend_on_me));
}
}
@@ -1693,8 +1695,8 @@ static inline void put_red_drawable(RedWorker *worker, RedDrawable *drawable, ui
static void remove_depended_item(DependItem *item)
{
- ASSERT(item->drawable);
- ASSERT(ring_item_is_linked(&item->ring_item));
+ spice_assert(item->drawable);
+ spice_assert(ring_item_is_linked(&item->ring_item));
item->drawable = NULL;
ring_remove(&item->ring_item);
}
@@ -1731,9 +1733,9 @@ static inline void release_drawable(RedWorker *worker, Drawable *drawable)
RingItem *item, *next;
if (!--drawable->refs) {
- ASSERT(!drawable->stream);
- ASSERT(!drawable->tree_item.shadow);
- ASSERT(ring_is_empty(&drawable->pipes));
+ spice_assert(!drawable->stream);
+ spice_assert(!drawable->tree_item.shadow);
+ spice_assert(ring_is_empty(&drawable->pipes));
region_destroy(&drawable->tree_item.base.rgn);
remove_drawable_dependencies(worker, drawable);
@@ -1769,7 +1771,7 @@ static inline void remove_shadow(RedWorker *worker, DrawItem *item)
static inline void current_remove_container(RedWorker *worker, Container *container)
{
- ASSERT(ring_is_empty(&container->items));
+ spice_assert(ring_is_empty(&container->items));
worker->containers_count--;
ring_remove(&container->base.siblings_link);
region_destroy(&container->base.rgn);
@@ -1782,7 +1784,7 @@ static inline void container_cleanup(RedWorker *worker, Container *container)
Container *next = container->base.container;
if (container->items.next != &container->items) {
TreeItem *item = (TreeItem *)ring_get_head(&container->items);
- ASSERT(item);
+ spice_assert(item);
ring_remove(&item->siblings_link);
ring_add_after(&item->siblings_link, &container->base.siblings_link);
item->container = container->base.container;
@@ -1867,7 +1869,7 @@ static inline void current_remove(RedWorker *worker, TreeItem *item)
} else {
Container *container = (Container *)now;
- ASSERT(now->type == TREE_ITEM_TYPE_CONTAINER);
+ spice_assert(now->type == TREE_ITEM_TYPE_CONTAINER);
if ((ring_item = ring_get_head(&container->items))) {
now = SPICE_CONTAINEROF(ring_item, TreeItem, siblings_link);
@@ -2080,7 +2082,7 @@ static void print_base_item(const char* prefix, const TreeItem *base)
print_container_item(prefix, (const Container *)base);
break;
default:
- red_error("invalid type %u", base->type);
+ spice_error("invalid type %u", base->type);
}
}
@@ -2092,7 +2094,7 @@ void __show_current(TreeItem *item, void *data)
static void show_current(RedWorker *worker, Ring *ring)
{
if (ring_is_empty(ring)) {
- red_printf("TEST: TREE: EMPTY");
+ spice_printerr("TEST: TREE: EMPTY");
return;
}
current_tree_for_each(ring, __show_current, NULL);
@@ -2128,7 +2130,7 @@ static inline Ring *ring_of(RedWorker *worker, Ring *ring, TreeItem *item)
static inline int __contained_by(RedWorker *worker, TreeItem *item, Ring *ring)
{
- ASSERT(item && ring);
+ spice_assert(item && ring);
do {
Ring *now = ring_of(worker, ring, item);
if (now == ring) {
@@ -2200,7 +2202,7 @@ static inline void __exclude_region(RedWorker *worker, Ring *ring, TreeItem *ite
} else {
Shadow *shadow;
- ASSERT(item->type == TREE_ITEM_TYPE_SHADOW);
+ spice_assert(item->type == TREE_ITEM_TYPE_SHADOW);
shadow = (Shadow *)item;
region_exclude(rgn, &and_rgn);
region_or(&shadow->on_hold, &and_rgn);
@@ -2228,7 +2230,7 @@ static void exclude_region(RedWorker *worker, Ring *ring, RingItem *ring_item, Q
TreeItem *now = SPICE_CONTAINEROF(ring_item, TreeItem, siblings_link);
Container *container = now->container;
- ASSERT(!region_is_empty(&now->rgn));
+ spice_assert(!region_is_empty(&now->rgn));
if (region_intersects(rgn, &now->rgn)) {
print_base_item("EXCLUDE2", now);
@@ -2236,7 +2238,7 @@ static void exclude_region(RedWorker *worker, Ring *ring, RingItem *ring_item, Q
print_base_item("EXCLUDE3", now);
if (region_is_empty(&now->rgn)) {
- ASSERT(now->type != TREE_ITEM_TYPE_SHADOW);
+ spice_assert(now->type != TREE_ITEM_TYPE_SHADOW);
ring_item = now->siblings_link.prev;
print_base_item("EXCLUDE_REMOVE", now);
current_remove(worker, now);
@@ -2247,7 +2249,7 @@ static void exclude_region(RedWorker *worker, Ring *ring, RingItem *ring_item, Q
Container *container = (Container *)now;
if ((ring_item = ring_get_head(&container->items))) {
ring = &container->items;
- ASSERT(((TreeItem *)ring_item)->container);
+ spice_assert(((TreeItem *)ring_item)->container);
continue;
}
ring_item = &now->siblings_link;
@@ -2402,7 +2404,7 @@ static inline void red_free_stream(RedWorker *worker, Stream *stream)
static void red_release_stream(RedWorker *worker, Stream *stream)
{
if (!--stream->refs) {
- ASSERT(!ring_item_is_linked(&stream->link));
+ spice_assert(!ring_item_is_linked(&stream->link));
if (stream->mjpeg_encoder) {
mjpeg_encoder_destroy(stream->mjpeg_encoder);
}
@@ -2413,8 +2415,8 @@ static void red_release_stream(RedWorker *worker, Stream *stream)
static inline void red_detach_stream(RedWorker *worker, Stream *stream)
{
- ASSERT(stream->current && stream->current->stream);
- ASSERT(stream->current->stream == stream);
+ spice_assert(stream->current && stream->current->stream);
+ spice_assert(stream->current->stream == stream);
stream->current->stream = NULL;
stream->current = NULL;
}
@@ -2438,7 +2440,7 @@ static void push_stream_clip_by_drawable(DisplayChannelClient* dcc, StreamAgent
int n_rects;
if (!item) {
- PANIC("alloc failed");
+ spice_critical("alloc failed");
}
if (drawable->red_drawable->clip.type == SPICE_CLIP_TYPE_NONE) {
@@ -2462,7 +2464,7 @@ static void push_stream_clip(DisplayChannelClient* dcc, StreamAgent *agent)
int n_rects;
if (!item) {
- PANIC("alloc failed");
+ spice_critical("alloc failed");
}
item->clip_type = SPICE_CLIP_TYPE_RECTS;
@@ -2489,8 +2491,8 @@ static void red_attach_stream(RedWorker *worker, Drawable *drawable, Stream *str
StreamAgent *agent;
RingItem *item;
- ASSERT(!drawable->stream && !stream->current);
- ASSERT(drawable && stream);
+ spice_assert(!drawable->stream && !stream->current);
+ spice_assert(drawable && stream);
stream->current = drawable;
drawable->stream = stream;
stream->last_time = drawable->creation_time;
@@ -2510,13 +2512,13 @@ static void red_stop_stream(RedWorker *worker, Stream *stream)
DisplayChannelClient *dcc;
RingItem *item;
- ASSERT(ring_item_is_linked(&stream->link));
- ASSERT(!stream->current);
+ spice_assert(ring_item_is_linked(&stream->link));
+ spice_assert(!stream->current);
WORKER_FOREACH_DCC(worker, item, dcc) {
StreamAgent *stream_agent;
stream_agent = &dcc->stream_agents[stream - worker->streams_buf];
region_clear(&stream_agent->vis_region);
- ASSERT(!pipe_item_is_linked(&stream_agent->destroy_item));
+ spice_assert(!pipe_item_is_linked(&stream_agent->destroy_item));
stream->refs++;
red_channel_client_pipe_add(&dcc->common.base, &stream_agent->destroy_item);
}
@@ -2536,7 +2538,7 @@ static inline void red_detach_stream_gracefully(RedWorker *worker, Stream *strea
RedChannelClient *rcc;
DisplayChannelClient *dcc;
- ASSERT(stream->current);
+ spice_assert(stream->current);
WORKER_FOREACH_DCC(worker, item, dcc) {
UpgradeItem *upgrade_item;
int n_rects;
@@ -2682,7 +2684,7 @@ static inline void red_handle_streams_timout(RedWorker *worker)
static void red_display_release_stream(RedWorker *worker, StreamAgent *agent)
{
- ASSERT(agent->stream);
+ spice_assert(agent->stream);
red_release_stream(worker, agent->stream);
}
@@ -2736,7 +2738,7 @@ static void red_display_create_stream(DisplayChannelClient *dcc, Stream *stream)
StreamAgent *agent = &dcc->stream_agents[stream - dcc->common.worker->streams_buf];
stream->refs++;
- ASSERT(region_is_empty(&agent->vis_region));
+ spice_assert(region_is_empty(&agent->vis_region));
if (stream->current) {
agent->frames = 1;
region_clone(&agent->vis_region, &stream->current->tree_item.base.rgn);
@@ -2760,13 +2762,13 @@ static void red_create_stream(RedWorker *worker, Drawable *drawable)
int stream_width;
int stream_height;
- ASSERT(!drawable->stream);
+ spice_assert(!drawable->stream);
if (!(stream = red_alloc_stream(worker))) {
return;
}
- ASSERT(drawable->red_drawable->type == QXL_DRAW_COPY);
+ spice_assert(drawable->red_drawable->type == QXL_DRAW_COPY);
src_rect = &drawable->red_drawable->u.copy.src_area;
stream_width = src_rect->right - src_rect->left;
stream_height = src_rect->bottom - src_rect->top;
@@ -2919,7 +2921,7 @@ static inline void pre_stream_item_swap(RedWorker *worker, Stream *stream)
StreamAgent *agent;
RingItem *ring_item;
- ASSERT(stream->current);
+ spice_assert(stream->current);
if (!display_is_connected(worker)) {
return;
@@ -2962,7 +2964,7 @@ static inline void pre_stream_item_swap(RedWorker *worker, Stream *stream)
static inline void red_update_copy_graduality(RedWorker* worker, Drawable *drawable)
{
SpiceBitmap *bitmap;
- ASSERT(drawable->red_drawable->type == QXL_DRAW_COPY);
+ spice_assert(drawable->red_drawable->type == QXL_DRAW_COPY);
if (worker->streaming_video != STREAM_VIDEO_FILTER) {
drawable->copy_bitmap_graduality = BITMAP_GRADUAL_INVALID;
@@ -3211,7 +3213,7 @@ static void red_reset_stream_trace(RedWorker *worker)
if (!stream->current) {
red_stop_stream(worker, stream);
} else {
- red_printf("attached stream");
+ spice_printerr("attached stream");
}
}
@@ -3230,7 +3232,7 @@ static inline int red_current_add(RedWorker *worker, Ring *ring, Drawable *drawa
RingItem *exclude_base = NULL;
print_base_item("ADD", &item->base);
- ASSERT(!region_is_empty(&item->base.rgn));
+ spice_assert(!region_is_empty(&item->base.rgn));
region_init(&exclude_rgn);
now = ring_next(ring, ring);
@@ -3298,11 +3300,11 @@ static inline int red_current_add(RedWorker *worker, Ring *ring, Drawable *drawa
now = ring_next(ring, ring);
continue;
}
- ASSERT(IS_DRAW_ITEM(sibling));
+ spice_assert(IS_DRAW_ITEM(sibling));
if (!((DrawItem *)sibling)->container_root) {
container = __new_container(worker, (DrawItem *)sibling);
if (!container) {
- red_printf("create new container failed");
+ spice_printerr("create new container failed");
region_destroy(&exclude_rgn);
return FALSE;
}
@@ -3465,17 +3467,17 @@ static inline int red_current_add_qxl(RedWorker *worker, Ring *ring, Drawable *d
#ifdef RED_WORKER_STAT
if ((++worker->add_count % 100) == 0) {
stat_time_t total = worker->add_stat.total;
- red_printf("add with shadow count %u",
+ spice_printerr("add with shadow count %u",
worker->add_with_shadow_count);
worker->add_with_shadow_count = 0;
- red_printf("add[%u] %f exclude[%u] %f __exclude[%u] %f",
+ spice_printerr("add[%u] %f exclude[%u] %f __exclude[%u] %f",
worker->add_stat.count,
stat_cpu_time_to_sec(total),
worker->exclude_stat.count,
stat_cpu_time_to_sec(worker->exclude_stat.total),
worker->__exclude_stat.count,
stat_cpu_time_to_sec(worker->__exclude_stat.total));
- red_printf("add %f%% exclude %f%% exclude2 %f%% __exclude %f%%",
+ spice_printerr("add %f%% exclude %f%% exclude2 %f%% __exclude %f%%",
(double)(total - worker->exclude_stat.total) / total * 100,
(double)(worker->exclude_stat.total) / total * 100,
(double)(worker->exclude_stat.total -
@@ -3514,7 +3516,7 @@ static int surface_format_to_image_type(uint32_t surface_format)
case SPICE_SURFACE_FMT_32_ARGB:
return SPICE_BITMAP_FMT_RGBA;
default:
- PANIC("Unsupported surface format");
+ spice_critical("Unsupported surface format");
}
return 0;
}
@@ -3614,7 +3616,7 @@ static void free_one_drawable(RedWorker *worker, int force_glz_free)
Drawable *drawable;
Container *container;
- ASSERT(ring_item);
+ spice_assert(ring_item);
drawable = SPICE_CONTAINEROF(ring_item, Drawable, list_link);
if (force_glz_free) {
RingItem *glz_item, *next_item;
@@ -3752,7 +3754,7 @@ static inline void red_process_drawable(RedWorker *worker, RedDrawable *drawable
int surface_id;
Drawable *item = get_drawable(worker, drawable->effect, drawable, group_id);
- ASSERT(item);
+ spice_assert(item);
surface_id = item->surface_id;
@@ -3851,7 +3853,7 @@ static inline void red_process_surface(RedWorker *worker, RedSurfaceCmd *surface
break;
}
case QXL_SURFACE_CMD_DESTROY:
- PANIC_ON(!red_surface->context.canvas);
+ spice_warn_if(!red_surface->context.canvas);
set_surface_release_info(worker, surface_id, 0, surface->release_info, group_id);
red_handle_depends_on_target_surface(worker, surface_id);
/* note that red_handle_depends_on_target_surface must be called before red_current_clear.
@@ -3862,7 +3864,7 @@ static inline void red_process_surface(RedWorker *worker, RedSurfaceCmd *surface
red_destroy_surface(worker, surface_id);
break;
default:
- red_error("unknown surface command");
+ spice_error("unknown surface command");
};
red_put_surface_cmd(surface);
free(surface);
@@ -3921,7 +3923,7 @@ static void image_cache_remove(ImageCache *cache, ImageCacheItem *item)
now = &cache->hash_table[item->id % IMAGE_CACHE_HASH_SIZE];
for (;;) {
- ASSERT(*now);
+ spice_assert(*now);
if (*now == item) {
*now = item->next;
break;
@@ -3946,7 +3948,7 @@ static void image_cache_put(SpiceImageCache *spice_cache, uint64_t id, pixman_im
#ifndef IMAGE_CACHE_AGE
if (cache->num_items == IMAGE_CACHE_MAX_ITEMS) {
ImageCacheItem *tail = (ImageCacheItem *)ring_get_tail(&cache->lru);
- ASSERT(tail);
+ spice_assert(tail);
image_cache_remove(cache, tail);
}
#endif
@@ -3973,7 +3975,7 @@ static pixman_image_t *image_cache_get(SpiceImageCache *spice_cache, uint64_t id
ImageCacheItem *item = image_cache_find(cache, id);
if (!item) {
- red_error("not found");
+ spice_error("not found");
}
return pixman_image_ref(item->image);
}
@@ -4028,8 +4030,8 @@ static void localize_bitmap(RedWorker *worker, SpiceImage **image_ptr, SpiceImag
SpiceImage *image = *image_ptr;
if (image == NULL) {
- ASSERT(drawable != NULL);
- ASSERT(drawable->self_bitmap != NULL);
+ spice_assert(drawable != NULL);
+ spice_assert(drawable->self_bitmap != NULL);
*image_ptr = drawable->self_bitmap;
return;
}
@@ -4061,7 +4063,7 @@ static void localize_bitmap(RedWorker *worker, SpiceImage **image_ptr, SpiceImag
/* nothing */
break;
default:
- red_error("invalid image type");
+ spice_error("invalid image type");
}
}
@@ -4204,7 +4206,7 @@ static void red_draw_qxl_drawable(RedWorker *worker, Drawable *drawable)
break;
}
default:
- red_printf("invalid type");
+ spice_printerr("invalid type");
}
}
@@ -4242,7 +4244,7 @@ static void validate_area(RedWorker *worker, const SpiceRect *area, uint32_t sur
return;
}
- ASSERT(stride < 0);
+ spice_assert(stride < 0);
uint8_t *dest = line_0 + (area->top * stride) + area->left * sizeof(uint32_t);
dest += (h - 1) * stride;
canvas->ops->read_bits(canvas, dest, -stride, area);
@@ -4280,7 +4282,7 @@ static inline void __red_collect_for_update(RedWorker *worker, Ring *ring, RingI
if ((ring_item = ring_get_head(&container->items))) {
ring = &container->items;
- ASSERT(((TreeItem *)ring_item)->container);
+ spice_assert(((TreeItem *)ring_item)->container);
continue;
}
ring_item = &now->siblings_link;
@@ -4353,8 +4355,8 @@ static void red_update_area_till(RedWorker *worker, const SpiceRect *area, int s
Drawable *now;
QRegion rgn;
- ASSERT(last);
- ASSERT(ring_item_is_linked(&last->list_link));
+ spice_assert(last);
+ spice_assert(ring_item_is_linked(&last->list_link));
surface = &worker->surfaces[surface_id];
@@ -4471,7 +4473,7 @@ static void red_update_area(RedWorker *worker, const SpiceRect *area, int surfac
release_drawable(worker, now);
#ifdef ACYCLIC_SURFACE_DEBUG
if (gn != surface->current_gn) {
- red_error("cyclic surface dependencies");
+ spice_error("cyclic surface dependencies");
}
#endif
} while (now != last);
@@ -4533,7 +4535,7 @@ static inline void free_cursor_item(RedWorker *worker, CursorItem *item)
worker->free_cursor_items = (_CursorItem *)item;
#ifdef DEBUG_CURSORS
++_cursor_count;
- ASSERT(_cursor_count <= NUM_CURSORS);
+ spice_assert(_cursor_count <= NUM_CURSORS);
#endif
}
@@ -4551,7 +4553,7 @@ static CursorItem *get_cursor_item(RedWorker *worker, RedCursorCmd *cmd, uint32_
{
CursorItem *cursor_item;
- PANIC_ON(!(cursor_item = alloc_cursor_item(worker)));
+ spice_warn_if(!(cursor_item = alloc_cursor_item(worker)));
cursor_item->refs = 1;
cursor_item->group_id = group_id;
@@ -4562,7 +4564,7 @@ static CursorItem *get_cursor_item(RedWorker *worker, RedCursorCmd *cmd, uint32_
static CursorPipeItem *ref_cursor_pipe_item(CursorPipeItem *item)
{
- ASSERT(item);
+ spice_assert(item);
item->refs++;
return item;
}
@@ -4580,13 +4582,13 @@ static PipeItem *new_cursor_pipe_item(RedChannelClient *rcc, void *data, int num
static void put_cursor_pipe_item(CursorChannelClient *ccc, CursorPipeItem *pipe_item)
{
- ASSERT(pipe_item);
+ spice_assert(pipe_item);
if (--pipe_item->refs) {
return;
}
- ASSERT(!pipe_item_is_linked(&pipe_item->base));
+ spice_assert(!pipe_item_is_linked(&pipe_item->base));
red_release_cursor(ccc->common.worker, pipe_item->cursor_item);
free(pipe_item);
@@ -4617,7 +4619,7 @@ static void qxl_process_cursor(RedWorker *worker, RedCursorCmd *cursor_cmd, uint
worker->cursor_trail_frequency = cursor_cmd->u.trail.frequency;
break;
default:
- red_error("invalid cursor command %u", cursor_cmd->type);
+ spice_error("invalid cursor command %u", cursor_cmd->type);
}
if (cursor_is_connected(worker) && (worker->mouse_mode == SPICE_MOUSE_MODE_SERVER ||
@@ -4675,7 +4677,7 @@ static int red_process_cursor(RedWorker *worker, uint32_t max_pipe_size, int *ri
break;
}
default:
- red_error("bad command type");
+ spice_error("bad command type");
}
n++;
}
@@ -4755,7 +4757,7 @@ static int red_process_commands(RedWorker *worker, uint32_t max_pipe_size, int *
&message, ext_cmd.cmd.data);
#ifdef DEBUG
/* alert: accessing message.data is insecure */
- red_printf("MESSAGE: %s", message.data);
+ spice_printerr("MESSAGE: %s", message.data);
#endif
release_info_ext.group_id = ext_cmd.group_id;
release_info_ext.info = message.release_info;
@@ -4772,7 +4774,7 @@ static int red_process_commands(RedWorker *worker, uint32_t max_pipe_size, int *
break;
}
default:
- red_error("bad command type");
+ spice_error("bad command type");
}
n++;
if ((worker->display_channel &&
@@ -4793,9 +4795,8 @@ static void red_free_some(RedWorker *worker)
DisplayChannelClient *dcc;
RingItem *item;
- red_printf_debug(3, "WORKER",
- "#draw=%d, #red_draw=%d, #glz_draw=%d", worker->drawable_count,
- worker->red_drawable_count, worker->glz_drawable_count);
+ spice_debug("#draw=%d, #red_draw=%d, #glz_draw=%d", worker->drawable_count,
+ worker->red_drawable_count, worker->glz_drawable_count);
WORKER_FOREACH_DCC(worker, item, dcc) {
GlzSharedDictionary *glz_dict = dcc ? dcc->glz_dict : NULL;
@@ -4844,7 +4845,7 @@ static ImageItem *red_add_surface_area_image(DisplayChannelClient *dcc, int surf
int bpp;
int all_set;
- ASSERT(area);
+ spice_assert(area);
width = area->right - area->left;
height = area->bottom - area->top;
@@ -4929,7 +4930,7 @@ static void marshaller_add_compressed(SpiceMarshaller *m,
size_t max = size;
size_t now;
do {
- ASSERT(comp_buf);
+ spice_assert(comp_buf);
now = MIN(sizeof(comp_buf->buf), max);
max -= now;
spice_marshaller_add_ref(m, (uint8_t*)comp_buf->buf, now);
@@ -5020,7 +5021,7 @@ static void red_display_free_compress_buf(DisplayChannelClient *dcc,
RedCompressBuf **curr_used = &dcc->send_data.used_compress_bufs;
for (;;) {
- ASSERT(*curr_used);
+ spice_assert(*curr_used);
if (*curr_used == buf) {
*curr_used = buf->next;
break;
@@ -5041,7 +5042,7 @@ static void red_display_reset_compress_buf(DisplayChannelClient *dcc)
static void red_display_destroy_compress_bufs(DisplayChannel *display_channel)
{
- ASSERT(!red_channel_is_connected(&display_channel->common.base));
+ spice_assert(!red_channel_is_connected(&display_channel->common.base));
while (display_channel->free_compress_bufs) {
RedCompressBuf *buf = display_channel->free_compress_bufs;
display_channel->free_compress_bufs = buf->next;
@@ -5091,7 +5092,7 @@ static RedGlzDrawable *red_display_get_glz_drawable(DisplayChannelClient *dcc, D
NOTE - the caller should set the glz_instance returned by the encoder by itself.*/
static GlzDrawableInstanceItem *red_display_add_glz_drawable_instance(RedGlzDrawable *glz_drawable)
{
- ASSERT(glz_drawable->instances_count < MAX_GLZ_DRAWABLE_INSTANCES);
+ spice_assert(glz_drawable->instances_count < MAX_GLZ_DRAWABLE_INSTANCES);
// NOTE: We assume the additions are performed consecutively, without removals in the middle
GlzDrawableInstanceItem *ret = glz_drawable->instances_pool + glz_drawable->instances_count;
glz_drawable->instances_count++;
@@ -5117,13 +5118,13 @@ static void red_display_free_glz_drawable_instance(DisplayChannelClient *dcc,
RedWorker *worker = display_channel->common.worker;
RedGlzDrawable *glz_drawable;
- ASSERT(glz_drawable_instance);
- ASSERT(glz_drawable_instance->red_glz_drawable);
+ spice_assert(glz_drawable_instance);
+ spice_assert(glz_drawable_instance->red_glz_drawable);
glz_drawable = glz_drawable_instance->red_glz_drawable;
- ASSERT(glz_drawable->dcc == dcc);
- ASSERT(glz_drawable->instances_count);
+ spice_assert(glz_drawable->dcc == dcc);
+ spice_assert(glz_drawable->instances_count);
ring_remove(&glz_drawable_instance->glz_link);
glz_drawable->instances_count--;
@@ -5134,7 +5135,7 @@ static void red_display_free_glz_drawable_instance(DisplayChannelClient *dcc,
}
if (ring_is_empty(&glz_drawable->instances)) {
- ASSERT(!glz_drawable->instances_count);
+ spice_assert(!glz_drawable->instances_count);
Drawable *drawable = glz_drawable->drawable;
@@ -5272,7 +5273,7 @@ static void quic_usr_error(QuicUsrContext *usr, const char *fmt, ...)
va_start(ap, fmt);
vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
va_end(ap);
- red_printf("%s", usr_data->message_buf);
+ spice_printerr("%s", usr_data->message_buf);
longjmp(usr_data->jmp_env, 1);
}
@@ -5285,7 +5286,7 @@ static void lz_usr_error(LzUsrContext *usr, const char *fmt, ...)
va_start(ap, fmt);
vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
va_end(ap);
- red_printf("%s", usr_data->message_buf);
+ spice_printerr("%s", usr_data->message_buf);
longjmp(usr_data->jmp_env, 1);
}
@@ -5299,7 +5300,7 @@ static void glz_usr_error(GlzEncoderUsrContext *usr, const char *fmt, ...)
vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
va_end(ap);
- PANIC("%s", usr_data->message_buf); // if global lz fails in the middle
+ spice_critical("%s", usr_data->message_buf); // if global lz fails in the middle
// the consequences are not predictable since the window
// can turn to be unsynchronized between the server and
// and the client
@@ -5313,7 +5314,7 @@ static void quic_usr_warn(QuicUsrContext *usr, const char *fmt, ...)
va_start(ap, fmt);
vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
va_end(ap);
- red_printf("%s", usr_data->message_buf);
+ spice_printerr("%s", usr_data->message_buf);
}
static void lz_usr_warn(LzUsrContext *usr, const char *fmt, ...)
@@ -5324,7 +5325,7 @@ static void lz_usr_warn(LzUsrContext *usr, const char *fmt, ...)
va_start(ap, fmt);
vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
va_end(ap);
- red_printf("%s", usr_data->message_buf);
+ spice_printerr("%s", usr_data->message_buf);
}
static void glz_usr_warn(GlzEncoderUsrContext *usr, const char *fmt, ...)
@@ -5335,7 +5336,7 @@ static void glz_usr_warn(GlzEncoderUsrContext *usr, const char *fmt, ...)
va_start(ap, fmt);
vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
va_end(ap);
- red_printf("%s", usr_data->message_buf);
+ spice_printerr("%s", usr_data->message_buf);
}
static void *quic_usr_malloc(QuicUsrContext *usr, int size)
@@ -5472,7 +5473,7 @@ static int zlib_usr_more_input(ZlibEncoderUsrContext *usr, uint8_t** input)
int buf_size;
if (!usr_data->u.compressed_data.next) {
- ASSERT(usr_data->u.compressed_data.size_left == 0);
+ spice_assert(usr_data->u.compressed_data.size_left == 0);
return 0;
}
@@ -5521,7 +5522,7 @@ static inline void red_init_quic(RedWorker *worker)
worker->quic = quic_create(&worker->quic_data.usr);
if (!worker->quic) {
- PANIC("create quic failed");
+ spice_critical("create quic failed");
}
}
@@ -5538,7 +5539,7 @@ static inline void red_init_lz(RedWorker *worker)
worker->lz = lz_create(&worker->lz_data.usr);
if (!worker->lz) {
- PANIC("create lz failed");
+ spice_critical("create lz failed");
}
}
@@ -5563,7 +5564,7 @@ static inline void red_init_jpeg(RedWorker *worker)
worker->jpeg = jpeg_encoder_create(&worker->jpeg_data.usr);
if (!worker->jpeg) {
- PANIC("create jpeg encoder failed");
+ spice_critical("create jpeg encoder failed");
}
}
@@ -5575,7 +5576,7 @@ static inline void red_init_zlib(RedWorker *worker)
worker->zlib = zlib_encoder_create(&worker->zlib_data.usr, ZLIB_DEFAULT_COMPRESSION_LEVEL);
if (!worker->zlib) {
- PANIC("create zlib encoder failed");
+ spice_critical("create zlib encoder failed");
}
}
@@ -5655,13 +5656,13 @@ static BitmapGradualType _get_bitmap_graduality_level(RedWorker *worker, SpiceBi
&chunk_score, &chunk_num_samples);
break;
default:
- red_error("invalid bitmap format (not RGB) %u", bitmap->format);
+ spice_error("invalid bitmap format (not RGB) %u", bitmap->format);
}
score += chunk_score;
num_samples += chunk_num_samples;
}
- ASSERT(num_samples);
+ spice_assert(num_samples);
score /= num_samples;
if (bitmap->format == SPICE_BITMAP_FMT_16BIT) {
@@ -5683,7 +5684,7 @@ static BitmapGradualType _get_bitmap_graduality_level(RedWorker *worker, SpiceBi
static inline int _stride_is_extra(SpiceBitmap *bitmap)
{
- ASSERT(bitmap);
+ spice_assert(bitmap);
if (BITMAP_FMT_IS_RGB[bitmap->format]) {
return ((bitmap->x * BITMAP_FMP_BYTES_PER_PIXEL[bitmap->format]) < bitmap->stride);
} else {
@@ -5701,9 +5702,11 @@ static inline int _stride_is_extra(SpiceBitmap *bitmap)
return bytes_width < bitmap->stride;
}
default:
- red_error("invalid image type %u", bitmap->format);
+ spice_error("invalid image type %u", bitmap->format);
+ return 0;
}
}
+ return 0;
}
static const LzImageType MAP_BITMAP_FMT_TO_LZ_IMAGE_TYPE[] = {
@@ -5736,7 +5739,7 @@ static inline int red_glz_compress_image(DisplayChannelClient *dcc,
#ifdef COMPRESS_STAT
stat_time_t start_time = stat_now();
#endif
- ASSERT(BITMAP_FMT_IS_RGB[src->format]);
+ spice_assert(BITMAP_FMT_IS_RGB[src->format]);
GlzData *glz_data = &dcc->glz_data;
ZlibData *zlib_data;
LzImageType type = MAP_BITMAP_FMT_TO_LZ_IMAGE_TYPE[src->format];
@@ -5785,7 +5788,7 @@ static inline int red_glz_compress_image(DisplayChannelClient *dcc,
zlib_data->data.bufs_head = zlib_data->data.bufs_tail;
if (!zlib_data->data.bufs_head) {
- red_printf("failed to allocate zlib compress buffer");
+ spice_printerr("failed to allocate zlib compress buffer");
goto glz;
}
@@ -5948,7 +5951,7 @@ static int red_jpeg_compress_image(DisplayChannelClient *dcc, SpiceImage *dest,
jpeg_data->data.bufs_head = jpeg_data->data.bufs_tail;
if (!jpeg_data->data.bufs_head) {
- red_printf("failed to allocate compress buffer");
+ spice_printerr("failed to allocate compress buffer");
return FALSE;
}
@@ -6190,7 +6193,7 @@ static inline int red_compress_image(DisplayChannelClient *dcc,
if (quic_compress) {
#ifdef COMPRESS_DEBUG
- red_printf("QUIC compress");
+ spice_printerr("QUIC compress");
#endif
// if bitmaps is picture-like, compress it using jpeg
if (can_lossy && display_channel->enable_jpeg &&
@@ -6216,7 +6219,8 @@ static inline int red_compress_image(DisplayChannelClient *dcc,
(image_compression == SPICE_IMAGE_COMPRESS_LZ)) {
glz = FALSE;
} else {
- red_error("invalid image compression type %u", image_compression);
+ spice_error("invalid image compression type %u", image_compression);
+ return FALSE;
}
if (glz) {
@@ -6236,12 +6240,12 @@ static inline int red_compress_image(DisplayChannelClient *dcc,
ret = red_lz_compress_image(dcc, dest, src, o_comp_data,
drawable->group_id);
#ifdef COMPRESS_DEBUG
- red_printf("LZ LOCAL compress");
+ spice_printerr("LZ LOCAL compress");
#endif
}
#ifdef COMPRESS_DEBUG
else {
- red_printf("LZ global compress fmt=%d", src->format);
+ spice_printerr("LZ global compress fmt=%d", src->format);
}
#endif
return ret;
@@ -6256,7 +6260,7 @@ static inline void red_display_add_image_to_pixmap_cache(RedChannelClient *rcc,
DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
if ((image->descriptor.flags & SPICE_IMAGE_FLAGS_CACHE_ME)) {
- ASSERT(image->descriptor.width * image->descriptor.height > 0);
+ spice_assert(image->descriptor.width * image->descriptor.height > 0);
if (!(io_image->descriptor.flags & SPICE_IMAGE_FLAGS_CACHE_REPLACE_ME)) {
if (pixmap_cache_add(dcc->pixmap_cache, image->descriptor.id,
image->descriptor.width * image->descriptor.height, is_lossy,
@@ -6296,7 +6300,7 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
SpiceMarshaller *bitmap_palette_out, *lzplt_palette_out;
if (simage == NULL) {
- ASSERT(drawable->self_bitmap);
+ spice_assert(drawable->self_bitmap);
simage = drawable->self_bitmap;
}
@@ -6319,8 +6323,8 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
}
spice_marshall_Image(m, &image,
&bitmap_palette_out, &lzplt_palette_out);
- ASSERT(bitmap_palette_out == NULL);
- ASSERT(lzplt_palette_out == NULL);
+ spice_assert(bitmap_palette_out == NULL);
+ spice_assert(lzplt_palette_out == NULL);
stat_inc_counter(display_channel->cache_hits_counter, 1);
return FILL_BITS_TYPE_CACHE;
} else {
@@ -6348,8 +6352,8 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
image.u.surface.surface_id = surface_id;
spice_marshall_Image(m, &image,
&bitmap_palette_out, &lzplt_palette_out);
- ASSERT(bitmap_palette_out == NULL);
- ASSERT(lzplt_palette_out == NULL);
+ spice_assert(bitmap_palette_out == NULL);
+ spice_assert(lzplt_palette_out == NULL);
return FILL_BITS_TYPE_SURFACE;
}
case SPICE_IMAGE_TYPE_BITMAP: {
@@ -6373,7 +6377,7 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
fill_palette(dcc, palette, &bitmap->flags);
spice_marshall_Image(m, &image,
&bitmap_palette_out, &lzplt_palette_out);
- ASSERT(lzplt_palette_out == NULL);
+ spice_assert(lzplt_palette_out == NULL);
if (bitmap_palette_out && palette) {
spice_marshall_Palette(bitmap_palette_out, palette);
@@ -6387,7 +6391,7 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
spice_marshall_Image(m, &image,
&bitmap_palette_out, &lzplt_palette_out);
- ASSERT(bitmap_palette_out == NULL);
+ spice_assert(bitmap_palette_out == NULL);
marshaller_add_compressed(m, comp_send_data.comp_buf,
comp_send_data.comp_buf_size);
@@ -6396,7 +6400,7 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
spice_marshall_Palette(lzplt_palette_out, comp_send_data.lzplt_palette);
}
- ASSERT(!comp_send_data.is_lossy || can_lossy);
+ spice_assert(!comp_send_data.is_lossy || can_lossy);
return (comp_send_data.is_lossy ? FILL_BITS_TYPE_COMPRESS_LOSSY :
FILL_BITS_TYPE_COMPRESS_LOSSLESS);
}
@@ -6407,13 +6411,15 @@ static FillBitsType fill_bits(DisplayChannelClient *dcc, SpiceMarshaller *m,
image.u.quic = simage->u.quic;
spice_marshall_Image(m, &image,
&bitmap_palette_out, &lzplt_palette_out);
- ASSERT(bitmap_palette_out == NULL);
- ASSERT(lzplt_palette_out == NULL);
+ spice_assert(bitmap_palette_out == NULL);
+ spice_assert(lzplt_palette_out == NULL);
spice_marshaller_add_ref_chunks(m, image.u.quic.data);
return FILL_BITS_TYPE_COMPRESS_LOSSLESS;
default:
- red_error("invalid image type %u", image.descriptor.type);
+ spice_error("invalid image type %u", image.descriptor.type);
}
+
+ return 0;
}
static void fill_mask(RedChannelClient *rcc, SpiceMarshaller *m,
@@ -6706,7 +6712,7 @@ static int pipe_rendered_drawables_intersect_with_areas(RedWorker *worker,
PipeItem *pipe_item;
Ring *pipe;
- ASSERT(num_surfaces);
+ spice_assert(num_surfaces);
pipe = &dcc->common.base.pipe;
for (pipe_item = (PipeItem *)ring_get_head(pipe);
@@ -6780,7 +6786,7 @@ static void red_pipe_replace_rendered_drawables_with_images(RedWorker *worker,
resent_areas[num_resent] = drawable->red_drawable->bbox;
num_resent++;
- ASSERT(image);
+ spice_assert(image);
red_channel_client_pipe_remove_and_release(&dcc->common.base, &dpi->dpi_pipe_item);
pipe_item = &image->link;
}
@@ -7722,7 +7728,7 @@ static void red_lossy_marshall_qxl_drawable(RedWorker *worker, RedChannelClient
red_lossy_marshall_qxl_draw_text(worker, rcc, base_marshaller, dpi);
break;
default:
- red_error("invalid type");
+ spice_error("invalid type");
}
}
@@ -7773,7 +7779,7 @@ static inline void red_marshall_qxl_drawable(RedWorker *worker, RedChannelClient
red_marshall_qxl_draw_text(worker, rcc, m, dpi);
break;
default:
- red_error("invalid type");
+ spice_error("invalid type");
}
}
@@ -7956,7 +7962,7 @@ static inline uint8_t *red_get_image_line(RedWorker *worker, SpiceChunks *chunks
}
if (chunk->len - *offset < stride) {
- red_printf("bad chunk alignment");
+ spice_printerr("bad chunk alignment");
return NULL;
}
ret = chunk->data + *offset;
@@ -8011,8 +8017,8 @@ static inline int red_marshall_stream_data(RedChannelClient *rcc,
RedWorker *worker = dcc->common.worker;
int n;
- ASSERT(stream);
- ASSERT(drawable->red_drawable->type == QXL_DRAW_COPY);
+ spice_assert(stream);
+ spice_assert(drawable->red_drawable->type == QXL_DRAW_COPY);
worker = display_channel->common.worker;
image = drawable->red_drawable->u.copy.src_bitmap;
@@ -8062,7 +8068,7 @@ static inline void marshall_qxl_drawable(RedChannelClient *rcc,
Drawable *item = dpi->drawable;
DisplayChannel *display_channel = SPICE_CONTAINEROF(rcc->channel, DisplayChannel, common.base);
- ASSERT(display_channel && rcc);
+ spice_assert(display_channel && rcc);
if (item->stream && red_marshall_stream_data(rcc, m, item)) {
return;
}
@@ -8074,7 +8080,7 @@ static inline void marshall_qxl_drawable(RedChannelClient *rcc,
static inline void red_marshall_verb(RedChannelClient *rcc, uint16_t verb)
{
- ASSERT(rcc);
+ spice_assert(rcc);
red_channel_client_init_send_data(rcc, verb, NULL);
}
@@ -8109,9 +8115,9 @@ static void display_channel_marshall_migrate_data(RedChannelClient *rcc,
red_channel_client_init_send_data(rcc, SPICE_MSG_MIGRATE_DATA, NULL);
- ASSERT(dcc->pixmap_cache);
+ spice_assert(dcc->pixmap_cache);
display_data.magic = DISPLAY_MIGRATE_DATA_MAGIC;
- ASSERT(MAX_CACHE_CLIENTS == 4); //MIGRATE_DATA_VERSION dependent
+ spice_assert(MAX_CACHE_CLIENTS == 4); //MIGRATE_DATA_VERSION dependent
display_data.version = DISPLAY_MIGRATE_DATA_VERSION;
display_data.message_serial = red_channel_client_get_message_serial(rcc);
@@ -8122,7 +8128,7 @@ static void display_channel_marshall_migrate_data(RedChannelClient *rcc,
memcpy(display_data.pixmap_cache_clients, dcc->pixmap_cache->sync,
sizeof(display_data.pixmap_cache_clients));
- ASSERT(dcc->glz_dict);
+ spice_assert(dcc->glz_dict);
red_freeze_glz(dcc);
display_data.glz_dict_id = dcc->glz_dict->id;
glz_enc_dictionary_get_restore_data(dcc->glz_dict->dict,
@@ -8187,7 +8193,7 @@ static void red_marshall_image(RedChannelClient *rcc, SpiceMarshaller *m, ImageI
SpiceMarshaller *src_bitmap_out, *mask_bitmap_out;
SpiceMarshaller *bitmap_palette_out, *lzplt_palette_out;
- ASSERT(rcc && display_channel && item);
+ spice_assert(rcc && display_channel && item);
worker = display_channel->common.worker;
QXL_SET_IMAGE_ID(&red_image, QXL_IMAGE_GROUP_RED, ++worker->bits_unique);
@@ -8312,14 +8318,14 @@ static void red_display_marshall_upgrade(RedChannelClient *rcc, SpiceMarshaller
SpiceMsgDisplayDrawCopy copy;
SpiceMarshaller *src_bitmap_out, *mask_bitmap_out;
- ASSERT(rcc && rcc->channel && item && item->drawable);
+ spice_assert(rcc && rcc->channel && item && item->drawable);
red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_COPY, &item->base);
red_drawable = item->drawable->red_drawable;
- ASSERT(red_drawable->type == QXL_DRAW_COPY);
- ASSERT(red_drawable->u.copy.rop_descriptor == SPICE_ROPD_OP_PUT);
- ASSERT(red_drawable->u.copy.mask.bitmap == 0);
+ spice_assert(red_drawable->type == QXL_DRAW_COPY);
+ spice_assert(red_drawable->u.copy.rop_descriptor == SPICE_ROPD_OP_PUT);
+ spice_assert(red_drawable->u.copy.mask.bitmap == 0);
copy.base.surface_id = 0;
copy.base.box = red_drawable->bbox;
@@ -8340,7 +8346,7 @@ static void red_display_marshall_stream_start(RedChannelClient *rcc,
Stream *stream = agent->stream;
agent->last_send_time = 0;
- ASSERT(stream);
+ spice_assert(stream);
red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_CREATE, &agent->create_item);
SpiceMsgDisplayStreamCreate stream_create;
SpiceClipRects clip_rects;
@@ -8377,7 +8383,7 @@ static void red_display_marshall_stream_clip(RedChannelClient *rcc,
DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
StreamAgent *agent = item->stream_agent;
- ASSERT(agent->stream);
+ spice_assert(agent->stream);
red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_CLIP, &item->base);
SpiceMsgDisplayStreamClip stream_clip;
@@ -8404,7 +8410,7 @@ static void red_display_marshall_stream_end(RedChannelClient *rcc,
static void red_cursor_marshall_inval(RedChannelClient *rcc,
SpiceMarshaller *m, CacheItem *cach_item)
{
- ASSERT(rcc);
+ spice_assert(rcc);
red_marshall_inval(rcc, m, cach_item);
}
@@ -8417,7 +8423,7 @@ static void red_marshall_cursor_init(RedChannelClient *rcc, SpiceMarshaller *bas
SpiceMsgCursorInit msg;
AddBufInfo info;
- ASSERT(rcc);
+ spice_assert(rcc);
cursor_channel = SPICE_CONTAINEROF(rcc->channel, CursorChannel, common.base);
worker = cursor_channel->common.worker;
@@ -8453,7 +8459,7 @@ static void red_marshall_cursor(RedChannelClient *rcc,
RedCursorCmd *cmd;
RedWorker *worker;
- ASSERT(cursor_channel);
+ spice_assert(cursor_channel);
worker = cursor_channel->common.worker;
@@ -8495,7 +8501,7 @@ static void red_marshall_cursor(RedChannelClient *rcc,
}
break;
default:
- red_error("bad cursor command %d", cmd->type);
+ spice_error("bad cursor command %d", cmd->type);
}
}
@@ -8561,7 +8567,7 @@ static void display_channel_send_item(RedChannelClient *rcc, PipeItem *pipe_item
red_marshall_verb(rcc, ((VerbItem*)pipe_item)->verb);
break;
case PIPE_ITEM_TYPE_MIGRATE:
- red_printf("PIPE_ITEM_TYPE_MIGRATE");
+ spice_printerr("PIPE_ITEM_TYPE_MIGRATE");
display_channel_marshall_migrate(rcc, m);
break;
case PIPE_ITEM_TYPE_MIGRATE_DATA:
@@ -8593,7 +8599,7 @@ static void display_channel_send_item(RedChannelClient *rcc, PipeItem *pipe_item
break;
}
default:
- red_error("invalid pipe item type");
+ spice_error("invalid pipe item type");
}
display_channel_client_release_item_before_push(dcc, pipe_item);
@@ -8620,7 +8626,7 @@ static void cursor_channel_send_item(RedChannelClient *rcc, PipeItem *pipe_item)
red_marshall_verb(rcc, ((VerbItem*)pipe_item)->verb);
break;
case PIPE_ITEM_TYPE_MIGRATE:
- red_printf("PIPE_ITEM_TYPE_MIGRATE");
+ spice_printerr("PIPE_ITEM_TYPE_MIGRATE");
cursor_channel_marshall_migrate(rcc, m);
break;
case PIPE_ITEM_TYPE_CURSOR_INIT:
@@ -8632,7 +8638,7 @@ static void cursor_channel_send_item(RedChannelClient *rcc, PipeItem *pipe_item)
red_marshall_verb(rcc, SPICE_MSG_CURSOR_INVAL_ALL);
break;
default:
- red_error("invalid pipe item type");
+ spice_error("invalid pipe item type");
}
cursor_channel_client_release_item_before_push(ccc, pipe_item);
@@ -8662,7 +8668,7 @@ static void __show_tree_call(TreeItem *item, void *data)
int i;
while (tree_data->container != item->container) {
- ASSERT(tree_data->container);
+ spice_assert(tree_data->container);
tree_data->level--;
tree_data->container = tree_data->container->base.container;
}
@@ -8726,11 +8732,11 @@ static void display_channel_client_on_disconnect(RedChannelClient *rcc)
if (!rcc) {
return;
}
- red_printf("");
+ spice_printerr("");
common = SPICE_CONTAINEROF(rcc->channel, CommonChannel, base);
worker = common->worker;
display_channel = (DisplayChannel *)rcc->channel;
- ASSERT(display_channel == worker->display_channel);
+ spice_assert(display_channel == worker->display_channel);
#ifdef COMPRESS_STAT
print_compress_stats(display_channel);
#endif
@@ -8746,9 +8752,9 @@ static void display_channel_client_on_disconnect(RedChannelClient *rcc)
if (!red_channel_is_connected(rcc->channel)) {
red_display_destroy_compress_bufs(display_channel);
}
- red_printf_debug(3, "WORKER", "#draw=%d, #red_draw=%d, #glz_draw=%d",
- worker->drawable_count, worker->red_drawable_count,
- worker->glz_drawable_count);
+ spice_debug("#draw=%d, #red_draw=%d, #glz_draw=%d",
+ worker->drawable_count, worker->red_drawable_count,
+ worker->glz_drawable_count);
}
void red_disconnect_all_display_TODO_remove_me(RedChannel *channel)
@@ -8858,8 +8864,10 @@ static inline void *create_canvas_for_surface(RedWorker *worker, RedSurface *sur
return canvas;
#endif
default:
- red_error("invalid renderer type");
+ spice_error("invalid renderer type");
};
+
+ return NULL;
}
static SurfaceCreateItem *get_surface_create_item(
@@ -8870,7 +8878,7 @@ static SurfaceCreateItem *get_surface_create_item(
SurfaceCreateItem *create;
create = (SurfaceCreateItem *)malloc(sizeof(SurfaceCreateItem));
- PANIC_ON(!create);
+ spice_warn_if(!create);
create->surface_create.surface_id = surface_id;
create->surface_create.width = width;
@@ -8931,9 +8939,9 @@ static inline void red_create_surface(RedWorker *worker, uint32_t surface_id, ui
uint32_t i;
if (stride >= 0) {
- PANIC("Untested path stride >= 0");
+ spice_critical("Untested path stride >= 0");
}
- PANIC_ON(surface->context.canvas);
+ spice_warn_if(surface->context.canvas);
surface->context.canvas_draws_on_surface = FALSE;
surface->context.width = width;
@@ -8956,7 +8964,7 @@ static inline void red_create_surface(RedWorker *worker, uint32_t surface_id, ui
width, height, stride,
surface->context.format, line_0);
if (!surface->context.canvas) {
- PANIC("drawing canvas creating failed - can`t create same type canvas");
+ spice_critical("drawing canvas creating failed - can`t create same type canvas");
}
if (send_client) {
@@ -8984,7 +8992,7 @@ static inline void red_create_surface(RedWorker *worker, uint32_t surface_id, ui
}
}
- PANIC("unable to create drawing canvas");
+ spice_critical("unable to create drawing canvas");
}
static inline void flush_display_commands(RedWorker *worker)
@@ -9021,7 +9029,7 @@ static inline void flush_display_commands(RedWorker *worker)
// TODO: MC: the whole timeout will break since it takes lowest timeout, should
// do it client by client.
if (red_now() >= end_time) {
- red_printf("update timeout");
+ spice_printerr("update timeout");
red_disconnect_all_display_TODO_remove_me(channel);
} else {
sleep_count++;
@@ -9063,7 +9071,7 @@ static inline void flush_cursor_commands(RedWorker *worker)
red_channel_receive(channel);
red_channel_send(channel);
if (red_now() >= end_time) {
- red_printf("flush cursor timeout");
+ spice_printerr("flush cursor timeout");
red_disconnect_cursor(channel);
} else {
sleep_count++;
@@ -9107,15 +9115,15 @@ static int display_channel_client_wait_for_init(DisplayChannelClient *dcc)
if (dcc->pixmap_cache && dcc->glz_dict) {
dcc->pixmap_cache_generation = dcc->pixmap_cache->generation;
/* TODO: move common.id? if it's used for a per client structure.. */
- red_printf("creating encoder with id == %d", dcc->common.id);
+ spice_printerr("creating encoder with id == %d", dcc->common.id);
dcc->glz = glz_encoder_create(dcc->common.id, dcc->glz_dict->dict, &dcc->glz_data.usr);
if (!dcc->glz) {
- PANIC("create global lz failed");
+ spice_critical("create global lz failed");
}
return TRUE;
}
if (red_now() > end_time) {
- red_printf("timeout");
+ spice_printerr("timeout");
red_channel_client_disconnect(&dcc->common.base);
break;
}
@@ -9189,10 +9197,10 @@ static GlzSharedDictionary *red_create_glz_dictionary(DisplayChannelClient *dcc,
MAX_LZ_ENCODERS,
&dcc->glz_data.usr);
#ifdef COMPRESS_DEBUG
- red_printf("Lz Window %d Size=%d", id, window_size);
+ spice_printerr("Lz Window %d Size=%d", id, window_size);
#endif
if (!glz_dict) {
- PANIC("failed creating lz dictionary");
+ spice_critical("failed creating lz dictionary");
return NULL;
}
return _red_create_glz_dictionary(dcc->common.base.client, id, glz_dict);
@@ -9205,7 +9213,7 @@ static GlzSharedDictionary *red_create_restored_glz_dictionary(DisplayChannelCli
GlzEncDictContext *glz_dict = glz_enc_dictionary_restore(restore_data,
&dcc->glz_data.usr);
if (!glz_dict) {
- PANIC("failed creating lz dictionary");
+ spice_critical("failed creating lz dictionary");
return NULL;
}
return _red_create_glz_dictionary(dcc->common.base.client, id, glz_dict);
@@ -9342,7 +9350,7 @@ static void red_release_pixmap_cache(DisplayChannelClient *dcc)
static int display_channel_init_cache(DisplayChannelClient *dcc, SpiceMsgcDisplayInit *init_info)
{
- ASSERT(!dcc->pixmap_cache);
+ spice_assert(!dcc->pixmap_cache);
return !!(dcc->pixmap_cache = red_get_pixmap_cache(dcc->common.base.client,
init_info->pixmap_cache_id,
init_info->pixmap_cache_size));
@@ -9351,7 +9359,7 @@ static int display_channel_init_cache(DisplayChannelClient *dcc, SpiceMsgcDispla
static int display_channel_init_glz_dictionary(DisplayChannelClient *dcc,
SpiceMsgcDisplayInit *init_info)
{
- ASSERT(!dcc->glz_dict);
+ spice_assert(!dcc->glz_dict);
ring_init(&dcc->glz_drawables);
ring_init(&dcc->glz_drawables_inst_to_free);
pthread_mutex_init(&dcc->glz_drawables_inst_to_free_lock, NULL);
@@ -9369,7 +9377,7 @@ static int display_channel_init(DisplayChannelClient *dcc, SpiceMsgcDisplayInit
static int display_channel_handle_migrate_glz_dictionary(DisplayChannelClient *dcc,
DisplayChannelMigrateData *migrate_info)
{
- ASSERT(!dcc->glz_dict);
+ spice_assert(!dcc->glz_dict);
ring_init(&dcc->glz_drawables);
ring_init(&dcc->glz_drawables_inst_to_free);
pthread_mutex_init(&dcc->glz_drawables_inst_to_free_lock, NULL);
@@ -9384,7 +9392,7 @@ static int display_channel_handle_migrate_mark(RedChannelClient *rcc)
RedChannel *channel = &display_channel->common.base;
if (!display_channel->expect_migrate_mark) {
- red_printf("unexpected");
+ spice_printerr("unexpected");
return FALSE;
}
display_channel->expect_migrate_mark = FALSE;
@@ -9398,12 +9406,12 @@ static uint64_t display_channel_handle_migrate_data_get_serial(
DisplayChannelMigrateData *migrate_data = message;
if (size < sizeof(*migrate_data)) {
- red_printf("bad message size");
+ spice_printerr("bad message size");
return 0;
}
if (migrate_data->magic != DISPLAY_MIGRATE_DATA_MAGIC ||
migrate_data->version != DISPLAY_MIGRATE_DATA_VERSION) {
- red_printf("invalid content");
+ spice_printerr("invalid content");
return 0;
}
return migrate_data->message_serial;
@@ -9419,17 +9427,17 @@ static uint64_t display_channel_handle_migrate_data(RedChannelClient *rcc, uint3
int i;
if (size < sizeof(*migrate_data)) {
- red_printf("bad message size");
+ spice_printerr("bad message size");
return FALSE;
}
migrate_data = (DisplayChannelMigrateData *)message;
if (migrate_data->magic != DISPLAY_MIGRATE_DATA_MAGIC ||
migrate_data->version != DISPLAY_MIGRATE_DATA_VERSION) {
- red_printf("invalid content");
+ spice_printerr("invalid content");
return FALSE;
}
if (!display_channel->expect_migrate_data) {
- red_printf("unexpected");
+ spice_printerr("unexpected");
return FALSE;
}
display_channel->expect_migrate_data = FALSE;
@@ -9456,10 +9464,10 @@ static uint64_t display_channel_handle_migrate_data(RedChannelClient *rcc, uint3
dcc->glz = glz_encoder_create(dcc->common.id,
dcc->glz_dict->dict, &dcc->glz_data.usr);
if (!dcc->glz) {
- PANIC("create global lz failed");
+ spice_critical("create global lz failed");
}
} else {
- PANIC("restoring global lz dictionary failed");
+ spice_critical("restoring global lz dictionary failed");
}
red_channel_client_pipe_add_type(rcc, PIPE_ITEM_TYPE_INVAL_PALLET_CACHE);
@@ -9474,7 +9482,7 @@ static int display_channel_handle_message(RedChannelClient *rcc, uint32_t size,
switch (type) {
case SPICE_MSGC_DISPLAY_INIT:
if (!dcc->expect_init) {
- red_printf("unexpected SPICE_MSGC_DISPLAY_INIT");
+ spice_printerr("unexpected SPICE_MSGC_DISPLAY_INIT");
return FALSE;
}
dcc->expect_init = FALSE;
@@ -9493,12 +9501,12 @@ static int common_channel_config_socket(RedChannelClient *rcc)
int delay_val;
if ((flags = fcntl(stream->socket, F_GETFL)) == -1) {
- red_printf("accept failed, %s", strerror(errno));
+ spice_printerr("accept failed, %s", strerror(errno));
return FALSE;
}
if (fcntl(stream->socket, F_SETFL, flags | O_NONBLOCK) == -1) {
- red_printf("accept failed, %s", strerror(errno));
+ spice_printerr("accept failed, %s", strerror(errno));
return FALSE;
}
@@ -9507,7 +9515,7 @@ static int common_channel_config_socket(RedChannelClient *rcc)
if (setsockopt(stream->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val,
sizeof(delay_val)) == -1) {
if (errno != ENOTSUP) {
- red_printf("setsockopt failed, %s", strerror(errno));
+ spice_printerr("setsockopt failed, %s", strerror(errno));
}
}
return TRUE;
@@ -9553,7 +9561,7 @@ static SpiceWatch *worker_watch_add(int fd, int event_mask, SpiceWatchFunc func,
}
}
if (i == MAX_EVENT_SOURCES) {
- red_printf("ERROR could not add a watch for channel type %u id %u",
+ spice_printerr("ERROR could not add a watch for channel type %u id %u",
rcc->channel->type, rcc->channel->id);
return NULL;
}
@@ -9700,7 +9708,7 @@ error:
static void display_channel_hold_pipe_item(RedChannelClient *rcc, PipeItem *item)
{
- ASSERT(item);
+ spice_assert(item);
switch (item->type) {
case PIPE_ITEM_TYPE_DRAW:
ref_drawable_pipe_item(SPICE_CONTAINEROF(item, DrawablePipeItem, dpi_pipe_item));
@@ -9722,7 +9730,7 @@ static void display_channel_hold_pipe_item(RedChannelClient *rcc, PipeItem *item
((ImageItem *)item)->refs++;
break;
default:
- PANIC("invalid item type");
+ spice_critical("invalid item type");
}
}
@@ -9755,7 +9763,7 @@ static void display_channel_client_release_item_after_push(DisplayChannelClient
free(item);
break;
default:
- PANIC("invalid item type");
+ spice_critical("invalid item type");
}
}
@@ -9814,7 +9822,7 @@ static void display_channel_client_release_item_before_push(DisplayChannelClient
free(item);
break;
default:
- PANIC("invalid item type");
+ spice_critical("invalid item type");
}
}
@@ -9822,11 +9830,11 @@ static void display_channel_release_item(RedChannelClient *rcc, PipeItem *item,
{
DisplayChannelClient *dcc = RCC_TO_DCC(rcc);
- ASSERT(item);
+ spice_assert(item);
if (item_pushed) {
display_channel_client_release_item_after_push(dcc, item);
} else {
- red_printf_once("not pushed (%d)", item->type);
+ spice_debug("not pushed (%d)", item->type);
display_channel_client_release_item_before_push(dcc, item);
}
}
@@ -9839,7 +9847,7 @@ static void display_channel_create(RedWorker *worker, int migrate)
return;
}
- red_printf("create display channel");
+ spice_printerr("create display channel");
if (!(worker->display_channel = (DisplayChannel *)__new_channel(
worker, sizeof(*display_channel),
SPICE_CHANNEL_DISPLAY, migrate,
@@ -9852,7 +9860,7 @@ static void display_channel_create(RedWorker *worker, int migrate)
display_channel_handle_migrate_data,
display_channel_handle_migrate_data_get_serial
))) {
- red_printf("failed to create display channel");
+ spice_printerr("failed to create display channel");
return;
}
display_channel = worker->display_channel;
@@ -9887,18 +9895,18 @@ static void handle_new_display_channel(RedWorker *worker, RedClient *client, Red
int is_low_bandwidth = main_channel_client_is_low_bandwidth(red_client_get_main(client));
if (!worker->display_channel) {
- red_printf("Warning: Display channel was not created");
+ spice_printerr("Warning: Display channel was not created");
return;
}
display_channel = worker->display_channel;
- red_printf("add display channel client");
+ spice_printerr("add display channel client");
dcc = display_channel_client_create(&display_channel->common, client, stream,
common_caps, num_common_caps,
caps, num_caps);
if (!dcc) {
return;
}
- red_printf("New display (client %p) dcc %p stream %p", client, dcc, stream);
+ spice_printerr("New display (client %p) dcc %p stream %p", client, dcc, stream);
stream_buf_size = 32*1024;
dcc->send_data.stream_outbuf = spice_malloc(stream_buf_size);
dcc->send_data.stream_outbuf_size = stream_buf_size;
@@ -9925,8 +9933,8 @@ static void handle_new_display_channel(RedWorker *worker, RedClient *client, Red
SPICE_WAN_COMPRESSION_ALWAYS);
}
- red_printf("jpeg %s", display_channel->enable_jpeg ? "enabled" : "disabled");
- red_printf("zlib-over-glz %s", display_channel->enable_zlib_glz_wrap ? "enabled" : "disabled");
+ spice_printerr("jpeg %s", display_channel->enable_jpeg ? "enabled" : "disabled");
+ spice_printerr("zlib-over-glz %s", display_channel->enable_zlib_glz_wrap ? "enabled" : "disabled");
// todo: tune level according to bandwidth
display_channel->zlib_level = ZLIB_DEFAULT_COMPRESSION_LEVEL;
@@ -9950,7 +9958,7 @@ static void red_disconnect_cursor(RedChannel *channel)
return;
}
common = SPICE_CONTAINEROF(channel, CommonChannel, base);
- ASSERT(channel == (RedChannel *)common->worker->cursor_channel);
+ spice_assert(channel == (RedChannel *)common->worker->cursor_channel);
common->worker->cursor_channel = NULL;
red_channel_apply_clients(channel, red_reset_cursor_cache);
red_channel_disconnect(channel);
@@ -9971,7 +9979,7 @@ static void on_new_cursor_channel(RedWorker *worker, RedChannelClient *rcc)
{
CursorChannel *channel = worker->cursor_channel;
- ASSERT(channel);
+ spice_assert(channel);
red_channel_client_ack_zero_messages_window(rcc);
red_channel_client_push_set_ack(rcc);
// TODO: why do we check for context.canvas? defer this to after display cc is connected
@@ -9984,7 +9992,7 @@ static void on_new_cursor_channel(RedWorker *worker, RedChannelClient *rcc)
static void cursor_channel_hold_pipe_item(RedChannelClient *rcc, PipeItem *item)
{
CursorPipeItem *cursor_pipe_item;
- ASSERT(item);
+ spice_assert(item);
cursor_pipe_item = SPICE_CONTAINEROF(item, CursorPipeItem, base);
ref_cursor_pipe_item(cursor_pipe_item);
}
@@ -10008,7 +10016,7 @@ static void cursor_channel_client_release_item_before_push(CursorChannelClient *
free(item);
break;
default:
- red_error("invalid pipe item type");
+ spice_error("invalid pipe item type");
}
}
@@ -10022,7 +10030,7 @@ static void cursor_channel_client_release_item_after_push(CursorChannelClient *c
break;
}
default:
- PANIC("invalid item type");
+ spice_critical("invalid item type");
}
}
@@ -10030,12 +10038,12 @@ static void cursor_channel_release_item(RedChannelClient *rcc, PipeItem *item, i
{
CursorChannelClient *ccc = RCC_TO_CCC(rcc);
- ASSERT(item);
+ spice_assert(item);
if (item_pushed) {
cursor_channel_client_release_item_after_push(ccc, item);
} else {
- red_printf_once("not pushed (%d)", item->type);
+ spice_debug("not pushed (%d)", item->type);
cursor_channel_client_release_item_before_push(ccc, item);
}
}
@@ -10045,7 +10053,7 @@ static void cursor_channel_create(RedWorker *worker, int migrate)
if (worker->cursor_channel != NULL) {
return;
}
- red_printf("create cursor channel");
+ spice_printerr("create cursor channel");
worker->cursor_channel = (CursorChannel *)__new_channel(
worker, sizeof(*worker->cursor_channel),
SPICE_CHANNEL_CURSOR, migrate,
@@ -10068,11 +10076,11 @@ static void red_connect_cursor(RedWorker *worker, RedClient *client, RedsStream
CursorChannelClient *ccc;
if (worker->cursor_channel == NULL) {
- red_printf("Warning: cursor channel was not created");
+ spice_printerr("Warning: cursor channel was not created");
return;
}
channel = worker->cursor_channel;
- red_printf("add cursor channel client");
+ spice_printerr("add cursor channel client");
ccc = cursor_channel_create_rcc(&channel->common, client, stream,
common_caps, num_common_caps,
caps, num_caps);
@@ -10104,7 +10112,7 @@ static void red_wait_outgoing_item(RedChannelClient *rcc)
return;
}
end_time = red_now() + DETACH_TIMEOUT;
- red_printf("blocked");
+ spice_printerr("blocked");
do {
usleep(DETACH_SLEEP_DURATION);
@@ -10113,12 +10121,12 @@ static void red_wait_outgoing_item(RedChannelClient *rcc)
} while ((blocked = red_channel_client_blocked(rcc)) && red_now() < end_time);
if (blocked) {
- red_printf("timeout");
+ spice_printerr("timeout");
// TODO - shutting down the socket but we still need to trigger
// disconnection. Right now we wait for main channel to error for that.
red_channel_client_shutdown(rcc);
} else {
- ASSERT(red_channel_client_no_item_being_sent(rcc));
+ spice_assert(red_channel_client_no_item_being_sent(rcc));
}
}
@@ -10127,7 +10135,7 @@ static void rcc_shutdown_if_blocked(RedChannelClient *rcc)
if (red_channel_client_blocked(rcc)) {
red_channel_client_shutdown(rcc);
} else {
- ASSERT(red_channel_client_no_item_being_sent(rcc));
+ spice_assert(red_channel_client_no_item_being_sent(rcc));
}
}
@@ -10141,7 +10149,7 @@ static void red_wait_outgoing_items(RedChannel *channel)
}
end_time = red_now() + DETACH_TIMEOUT;
- red_printf("blocked");
+ spice_printerr("blocked");
do {
usleep(DETACH_SLEEP_DURATION);
@@ -10150,10 +10158,10 @@ static void red_wait_outgoing_items(RedChannel *channel)
} while ((blocked = red_channel_any_blocked(channel)) && red_now() < end_time);
if (blocked) {
- red_printf("timeout");
+ spice_printerr("timeout");
red_channel_apply_clients(channel, rcc_shutdown_if_blocked);
} else {
- ASSERT(red_channel_no_item_being_sent(channel));
+ spice_assert(red_channel_no_item_being_sent(channel));
}
}
@@ -10168,7 +10176,7 @@ static void red_wait_pipe_item_sent(RedChannelClient *rcc, PipeItem *item)
return;
}
- red_printf("");
+ spice_printerr("");
channel->channel_cbs.hold_item(rcc, item);
end_time = red_now() + CHANNEL_PUSH_TIMEOUT;
@@ -10187,7 +10195,7 @@ static void red_wait_pipe_item_sent(RedChannelClient *rcc, PipeItem *item)
}
if (item_in_pipe) {
- red_printf("timeout");
+ spice_printerr("timeout");
red_channel_client_disconnect(rcc);
} else {
if (red_channel_client_item_being_sent(rcc, item)) {
@@ -10236,7 +10244,7 @@ void handle_dev_update_async(void *opaque, void *payload)
red_get_rect_ptr(&rect, &qxl_area);
flush_display_commands(worker);
- ASSERT(worker->running);
+ spice_assert(worker->running);
validate_surface(worker, surface_id);
red_update_area(worker, &rect, surface_id);
@@ -10272,7 +10280,7 @@ void handle_dev_update(void *opaque, void *payload)
red_get_rect_ptr(rect, qxl_area);
flush_display_commands(worker);
- ASSERT(worker->running);
+ spice_assert(worker->running);
validate_surface(worker, surface_id);
red_update_area(worker, rect, surface_id);
@@ -10328,7 +10336,7 @@ static inline void destroy_surface_wait(RedWorker *worker, int surface_id)
static void dev_destroy_surface_wait(RedWorker *worker, uint32_t surface_id)
{
- ASSERT(surface_id == 0);
+ spice_assert(surface_id == 0);
flush_all_qxl_commands(worker);
@@ -10381,10 +10389,10 @@ static inline void dev_destroy_surfaces(RedWorker *worker)
if (worker->surfaces[i].context.canvas) {
red_destroy_surface(worker, i);
}
- ASSERT(!worker->surfaces[i].context.canvas);
+ spice_assert(!worker->surfaces[i].context.canvas);
}
}
- ASSERT(ring_is_empty(&worker->streams));
+ spice_assert(ring_is_empty(&worker->streams));
if (display_is_connected(worker)) {
red_channel_pipes_add_type(&worker->display_channel->common.base,
@@ -10410,9 +10418,9 @@ static void dev_create_primary_surface(RedWorker *worker, uint32_t surface_id,
{
uint8_t *line_0;
- PANIC_ON(surface_id != 0);
- PANIC_ON(surface.height == 0);
- PANIC_ON(((uint64_t)abs(surface.stride) * (uint64_t)surface.height) !=
+ spice_warn_if(surface_id != 0);
+ spice_warn_if(surface.height == 0);
+ spice_warn_if(((uint64_t)abs(surface.stride) * (uint64_t)surface.height) !=
abs(surface.stride) * surface.height);
line_0 = (uint8_t*)get_virt(&worker->mem_slots, surface.mem,
@@ -10446,19 +10454,19 @@ void handle_dev_create_primary_surface(void *opaque, void *payload)
static void dev_destroy_primary_surface(RedWorker *worker, uint32_t surface_id)
{
- PANIC_ON(surface_id != 0);
+ spice_warn_if(surface_id != 0);
if (!worker->surfaces[surface_id].context.canvas) {
- red_printf("double destroy of primary surface");
+ spice_printerr("double destroy of primary surface");
return;
}
flush_all_qxl_commands(worker);
dev_destroy_surface_wait(worker, 0);
red_destroy_surface(worker, 0);
- ASSERT(ring_is_empty(&worker->streams));
+ spice_assert(ring_is_empty(&worker->streams));
- ASSERT(!worker->surfaces[surface_id].context.canvas);
+ spice_assert(!worker->surfaces[surface_id].context.canvas);
red_cursor_reset(worker);
}
@@ -10518,8 +10526,8 @@ void handle_dev_stop(void *opaque, void *payload)
{
RedWorker *worker = opaque;
- red_printf("stop");
- ASSERT(worker->running);
+ spice_printerr("stop");
+ spice_assert(worker->running);
worker->running = FALSE;
red_display_clear_glz_drawables(worker->display_channel);
flush_all_surfaces(worker);
@@ -10533,7 +10541,7 @@ void handle_dev_start(void *opaque, void *payload)
RedChannel *cursor_red_channel = &worker->cursor_channel->common.base;
RedChannel *display_red_channel = &worker->display_channel->common.base;
- ASSERT(!worker->running);
+ spice_assert(!worker->running);
if (worker->cursor_channel) {
cursor_red_channel->migrate = FALSE;
}
@@ -10558,16 +10566,15 @@ void handle_dev_oom(void *opaque, void *payload)
RedChannel *display_red_channel = &worker->display_channel->common.base;
int ring_is_empty;
- ASSERT(worker->running);
+ spice_assert(worker->running);
// streams? but without streams also leak
- red_printf_debug(1, "WORKER",
- "OOM1 #draw=%u, #red_draw=%u, #glz_draw=%u current %u pipes %u",
- worker->drawable_count,
- worker->red_drawable_count,
- worker->glz_drawable_count,
- worker->current_size,
- worker->display_channel ?
- red_channel_sum_pipes_size(display_red_channel) : 0);
+ spice_debug("OOM1 #draw=%u, #red_draw=%u, #glz_draw=%u current %u pipes %u",
+ worker->drawable_count,
+ worker->red_drawable_count,
+ worker->glz_drawable_count,
+ worker->current_size,
+ worker->display_channel ?
+ red_channel_sum_pipes_size(display_red_channel) : 0);
while (red_process_commands(worker, MAX_PIPE_SIZE, &ring_is_empty)) {
red_channel_push(&worker->display_channel->common.base);
}
@@ -10575,14 +10582,13 @@ void handle_dev_oom(void *opaque, void *payload)
red_free_some(worker);
worker->qxl->st->qif->flush_resources(worker->qxl);
}
- red_printf_debug(1, "WORKER",
- "OOM2 #draw=%u, #red_draw=%u, #glz_draw=%u current %u pipes %u",
- worker->drawable_count,
- worker->red_drawable_count,
- worker->glz_drawable_count,
- worker->current_size,
- worker->display_channel ?
- red_channel_sum_pipes_size(display_red_channel) : 0);
+ spice_debug("OOM2 #draw=%u, #red_draw=%u, #glz_draw=%u current %u pipes %u",
+ worker->drawable_count,
+ worker->red_drawable_count,
+ worker->glz_drawable_count,
+ worker->current_size,
+ worker->display_channel ?
+ red_channel_sum_pipes_size(display_red_channel) : 0);
clear_bit(RED_WORKER_PENDING_OOM, worker->pending);
}
@@ -10644,7 +10650,7 @@ void handle_dev_display_connect(void *opaque, void *payload)
RedClient *client = msg->client;
int migration = msg->migration;
- red_printf("connect");
+ spice_printerr("connect");
handle_new_display_channel(worker, client, stream, migration,
msg->common_caps, msg->num_common_caps,
msg->caps, msg->num_caps);
@@ -10657,8 +10663,8 @@ void handle_dev_display_disconnect(void *opaque, void *payload)
RedWorkerMessageDisplayDisconnect *msg = payload;
RedChannelClient *rcc = msg->rcc;
- red_printf("disconnect display client");
- ASSERT(rcc);
+ spice_printerr("disconnect display client");
+ spice_assert(rcc);
red_channel_client_disconnect(rcc);
}
@@ -10668,8 +10674,8 @@ void handle_dev_display_migrate(void *opaque, void *payload)
RedWorker *worker = opaque;
RedChannelClient *rcc = msg->rcc;
- red_printf("migrate display client");
- ASSERT(rcc);
+ spice_printerr("migrate display client");
+ spice_assert(rcc);
red_migrate_display(worker, rcc);
}
@@ -10693,7 +10699,7 @@ void handle_dev_cursor_connect(void *opaque, void *payload)
RedClient *client = msg->client;
int migration = msg->migration;
- red_printf("cursor connect");
+ spice_printerr("cursor connect");
red_connect_cursor(worker, client, stream, migration,
msg->common_caps, msg->num_common_caps,
msg->caps, msg->num_caps);
@@ -10706,8 +10712,8 @@ void handle_dev_cursor_disconnect(void *opaque, void *payload)
RedWorkerMessageCursorDisconnect *msg = payload;
RedChannelClient *rcc = msg->rcc;
- red_printf("disconnect cursor client");
- ASSERT(rcc);
+ spice_printerr("disconnect cursor client");
+ spice_assert(rcc);
red_channel_client_disconnect(rcc);
}
@@ -10717,8 +10723,8 @@ void handle_dev_cursor_migrate(void *opaque, void *payload)
RedWorker *worker = opaque;
RedChannelClient *rcc = msg->rcc;
- red_printf("migrate cursor client");
- ASSERT(rcc);
+ spice_printerr("migrate cursor client");
+ spice_assert(rcc);
red_migrate_cursor(worker, rcc);
}
@@ -10730,25 +10736,25 @@ void handle_dev_set_compression(void *opaque, void *payload)
worker->image_compression = msg->image_compression;
switch (worker->image_compression) {
case SPICE_IMAGE_COMPRESS_AUTO_LZ:
- red_printf("ic auto_lz");
+ spice_printerr("ic auto_lz");
break;
case SPICE_IMAGE_COMPRESS_AUTO_GLZ:
- red_printf("ic auto_glz");
+ spice_printerr("ic auto_glz");
break;
case SPICE_IMAGE_COMPRESS_QUIC:
- red_printf("ic quic");
+ spice_printerr("ic quic");
break;
case SPICE_IMAGE_COMPRESS_LZ:
- red_printf("ic lz");
+ spice_printerr("ic lz");
break;
case SPICE_IMAGE_COMPRESS_GLZ:
- red_printf("ic glz");
+ spice_printerr("ic glz");
break;
case SPICE_IMAGE_COMPRESS_OFF:
- red_printf("ic off");
+ spice_printerr("ic off");
break;
default:
- red_printf("ic invalid");
+ spice_printerr("ic invalid");
}
#ifdef COMPRESS_STAT
print_compress_stats(worker->display_channel);
@@ -10769,19 +10775,19 @@ void handle_dev_set_streaming_video(void *opaque, void *payload)
RedWorker *worker = opaque;
worker->streaming_video = msg->streaming_video;
- ASSERT(worker->streaming_video != STREAM_VIDEO_INVALID);
+ spice_assert(worker->streaming_video != STREAM_VIDEO_INVALID);
switch(worker->streaming_video) {
case STREAM_VIDEO_ALL:
- red_printf("sv all");
+ spice_printerr("sv all");
break;
case STREAM_VIDEO_FILTER:
- red_printf("sv filter");
+ spice_printerr("sv filter");
break;
case STREAM_VIDEO_OFF:
- red_printf("sv off");
+ spice_printerr("sv off");
break;
default:
- red_printf("sv invalid");
+ spice_printerr("sv invalid");
}
}
@@ -10791,7 +10797,7 @@ void handle_dev_set_mouse_mode(void *opaque, void *payload)
RedWorker *worker = opaque;
worker->mouse_mode = msg->mode;
- red_printf("mouse mode %u", worker->mouse_mode);
+ spice_printerr("mouse mode %u", worker->mouse_mode);
}
void handle_dev_add_memslot_async(void *opaque, void *payload)
@@ -10819,7 +10825,7 @@ void handle_dev_loadvm_commands(void *opaque, void *payload)
uint32_t count = msg->count;
QXLCommandExt *ext = msg->ext;
- red_printf("loadvm_commands");
+ spice_printerr("loadvm_commands");
for (i = 0 ; i < count ; ++i) {
switch (ext[i].cmd.type) {
case QXL_CMD_CURSOR:
@@ -10835,7 +10841,7 @@ void handle_dev_loadvm_commands(void *opaque, void *payload)
red_process_surface(worker, surface_cmd, ext[i].group_id, TRUE);
break;
default:
- red_printf("unhandled loadvm command type (%d)", ext[i].cmd.type);
+ spice_printerr("unhandled loadvm command type (%d)", ext[i].cmd.type);
break;
}
}
@@ -10848,7 +10854,7 @@ static void worker_handle_dispatcher_async_done(void *opaque,
RedWorker *worker = opaque;
RedWorkerMessageAsync *msg_async = payload;
- red_printf_debug(2, "WORKER", "");
+ spice_debug(NULL);
red_dispatcher_async_complete(worker->red_dispatcher, msg_async->cmd);
}
@@ -11039,7 +11045,7 @@ static void red_init(RedWorker *worker, WorkerInitData *init_data)
Dispatcher *dispatcher;
int i;
- ASSERT(sizeof(CursorItem) <= QXL_CURSUR_DEVICE_DATA_SIZE);
+ spice_assert(sizeof(CursorItem) <= QXL_CURSUR_DEVICE_DATA_SIZE);
memset(worker, 0, sizeof(RedWorker));
dispatcher = red_dispatcher_get_dispatcher(init_data->red_dispatcher);
@@ -11051,7 +11057,7 @@ static void red_init(RedWorker *worker, WorkerInitData *init_data)
register_callbacks(dispatcher);
worker->pending = init_data->pending;
worker->cursor_visible = TRUE;
- ASSERT(init_data->num_renderers > 0);
+ spice_assert(init_data->num_renderers > 0);
worker->num_renderers = init_data->num_renderers;
memcpy(worker->renderers, init_data->renderers, sizeof(worker->renderers));
worker->renderer = RED_RENDERER_INVALID;
@@ -11093,7 +11099,7 @@ static void red_init(RedWorker *worker, WorkerInitData *init_data)
init_data->memslot_id_bits,
init_data->internal_groupslot_id);
- PANIC_ON(init_data->n_surfaces > NUM_SURFACES);
+ spice_warn_if(init_data->n_surfaces > NUM_SURFACES);
worker->n_surfaces = init_data->n_surfaces;
message = RED_WORKER_MESSAGE_READY;
@@ -11111,13 +11117,13 @@ void *red_worker_main(void *arg)
{
RedWorker worker;
- red_printf("begin");
- ASSERT(MAX_PIPE_SIZE > WIDE_CLIENT_ACK_WINDOW &&
+ spice_printerr("begin");
+ spice_assert(MAX_PIPE_SIZE > WIDE_CLIENT_ACK_WINDOW &&
MAX_PIPE_SIZE > NARROW_CLIENT_ACK_WINDOW); //ensure wakeup by ack message
#if defined(RED_WORKER_STAT) || defined(COMPRESS_STAT)
if (pthread_getcpuclockid(pthread_self(), &clock_id)) {
- red_error("pthread_getcpuclockid failed");
+ spice_error("pthread_getcpuclockid failed");
}
#endif
@@ -11145,7 +11151,7 @@ void *red_worker_main(void *arg)
worker.event_timeout = INF_EVENT_WAIT;
if (num_events == -1) {
if (errno != EINTR) {
- red_error("poll failed, %s", strerror(errno));
+ spice_error("poll failed, %s", strerror(errno));
}
}
@@ -11181,7 +11187,7 @@ void *red_worker_main(void *arg)
}
red_push(&worker);
}
- red_printf("exit");
+ spice_printerr("exit");
return 0;
}
@@ -11260,7 +11266,7 @@ static void dump_bitmap(RedWorker *worker, SpiceBitmap *bitmap, uint32_t group_i
alpha = 1;
break;
default:
- red_error("invalid bitmap format %u", bitmap->format);
+ spice_error("invalid bitmap format %u", bitmap->format);
}
if (!rgb) {
@@ -11282,7 +11288,7 @@ static void dump_bitmap(RedWorker *worker, SpiceBitmap *bitmap, uint32_t group_i
f = fopen(file_str, "wb");
if (!f) {
- red_error("Error creating bmp\n");
+ spice_error("Error creating bmp");
return;
}
diff --git a/server/red_worker.h b/server/red_worker.h
index 1f63d01..fd23ede 100644
--- a/server/red_worker.h
+++ b/server/red_worker.h
@@ -131,7 +131,7 @@ static inline void send_data(int fd, void *in_buf, int n)
if (errno == EINTR) {
continue;
}
- red_error("%s", strerror(errno));
+ spice_error("%s", strerror(errno));
}
buf += now;
n -= now;
@@ -152,7 +152,7 @@ static inline void receive_data(int fd, void *in_buf, int n)
if (errno == EINTR) {
continue;
}
- red_error("%s", strerror(errno));
+ spice_error("%s", strerror(errno));
}
buf += now;
n -= now;
diff --git a/server/reds.c b/server/reds.c
index cf493dd..27e7ea2 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -467,7 +467,7 @@ StatNodeRef stat_add_node(StatNodeRef parent, const char *name, int visible)
StatNodeRef ref;
SpiceStatNode *node;
- ASSERT(name && strlen(name) > 0);
+ spice_assert(name && strlen(name) > 0);
if (strlen(name) >= sizeof(node->name)) {
return INVALID_STAT_REF;
}
@@ -495,7 +495,7 @@ StatNodeRef stat_add_node(StatNodeRef parent, const char *name, int visible)
break;
}
}
- ASSERT(!(node->flags & SPICE_STAT_NODE_FLAG_ENABLED));
+ spice_assert(!(node->flags & SPICE_STAT_NODE_FLAG_ENABLED));
node->value = 0;
node->flags = SPICE_STAT_NODE_FLAG_ENABLED | (visible ? SPICE_STAT_NODE_FLAG_VISIBLE : 0);
strncpy(node->name, name, sizeof(node->name));
@@ -552,7 +552,7 @@ void reds_update_stat_value(uint32_t value)
void reds_register_channel(RedChannel *channel)
{
- ASSERT(reds);
+ spice_assert(reds);
ring_add(&reds->channels, &channel->link);
reds->num_of_channels++;
}
@@ -563,7 +563,7 @@ void reds_unregister_channel(RedChannel *channel)
ring_remove(&channel->link);
reds->num_of_channels--;
} else {
- red_printf("not found");
+ spice_printerr("not found");
}
}
@@ -585,7 +585,7 @@ static void reds_mig_cleanup(void)
if (reds->mig_inprogress) {
if (reds->mig_wait_connect) {
SpiceMigrateInterface *sif;
- ASSERT(migration_interface);
+ spice_assert(migration_interface);
sif = SPICE_CONTAINEROF(migration_interface->base.sif, SpiceMigrateInterface, base);
sif->migrate_connect_complete(migration_interface);
}
@@ -644,7 +644,7 @@ void reds_client_disconnect(RedClient *client)
return;
}
- red_printf("");
+ spice_printerr("");
/* disconnecting is set to prevent recursion because of the following:
* main_channel_client_on_disconnect->
* reds_client_disconnect->red_client_destroy->main_channel...
@@ -684,7 +684,7 @@ static void reds_disconnect(void)
{
RingItem *link, *next;
- red_printf("");
+ spice_printerr("");
RING_FOREACH_SAFE(link, next, &reds->clients) {
reds_client_disconnect(SPICE_CONTAINEROF(link, RedClient, link));
}
@@ -759,7 +759,7 @@ static void reds_agent_remove(void)
static void reds_push_tokens(void)
{
reds->agent_state.num_client_tokens += reds->agent_state.num_tokens;
- ASSERT(reds->agent_state.num_client_tokens <= REDS_AGENT_WINDOW_SIZE);
+ spice_assert(reds->agent_state.num_client_tokens <= REDS_AGENT_WINDOW_SIZE);
main_channel_push_tokens(reds->main_channel, reds->agent_state.num_tokens);
reds->agent_state.num_tokens = 0;
}
@@ -865,7 +865,7 @@ static void dispatch_vdi_port_data(int port, VDIReadBuf *buf)
break;
default:
ring_add(&state->read_bufs, &buf->link);
- red_printf("invalid port");
+ spice_printerr("invalid port");
reds_agent_remove();
}
}
@@ -1019,7 +1019,7 @@ int reds_num_of_clients(void)
SPICE_GNUC_VISIBLE int spice_server_get_num_clients(SpiceServer *s)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
return reds_num_of_clients();
}
@@ -1055,7 +1055,7 @@ void reds_fill_channels(SpiceMsgChannels *channels_info)
channels_info->num_of_channels = used_channels;
if (used_channels != reds->num_of_channels) {
- red_printf("sent %d out of %d", used_channels, reds->num_of_channels);
+ spice_printerr("sent %d out of %d", used_channels, reds->num_of_channels);
}
}
@@ -1076,7 +1076,7 @@ void reds_on_main_agent_data(MainChannelClient *mcc, void *message, size_t size)
int res;
if (!reds->agent_state.num_client_tokens) {
- red_printf("token violation");
+ spice_printerr("token violation");
reds_disconnect();
return;
}
@@ -1096,7 +1096,7 @@ void reds_on_main_agent_data(MainChannelClient *mcc, void *message, size_t size)
}
if (!(ring_item = ring_get_head(&reds->agent_state.external_bufs))) {
- red_printf("no agent free bufs");
+ spice_printerr("no agent free bufs");
reds_disconnect();
return;
}
@@ -1124,14 +1124,14 @@ void reds_on_main_mouse_mode_request(void *message, size_t size)
if (reds->is_client_mouse_allowed) {
reds_set_mouse_mode(SPICE_MOUSE_MODE_CLIENT);
} else {
- red_printf("client mouse is disabled");
+ spice_printerr("client mouse is disabled");
}
break;
case SPICE_MOUSE_MODE_SERVER:
reds_set_mouse_mode(SPICE_MOUSE_MODE_SERVER);
break;
default:
- red_printf("unsupported mouse mode");
+ spice_printerr("unsupported mouse mode");
}
}
@@ -1211,7 +1211,7 @@ static int reds_main_channel_restore_vdi_read_state(MainMigrateData *data, uint8
switch (state->read_state) {
case VDI_PORT_READ_STATE_READ_HADER:
if (data->read_buf_len) {
- red_printf("unexpected receive buf");
+ spice_printerr("unexpected receive buf");
reds_disconnect();
return FALSE;
}
@@ -1219,13 +1219,13 @@ static int reds_main_channel_restore_vdi_read_state(MainMigrateData *data, uint8
break;
case VDI_PORT_READ_STATE_GET_BUFF:
if (state->message_recive_len > state->vdi_chunk_header.size) {
- red_printf("invalid message receive len");
+ spice_printerr("invalid message receive len");
reds_disconnect();
return FALSE;
}
if (data->read_buf_len) {
- red_printf("unexpected receive buf");
+ spice_printerr("unexpected receive buf");
reds_disconnect();
return FALSE;
}
@@ -1235,20 +1235,20 @@ static int reds_main_channel_restore_vdi_read_state(MainMigrateData *data, uint8
uint32_t n;
if (!data->read_buf_len) {
- red_printf("read state and read_buf_len == 0");
+ spice_printerr("read state and read_buf_len == 0");
reds_disconnect();
return FALSE;
}
if (state->message_recive_len > state->vdi_chunk_header.size) {
- red_printf("invalid message receive len");
+ spice_printerr("invalid message receive len");
reds_disconnect();
return FALSE;
}
if (!(ring_item = ring_get_head(&state->read_bufs))) {
- red_printf("get read buf failed");
+ spice_printerr("get read buf failed");
reds_disconnect();
return FALSE;
}
@@ -1258,7 +1258,7 @@ static int reds_main_channel_restore_vdi_read_state(MainMigrateData *data, uint8
buff->len = data->read_buf_len;
n = buff->len - state->recive_len;
if (buff->len > SPICE_AGENT_MAX_DATA_SIZE || n > SPICE_AGENT_MAX_DATA_SIZE) {
- red_printf("bad read position");
+ spice_printerr("bad read position");
reds_disconnect();
return FALSE;
}
@@ -1268,7 +1268,7 @@ static int reds_main_channel_restore_vdi_read_state(MainMigrateData *data, uint8
break;
}
default:
- red_printf("invalid read state");
+ spice_printerr("invalid read state");
reds_disconnect();
return FALSE;
}
@@ -1296,14 +1296,14 @@ static int reds_main_channel_restore_vdi_wqueue(MainMigrateData *data, uint8_t *
inf_end = inf + data->write_queue_size;
pos = (uint8_t *)inf_end;
if (pos > end) {
- red_printf("access violation");
+ spice_printerr("access violation");
reds_disconnect();
return FALSE;
}
for (; inf < inf_end; inf++) {
if (pos + inf->len > end) {
- red_printf("access violation");
+ spice_printerr("access violation");
reds_disconnect();
return FALSE;
}
@@ -1311,7 +1311,7 @@ static int reds_main_channel_restore_vdi_wqueue(MainMigrateData *data, uint8_t *
VDInternalBuf *buf;
if (inf->len > sizeof(*buf) - SPICE_OFFSETOF(VDInternalBuf, header)) {
- red_printf("bad buffer len");
+ spice_printerr("bad buffer len");
reds_disconnect();
return FALSE;
}
@@ -1327,12 +1327,12 @@ static int reds_main_channel_restore_vdi_wqueue(MainMigrateData *data, uint8_t *
state->num_tokens--;
if (inf->len > sizeof(*buf) - SPICE_OFFSETOF(VDAgentExtBuf, buf)) {
- red_printf("bad buffer len");
+ spice_printerr("bad buffer len");
reds_disconnect();
return FALSE;
}
if (!(ring_item = ring_get_head(&reds->agent_state.external_bufs))) {
- red_printf("no external buff");
+ spice_printerr("no external buff");
reds_disconnect();
return FALSE;
}
@@ -1343,7 +1343,7 @@ static int reds_main_channel_restore_vdi_wqueue(MainMigrateData *data, uint8_t *
buf->base.write_len = inf->len;
ring_add(&reds->agent_state.write_queue, &buf->base.link);
} else {
- red_printf("invalid data");
+ spice_printerr("invalid data");
reds_disconnect();
return FALSE;
}
@@ -1358,13 +1358,13 @@ void reds_on_main_receive_migrate_data(MainMigrateData *data, uint8_t *end)
uint8_t *pos;
if (data->version != MAIN_CHANNEL_MIG_DATA_VERSION) {
- red_printf("version mismatch");
+ spice_printerr("version mismatch");
reds_disconnect();
return;
}
state->num_client_tokens = data->num_client_tokens;
- ASSERT(state->num_client_tokens + data->write_queue_size <= REDS_AGENT_WINDOW_SIZE +
+ spice_assert(state->num_client_tokens + data->write_queue_size <= REDS_AGENT_WINDOW_SIZE +
REDS_NUM_INTERNAL_AGENT_MESSAGES);
state->num_tokens = REDS_AGENT_WINDOW_SIZE - state->num_client_tokens;
@@ -1395,7 +1395,7 @@ void reds_on_main_receive_migrate_data(MainMigrateData *data, uint8_t *end)
}
reds_main_channel_restore_vdi_wqueue(data, pos, end);
- ASSERT(state->num_client_tokens + state->num_tokens == REDS_AGENT_WINDOW_SIZE);
+ spice_assert(state->num_client_tokens + state->num_tokens == REDS_AGENT_WINDOW_SIZE);
while (write_to_vdi_port() || read_from_vdi_port());
}
@@ -1447,8 +1447,8 @@ static int reds_send_link_ack(RedLinkInfo *link)
channel = reds_find_channel(link->link_mess->channel_type, 0);
if (!channel) {
- ASSERT(link->link_mess->channel_type == SPICE_CHANNEL_MAIN);
- ASSERT(reds->main_channel);
+ spice_assert(link->link_mess->channel_type == SPICE_CHANNEL_MAIN);
+ spice_assert(reds->main_channel);
channel = &reds->main_channel->base;
}
@@ -1461,12 +1461,12 @@ static int reds_send_link_ack(RedLinkInfo *link)
ack.caps_offset = sizeof(SpiceLinkReply);
if (!(link->tiTicketing.rsa = RSA_new())) {
- red_printf("RSA nes failed");
+ spice_printerr("RSA nes failed");
return FALSE;
}
if (!(bio = BIO_new(BIO_s_mem()))) {
- red_printf("BIO new failed");
+ spice_printerr("BIO new failed");
return FALSE;
}
@@ -1511,7 +1511,7 @@ static int reds_send_link_error(RedLinkInfo *link, uint32_t error)
static void reds_show_new_channel(RedLinkInfo *link, int connection_id)
{
- red_printf("channel %d:%d, connected successfully, over %s link",
+ spice_printerr("channel %d:%d, connected successfully, over %s link",
link->link_mess->channel_type,
link->link_mess->channel_id,
link->stream->ssl == NULL ? "Non Secure" : "Secure");
@@ -1532,7 +1532,7 @@ static void reds_send_link_result(RedLinkInfo *link, uint32_t error)
int reds_expects_link_id(uint32_t connection_id)
{
- red_printf("TODO: keep a list of connection_id's from migration, compare to them");
+ spice_printerr("TODO: keep a list of connection_id's from migration, compare to them");
return 1;
}
@@ -1540,8 +1540,8 @@ static void reds_mig_target_client_add(RedClient *client)
{
RedsMigTargetClient *mig_client;
- ASSERT(reds);
- red_printf("");
+ spice_assert(reds);
+ spice_printerr("");
mig_client = spice_malloc0(sizeof(RedsMigTargetClient));
mig_client->client = client;
ring_init(&mig_client->pending_links);
@@ -1571,8 +1571,8 @@ static void reds_mig_target_client_add_pending_link(RedsMigTargetClient *client,
{
RedsMigPendingLink *mig_link;
- ASSERT(reds);
- ASSERT(client);
+ spice_assert(reds);
+ spice_assert(client);
mig_link = spice_malloc0(sizeof(RedsMigPendingLink));
mig_link->link_msg = link_msg;
mig_link->stream = stream;
@@ -1617,8 +1617,8 @@ static void reds_handle_main_link(RedLinkInfo *link)
MainChannelClient *mcc;
int mig_target = FALSE;
- red_printf("");
- ASSERT(reds->main_channel);
+ spice_printerr("");
+ spice_assert(reds->main_channel);
link_mess = link->link_mess;
if (!reds->allow_multiple_clients) {
@@ -1657,7 +1657,7 @@ static void reds_handle_main_link(RedLinkInfo *link)
link_mess->num_common_caps,
link_mess->num_common_caps ? caps : NULL, link_mess->num_channel_caps,
link_mess->num_channel_caps ? caps + link_mess->num_common_caps : NULL);
- red_printf("NEW Client %p mcc %p connect-id %d", client, mcc, connection_id);
+ spice_printerr("NEW Client %p mcc %p connect-id %d", client, mcc, connection_id);
free(link_mess);
red_client_set_main(client, mcc);
@@ -1713,7 +1713,7 @@ static void openssl_init(RedLinkInfo *link)
link->tiTicketing.bn = BN_new();
if (!link->tiTicketing.bn) {
- red_error("OpenSSL BIGNUMS alloc failed");
+ spice_error("OpenSSL BIGNUMS alloc failed");
}
BN_set_word(link->tiTicketing.bn, f4);
@@ -1725,9 +1725,9 @@ static void reds_channel_do_link(RedChannel *channel, RedClient *client,
{
uint32_t *caps;
- ASSERT(channel);
- ASSERT(link_msg);
- ASSERT(stream);
+ spice_assert(channel);
+ spice_assert(link_msg);
+ spice_assert(stream);
if (link_msg->channel_type == SPICE_CHANNEL_INPUTS && !stream->ssl) {
char *mess = "keyboard channel is insecure";
@@ -1751,11 +1751,11 @@ void reds_on_client_migrate_complete(RedClient *client)
MainChannelClient *mcc;
RingItem *item;
- red_printf("%p", client);
+ spice_printerr("%p", client);
mcc = red_client_get_main(client);
mig_client = reds_mig_target_client_find(client);
if (!mig_client) {
- red_printf("Error: mig target client was not found");
+ spice_printerr("Error: mig target client was not found");
return;
}
@@ -1773,7 +1773,7 @@ void reds_on_client_migrate_complete(RedClient *client)
channel = reds_find_channel(mig_link->link_msg->channel_type,
mig_link->link_msg->channel_id);
if (!channel) {
- red_printf("warning: client %p channel (%d, %d) (type, id) wasn't found",
+ spice_printerr("warning: client %p channel (%d, %d) (type, id) wasn't found",
client,
mig_link->link_msg->channel_type,
mig_link->link_msg->channel_id);
@@ -1824,10 +1824,10 @@ static void reds_handle_other_links(RedLinkInfo *link)
mig_client = reds_mig_target_client_find(client);
if (red_client_during_migrate_at_target(client)) {
- ASSERT(mig_client);
+ spice_assert(mig_client);
reds_mig_target_client_add_pending_link(mig_client, link_mess, link->stream);
} else {
- ASSERT(!mig_client);
+ spice_assert(!mig_client);
reds_channel_do_link(channel, client, link_mess, link->stream);
free(link_mess);
}
@@ -1862,7 +1862,7 @@ static void reds_handle_ticket(void *opaque)
if (strlen(taTicket.password) == 0) {
reds_send_link_result(link, SPICE_LINK_ERR_PERMISSION_DENIED);
- red_printf("Ticketing is enabled, but no password is set. "
+ spice_printerr("Ticketing is enabled, but no password is set. "
"please set a ticket first");
reds_link_free(link);
return;
@@ -1870,9 +1870,9 @@ static void reds_handle_ticket(void *opaque)
if (expired || strncmp(password, taTicket.password, SPICE_MAX_PASSWORD_LENGTH) != 0) {
if (expired) {
- red_printf("Ticket has expired");
+ spice_printerr("Ticket has expired");
} else {
- red_printf("Invalid password");
+ spice_printerr("Invalid password");
}
reds_send_link_result(link, SPICE_LINK_ERR_PERMISSION_DENIED);
reds_link_free(link);
@@ -1913,7 +1913,7 @@ static ssize_t reds_stream_sasl_write(RedsStream *s, const void *buf, size_t nby
(const char **)&s->sasl.encoded,
&s->sasl.encodedLength);
if (err != SASL_OK) {
- red_printf("sasl_encode error: %d", err);
+ spice_printerr("sasl_encode error: %d", err);
return -1;
}
@@ -1922,7 +1922,7 @@ static ssize_t reds_stream_sasl_write(RedsStream *s, const void *buf, size_t nby
}
if (!s->sasl.encoded) {
- red_printf("sasl_encode didn't return a buffer!");
+ spice_printerr("sasl_encode didn't return a buffer!");
return 0;
}
@@ -1974,7 +1974,7 @@ static ssize_t reds_stream_sasl_read(RedsStream *s, uint8_t *buf, size_t nbyte)
(char *)encoded, n,
&decoded, &decodedlen);
if (err != SASL_OK) {
- red_printf("sasl_decode error: %d", err);
+ spice_printerr("sasl_decode error: %d", err);
return -1;
}
@@ -1997,7 +1997,7 @@ static void async_read_handler(int fd, int event, void *data)
for (;;) {
int n = obj->end - obj->now;
- ASSERT(n > 0);
+ spice_assert(n > 0);
n = reds_stream_read(obj->stream, obj->now, n);
if (n <= 0) {
if (n < 0) {
@@ -2056,7 +2056,7 @@ static char *addr_to_string(const char *format,
host, sizeof(host),
serv, sizeof(serv),
NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
- red_printf("Cannot resolve address %d: %s",
+ spice_printerr("Cannot resolve address %d: %s",
err, gai_strerror(err));
return NULL;
}
@@ -2087,7 +2087,7 @@ static int auth_sasl_check_ssf(RedsSASL *sasl, int *runSSF)
}
ssf = *(const int *)val;
- red_printf("negotiated an SSF of %d", ssf);
+ spice_printerr("negotiated an SSF of %d", ssf);
if (ssf < 56) {
return 0; /* 56 is good for Kerberos */
}
@@ -2134,7 +2134,7 @@ static void reds_handle_auth_sasl_step(void *opaque)
datalen--; /* Don't count NULL byte when passing to _start() */
}
- red_printf("Step using SASL Data %p (%d bytes)",
+ spice_printerr("Step using SASL Data %p (%d bytes)",
clientdata, datalen);
err = sasl_server_step(sasl->conn,
clientdata,
@@ -2143,18 +2143,18 @@ static void reds_handle_auth_sasl_step(void *opaque)
&serveroutlen);
if (err != SASL_OK &&
err != SASL_CONTINUE) {
- red_printf("sasl step failed %d (%s)",
+ spice_printerr("sasl step failed %d (%s)",
err, sasl_errdetail(sasl->conn));
goto authabort;
}
if (serveroutlen > SASL_DATA_MAX_LEN) {
- red_printf("sasl step reply data too long %d",
+ spice_printerr("sasl step reply data too long %d",
serveroutlen);
goto authabort;
}
- red_printf("SASL return data %d bytes, %p", serveroutlen, serverout);
+ spice_printerr("SASL return data %d bytes, %p", serveroutlen, serverout);
if (serveroutlen) {
serveroutlen += 1;
@@ -2168,7 +2168,7 @@ static void reds_handle_auth_sasl_step(void *opaque)
sync_write_u8(link->stream, err == SASL_CONTINUE ? 0 : 1);
if (err == SASL_CONTINUE) {
- red_printf("%s", "Authentication must continue (step)");
+ spice_printerr("%s", "Authentication must continue (step)");
/* Wait for step length */
obj->now = (uint8_t *)&sasl->len;
obj->end = obj->now + sizeof(uint32_t);
@@ -2178,11 +2178,11 @@ static void reds_handle_auth_sasl_step(void *opaque)
int ssf;
if (auth_sasl_check_ssf(sasl, &ssf) == 0) {
- red_printf("Authentication rejected for weak SSF");
+ spice_printerr("Authentication rejected for weak SSF");
goto authreject;
}
- red_printf("Authentication successful");
+ spice_printerr("Authentication successful");
sync_write_u32(link->stream, SPICE_LINK_ERR_OK); /* Accept auth */
/*
@@ -2212,9 +2212,9 @@ static void reds_handle_auth_sasl_steplen(void *opaque)
AsyncRead *obj = &link->asyc_read;
RedsSASL *sasl = &link->stream->sasl;
- red_printf("Got steplen %d", sasl->len);
+ spice_printerr("Got steplen %d", sasl->len);
if (sasl->len > SASL_DATA_MAX_LEN) {
- red_printf("Too much SASL data %d", sasl->len);
+ spice_printerr("Too much SASL data %d", sasl->len);
reds_link_free(link);
return;
}
@@ -2264,7 +2264,7 @@ static void reds_handle_auth_sasl_start(void *opaque)
datalen--; /* Don't count NULL byte when passing to _start() */
}
- red_printf("Start SASL auth with mechanism %s. Data %p (%d bytes)",
+ spice_printerr("Start SASL auth with mechanism %s. Data %p (%d bytes)",
sasl->mechlist, clientdata, datalen);
err = sasl_server_start(sasl->conn,
sasl->mechlist,
@@ -2274,18 +2274,18 @@ static void reds_handle_auth_sasl_start(void *opaque)
&serveroutlen);
if (err != SASL_OK &&
err != SASL_CONTINUE) {
- red_printf("sasl start failed %d (%s)",
+ spice_printerr("sasl start failed %d (%s)",
err, sasl_errdetail(sasl->conn));
goto authabort;
}
if (serveroutlen > SASL_DATA_MAX_LEN) {
- red_printf("sasl start reply data too long %d",
+ spice_printerr("sasl start reply data too long %d",
serveroutlen);
goto authabort;
}
- red_printf("SASL return data %d bytes, %p", serveroutlen, serverout);
+ spice_printerr("SASL return data %d bytes, %p", serveroutlen, serverout);
if (serveroutlen) {
serveroutlen += 1;
@@ -2299,7 +2299,7 @@ static void reds_handle_auth_sasl_start(void *opaque)
sync_write_u8(link->stream, err == SASL_CONTINUE ? 0 : 1);
if (err == SASL_CONTINUE) {
- red_printf("%s", "Authentication must continue (start)");
+ spice_printerr("%s", "Authentication must continue (start)");
/* Wait for step length */
obj->now = (uint8_t *)&sasl->len;
obj->end = obj->now + sizeof(uint32_t);
@@ -2309,11 +2309,11 @@ static void reds_handle_auth_sasl_start(void *opaque)
int ssf;
if (auth_sasl_check_ssf(sasl, &ssf) == 0) {
- red_printf("Authentication rejected for weak SSF");
+ spice_printerr("Authentication rejected for weak SSF");
goto authreject;
}
- red_printf("Authentication successful");
+ spice_printerr("Authentication successful");
sync_write_u32(link->stream, SPICE_LINK_ERR_OK); /* Accept auth */
/*
@@ -2343,9 +2343,9 @@ static void reds_handle_auth_startlen(void *opaque)
AsyncRead *obj = &link->asyc_read;
RedsSASL *sasl = &link->stream->sasl;
- red_printf("Got client start len %d", sasl->len);
+ spice_printerr("Got client start len %d", sasl->len);
if (sasl->len > SASL_DATA_MAX_LEN) {
- red_printf("Too much SASL data %d", sasl->len);
+ spice_printerr("Too much SASL data %d", sasl->len);
reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA);
reds_link_free(link);
return;
@@ -2370,24 +2370,24 @@ static void reds_handle_auth_mechname(void *opaque)
RedsSASL *sasl = &link->stream->sasl;
sasl->mechname[sasl->len] = '\0';
- red_printf("Got client mechname '%s' check against '%s'",
+ spice_printerr("Got client mechname '%s' check against '%s'",
sasl->mechname, sasl->mechlist);
if (strncmp(sasl->mechlist, sasl->mechname, sasl->len) == 0) {
if (sasl->mechlist[sasl->len] != '\0' &&
sasl->mechlist[sasl->len] != ',') {
- red_printf("One %d", sasl->mechlist[sasl->len]);
+ spice_printerr("One %d", sasl->mechlist[sasl->len]);
reds_link_free(link);
return;
}
} else {
char *offset = strstr(sasl->mechlist, sasl->mechname);
- red_printf("Two %p", offset);
+ spice_printerr("Two %p", offset);
if (!offset) {
reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA);
return;
}
- red_printf("Two '%s'", offset);
+ spice_printerr("Two '%s'", offset);
if (offset[-1] != ',' ||
(offset[sasl->len] != '\0'&&
offset[sasl->len] != ',')) {
@@ -2399,7 +2399,7 @@ static void reds_handle_auth_mechname(void *opaque)
free(sasl->mechlist);
sasl->mechlist = spice_strdup(sasl->mechname);
- red_printf("Validated mechname '%s'", sasl->mechname);
+ spice_printerr("Validated mechname '%s'", sasl->mechname);
obj->now = (uint8_t *)&sasl->len;
obj->end = obj->now + sizeof(uint32_t);
@@ -2416,14 +2416,14 @@ static void reds_handle_auth_mechlen(void *opaque)
RedsSASL *sasl = &link->stream->sasl;
if (sasl->len < 1 || sasl->len > 100) {
- red_printf("Got bad client mechname len %d", sasl->len);
+ spice_printerr("Got bad client mechname len %d", sasl->len);
reds_link_free(link);
return;
}
sasl->mechname = spice_malloc(sasl->len + 1);
- red_printf("Wait for client mechname");
+ spice_printerr("Wait for client mechname");
obj->now = (uint8_t *)sasl->mechname;
obj->end = obj->now + sasl->len;
obj->done = reds_handle_auth_mechname;
@@ -2465,7 +2465,7 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
localAddr = remoteAddr = NULL;
if (err != SASL_OK) {
- red_printf("sasl context setup failed %d (%s)",
+ spice_printerr("sasl context setup failed %d (%s)",
err, sasl_errstring(err, NULL, NULL));
sasl->conn = NULL;
goto error;
@@ -2478,7 +2478,7 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
ssf = SSL_get_cipher_bits(link->stream->ssl, NULL);
err = sasl_setprop(sasl->conn, SASL_SSF_EXTERNAL, &ssf);
if (err != SASL_OK) {
- red_printf("cannot set SASL external SSF %d (%s)",
+ spice_printerr("cannot set SASL external SSF %d (%s)",
err, sasl_errstring(err, NULL, NULL));
goto error_dispose;
}
@@ -2506,7 +2506,7 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
err = sasl_setprop(sasl->conn, SASL_SEC_PROPS, &secprops);
if (err != SASL_OK) {
- red_printf("cannot set SASL security props %d (%s)",
+ spice_printerr("cannot set SASL security props %d (%s)",
err, sasl_errstring(err, NULL, NULL));
goto error_dispose;
}
@@ -2520,23 +2520,23 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
NULL,
NULL);
if (err != SASL_OK || mechlist == NULL) {
- red_printf("cannot list SASL mechanisms %d (%s)",
+ spice_printerr("cannot list SASL mechanisms %d (%s)",
err, sasl_errdetail(sasl->conn));
goto error_dispose;
}
- red_printf("Available mechanisms for client: '%s'", mechlist);
+ spice_printerr("Available mechanisms for client: '%s'", mechlist);
sasl->mechlist = spice_strdup(mechlist);
mechlistlen = strlen(mechlist);
if (!sync_write(link->stream, &mechlistlen, sizeof(uint32_t))
|| !sync_write(link->stream, sasl->mechlist, mechlistlen)) {
- red_printf("SASL mechanisms write error");
+ spice_printerr("SASL mechanisms write error");
goto error;
}
- red_printf("Wait for client mechname length");
+ spice_printerr("Wait for client mechname length");
obj->now = (uint8_t *)&sasl->len;
obj->end = obj->now + sizeof(uint32_t);
obj->done = reds_handle_auth_mechlen;
@@ -2557,7 +2557,7 @@ static void reds_handle_auth_mechanism(void *opaque)
{
RedLinkInfo *link = (RedLinkInfo *)opaque;
- red_printf("Auth method: %d", link->auth_mechanism.auth_mechanism);
+ spice_printerr("Auth method: %d", link->auth_mechanism.auth_mechanism);
if (link->auth_mechanism.auth_mechanism == SPICE_COMMON_CAP_AUTH_SPICE
&& !sasl_enabled
@@ -2565,13 +2565,13 @@ static void reds_handle_auth_mechanism(void *opaque)
reds_get_spice_ticket(link);
#if HAVE_SASL
} else if (link->auth_mechanism.auth_mechanism == SPICE_COMMON_CAP_AUTH_SASL) {
- red_printf("Starting SASL");
+ spice_printerr("Starting SASL");
reds_start_auth_sasl(link);
#endif
} else {
- red_printf("Unknown auth method, disconnecting");
+ spice_printerr("Unknown auth method, disconnecting");
if (sasl_enabled) {
- red_printf("Your client doesn't handle SASL?");
+ spice_printerr("Your client doesn't handle SASL?");
}
reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA);
reds_link_free(link);
@@ -2608,10 +2608,10 @@ static void reds_handle_read_link_done(void *opaque)
if (!reds_security_check(link)) {
if (link->stream->ssl) {
- red_printf("spice channels %d should not be encrypted", link_mess->channel_type);
+ spice_printerr("spice channels %d should not be encrypted", link_mess->channel_type);
reds_send_link_error(link, SPICE_LINK_ERR_NEED_UNSECURED);
} else {
- red_printf("spice channels %d should be encrypted", link_mess->channel_type);
+ spice_printerr("spice channels %d should be encrypted", link_mess->channel_type);
reds_send_link_error(link, SPICE_LINK_ERR_NEED_SECURED);
}
reds_link_free(link);
@@ -2625,11 +2625,11 @@ static void reds_handle_read_link_done(void *opaque)
if (!auth_selection) {
if (sasl_enabled && !link->skip_auth) {
- red_printf("SASL enabled, but peer supports only spice authentication");
+ spice_printerr("SASL enabled, but peer supports only spice authentication");
reds_send_link_error(link, SPICE_LINK_ERR_VERSION_MISMATCH);
return;
}
- red_printf("Peer doesn't support AUTH selection");
+ spice_printerr("Peer doesn't support AUTH selection");
reds_get_spice_ticket(link);
} else {
obj->now = (uint8_t *)&link->auth_mechanism;
@@ -2647,7 +2647,7 @@ static void reds_handle_link_error(void *opaque, int err)
case EPIPE:
break;
default:
- red_printf("%s", strerror(errno));
+ spice_printerr("%s", strerror(errno));
break;
}
reds_link_free(link);
@@ -2670,7 +2670,7 @@ static void reds_handle_read_header_done(void *opaque)
reds_send_link_error(link, SPICE_LINK_ERR_VERSION_MISMATCH);
}
- red_printf("version mismatch");
+ spice_printerr("version mismatch");
reds_link_free(link);
return;
}
@@ -2679,7 +2679,7 @@ static void reds_handle_read_header_done(void *opaque)
if (header->size < sizeof(SpiceLinkMess)) {
reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA);
- red_printf("bad size %u", header->size);
+ spice_printerr("bad size %u", header->size);
reds_link_free(link);
return;
}
@@ -2712,7 +2712,7 @@ static void reds_handle_ssl_accept(int fd, int event, void *data)
if ((return_code = SSL_accept(link->stream->ssl)) != 1) {
int ssl_error = SSL_get_error(link->stream->ssl, return_code);
if (ssl_error != SSL_ERROR_WANT_READ && ssl_error != SSL_ERROR_WANT_WRITE) {
- red_printf("SSL_accept failed, error=%d", ssl_error);
+ spice_printerr("SSL_accept failed, error=%d", ssl_error);
reds_link_free(link);
} else {
if (ssl_error == SSL_ERROR_WANT_READ) {
@@ -2735,18 +2735,18 @@ static RedLinkInfo *reds_init_client_connection(int socket)
int flags;
if ((flags = fcntl(socket, F_GETFL)) == -1) {
- red_printf("accept failed, %s", strerror(errno));
+ spice_printerr("accept failed, %s", strerror(errno));
goto error;
}
if (fcntl(socket, F_SETFL, flags | O_NONBLOCK) == -1) {
- red_printf("accept failed, %s", strerror(errno));
+ spice_printerr("accept failed, %s", strerror(errno));
goto error;
}
if (setsockopt(socket, IPPROTO_TCP, TCP_NODELAY, &delay_val, sizeof(delay_val)) == -1) {
if (errno != ENOTSUP) {
- red_printf("setsockopt failed, %s", strerror(errno));
+ spice_printerr("setsockopt failed, %s", strerror(errno));
}
}
@@ -2796,13 +2796,13 @@ static RedLinkInfo *reds_init_client_ssl_connection(int socket)
// Handle SSL handshaking
if (!(sbio = BIO_new_socket(link->stream->socket, BIO_NOCLOSE))) {
- red_printf("could not allocate ssl bio socket");
+ spice_printerr("could not allocate ssl bio socket");
goto error;
}
link->stream->ssl = SSL_new(reds->ctx);
if (!link->stream->ssl) {
- red_printf("could not allocate ssl context");
+ spice_printerr("could not allocate ssl context");
BIO_free(sbio);
goto error;
}
@@ -2830,7 +2830,7 @@ static RedLinkInfo *reds_init_client_ssl_connection(int socket)
}
ERR_print_errors_fp(stderr);
- red_printf("SSL_accept failed, error=%d", ssl_error);
+ spice_printerr("SSL_accept failed, error=%d", ssl_error);
SSL_free(link->stream->ssl);
error:
@@ -2846,7 +2846,7 @@ static void reds_accept_ssl_connection(int fd, int event, void *data)
int socket;
if ((socket = accept(reds->secure_listen_socket, NULL, 0)) == -1) {
- red_printf("accept failed, %s", strerror(errno));
+ spice_printerr("accept failed, %s", strerror(errno));
return;
}
@@ -2862,7 +2862,7 @@ static void reds_accept(int fd, int event, void *data)
int socket;
if ((socket = accept(reds->listen_socket, NULL, 0)) == -1) {
- red_printf("accept failed, %s", strerror(errno));
+ spice_printerr("accept failed, %s", strerror(errno));
return;
}
@@ -2876,9 +2876,9 @@ SPICE_GNUC_VISIBLE int spice_server_add_client(SpiceServer *s, int socket, int s
RedLinkInfo *link;
RedsStream *stream;
- ASSERT(reds == s);
+ spice_assert(reds == s);
if (!(link = reds_init_client_connection(socket))) {
- red_printf("accept failed");
+ spice_printerr("accept failed");
return -1;
}
@@ -2898,7 +2898,7 @@ SPICE_GNUC_VISIBLE int spice_server_add_ssl_client(SpiceServer *s, int socket, i
{
RedLinkInfo *link;
- ASSERT(reds == s);
+ spice_assert(reds == s);
if (!(link = reds_init_client_ssl_connection(socket))) {
return -1;
}
@@ -2925,7 +2925,7 @@ static int reds_init_socket(const char *addr, int portnr, int family)
snprintf(port, sizeof(port), "%d", portnr);
rc = getaddrinfo(strlen(addr) ? addr : NULL, port, &ai, &res);
if (rc != 0) {
- red_error("getaddrinfo(%s,%s): %s", addr, port,
+ spice_error("getaddrinfo(%s,%s): %s", addr, port,
gai_strerror(rc));
}
@@ -2951,7 +2951,7 @@ static int reds_init_socket(const char *addr, int portnr, int family)
}
close(slisten);
}
- red_printf("%s: binding socket to %s:%d failed", __FUNCTION__,
+ spice_printerr("%s: binding socket to %s:%d failed", __FUNCTION__,
addr, portnr);
freeaddrinfo(res);
return -1;
@@ -2959,7 +2959,7 @@ static int reds_init_socket(const char *addr, int portnr, int family)
listen:
freeaddrinfo(res);
if (listen(slisten,1) != 0) {
- red_error("%s: listen: %s", __FUNCTION__, strerror(errno));
+ spice_error("listen: %s", strerror(errno));
close(slisten);
return -1;
}
@@ -2977,7 +2977,7 @@ static int reds_init_net(void)
SPICE_WATCH_EVENT_READ,
reds_accept, NULL);
if (reds->listen_watch == NULL) {
- red_error("set fd handle failed");
+ spice_error("set fd handle failed");
}
}
@@ -2991,7 +2991,7 @@ static int reds_init_net(void)
SPICE_WATCH_EVENT_READ,
reds_accept_ssl_connection, NULL);
if (reds->secure_listen_watch == NULL) {
- red_error("set fd handle failed");
+ spice_error("set fd handle failed");
}
}
@@ -3001,7 +3001,7 @@ static int reds_init_net(void)
SPICE_WATCH_EVENT_READ,
reds_accept, NULL);
if (reds->listen_watch == NULL) {
- red_error("set fd handle failed");
+ spice_error("set fd handle failed");
}
}
return 0;
@@ -3013,18 +3013,18 @@ static void load_dh_params(SSL_CTX *ctx, char *file)
BIO *bio;
if ((bio = BIO_new_file(file, "r")) == NULL) {
- red_error("Could not open DH file");
+ spice_error("Could not open DH file");
}
ret = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
if (ret == 0) {
- red_error("Could not read DH params");
+ spice_error("Could not read DH params");
}
BIO_free(bio);
if (SSL_CTX_set_tmp_dh(ctx, ret) < 0) {
- red_error("Could not set DH params");
+ spice_error("Could not set DH params");
}
}
@@ -3092,7 +3092,7 @@ static void reds_init_ssl(void)
ssl_method = TLSv1_method();
reds->ctx = SSL_CTX_new(ssl_method);
if (!reds->ctx) {
- red_error("Could not allocate new SSL context");
+ spice_error("Could not allocate new SSL context");
}
/* Limit connection to TLSv1 only */
@@ -3104,9 +3104,9 @@ static void reds_init_ssl(void)
/* Load our keys and certificates*/
return_code = SSL_CTX_use_certificate_chain_file(reds->ctx, ssl_parameters.certs_file);
if (return_code == 1) {
- red_printf("Loaded certificates from %s", ssl_parameters.certs_file);
+ spice_printerr("Loaded certificates from %s", ssl_parameters.certs_file);
} else {
- red_error("Could not load certificates from %s", ssl_parameters.certs_file);
+ spice_error("Could not load certificates from %s", ssl_parameters.certs_file);
}
SSL_CTX_set_default_passwd_cb(reds->ctx, ssl_password_cb);
@@ -3114,17 +3114,17 @@ static void reds_init_ssl(void)
return_code = SSL_CTX_use_PrivateKey_file(reds->ctx, ssl_parameters.private_key_file,
SSL_FILETYPE_PEM);
if (return_code == 1) {
- red_printf("Using private key from %s", ssl_parameters.private_key_file);
+ spice_printerr("Using private key from %s", ssl_parameters.private_key_file);
} else {
- red_error("Could not use private key file");
+ spice_error("Could not use private key file");
}
/* Load the CAs we trust*/
return_code = SSL_CTX_load_verify_locations(reds->ctx, ssl_parameters.ca_certificate_file, 0);
if (return_code == 1) {
- red_printf("Loaded CA certificates from %s", ssl_parameters.ca_certificate_file);
+ spice_printerr("Loaded CA certificates from %s", ssl_parameters.ca_certificate_file);
} else {
- red_error("Could not use CA file %s", ssl_parameters.ca_certificate_file);
+ spice_error("Could not use CA file %s", ssl_parameters.ca_certificate_file);
}
#if (OPENSSL_VERSION_NUMBER < 0x00905100L)
@@ -3195,7 +3195,7 @@ enum {
static inline void on_activating_ticketing(void)
{
if (!ticketing_enabled && reds_main_channel_connected()) {
- red_printf("disconnecting");
+ spice_printerr("disconnecting");
reds_disconnect();
}
}
@@ -3247,8 +3247,8 @@ static void reds_mig_release(void)
static void reds_mig_started(void)
{
- red_printf("");
- ASSERT(reds->mig_spice);
+ spice_printerr("");
+ spice_assert(reds->mig_spice);
reds->mig_inprogress = TRUE;
reds->mig_wait_connect = TRUE;
@@ -3257,10 +3257,10 @@ static void reds_mig_started(void)
static void reds_mig_finished(int completed)
{
- red_printf("");
+ spice_printerr("");
if (!reds_main_channel_connected()) {
- red_printf("no peer connected");
+ spice_printerr("no peer connected");
return;
}
reds->mig_inprogress = TRUE;
@@ -3277,7 +3277,7 @@ static void reds_mig_finished(int completed)
static void reds_mig_switch(void)
{
if (!reds->mig_spice) {
- red_printf("warning: reds_mig_switch called without migrate_info set");
+ spice_printerr("warning: reds_mig_switch called without migrate_info set");
return;
}
main_channel_migrate_switch(reds->main_channel, reds->mig_spice);
@@ -3286,8 +3286,8 @@ static void reds_mig_switch(void)
static void migrate_timeout(void *opaque)
{
- red_printf("");
- ASSERT(reds->mig_wait_connect || reds->mig_wait_disconnect);
+ spice_printerr("");
+ spice_assert(reds->mig_wait_connect || reds->mig_wait_disconnect);
if (reds->mig_wait_connect) {
/* we will fall back to the switch host scheme when migration completes */
main_channel_migrate_cancel_wait(reds->main_channel);
@@ -3383,10 +3383,10 @@ static int spice_server_char_device_add_interface(SpiceServer *s,
SpiceCharDeviceInstance* char_device =
SPICE_CONTAINEROF(sin, SpiceCharDeviceInstance, base);
- red_printf("CHAR_DEVICE %s", char_device->subtype);
+ spice_printerr("CHAR_DEVICE %s", char_device->subtype);
if (strcmp(char_device->subtype, SUBTYPE_VDAGENT) == 0) {
if (vdagent) {
- red_printf("vdagent already attached");
+ spice_printerr("vdagent already attached");
return -1;
}
char_device->st = &vdagent_char_device_state;
@@ -3410,7 +3410,7 @@ static void spice_server_char_device_remove_interface(SpiceBaseInstance *sin)
SpiceCharDeviceInstance* char_device =
SPICE_CONTAINEROF(sin, SpiceCharDeviceInstance, base);
- red_printf("remove CHAR_DEVICE %s", char_device->subtype);
+ spice_printerr("remove CHAR_DEVICE %s", char_device->subtype);
if (strcmp(char_device->subtype, SUBTYPE_VDAGENT) == 0) {
if (vdagent) {
reds_agent_remove();
@@ -3431,23 +3431,23 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
{
const SpiceBaseInterface *interface = sin->sif;
- ASSERT(reds == s);
+ spice_assert(reds == s);
if (strcmp(interface->type, SPICE_INTERFACE_KEYBOARD) == 0) {
- red_printf("SPICE_INTERFACE_KEYBOARD");
+ spice_printerr("SPICE_INTERFACE_KEYBOARD");
if (interface->major_version != SPICE_INTERFACE_KEYBOARD_MAJOR ||
interface->minor_version > SPICE_INTERFACE_KEYBOARD_MINOR) {
- red_printf("unsupported keyboard interface");
+ spice_printerr("unsupported keyboard interface");
return -1;
}
if (inputs_set_keyboard(SPICE_CONTAINEROF(sin, SpiceKbdInstance, base)) != 0) {
return -1;
}
} else if (strcmp(interface->type, SPICE_INTERFACE_MOUSE) == 0) {
- red_printf("SPICE_INTERFACE_MOUSE");
+ spice_printerr("SPICE_INTERFACE_MOUSE");
if (interface->major_version != SPICE_INTERFACE_MOUSE_MAJOR ||
interface->minor_version > SPICE_INTERFACE_MOUSE_MINOR) {
- red_printf("unsupported mouse interface");
+ spice_printerr("unsupported mouse interface");
return -1;
}
if (inputs_set_mouse(SPICE_CONTAINEROF(sin, SpiceMouseInstance, base)) != 0) {
@@ -3456,10 +3456,10 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
} else if (strcmp(interface->type, SPICE_INTERFACE_QXL) == 0) {
QXLInstance *qxl;
- red_printf("SPICE_INTERFACE_QXL");
+ spice_printerr("SPICE_INTERFACE_QXL");
if (interface->major_version != SPICE_INTERFACE_QXL_MAJOR ||
interface->minor_version > SPICE_INTERFACE_QXL_MINOR) {
- red_printf("unsupported qxl interface");
+ spice_printerr("unsupported qxl interface");
return -1;
}
@@ -3469,10 +3469,10 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
qxl->st->dispatcher = red_dispatcher_init(qxl);
} else if (strcmp(interface->type, SPICE_INTERFACE_TABLET) == 0) {
- red_printf("SPICE_INTERFACE_TABLET");
+ spice_printerr("SPICE_INTERFACE_TABLET");
if (interface->major_version != SPICE_INTERFACE_TABLET_MAJOR ||
interface->minor_version > SPICE_INTERFACE_TABLET_MINOR) {
- red_printf("unsupported tablet interface");
+ spice_printerr("unsupported tablet interface");
return -1;
}
if (inputs_set_tablet(SPICE_CONTAINEROF(sin, SpiceTabletInstance, base)) != 0) {
@@ -3484,19 +3484,19 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
}
} else if (strcmp(interface->type, SPICE_INTERFACE_PLAYBACK) == 0) {
- red_printf("SPICE_INTERFACE_PLAYBACK");
+ spice_printerr("SPICE_INTERFACE_PLAYBACK");
if (interface->major_version != SPICE_INTERFACE_PLAYBACK_MAJOR ||
interface->minor_version > SPICE_INTERFACE_PLAYBACK_MINOR) {
- red_printf("unsupported playback interface");
+ spice_printerr("unsupported playback interface");
return -1;
}
snd_attach_playback(SPICE_CONTAINEROF(sin, SpicePlaybackInstance, base));
} else if (strcmp(interface->type, SPICE_INTERFACE_RECORD) == 0) {
- red_printf("SPICE_INTERFACE_RECORD");
+ spice_printerr("SPICE_INTERFACE_RECORD");
if (interface->major_version != SPICE_INTERFACE_RECORD_MAJOR ||
interface->minor_version > SPICE_INTERFACE_RECORD_MINOR) {
- red_printf("unsupported record interface");
+ spice_printerr("unsupported record interface");
return -1;
}
snd_attach_record(SPICE_CONTAINEROF(sin, SpiceRecordInstance, base));
@@ -3504,7 +3504,7 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
} else if (strcmp(interface->type, SPICE_INTERFACE_CHAR_DEVICE) == 0) {
if (interface->major_version != SPICE_INTERFACE_CHAR_DEVICE_MAJOR ||
interface->minor_version > SPICE_INTERFACE_CHAR_DEVICE_MINOR) {
- red_printf("unsupported char device interface");
+ spice_printerr("unsupported char device interface");
return -1;
}
spice_server_char_device_add_interface(s, sin);
@@ -3512,33 +3512,33 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
} else if (strcmp(interface->type, SPICE_INTERFACE_NET_WIRE) == 0) {
#ifdef USE_TUNNEL
SpiceNetWireInstance *net;
- red_printf("SPICE_INTERFACE_NET_WIRE");
+ spice_printerr("SPICE_INTERFACE_NET_WIRE");
if (red_tunnel) {
- red_printf("net wire already attached");
+ spice_printerr("net wire already attached");
return -1;
}
if (interface->major_version != SPICE_INTERFACE_NET_WIRE_MAJOR ||
interface->minor_version > SPICE_INTERFACE_NET_WIRE_MINOR) {
- red_printf("unsupported net wire interface");
+ spice_printerr("unsupported net wire interface");
return -1;
}
net = SPICE_CONTAINEROF(sin, SpiceNetWireInstance, base);
net->st = spice_new0(SpiceNetWireState, 1);
red_tunnel = red_tunnel_attach(core, net);
#else
- red_printf("unsupported net wire interface");
+ spice_printerr("unsupported net wire interface");
return -1;
#endif
} else if (strcmp(interface->type, SPICE_INTERFACE_MIGRATION) == 0) {
- red_printf("SPICE_INTERFACE_MIGRATION");
+ spice_printerr("SPICE_INTERFACE_MIGRATION");
if (migration_interface) {
- red_printf("already have migration");
+ spice_printerr("already have migration");
return -1;
}
if (interface->major_version != SPICE_INTERFACE_MIGRATION_MAJOR ||
interface->minor_version > SPICE_INTERFACE_MIGRATION_MINOR) {
- red_printf("unsupported migration interface");
+ spice_printerr("unsupported migration interface");
return -1;
}
migration_interface = SPICE_CONTAINEROF(sin, SpiceMigrateInstance, base);
@@ -3553,21 +3553,21 @@ SPICE_GNUC_VISIBLE int spice_server_remove_interface(SpiceBaseInstance *sin)
const SpiceBaseInterface *interface = sin->sif;
if (strcmp(interface->type, SPICE_INTERFACE_TABLET) == 0) {
- red_printf("remove SPICE_INTERFACE_TABLET");
+ spice_printerr("remove SPICE_INTERFACE_TABLET");
inputs_detach_tablet(SPICE_CONTAINEROF(sin, SpiceTabletInstance, base));
reds_update_mouse_mode();
} else if (strcmp(interface->type, SPICE_INTERFACE_PLAYBACK) == 0) {
- red_printf("remove SPICE_INTERFACE_PLAYBACK");
+ spice_printerr("remove SPICE_INTERFACE_PLAYBACK");
snd_detach_playback(SPICE_CONTAINEROF(sin, SpicePlaybackInstance, base));
} else if (strcmp(interface->type, SPICE_INTERFACE_RECORD) == 0) {
- red_printf("remove SPICE_INTERFACE_RECORD");
+ spice_printerr("remove SPICE_INTERFACE_RECORD");
snd_detach_record(SPICE_CONTAINEROF(sin, SpiceRecordInstance, base));
} else if (strcmp(interface->type, SPICE_INTERFACE_CHAR_DEVICE) == 0) {
spice_server_char_device_remove_interface(sin);
} else {
- red_error("VD_INTERFACE_REMOVING unsupported");
+ spice_error("VD_INTERFACE_REMOVING unsupported");
return -1;
}
@@ -3640,10 +3640,10 @@ const char *version_string = VERSION;
static int do_spice_init(SpiceCoreInterface *core_interface)
{
- red_printf("starting %s", version_string);
+ spice_printerr("starting %s", version_string);
if (core_interface->base.major_version != SPICE_INTERFACE_CORE_MAJOR) {
- red_printf("bad core interface version");
+ spice_printerr("bad core interface version");
goto err;
}
core = core_interface;
@@ -3657,11 +3657,11 @@ static int do_spice_init(SpiceCoreInterface *core_interface)
ring_init(&reds->mig_target_clients);
if (!(reds->mig_timer = core->timer_add(migrate_timeout, NULL))) {
- red_error("migration timer create failed");
+ spice_error("migration timer create failed");
}
if (!(reds->vdi_port_write_timer = core->timer_add(vdi_port_write_retry, NULL)))
{
- red_error("vdi port write timer create failed");
+ spice_error("vdi port write timer create failed");
}
reds->vdi_port_write_timer_started = FALSE;
@@ -3672,26 +3672,26 @@ static int do_spice_init(SpiceCoreInterface *core_interface)
reds->stat_shm_name = (char *)spice_malloc(shm_name_len);
snprintf(reds->stat_shm_name, shm_name_len, SPICE_STAT_SHM_NAME, getpid());
if ((fd = shm_open(reds->stat_shm_name, O_CREAT | O_RDWR, 0444)) == -1) {
- red_error("statistics shm_open failed, %s", strerror(errno));
+ spice_error("statistics shm_open failed, %s", strerror(errno));
}
if (ftruncate(fd, REDS_STAT_SHM_SIZE) == -1) {
- red_error("statistics ftruncate failed, %s", strerror(errno));
+ spice_error("statistics ftruncate failed, %s", strerror(errno));
}
reds->stat = (SpiceStat *)mmap(NULL, REDS_STAT_SHM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (reds->stat == (SpiceStat *)MAP_FAILED) {
- red_error("statistics mmap failed, %s", strerror(errno));
+ spice_error("statistics mmap failed, %s", strerror(errno));
}
memset(reds->stat, 0, REDS_STAT_SHM_SIZE);
reds->stat->magic = SPICE_STAT_MAGIC;
reds->stat->version = SPICE_STAT_VERSION;
reds->stat->root_index = INVALID_STAT_REF;
if (pthread_mutex_init(&reds->stat_lock, NULL)) {
- red_error("mutex init failed");
+ spice_error("mutex init failed");
}
#endif
if (!(reds->mm_timer = core->timer_add(mm_timer_proc, NULL))) {
- red_error("mm timer create failed");
+ spice_error("mm timer create failed");
}
core->timer_start(reds->mm_timer, MM_TIMER_GRANULARITY_MS);
@@ -3705,7 +3705,7 @@ static int do_spice_init(SpiceCoreInterface *core_interface)
int saslerr;
if ((saslerr = sasl_server_init(NULL, sasl_appname ?
sasl_appname : "spice")) != SASL_OK) {
- red_error("Failed to initialize SASL auth %s",
+ spice_error("Failed to initialize SASL auth %s",
sasl_errstring(saslerr, NULL, NULL));
goto err;
}
@@ -3717,7 +3717,7 @@ static int do_spice_init(SpiceCoreInterface *core_interface)
reds->mouse_mode = SPICE_MOUSE_MODE_SERVER;
reds->allow_multiple_clients = getenv(SPICE_DEBUG_ALLOW_MC_ENV) != NULL;
if (reds->allow_multiple_clients) {
- red_printf("spice: allowing multiple client connections");
+ spice_printerr("spice: allowing multiple client connections");
}
atexit(reds_exit);
return 0;
@@ -3730,7 +3730,7 @@ err:
SPICE_GNUC_VISIBLE SpiceServer *spice_server_new(void)
{
/* we can't handle multiple instances (yet) */
- ASSERT(reds == NULL);
+ spice_assert(reds == NULL);
reds = spice_new0(RedsState, 1);
return reds;
@@ -3740,7 +3740,7 @@ SPICE_GNUC_VISIBLE int spice_server_init(SpiceServer *s, SpiceCoreInterface *cor
{
int ret;
- ASSERT(reds == s);
+ spice_assert(reds == s);
ret = do_spice_init(core);
if (default_renderer) {
red_dispatcher_add_renderer(default_renderer);
@@ -3750,7 +3750,7 @@ SPICE_GNUC_VISIBLE int spice_server_init(SpiceServer *s, SpiceCoreInterface *cor
SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *s)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
reds_exit();
}
@@ -3776,7 +3776,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_compat_version(SpiceServer *s,
SPICE_GNUC_VISIBLE int spice_server_set_port(SpiceServer *s, int port)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
if (port < 0 || port > 0xffff) {
return -1;
}
@@ -3786,7 +3786,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_port(SpiceServer *s, int port)
SPICE_GNUC_VISIBLE void spice_server_set_addr(SpiceServer *s, const char *addr, int flags)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
strncpy(spice_addr, addr, sizeof(spice_addr));
if (flags & SPICE_ADDR_FLAG_IPV4_ONLY) {
spice_family = PF_INET;
@@ -3798,14 +3798,14 @@ SPICE_GNUC_VISIBLE void spice_server_set_addr(SpiceServer *s, const char *addr,
SPICE_GNUC_VISIBLE int spice_server_set_listen_socket_fd(SpiceServer *s, int listen_fd)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
spice_listen_socket_fd = listen_fd;
return 0;
}
SPICE_GNUC_VISIBLE int spice_server_set_noauth(SpiceServer *s)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
memset(taTicket.password, 0, sizeof(taTicket.password));
ticketing_enabled = 0;
return 0;
@@ -3813,7 +3813,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_noauth(SpiceServer *s)
SPICE_GNUC_VISIBLE int spice_server_set_sasl(SpiceServer *s, int enabled)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
#if HAVE_SASL
sasl_enabled = enabled;
return 0;
@@ -3824,7 +3824,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_sasl(SpiceServer *s, int enabled)
SPICE_GNUC_VISIBLE int spice_server_set_sasl_appname(SpiceServer *s, const char *appname)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
#if HAVE_SASL
free(sasl_appname);
sasl_appname = spice_strdup(appname);
@@ -3851,7 +3851,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_ticket(SpiceServer *s,
int fail_if_connected,
int disconnect_if_connected)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
if (reds_main_channel_connected()) {
if (fail_if_connected) {
@@ -3884,7 +3884,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_tls(SpiceServer *s, int port,
const char *private_key_file, const char *key_passwd,
const char *dh_key_file, const char *ciphersuite)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
if (port == 0 || ca_cert_file == NULL || certs_file == NULL ||
private_key_file == NULL) {
return -1;
@@ -3920,22 +3920,22 @@ SPICE_GNUC_VISIBLE int spice_server_set_tls(SpiceServer *s, int port,
SPICE_GNUC_VISIBLE int spice_server_set_image_compression(SpiceServer *s,
spice_image_compression_t comp)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
set_image_compression(comp);
return 0;
}
SPICE_GNUC_VISIBLE spice_image_compression_t spice_server_get_image_compression(SpiceServer *s)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
return image_compression;
}
SPICE_GNUC_VISIBLE int spice_server_set_jpeg_compression(SpiceServer *s, spice_wan_compression_t comp)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
if (comp == SPICE_WAN_COMPRESSION_INVALID) {
- red_printf("invalid jpeg state");
+ spice_printerr("invalid jpeg state");
return -1;
}
// todo: support dynamically changing the state
@@ -3945,9 +3945,9 @@ SPICE_GNUC_VISIBLE int spice_server_set_jpeg_compression(SpiceServer *s, spice_w
SPICE_GNUC_VISIBLE int spice_server_set_zlib_glz_compression(SpiceServer *s, spice_wan_compression_t comp)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
if (comp == SPICE_WAN_COMPRESSION_INVALID) {
- red_printf("invalid zlib_glz state");
+ spice_printerr("invalid zlib_glz state");
return -1;
}
// todo: support dynamically changing the state
@@ -3973,7 +3973,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_channel_security(SpiceServer *s, const c
};
int i;
- ASSERT(reds == s);
+ spice_assert(reds == s);
if (channel == NULL) {
default_channel_security = security;
@@ -3990,7 +3990,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_channel_security(SpiceServer *s, const c
SPICE_GNUC_VISIBLE int spice_server_get_sock_info(SpiceServer *s, struct sockaddr *sa, socklen_t *salen)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
if (main_channel_getsockname(reds->main_channel, sa, salen) < 0) {
return -1;
}
@@ -3999,7 +3999,7 @@ SPICE_GNUC_VISIBLE int spice_server_get_sock_info(SpiceServer *s, struct sockadd
SPICE_GNUC_VISIBLE int spice_server_get_peer_info(SpiceServer *s, struct sockaddr *sa, socklen_t *salen)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
if (main_channel_getpeername(reds->main_channel, sa, salen) < 0) {
return -1;
}
@@ -4008,7 +4008,7 @@ SPICE_GNUC_VISIBLE int spice_server_get_peer_info(SpiceServer *s, struct sockadd
SPICE_GNUC_VISIBLE int spice_server_add_renderer(SpiceServer *s, const char *name)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
if (!red_dispatcher_add_renderer(name)) {
return -1;
}
@@ -4024,7 +4024,7 @@ SPICE_GNUC_VISIBLE int spice_server_kbd_leds(SpiceKbdInstance *sin, int leds)
SPICE_GNUC_VISIBLE int spice_server_set_streaming_video(SpiceServer *s, int value)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
if (value != SPICE_STREAM_VIDEO_OFF &&
value != SPICE_STREAM_VIDEO_ALL &&
value != SPICE_STREAM_VIDEO_FILTER)
@@ -4036,14 +4036,14 @@ SPICE_GNUC_VISIBLE int spice_server_set_streaming_video(SpiceServer *s, int valu
SPICE_GNUC_VISIBLE int spice_server_set_playback_compression(SpiceServer *s, int enable)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
snd_set_playback_compression(enable);
return 0;
}
SPICE_GNUC_VISIBLE int spice_server_set_agent_mouse(SpiceServer *s, int enable)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
agent_mouse = enable;
reds_update_mouse_mode();
return 0;
@@ -4051,7 +4051,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_agent_mouse(SpiceServer *s, int enable)
SPICE_GNUC_VISIBLE int spice_server_set_agent_copypaste(SpiceServer *s, int enable)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
agent_copypaste = enable;
reds->agent_state.write_filter.copy_paste_enabled = agent_copypaste;
reds->agent_state.read_filter.copy_paste_enabled = agent_copypaste;
@@ -4090,12 +4090,12 @@ SPICE_GNUC_VISIBLE int spice_server_migrate_connect(SpiceServer *s, const char*
{
SpiceMigrateInterface *sif;
- red_printf("");
- ASSERT(migration_interface);
- ASSERT(reds == s);
+ spice_printerr("");
+ spice_assert(migration_interface);
+ spice_assert(reds == s);
if (reds->expect_migrate) {
- red_printf("warning: consecutive calls without migration. Canceling previous call");
+ spice_printerr("warning: consecutive calls without migration. Canceling previous call");
main_channel_migrate_complete(reds->main_channel, FALSE);
}
@@ -4114,7 +4114,7 @@ SPICE_GNUC_VISIBLE int spice_server_migrate_connect(SpiceServer *s, const char*
} else {
if (reds->num_clients == 0) {
reds_mig_release();
- red_printf("no client connected");
+ spice_printerr("no client connected");
}
sif->migrate_connect_complete(migration_interface);
}
@@ -4126,9 +4126,9 @@ SPICE_GNUC_VISIBLE int spice_server_migrate_info(SpiceServer *s, const char* des
int port, int secure_port,
const char* cert_subject)
{
- red_printf("");
- ASSERT(!migration_interface);
- ASSERT(reds == s);
+ spice_printerr("");
+ spice_assert(!migration_interface);
+ spice_assert(reds == s);
if (!reds_set_migration_dest_info(dest, port, secure_port, cert_subject)) {
return -1;
@@ -4138,8 +4138,8 @@ SPICE_GNUC_VISIBLE int spice_server_migrate_info(SpiceServer *s, const char* des
SPICE_GNUC_VISIBLE int spice_server_migrate_start(SpiceServer *s)
{
- ASSERT(reds == s);
- red_printf("");
+ spice_assert(reds == s);
+ spice_printerr("");
if (!reds->mig_spice) {
return -1;
}
@@ -4148,7 +4148,7 @@ SPICE_GNUC_VISIBLE int spice_server_migrate_start(SpiceServer *s)
SPICE_GNUC_VISIBLE int spice_server_migrate_client_state(SpiceServer *s)
{
- ASSERT(reds == s);
+ spice_assert(reds == s);
if (!reds_main_channel_connected()) {
return SPICE_MIGRATE_CLIENT_NONE;
@@ -4165,14 +4165,14 @@ SPICE_GNUC_VISIBLE int spice_server_migrate_end(SpiceServer *s, int completed)
SpiceMigrateInterface *sif;
int ret = 0;
- red_printf("");
+ spice_printerr("");
- ASSERT(migration_interface);
- ASSERT(reds == s);
+ spice_assert(migration_interface);
+ spice_assert(reds == s);
sif = SPICE_CONTAINEROF(migration_interface->base.sif, SpiceMigrateInterface, base);
if (!reds->expect_migrate && reds->num_clients) {
- red_printf("spice_server_migrate_info was not called, disconnecting clients");
+ spice_printerr("spice_server_migrate_info was not called, disconnecting clients");
reds_disconnect();
ret = -1;
goto complete;
@@ -4191,8 +4191,8 @@ complete:
/* interface for switch-host migration */
SPICE_GNUC_VISIBLE int spice_server_migrate_switch(SpiceServer *s)
{
- ASSERT(reds == s);
- red_printf("");
+ spice_assert(reds == s);
+ spice_printerr("");
if (!reds->num_clients) {
return 0;
}
@@ -4276,7 +4276,7 @@ void reds_stream_free(RedsStream *s)
}
reds_stream_remove_watch(s);
- red_printf("close socket fd %d", s->socket);
+ spice_printerr("close socket fd %d", s->socket);
close(s->socket);
free(s);
diff --git a/server/smartcard.c b/server/smartcard.c
index d023331..894053e 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -101,7 +101,7 @@ void smartcard_char_device_wakeup(SpiceCharDeviceInstance *sin)
if (actual_length > state->buf_size) {
state->buf_size = MAX(state->buf_size*2, actual_length + sizeof(VSCMsgHeader));
state->buf = spice_realloc(state->buf, state->buf_size);
- ASSERT(state->buf != NULL);
+ spice_assert(state->buf != NULL);
}
if (state->buf_used - sizeof(VSCMsgHeader) < actual_length) {
continue;
@@ -135,7 +135,7 @@ void smartcard_char_device_on_message_from_device(
}
/* We pass any VSC_Error right now - might need to ignore some? */
if (state->reader_id == VSCARD_UNDEFINED_READER_ID && vheader->type != VSC_Init) {
- red_printf("error: reader_id not assigned for message of type %d", vheader->type);
+ spice_printerr("error: reader_id not assigned for message of type %d", vheader->type);
}
if (state->rcc) {
sent_header = spice_memdup(vheader, sizeof(*vheader) + vheader->length);
@@ -176,7 +176,7 @@ static int smartcard_char_device_add_to_readers(SpiceCharDeviceInstance *char_de
static SpiceCharDeviceInstance *smartcard_readers_get(uint32_t reader_id)
{
- ASSERT(reader_id < g_smartcard_readers.num);
+ spice_assert(reader_id < g_smartcard_readers.num);
return g_smartcard_readers.sin[reader_id];
}
@@ -284,15 +284,15 @@ static void smartcard_channel_release_msg_rcv_buf(RedChannelClient *rcc,
uint32_t size,
uint8_t *msg)
{
- red_printf("freeing %d bytes", size);
+ spice_printerr("freeing %d bytes", size);
free(msg);
}
static void smartcard_channel_send_data(RedChannelClient *rcc, SpiceMarshaller *m,
PipeItem *item, VSCMsgHeader *vheader)
{
- ASSERT(rcc);
- ASSERT(vheader);
+ spice_assert(rcc);
+ spice_assert(vheader);
red_channel_client_init_send_data(rcc, SPICE_MSG_SMARTCARD_DATA, item);
spice_marshaller_add_ref(m, (uint8_t*)vheader, sizeof(VSCMsgHeader));
if (vheader->length > 0) {
@@ -428,7 +428,7 @@ static void smartcard_channel_write_to_reader(VSCMsgHeader *vheader)
uint32_t n;
uint32_t actual_length = vheader->length;
- ASSERT(vheader->reader_id >= 0 &&
+ spice_assert(vheader->reader_id >= 0 &&
vheader->reader_id <= g_smartcard_readers.num);
sin = g_smartcard_readers.sin[vheader->reader_id];
sif = SPICE_CONTAINEROF(sin->base.sif, SpiceCharDeviceInterface, base);
@@ -439,7 +439,7 @@ static void smartcard_channel_write_to_reader(VSCMsgHeader *vheader)
n = sif->write(sin, (uint8_t*)vheader,
actual_length + sizeof(VSCMsgHeader));
// TODO - add ring
- ASSERT(n == actual_length + sizeof(VSCMsgHeader));
+ spice_assert(n == actual_length + sizeof(VSCMsgHeader));
}
static int smartcard_channel_handle_message(RedChannelClient *rcc,
@@ -454,7 +454,7 @@ static int smartcard_channel_handle_message(RedChannelClient *rcc,
return red_channel_client_handle_message(rcc, size, type, msg);
}
- ASSERT(size == vheader->length + sizeof(VSCMsgHeader));
+ spice_assert(size == vheader->length + sizeof(VSCMsgHeader));
switch (vheader->type) {
case VSC_ReaderAdd:
smartcard_add_reader(rcc, msg + sizeof(VSCMsgHeader));
@@ -479,7 +479,7 @@ static int smartcard_channel_handle_message(RedChannelClient *rcc,
}
if (vheader->reader_id >= g_smartcard_readers.num) {
- red_printf("ERROR: received message for non existent reader: %d, %d, %d", vheader->reader_id,
+ spice_printerr("ERROR: received message for non existent reader: %d, %d, %d", vheader->reader_id,
vheader->type, vheader->length);
return FALSE;
}
@@ -515,7 +515,7 @@ static void smartcard_init(void)
ChannelCbs channel_cbs = { NULL, };
ClientCbs client_cbs = { NULL, };
- ASSERT(!g_smartcard_channel);
+ spice_assert(!g_smartcard_channel);
channel_cbs.config_socket = smartcard_channel_client_config_socket;
channel_cbs.on_disconnect = smartcard_channel_on_disconnect;
@@ -533,7 +533,7 @@ static void smartcard_init(void)
&channel_cbs);
if (!g_smartcard_channel) {
- red_error("failed to allocate Inputs Channel");
+ spice_error("failed to allocate Inputs Channel");
}
client_cbs.connect = smartcard_connect;
diff --git a/server/snd_worker.c b/server/snd_worker.c
index be98094..7bdd399 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -208,7 +208,7 @@ static SndChannel *snd_channel_put(SndChannel *channel)
if (!--channel->refs) {
channel->worker->connection = NULL;
free(channel);
- red_printf("sound channel freed");
+ spice_printerr("sound channel freed");
return NULL;
}
return channel;
@@ -295,7 +295,7 @@ static int snd_send_data(SndChannel *channel)
snd_disconnect_channel(channel);
return FALSE;
default:
- red_printf("%s", strerror(errno));
+ spice_printerr("%s", strerror(errno));
snd_disconnect_channel(channel);
return FALSE;
}
@@ -326,7 +326,7 @@ static int snd_record_handle_write(RecordChannel *record_channel, size_t size, v
int celt_err = celt051_decode(record_channel->celt_decoder, packet->data, size,
(celt_int16_t *)record_channel->celt_buf);
if (celt_err != CELT_OK) {
- red_printf("celt decode failed (%d)", celt_err);
+ spice_printerr("celt decode failed (%d)", celt_err);
return FALSE;
}
data = record_channel->celt_buf;
@@ -366,7 +366,7 @@ static int snd_playback_handle_message(SndChannel *channel, size_t size, uint32_
case SPICE_MSGC_DISCONNECTING:
break;
default:
- red_printf("invalid message type %u", type);
+ spice_printerr("invalid message type %u", type);
return FALSE;
}
return TRUE;
@@ -388,7 +388,7 @@ static int snd_record_handle_message(SndChannel *channel, size_t size, uint32_t
record_channel->mode_time = mode->time;
if (record_channel->mode != SPICE_AUDIO_DATA_MODE_CELT_0_5_1 &&
record_channel->mode != SPICE_AUDIO_DATA_MODE_RAW) {
- red_printf("unsupported mode");
+ spice_printerr("unsupported mode");
}
break;
}
@@ -402,7 +402,7 @@ static int snd_record_handle_message(SndChannel *channel, size_t size, uint32_t
case SPICE_MSGC_MIGRATE_DATA: {
RecordMigrateData* mig_data = (RecordMigrateData *)message;
if (mig_data->version != RECORD_MIG_VERSION) {
- red_printf("invalid mig version");
+ spice_printerr("invalid mig version");
break;
}
record_channel->mode = mig_data->mode;
@@ -411,7 +411,7 @@ static int snd_record_handle_message(SndChannel *channel, size_t size, uint32_t
break;
}
default:
- red_printf("invalid message type %u", type);
+ spice_printerr("invalid message type %u", type);
return FALSE;
}
return TRUE;
@@ -431,14 +431,14 @@ static void snd_receive(void* data)
for (;;) {
ssize_t n;
n = channel->recive_data.end - channel->recive_data.now;
- ASSERT(n);
+ spice_assert(n);
n = reds_stream_read(channel->stream, channel->recive_data.now, n);
if (n <= 0) {
if (n == 0) {
snd_disconnect_channel(channel);
return;
}
- ASSERT(n == -1);
+ spice_assert(n == -1);
switch (errno) {
case EAGAIN:
return;
@@ -448,7 +448,7 @@ static void snd_receive(void* data)
snd_disconnect_channel(channel);
return;
default:
- red_printf("%s", strerror(errno));
+ spice_printerr("%s", strerror(errno));
snd_disconnect_channel(channel);
return;
}
@@ -472,7 +472,7 @@ static void snd_receive(void* data)
header->get_msg_type(header),
SPICE_VERSION_MINOR, &parsed_size, &parsed_free);
if (parsed == NULL) {
- red_printf("failed to parse message type %d", header->get_msg_type(header));
+ spice_printerr("failed to parse message type %d", header->get_msg_type(header));
snd_disconnect_channel(channel);
return;
}
@@ -629,7 +629,7 @@ static int snd_playback_send_start(PlaybackChannel *playback_channel)
start.channels = SPICE_INTERFACE_PLAYBACK_CHAN;
start.frequency = SPICE_INTERFACE_PLAYBACK_FREQ;
- ASSERT(SPICE_INTERFACE_PLAYBACK_FMT == SPICE_INTERFACE_AUDIO_FMT_S16);
+ spice_assert(SPICE_INTERFACE_PLAYBACK_FMT == SPICE_INTERFACE_AUDIO_FMT_S16);
start.format = SPICE_AUDIO_FMT_S16;
start.time = reds_get_mm_time();
spice_marshall_msg_playback_start(channel->send_data.marshaller, &start);
@@ -670,7 +670,7 @@ static int snd_record_send_start(RecordChannel *record_channel)
start.channels = SPICE_INTERFACE_RECORD_CHAN;
start.frequency = SPICE_INTERFACE_RECORD_FREQ;
- ASSERT(SPICE_INTERFACE_RECORD_FMT == SPICE_INTERFACE_AUDIO_FMT_S16);
+ spice_assert(SPICE_INTERFACE_RECORD_FMT == SPICE_INTERFACE_AUDIO_FMT_S16);
start.format = SPICE_AUDIO_FMT_S16;
spice_marshall_msg_record_start(channel->send_data.marshaller, &start);
@@ -783,7 +783,7 @@ static int snd_playback_send_write(PlaybackChannel *playback_channel)
int n = celt051_encode(playback_channel->celt_encoder, (celt_int16_t *)frame->samples, NULL,
playback_channel->send_data.celt_buf, CELT_COMPRESSED_FRAME_BYTES);
if (n < 0) {
- red_printf("celt encode failed");
+ spice_printerr("celt encode failed");
snd_disconnect_channel(channel);
return FALSE;
}
@@ -829,12 +829,12 @@ static void snd_playback_send(void* data)
channel->command &= ~SND_PLAYBACK_MODE_MASK;
}
if (channel->command & SND_PLAYBACK_PCM_MASK) {
- ASSERT(!playback_channel->in_progress && playback_channel->pending_frame);
+ spice_assert(!playback_channel->in_progress && playback_channel->pending_frame);
playback_channel->in_progress = playback_channel->pending_frame;
playback_channel->pending_frame = NULL;
channel->command &= ~SND_PLAYBACK_PCM_MASK;
if (!snd_playback_send_write(playback_channel)) {
- red_printf("snd_send_playback_write failed");
+ spice_printerr("snd_send_playback_write failed");
return;
}
}
@@ -913,7 +913,7 @@ static SndChannel *__new_channel(SndWorker *worker, int size, uint32_t channel_i
MainChannelClient *mcc = red_client_get_main(client);
if ((flags = fcntl(stream->socket, F_GETFL)) == -1) {
- red_printf("accept failed, %s", strerror(errno));
+ spice_printerr("accept failed, %s", strerror(errno));
goto error1;
}
@@ -922,7 +922,7 @@ static SndChannel *__new_channel(SndWorker *worker, int size, uint32_t channel_i
if (setsockopt(stream->socket, SOL_SOCKET, SO_PRIORITY, (void*)&priority,
sizeof(priority)) == -1) {
if (errno != ENOTSUP) {
- red_printf("setsockopt failed, %s", strerror(errno));
+ spice_printerr("setsockopt failed, %s", strerror(errno));
}
}
#endif
@@ -930,23 +930,23 @@ static SndChannel *__new_channel(SndWorker *worker, int size, uint32_t channel_i
tos = IPTOS_LOWDELAY;
if (setsockopt(stream->socket, IPPROTO_IP, IP_TOS, (void*)&tos, sizeof(tos)) == -1) {
if (errno != ENOTSUP) {
- red_printf("setsockopt failed, %s", strerror(errno));
+ spice_printerr("setsockopt failed, %s", strerror(errno));
}
}
delay_val = main_channel_client_is_low_bandwidth(mcc) ? 0 : 1;
if (setsockopt(stream->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val, sizeof(delay_val)) == -1) {
if (errno != ENOTSUP) {
- red_printf("setsockopt failed, %s", strerror(errno));
+ spice_printerr("setsockopt failed, %s", strerror(errno));
}
}
if (fcntl(stream->socket, F_SETFL, flags | O_NONBLOCK) == -1) {
- red_printf("accept failed, %s", strerror(errno));
+ spice_printerr("accept failed, %s", strerror(errno));
goto error1;
}
- ASSERT(size >= sizeof(*channel));
+ spice_assert(size >= sizeof(*channel));
channel = spice_malloc0(size);
channel->refs = 1;
channel->parser = spice_get_client_channel_parser(channel_id, NULL);
@@ -960,7 +960,7 @@ static SndChannel *__new_channel(SndWorker *worker, int size, uint32_t channel_i
stream->watch = core->watch_add(stream->socket, SPICE_WATCH_EVENT_READ,
snd_event, channel);
if (stream->watch == NULL) {
- red_printf("watch_add failed, %s", strerror(errno));
+ spice_printerr("watch_add failed, %s", strerror(errno));
goto error2;
}
@@ -989,13 +989,13 @@ static void snd_disconnect_channel_client(RedChannelClient *rcc)
{
SndWorker *worker;
- ASSERT(rcc->channel);
- ASSERT(rcc->channel->data);
+ spice_assert(rcc->channel);
+ spice_assert(rcc->channel->data);
worker = (SndWorker *)rcc->channel->data;
- ASSERT(worker->connection->channel_client == rcc);
+ spice_assert(worker->connection->channel_client == rcc);
snd_disconnect_channel(worker->connection);
- ASSERT(worker->connection == NULL);
+ spice_assert(worker->connection == NULL);
}
static void snd_set_command(SndChannel *channel, uint32_t command)
@@ -1046,7 +1046,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_start(SpicePlaybackInstance *sin)
sin->st->worker.active = 1;
if (!channel)
return;
- ASSERT(!playback_channel->base.active);
+ spice_assert(!playback_channel->base.active);
reds_disable_mm_timer();
playback_channel->base.active = TRUE;
if (!playback_channel->base.client_active) {
@@ -1065,7 +1065,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_stop(SpicePlaybackInstance *sin)
sin->st->worker.active = 0;
if (!channel)
return;
- ASSERT(playback_channel->base.active);
+ spice_assert(playback_channel->base.active);
reds_enable_mm_timer();
playback_channel->base.active = FALSE;
if (playback_channel->base.client_active) {
@@ -1076,7 +1076,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_stop(SpicePlaybackInstance *sin)
playback_channel->base.command &= ~SND_PLAYBACK_PCM_MASK;
if (playback_channel->pending_frame) {
- ASSERT(!playback_channel->in_progress);
+ spice_assert(!playback_channel->in_progress);
snd_playback_free_frame(playback_channel,
playback_channel->pending_frame);
playback_channel->pending_frame = NULL;
@@ -1095,7 +1095,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_get_buffer(SpicePlaybackInstance *
*num_samples = 0;
return;
}
- ASSERT(playback_channel->base.active);
+ spice_assert(playback_channel->base.active);
snd_channel_get(channel);
*frame = playback_channel->free_frames->samples;
@@ -1116,7 +1116,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_put_samples(SpicePlaybackInstance
/* lost last reference, channel has been destroyed previously */
return;
}
- ASSERT(playback_channel->base.active);
+ spice_assert(playback_channel->base.active);
if (playback_channel->pending_frame) {
snd_playback_free_frame(playback_channel, playback_channel->pending_frame);
@@ -1134,7 +1134,7 @@ static void on_new_playback_channel(SndWorker *worker)
PlaybackChannel *playback_channel =
SPICE_CONTAINEROF(worker->connection, PlaybackChannel, base);
- ASSERT(playback_channel);
+ spice_assert(playback_channel);
snd_set_command((SndChannel *)playback_channel, SND_PLAYBACK_MODE_MASK);
if (!playback_channel->base.migrate && playback_channel->base.active) {
@@ -1175,12 +1175,12 @@ static void snd_set_playback_peer(RedChannel *channel, RedClient *client, RedsSt
if (!(celt_mode = celt051_mode_create(SPICE_INTERFACE_PLAYBACK_FREQ,
SPICE_INTERFACE_PLAYBACK_CHAN,
FRAME_SIZE, &celt_error))) {
- red_printf("create celt mode failed %d", celt_error);
+ spice_printerr("create celt mode failed %d", celt_error);
return;
}
if (!(celt_encoder = celt051_encoder_create(celt_mode))) {
- red_printf("create celt encoder failed");
+ spice_printerr("create celt encoder failed");
goto error_1;
}
@@ -1228,12 +1228,12 @@ static void snd_record_migrate_channel_client(RedChannelClient *rcc)
{
SndWorker *worker;
- ASSERT(rcc->channel);
- ASSERT(rcc->channel->data);
+ spice_assert(rcc->channel);
+ spice_assert(rcc->channel->data);
worker = (SndWorker *)rcc->channel->data;
if (worker->connection) {
- ASSERT(worker->connection->channel_client == rcc);
+ spice_assert(worker->connection->channel_client == rcc);
snd_set_command(worker->connection, SND_RECORD_MIGRATE_MASK);
snd_record_send(worker->connection);
}
@@ -1279,7 +1279,7 @@ SPICE_GNUC_VISIBLE void spice_server_record_start(SpiceRecordInstance *sin)
sin->st->worker.active = 1;
if (!channel)
return;
- ASSERT(!record_channel->base.active);
+ spice_assert(!record_channel->base.active);
record_channel->base.active = TRUE;
record_channel->read_pos = record_channel->write_pos = 0; //todo: improve by
//stream generation
@@ -1299,7 +1299,7 @@ SPICE_GNUC_VISIBLE void spice_server_record_stop(SpiceRecordInstance *sin)
sin->st->worker.active = 0;
if (!channel)
return;
- ASSERT(record_channel->base.active);
+ spice_assert(record_channel->base.active);
record_channel->base.active = FALSE;
if (record_channel->base.client_active) {
snd_set_command(&record_channel->base, SND_RECORD_CTRL_MASK);
@@ -1320,7 +1320,7 @@ SPICE_GNUC_VISIBLE uint32_t spice_server_record_get_samples(SpiceRecordInstance
if (!channel)
return 0;
- ASSERT(record_channel->base.active);
+ spice_assert(record_channel->base.active);
if (record_channel->write_pos < RECORD_SAMPLES_SIZE / 2) {
return 0;
@@ -1350,7 +1350,7 @@ SPICE_GNUC_VISIBLE uint32_t spice_server_record_get_samples(SpiceRecordInstance
static void on_new_record_channel(SndWorker *worker)
{
RecordChannel *record_channel = (RecordChannel *)worker->connection;
- ASSERT(record_channel);
+ spice_assert(record_channel);
snd_set_command((SndChannel *)record_channel, SND_RECORD_VOLUME_MASK);
if (!record_channel->base.migrate) {
@@ -1384,12 +1384,12 @@ static void snd_set_record_peer(RedChannel *channel, RedClient *client, RedsStre
if (!(celt_mode = celt051_mode_create(SPICE_INTERFACE_RECORD_FREQ,
SPICE_INTERFACE_RECORD_CHAN,
FRAME_SIZE, &celt_error))) {
- red_printf("create celt mode failed %d", celt_error);
+ spice_printerr("create celt mode failed %d", celt_error);
return;
}
if (!(celt_decoder = celt051_decoder_create(celt_mode))) {
- red_printf("create celt decoder failed");
+ spice_printerr("create celt decoder failed");
goto error_1;
}
@@ -1431,12 +1431,12 @@ static void snd_playback_migrate_channel_client(RedChannelClient *rcc)
{
SndWorker *worker;
- ASSERT(rcc->channel);
- ASSERT(rcc->channel->data);
+ spice_assert(rcc->channel);
+ spice_assert(rcc->channel->data);
worker = (SndWorker *)rcc->channel->data;
if (worker->connection) {
- ASSERT(worker->connection->channel_client == rcc);
+ spice_assert(worker->connection->channel_client == rcc);
snd_set_command(worker->connection, SND_PLAYBACK_MIGRATE_MASK);
snd_playback_send(worker->connection);
}
@@ -1458,7 +1458,7 @@ static void remove_worker(SndWorker *worker)
}
now = &(*now)->next;
}
- red_printf("not found");
+ spice_printerr("not found");
}
void snd_attach_playback(SpicePlaybackInstance *sin)
@@ -1561,7 +1561,7 @@ void snd_set_playback_compression(int on)
PlaybackChannel* playback = (PlaybackChannel*)now->connection;
if (!red_channel_client_test_remote_cap(sndchannel->channel_client,
SPICE_PLAYBACK_CAP_CELT_0_5_1)) {
- ASSERT(playback->mode == SPICE_AUDIO_DATA_MODE_RAW);
+ spice_assert(playback->mode == SPICE_AUDIO_DATA_MODE_RAW);
continue;
}
if (playback->mode != playback_compression) {
diff --git a/server/spicevmc.c b/server/spicevmc.c
index 18ae627..27123d4 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -93,7 +93,7 @@ static int spicevmc_red_channel_client_config_socket(RedChannelClient *rcc)
if (setsockopt(stream->socket, IPPROTO_TCP, TCP_NODELAY,
&delay_val, sizeof(delay_val)) != 0) {
if (errno != ENOTSUP && errno != ENOPROTOOPT) {
- red_printf("setsockopt failed, %s", strerror(errno));
+ spice_printerr("setsockopt failed, %s", strerror(errno));
return FALSE;
}
}
@@ -223,8 +223,8 @@ static void spicevmc_connect(RedChannel *channel, RedClient *client,
sif = SPICE_CONTAINEROF(sin->base.sif, SpiceCharDeviceInterface, base);
if (state->rcc) {
- WARN("channel client %d:%d (%p) already connected, refusing second connection\n",
- channel->type, channel->id, state->rcc);
+ spice_printerr("channel client %d:%d (%p) already connected, refusing second connection",
+ channel->type, channel->id, state->rcc);
// TODO: notify client in advance about the in use channel using
// SPICE_MSG_MAIN_CHANNEL_IN_USE (for example)
reds_stream_free(stream);
diff --git a/server/zlib_encoder.c b/server/zlib_encoder.c
index c51466b..a3d2aa6 100644
--- a/server/zlib_encoder.c
+++ b/server/zlib_encoder.c
@@ -50,7 +50,7 @@ ZlibEncoder* zlib_encoder_create(ZlibEncoderUsrContext *usr, int level)
z_ret = deflateInit(&enc->strm, level);
enc->last_level = level;
if (z_ret != Z_OK) {
- red_printf("zlib error");
+ spice_printerr("zlib error");
free(enc);
return NULL;
}
@@ -76,7 +76,7 @@ int zlib_encode(ZlibEncoder *zlib, int level, int input_size,
z_ret = deflateReset(&zlib->strm);
if (z_ret != Z_OK) {
- red_error("deflateReset failed");
+ spice_error("deflateReset failed");
}
zlib->strm.next_out = io_ptr;
@@ -86,12 +86,12 @@ int zlib_encode(ZlibEncoder *zlib, int level, int input_size,
if (zlib->strm.avail_out == 0) {
zlib->strm.avail_out = zlib->usr->more_space(zlib->usr, &zlib->strm.next_out);
if (zlib->strm.avail_out == 0) {
- red_error("not enough space");
+ spice_error("not enough space");
}
}
z_ret = deflateParams(&zlib->strm, level, Z_DEFAULT_STRATEGY);
if (z_ret != Z_OK) {
- red_error("deflateParams failed");
+ spice_error("deflateParams failed");
}
zlib->last_level = level;
}
@@ -100,14 +100,14 @@ int zlib_encode(ZlibEncoder *zlib, int level, int input_size,
do {
zlib->strm.avail_in = zlib->usr->more_input(zlib->usr, &zlib->strm.next_in);
if (zlib->strm.avail_in <= 0) {
- red_error("more input failed\n");
+ spice_error("more input failed");
}
enc_size += zlib->strm.avail_in;
flush = (enc_size == input_size) ? Z_FINISH : Z_NO_FLUSH;
while (1) {
int deflate_size = zlib->strm.avail_out;
z_ret = deflate(&zlib->strm, flush);
- ASSERT(z_ret != Z_STREAM_ERROR);
+ spice_assert(z_ret != Z_STREAM_ERROR);
out_size += deflate_size - zlib->strm.avail_out;
if (zlib->strm.avail_out) {
break;
@@ -115,11 +115,11 @@ int zlib_encode(ZlibEncoder *zlib, int level, int input_size,
zlib->strm.avail_out = zlib->usr->more_space(zlib->usr, &zlib->strm.next_out);
if (zlib->strm.avail_out == 0) {
- red_error("not enough space");
+ spice_error("not enough space");
}
}
} while (flush != Z_FINISH);
- ASSERT(z_ret == Z_STREAM_END);
+ spice_assert(z_ret == Z_STREAM_END);
return out_size;
}