使用“bdrv_pread(..)”或替代方法读取 qcow2 图像的内容
Reading contents of a qcow2 image using `bdrv_pread(..)` or alternatives
我想使用 QEMU 中的 bdrv_pread(...)
函数从 .qcow2
图像中读取内容。
比如说,我的图像的完整路径是 /path/to/myimage.qcow2
,我希望能够从该图像的特定偏移处读取 'n' 字节的数据。现在 bdrv_pread
函数采用这些参数“BlockDriverState *bs, int64_t offset, void *buf, int count1
”,我究竟如何从图像路径初始化 BlockDriverState
(设备?)。除了 BlockDriverState
之外的所有其他参数我都清楚。
谢谢。
如果您的目标是从您自己的程序访问 qcow2 文件,我建议您不要尝试使用 QEMU 函数。这些将有很多与 QEMU 相关的状态,如果您只想读取 qcow2 文件的内容,则这些状态不是必需的。相反,您可以查看可以帮助您入门的 qcow2 specification or if you want to work at one higher level of abstraction you could look at the libguestfs library, which states that it has an API for accessing the supported VM disk formats (although I have never used it myself). There is some example code here。
我想使用 QEMU 中的 bdrv_pread(...)
函数从 .qcow2
图像中读取内容。
比如说,我的图像的完整路径是 /path/to/myimage.qcow2
,我希望能够从该图像的特定偏移处读取 'n' 字节的数据。现在 bdrv_pread
函数采用这些参数“BlockDriverState *bs, int64_t offset, void *buf, int count1
”,我究竟如何从图像路径初始化 BlockDriverState
(设备?)。除了 BlockDriverState
之外的所有其他参数我都清楚。
谢谢。
如果您的目标是从您自己的程序访问 qcow2 文件,我建议您不要尝试使用 QEMU 函数。这些将有很多与 QEMU 相关的状态,如果您只想读取 qcow2 文件的内容,则这些状态不是必需的。相反,您可以查看可以帮助您入门的 qcow2 specification or if you want to work at one higher level of abstraction you could look at the libguestfs library, which states that it has an API for accessing the supported VM disk formats (although I have never used it myself). There is some example code here。