[libvirt] [PATCH v4 01/25] qemusecuritymock: Mock virProcessRunInFork
Daniel P. Berrangé
berrange at redhat.com
Mon Jun 17 12:28:30 UTC 2019
On Thu, Apr 25, 2019 at 10:19:37AM +0200, Michal Privoznik wrote:
> This test is beautiful. It checks if we haven't messed up
> refcounting on security labels (well, XATTRs where the original
> owner is stored). It does this by setting up tracking of XATTR
> setting/removing into a hash table, then calling
> qemuSecuritySetAllLabel() followed by immediate
> qemuSecurityRestoreAllLabel() at which point, the hash table must
> be empty. The test so beautifully written that now matter
s/now/no/
> what you do it won't fail. The reason is that all seclabel work
> is done in a child process. Therefore, the hash table in the
> parent is never changed and thus always empty.
>
> There are two reasons for forking (only one of them makes sense
> here though):
>
> 1) namespaces - when chown()-ing a file we have to fork() and
> make the child enter desired namespace,
> 2) locking - because of exclusive access to XATTRs we lock the
> files we chown() and this is done in a fork (see 207860927ad for
> more info).
>
> While we want to fork in real world, we don't want that in a test
> suite. Override virProcessRunInFork() then.
>
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
> src/util/virprocess.h | 3 ++-
> tests/qemusecuritymock.c | 8 ++++++++
> 2 files changed, 10 insertions(+), 1 deletion(-)
Reviewed-by: Daniel P. Berrangé <berrange at redhat.com>
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
More information about the libvir-list
mailing list