Page MenuHomeFreeBSD

Only try to retrieve UUID from SMBIOS on x86 machines
Needs ReviewPublic

Authored by lwhsu on Nov 6 2020, 9:40 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jan 10, 4:24 PM
Unknown Object (File)
Sat, Jan 10, 3:12 PM
Unknown Object (File)
Sat, Jan 10, 4:38 AM
Unknown Object (File)
Dec 3 2025, 9:35 PM
Unknown Object (File)
Nov 17 2025, 11:44 AM
Unknown Object (File)
Nov 3 2025, 5:41 AM
Unknown Object (File)
Oct 19 2025, 6:12 PM
Unknown Object (File)
Sep 22 2025, 12:36 PM

Details

Reviewers
jhb
linimon
olce
Summary

This is a new version of D9384, updated with jhb's suggestion and patch against
the new location of hostid file.

Proposed commit message:

Only try to retrieve UUID from SMBIOS on x86 machines

This prevents an useless warning message on non-x86 machines.

Also rename hostid_hardware() to hostid_smbios() to reflect what it actually
does.  In the future we may introduce more hostid_foo functions to obtain UUID
from firmware on other platforms.

Original work by: linimon

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 34664
Build 31733: arc lint + arc unit

Event Timeline

lwhsu requested review of this revision.Nov 6 2020, 9:40 AM

Server-class arm64 machines also have SMBIOS data present. Maybe just condition the actual warning print to amd64 | i386 but try it everywhere?

I agree with Val. I think hostid_smbios() should always be called, and if it returns nothing, then a warning should be printed for i386/amd64 only (and then uuidgen run on all platforms of course). I don't really know the situation for arm64, but if embedded systems do not have it, it's better not to print the warning (unless there is another reliable mean to discriminate between these systems and server-class ones).

Otherwise, looks good.

libexec/rc/rc.d/hostid
103

I'd suggest this rename as to clarify the provenance of the SMBIOS information. We indeed have smbios(4) in the kernel also, but it does almost nothing and does not export any information (for the time being).

I would maybe structure this so that both hostid_set and uuidgen are only called in one place by first focusing on obtaining or generating the UUID and then setting it, so something like:

hostid_generate()
{
    uuid=`hostid_smbios`

    # in the future other hostid_foo methods could be invoked

    if [ -z "${uuid}" ]; then
        case $_arch in
        amd64 | i386)
            warn "hostid: unable to obtain UUID from firmware, generating a new one"
            sleep 2
        esac

        uuid=`uuidgen` 
    fi

    hostid_set $uuid
}
libexec/rc/rc.d/hostid
103

I think it's perhaps most relevant to denote the source of the hostid which in this case is the SMBIOS table (and would be the same value no matter which method is used to read the hostid from the SMBIOS table).

In D27113#1125261, @jhb wrote:

I would maybe structure this so that both hostid_set and uuidgen are only called in one place by first focusing on obtaining or generating the UUID and then setting it, so something like:

Would be great, yes.

libexec/rc/rc.d/hostid
103

Mmm... Right. We could just modify hostid_smbios() to try various methods then.