@@ -3258,6 +3258,23 @@ def _hw_data(osdata):
32583258 return {}
32593259
32603260 grains = {}
3261+
3262+ # For Xen para-virtualized guests read UUID from /sys/hypervisor/uuid
3263+ if osdata ["kernel" ] == "Linux" and os .path .exists ("/sys/hypervisor/uuid" ):
3264+ try :
3265+ with salt .utils .files .fopen ("/sys/hypervisor/uuid" , "r" ) as ifile :
3266+ hypervisor_uuid = salt .utils .stringutils .to_unicode (
3267+ ifile .read ().strip (), errors = "replace"
3268+ )
3269+ # Normalize to lowercase to match DMI format
3270+ grains ["uuid" ] = hypervisor_uuid .lower ()
3271+ log .debug (
3272+ "Read UUID from /sys/hypervisor/uuid for para-virtualized guest: %s" ,
3273+ grains ["uuid" ],
3274+ )
3275+ except OSError as err :
3276+ log .debug ("Unable to read /sys/hypervisor/uuid: %s" , err )
3277+
32613278 if osdata ["kernel" ] == "Linux" and os .path .exists ("/sys/class/dmi/id" ):
32623279 # On many Linux distributions basic firmware information is available via sysfs
32633280 # requires CONFIG_DMIID to be enabled in the Linux kernel configuration
@@ -3272,6 +3289,9 @@ def _hw_data(osdata):
32723289 "serialnumber" : "product_serial" ,
32733290 }
32743291 for key , fw_file in sysfs_firmware_info .items ():
3292+ # Skip UUID if already read from /sys/hypervisor/uuid (Xen PV guests)
3293+ if key == "uuid" and "uuid" in grains :
3294+ continue
32753295 contents_file = os .path .join ("/sys/class/dmi/id" , fw_file )
32763296 if os .path .exists (contents_file ):
32773297 try :
0 commit comments