Index: usr.sbin/bhyve/bhyverun.h =================================================================== --- usr.sbin/bhyve/bhyverun.h +++ usr.sbin/bhyve/bhyverun.h @@ -37,7 +37,6 @@ struct vmctx; extern int guest_ncpus; extern uint16_t cores, sockets, threads; -extern char *guest_uuid_str; extern const char *vmname; void *paddr_guest2host(struct vmctx *ctx, uintptr_t addr, size_t len); Index: usr.sbin/bhyve/bhyverun.c =================================================================== --- usr.sbin/bhyve/bhyverun.c +++ usr.sbin/bhyve/bhyverun.c @@ -69,6 +69,7 @@ #include #include #include +#include #ifdef BHYVE_SNAPSHOT #include #include @@ -188,7 +189,7 @@ int guest_ncpus; uint16_t cores, maxcpus, sockets, threads; -char *guest_uuid_str; +uuid_t guest_uuid; int raw_stdio = 0; @@ -1106,6 +1107,8 @@ rtc_localtime = 1; memflags = 0; + uuid_create_nil(guest_uuid, NULL); + #ifdef BHYVE_SNAPSHOT optstr = "aehuwxACDHIPSWYp:G:c:s:m:l:U:r:"; #else @@ -1196,7 +1199,10 @@ rtc_localtime = 0; break; case 'U': - guest_uuid_str = optarg; + uuid_from_string(optarg, &guest_uuid, &error); + if (error != uuid_s_ok) { + errx(EX_USAGE, "invalid UUID '%s'", optarg); + } break; case 'w': strictmsr = 0; Index: usr.sbin/bhyve/smbiostbl.c =================================================================== --- usr.sbin/bhyve/smbiostbl.c +++ usr.sbin/bhyve/smbiostbl.c @@ -544,6 +544,8 @@ static uint64_t guest_lomem, guest_himem; static uint16_t type16_handle; +extern uuid_t guest_uuid; + static int smbios_generic_initializer(struct smbios_structure *template_entry, const char **template_strings, char *curaddr, char **endaddr, @@ -593,15 +595,8 @@ curaddr, endaddr, n, size); type1 = (struct smbios_table_type1 *)curaddr; - if (guest_uuid_str != NULL) { - uuid_t uuid; - uint32_t status; - - uuid_from_string(guest_uuid_str, &uuid, &status); - if (status != uuid_s_ok) - return (-1); - - uuid_enc_le(&type1->uuid, &uuid); + if (! uuid_is_nil(&guest_uuid, NULL)) { + uuid_enc_le(&type1->uuid, &guest_uuid); } else { MD5_CTX mdctx; u_char digest[16];