Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/smbiostbl.c
| Show All 37 Lines | |||||
| #include <string.h> | #include <string.h> | ||||
| #include <unistd.h> | #include <unistd.h> | ||||
| #include <uuid.h> | #include <uuid.h> | ||||
| #include <machine/vmm.h> | #include <machine/vmm.h> | ||||
| #include <vmmapi.h> | #include <vmmapi.h> | ||||
| #include "bhyverun.h" | #include "bhyverun.h" | ||||
| #include "config.h" | |||||
| #include "debug.h" | #include "debug.h" | ||||
| #include "smbiostbl.h" | #include "smbiostbl.h" | ||||
| #define MB (1024*1024) | #define MB (1024*1024) | ||||
| #define GB (1024ULL*1024*1024) | #define GB (1024ULL*1024*1024) | ||||
| #define SMBIOS_BASE 0xF1000 | #define SMBIOS_BASE 0xF1000 | ||||
| ▲ Show 20 Lines • Show All 529 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static int | static int | ||||
| smbios_type1_initializer(struct smbios_structure *template_entry, | smbios_type1_initializer(struct smbios_structure *template_entry, | ||||
| const char **template_strings, char *curaddr, char **endaddr, | const char **template_strings, char *curaddr, char **endaddr, | ||||
| uint16_t *n, uint16_t *size) | uint16_t *n, uint16_t *size) | ||||
| { | { | ||||
| struct smbios_table_type1 *type1; | struct smbios_table_type1 *type1; | ||||
| const char *guest_uuid_str; | |||||
| smbios_generic_initializer(template_entry, template_strings, | smbios_generic_initializer(template_entry, template_strings, | ||||
| curaddr, endaddr, n, size); | curaddr, endaddr, n, size); | ||||
| type1 = (struct smbios_table_type1 *)curaddr; | type1 = (struct smbios_table_type1 *)curaddr; | ||||
| guest_uuid_str = get_config_value("uuid"); | |||||
| if (guest_uuid_str != NULL) { | if (guest_uuid_str != NULL) { | ||||
| uuid_t uuid; | uuid_t uuid; | ||||
| uint32_t status; | uint32_t status; | ||||
| uuid_from_string(guest_uuid_str, &uuid, &status); | uuid_from_string(guest_uuid_str, &uuid, &status); | ||||
| if (status != uuid_s_ok) | if (status != uuid_s_ok) | ||||
| return (-1); | return (-1); | ||||
| uuid_enc_le(&type1->uuid, &uuid); | uuid_enc_le(&type1->uuid, &uuid); | ||||
| } else { | } else { | ||||
| MD5_CTX mdctx; | MD5_CTX mdctx; | ||||
| u_char digest[16]; | u_char digest[16]; | ||||
| char hostname[MAXHOSTNAMELEN]; | char hostname[MAXHOSTNAMELEN]; | ||||
| const char *vmname; | |||||
| /* | /* | ||||
| * Universally unique and yet reproducible are an | * Universally unique and yet reproducible are an | ||||
| * oxymoron, however reproducible is desirable in | * oxymoron, however reproducible is desirable in | ||||
| * this case. | * this case. | ||||
| */ | */ | ||||
| if (gethostname(hostname, sizeof(hostname))) | if (gethostname(hostname, sizeof(hostname))) | ||||
| return (-1); | return (-1); | ||||
| MD5Init(&mdctx); | MD5Init(&mdctx); | ||||
| vmname = get_config_value("name"); | |||||
| MD5Update(&mdctx, vmname, strlen(vmname)); | MD5Update(&mdctx, vmname, strlen(vmname)); | ||||
| MD5Update(&mdctx, hostname, sizeof(hostname)); | MD5Update(&mdctx, hostname, sizeof(hostname)); | ||||
| MD5Final(digest, &mdctx); | MD5Final(digest, &mdctx); | ||||
| /* | /* | ||||
| * Set the variant and version number. | * Set the variant and version number. | ||||
| */ | */ | ||||
| digest[6] &= 0x0F; | digest[6] &= 0x0F; | ||||
| ▲ Show 20 Lines • Show All 237 Lines • Show Last 20 Lines | |||||