Follow-up from "Fix hypervisor sub-leaf handling"
The following discussion from !460 (merged) should be addressed:
-
@smcv started a discussion: guint is only 32 bits, and GHashTable keys are pointer-sized (therefore 32-bit when compiled for i386), so a hash table
{ guint => SrtCpuidData }
cannot provide correct mock values for something that wants 64-bit keys.I see two ways this could go:
- short-term: declare that items with a non-zero subleaf just can't use this mocking mechanism, use something like
G_UNLIKELY (mock_cpuid != NULL && subleaf == 0)
, and go back to usingGUINT_TO_POINTER (leaf)
as the hash table key; - long-term: use a data structure with larger keys and a custom hash/equals function, like a hash table
{ SubleafPair* => SrtCpuidData* }
where SubleafPair is a struct{ unsigned leaf, unsigned subleaf }
- short-term: declare that items with a non-zero subleaf just can't use this mocking mechanism, use something like