qcow2-snapshot.c (72893756e0da74fcb626c52dfff1fc6e9de84f0c) | qcow2-snapshot.c (51ef67270b1d10e1fcf3de7368dccad1ba0bf9d1) |
---|---|
1/* 2 * Block driver for the QCOW version 2 format 3 * 4 * Copyright (c) 2004-2006 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 404 unchanged lines hidden (view full) --- 413 sn_info->date_sec = sn->date_sec; 414 sn_info->date_nsec = sn->date_nsec; 415 sn_info->vm_clock_nsec = sn->vm_clock_nsec; 416 } 417 *psn_tab = sn_tab; 418 return s->nb_snapshots; 419} 420 | 1/* 2 * Block driver for the QCOW version 2 format 3 * 4 * Copyright (c) 2004-2006 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 404 unchanged lines hidden (view full) --- 413 sn_info->date_sec = sn->date_sec; 414 sn_info->date_nsec = sn->date_nsec; 415 sn_info->vm_clock_nsec = sn->vm_clock_nsec; 416 } 417 *psn_tab = sn_tab; 418 return s->nb_snapshots; 419} 420 |
421int qcow2_snapshot_load_tmp(BlockDriverState *bs, const char *snapshot_name) 422{ 423 int i, snapshot_index, l1_size2; 424 BDRVQcowState *s = bs->opaque; 425 QCowSnapshot *sn; 426 427 snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_name); 428 if (snapshot_index < 0) { 429 return -ENOENT; 430 } 431 432 sn = &s->snapshots[snapshot_index]; 433 s->l1_size = sn->l1_size; 434 l1_size2 = s->l1_size * sizeof(uint64_t); 435 if (s->l1_table != NULL) { 436 qemu_free(s->l1_table); 437 } 438 439 s->l1_table_offset = sn->l1_table_offset; 440 s->l1_table = qemu_mallocz(align_offset(l1_size2, 512)); 441 442 if (bdrv_pread(bs->file, sn->l1_table_offset, 443 s->l1_table, l1_size2) != l1_size2) { 444 return -1; 445 } 446 447 for(i = 0;i < s->l1_size; i++) { 448 be64_to_cpus(&s->l1_table[i]); 449 } 450 return 0; 451} |
|