]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemuxml2argvmock: Fix behaviour of 'virCommandPass' mock
authorPeter Krempa <pkrempa@redhat.com>
Fri, 15 May 2026 12:34:27 +0000 (14:34 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 25 May 2026 11:28:57 +0000 (13:28 +0200)
commita3bedabcc4c86a4fbc4bbb610171591c6a21721e
treec7bc38313502bf36a6315b515b5dd99962163cc6
parentf705379443ddfc0c7621cccf56d0008b4afd3b99
qemuxml2argvmock: Fix behaviour of 'virCommandPass' mock

The 'virCommandPass' mock in 'qemuxml2argvmock.so' skipped passing most
FDs to the real implementation of 'virCommandPass', except for few fake
FDs that were hardcoded.

This meant that if a test case had an valid FD that it used for testing
that FD would be leaked. At the same time fake fds 1730, 1731, 1732
would be actually passed to the virCommand itself although the FD was
invalid.

Since neither of the above makes sense fix the implementation the
following way:

 - refuse to pass any STDIO fds
     They are real and they would break test program output. Some tests
     do try to use them errorneously; they will be addressed later.

 - pass real FDs to virCommand
    Real FDs can be properly handled by virCommand. Especially they will
    be closed once the virCommand object is disposed of.

 - don't pass fake FDs
    They create extra noise e.g. in valgrind. Skip those as it makes no
    sense to handle those.

This patch addresses most failures that valgrind reports with
--track-fds=all.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/qemuxml2argvmock.c