Loading
Fix virDomainInfo.state type from int to byte
The C struct defines state as unsigned char (1 byte), but the JNA
mapping used int (4 bytes). This causes two problems:
- On big-endian systems, the 1-byte state value is stored at the
beginning of the field, but reading it as a 4-byte int interprets
it as the most significant byte, producing a completely wrong
value (e.g. state=1 would be read as 0x01000000).
- On little-endian systems, the state byte is correctly placed in
the least significant position, but the remaining 3 padding bytes
are also read as part of the int. These padding bytes may contain
garbage, corrupting the value. In practice this was masked by
libvirt zero-initializing the struct, but it is not guaranteed by
the C specification.
Changed to byte to match the C type, and added a bitmask (& 0xFF)
when converting to the DomainState enum index to handle the
unsigned-to-signed conversion correctly.
Signed-off-by:
Mitsuru Kariya <mitsuru.kariya@nttdata.com>