qemu: Do not error out when setting affinity failed
qemu: Do not error out when setting affinity failed

Consider a host with 8 CPUs. There are the following possible scenarios

1. Bare metal; libvirtd has affinity of 8 CPUs; QEMU should get 8 CPUs

2. Bare metal; libvirtd has affinity of 2 CPUs; QEMU should get 8 CPUs

3. Container has affinity of 8 CPUs; libvirtd has affinity of 8 CPus;
   QEMU should get 8 CPUs

4. Container has affinity of 8 CPUs; libvirtd has affinity of 2 CPus;
   QEMU should get 8 CPUs

5. Container has affinity of 4 CPUs; libvirtd has affinity of 4 CPus;
   QEMU should get 4 CPUs

6. Container has affinity of 4 CPUs; libvirtd has affinity of 2 CPus;
   QEMU should get 4 CPUs

Scenarios 1 & 2 always work unless systemd restricted libvirtd privs.

Scenario 3 works because libvirt checks current affinity first and
skips the sched_setaffinity call, avoiding the SYS_NICE issue

Scenario 4 works only if CAP_SYS_NICE is availalbe

Scenarios 5 & 6 works only if CAP_SYS_NICE is present *AND* the cgroups
cpuset is not set on the container.

If libvirt blindly ignores the sched_setaffinity failure, then scenarios
4, 5 and 6 should all work, but with caveat in case 4 and 6, that
QEMU will only get 2 CPUs instead of the possible 8 and 4 respectively.
This is still better than failing.

Therefore libvirt can blindly ignore the setaffinity failure, but *ONLY*
ignore it when there was no affinity specified in the XML config.
If user specified affinity explicitly, libvirt must report an error if
it can't be honoured.

Resolves: https://bugzilla.redhat.com/1819801

Suggested-by: Daniel P. Berrangé <bb938cf255e055ff3507f2627d214e8e62118fcf@redhat.com>
Signed-off-by: Martin Kletzander <e82f23e74d43760279ebcc505dac4ae70d5627d0@redhat.com>
Reviewed-by: Daniel P. Berrangé <bb938cf255e055ff3507f2627d214e8e62118fcf@redhat.com>

nertpinx/libvirt,zippy2/libvirt,jardasgit/libvirt,olafhering/libvirt,nertpinx/libvirt,jardasgit/libvirt,nertpinx/libvirt,zippy2/libvirt,libvirt/libvirt,jardasgit/libvirt,jfehlig/libvirt,jfehlig/libvirt,libvirt/libvirt,zippy2/libvirt,libvirt/libvirt,crobinso/libvirt,jfehlig/libvirt,zippy2/libvirt,crobinso/libvirt,jardasgit/libvirt,nertpinx/libvirt,crobinso/libvirt,crobinso/libvirt,libvirt/libvirt,olafhering/libvirt,olafhering/libvirt,jfehlig/libvirt,nertpinx/libvirt,olafhering/libvirt,jardasgit/libvirt