Notify system services about VM clones
cover Notify system services about VM clones
Hi Jason,
This is a rebase of the previous patch[1] that enabled VMGenID to send a uevent notification to user space. I have rebased it on top of current Linus's master branch, which includes the changes to add DT support to VMGenID, and fixed the conflicts.
The simple problem this solves is sending a notification to user space services, like networkd et al, chrony, etc., that they are now working on a new VM. The former would do things like refresh DHCP leases, the latter would reset the system's clock to current date and time. This is a problem quite common in the VM world. Apart from us, systemd folks have chimed in the past with their use-cases[2][3].
Previously, you have mentioned that you envision this being handled by random.c due to the fact that it receives such events from a variety of devices[4][5], hence it should be the one dispatching the notification to user space.
I am resending this because I believe the above rationale is conflating two different events, i.e. "you have stale entropy" and "your VM has been cloned". The latter implies the former, but there are use cases other than reseeding PRNGs; some of them I mentioned earlier in this cover letter. In practical terms, we should not regenerate MAC addresses whenever we need to reseed our PRNGs. And I simply cannot think of any other device that could trigger an effect on networkd, chrony, etc, similar to the one VMGenID updates do.
I am really interested in your thoughts on this and, ultimately, I hope we can have a technical discussion on the arguments above and try to find the best solution for the problem at hand.
Cheers,
Babis
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/ZieoRxn-On0gD-H2@gardel-login/
[3] https://lore.kernel.org/lkml/ZJGNREN4tLzQXOJr@gardel-login/
[4] https://lore.kernel.org/lkml/CAHmME9pVLD-U+iYfv7=HBufRtaSkBmCRpKLH8pbvPNkgozE3cg@mail.gmail.com/
[5] https://lore.kernel.org/lkml/[email protected]/
Babis Chalios (1):
vmgenid: emit uevent with new generation ID
drivers/virt/vmgenid.c | 2 ++ 1 file changed, 2 insertions(+)
Signature · 1 line
2.34.1
PATCH 1/1 vmgenid: emit uevent with new generation ID
There are many system services that need to be notified when the VM they are running in is resumed from a snapshot. One example are network managers which need to renew DHCP leases and/or re-create MAC addresses for virtual interfaces. Other example are daemons that manage system clocks which need reset upon snapshot resume.
Send a uevent notification to user space from the VMGenID driver when we receive the ACPI notification about a new generation ID. This way, we notify user space software about the VM cloning event and give it a chance to adapt to the new environment.
--- drivers/virt/vmgenid.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/virt/vmgenid.c +2 -0
@@ -26,6 +26,7 @@ struct vmgenid_state {static void vmgenid_notify (struct device *device) {struct vmgenid_state *state = device->driver_data; +char *envp[] = {"NEW_VMGENID=1" ,NULL };u8 old_id[VMGENID_SIZE ];memcpy (old_id, state->this_id,sizeof (old_id));
@@ -33,6 +34,7 @@ static void vmgenid_notify(struct device *device)if (!memcmp (old_id, state->this_id,sizeof (old_id)))return ;add_vmfork_randomness (state->this_id,sizeof (state->this_id)); +kobject_uevent_env (&device->kobj,KOBJ_CHANGE , envp); }static void setup_vmgenid_state (struct vmgenid_state *state,void *virt_addr)
Signature · 1 line
2.34.1
Re: [PATCH 1/1] vmgenid: emit uevent with new generation ID
Quoted 11 lines · Babis Chalios
There are many system services that need to be notified when the VM they are running in is resumed from a snapshot. One example are network managers which need to renew DHCP leases and/or re-create MAC addresses for virtual interfaces. Other example are daemons that manage system clocks which need reset upon snapshot resume.
Send a uevent notification to user space from the VMGenID driver when we receive the ACPI notification about a new generation ID. This way, we notify user space software about the VM cloning event and give it a chance to adapt to the new environment.
Quoted 4 lines
Signed-off-by Babis Chalios <[email protected]>--- drivers/virt/vmgenid.c | 2 ++ 1 file changed, 2 insertions(+)
Speaking as a systemd maintainer, this is precisely what we need for systemd-networkd and systemd-timesyncd, thanks for taking care of this.
Signature · 2 lines
Kind regards, Luca Boccassi