@@ -66,6 +66,7 @@ typedef struct BDRVParallelsState {
unsigned int tracks;
unsigned int off_multiplier;
+ unsigned int padding;
} BDRVParallelsState;
static int parallels_open_image(BlockDriverState *bs, Error **errp);
@@ -144,6 +145,7 @@ static int parallels_open_xml(BlockDriverState *bs, int flags, Error **errp)
const char *data;
char image_path[PATH_MAX];
Error *local_err = NULL;
+ BDRVParallelsState *s = bs->opaque;
ret = size = bdrv_getlength(bs->file);
if (ret < 0) {
@@ -173,6 +175,19 @@ static int parallels_open_xml(BlockDriverState *bs, int flags, Error **errp)
if (root == NULL) {
goto fail;
}
+
+ data = xml_get_text(root, "/Disk_Parameters/Padding");
+ if (data != NULL) {
+ char *endptr;
+ unsigned long pad;
+
+ pad = strtoul(data, &endptr, 0);
+ if ((endptr != NULL && *endptr != '\0') || pad > UINT_MAX) {
+ goto fail;
+ }
+ s->padding = (uint32_t)pad;
+ }
+
image = xml_seek(root, "/StorageData/Storage/Image");
data = ""; /* make gcc happy */
for (size = 0; image != NULL; image = image->next) {
@@ -385,6 +400,10 @@ static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
static int parallels_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors)
{
+ BDRVParallelsState *s = bs->opaque;
+
+ sector_num += s->padding;
+
while (nb_sectors > 0) {
int64_t position = seek_to_sector(bs, sector_num);
if (position >= 0) {