[RHEL 8] Use of qemu-img info -U option to avoid locking error

Solution In Progress - Updated -

Issue

  • How do I get disk information from a live guest

  • libguestfs tools are failing to get shared "write" lock on running KVM guests

    # virt-df -d rhel-7
    libguestfs: error: could not create appliance through libvirt.
    
    Try running qemu directly without libvirt using this environment variable:
    export LIBGUESTFS_BACKEND=direct
    
    Original error from libvirt: internal error: process exited while connecting to monitor: arserial0,id=serial0 -chardev socket,id=charchannel0,path=/tmp/libguestfsMAjZPC/guestfsd.sock -device  virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.libguestfs.channel.0 -object rng-random,id=objrng0,filename=/dev/urandom -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0x4 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny -msg timestamp=on
    2020-03-03 17:29:46.520+0000: Domain id=3 is tainted: custom-argv
    2020-03-03 17:29:46.520+0000: Domain id=3 is tainted: host-cpu
    2020-03-03T17:29:46.590130Z qemu-kvm: -drive file=/tmp/libguestfsCUcrvw/overlay1.qcow2,format=qcow2,if=none,id=drive-scsi0-0-0-0,cache=unsafe: Could not open backing file: Failed to get shared "write" lock
    Is another process using the image [/home/qemu/rhel-server-7.7-x86_64-kvm.qcow2]? [code=1 int1=-1]
    
  • qemu-img -U option allows to open the image in shared mode, and it can be used to get the running image information.

    # man qemu-img
    ...
          --force-share (-U)
                 If specified, qemu-img will open the image in shared mode, allowing other QEMU processes to open it in
                 write  mode.  For example, this can be used to get the image information (with 'info' subcommand) when
                 the image is used by a running guest.  Note that this could produce inconsistent  results  because  of
                 concurrent metadata changes, etc. This option is only allowed when opening images in read-only mode.
    

Environment

  • RHEL 8
  • libguestfs-1.38.4-14

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content