Opened 12 years ago
Closed 12 years ago
#9150 closed defect (fixed)
vhdRead is broken => Fixed in SVN
Reported by: | harrumph | Owned by: | |
---|---|---|---|
Component: | virtual disk | Version: | VirtualBox 4.0.10 |
Keywords: | VHD | Cc: | |
Guest type: | other | Host type: | other |
Description
I'm seeing disk corruption converting disks from VHD, and booting VMs. From inspection, this code looks bad...
cbBuf = cSectors * VHD_SECTOR_SIZE; LogFunc(("Sectors free: uVhdOffset=%llu cbBuf=%u\n", uVhdOffset, cbBuf)); rc = VERR_VD_BLOCK_FREE; } } else AssertMsgFailed(("Reading block bitmap failed rc=%Rrc\n", rc)); } else { rc = vhdFileReadSync(pImage, uOffset, pvBuf, cbBuf, NULL); } if (RT_SUCCESS(rc)) { if (pcbActuallyRead) *pcbActuallyRead = cbBuf; Log2(("vhdRead: off=%#llx pvBuf=%p cbBuf=%d\n" "%.*Rhxd\n", uOffset, pvBuf, cbBuf, cbBuf, pvBuf)); }
Note - *pcbActuallyRead not updated when a 'free' sector found, so calling code assumes all data in the scope of the read was 'free', when it could just be a single sector.
Contrast with vhdAsyncRead that does this
cbRead = cSectors * VHD_SECTOR_SIZE; LogFunc(("Sectors free: uVhdOffset=%llu cbRead=%u\n", uVhdOffset, cbRead)); rc = VERR_VD_BLOCK_FREE; } } else AssertMsg(rc == VERR_VD_NOT_ENOUGH_METADATA, ("Reading block bitmap failed rc=%Rrc\n", rc)); } else { rc = vhdFileReadUserAsync(pImage, uOffset, pIoCtx, cbRead); } if (pcbActuallyRead) *pcbActuallyRead = cbRead; LogFlowFunc(("returns rc=%Rrc\n", rc)); return rc; }
This always indicates the number of bytes actually read (whether 'free' or not).
Change History (3)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Summary: | vhdRead is broken → vhdRead is broken => Fixed in SVN |
---|
comment:3 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Thanks for this report! This will be fixed in the next release of VirtualBox.