[Spice-devel] [PATCH] spice-vmc: split vmc_write to max sized virtio_serial_write calls
Arnon Gilboa
agilboa at redhat.com
Wed Jul 21 23:18:29 PDT 2010
Alon Levy wrote:
> This is required for working agent in windows guests with up coming release. Prevents pretty blue screens. Please Ack.
>
> workaround for current windows driver limitation (RHBZ 617000)
> ---
> hw/spice-vmc.c | 21 ++++++++++++++++++---
> 1 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/hw/spice-vmc.c b/hw/spice-vmc.c
> index 8e14446..bf0c06e 100644
> --- a/hw/spice-vmc.c
> +++ b/hw/spice-vmc.c
> @@ -21,6 +21,8 @@
> #define VMC_GUEST_DEVICE_NAME "com.redhat.spice.0"
> #define VMC_DEVICE_NAME "spicevmc"
>
> +#define VMC_MAX_HOST_WRITE 2048
> +
> #define dprintf(_svc, _level, _fmt, ...) \
> do { \
> static unsigned __dprintf_counter = 0; \
> @@ -43,10 +45,23 @@ typedef struct SpiceVirtualChannel {
> static int vmc_write(SpiceVDIPortInstance *sin, const uint8_t *buf, int len)
> {
> SpiceVirtualChannel *svc = container_of(sin, SpiceVirtualChannel, sin);
> - ssize_t out;
> + ssize_t out = 0;
> + ssize_t last_out;
> + uint8_t* p = (uint8_t*)buf;
> +
> + while (len > 0) {
> + last_out = virtio_serial_write(&svc->port, p,
> + MIN(len, VMC_MAX_HOST_WRITE));
> + if (last_out > 0) {
> + out += last_out;
> + len -= last_out;
> + p += last_out;
> + } else {
> + break;
> + }
> + }
>
> - out = virtio_serial_write(&svc->port, buf, len);
> - dprintf(svc, 3, "%s: %lu/%d\n", __func__, out, len);
> + dprintf(svc, 3, "%s: %lu/%zd\n", __func__, out, len + out);
> return out;
> }
>
>
ACK
More information about the Spice-devel
mailing list