On 2019/4/11 20:22, Kevin Wolf wrote: > Okay, so your problem is that blk_pread() writes to the whole buffer, > writing explicit zeroes for unallocated parts of the image, while you > would like to leave those parts of the buffer untouched so that we don't > actually allocate the memory, but can just use the shared zero page. > > If you just want to read the non-zero parts of the image, that can be > done by using a loop that calls bdrv_block_status() and only reads from > the image if the BDRV_BLOCK_ZERO bit is clear. > > Would this solve your problem?
Sounds good! What if guest tried to read/write the zero parts? -- Thanks, Xiang