Revision 344bf1e9 spice-qemu-char.c
b/spice-qemu-char.c | ||
---|---|---|
8 | 8 |
|
9 | 9 |
#include "qemu/osdep.h" |
10 | 10 |
|
11 |
#define dprintf(_scd, _level, _fmt, ...) \ |
|
12 |
do { \ |
|
13 |
static unsigned __dprintf_counter = 0; \ |
|
14 |
if (_scd->debug >= _level) { \ |
|
15 |
fprintf(stderr, "scd: %3d: " _fmt, ++__dprintf_counter, ## __VA_ARGS__);\ |
|
16 |
} \ |
|
17 |
} while (0) |
|
18 |
|
|
19 | 11 |
typedef struct SpiceCharDriver { |
20 | 12 |
CharDriverState* chr; |
21 | 13 |
SpiceCharDeviceInstance sin; |
... | ... | |
24 | 16 |
uint8_t *buffer; |
25 | 17 |
uint8_t *datapos; |
26 | 18 |
ssize_t bufsize, datalen; |
27 |
uint32_t debug; |
|
28 | 19 |
QLIST_ENTRY(SpiceCharDriver) next; |
29 | 20 |
} SpiceCharDriver; |
30 | 21 |
|
... | ... | |
49 | 40 |
p += last_out; |
50 | 41 |
} |
51 | 42 |
|
52 |
dprintf(scd, 3, "%s: %zu/%zd\n", __func__, out, len + out); |
|
53 | 43 |
trace_spice_vmc_write(out, len + out); |
54 | 44 |
return out; |
55 | 45 |
} |
... | ... | |
59 | 49 |
SpiceCharDriver *scd = container_of(sin, SpiceCharDriver, sin); |
60 | 50 |
int bytes = MIN(len, scd->datalen); |
61 | 51 |
|
62 |
dprintf(scd, 2, "%s: %p %d/%d/%zd\n", __func__, scd->datapos, len, bytes, scd->datalen); |
|
63 | 52 |
if (bytes > 0) { |
64 | 53 |
memcpy(buf, scd->datapos, bytes); |
65 | 54 |
scd->datapos += bytes; |
... | ... | |
84 | 73 |
chr_event = CHR_EVENT_BREAK; |
85 | 74 |
break; |
86 | 75 |
default: |
87 |
dprintf(scd, 2, "%s: unknown %d\n", __func__, event); |
|
88 | 76 |
return; |
89 | 77 |
} |
90 | 78 |
|
91 |
dprintf(scd, 2, "%s: %d\n", __func__, event); |
|
92 | 79 |
trace_spice_vmc_event(chr_event); |
93 | 80 |
qemu_chr_be_event(scd->chr, chr_event); |
94 | 81 |
} |
... | ... | |
141 | 128 |
if (scd->active) { |
142 | 129 |
return; |
143 | 130 |
} |
144 |
dprintf(scd, 1, "%s\n", __func__); |
|
145 | 131 |
scd->sin.base.sif = &vmc_interface.base; |
146 | 132 |
qemu_spice_add_interface(&scd->sin.base); |
147 | 133 |
scd->active = true; |
... | ... | |
153 | 139 |
if (!scd->active) { |
154 | 140 |
return; |
155 | 141 |
} |
156 |
dprintf(scd, 1, "%s\n", __func__); |
|
157 | 142 |
spice_server_remove_interface(&scd->sin.base); |
158 | 143 |
scd->active = false; |
159 | 144 |
trace_spice_vmc_unregister_interface(scd); |
... | ... | |
164 | 149 |
{ |
165 | 150 |
SpiceCharDriver *s = chr->opaque; |
166 | 151 |
|
167 |
dprintf(s, 2, "%s: %d\n", __func__, len); |
|
168 | 152 |
vmc_register_interface(s); |
169 | 153 |
assert(s->datalen == 0); |
170 | 154 |
if (s->bufsize < len) { |
... | ... | |
182 | 166 |
{ |
183 | 167 |
SpiceCharDriver *s = chr->opaque; |
184 | 168 |
|
185 |
printf("%s\n", __func__); |
|
186 | 169 |
vmc_unregister_interface(s); |
187 | 170 |
QLIST_REMOVE(s, next); |
188 | 171 |
|
Also available in: Unified diff