RFC PATCH: Issue 90 (Test Clarification)

Peter Krempa pkrempa at redhat.com
Wed Dec 23 17:45:12 UTC 2020


On Mon, Dec 21, 2020 at 17:10:35 -0600, Ryan Gahagan wrote:
> We were able to get the testing environment running after some
> trial-and-error. The issue was that the version of libtirpc was out of
> date, causing an error in meson.build when the XDR dependency was being
> read. By updating the libtirpc-dev package we were able to start building
> locally. However, we did have some questions about our tests. For now we
> wanted to focus specifically on the qemublocktest.c file.
> 
> We have the function virDomainDiskSourceNetworkParse in
> src/conf/domain_conf.c where XML is parsed into virStorageSource data and
> the function qemuBlockStorageSourceCreateGetStorageProps under
> src/qemu/qemu_block.c where this data is converted into a JSON object. Our
> understanding of the tests/qemublocktest.c file is that we provide an XML
> string example via TEST_JSON_FORMAT_NET and that this string was parsed
> into JSON then formatted back into XML to make sure the process produced
> the same output as the input. One issue is that for some reason our user
> and group strings (i.e. “<nfs user=’+1’ group=’+2’/>”) are not getting
> parsed into integers. The nfs_uid and nfs_gid fields are never set and
> therefore result in a 0 every time. We have code to fix this in a method
> under qemuDomainPrepareStorageSourceBlockdev in the file
> src/qemu/qemu_domain.c which looks up the user and group and stores the
> values we expect, but this method isn’t getting called. Where in this
> process have we missed something? Should we move the virGetUserID and
> virGetGroupID method calls to somewhere else?

No. The issue is that the tests shouldn't really be allowed to look up
the UID/GID in the system. For that reason the test code doesn't
actually call qemuDomainPrepareStorageSourceBlockdev. For this test,
you'll be better off adding a hack to fill in the uid/gid values (e.g.
by checking that they start with a + to be safe.

> We were also curious about the methods which parse the JSON values back
> into data. In our case, this is virStorageSourceParseBackingJSONNFS in
> src/util/virstoragefile.c. This method tries to retrieve the user and group
> integers from the NFS JSON object. However, when constructing the JSON
> object in the getStorageProps method we don't actually add those values if
> they're "default" values. In JSON terms this means that the integers are
> undefined, but how does C interpret it? Does the retrieve method return 0
> or simply fail?

The formatter omits the values if they are default. According to the QMP
schema they can be missing. The parser thus must cope when the JSON
object doesn't have the values populated.




More information about the libvir-list mailing list