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

Erik Skultety eskultet at redhat.com
Thu Aug 15 15:26:03 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
> 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>
> ---

Reviewed-by: Erik Skultety <eskultet at redhat.com>




More information about the libvir-list mailing list