[libvirt] [PATCH 2/2] virpcimock: Mock __open_2()

Ján Tomko jtomko at redhat.com
Thu Aug 15 18:26:55 UTC 2019


On Thu, Aug 15, 2019 at 05:15:57PM +0200, Michal Privoznik wrote:
>Hold on to your hat, this is going to be a wild ride. As nearly
>nothing in glic, nor open() is a real function. Just look into

s/glic/glibc/

>bits/fcntl2.h and you'll see that open() is actually a thin
>wrapper that calls either __open_alias() or __open_2(). Now,
>before 801ebb5edb6 the open() done in
>virPCIDeviceConfigOpenInternal() had a constant oflags (we were
>opening the pci config with O_RDWR). And since we were not
>passing any mode nor O_CREAT the wrapper decided to call
>__open_alias() which was open() provided by our mock. So far so
>good. But after the referenced commit, the oflags is no longer
>compile time constant and therefore the wrapper calls __open_2()
>which we don't mock and thus the real __open_2() from glibc was
>called and thus we did try to open real path from host's /sys.
>This of course fails with variety of errors.
>
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>---
> tests/virpcimock.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>

Thanks for tracking this down!

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190815/e7b3b156/attachment-0001.sig>


More information about the libvir-list mailing list