0

I'm trying to create a qcow2 volume with libvirt+qemu in a custom volume pool, then consuming that volume in a new domain. When trying to create the volume, I get an error from qemu-system-x86_64:

libvirt.libvirtError: internal error: process exited while connecting to monitor: 2019-05-24T11:06:50.756887Z qemu-system-x86_64: -drive file=/path/to/volume,format=qcow2,if=none,id=drive-virtio-disk0: Could not open '/path/to/volume': Permission denied

The entire path is set to 0777 permissions. Interestingly, if I consume the volume by specifying the file (instead of the storage pool and volume), then there's no permission issue.

I'm using the system instance of libvirt, qemu:///system. The libvirtd/qemu.cfg uses the default value for the user and group of qemu, for all I can tell, that's libvirt-qemu:kvm, neither setting of dynamic_ownership works.

strace -f on libvirtd shows the following curiosity:

22008 open("/path/to/volume", O_RDONLY|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
22008 stat("/path/to/volume", {st_mode=S_IFREG|0777, st_size=5369757696, ...}) = 0

Yes these lines are adjacent in the strace output. This particular setup happens with dynamic_ownership=0 and setting permissions in the volume XML to 0777. My guess is that using a volume somehow restricts the capability of the qemu process to access the filesystem.


Pool:

<pool type="dir">
   <name>meow</name>
   <target>
       <path>/path/to</path>
   </target>
</pool>

Volume:

<volume type='file'>
    <name>meow</name>
    <capacity unit="GiB">5</capacity>
    <target>
        <format type="qcow2" />
        <compat>1.1</compat>
        <!--
        These permissions have no influence on the error
        <permissions>
            <owner>libvirtd-qemu</owner>
            <group>kvm</group>
            <mode>0777</mode>
        </permissions>
        -->
    </target>
</volume>

<device> node of the domain:

    <!--
    This works without any issues
    <disk type="file" device="disk">
        <driver name="qemu" type="qcow2" />
        <source file="/path/to/volume" />
        <target dev="vda" bus="virtio" />
    </disk>
    -->

    <!--
    Consuming the disk via pool+volume causes permissions issues
    -->
    <disk type="volume" device="disk">
        <driver name="qemu" type="qcow2" />
        <source pool="meow" volume="meow" />
        <target dev="vda" bus="virtio" />
    </disk>
  • There wasn't any issue using another (more recent) installation of libvirt on another OS. So my guess is that it's either the libvirt installation or a bug in the version of libvirt I've been using. – dyp Jun 2 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.