[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/7] Move boot_set callback backend
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [PATCH 2/7] Move boot_set callback backend |
Date: |
Thu, 02 Jul 2009 00:19:02 +0200 |
User-agent: |
StGIT/0.14.3 |
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 <address@hidden>
---
hw/hw.h | 5 +++--
monitor.c | 23 +++++------------------
vl.c | 17 +++++++++++++++++
3 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/hw/hw.h b/hw/hw.h
index 2e43c1f..0f1ef98 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -261,10 +261,11 @@ typedef void QEMUResetHandler(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 */
-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);
+int qemu_boot_set(const char *boot_devices);
/* These should really be in isa.h, but are here to make pc.h happy. */
typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data);
diff --git a/monitor.c b/monitor.c
index bad79fe..fedc04e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1185,28 +1185,15 @@ static void do_ioport_read(Monitor *mon, int count, int
format, int size,
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)
{
int res;
- if (qemu_boot_set_handler) {
- res = qemu_boot_set_handler(boot_opaque, bootdevice);
- if (res == 0)
- monitor_printf(mon, "boot device list now set to %s\n",
- bootdevice);
- else
- monitor_printf(mon, "setting boot device list failed with "
- "error %i\n", res);
+ res = qemu_boot_set(bootdevice);
+ if (res == 0) {
+ monitor_printf(mon, "boot device list now set to %s\n", bootdevice);
+ } else if (res > 0) {
+ monitor_printf(mon, "setting boot device list failed\n");
} else {
monitor_printf(mon, "no function defined to set boot device list for "
"this architecture\n");
diff --git a/vl.c b/vl.c
index 057037a..9f1c9db 100644
--- a/vl.c
+++ b/vl.c
@@ -288,6 +288,9 @@ static QEMUTimer *nographic_timer;
uint8_t qemu_uuid[16];
+static QEMUBootSetHandler *boot_set_handler;
+static void *boot_set_opaque;
+
/***********************************************************/
/* x86 ISA bus support */
@@ -2569,6 +2572,20 @@ int drive_init(struct drive_opt *arg, int snapshot, void
*opaque)
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)
{
/* We just do some generic consistency checks */
- [Qemu-devel] [PATCH 0/7] Rework -boot option, Jan Kiszka, 2009/07/01
- [Qemu-devel] [PATCH 5/7] Add boot-once support, Jan Kiszka, 2009/07/01
- [Qemu-devel] [PATCH 6/7] Add boot menu control via command line switch, Jan Kiszka, 2009/07/01
- [Qemu-devel] [PATCH 3/7] Rework reset handler management, Jan Kiszka, 2009/07/01
- [Qemu-devel] [PATCH 7/7] Update boot option documentation, Jan Kiszka, 2009/07/01
- [Qemu-devel] [PATCH 4/7] Add qemu_unregister_reset, Jan Kiszka, 2009/07/01
- [Qemu-devel] [PATCH 1/7] Rework -boot option, Jan Kiszka, 2009/07/10
- [Qemu-devel] [PATCH 2/7] Move boot_set callback backend,
Jan Kiszka <=