[Spice-devel] [PATCH 9/9] chardev: learn to keep running when vm is stopped

Alon Levy alevy at redhat.com
Mon Nov 18 03:47:11 PST 2013


On 11/18/2013 12:28 PM, Marc-André Lureau wrote:
> All chardev channels are stopped when calling spice_server_vm_stop(),
> which prevents them from doing any i/o.
> 
> However, the Spice block device channel needs to keep running even when
> the VM is stopped. It is entirely drived by the server, so it is

s/drived/drivven/

> entirely to the server to deal with the channel running state (finish

s/to the/up to the/

> all outstanding operations or block io).

Looks good,
ACK series.

> ---
>  server/char_device.c | 11 ++++++++++-
>  server/char_device.h |  1 +
>  server/reds.c        |  1 +
>  3 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/server/char_device.c b/server/char_device.c
> index 0cd5106..7b4c3f8 100644
> --- a/server/char_device.c
> +++ b/server/char_device.c
> @@ -45,6 +45,7 @@ struct SpiceCharDeviceClientState {
>  };
>  
>  struct SpiceCharDeviceState {
> +    int non_stop;
>      int running;
>      int active; /* has read/write been performed since the device was started */
>      int wait_for_migrate_data;
> @@ -803,12 +804,20 @@ void spice_char_device_start(SpiceCharDeviceState *dev)
>  
>  void spice_char_device_stop(SpiceCharDeviceState *dev)
>  {
> -    spice_debug("dev_state %p", dev);
> +    spice_debug("char_device_stop %p: non_stop:%d", dev, dev->non_stop);
> +
> +    if (dev->non_stop)
> +        return;
>      dev->running = FALSE;
>      dev->active = FALSE;
>      core->timer_cancel(dev->write_to_dev_timer);
>  }
>  
> +void spice_char_device_set_non_stop(SpiceCharDeviceState *dev, int non_stop)
> +{
> +    dev->non_stop = non_stop;
> +}
> +
>  void spice_char_device_reset(SpiceCharDeviceState *dev)
>  {
>      RingItem *client_item;
> diff --git a/server/char_device.h b/server/char_device.h
> index c17a40d..e2b6c63 100644
> --- a/server/char_device.h
> +++ b/server/char_device.h
> @@ -162,6 +162,7 @@ void spice_char_device_client_remove(SpiceCharDeviceState *dev,
>  int spice_char_device_client_exists(SpiceCharDeviceState *dev,
>                                      RedClient *client);
>  
> +void spice_char_device_set_non_stop(SpiceCharDeviceState *dev, int non_stop);
>  void spice_char_device_start(SpiceCharDeviceState *dev);
>  void spice_char_device_stop(SpiceCharDeviceState *dev);
>  
> diff --git a/server/reds.c b/server/reds.c
> index d9e04de..f1bad0c 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -3669,6 +3669,7 @@ static int spice_server_char_device_add_interface(SpiceServer *s,
>      }
>      else if (strcmp(char_device->subtype, SUBTYPE_NBD) == 0) {
>          dev_state = spicevmc_device_connect(char_device, SPICE_CHANNEL_NBD);
> +        spice_char_device_set_non_stop(dev_state, TRUE);
>      }
>      else if (strcmp(char_device->subtype, SUBTYPE_PORT) == 0) {
>          dev_state = spicevmc_device_connect(char_device, SPICE_CHANNEL_PORT);
> 



More information about the Spice-devel mailing list