[libvirt] adding tests to qemu_driver

Jiri Denemark jdenemar at redhat.com
Thu Nov 12 22:30:01 UTC 2015

On Thu, Nov 12, 2015 at 23:47:54 +0200, noxdafox wrote:
> Greetings,
> I was investigating on an issue in which QEMU's dynamic ownership was 
> not properly working when calling qemuDomainCoreDumpWithFormat().

Could describe this issue you are investigating?

> The core of the issue seems to be the qemuOpenFileAs() function which 
> does not handle the dynamic ownership. This might affect other libvirt's 
> features within as well.

Because you are most likely looking at a wrong place; qemuOpenFileAs is
a quite low level function which is just supposed to open/create a file
accessible to a given user. It's up to the caller to decide what the
user should be.

> The issue is that all the functions within the qemu_driver.c module are 
> static. I could indeed include the module itself in my tests but I'm not 
> sure whether this is acceptable.

We solve this kind of issues by removing "static" from the functions and
adding a new header file (if it doesn't exist yet) called *priv.h
(qemu_driverpriv.h in this case) with the prototypes for such functions.
Only tests are allowed to include such header files.

> Furthermore I'd like to have some clarification about the NFS related 
> code. It seems that some effort has been put in order to tackle 
> something I'm not aware of. Could someone briefly explain how to 
> reproduce NFS failing scenarios?

The main problem with NFS which this ugly function is trying to handle
is called "root-squash". This feature maps all access from UID 0 to an
unprivileged UID. That is, libvirtd (even though it is running as root)
will not be able to access the desired file.


More information about the libvir-list mailing list