* [PATCH 0/1] Notify system services about VM clones
@ 2024-07-30 9:48 Babis Chalios
2024-07-30 9:48 ` [PATCH 1/1] vmgenid: emit uevent with new generation ID Babis Chalios
0 siblings, 1 reply; 3+ messages in thread
From: Babis Chalios @ 2024-07-30 9:48 UTC (permalink / raw)
To: tytso, Jason, linux-kernel
Cc: graf, mzxreary, xmarcalx, gregkh, Babis Chalios
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/20230531095119.11202-1-bchalios@amazon.es/
[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/Ziujox51oPzZmwzA@zx2c4.com/
Babis Chalios (1):
vmgenid: emit uevent with new generation ID
drivers/virt/vmgenid.c | 2 ++
1 file changed, 2 insertions(+)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/1] vmgenid: emit uevent with new generation ID
2024-07-30 9:48 [PATCH 0/1] Notify system services about VM clones Babis Chalios
@ 2024-07-30 9:48 ` Babis Chalios
2024-07-30 11:32 ` Luca Boccassi
0 siblings, 1 reply; 3+ messages in thread
From: Babis Chalios @ 2024-07-30 9:48 UTC (permalink / raw)
To: tytso, Jason, linux-kernel
Cc: graf, mzxreary, xmarcalx, gregkh, 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.
Signed-off-by: Babis Chalios <bchalios@amazon.es>
---
drivers/virt/vmgenid.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/virt/vmgenid.c b/drivers/virt/vmgenid.c
index 66135eac3abff..5410620a017f5 100644
--- a/drivers/virt/vmgenid.c
+++ b/drivers/virt/vmgenid.c
@@ -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)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH 1/1] vmgenid: emit uevent with new generation ID
2024-07-30 9:48 ` [PATCH 1/1] vmgenid: emit uevent with new generation ID Babis Chalios
@ 2024-07-30 11:32 ` Luca Boccassi
0 siblings, 0 replies; 3+ messages in thread
From: Luca Boccassi @ 2024-07-30 11:32 UTC (permalink / raw)
To: Babis Chalios, tytso, Jason, linux-kernel
Cc: graf, mzxreary, xmarcalx, gregkh
On Tue, 2024-07-30 at 11:48 +0200, Babis Chalios wrote:
> 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.
>
> Signed-off-by: Babis Chalios <bchalios@amazon.es>
> ---
> 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.
Acked-by: Luca Boccassi <bluca@debian.org>
--
Kind regards,
Luca Boccassi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-30 11:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-30 9:48 [PATCH 0/1] Notify system services about VM clones Babis Chalios
2024-07-30 9:48 ` [PATCH 1/1] vmgenid: emit uevent with new generation ID Babis Chalios
2024-07-30 11:32 ` Luca Boccassi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®