Modifying BDRVVmdkState

The new state structure looks like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
typedef struct VmdkExtent {
    BlockDriverState *file;
    int flat;
    int64_t sectors;
    int64_t l1_table_offset;
    int64_t l1_backup_table_offset;
    uint32_t *l1_table;
    uint32_t *l1_backup_table;
    unsigned int l1_size;
    uint32_t l1_entry_sectors;

    unsigned int l2_size;
    uint32_t *l2_cache;
    uint32_t l2_cache_offsets[L2_CACHE_SIZE];
    uint32_t l2_cache_counts[L2_CACHE_SIZE];

    unsigned int cluster_sectors;
} VmdkExtent;

typedef struct BDRVVmdkState {
    int has_descriptor_file;
    int extent_size;
    uint32_t parent_cid;
    VmdkExtent *extents;
} BDRVVmdkState;

The difference is that fields in VmdkExtent are moved out from state structure and form a new structure VmdkExtent, which represents one extent in a vmdk disk. BDRVVmdkState.extents points to an array of VmdkExtent, with size of extent_size.

It’s the fundamental change for the support of multiple extents of vmdk. When opening image, descriptor file is parsed and extents lines are read to build an array of extents. I.e. if it’s monolithic, array with one item is created, if 2GB multi extents, array with multiple items is created. Each extent holds the file path and type, according to which proper r/w operations are taken. Not all fields in VmdkExtent are used all the time, e.g. for flat extents the lookup table related fields are just ignored.

Soon I’ll add flat extent support upon these structures and migrate the original mono-sparse support to it.

Comments