Skip to contentSkip to conversation

Make serial number in SMBIOS table equal to UUID

PATCH New Andrew D. Ball 1 participant 1 message Aug 22, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make serial number in SMBIOS table equal to UUID

[HVM] [SMBIOS] Duplicate UUID into serial number in SMBIOS tables.

Windows zeroes out the UUID in the SMBIOS tables, but the identifier is often needed by systems management code. Duplicating the UUID as the virtual system's serial number should help.

tools/firmware/hvmloader/smbios.c +9 -3
diff -r 6a8204e4619d -r f3a3ee53050e tools/firmware/hvmloader/smbios.c
@@ -116,8 +116,10 @@ smbios_table_size(uint32_t vcpus, const 
 
 	/* type 0: "Xen", xen_version, and release_date */
 	size += strlen("Xen") + strlen(xen_version) + 2;
-	/* type 1: "Xen", xen_version, "HVM domU" */
-	size += strlen("Xen") + strlen("HVM domU") + strlen(xen_version) + 3;
+	/* type 1: "Xen", xen_version, "HVM domU", UUID as string for 
+                   serial number */
+	size += strlen("Xen") + strlen("HVM domU") + strlen(xen_version) +
+			36 + 4;
 	/* type 3: "Xen" */
 	size += strlen("Xen") + 1;
 	/* type 4: socket designation ("CPU n"), processor_manufacturer */
@@ -371,6 +373,7 @@ smbios_type_1_init(void *start, const ch
 smbios_type_1_init(void *start, const char *xen_version, 
 		   uint8_t uuid[16])
 {
+	char uuid_str[37];
 	struct smbios_type_1 *p = (struct smbios_type_1 *)start;
 	p->header.type = 1;
 	p->header.length = sizeof(struct smbios_type_1);
@@ -379,7 +382,7 @@ smbios_type_1_init(void *start, const ch
 	p->manufacturer_str = 1;
 	p->product_name_str = 2;
 	p->version_str = 3;
-	p->serial_number_str = 0;
+	p->serial_number_str = 4;
     
 	memcpy(p->uuid, uuid, 16);
 
@@ -395,6 +398,9 @@ smbios_type_1_init(void *start, const ch
 	start += strlen("HVM domU") + 1;
 	strcpy((char *)start, xen_version);
 	start += strlen(xen_version) + 1;
+	uuid_to_string(uuid_str, uuid);	
+	strcpy((char *)start, uuid_str);
+	start += strlen(uuid_str) + 1;
 	*((uint8_t *)start) = 0;
     
 	return start+1; 
tools/firmware/hvmloader/util.c +54 -0

57 lines not on this page · raw message

tools/firmware/hvmloader/util.h +10 -0
diff -r 6a8204e4619d -r f3a3ee53050e tools/firmware/hvmloader/util.h
@@ -25,6 +25,16 @@ void *memset(void *s, int c, unsigned n)
 void *memset(void *s, int c, unsigned n);
 char *itoa(char *a, unsigned int i);
 
+/* convert a byte to two lowercase hex digits, with no terminating NUL 
+   character.  digits[] must have at least two elements. */
+void byte_to_hex(char *digits, uint8_t byte);
+
+/* Convert an array of 16 unsigned bytes to a DCE/OSF formatted UUID
+   string.
+
+   Pre-condition: sizeof(dest) >= 37 */
+void uuid_to_string(char *dest, uint8_t *uuid);
+
 /* Debug output */
 void puts(const char *s);