fix regression: remove dependency on dmidecode

Bug #1900753 reported by Mina Galić
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Undecided
Mina Galić

Bug Description

When we extended ds-identify to use dmidecode, we made it x86-only, which is the platforms that dmidecode supports (on FreeBSD): https://github.com/freebsd/freebsd-ports/commit/ea408d31b8d9d3b3bac932f8c351d2e883070e6b

it would be good if we could "fix" that, by removing our dependency on dmidecode, and instead use kenv(1) https://www.freebsd.org/cgi/man.cgi?kenv

Changed in cloud-init:
status: New → Triaged
Revision history for this message
Scott Moser (smoser) wrote :

We don't strictly have a dependency on dmidecode.
ds-identify will only try dmidecode if values in /sys/class/dmi/id/ are not present. That is desirable, as reading files from /sys is orders of magnitude faster than invoking a program to do the same.

I think calling kenv on freebsd would be fine.

something like this:

diff --git a/tools/ds-identify b/tools/ds-identify
index 4e5700fc6..7019b757d 100755
--- a/tools/ds-identify
+++ b/tools/ds-identify
@@ -198,6 +198,11 @@ dmi_decode() {
     _RET="$val"
 }

+read_kenv() {
+ # left as an excersize to the reader.
+ :
+}
+
 get_dmi_field() {
     local path="${PATH_SYS_CLASS_DMI_ID}/$1"
     _RET="$UNAVAILABLE"
@@ -210,7 +215,10 @@ get_dmi_field() {
         # do *not* fallback to dmidecode!
         return
     fi
- dmi_decode "$1" || _RET="$ERROR"
+ case "$DI_UNAME_KERNEL_NAME" in
+ FreeBSD) read_kenv "$1" || _RET="$ERROR";;
+ *) dmi_decode "$1" || _RET="$ERROR"
+ esac
     return
 }

Revision history for this message
Mina Galić (minagalic) wrote :

leaving an example from an Azure vm here for safekeeping

smbios.bios.reldate="06/02/2017"
smbios.bios.vendor="American Megatrends Inc."
smbios.bios.version="090007 "
smbios.chassis.maker="Microsoft Corporation"
smbios.chassis.serial="0294-2963-9005-7688-4363-4003-04"
smbios.chassis.tag="7783-7084-3265-9085-8269-3286-77"
smbios.chassis.version="7.0"
smbios.memory.enabled="16777216"
smbios.planar.location=""
smbios.planar.maker="Microsoft Corporation"
smbios.planar.product="Virtual Machine"
smbios.planar.serial="0000-0009-9589-8832-9763-2029-02"
smbios.planar.tag=""
smbios.planar.version="7.0"
smbios.socket.enabled="4"
smbios.socket.populated="4"
smbios.system.maker="Microsoft Corporation"
smbios.system.product="Virtual Machine"
smbios.system.serial="0000-0014-1815-7361-2091-5586-34"
smbios.system.uuid="1012cfc4-c520-ea4a-8a35-6f1ef5cbe756"
smbios.system.version="7.0"
smbios.version="2.3"

thanks to kevans91 from the FreeBSD community for providing this

Revision history for this message
Mina Galić (minagalic) wrote :

n.b.: I have started a PR here: https://github.com/canonical/cloud-init/pull/621

James Falcon (falcojr)
Changed in cloud-init:
assignee: nobody → Mina Galić (minagalic)
Mina Galić (minagalic)
Changed in cloud-init:
status: Triaged → In Progress
Revision history for this message
Ed Maste (emaste) wrote :

Pull request was merged

Revision history for this message
James Falcon (falcojr) wrote :

Thanks Ed. Yes, this was fixed with https://github.com/canonical/cloud-init/pull/621 and released in upstream 20.4.

Changed in cloud-init:
status: In Progress → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.