mirror of https://github.com/xqemu/xqemu.git
savevm: Split load vm state function qemu_loadvm_state
qemu_loadvm_state is too long, and we can simplify it by splitting up with three helper functions. Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Amit Shah <amit.shah@redhat.com> Message-Id: <1452829066-9764-4-git-send-email-zhang.zhanghailiang@huawei.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
This commit is contained in:
parent
89a02a9f7b
commit
fb3520a84e
|
@ -1718,21 +1718,15 @@ void loadvm_free_handlers(MigrationIncomingState *mis)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
|
static int
|
||||||
|
qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)
|
||||||
{
|
{
|
||||||
uint8_t section_type;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) {
|
|
||||||
uint32_t instance_id, version_id, section_id;
|
uint32_t instance_id, version_id, section_id;
|
||||||
SaveStateEntry *se;
|
SaveStateEntry *se;
|
||||||
LoadStateEntry *le;
|
LoadStateEntry *le;
|
||||||
char idstr[256];
|
char idstr[256];
|
||||||
|
int ret;
|
||||||
|
|
||||||
trace_qemu_loadvm_state_section(section_type);
|
|
||||||
switch (section_type) {
|
|
||||||
case QEMU_VM_SECTION_START:
|
|
||||||
case QEMU_VM_SECTION_FULL:
|
|
||||||
/* Read section start */
|
/* Read section start */
|
||||||
section_id = qemu_get_be32(f);
|
section_id = qemu_get_be32(f);
|
||||||
if (!qemu_get_counted_string(f, idstr)) {
|
if (!qemu_get_counted_string(f, idstr)) {
|
||||||
|
@ -1777,9 +1771,17 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
|
||||||
if (!check_section_footer(f, le)) {
|
if (!check_section_footer(f, le)) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case QEMU_VM_SECTION_PART:
|
return 0;
|
||||||
case QEMU_VM_SECTION_END:
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis)
|
||||||
|
{
|
||||||
|
uint32_t section_id;
|
||||||
|
LoadStateEntry *le;
|
||||||
|
int ret;
|
||||||
|
|
||||||
section_id = qemu_get_be32(f);
|
section_id = qemu_get_be32(f);
|
||||||
|
|
||||||
trace_qemu_loadvm_state_section_partend(section_id);
|
trace_qemu_loadvm_state_section_partend(section_id);
|
||||||
|
@ -1802,6 +1804,32 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
|
||||||
if (!check_section_footer(f, le)) {
|
if (!check_section_footer(f, le)) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
|
||||||
|
{
|
||||||
|
uint8_t section_type;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) {
|
||||||
|
|
||||||
|
trace_qemu_loadvm_state_section(section_type);
|
||||||
|
switch (section_type) {
|
||||||
|
case QEMU_VM_SECTION_START:
|
||||||
|
case QEMU_VM_SECTION_FULL:
|
||||||
|
ret = qemu_loadvm_section_start_full(f, mis);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QEMU_VM_SECTION_PART:
|
||||||
|
case QEMU_VM_SECTION_END:
|
||||||
|
ret = qemu_loadvm_section_part_end(f, mis);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case QEMU_VM_COMMAND:
|
case QEMU_VM_COMMAND:
|
||||||
ret = loadvm_process_command(f);
|
ret = loadvm_process_command(f);
|
||||||
|
|
Loading…
Reference in New Issue