Hi. I'm try to use guestfish inside golang (extract some files from image and create squashfs from root). Now i can't understand how can i work with mount-local/mount-local-run. Where i can specify what partition i'm export to local? Does i need firstly mount /dev/sda1 to / for example and after that run mount-local /tmp/xxx ? Second - i'm work with guestfish via writing to stdin and getting result from stdout. In case of mount-local-run does i need fully fork new binary or i can only dup stdin descriptor and work with it? -- Vasiliy Tolstov, e-mail: v.tolstov@selfip.ru jabber: vase@selfip.ru
Hi, On Tuesday 15 July 2014 15:33:12 Vasiliy Tolstov wrote:
Hi. I'm try to use guestfish inside golang (extract some files from image and create squashfs from root). Now i can't understand how can i work with mount-local/mount-local-run. Where i can specify what partition i'm export to local? Does i need firstly mount /dev/sda1 to / for example and after that run mount-local /tmp/xxx ?
Yes, you need at least something mounted to / (so /dev/sda1 in your example) before calling mount-local. mount-local needs a root filesystem mounted and it will always fail without it (in libguestfs 1.26 the error message is clear in such cases).
Second - i'm work with guestfish via writing to stdin and getting result from stdout. In case of mount-local-run does i need fully fork new binary or i can only dup stdin descriptor and work with it?
I'm afraid I don't understand what you mean here -- can you please provide an actual case of what you want to do? -- Pino Toscano
On Tue, Jul 15, 2014 at 03:33:12PM +0400, Vasiliy Tolstov wrote:
Hi. I'm try to use guestfish inside golang (extract some files from image and create squashfs from root). Now i can't understand how can i work with mount-local/mount-local-run. Where i can specify what partition i'm export to local? Does i need firstly mount /dev/sda1 to / for example and after that run mount-local /tmp/xxx ?
Have a look at this example: https://github.com/libguestfs/libguestfs/blob/master/examples/mount-local.c As Pino says, it exports the root directory from the "libguestfs API space".
Second - i'm work with guestfish via writing to stdin and getting result from stdout. In case of mount-local-run does i need fully fork new binary or i can only dup stdin descriptor and work with it?
Not sure I understand the question, but the guestfish mount-local-run command will block guestfish until another process runs 'fusermount -u /mntpoint' (or better, 'guestunmount /mntpoint'). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
2014-07-15 20:59 GMT+04:00 Richard W.M. Jones <rjones@redhat.com>:
Not sure I understand the question, but the guestfish mount-local-run command will block guestfish until another process runs 'fusermount -u /mntpoint' (or better, 'guestunmount /mntpoint').
I understand that guestfish process will be locked. But in case of go that uses lightweight goroutines, is that possible to replace fork with goroutine ? -- Vasiliy Tolstov, e-mail: v.tolstov@selfip.ru jabber: vase@selfip.ru
On Wed, Jul 16, 2014 at 12:08:50AM +0400, Vasiliy Tolstov wrote:
2014-07-15 20:59 GMT+04:00 Richard W.M. Jones <rjones@redhat.com>:
Not sure I understand the question, but the guestfish mount-local-run command will block guestfish until another process runs 'fusermount -u /mntpoint' (or better, 'guestunmount /mntpoint').
I understand that guestfish process will be locked. But in case of go that uses lightweight goroutines, is that possible to replace fork with goroutine ?
It's a pretty tricky question. It will depend on how goroutines map to pthreads. In my experience it has been very difficult to avoid races in FUSE when using EITHER pthreads OR multiple processes. One particular problem is if the kernel socket that FUSE uses leaks into a forked subprocess, which can happen because the FUSE library is not careful about setting FD_CLOEXEC atomically. You'll probably want to take a look at the implementation of guestfs_mount_local_run here: https://github.com/libguestfs/libguestfs/blob/master/src/fuse.c#L1029 Also at the parallel test of mount_local which is part of the test suite: https://github.com/libguestfs/libguestfs/blob/master/tests/mount-local/test-... BTW is there any reason to use FUSE instead of using the libguestfs API directly? Using the API is going to be much more robust. Also -- 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
2014-07-16 0:58 GMT+04:00 Richard W.M. Jones <rjones@redhat.com>:
BTW is there any reason to use FUSE instead of using the libguestfs API directly? Using the API is going to be much more robust.
I'm need to create squashfs from root file system. I see some methods like tar and cpio, but i can't find anything suitable for creating squashfs. Also i can't use root permissions and need to work only with user rights. -- Vasiliy Tolstov, e-mail: v.tolstov@selfip.ru jabber: vase@selfip.ru
On Wed, Jul 16, 2014 at 01:04:43AM +0400, Vasiliy Tolstov wrote:
2014-07-16 0:58 GMT+04:00 Richard W.M. Jones <rjones@redhat.com>:
BTW is there any reason to use FUSE instead of using the libguestfs API directly? Using the API is going to be much more robust.
I'm need to create squashfs from root file system. I see some methods like tar and cpio, but i can't find anything suitable for creating squashfs.
I believe I investigates making a squashfs from within libguestfs, and although it's possible, it is not possible to stream the output (unlike, say, guestfs_tar_out or guestfs_cpio_out). This means that the maximum size of the squashfs would be quite small. Nevertheless we could add an API to do it. (Even better if you can find a way to stream mksquashfs).
Also i can't use root permissions and need to work only with user rights.
I approve :-) Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
2014-07-16 1:12 GMT+04:00 Richard W.M. Jones <rjones@redhat.com>:
I believe I investigates making a squashfs from within libguestfs, and although it's possible, it is not possible to stream the output (unlike, say, guestfs_tar_out or guestfs_cpio_out). This means that the maximum size of the squashfs would be quite small.
Nevertheless we could add an API to do it. (Even better if you can find a way to stream mksquashfs).
May be i'm wrong but does it possible to create ability to export guest file system via 9p proto? If yes - i can mount share with fuse inside go application via 9p protocol... -- Vasiliy Tolstov, e-mail: v.tolstov@selfip.ru jabber: vase@selfip.ru
On Wed, Jul 16, 2014 at 01:17:23AM +0400, Vasiliy Tolstov wrote:
2014-07-16 1:12 GMT+04:00 Richard W.M. Jones <rjones@redhat.com>:
I believe I investigates making a squashfs from within libguestfs, and although it's possible, it is not possible to stream the output (unlike, say, guestfs_tar_out or guestfs_cpio_out). This means that the maximum size of the squashfs would be quite small.
Nevertheless we could add an API to do it. (Even better if you can find a way to stream mksquashfs).
May be i'm wrong but does it possible to create ability to export guest file system via 9p proto? If yes - i can mount share with fuse inside go application via 9p protocol...
There is some support for 9p in the libguestfs APIs. I would be worried about 9p support upstream (in qemu) as it appears to be dead. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
2014-07-16 14:39 GMT+04:00 Richard W.M. Jones <rjones@redhat.com>:
There is some support for 9p in the libguestfs APIs. I would be worried about 9p support upstream (in qemu) as it appears to be dead.
Ok. I'm solve my problem - i'm exec guestfish where i do mount-local-run and waiting, after creating squashfs i'm simply doing fusermount -u -z /xxx -- Vasiliy Tolstov, e-mail: v.tolstov@selfip.ru jabber: vase@selfip.ru
participants (3)
-
Pino Toscano -
Richard W.M. Jones -
Vasiliy Tolstov