Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to use this roles with lvm #61

Open
roumano opened this issue Sep 11, 2020 · 1 comment · May be fixed by #62
Open

Failed to use this roles with lvm #61

roumano opened this issue Sep 11, 2020 · 1 comment · May be fixed by #62

Comments

@roumano
Copy link
Contributor

roumano commented Sep 11, 2020

I've failed to use this roles with lvm (at least on debian 10)

Error

if data to created VM is :

  volumes:
    - name: 'ns2'
      type: 'volume'
      capacity: '10GB'
      pool: 'lvm_pool'
      format: 'raw'

The role is crashing with this error

    "msg": "internal error: qemu unexpectedly closed the monitor: 2020-09-11T12:51:05.508705Z qemu-system-x86_64: -drive file=/dev/lvm_pool/ns3,format=raw,if=none,id=drive-virtio-disk0: Could not open '/dev/lvm_pool/ns3': Permission denied"

Debugging

  • Debugging, virsh dumpxml <nodename> give me :
    <disk type='volume' device='disk'>
      <driver name='qemu' type='raw'/>
      <source pool='lvm_pool' volume='ns3'/>
      <target dev='vda' bus='virtio'/>
    </disk>
  • Update the node via virsh edit <node>
    • replace <disk type='volume' device='disk'> with <disk type='block' device='disk'>
    • replace <source pool='lvm_pool' volume='ns3'/> with <source dev='/dev/lvm_pool/ns3'/>

It's now can boot

Change need

To permit these two line change (done on virsh edit) via ansible and your role :

  • Need to add this in the template vm.xml.j2 :
      {% elif volume.pool is defined %}
      <source dev='/dev/{{ volume.pool }}/{{ volume.name }}'/>
  • Need to change type from volume to block, so my variable will be :
  volumes:
    - name: 'ns2'
      type: 'block'
      capacity: '10GB'
      pool: 'lvm_pool'
      format: 'raw'
  • As it's now a block volume, the tasks Ensure the VM volumes exist will be skipped (due to when condition)
    So needed to update volumes.yml condition (line 30)

from : when: item.type | default(libvirt_volume_default_type) == 'volume'
to : when: item.type | default(libvirt_volume_default_type) == 'volume' or ( item.type | default(libvirt_volume_default_type) == 'block' and item.pool is defined )

  • Maybe, it's will also good to update the README to have a lvm example .
@roumano roumano linked a pull request Sep 11, 2020 that will close this issue
@roumano roumano closed this as completed Sep 11, 2020
@roumano roumano reopened this Sep 11, 2020
@NightTsarina
Copy link

I am having this exact problem. The volume definition seems fine, but libvirt is not creating apparmor rules to access the device file, it seems it is only done when the device file is specified in the XML (instead of using pool+name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants