diff mbox

[1/2] Make default boot order machine specific

Message ID 1350986975-21786-2-git-send-email-aviksil@linux.vnet.ibm.com
State New
Headers show

Commit Message

Avik Sil Oct. 23, 2012, 10:09 a.m. UTC
This patch makes default boot order machine specific instead of
set globally. The default boot order can be set per machine in
QEMUMachine default_machine_opts, or by the command line using
-machine <machine_name>,boot=<boot_devices>, or by standard -boot
option. This allows a machine to receive a NULL boot order when
-boot isn't used and take an appropriate action accordingly. This
helps machine boots from the devices as set in guest's non-volatile
memory location in case no boot order is provided by the user.

Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
---
 hw/nseries.c      |  2 ++
 hw/pc_piix.c      | 13 ++++++++++++-
 hw/ppc_newworld.c |  1 +
 hw/ppc_oldworld.c |  1 +
 hw/ppc_prep.c     |  1 +
 hw/sun4m.c        | 10 ++++++++++
 hw/sun4u.c        |  3 +++
 qemu-config.c     |  6 +++++-
 vl.c              | 13 +++++++++----
 9 files changed, 44 insertions(+), 6 deletions(-)

Comments

Alexander Graf Oct. 23, 2012, 10:20 a.m. UTC | #1
On 23.10.2012, at 12:09, Avik Sil wrote:

> This patch makes default boot order machine specific instead of
> set globally. The default boot order can be set per machine in
> QEMUMachine default_machine_opts, or by the command line using
> -machine <machine_name>,boot=<boot_devices>, or by standard -boot
> option. This allows a machine to receive a NULL boot order when
> -boot isn't used and take an appropriate action accordingly. This
> helps machine boots from the devices as set in guest's non-volatile
> memory location in case no boot order is provided by the user.
> 
> Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
> ---
> hw/nseries.c      |  2 ++
> hw/pc_piix.c      | 13 ++++++++++++-
> hw/ppc_newworld.c |  1 +
> hw/ppc_oldworld.c |  1 +
> hw/ppc_prep.c     |  1 +
> hw/sun4m.c        | 10 ++++++++++
> hw/sun4u.c        |  3 +++

That feels like too much magic for my taste. Can't we have some default macro (or even the explicit "cad" thing) that we push to _every_ machine description out there? The next patch to implement boot= for pseries would then remove this default value for the pseries machine.

The way the patch works right now, the "make machine specific" patch indirectly also changes the behavior for a bunch of machines.


Alex
Anthony Liguori Oct. 23, 2012, 1:24 p.m. UTC | #2
Alexander Graf <agraf@suse.de> writes:

> On 23.10.2012, at 12:09, Avik Sil wrote:
>
>> This patch makes default boot order machine specific instead of
>> set globally. The default boot order can be set per machine in
>> QEMUMachine default_machine_opts, or by the command line using
>> -machine <machine_name>,boot=<boot_devices>, or by standard -boot
>> option. This allows a machine to receive a NULL boot order when
>> -boot isn't used and take an appropriate action accordingly. This
>> helps machine boots from the devices as set in guest's non-volatile
>> memory location in case no boot order is provided by the user.
>> 
>> Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
>> ---
>> hw/nseries.c      |  2 ++
>> hw/pc_piix.c      | 13 ++++++++++++-
>> hw/ppc_newworld.c |  1 +
>> hw/ppc_oldworld.c |  1 +
>> hw/ppc_prep.c     |  1 +
>> hw/sun4m.c        | 10 ++++++++++
>> hw/sun4u.c        |  3 +++
>
> That feels like too much magic for my taste. Can't we have some
> default macro (or even the explicit "cad" thing) that we push to
> _every_ machine description out there? The next patch to implement
> boot= for pseries would then remove this default value for the pseries
> machine.

I agree, having a default macro would avoid having to touch everything
again for the next addition.

Regards,

Anthony Liguori

>
> The way the patch works right now, the "make machine specific" patch indirectly also changes the behavior for a bunch of machines.
>
>
> Alex
Alexander Graf Oct. 23, 2012, 1:28 p.m. UTC | #3
On 23.10.2012, at 15:24, Anthony Liguori wrote:

> Alexander Graf <agraf@suse.de> writes:
> 
>> On 23.10.2012, at 12:09, Avik Sil wrote:
>> 
>>> This patch makes default boot order machine specific instead of
>>> set globally. The default boot order can be set per machine in
>>> QEMUMachine default_machine_opts, or by the command line using
>>> -machine <machine_name>,boot=<boot_devices>, or by standard -boot
>>> option. This allows a machine to receive a NULL boot order when
>>> -boot isn't used and take an appropriate action accordingly. This
>>> helps machine boots from the devices as set in guest's non-volatile
>>> memory location in case no boot order is provided by the user.
>>> 
>>> Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
>>> ---
>>> hw/nseries.c      |  2 ++
>>> hw/pc_piix.c      | 13 ++++++++++++-
>>> hw/ppc_newworld.c |  1 +
>>> hw/ppc_oldworld.c |  1 +
>>> hw/ppc_prep.c     |  1 +
>>> hw/sun4m.c        | 10 ++++++++++
>>> hw/sun4u.c        |  3 +++
>> 
>> That feels like too much magic for my taste. Can't we have some
>> default macro (or even the explicit "cad" thing) that we push to
>> _every_ machine description out there? The next patch to implement
>> boot= for pseries would then remove this default value for the pseries
>> machine.
> 
> I agree, having a default macro would avoid having to touch everything
> again for the next addition.

Well, can you override a default macro? Otherwise we will convert a few machines now to a different boot order default, then add another default thing for a completely different option, and the boot order modified machines miss out the change to the macro.


Alex
David Gibson Oct. 23, 2012, 10:43 p.m. UTC | #4
On Tue, Oct 23, 2012 at 12:20:08PM +0200, Alexander Graf wrote:
> 
> On 23.10.2012, at 12:09, Avik Sil wrote:
> 
> > This patch makes default boot order machine specific instead of
> > set globally. The default boot order can be set per machine in
> > QEMUMachine default_machine_opts, or by the command line using
> > -machine <machine_name>,boot=<boot_devices>, or by standard -boot
> > option. This allows a machine to receive a NULL boot order when
> > -boot isn't used and take an appropriate action accordingly. This
> > helps machine boots from the devices as set in guest's non-volatile
> > memory location in case no boot order is provided by the user.
> > 
> > Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
> > ---
> > hw/nseries.c      |  2 ++
> > hw/pc_piix.c      | 13 ++++++++++++-
> > hw/ppc_newworld.c |  1 +
> > hw/ppc_oldworld.c |  1 +
> > hw/ppc_prep.c     |  1 +
> > hw/sun4m.c        | 10 ++++++++++
> > hw/sun4u.c        |  3 +++
> 
> That feels like too much magic for my taste. Can't we have some
> default macro (or even the explicit "cad" thing) that we push to
> _every_ machine description out there? The next patch to implement
> boot= for pseries would then remove this default value for the
> pseries machine.

I'm not 100% clear on what you mean here.  Do you just mean:
	#define DEFAULT_BOOT_ORDER	"boot=cad"
and then we use
	.default_machine_opts = DEFAULT_BOOT_ORDER,

or something else?

> The way the patch works right now, the "make machine specific" patch
> indirectly also changes the behavior for a bunch of machines.

A bunch?  I thought the only machine whose behaviour changed was
pseries.  I agree that moving the behaviour change into a separate
patch would be a better idea, but if there are machines other than
pseries with changed behaviour by this patch, then that's a plain old
bug, rather than a mere question of patch elegance.
Alexander Graf Oct. 23, 2012, 10:47 p.m. UTC | #5
On 24.10.2012, at 00:43, David Gibson wrote:

> On Tue, Oct 23, 2012 at 12:20:08PM +0200, Alexander Graf wrote:
>> 
>> On 23.10.2012, at 12:09, Avik Sil wrote:
>> 
>>> This patch makes default boot order machine specific instead of
>>> set globally. The default boot order can be set per machine in
>>> QEMUMachine default_machine_opts, or by the command line using
>>> -machine <machine_name>,boot=<boot_devices>, or by standard -boot
>>> option. This allows a machine to receive a NULL boot order when
>>> -boot isn't used and take an appropriate action accordingly. This
>>> helps machine boots from the devices as set in guest's non-volatile
>>> memory location in case no boot order is provided by the user.
>>> 
>>> Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
>>> ---
>>> hw/nseries.c      |  2 ++
>>> hw/pc_piix.c      | 13 ++++++++++++-
>>> hw/ppc_newworld.c |  1 +
>>> hw/ppc_oldworld.c |  1 +
>>> hw/ppc_prep.c     |  1 +
>>> hw/sun4m.c        | 10 ++++++++++
>>> hw/sun4u.c        |  3 +++
>> 
>> That feels like too much magic for my taste. Can't we have some
>> default macro (or even the explicit "cad" thing) that we push to
>> _every_ machine description out there? The next patch to implement
>> boot= for pseries would then remove this default value for the
>> pseries machine.
> 
> I'm not 100% clear on what you mean here.  Do you just mean:
> 	#define DEFAULT_BOOT_ORDER	"boot=cad"
> and then we use
> 	.default_machine_opts = DEFAULT_BOOT_ORDER,
> 
> or something else?

I mean that this patch only patches 7 files. Check this out:

dekai:qemu alex$ grep -R register_machine hw
hw/alpha_dp264.c:    qemu_register_machine(&clipper_machine);
hw/an5206.c:    qemu_register_machine(&an5206_machine);
hw/axis_dev88.c:    qemu_register_machine(&axisdev88_machine);
hw/boards.h:int qemu_register_machine(QEMUMachine *m);
hw/collie.c:    qemu_register_machine(&collie_machine);
hw/dummy_m68k.c:    qemu_register_machine(&dummy_m68k_machine);
hw/exynos4_boards.c:    qemu_register_machine(&exynos4_machines[EXYNOS4_BOARD_NURI]);
hw/exynos4_boards.c:    qemu_register_machine(&exynos4_machines[EXYNOS4_BOARD_SMDKC210]);
hw/gumstix.c:    qemu_register_machine(&connex_machine);
hw/gumstix.c:    qemu_register_machine(&verdex_machine);
hw/highbank.c:    qemu_register_machine(&highbank_machine);
hw/integratorcp.c:    qemu_register_machine(&integratorcp_machine);
hw/leon3.c:    qemu_register_machine(&leon3_generic_machine);
hw/lm32_boards.c:    qemu_register_machine(&lm32_uclinux_machine);
hw/lm32_boards.c:    qemu_register_machine(&lm32_evr_machine);
hw/mainstone.c:    qemu_register_machine(&mainstone2_machine);
hw/mcf5208.c:    qemu_register_machine(&mcf5208evb_machine);
hw/milkymist.c:    qemu_register_machine(&milkymist_machine);
hw/mips_fulong2e.c:    qemu_register_machine(&mips_fulong2e_machine);
hw/mips_jazz.c:    qemu_register_machine(&mips_magnum_machine);
hw/mips_jazz.c:    qemu_register_machine(&mips_pica61_machine);
hw/mips_malta.c:    qemu_register_machine(&mips_malta_machine);
hw/mips_mipssim.c:    qemu_register_machine(&mips_mipssim_machine);
hw/mips_r4k.c:    qemu_register_machine(&mips_machine);
hw/musicpal.c:    qemu_register_machine(&musicpal_machine);
hw/nseries.c:    qemu_register_machine(&n800_machine);
hw/nseries.c:    qemu_register_machine(&n810_machine);
hw/omap_sx1.c:    qemu_register_machine(&sx1_machine_v2);
hw/omap_sx1.c:    qemu_register_machine(&sx1_machine_v1);
hw/palm.c:    qemu_register_machine(&palmte_machine);
hw/pc_piix.c:    qemu_register_machine(&pc_machine_v1_1);
hw/pc_piix.c:    qemu_register_machine(&pc_machine_v1_0);
hw/pc_piix.c:    qemu_register_machine(&pc_machine_v0_15);
hw/pc_piix.c:    qemu_register_machine(&pc_machine_v0_14);
hw/pc_piix.c:    qemu_register_machine(&pc_machine_v0_13);
hw/pc_piix.c:    qemu_register_machine(&pc_machine_v0_12);
hw/pc_piix.c:    qemu_register_machine(&pc_machine_v0_11);
hw/pc_piix.c:    qemu_register_machine(&pc_machine_v0_10);
hw/pc_piix.c:    qemu_register_machine(&isapc_machine);
hw/pc_piix.c:    qemu_register_machine(&xenfv_machine);
hw/petalogix_ml605_mmu.c:    qemu_register_machine(&petalogix_ml605_machine);
hw/petalogix_s3adsp1800_mmu.c:    qemu_register_machine(&petalogix_s3adsp1800_machine);
hw/ppc405_boards.c:    qemu_register_machine(&ref405ep_machine);
hw/ppc405_boards.c:    qemu_register_machine(&taihu_machine);
hw/ppc440_bamboo.c:    qemu_register_machine(&bamboo_machine);
hw/ppc_newworld.c:    qemu_register_machine(&core99_machine);
hw/ppc_oldworld.c:    qemu_register_machine(&heathrow_machine);
hw/ppc_prep.c:    qemu_register_machine(&prep_machine);
hw/ppce500_mpc8544ds.c:    qemu_register_machine(&mpc8544ds_machine);
hw/r2d.c:    qemu_register_machine(&r2d_machine);
hw/realview.c:    qemu_register_machine(&realview_eb_machine);
hw/realview.c:    qemu_register_machine(&realview_eb_mpcore_machine);
hw/realview.c:    qemu_register_machine(&realview_pb_a8_machine);
hw/realview.c:    qemu_register_machine(&realview_pbx_a9_machine);
hw/s390-virtio.c:    qemu_register_machine(&s390_machine);
hw/shix.c:    qemu_register_machine(&shix_machine);
hw/spapr.c:    qemu_register_machine(&spapr_machine);
hw/spitz.c:    qemu_register_machine(&akitapda_machine);
hw/spitz.c:    qemu_register_machine(&spitzpda_machine);
hw/spitz.c:    qemu_register_machine(&borzoipda_machine);
hw/spitz.c:    qemu_register_machine(&terrierpda_machine);
hw/stellaris.c:    qemu_register_machine(&lm3s811evb_machine);
hw/stellaris.c:    qemu_register_machine(&lm3s6965evb_machine);
hw/sun4m.c:    qemu_register_machine(&ss5_machine);
hw/sun4m.c:    qemu_register_machine(&ss10_machine);
hw/sun4m.c:    qemu_register_machine(&ss600mp_machine);
hw/sun4m.c:    qemu_register_machine(&ss20_machine);
hw/sun4m.c:    qemu_register_machine(&voyager_machine);
hw/sun4m.c:    qemu_register_machine(&ss_lx_machine);
hw/sun4m.c:    qemu_register_machine(&ss4_machine);
hw/sun4m.c:    qemu_register_machine(&scls_machine);
hw/sun4m.c:    qemu_register_machine(&sbook_machine);
hw/sun4m.c:    qemu_register_machine(&ss1000_machine);
hw/sun4m.c:    qemu_register_machine(&ss2000_machine);
hw/sun4m.c:    qemu_register_machine(&ss2_machine);
hw/sun4u.c:    qemu_register_machine(&sun4u_machine);
hw/sun4u.c:    qemu_register_machine(&sun4v_machine);
hw/sun4u.c:    qemu_register_machine(&niagara_machine);
hw/tosa.c:    qemu_register_machine(&tosapda_machine);
hw/versatilepb.c:    qemu_register_machine(&versatilepb_machine);
hw/versatilepb.c:    qemu_register_machine(&versatileab_machine);
hw/vexpress.c:    qemu_register_machine(&vexpress_a9_machine);
hw/vexpress.c:    qemu_register_machine(&vexpress_a15_machine);
hw/virtex_ml507.c:    qemu_register_machine(&virtex_machine);
hw/xen_machine_pv.c:    qemu_register_machine(&xenpv_machine);
hw/xilinx_zynq.c:    qemu_register_machine(&zynq_machine);
hw/xtensa_lx60.c:    qemu_register_machine(&xtensa_lx60_machine);
hw/xtensa_lx60.c:    qemu_register_machine(&xtensa_lx200_machine);
hw/xtensa_sim.c:    qemu_register_machine(&xtensa_sim_machine);
hw/z2.c:    qemu_register_machine(&z2_machine);

Looks like a lot more files to me :).

> 
>> The way the patch works right now, the "make machine specific" patch
>> indirectly also changes the behavior for a bunch of machines.
> 
> A bunch?  I thought the only machine whose behaviour changed was
> pseries.  

It changes the behavior of all machines that are not patched, because they will fall back to no boot order now.


Alex

> I agree that moving the behaviour change into a separate
> patch would be a better idea, but if there are machines other than
> pseries with changed behaviour by this patch, then that's a plain old
> bug, rather than a mere question of patch elegance.
> 
> -- 
> David Gibson			| I'll have my music baroque, and my code
> david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
> 				| _way_ _around_!
> http://www.ozlabs.org/~dgibson
>
David Gibson Oct. 23, 2012, 11:43 p.m. UTC | #6
On Wed, Oct 24, 2012 at 12:47:34AM +0200, Alexander Graf wrote:
> 
> On 24.10.2012, at 00:43, David Gibson wrote:
> 
> > On Tue, Oct 23, 2012 at 12:20:08PM +0200, Alexander Graf wrote:
> >> 
> >> On 23.10.2012, at 12:09, Avik Sil wrote:
> >> 
> >>> This patch makes default boot order machine specific instead of
> >>> set globally. The default boot order can be set per machine in
> >>> QEMUMachine default_machine_opts, or by the command line using
> >>> -machine <machine_name>,boot=<boot_devices>, or by standard -boot
> >>> option. This allows a machine to receive a NULL boot order when
> >>> -boot isn't used and take an appropriate action accordingly. This
> >>> helps machine boots from the devices as set in guest's non-volatile
> >>> memory location in case no boot order is provided by the user.
> >>> 
> >>> Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
> >>> ---
> >>> hw/nseries.c      |  2 ++
> >>> hw/pc_piix.c      | 13 ++++++++++++-
> >>> hw/ppc_newworld.c |  1 +
> >>> hw/ppc_oldworld.c |  1 +
> >>> hw/ppc_prep.c     |  1 +
> >>> hw/sun4m.c        | 10 ++++++++++
> >>> hw/sun4u.c        |  3 +++
> >> 
> >> That feels like too much magic for my taste. Can't we have some
> >> default macro (or even the explicit "cad" thing) that we push to
> >> _every_ machine description out there? The next patch to implement
> >> boot= for pseries would then remove this default value for the
> >> pseries machine.
> > 
> > I'm not 100% clear on what you mean here.  Do you just mean:
> > 	#define DEFAULT_BOOT_ORDER	"boot=cad"
> > and then we use
> > 	.default_machine_opts = DEFAULT_BOOT_ORDER,
> > 
> > or something else?
> 
> I mean that this patch only patches 7 files. Check this out:

Oh, yes, oops.  Saw the big pile of hunks changing machines and
assumed that was all, but in fact half of them were just the PC
variants.

Avik, this will need to be fixed.
Avik Sil Oct. 24, 2012, 1:57 a.m. UTC | #7
On 10/24/2012 05:13 AM, David Gibson wrote:
> On Wed, Oct 24, 2012 at 12:47:34AM +0200, Alexander Graf wrote:
>>
>> On 24.10.2012, at 00:43, David Gibson wrote:
>>
>>> On Tue, Oct 23, 2012 at 12:20:08PM +0200, Alexander Graf wrote:
>>>>
>>>> On 23.10.2012, at 12:09, Avik Sil wrote:
>>>>
>>>>> This patch makes default boot order machine specific instead of
>>>>> set globally. The default boot order can be set per machine in
>>>>> QEMUMachine default_machine_opts, or by the command line using
>>>>> -machine <machine_name>,boot=<boot_devices>, or by standard -boot
>>>>> option. This allows a machine to receive a NULL boot order when
>>>>> -boot isn't used and take an appropriate action accordingly. This
>>>>> helps machine boots from the devices as set in guest's non-volatile
>>>>> memory location in case no boot order is provided by the user.
>>>>>
>>>>> Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
>>>>> ---
>>>>> hw/nseries.c      |  2 ++
>>>>> hw/pc_piix.c      | 13 ++++++++++++-
>>>>> hw/ppc_newworld.c |  1 +
>>>>> hw/ppc_oldworld.c |  1 +
>>>>> hw/ppc_prep.c     |  1 +
>>>>> hw/sun4m.c        | 10 ++++++++++
>>>>> hw/sun4u.c        |  3 +++
>>>>
>>>> That feels like too much magic for my taste. Can't we have some
>>>> default macro (or even the explicit "cad" thing) that we push to
>>>> _every_ machine description out there? The next patch to implement
>>>> boot= for pseries would then remove this default value for the
>>>> pseries machine.
>>>
>>> I'm not 100% clear on what you mean here.  Do you just mean:
>>> 	#define DEFAULT_BOOT_ORDER	"boot=cad"
>>> and then we use
>>> 	.default_machine_opts = DEFAULT_BOOT_ORDER,
>>>
>>> or something else?
>>
>> I mean that this patch only patches 7 files. Check this out:
> 
> Oh, yes, oops.  Saw the big pile of hunks changing machines and
> assumed that was all, but in fact half of them were just the PC
> variants.
> 
> Avik, this will need to be fixed.
> 
Sure, will do. Actually I patched the machines that do care for boot
order like in pc_piix.c and other machines do not care for the order.
But in next series I'll do it for every machine.

Regards,
Avik
diff mbox

Patch

diff --git a/hw/nseries.c b/hw/nseries.c
index 7ada90d..7247e40 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -1427,12 +1427,14 @@  static QEMUMachine n800_machine = {
     .name = "n800",
     .desc = "Nokia N800 tablet aka. RX-34 (OMAP2420)",
     .init = n800_init,
+    .default_machine_opts = "boot=cad",
 };
 
 static QEMUMachine n810_machine = {
     .name = "n810",
     .desc = "Nokia N810 tablet aka. RX-44 (OMAP2420)",
     .init = n810_init,
+    .default_machine_opts = "boot=cad",
 };
 
 static void nseries_machine_init(void)
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index bf04a42..9592f16 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -352,6 +352,7 @@  static QEMUMachine pc_machine_v1_3 = {
     .init = pc_init_pci,
     .max_cpus = 255,
     .is_default = 1,
+    .default_machine_opts = "boot=cad",
 };
 
 #define PC_COMPAT_1_2 \
@@ -390,6 +391,7 @@  static QEMUMachine pc_machine_v1_2 = {
         PC_COMPAT_1_2,
         { /* end of list */ }
     },
+    .default_machine_opts = "boot=cad",
 };
 
 #define PC_COMPAT_1_1 \
@@ -433,6 +435,7 @@  static QEMUMachine pc_machine_v1_1 = {
         PC_COMPAT_1_1,
         { /* end of list */ }
     },
+    .default_machine_opts = "boot=cad",
 };
 
 #define PC_COMPAT_1_0 \
@@ -469,6 +472,7 @@  static QEMUMachine pc_machine_v1_0 = {
         { /* end of list */ }
     },
     .hw_version = "1.0",
+    .default_machine_opts = "boot=cad",
 };
 
 #define PC_COMPAT_0_15 \
@@ -484,6 +488,7 @@  static QEMUMachine pc_machine_v0_15 = {
         { /* end of list */ }
     },
     .hw_version = "0.15",
+    .default_machine_opts = "boot=cad",
 };
 
 #define PC_COMPAT_0_14 \
@@ -525,6 +530,7 @@  static QEMUMachine pc_machine_v0_14 = {
         { /* end of list */ }
     },
     .hw_version = "0.14",
+    .default_machine_opts = "boot=cad",
 };
 
 #define PC_COMPAT_0_13 \
@@ -562,6 +568,7 @@  static QEMUMachine pc_machine_v0_13 = {
         { /* end of list */ }
     },
     .hw_version = "0.13",
+    .default_machine_opts = "boot=cad",
 };
 
 #define PC_COMPAT_0_12 \
@@ -595,6 +602,7 @@  static QEMUMachine pc_machine_v0_12 = {
         { /* end of list */ }
     },
     .hw_version = "0.12",
+    .default_machine_opts = "boot=cad",
 };
 
 #define PC_COMPAT_0_11 \
@@ -628,6 +636,7 @@  static QEMUMachine pc_machine_v0_11 = {
         { /* end of list */ }
     },
     .hw_version = "0.11",
+    .default_machine_opts = "boot=cad",
 };
 
 static QEMUMachine pc_machine_v0_10 = {
@@ -661,6 +670,7 @@  static QEMUMachine pc_machine_v0_10 = {
         { /* end of list */ }
     },
     .hw_version = "0.10",
+    .default_machine_opts = "boot=cad",
 };
 
 static QEMUMachine isapc_machine = {
@@ -676,6 +686,7 @@  static QEMUMachine isapc_machine = {
         },
         { /* end of list */ }
     },
+    .default_machine_opts = "boot=cad",
 };
 
 #ifdef CONFIG_XEN
@@ -684,7 +695,7 @@  static QEMUMachine xenfv_machine = {
     .desc = "Xen Fully-virtualized PC",
     .init = pc_xen_hvm_init,
     .max_cpus = HVM_MAX_VCPUS,
-    .default_machine_opts = "accel=xen",
+    .default_machine_opts = "accel=xen,boot=cad",
 };
 #endif
 
diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
index a265445..1f00aa1 100644
--- a/hw/ppc_newworld.c
+++ b/hw/ppc_newworld.c
@@ -426,6 +426,7 @@  static QEMUMachine core99_machine = {
 #ifdef TARGET_PPC64
     .is_default = 1,
 #endif
+    .default_machine_opts = "boot=cad",
 };
 
 static void core99_machine_init(void)
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index de33408..355a3ec 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -341,6 +341,7 @@  static QEMUMachine heathrow_machine = {
 #ifndef TARGET_PPC64
     .is_default = 1,
 #endif
+    .default_machine_opts = "boot=cad",
 };
 
 static void heathrow_machine_init(void)
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index a0d1c3d..6dfbb7b 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -694,6 +694,7 @@  static QEMUMachine prep_machine = {
     .desc = "PowerPC PREP platform",
     .init = ppc_prep_init,
     .max_cpus = MAX_CPUS,
+    .default_machine_opts = "boot=cad",
 };
 
 static void prep_machine_init(void)
diff --git a/hw/sun4m.c b/hw/sun4m.c
index dbe93f9..7b436be 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -1428,6 +1428,7 @@  static QEMUMachine ss5_machine = {
     .init = ss5_init,
     .use_scsi = 1,
     .is_default = 1,
+    .default_machine_opts = "boot=cad",
 };
 
 static QEMUMachine ss10_machine = {
@@ -1436,6 +1437,7 @@  static QEMUMachine ss10_machine = {
     .init = ss10_init,
     .use_scsi = 1,
     .max_cpus = 4,
+    .default_machine_opts = "boot=cad",
 };
 
 static QEMUMachine ss600mp_machine = {
@@ -1444,6 +1446,7 @@  static QEMUMachine ss600mp_machine = {
     .init = ss600mp_init,
     .use_scsi = 1,
     .max_cpus = 4,
+    .default_machine_opts = "boot=cad",
 };
 
 static QEMUMachine ss20_machine = {
@@ -1452,6 +1455,7 @@  static QEMUMachine ss20_machine = {
     .init = ss20_init,
     .use_scsi = 1,
     .max_cpus = 4,
+    .default_machine_opts = "boot=cad",
 };
 
 static QEMUMachine voyager_machine = {
@@ -1459,6 +1463,7 @@  static QEMUMachine voyager_machine = {
     .desc = "Sun4m platform, SPARCstation Voyager",
     .init = vger_init,
     .use_scsi = 1,
+    .default_machine_opts = "boot=cad",
 };
 
 static QEMUMachine ss_lx_machine = {
@@ -1466,6 +1471,7 @@  static QEMUMachine ss_lx_machine = {
     .desc = "Sun4m platform, SPARCstation LX",
     .init = ss_lx_init,
     .use_scsi = 1,
+    .default_machine_opts = "boot=cad",
 };
 
 static QEMUMachine ss4_machine = {
@@ -1473,6 +1479,7 @@  static QEMUMachine ss4_machine = {
     .desc = "Sun4m platform, SPARCstation 4",
     .init = ss4_init,
     .use_scsi = 1,
+    .default_machine_opts = "boot=cad",
 };
 
 static QEMUMachine scls_machine = {
@@ -1480,6 +1487,7 @@  static QEMUMachine scls_machine = {
     .desc = "Sun4m platform, SPARCClassic",
     .init = scls_init,
     .use_scsi = 1,
+    .default_machine_opts = "boot=cad",
 };
 
 static QEMUMachine sbook_machine = {
@@ -1487,6 +1495,7 @@  static QEMUMachine sbook_machine = {
     .desc = "Sun4m platform, SPARCbook",
     .init = sbook_init,
     .use_scsi = 1,
+    .default_machine_opts = "boot=cad",
 };
 
 static const struct sun4d_hwdef sun4d_hwdefs[] = {
@@ -1897,6 +1906,7 @@  static QEMUMachine ss2_machine = {
     .desc = "Sun4c platform, SPARCstation 2",
     .init = ss2_init,
     .use_scsi = 1,
+    .default_machine_opts = "boot=cad",
 };
 
 static void sun4m_register_types(void)
diff --git a/hw/sun4u.c b/hw/sun4u.c
index eeb6496..b77eed7 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -978,6 +978,7 @@  static QEMUMachine sun4u_machine = {
     .init = sun4u_init,
     .max_cpus = 1, // XXX for now
     .is_default = 1,
+    .default_machine_opts = "boot=cad",
 };
 
 static QEMUMachine sun4v_machine = {
@@ -985,6 +986,7 @@  static QEMUMachine sun4v_machine = {
     .desc = "Sun4v platform",
     .init = sun4v_init,
     .max_cpus = 1, // XXX for now
+    .default_machine_opts = "boot=cad",
 };
 
 static QEMUMachine niagara_machine = {
@@ -992,6 +994,7 @@  static QEMUMachine niagara_machine = {
     .desc = "Sun4v platform, Niagara",
     .init = niagara_init,
     .max_cpus = 1, // XXX for now
+    .default_machine_opts = "boot=cad",
 };
 
 static void sun4u_register_types(void)
diff --git a/qemu-config.c b/qemu-config.c
index cd1ec21..92dfc8e 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -619,7 +619,11 @@  static QemuOptsList qemu_machine_opts = {
             .name = "mem-merge",
             .type = QEMU_OPT_BOOL,
             .help = "enable/disable memory merge support",
-        },
+        }, {
+            .name = "boot",
+            .type = QEMU_OPT_STRING,
+            .help = "boot order",
+         },
         { /* End of list */ }
     },
 };
diff --git a/vl.c b/vl.c
index ee3c43a..7b1f6c4 100644
--- a/vl.c
+++ b/vl.c
@@ -2369,7 +2369,7 @@  int main(int argc, char **argv, char **envp)
     const char *icount_option = NULL;
     const char *initrd_filename;
     const char *kernel_filename, *kernel_cmdline;
-    char boot_devices[33] = "cad"; /* default to HD->floppy->CD-ROM */
+    const char *boot_devices = NULL;
     DisplayState *ds;
     DisplayChangeListener *dcl;
     int cyls, heads, secs, translation;
@@ -2645,7 +2645,7 @@  int main(int argc, char **argv, char **envp)
                         "splash", "splash-time",
                         "reboot-timeout", NULL
                     };
-                    char buf[sizeof(boot_devices)];
+                    char buf[33];
                     char *standard_boot_devices;
                     int legacy = 0;
 
@@ -2662,14 +2662,18 @@  int main(int argc, char **argv, char **envp)
                     if (legacy ||
                         get_param_value(buf, sizeof(buf), "order", optarg)) {
                         validate_bootdevices(buf);
-                        pstrcpy(boot_devices, sizeof(boot_devices), buf);
+                        machine_opts = qemu_opts_create(qemu_find_opts("machine"), 
+                                                        NULL, 0, NULL);
+                        qemu_opt_set(machine_opts, "boot", buf);
                     }
                     if (!legacy) {
                         if (get_param_value(buf, sizeof(buf),
                                             "once", optarg)) {
                             validate_bootdevices(buf);
                             standard_boot_devices = g_strdup(boot_devices);
-                            pstrcpy(boot_devices, sizeof(boot_devices), buf);
+                            machine_opts = qemu_opts_create(qemu_find_opts("machine"), 
+                                                            NULL, 0, NULL);
+                            qemu_opt_set(machine_opts, "boot", buf);
                             qemu_register_reset(restore_boot_devices,
                                                 standard_boot_devices);
                         }
@@ -3479,6 +3483,7 @@  int main(int argc, char **argv, char **envp)
         kernel_filename = qemu_opt_get(machine_opts, "kernel");
         initrd_filename = qemu_opt_get(machine_opts, "initrd");
         kernel_cmdline = qemu_opt_get(machine_opts, "append");
+        boot_devices = qemu_opt_get(machine_opts, "boot");
     } else {
         kernel_filename = initrd_filename = kernel_cmdline = NULL;
     }