Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 533c9a0

Browse files
committed
Attempt harder to obtain config-drive.
There are some cases where a config-drive is on the system, but not initially detected early at boot. One such case is when the cdrom subsystem isn't builtin to the kernel but enabled as a module. We can try and catch this issue. It will slow down boot a bit, so this only waits 1 second total for now. But modprobing `sr_mod` which depends on `cdrom` is a good start here, and covers obtaining the `meda_data.json` file in case a VM is booted with the -native or other non-kvm kernels.
1 parent ca976ef commit 533c9a0

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

src/datasources/openstack.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,26 @@ bool openstack_init() {
136136

137137
data_source = SOURCE_NONE;
138138

139-
if (disk_by_label("config-2", &device)) {
140-
data_source = SOURCE_CONFIG_DRIVE;
141-
g_strlcpy(config_drive_disk, device, PATH_MAX);
142-
g_free(device);
143-
return true;
139+
for (int tries = 0; tries < 8; tries++) {
140+
if (disk_by_label("config-2", &device)) {
141+
data_source = SOURCE_CONFIG_DRIVE;
142+
g_strlcpy(config_drive_disk, device, PATH_MAX);
143+
g_free(device);
144+
return true;
145+
}
146+
147+
/*
148+
* In case of a VM image with module for cdrom+sr_mod,
149+
* trigger modprobe to reveal config drive, once.
150+
*/
151+
if (tries == 0) {
152+
system("/sbin/modprobe sr_mod");
153+
}
154+
155+
usleep((1 << tries) * 4000);
156+
157+
if (tries > 8)
158+
break;
144159
}
145160

146161
LOG(MOD "config drive was not found\n");

0 commit comments

Comments
 (0)