libguestfs live

It has been possible for a while to use libguestfs to access a running guest by installing guestfsd in the guest.

Up until now the process required lots of manual configuration. However today (thanks to Dan and Lennart), the process is almost automatic.

You just have to install the new (Rawhide-only) libguestfs-live-service package inside the guest.

On the host, add the following clause to the guest’s XML:

<channel type='unix'>
  <source mode='bind' path='/var/lib/libvirt/qemu/$GUESTNAME.libguestfs' />
  <target type='virtio' name='org.libguestfs.channel.0' />
</channel>

(Replace $GUESTNAME with the name of the guest. We will likely change virt-install to make the above automatic.)

Update: librarian points out that you need qemu ≥ 0.14, and you also need to change the machine type to pc-0.14, otherwise virtio-serial sockets are not supported.

You can now connect using guestfish, eg:

# guestfish --live -d FedoraRawhidex64

Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

><fs> run
><fs> lvs
/dev/vg_fedorarawhidex64/lv_root
/dev/vg_fedorarawhidex64/lv_swap
><fs> touch /tmp/foo

A word of warning: Trying to edit disk images which are in use by virtual machines is dangerous and will result in disk corruption. libguestfs live works quite differently — it talks to the daemon running inside the guest and the daemon makes the changes safely.

12 Comments

Filed under Uncategorized

12 responses to “libguestfs live

  1. feeliwood

    hi Mr. Rich, should we install libguestfs before we install libguestfs-live-service package.
    thanks.

  2. feeliwood

    hi Mr.Rich,
    I create and manage VMs with qemu, qemu-kvm command.
    I don`t use virt-manager or any libvirt`s tool.
    I`ve been searching the host file system but I can`t find any guest`s xml file.
    Should I use virt-manager ?
    Thank you

  3. feeliwood

    thank you

  4. Adam Zouari

    Hello Rich,

    I’m working on my Bachelor thesis and I would like to access to a running guest. I know that this post have been written many years ago but I even tried the solution. I installed a Rawhide version of Fedora but the libguestfs-live-service package seems to have been deleted. Is there another solution ?

    Thank you

  5. Alex Chan

    Hi, Mr.Rich
    Now when I use the libguestfs in my project,I have a problem:
    In my project, the micro service is run in the Kata container. And I hope the micro service can use libguestfs to finish the identification and operation of the filesystem in a disk file. But the kernel of Kata container that I am using now is lack of kernel modules like KVM, so creating the qemu appliance in the container is unable to achieve.

    So I am thinking about making the guestfsd and our micro service run in the same container, instead of creating another qemu appliance in the container, so that micro service can communicate with guestfsd by using API that is supplied by libguestfs.

    But I still don’t have a very clear clue or an achievable method to realize what I’m thinking about. What do you think of my thoughts and how can I do? I sincerely look forward to your reply.

    Thanks,
    Alex

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.