Commit 76e30d0f13a8eb1f4dee86273b50b17b81dad9f4
Committed by
Anthony Liguori
1 parent
ef3adf68
Move boot_set callback backend
Move registration function for the boot_set callback handler and provide qemu_boot_set so that it can also be used outside the monitor code. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
3 changed files
with
25 additions
and
20 deletions
hw/hw.h
... | ... | @@ -262,9 +262,10 @@ typedef void QEMUResetHandler(void *opaque); |
262 | 262 | |
263 | 263 | void qemu_register_reset(QEMUResetHandler *func, void *opaque); |
264 | 264 | |
265 | -/* handler to set the boot_device for a specific type of QEMUMachine */ | |
265 | +/* handler to set the boot_device order for a specific type of QEMUMachine */ | |
266 | 266 | /* return 0 if success */ |
267 | -typedef int QEMUBootSetHandler(void *opaque, const char *boot_device); | |
267 | +typedef int QEMUBootSetHandler(void *opaque, const char *boot_devices); | |
268 | 268 | void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque); |
269 | +int qemu_boot_set(const char *boot_devices); | |
269 | 270 | |
270 | 271 | #endif | ... | ... |
monitor.c
... | ... | @@ -1185,28 +1185,15 @@ static void do_ioport_read(Monitor *mon, int count, int format, int size, |
1185 | 1185 | suffix, addr, size * 2, val); |
1186 | 1186 | } |
1187 | 1187 | |
1188 | -/* boot_set handler */ | |
1189 | -static QEMUBootSetHandler *qemu_boot_set_handler = NULL; | |
1190 | -static void *boot_opaque; | |
1191 | - | |
1192 | -void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque) | |
1193 | -{ | |
1194 | - qemu_boot_set_handler = func; | |
1195 | - boot_opaque = opaque; | |
1196 | -} | |
1197 | - | |
1198 | 1188 | static void do_boot_set(Monitor *mon, const char *bootdevice) |
1199 | 1189 | { |
1200 | 1190 | int res; |
1201 | 1191 | |
1202 | - if (qemu_boot_set_handler) { | |
1203 | - res = qemu_boot_set_handler(boot_opaque, bootdevice); | |
1204 | - if (res == 0) | |
1205 | - monitor_printf(mon, "boot device list now set to %s\n", | |
1206 | - bootdevice); | |
1207 | - else | |
1208 | - monitor_printf(mon, "setting boot device list failed with " | |
1209 | - "error %i\n", res); | |
1192 | + res = qemu_boot_set(bootdevice); | |
1193 | + if (res == 0) { | |
1194 | + monitor_printf(mon, "boot device list now set to %s\n", bootdevice); | |
1195 | + } else if (res > 0) { | |
1196 | + monitor_printf(mon, "setting boot device list failed\n"); | |
1210 | 1197 | } else { |
1211 | 1198 | monitor_printf(mon, "no function defined to set boot device list for " |
1212 | 1199 | "this architecture\n"); | ... | ... |
vl.c
... | ... | @@ -274,6 +274,9 @@ static QEMUTimer *nographic_timer; |
274 | 274 | |
275 | 275 | uint8_t qemu_uuid[16]; |
276 | 276 | |
277 | +static QEMUBootSetHandler *boot_set_handler; | |
278 | +static void *boot_set_opaque; | |
279 | + | |
277 | 280 | /***********************************************************/ |
278 | 281 | /* x86 ISA bus support */ |
279 | 282 | |
... | ... | @@ -2356,6 +2359,20 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) |
2356 | 2359 | return drives_table_idx; |
2357 | 2360 | } |
2358 | 2361 | |
2362 | +void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque) | |
2363 | +{ | |
2364 | + boot_set_handler = func; | |
2365 | + boot_set_opaque = opaque; | |
2366 | +} | |
2367 | + | |
2368 | +int qemu_boot_set(const char *boot_devices) | |
2369 | +{ | |
2370 | + if (!boot_set_handler) { | |
2371 | + return -EINVAL; | |
2372 | + } | |
2373 | + return boot_set_handler(boot_set_opaque, boot_devices); | |
2374 | +} | |
2375 | + | |
2359 | 2376 | static int parse_bootdevices(char *devices) |
2360 | 2377 | { |
2361 | 2378 | /* We just do some generic consistency checks */ | ... | ... |