1 #include "kvm/disk-image.h"
4 * raw image and blk dev are similar, so reuse raw image ops.
6 static struct disk_image_operations blk_dev_ops
= {
7 .read_sector
= raw_image__read_sector
,
8 .write_sector
= raw_image__write_sector
,
9 .close
= raw_image__close
,
12 struct disk_image
*blkdev__probe(const char *filename
, struct stat
*st
)
17 if (!S_ISBLK(st
->st_mode
))
21 * Be careful! We are opening host block device!
22 * Open it readonly since we do not want to break user's data on disk.
24 fd
= open(filename
, O_RDONLY
);
28 if (ioctl(fd
, BLKGETSIZE64
, &size
) < 0) {
34 * FIXME: This will not work on 32-bit host because we can not
35 * mmap large disk. There is not enough virtual address space
36 * in 32-bit host. However, this works on 64-bit host.
38 return disk_image__new(fd
, size
, &blk_dev_ops
, DISK_IMAGE_MMAP
);