[PATCH 24/36] qemuxml2argvtest: Add support for populating 'fds' in private data

Peter Krempa pkrempa at redhat.com
Fri Jan 6 13:28:39 UTC 2023


On Fri, Jan 06, 2023 at 14:06:50 +0100, Pavel Hrdina wrote:
> On Thu, Jan 05, 2023 at 05:30:13PM +0100, Peter Krempa wrote:
> > Introduce a new argument type for testQemuInfoSetArgs named ARG_FD_GROUP
> > which allows users to instantiate tests with populated FD passing hash
> > table.
> 
> I don't like when we need to alter the code in order to be able to test
> it. There should be another better way of ensuring we have stable FDs
> for tests. Not sure how difficult it would be to change it so we need
> to go with this approach for now but would be nice to rework this by
> follow up patches.

All the other code uses invalid FD numbers. That doesn't work very well
when you need to duplicate them though.

When we'd mock 'dup' then it becomes order dependant which is very hard
to debug especially when combined with LD_PRELOAD-ed libraries we use
for mocking.

The advantage here is that we don't have fake FDs, thus dup works and
it's the output doesn't change based on the system.

Obviously for real usage we don't care about the specific numbers.


More information about the libvir-list mailing list