陳培泓
2017-Jul-12 08:45 UTC
[Libguestfs] any read/write raw image function or API in Python?
I know there's lots of functions that can access/modify the internal fs of img or qcow2 through libguestfs. I want to know is there any library can modify the raw/qcow2 image directly in Python? For example, there's function called read_qcow2(), and I can know the content of tmp.qcow2 through the function read_qcow2().
Pino Toscano
2017-Jul-12 09:24 UTC
Re: [Libguestfs] any read/write raw image function or API in Python?
On Wednesday, 12 July 2017 10:45:35 CEST 陳培泓 wrote:> I know there's lots of functions that can access/modify the internal fs of > img or qcow2 through libguestfs. > > I want to know is there any library can modify the raw/qcow2 image directly > in Python? > > For example, there's function called read_qcow2(), and I can know the > content of tmp.qcow2 through the function read_qcow2().The only library I know for qcow2 is: https://github.com/libyal/libqcow although it seems to not be fully up-to-date with the state of QEMU's later additions to the format. RAW files are just 1:1 representation of disks, so you will need to read partitions, filesystems, etc directly from there. -- Pino Toscano
陳培泓
2017-Jul-12 10:03 UTC
Re: [Libguestfs] any read/write raw image function or API in Python?
libqcow is read-only on qcow files and don't support write It seems there's none library can parse the qcow format. 2017-07-12 17:24 GMT+08:00 Pino Toscano <ptoscano@redhat.com>:> On Wednesday, 12 July 2017 10:45:35 CEST 陳培泓 wrote: > > I know there's lots of functions that can access/modify the internal fs > of > > img or qcow2 through libguestfs. > > > > I want to know is there any library can modify the raw/qcow2 image > directly > > in Python? > > > > For example, there's function called read_qcow2(), and I can know the > > content of tmp.qcow2 through the function read_qcow2(). > > The only library I know for qcow2 is: https://github.com/libyal/libqcow > although it seems to not be fully up-to-date with the state of QEMU's > later additions to the format. > > RAW files are just 1:1 representation of disks, so you will need to > read partitions, filesystems, etc directly from there. > > -- > Pino Toscano
Richard W.M. Jones
2017-Jul-12 16:46 UTC
Re: [Libguestfs] any read/write raw image function or API in Python?
On Wed, Jul 12, 2017 at 04:45:35PM +0800, 陳培泓 wrote:> I know there's lots of functions that can access/modify the internal fs of > img or qcow2 through libguestfs. > > I want to know is there any library can modify the raw/qcow2 image directly > in Python?libguestfs can do this, eg. using: http://libguestfs.org/guestfs.3.html#guestfs_pread_device http://libguestfs.org/guestfs.3.html#guestfs_pwrite_device Another way might be to use the ‘qemu-io’ utility from qemu. Rich.> For example, there's function called read_qcow2(), and I can know the > content of tmp.qcow2 through the function read_qcow2().> _______________________________________________ > Libguestfs mailing list > Libguestfs@redhat.com > https://www.redhat.com/mailman/listinfo/libguestfs-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org