Use the spice-common logging functions

It will abort by default for critical level messages. That behaviour
can be tuned at runtime.
This commit is contained in:
Marc-André Lureau 2012-03-14 19:34:35 +01:00
parent 359fc1cb5d
commit b34fd7432d
21 changed files with 907 additions and 908 deletions

1
.gitignore vendored
View File

@ -23,3 +23,4 @@ Makefile
Makefile.in
spice-server.pc
stamp-h1
INSTALL

View File

@ -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;
}

View File

@ -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);

View File

@ -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");
}
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;
};
}

View File

@ -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);

File diff suppressed because it is too large Load Diff

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -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;

View File

@ -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) {

View File

@ -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);

View File

@ -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;
}