<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p><span>Hello,</span></p>
<p><span><br>
</span></p>
<p><span>I'm running libvirt 3.1.0 on a Debian 8 server. I installed apparmor and configured libvirt to use apparmor as security driver.</span></p>
<p><span>After booting a VM, virsh dumpxml shows an apparmor seclabel.</span></p>
<p><span><br>
</span></p>
<p><span>As soon as I try to attach a second disk to the VM, apparmor blocks this.</span></p>
<p><span><br>
</span></p>
<p><span>virsh attach-device test-vps /tmp/virshXmlDefinition</span></p>
<p><span>error: Failed to attach device from /tmp/virshXmlDefinition</span></p>
<p><span>error: operation failed: Could not open '/mnt/images/disk2.raw': Permission denied</span></p>
<p><span><br>
</span></p>
<p><span>Syslogs shows me the following:</span></p>
<p><span>Mar 22 17:45:20 vps0 kernel: [1136647.318314] audit: type=1400 audit(1490201120.577:30): apparmor="DENIED" operation="open" profile="libvirt-5747e4db-a3b7-fd69-ca89-00007b0bf859" name="/mnt/images/disk2.raw" pid=13453 comm="kvm" requested_mask="r"
 denied_mask="r" fsuid=996 ouid=33</span></p>
<p><span>Mar 22 17:45:20 vps0 kernel: [1136647.325155] audit: type=1400 audit(1490201120.577:31): apparmor="DENIED" operation="open" profile="libvirt-5747e4db-a3b7-fd69-ca89-00007b0bf859" name="/mnt/images/disk2.raw" pid=13453 comm="kvm" requested_mask="rw"
 denied_mask="rw" fsuid=996 ouid=33</span></p>
<p><span>Mar 22 17:45:20 vps0 libvirtd[10282]: 2017-03-22 16:45:20.596+0000: 10283: error : qemuMonitorTextAddDrive:1968 : operation failed: Could not open '/mnt/images/disk2.raw': Permission denied</span></p>
<p><span><br>
</span></p>
<p><span>In the VM specific apparmor file /etc/apparmor.d/libvirt/libvirt-5747e4db-a3b7-fd69-ca89-00007b0bf859.files I see:</span></p>
<p><span>"/mnt/images/disk1.raw" rw,</span></p>
<p><span><br>
</span></p>
<p><span>Which is my primary VM disk, I expected a virsh attach-device to append /mnt/images/disk2.raw to this file and reload/refresh the apparmor profile?</span></p>
<p><span><br>
</span></p>
<p><span>I'm not able to attach a live disk to a running VM with apparmor. Am I missing something? Or is this a bug/missing feature in libvirt?</span></p>
<p><span><br>
</span></p>
<p><span>Thanks,</span></p>
<p><span>Frank</span><br>
</p>
</div>
</body>
</html>