[Spice-devel] Windows XP reboot hung up after several times reboot

Coolper Chen lxchen at tnsoft.com.cn
Tue Nov 2 02:18:02 PDT 2010


I got the cause,see the following,
welcome comments.

static int read_from_vdi_port(void)
{
    /* There are 2 scenarios where we can get called recursively:
       1) spice-vmc vmc_read triggering flush of throttled data,
recalling us
       2) the buf we push to the client may be send immediately without
          blocking, in which case its free function will recall us
       This messes up the state machine, so ignore recursive calls.
       This is why we always must be called in a loop. */
    static int inside_call = 0;
    int quit_loop = 0;
    VDIPortState *state = &reds->agent_state;
    SpiceCharDeviceInterface *sif;
    VDIReadBuf *dispatch_buf;
    int total = 0;
    int n;
    if (inside_call) {
        return 0;
    }
    inside_call = 1;

    sif = SPICE_CONTAINEROF(vdagent->base.sif, SpiceCharDeviceInterface,
base);
    if (!reds->agent_state.connected || reds->mig_target) {
        inside_call = 0;
        //root cause is here,it should call read function to consume the
spice_vmc data,if not,"virtio_serial_throttle_port(&svc->port, false);"
will not execute,so spice_vmc will block something
       //the following 2 lines code is ugly,but it resolved the issue.
        uint8_t a[2048];
        sif->read(vdagent, a, 2048);
        return 0;
    }

    while (!quit_loop && reds->agent_state.connected) {
        switch (state->read_state) {
        case VDI_PORT_READ_STATE_READ_HADER:
            n = sif->read(vdagent, state->recive_pos,
state->recive_len);
            if (!n) {
                quit_loop = 1;
                break;
            }
            total += n;
            if ((state->recive_len -= n)) {
                state->recive_pos += n;
                quit_loop = 1;
                break;
            }
            state->message_recive_len = state->vdi_chunk_header.size;
            state->read_state = VDI_PORT_READ_STATE_GET_BUFF;
        case VDI_PORT_READ_STATE_GET_BUFF: {
            RingItem *item;

            if (!(item = ring_get_head(&state->read_bufs))) {
                quit_loop = 1;
                break;
            }

            ring_remove(item);
            state->current_read_buf = (VDIReadBuf *)item;
            state->recive_pos = state->current_read_buf->data;
            state->recive_len = MIN(state->message_recive_len,

sizeof(state->current_read_buf->data));
            state->current_read_buf->len = state->recive_len;
            state->message_recive_len -= state->recive_len;
            state->read_state = VDI_PORT_READ_STATE_READ_DATA;
        }
        case VDI_PORT_READ_STATE_READ_DATA:
            n = sif->read(vdagent, state->recive_pos,
state->recive_len);
            if (!n) {
                quit_loop = 1;
                break;
            }
            total += n;
            if ((state->recive_len -= n)) {
                state->recive_pos += n;
                break;
            }
            dispatch_buf = state->current_read_buf;
            state->current_read_buf = NULL;
            state->recive_pos = NULL;
            if (state->message_recive_len == 0) {
                state->read_state = VDI_PORT_READ_STATE_READ_HADER;
                state->recive_pos = (uint8_t *)&state->vdi_chunk_header;
                state->recive_len = sizeof(state->vdi_chunk_header);
            } else {
                state->read_state = VDI_PORT_READ_STATE_GET_BUFF;
            }
            dispatch_vdi_port_data(state->vdi_chunk_header.port,
dispatch_buf);
        }
    }
    inside_call = 0;
    return total;
}

On Tue, 2010-11-02 at 16:03 +0800, Alon Levy wrote:

> On Tue, Nov 02, 2010 at 12:48:22PM +0800, Coolper Chen wrote:
> > If spice client keeps connecting Windows XP(vdservice running on
> > it),reboot XP remotely or locally,it's ok.
> > when XP hung-up,use spice client connecting to XP,XP will continue
> > reboot.
> 
> Nice workaround. We need to fix this bug.
> 
> > 
> > On Mon, 2010-11-01 at 17:47 +0800, Coolper Chen wrote:
> > > If no vdservice,there's no this issue.
> > > 
> > > On Mon, 2010-11-01 at 17:26 +0800, Arnon Gilboa wrote:
> > > > Please uninstall vdservice & vioser driver, try to reproduce it without 
> > > > them, and update us with the results.
> > > > Thanks,
> > > > Arnon
> > > > 
> > > > Coolper Chen wrote:
> > > > > hi,
> > > > > I'm testing spice.I found an issue about vd_agent,when there's no spice
> > > > > client connected to the Windows XP guest,I can't remotely reboot Windows
> > > > > XP more than 3 times,in the third time,the Windows XP guest will hung up
> > > > > in shutting down process,then wait a long time,there's no change(I have
> > > > > a monitor in guest,I can know when the guest OS is ready).If I use
> > > > > spicec to connect windows xp,I see windows xp shut down and then start.
> > > > >
> > > > > I compare the normal process of spicec connecting guest with it,I found
> > > > > vd_agent sends some messages(VD_AGENT_ANNOUNCE_CAPABILITIES, 3 messages)
> > > > > to spice client when Windows XP restart 3 times.
> > > > >
> > > > > What causes Windows XP not reboot?
> > > > >
> > > > > I'm using spice 0.6.3 and Windows XP.
> > > > >
> > > > > Coolper
> > > > >
> > > > > _______________________________________________
> > > > > Spice-devel mailing list
> > > > > Spice-devel at lists.freedesktop.org
> > > > > http://lists.freedesktop.org/mailman/listinfo/spice-devel
> > > > >   
> > > > 
> > > 
> > > 
> > > _______________________________________________
> > > Spice-devel mailing list
> > > Spice-devel at lists.freedesktop.org
> > > http://lists.freedesktop.org/mailman/listinfo/spice-devel
> > 
> > 
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/spice-devel


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20101102/0ac1ecc8/attachment.html>


More information about the Spice-devel mailing list