diff options
author | Vladimir Chtchetkine <vchtchetkine@google.com> | 2011-10-05 14:25:07 -0700 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2011-10-05 19:22:52 -0700 |
commit | 9f3c0c76682640cf6583b1b0babb23e9038a8d71 (patch) | |
tree | 8a24b80ec99ad6cdb75dca9b186ff48a71817d24 | |
parent | a2f29cb6efc83df073e66a3cf2c7ba02709b4257 (diff) | |
download | external_qemu-9f3c0c76682640cf6583b1b0babb23e9038a8d71.zip external_qemu-9f3c0c76682640cf6583b1b0babb23e9038a8d71.tar.gz external_qemu-9f3c0c76682640cf6583b1b0babb23e9038a8d71.tar.bz2 |
Cherry-pick d0e2872 from master: Fix snapshots. do not merge.
Change-Id: I8662ec8d2f38244bb8c727a1cd898c450ef5d051
-rw-r--r-- | android/hw-qemud.c | 30 | ||||
-rw-r--r-- | arch_init.c | 10 | ||||
-rw-r--r-- | hw/android_arm.c | 1 | ||||
-rw-r--r-- | hw/goldfish_audio.c | 2 | ||||
-rw-r--r-- | savevm.c | 6 |
5 files changed, 27 insertions, 22 deletions
diff --git a/android/hw-qemud.c b/android/hw-qemud.c index b8d912c..0820e4c 100644 --- a/android/hw-qemud.c +++ b/android/hw-qemud.c @@ -45,7 +45,7 @@ /* Version number of snapshots code. Increment whenever the data saved * or the layout in which it is saved is changed. */ -#define QEMUD_SAVE_VERSION 1 +#define QEMUD_SAVE_VERSION 2 #define min(a, b) (((a) < (b)) ? (a) : (b)) @@ -934,7 +934,7 @@ qemud_client_save(QEMUFile* f, QemudClient* c) /* save generic information */ qemud_service_save_name(f, c->service); qemu_put_be32(f, c->protocol); - if (_is_pipe_client(c)) { + if (!_is_pipe_client(c)) { qemu_put_be32(f, c->ProtocolSelector.Serial.channel); } @@ -959,7 +959,7 @@ qemud_client_save(QEMUFile* f, QemudClient* c) * corresponding service. */ static int -qemud_client_load(QEMUFile* f, QemudService* current_services ) +qemud_client_load(QEMUFile* f, QemudService* current_services, int version ) { char *service_name = qemud_service_load_name(f); if (service_name == NULL) @@ -973,13 +973,19 @@ qemud_client_load(QEMUFile* f, QemudService* current_services ) return -EIO; } - /* get protocol. */ - QemudProtocol protocol = qemu_get_be32(f); - /* get channel id */ int channel = -1; - if (protocol == QEMUD_PROTOCOL_SERIAL) { - qemu_get_be32(f); + + if (version >= 2) { + /* get protocol. */ + QemudProtocol protocol = qemu_get_be32(f); + /* get channel id */ + if (protocol == QEMUD_PROTOCOL_SERIAL) { + channel = qemu_get_be32(f); + } + } else { + channel = qemu_get_be32(f); } + if (channel == 0) { D("%s: illegal snapshot: client for control channel must no be saved\n", __FUNCTION__); @@ -1791,7 +1797,7 @@ qemud_load_services( QEMUFile* f, QemudService* current_services ) * changes, there is no communication with the guest. */ static int -qemud_load_clients(QEMUFile* f, QemudMultiplexer* m ) +qemud_load_clients(QEMUFile* f, QemudMultiplexer* m, int version ) { /* Remove all clients, except on the control channel.*/ qemud_multiplexer_disconnect_noncontrol(m); @@ -1800,7 +1806,7 @@ qemud_load_clients(QEMUFile* f, QemudMultiplexer* m ) int client_count = qemu_get_be32(f); int i, ret; for (i = 0; i < client_count; i++) { - if ((ret = qemud_client_load(f, m->services))) { + if ((ret = qemud_client_load(f, m->services, version))) { return ret; } } @@ -1816,14 +1822,12 @@ qemud_load(QEMUFile *f, void* opaque, int version) QemudMultiplexer *m = opaque; int ret; - if (version != QEMUD_SAVE_VERSION) - return -1; if ((ret = qemud_serial_load(f, m->serial))) return ret; if ((ret = qemud_load_services(f, m->services))) return ret; - if ((ret = qemud_load_clients(f, m))) + if ((ret = qemud_load_clients(f, m, version))) return ret; return 0; diff --git a/arch_init.c b/arch_init.c index b966d8a..7285d27 100644 --- a/arch_init.c +++ b/arch_init.c @@ -382,7 +382,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) addr &= TARGET_PAGE_MASK; if (flags & RAM_SAVE_FLAG_MEM_SIZE) { - if (version_id == 3) { + if (version_id != 3) { if (addr != ram_bytes_total()) { return -EINVAL; } @@ -418,13 +418,11 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) total_ram_bytes -= length; } } - } - - if (flags & RAM_SAVE_FLAG_COMPRESS) { + } else if (flags & RAM_SAVE_FLAG_COMPRESS) { void *host; uint8_t ch; - if (version_id == 3) + if (version_id != 3) host = qemu_get_ram_ptr(addr); else host = host_from_stream_offset(f, addr, flags); @@ -443,7 +441,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) } else if (flags & RAM_SAVE_FLAG_PAGE) { void *host; - if (version_id == 3) + if (version_id != 3) host = qemu_get_ram_ptr(addr); else host = host_from_stream_offset(f, addr, flags); diff --git a/hw/android_arm.c b/hw/android_arm.c index 188051b..c93a4db 100644 --- a/hw/android_arm.c +++ b/hw/android_arm.c @@ -77,7 +77,6 @@ static void android_arm_init_(ram_addr_t ram_size, cpu_model = "arm926"; env = cpu_init(cpu_model); - register_savevm( "cpu", 0, ARM_CPU_SAVE_VERSION, cpu_save, cpu_load, env ); ram_offset = qemu_ram_alloc(NULL,"android_arm",ram_size); cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM); diff --git a/hw/goldfish_audio.c b/hw/goldfish_audio.c index 434522c..60e652c 100644 --- a/hw/goldfish_audio.c +++ b/hw/goldfish_audio.c @@ -263,7 +263,7 @@ static int audio_state_load( QEMUFile* f, void* opaque, int version_id ) goldfish_audio_buff_get( s->out_buff2, f ); goldfish_audio_buff_get (s->in_buff, f); } - return -1; + return ret; } static void enable_audio(struct goldfish_audio_state *s, int enable) @@ -1121,7 +1121,11 @@ int qemu_loadvm_state(QEMUFile *f) le->next = first_le; first_le = le; - le->se->load_state(f, le->se->opaque, le->version_id); + if (le->se->load_state(f, le->se->opaque, le->version_id)) { + fprintf(stderr, "savevm: unable to load section %s\n", idstr); + ret = -EINVAL; + goto out; + } break; case QEMU_VM_SECTION_PART: case QEMU_VM_SECTION_END: |