Conversation
`-uuid` makes the /sys/class/dmi/id/product_uuid present in the VM which is required by some tools. Closes: #2586 Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4733 +/- ##
==========================================
+ Coverage 87.65% 87.65% +0.01%
==========================================
Files 258 258
Lines 14124 14126 +2
==========================================
+ Hits 12379 12381 +2
Misses 1745 1745 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| else | ||
| { | ||
| // The UUID needs to be unique per VM and must be consistent across boots. | ||
| const auto vm_uuid = utils::make_uuid(desc.vm_name); |
There was a problem hiding this comment.
A few questions regarding effects on clones:
- Since their name changes from the original, clones get a new UUID, correct?
- Is that compatible with pre-existing disk contents in typical scenarios where this is relevant?
- We cause cloud-init to rerun when cloning. Is that typically enough to cascade the UUID wherever relevant?
There was a problem hiding this comment.
Since their name changes from the original, clones get a new UUID, correct?
Yes. It should be treated as any other instance-unique field.
Is that compatible with pre-existing disk contents in typical scenarios where this is relevant?
Yes, it is abstracted from the disk contents. In reality, it's a hardware serial-like info burned into the BIOS by the manufacturer. No disk involvement at all.
We cause cloud-init to rerun when cloning. Is that typically enough to cascade the UUID wherever relevant?
The /sys/class/dmi/id/product_uuid file is immediately available to queries without cloud-init to be re-run.
| // Cloud-init disk | ||
| args << "-cdrom" << desc.cloud_init_iso; | ||
| // To make `/sys/class/dmi/id/product_uuid` present | ||
| args << "-uuid" << vm_uuid; |
There was a problem hiding this comment.
To implement instance renaming, we'll probably want to keep the UUID stable. We'd probably save it along with other instance metadata, right? Do you foresee any impediment doing that? Just to be sure.
There was a problem hiding this comment.
We'd probably save it along with other instance metadata, right?
That should be sufficient if we update the UUID on clone. I can't think of any potential gotchas on that.
There was a problem hiding this comment.
This covers only the QEMU backend. What happens in other backends? Is a name-based UUID available in the new Hyper-V and AppleVZ today? If not, that's probably worth some wider team awareness and synchronizing.
There was a problem hiding this comment.
It should be available for all off-the-shelf hypervisors already -- the existing hyper-v implementation already does that:
ubuntu@test-vm-3:~$ sudo cat /sys/class/dmi/id/product_uuid
e190e5e1-6261-40ca-a806-1a197a1d4ca0
I don't know the specifics for Apple VZ, but I think there should be a way to set it, as it's a pretty common thing for hypervisors to do. https://developer.apple.com/documentation/virtualization/vzgenericmachineidentifier looks promising, maybe @sharder996 could confirm that. I'll check the new Hyper-V implementation to make sure that it's still available.
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
-uuidmakes the /sys/class/dmi/id/product_uuid present in the VM which is required by some tools.Closes: #2586
Description
-uuidparameter generated from the VM name to the QEMU args./sys/class/dmi/id/product_uuidto be present on the VM, which is possible via passing the-uuidflag to the QEMU process.Related Issue(s)
Closes #2586
Testing
Manual testing steps:
main, launch a VM in either Linux or macOS with the QEMU backend, and observe that the/sys/class/dmi/id/product_uuidis missing on the VMs/sys/class/dmi/id/product_uuidis present./sys/class/dmi/id/product_uuidvalue does not change./sys/class/dmi/id/product_uuidvalue is different from the launched VM in step 2.Screenshots (if applicable)
Checklist
Additional Notes
MULTI-2507