On Thu, Dec 10, 2020 at 14:00:07 -0600, Ryan Gahagan wrote:
> + virJSONValuePtr server = virJSONValueObjectGetObject(json, "server");
> + int gotUID = virJSONValueObjectGetNumberInt(json, "user", (int *)(&src->nfs_uid));
You should not typecast the pointers here since it's not guaranteed that
the uid_t/gid_t type is the same as an integer. Additionally storing
this only in the nfs_uid field will actually not show up in the VM xml
once parsed. You actually need to populate the string variants with the
uid number with + prepended so that the XML conversion works.
The reason we use this hacky integer pointer cast is because the virJSONValueObjectGetNumberInt method expects an int * as its thir parameter, and when we tried to use &src->nfs_uid or gid directly we got a compile error for type mismatch. This cast was the only way we could find to work around this easily other than changing the _virStorageSource parameters to be explicit int type, but then the virGetUserID and GroupID methods cause the opposite type mismatch error because they return uid_t and gid_t values. How should we actually get these numbers out if not for this cast?