[Bug 1927519] Re: Mitigate libvirt: error : unable to set AppArmor profile 'libvirt-<vm-uuid>' for '/usr/bin/kvm-spice': No such file or directory

Christian Ehrhardt  1927519 at bugs.launchpad.net
Tue Nov 23 11:34:33 UTC 2021


The documented testcase for this issue also LGTM.

Bionic
root at b:~# virsh dominfo f
Id:             -
Name:           f
UUID:           18ad0964-736e-4c8d-869b-13083e66beca
OS Type:        hvm
State:          shut off
CPU(s):         1
Max memory:     524288 KiB
Used memory:    524288 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: apparmor
Security DOI:   0

root at b:~# cat /dev/null | sudo tee /etc/apparmor.d/libvirt/libvirt-18ad0964-736e-4c8d-869b-13083e66beca
root at b:~# ll /etc/apparmor.d/libvirt/libvirt-18ad0964-736e-4c8d-869b-13083e66beca
-rw-r--r-- 1 root root 0 Nov 23 11:31 /etc/apparmor.d/libvirt/libvirt-18ad0964-736e-4c8d-869b-13083e66beca
root at b:~# virsh start f
Domain f started



Focal
root at f:~# virsh dominfo f
Id:             -
Name:           f
UUID:           f4c2021f-14bf-4e04-af31-0667908320f1
OS Type:        hvm
State:          shut off
CPU(s):         1
Max memory:     524288 KiB
Used memory:    524288 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: apparmor
Security DOI:   0

root at f:~# cat /dev/null | sudo tee /etc/apparmor.d/libvirt/libvirt-f4c2021f-14bf-4e04-af31-0667908320f1
root at f:~# ll /etc/apparmor.d/libvirt/libvirt-f4c2021f-14bf-4e04-af31-0667908320f1
-rw-r--r-- 1 root root 0 Nov 23 11:31 /etc/apparmor.d/libvirt/libvirt-f4c2021f-14bf-4e04-af31-0667908320f1
root at f:~# virsh start f
Domain f started


Hirsute
root at h:~# virsh dominfo f
Id:             -
Name:           f
UUID:           1ceac8db-c1e9-40b2-8ada-a60349454fc1
OS Type:        hvm
State:          shut off
CPU(s):         1
Max memory:     524288 KiB
Used memory:    524288 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: apparmor
Security DOI:   0

root at h:~# cat /dev/null | sudo tee /etc/apparmor.d/libvirt/libvirt-1ceac8db-c1e9-40b2-8ada-a60349454fc1
root at h:~# ll /etc/apparmor.d/libvirt/libvirt-1ceac8db-c1e9-40b2-8ada-a60349454fc1
-rw-r--r-- 1 root root 0 Nov 23 11:31 /etc/apparmor.d/libvirt/libvirt-1ceac8db-c1e9-40b2-8ada-a60349454fc1
root at h:~# virsh start f
Domain 'f' started


Impish
root at i:~# virsh dominfo f
Id:             -
Name:           f
UUID:           c2cf5436-c7c3-402e-9593-ad7dca047ceb
OS Type:        hvm
State:          shut off
CPU(s):         1
Max memory:     524288 KiB
Used memory:    524288 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: apparmor
Security DOI:   0

root at i:~# cat /dev/null | sudo tee /etc/apparmor.d/libvirt/libvirt-c2cf5436-c7c3-402e-9593-ad7dca047ceb
root at i:~# ll /etc/apparmor.d/libvirt/libvirt-ll /etc/apparmor.d/libvirt/libvirt-c2cf5436-c7c3-402e-9593-ad7dca047ceb
ls: cannot access '/etc/apparmor.d/libvirt/libvirt-ll': No such file or directory
-rw-r--r-- 1 root root 0 Nov 23 11:31 /etc/apparmor.d/libvirt/libvirt-c2cf5436-c7c3-402e-9593-ad7dca047ceb
root at i:~# virsh start f
Domain 'f' started


Almost all complete, scheduling general regression tests now.

-- 
You received this bug notification because you are a member of Ubuntu
OpenStack, which is subscribed to Ubuntu Cloud Archive.
https://bugs.launchpad.net/bugs/1927519

Title:
  Mitigate libvirt: error : unable to set AppArmor profile 'libvirt-<vm-
  uuid>' for '/usr/bin/kvm-spice': No such file or directory

Status in Ubuntu Cloud Archive:
  New
Status in Ubuntu Cloud Archive queens series:
  New
Status in Ubuntu Cloud Archive stein series:
  New
Status in Ubuntu Cloud Archive ussuri series:
  New
Status in libvirt package in Ubuntu:
  Fix Committed
Status in libvirt source package in Bionic:
  Fix Committed
Status in libvirt source package in Focal:
  Fix Committed
Status in libvirt source package in Hirsute:
  Fix Committed
Status in libvirt source package in Impish:
  Fix Committed
Status in libvirt source package in Jammy:
  Fix Committed

Bug description:
  [Impact]

  Some times libvirt fails to start a vm with the following error :
  libvirt:  error : unable to set AppArmor profile 'libvirt-b05b297f-952f-42d6-b04e-f9a13767db54' for '/usr/bin/kvm-spice': No such file or directory

  This happens because for some reason the apparmor profile for the
  guest /etc/apparmor.d/libvirt/libvirt-<vm-uuid> has 0 size.

  We do not now why the above file gets truncated to begin with and
  therefore we do not know the root cause to fix it there. But the
  condition is easy to detect and 100% broken, so we can detect and
  recreate the file in those cases.

  [Test case]

  To reproduce this behaviour, create a vm and stop it, note the uuid.

  For example:
  $ uvt-simplestreams-libvirt --verbose sync --source http://cloud-images.ubuntu.com/daily arch=amd64 label=daily release=focal
  $ uvt-kvm create --password=ubuntu f release=focal arch=amd64 label=daily
  $ virsh dominfo f
  ...
  Security label: libvirt-1ceac8db-c1e9-40b2-8ada-a60349454fc1 (enforcing)
  $ virsh shutdown f

  Then make the start apparmor profile an empty file.
  On Bionic/Focal that file will be non-existant by default (cleaned on guest stop), on Hirsute/Impish it will be around for admin-edit but with content. Therefore "touch" isn't enough every time, instead really put nothing to it as that is how the real issue looks like).

  $ cat /dev/null | sudo tee /etc/apparmor.d/libvirt/libvirt-1ceac8db-c1e9-40b2-8ada-a60349454fc1
  # ensure it is size zero
  $ ll /etc/apparmor.d/libvirt/libvirt-1ceac8db-c1e9-40b2-8ada-a60349454fc1
  -rw-r--r-- 1 root root 0 Nov 18 09:01 /etc/apparmor.d/libvirt/libvirt-1ceac8db-c1e9-40b2-8ada-a60349454fc1

  Next try to start the vm, it will try to use the file it found
  (instead of creating a new one as it would when non-existing) and will
  fail doing so:

  $ virsh start f
  error: internal error: Process exited prior to exec: libvirt:  error : unable to set AppArmor profile 'libvirt-1ceac8db-c1e9-40b2-8ada-a60349454fc1' for '/usr/bin/qemu-system-x86_64': No such file or directory

  To manually be able to start the vm again just delete the libvirt-<vm-uuid> file.
  With the fix applied libvirt will recreate the file and guest start works again.

  
  In addition (independent to the case) I'll run a set of common regression tests against <release>-proposed which didn't run for a while and would make us also spot if anything other slipped in from different places (like the dwarves hiccup we had). Since testing shall be on "the real build" and resources are limited I'd this time do so only on the builds in proposed.

  [Regression Potential]

  The new code is only active when the size of the file is zero which is
  a 100% guarantee that the guest is broken and won't start.
  Nevertheless if we made a mistake in the fix the area (of the many
  things libvirt does) to look at is the generating and usage of
  apparmor profiles.

  [Other]

  Similar reported bug : https://bugs.debian.org/cgi-
  bin/bugreport.cgi?bug=890084

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-archive/+bug/1927519/+subscriptions




More information about the Ubuntu-openstack-bugs mailing list