From: Gildas <gildas.ml@gmail.com>
To: qemu-devel@nongnu.org
Cc: Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [Qemu-devel] [PATCH] allow bootdevice change from the monitor [v2]
Date: Fri, 25 Apr 2008 15:03:22 +0200 [thread overview]
Message-ID: <b2ace7f20804250603x525728fdpa48366c2c5513de1@mail.gmail.com> (raw)
This patch allows changing the boot device from within the monitor.
For v2, remarks from Aurelien were taken in account and a small
description is added to the documentation,
Signed-off-by: Gildas Le Nadan <3ntr0p13@gmail.com>
diff -Nur -x .svn qemu/trunk/hw/pc.c b/hw/pc.c
--- qemu/trunk/hw/pc.c 2008-04-25 13:57:40.000000000 +0200
+++ b/hw/pc.c 2008-04-25 13:54:15.000000000 +0200
@@ -189,6 +189,33 @@
return 0;
}
+/* copy/pasted from cmos_init, should be made a general function
+ and used there as well */
+int pc_set_bootdevice(const char *boot_device)
+{
+#define PC_MAX_BOOT_DEVICES 3
+ RTCState *s = rtc_state;
+ int nbds, bds[3] = { 0, };
+ int i;
+
+ nbds = strlen(boot_device);
+ if (nbds > PC_MAX_BOOT_DEVICES) {
+ term_printf("Too many boot devices for PC\n");
+ return(1);
+ }
+ for (i = 0; i < nbds; i++) {
+ bds[i] = boot_device2nibble(boot_device[i]);
+ if (bds[i] == 0) {
+ term_printf("Invalid boot device for PC: '%c'\n",
+ boot_device[i]);
+ return(1);
+ }
+ }
+ rtc_set_memory(s, 0x3d, (bds[1] << 4) | bds[0]);
+ rtc_set_memory(s, 0x38, (bds[2] << 4));
+ return(0);
+}
+
/* hd_table must contain 4 block drivers */
static void cmos_init(int ram_size, const char *boot_device,
BlockDriverState **hd_table)
{
@@ -698,6 +725,8 @@
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
BlockDriverState *fd[MAX_FD];
+ set_bootdevice_fct = pc_set_bootdevice;
+
linux_boot = (kernel_filename != NULL);
/* init CPUs */
diff -Nur -x .svn qemu/trunk/monitor.c b/monitor.c
--- qemu/trunk/monitor.c 2008-04-25 13:57:42.000000000 +0200
+++ b/monitor.c 2008-04-25 13:55:54.000000000 +0200
@@ -1019,6 +1019,21 @@
suffix, addr, size * 2, val);
}
+static void do_bootdevice_set(const char *bootdevice)
+{
+ int res;
+
+ if (set_bootdevice_fct != NULL) {
+ res = set_bootdevice_fct(bootdevice);
+ if (res == 0)
+ term_printf("boot device list now set to %s\n", bootdevice);
+ else
+ term_printf("setting boot device list failed with error
%i\n", res);
+ } else {
+ term_printf("no function defined to set boot device list for
this architecture\n");
+ }
+}
+
static void do_system_reset(void)
{
qemu_system_reset_request();
@@ -1356,6 +1371,8 @@
"addr size file", "save to disk virtual memory dump starting at
'addr' of size 'size'", },
{ "pmemsave", "lis", do_physical_memory_save,
"addr size file", "save to disk physical memory dump starting
at 'addr' of size 'size'", },
+ { "boot_set", "s", do_bootdevice_set,
+ "bootdevice", "define new values for the boot device list" },
{ NULL, NULL, },
};
diff -Nur -x .svn qemu/trunk/qemu-doc.texi b/qemu-doc.texi
--- qemu/trunk/qemu-doc.texi 2008-04-25 13:57:42.000000000 +0200
+++ b/qemu-doc.texi 2008-04-25 13:54:15.000000000 +0200
@@ -1253,6 +1253,14 @@
Reset the system.
+@item boot_set @var{bootdevicelist}
+
+Define new values for the boot device list. Those values will override
+the values specified on the command line through the @code{-boot} option.
+
+The values that can be specified here depend on the machine type, but are
+the same that can be specified in the @code{-boot} command line option.
+
@item usb_add @var{devname}
Add the USB device @var{devname}. For details of available devices see
diff -Nur -x .svn qemu/trunk/sysemu.h b/sysemu.h
--- qemu/trunk/sysemu.h 2008-04-25 13:57:42.000000000 +0200
+++ b/sysemu.h 2008-04-25 13:54:15.000000000 +0200
@@ -9,6 +9,11 @@
extern int vm_running;
extern const char *qemu_name;
+/* handler to set the boot_device for a specific type of QEMUMachine */
+/* return 0 if success */
+typedef int QEMUMachineSetBootFunc(const char *boot_device);
+extern QEMUMachineSetBootFunc *set_bootdevice_fct;
+
typedef struct vm_change_state_entry VMChangeStateEntry;
typedef void VMChangeStateHandler(void *opaque, int running);
typedef void VMStopHandler(void *opaque, int reason);
diff -Nur -x .svn qemu/trunk/vl.c b/vl.c
--- qemu/trunk/vl.c 2008-04-25 13:57:42.000000000 +0200
+++ b/vl.c 2008-04-25 13:54:15.000000000 +0200
@@ -237,6 +237,7 @@
const char *file;
char opt[1024];
} drives_opt[MAX_DRIVES];
+QEMUMachineSetBootFunc *set_bootdevice_fct;
static CPUState *cur_cpu;
static CPUState *next_cpu;
reply other threads:[~2008-04-25 13:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b2ace7f20804250603x525728fdpa48366c2c5513de1@mail.gmail.com \
--to=gildas.ml@gmail.com \
--cc=aurelien@aurel32.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).