diff options
author | Yonit Halperin <yhalperi@redhat.com> | 2012-06-28 14:22:43 +0300 |
---|---|---|
committer | Yonit Halperin <yhalperi@redhat.com> | 2012-08-27 09:04:51 +0300 |
commit | c302e12c78acc24461e19691119557945e0c2dc8 (patch) | |
tree | e3007648e80587f801a6ec52ee4392d99fd619ff | |
parent | 11033ca5dcb031fea37b44dbcd07ebabc22288b8 (diff) | |
download | spice-c302e12c78acc24461e19691119557945e0c2dc8.tar.gz spice-c302e12c78acc24461e19691119557945e0c2dc8.tar.xz spice-c302e12c78acc24461e19691119557945e0c2dc8.zip |
spice.h: add entries for tracking vm state
When vm state changes (started/stopped), we notify all the
attached SpiceCharDeviceStates about the change. This is mainly required
for avoiding writing/reading to/from the device during the non-live
stage of migration.
spice version will be bumped in one of the following patches.
-rw-r--r-- | server/reds.c | 34 | ||||
-rw-r--r-- | server/spice.h | 3 |
2 files changed, 36 insertions, 1 deletions
diff --git a/server/reds.c b/server/reds.c index 4e8a008c..b0c609f6 100644 --- a/server/reds.c +++ b/server/reds.c @@ -252,6 +252,7 @@ typedef struct RedsState { SpiceTimer *mig_timer; SpiceTimer *mm_timer; + int vm_running; Ring char_devs_states; /* list of SpiceCharDeviceStateItem */ SSL_CTX *ctx; @@ -3260,7 +3261,9 @@ static int spice_server_char_device_add_interface(SpiceServer *s, spice_assert(char_device->st); /* setting the char_device state to "started" for backward compatibily with * qemu releases that don't call spice api for start/stop (not implemented yet) */ - spice_char_device_start(char_device->st); + if (reds->vm_running) { + spice_char_device_start(char_device->st); + } reds_char_device_add_state(char_device->st); } else { spice_warning("failed to create device state for %s", char_device->subtype); @@ -3476,6 +3479,7 @@ static int do_spice_init(SpiceCoreInterface *core_interface) ring_init(&reds->channels); ring_init(&reds->mig_target_clients); ring_init(&reds->char_devs_states); + reds->vm_running = TRUE; /* for backward compatibility */ if (!(reds->mig_timer = core->timer_add(migrate_timeout, NULL))) { spice_error("migration timer create failed"); @@ -4025,6 +4029,34 @@ SPICE_GNUC_VISIBLE int spice_server_migrate_switch(SpiceServer *s) return 0; } +SPICE_GNUC_VISIBLE void spice_server_vm_start(SpiceServer *s) +{ + RingItem *item; + + spice_assert(s == reds); + reds->vm_running = TRUE; + RING_FOREACH(item, &reds->char_devs_states) { + SpiceCharDeviceStateItem *st_item; + + st_item = SPICE_CONTAINEROF(item, SpiceCharDeviceStateItem, link); + spice_char_device_start(st_item->st); + } +} + +SPICE_GNUC_VISIBLE void spice_server_vm_stop(SpiceServer *s) +{ + RingItem *item; + + spice_assert(s == reds); + reds->vm_running = FALSE; + RING_FOREACH(item, &reds->char_devs_states) { + SpiceCharDeviceStateItem *st_item; + + st_item = SPICE_CONTAINEROF(item, SpiceCharDeviceStateItem, link); + spice_char_device_stop(st_item->st); + } +} + ssize_t reds_stream_read(RedsStream *s, void *buf, size_t nbyte) { ssize_t ret; diff --git a/server/spice.h b/server/spice.h index 3d70ec75..5f82ed5a 100644 --- a/server/spice.h +++ b/server/spice.h @@ -528,4 +528,7 @@ int spice_server_migrate_end(SpiceServer *s, int completed); void spice_server_set_name(SpiceServer *s, const char *name); void spice_server_set_uuid(SpiceServer *s, const uint8_t uuid[16]); +void spice_server_vm_start(SpiceServer *s); +void spice_server_vm_stop(SpiceServer *s); + #endif |