Revision b171271a block/vmdk.c
b/block/vmdk.c | ||
---|---|---|
170 | 170 |
{ |
171 | 171 |
#ifdef CHECK_CID |
172 | 172 |
BDRVVmdkState *s = bs->opaque; |
173 |
BlockDriverState *p_bs = s->hd->backing_hd;
|
|
173 |
BlockDriverState *p_bs = bs->backing_hd;
|
|
174 | 174 |
uint32_t cur_pcid; |
175 | 175 |
|
176 | 176 |
if (p_bs) { |
... | ... | |
338 | 338 |
p_name += sizeof("parentFileNameHint") + 1; |
339 | 339 |
if ((end_name = strchr(p_name,'\"')) == NULL) |
340 | 340 |
return -1; |
341 |
if ((end_name - p_name) > sizeof (s->hd->backing_file) - 1)
|
|
341 |
if ((end_name - p_name) > sizeof (bs->backing_file) - 1)
|
|
342 | 342 |
return -1; |
343 | 343 |
|
344 |
pstrcpy(s->hd->backing_file, end_name - p_name + 1, p_name);
|
|
345 |
if (stat(s->hd->backing_file, &file_buf) != 0) {
|
|
344 |
pstrcpy(bs->backing_file, end_name - p_name + 1, p_name);
|
|
345 |
if (stat(bs->backing_file, &file_buf) != 0) {
|
|
346 | 346 |
path_combine(parent_img_name, sizeof(parent_img_name), |
347 |
filename, s->hd->backing_file);
|
|
347 |
filename, bs->backing_file);
|
|
348 | 348 |
} else { |
349 | 349 |
pstrcpy(parent_img_name, sizeof(parent_img_name), |
350 |
s->hd->backing_file);
|
|
350 |
bs->backing_file);
|
|
351 | 351 |
} |
352 | 352 |
|
353 |
s->hd->backing_hd = bdrv_new("");
|
|
354 |
if (!s->hd->backing_hd) {
|
|
353 |
bs->backing_hd = bdrv_new("");
|
|
354 |
if (!bs->backing_hd) {
|
|
355 | 355 |
failure: |
356 | 356 |
bdrv_close(s->hd); |
357 | 357 |
return -1; |
358 | 358 |
} |
359 | 359 |
parent_open = 1; |
360 |
if (bdrv_open(s->hd->backing_hd, parent_img_name, BDRV_O_RDONLY) < 0)
|
|
360 |
if (bdrv_open(bs->backing_hd, parent_img_name, BDRV_O_RDONLY) < 0)
|
|
361 | 361 |
goto failure; |
362 | 362 |
parent_open = 0; |
363 | 363 |
} |
... | ... | |
464 | 464 |
|
465 | 465 |
// we will be here if it's first write on non-exist grain(cluster). |
466 | 466 |
// try to read from parent image, if exist |
467 |
if (s->hd->backing_hd) {
|
|
468 |
BDRVVmdkState *ps = s->hd->backing_hd->opaque;
|
|
467 |
if (bs->backing_hd) {
|
|
468 |
BDRVVmdkState *ps = bs->backing_hd->opaque;
|
|
469 | 469 |
|
470 | 470 |
if (!vmdk_is_cid_valid(bs)) |
471 | 471 |
return -1; |
472 | 472 |
|
473 |
parent_cluster_offset = get_cluster_offset(s->hd->backing_hd, NULL, offset, allocate); |
|
473 |
parent_cluster_offset = get_cluster_offset(bs->backing_hd, NULL, |
|
474 |
offset, allocate); |
|
474 | 475 |
|
475 | 476 |
if (parent_cluster_offset) { |
476 | 477 |
BDRVVmdkState *act_s = activeBDRV.hd->opaque; |
... | ... | |
621 | 622 |
n = nb_sectors; |
622 | 623 |
if (!cluster_offset) { |
623 | 624 |
// try to read from parent image, if exist |
624 |
if (s->hd->backing_hd) {
|
|
625 |
if (bs->backing_hd) {
|
|
625 | 626 |
if (!vmdk_is_cid_valid(bs)) |
626 | 627 |
return -1; |
627 |
ret = bdrv_read(s->hd->backing_hd, sector_num, buf, n);
|
|
628 |
ret = bdrv_read(bs->backing_hd, sector_num, buf, n);
|
|
628 | 629 |
if (ret < 0) |
629 | 630 |
return -1; |
630 | 631 |
} else { |
Also available in: Unified diff