- failure handling for save/restore added
This commit is contained in:
parent
2b72920cb6
commit
6ca6b46203
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: siminterface.cc,v 1.150 2006-05-27 21:37:36 sshwarts Exp $
|
||||
// $Id: siminterface.cc,v 1.151 2006-05-28 16:39:25 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// See siminterface.h for description of the siminterface concept.
|
||||
@ -866,7 +866,8 @@ bx_bool bx_real_sim_c::save_state(const char *checkpoint_path)
|
||||
FILE *fp;
|
||||
|
||||
sprintf(sr_file, "%s/config", checkpoint_path);
|
||||
write_rc(sr_file, 1);
|
||||
if (write_rc(sr_file, 1) < 0)
|
||||
return 0;
|
||||
sprintf(sr_file, "%s/logopts", checkpoint_path);
|
||||
fp = fopen(sr_file, "w");
|
||||
if (fp != NULL) {
|
||||
@ -886,6 +887,8 @@ bx_bool bx_real_sim_c::save_state(const char *checkpoint_path)
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
bx_list_c *sr_list = get_sr_root();
|
||||
ndev = sr_list->get_size();
|
||||
@ -895,9 +898,11 @@ bx_bool bx_real_sim_c::save_state(const char *checkpoint_path)
|
||||
if (fp != NULL) {
|
||||
save_sr_param(fp, sr_list->get(dev), checkpoint_path, 0);
|
||||
fclose(fp);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
bx_bool bx_real_sim_c::restore_config()
|
||||
@ -906,8 +911,7 @@ bx_bool bx_real_sim_c::restore_config()
|
||||
|
||||
sprintf(config, "%s/config", get_param_string(BXPN_RESTORE_PATH)->getptr());
|
||||
BX_INFO(("restoring '%s'", config));
|
||||
read_rc(config);
|
||||
return 0;
|
||||
return (read_rc(config) >= 0);
|
||||
}
|
||||
|
||||
bx_bool bx_real_sim_c::restore_logopts()
|
||||
@ -980,8 +984,10 @@ bx_bool bx_real_sim_c::restore_logopts()
|
||||
}
|
||||
} while (!feof(fp));
|
||||
fclose(fp);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
bx_bool bx_real_sim_c::restore_hardware()
|
||||
@ -1077,9 +1083,11 @@ bx_bool bx_real_sim_c::restore_hardware()
|
||||
}
|
||||
} while (!feof(fp));
|
||||
fclose(fp);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void bx_real_sim_c::save_sr_param(FILE *fp, bx_param_c *node, const char *sr_path, int level)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: textconfig.cc,v 1.53 2006-05-27 15:54:48 sshwarts Exp $
|
||||
// $Id: textconfig.cc,v 1.54 2006-05-28 16:39:25 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This is code for a text-mode configuration interface. Note that this file
|
||||
@ -515,10 +515,11 @@ int bx_config_interface(int menu)
|
||||
case BX_CI_RT_SAVE:
|
||||
if (ask_string("\nWhat is the path to save the Bochs state to?\nNOTE: Bochs quits after saving!\nTo cancel, type 'none'. [%s] ", "none", sr_path) >= 0) {
|
||||
if (strcmp (sr_path, "none")) {
|
||||
SIM->save_state(sr_path);
|
||||
bx_user_quit = 1;
|
||||
SIM->quit_sim(1);
|
||||
return -1;
|
||||
if (SIM->save_state(sr_path)) {
|
||||
bx_user_quit = 1;
|
||||
SIM->quit_sim(1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: win32dialog.cc,v 1.43 2006-05-28 08:49:20 vruppert Exp $
|
||||
// $Id: win32dialog.cc,v 1.44 2006-05-28 16:39:25 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "config.h"
|
||||
@ -763,8 +763,9 @@ static BOOL CALLBACK RTMiscDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP
|
||||
MessageBox(hDlg, "The save function quits after saving, since the state of hard drive images cannot be saved yet!", "WARNING", MB_ICONEXCLAMATION);
|
||||
sr_path[0] = 0;
|
||||
if (BrowseDir("Select folder for save/restore data", sr_path)) {
|
||||
SIM->save_state(sr_path);
|
||||
SendMessage(GetParent(hDlg), PSM_PRESSBUTTON, (WPARAM)PSBTN_CANCEL, 0);
|
||||
if (SIM->save_state(sr_path)) {
|
||||
SendMessage(GetParent(hDlg), PSM_PRESSBUTTON, (WPARAM)PSBTN_CANCEL, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: main.cc,v 1.335 2006-05-27 15:54:47 sshwarts Exp $
|
||||
// $Id: main.cc,v 1.336 2006-05-28 16:39:24 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -814,7 +814,10 @@ int bx_begin_simulation (int argc, char *argv[])
|
||||
{
|
||||
#if BX_SUPPORT_SAVE_RESTORE
|
||||
if (SIM->get_param_bool(BXPN_RESTORE_FLAG)->get()) {
|
||||
SIM->restore_config();
|
||||
if (!SIM->restore_config()) {
|
||||
BX_PANIC(("cannot restore configuration"));
|
||||
SIM->get_param_bool(BXPN_RESTORE_FLAG)->set(0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// deal with gui selection
|
||||
@ -1043,15 +1046,22 @@ int bx_init_hardware()
|
||||
bx_pc_system.register_state();
|
||||
DEV_register_state();
|
||||
if (SIM->get_param_bool(BXPN_RESTORE_FLAG)->get()) {
|
||||
SIM->restore_logopts();
|
||||
if (!SIM->restore_logopts()) {
|
||||
BX_PANIC(("cannot restore log options"));
|
||||
SIM->get_param_bool(BXPN_RESTORE_FLAG)->set(0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// will enable A20 line and reset CPU and devices
|
||||
bx_pc_system.Reset(BX_RESET_HARDWARE);
|
||||
#if BX_SUPPORT_SAVE_RESTORE
|
||||
if (SIM->get_param_bool(BXPN_RESTORE_FLAG)->get()) {
|
||||
SIM->restore_hardware();
|
||||
bx_sr_after_restore_state();
|
||||
if (SIM->restore_hardware()) {
|
||||
bx_sr_after_restore_state();
|
||||
} else {
|
||||
BX_PANIC(("cannot restore hardware state"));
|
||||
SIM->get_param_bool(BXPN_RESTORE_FLAG)->set(0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
bx_gui->init_signal_handlers();
|
||||
|
Loading…
Reference in New Issue
Block a user