I noticed that if a domain fails to restore, the ref count in the xattr 'trusted.libvirt.security.ref_selinux' keeps on increasing indefinitely and the VM will never restore even if the root cause for the restore failure has been removed. The reason seems to be that the code to decrease the ref count never gets called because the block above it fails due to virSecuritySELinuxTransactionAppend() failing. The simple solution seems to be to revert the order in which things are done. Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxxxxx> --- src/security/security_selinux.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index ea20373a90..9fd29e9bca 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1499,14 +1499,9 @@ virSecuritySELinuxRestoreFileLabel(virSecurityManagerPtr mgr, goto cleanup; } - if ((rc = virSecuritySELinuxTransactionAppend(path, NULL, - false, recall, true)) < 0) { - goto cleanup; - } else if (rc > 0) { - ret = 0; - goto cleanup; - } - + /* Recall the label so the ref count label decreases its counter + * even if transaction append below fails. + */ if (recall) { rc = virSecuritySELinuxRecallLabel(newpath, &fcon); if (rc == -2) { @@ -1519,6 +1514,14 @@ virSecuritySELinuxRestoreFileLabel(virSecurityManagerPtr mgr, } } + if ((rc = virSecuritySELinuxTransactionAppend(path, NULL, + false, recall, true)) < 0) { + goto cleanup; + } else if (rc > 0) { + ret = 0; + goto cleanup; + } + if (!recall || rc == -2) { if (stat(newpath, &buf) != 0) { VIR_WARN("cannot stat %s: %s", newpath, -- 2.20.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list