[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240730094831.882166-2-bchalios@amazon.es>
Date: Tue, 30 Jul 2024 11:48:31 +0200
From: Babis Chalios <bchalios@...zon.es>
To: <tytso@....edu>, <Jason@...c4.com>, <linux-kernel@...r.kernel.org>
CC: <graf@...zon.de>, <mzxreary@...inter.de>, <xmarcalx@...zon.co.uk>,
<gregkh@...uxfoundation.org>, Babis Chalios <bchalios@...zon.es>
Subject: [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.
Signed-off-by: Babis Chalios <bchalios@...zon.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
Powered by blists - more mailing lists