mirror of https://github.com/xemu-project/xemu.git
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>
This commit is contained in:
parent
ef3adf68f8
commit
76e30d0f13
5
hw/hw.h
5
hw/hw.h
|
@ -262,9 +262,10 @@ typedef void QEMUResetHandler(void *opaque);
|
||||||
|
|
||||||
void qemu_register_reset(QEMUResetHandler *func, void *opaque);
|
void qemu_register_reset(QEMUResetHandler *func, void *opaque);
|
||||||
|
|
||||||
/* handler to set the boot_device for a specific type of QEMUMachine */
|
/* handler to set the boot_device order for a specific type of QEMUMachine */
|
||||||
/* return 0 if success */
|
/* return 0 if success */
|
||||||
typedef int QEMUBootSetHandler(void *opaque, const char *boot_device);
|
typedef int QEMUBootSetHandler(void *opaque, const char *boot_devices);
|
||||||
void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque);
|
void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque);
|
||||||
|
int qemu_boot_set(const char *boot_devices);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
23
monitor.c
23
monitor.c
|
@ -1185,28 +1185,15 @@ static void do_ioport_read(Monitor *mon, int count, int format, int size,
|
||||||
suffix, addr, size * 2, val);
|
suffix, addr, size * 2, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* boot_set handler */
|
|
||||||
static QEMUBootSetHandler *qemu_boot_set_handler = NULL;
|
|
||||||
static void *boot_opaque;
|
|
||||||
|
|
||||||
void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque)
|
|
||||||
{
|
|
||||||
qemu_boot_set_handler = func;
|
|
||||||
boot_opaque = opaque;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void do_boot_set(Monitor *mon, const char *bootdevice)
|
static void do_boot_set(Monitor *mon, const char *bootdevice)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (qemu_boot_set_handler) {
|
res = qemu_boot_set(bootdevice);
|
||||||
res = qemu_boot_set_handler(boot_opaque, bootdevice);
|
if (res == 0) {
|
||||||
if (res == 0)
|
monitor_printf(mon, "boot device list now set to %s\n", bootdevice);
|
||||||
monitor_printf(mon, "boot device list now set to %s\n",
|
} else if (res > 0) {
|
||||||
bootdevice);
|
monitor_printf(mon, "setting boot device list failed\n");
|
||||||
else
|
|
||||||
monitor_printf(mon, "setting boot device list failed with "
|
|
||||||
"error %i\n", res);
|
|
||||||
} else {
|
} else {
|
||||||
monitor_printf(mon, "no function defined to set boot device list for "
|
monitor_printf(mon, "no function defined to set boot device list for "
|
||||||
"this architecture\n");
|
"this architecture\n");
|
||||||
|
|
17
vl.c
17
vl.c
|
@ -274,6 +274,9 @@ static QEMUTimer *nographic_timer;
|
||||||
|
|
||||||
uint8_t qemu_uuid[16];
|
uint8_t qemu_uuid[16];
|
||||||
|
|
||||||
|
static QEMUBootSetHandler *boot_set_handler;
|
||||||
|
static void *boot_set_opaque;
|
||||||
|
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
/* x86 ISA bus support */
|
/* x86 ISA bus support */
|
||||||
|
|
||||||
|
@ -2356,6 +2359,20 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque)
|
||||||
return drives_table_idx;
|
return drives_table_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque)
|
||||||
|
{
|
||||||
|
boot_set_handler = func;
|
||||||
|
boot_set_opaque = opaque;
|
||||||
|
}
|
||||||
|
|
||||||
|
int qemu_boot_set(const char *boot_devices)
|
||||||
|
{
|
||||||
|
if (!boot_set_handler) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
return boot_set_handler(boot_set_opaque, boot_devices);
|
||||||
|
}
|
||||||
|
|
||||||
static int parse_bootdevices(char *devices)
|
static int parse_bootdevices(char *devices)
|
||||||
{
|
{
|
||||||
/* We just do some generic consistency checks */
|
/* We just do some generic consistency checks */
|
||||||
|
|
Loading…
Reference in New Issue