Re: [RFC PATCH 6/6] util: Added a backing store NFS parser

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 11, 2020 at 3:24 AM Peter Krempa <pkrempa@xxxxxxxxxx> wrote:
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? 

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux