- implemented restore function for 'vmeare3' mode images
- 'vmware4' image mode: handle restore failure
This commit is contained in:
parent
8189a5ed20
commit
35ec96f740
@ -539,6 +539,44 @@ bx_bool vmware3_image_t::save_state(const char *backup_fname)
|
|||||||
|
|
||||||
void vmware3_image_t::restore_state(const char *backup_fname)
|
void vmware3_image_t::restore_state(const char *backup_fname)
|
||||||
{
|
{
|
||||||
// TODO
|
int backup_fd;
|
||||||
BX_ERROR(("vmware3_image_t::restore_state(): UNIMPLEMENTED"));
|
bx_bool ret = 1;
|
||||||
|
COW_Header temp_header;
|
||||||
|
char tempfn[BX_PATHNAME_LEN];
|
||||||
|
|
||||||
|
backup_fd = ::open(backup_fname, O_RDONLY
|
||||||
|
#ifdef O_BINARY
|
||||||
|
| O_BINARY
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
if (backup_fd < 0) {
|
||||||
|
BX_PANIC(("Could not open vmware3 image backup"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (read_header(backup_fd, temp_header) < 0) {
|
||||||
|
::close(backup_fd);
|
||||||
|
BX_PANIC(("Could not read vmware3 image header"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
::close(backup_fd);
|
||||||
|
if (!is_valid_header(temp_header)) {
|
||||||
|
BX_PANIC(("invalid vmware3 COW Disk image"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
unsigned count = current->header.number_of_chains;
|
||||||
|
close();
|
||||||
|
if (count < 1) count = 1;
|
||||||
|
for (unsigned i = 0; i < count; ++i) {
|
||||||
|
sprintf(tempfn, "%s%d", backup_fname, i);
|
||||||
|
char *filename = generate_cow_name(pathname, i);
|
||||||
|
ret &= hdimage_copy_file(tempfn, filename);
|
||||||
|
delete [] filename;
|
||||||
|
if (ret == 0) {
|
||||||
|
BX_PANIC(("Failed to restore vmware3 image '%s'", filename));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ret == 1) {
|
||||||
|
open(pathname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,6 +352,9 @@ void vmware4_image_t::restore_state(const char *backup_fname)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
close();
|
close();
|
||||||
hdimage_copy_file(backup_fname, pathname);
|
if (!hdimage_copy_file(backup_fname, pathname)) {
|
||||||
|
BX_PANIC(("Failed to restore vmware4 image '%s'", pathname));
|
||||||
|
return;
|
||||||
|
}
|
||||||
open(pathname);
|
open(pathname);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user