id128-util: use common implementation of helper to get/validate product ID

This commit is contained in:
Lennart Poettering
2021-04-29 16:39:09 +02:00
parent f813b62316
commit b4be4ff8ae
4 changed files with 35 additions and 21 deletions
+3 -9
View File
@@ -62,16 +62,10 @@ static int generate_machine_id(const char *root, sd_id128_t *ret) {
} else if (detect_vm() == VIRTUALIZATION_KVM) {
/* If we are not running in a container, see if we are
* running in qemu/kvm and a machine ID was passed in
* via -uuid on the qemu/kvm command line */
/* If we are not running in a container, see if we are running in qemu/kvm and a
* machine ID was passed in via -uuid on the qemu/kvm command line */
if (id128_read("/sys/class/dmi/id/product_uuid", ID128_UUID, ret) >= 0) {
log_info("Initializing machine ID from KVM UUID.");
return 0;
}
/* on POWER, it's exported here instead */
if (id128_read("/sys/firmware/devicetree/base/vm,uuid", ID128_UUID, ret) >= 0) {
if (id128_get_product(ret) >= 0) {
log_info("Initializing machine ID from KVM UUID.");
return 0;
}