add a boot option to do strict boot
PATCH 1/1 add a boot option to do strict boot
Current seabios will try to boot from selected devices first, if they are all failed, seabios will also try to boot from un-selected devices.
We need to make it configurable. I already posted a seabios patch to add a new device type to halt booting. Qemu can add "HALT" at the end of bootindex string, then seabios will halt booting after trying to boot from selected devices.
This option only effects when boot priority is changed by bootindex options, the old style(-boot order=..) will still try to boot from un-selected devices.
---
[SeaBIOS PATCH v3] boot: add a new type to halt booting
https://github.com/kongove/seabios/commit/39aeded2da6254eab2c34de92371ce1cad5c793e
bios.bin: http://kongove.fedorapeople.org/pub/added-halt-type-bios.bin
--- qemu-config.c | 3 +++ qemu-options.hx | 8 ++++++-- vl.c | 28 +++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 3 deletions(-)
qemu-config.c +3 -0
@@ -612,6 +612,9 @@ QemuOptsList qemu_boot_opts = { }, { .name = "reboot-timeout", .type = QEMU_OPT_STRING, + }, { + .name = "strict", + .type = QEMU_OPT_STRING, }, {/*End of list */ } },
qemu-options.hx +6 -2
@@ -376,14 +376,14 @@ ETEXI DEF("boot", HAS_ARG, QEMU_OPTION_boot, "-boot [order=drives][,once=drives][,menu=on|off]\n" - " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time]\n" + " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]\n" " 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n" " 'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n" " 'sp_time': the period that splash picture last if menu=on, unit is ms\n" " 'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n", QEMU_ARCH_ALL) STEXI -@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}] +@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}][,strict=on|off] @findex -boot Specify boot order @var{drives} as a string of drive letters. Valid drive letters depend on the target achitecture. The x86 PC uses: a, b
@@ -407,6 +407,10 @@ when boot failed, then reboot. If @var{rb_timeout} is '-1', guest will not reboot, qemu passes '-1' to bios by default. Currently Seabios for X86 system support it. +Do strict boot via @option{strict=on} as far as firmware/BIOS +supports it. This only effects when boot priority is changed by +bootindex options. The default is non-strict boot. + @example # try to boot from network first, then from hard disk qemu-system-i386 -boot order=nc
vl.c +27 -1
@@ -230,6 +230,7 @@ int ctrl_grab = 0;unsigned int nb_prom_envs =0 ;const char *prom_envs[MAX_PROM_ENVS ];int boot_menu; +int boot_strict;uint8_t *boot_splash_filedata;int boot_splash_filedata_size;uint8_t qemu_extra_params_fw[2 ];
@@ -2804,7 +2805,7 @@ int main(int argc, char **argv, char **envp)static const char *const params[] = {"order" ,"once" ,"menu" ,"splash" ,"splash-time" , -"reboot-timeout" ,NULL +"reboot-timeout" ,"strict" ,NULL };char buf[sizeof (boot_devices)];char *standard_boot_devices;
@@ -2847,6 +2848,19 @@ int main(int argc, char **argv, char **envp)exit (1 ); } } +if (get_param_value (buf,sizeof (buf), +"strict" , optarg)) { +if (!strcmp (buf,"on" )) { + boot_strict =1 ; + }else if (!strcmp (buf,"off" )) { + boot_strict =0 ; + }else { +fprintf (stderr, +"qemu: invalid option value '%s'\n" , + buf); +exit (1 ); + } + }qemu_opts_parse (qemu_find_opts ("boot-opts" ), optarg,0 ); }
@@ -3907,6 +3921,18 @@ int main(int argc, char **argv, char **envp)net_check_clients (); +if (boot_strict) { +/* do strict boot, only boot from selected devices */ +FWBootEntry *node; + + QTAILQ_FOREACH(node, &fw_boot_order, link) { +if (!node->link.tqe_next) { +add_boot_device_path (node->bootindex +1 ,NULL ,"HALT" ); +break ; + } + } + } +/* just use the first displaystate for the moment */ ds =get_displaystate ();
Signature · 1 line
1.7.1
Quoted 75 lines · Amos Kong
Current seabios will try to boot from selected devices first, if they are all failed, seabios will also try to boot from un-selected devices.
We need to make it configurable. I already posted a seabios patch to add a new device type to halt booting. Qemu can add "HALT" at the end of bootindex string, then seabios will halt booting after trying to boot from selected devices.
This option only effects when boot priority is changed by bootindex options, the old style(-boot order=..) will still try to boot from un-selected devices.
Signed-off-by Amos Kong <[email protected]>---
[SeaBIOS PATCH v3] boot: add a new type to halt booting
https://github.com/kongove/seabios/commit/39aeded2da6254eab2c34de92371ce1cad5c793e
bios.bin: http://kongove.fedorapeople.org/pub/added-halt-type-bios.bin--- qemu-config.c | 3 +++ qemu-options.hx | 8 ++++++-- vl.c | 28 +++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 3 deletions(-)qemu-config.c +3
-0@@ -612,6 +612,9 @@ QemuOptsList qemu_boot_opts = { }, { .name = "reboot-timeout", .type = QEMU_OPT_STRING, + }, { + .name = "strict", + .type = QEMU_OPT_STRING, }, {/*End of list */ } },qemu-options.hx +6
-2@@ -376,14 +376,14 @@ ETEXI DEF("boot", HAS_ARG, QEMU_OPTION_boot, "-boot [order=drives][,once=drives][,menu=on|off]\n" - " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time]\n" + " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]\n" " 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n" " 'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n" " 'sp_time': the period that splash picture last if menu=on, unit is ms\n" " 'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n", QEMU_ARCH_ALL) STEXI -@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}] +@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}][,strict=on|off] @findex -boot Specify boot order @var{drives} as a string of drive letters. Valid drive letters depend on the target achitecture. The x86 PC uses: a, b@@ -407,6 +407,10 @@ when boot failed, then reboot. If @var{rb_timeout} is '-1', guest will not reboot, qemu passes '-1' to bios by default. Currently Seabios for X86 system support it. +Do strict boot via @option{strict=on} as far as firmware/BIOS +supports it. This only effects when boot priority is changed by +bootindex options. The default is non-strict boot. + @example # try to boot from network first, then from hard disk qemu-system-i386 -boot order=ncvl.c +0
-0
vl.c int ctrl_grab = 0; · line 233
Quoted 4 lines
vl.c +1
-0@@ -230,6 +230,7 @@ int ctrl_grab = 0;unsigned int nb_prom_envs =0 ;const char *prom_envs[MAX_PROM_ENVS ];int boot_menu; +int boot_strict;
bool?
Quoted 38 lines
vl.c +16
-1uint8_t *boot_splash_filedata;int boot_splash_filedata_size;uint8_t qemu_extra_params_fw[2 ];@@ -2804,7 +2805,7 @@ int main(int argc, char **argv, char **envp)static const char *const params[] = {"order" ,"once" ,"menu" ,"splash" ,"splash-time" , -"reboot-timeout" ,NULL +"reboot-timeout" ,"strict" ,NULL };char buf[sizeof (boot_devices)];char *standard_boot_devices;@@ -2847,6 +2848,19 @@ int main(int argc, char **argv, char **envp)exit (1 ); } } +if (get_param_value (buf,sizeof (buf), +"strict" , optarg)) { +if (!strcmp (buf,"on" )) { + boot_strict =1 ; + }else if (!strcmp (buf,"off" )) { + boot_strict =0 ; + }else { +fprintf (stderr, +"qemu: invalid option value '%s'\n" , + buf); +exit (1 ); + } + }qemu_opts_parse (qemu_find_opts ("boot-opts" ), optarg,0 ); }@@ -3907,6 +3921,18 @@ int main(int argc, char **argv, char **envp)net_check_clients (); +if (boot_strict) { +/* do strict boot, only boot from selected devices */
vl.c int main(int argc, char **argv, char **envp) · line 3935
Quoted 10 lines
vl.c +10
-0+FWBootEntry *node; + + QTAILQ_FOREACH(node, &fw_boot_order, link) { +if (!node->link.tqe_next) { +add_boot_device_path (node->bootindex +1 ,NULL ,"HALT" ); +break ; + } + } + } +
Just add HALT entry in get_boot_devices_list() if boot_strict==true.
Quoted 5 lines
vl.c +0
-0/* just use the first displaystate for the moment */ ds =get_displaystate ();Signature · 1 line
1.7.1
--
Gleb.
PATCH v2 1/1 add a boot option to do strict boot
In reply to Amos KongCurrent seabios will try to boot from selected devices first, if they are all failed, seabios will also try to boot from un-selected devices.
We need to make it configurable. I already posted a seabios patch to add a new device type to halt booting. Qemu can add "HALT" at the end of bootindex string, then seabios will halt booting after trying to boot from selected devices.
This option only effects when boot priority is changed by bootindex options, the old style(-boot order=..) will still try to boot from un-selected devices.
v2: add HALT entry in get_boot_devices_list()
define boot_strict to bool
---
[SeaBIOS PATCH v3] boot: add a new type to halt booting
https://github.com/kongove/seabios/commit/39aeded2da6254eab2c34de92371ce1cad5c793e
bios.bin: http://kongove.fedorapeople.org/pub/added-halt-type-bios.bin
--- qemu-config.c | 3 +++ qemu-options.hx | 8 ++++++-- vl.c | 22 +++++++++++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-)
qemu-config.c +3 -0
@@ -612,6 +612,9 @@ QemuOptsList qemu_boot_opts = { }, { .name = "reboot-timeout", .type = QEMU_OPT_STRING, + }, { + .name = "strict", + .type = QEMU_OPT_STRING, }, {/*End of list */ } },
qemu-options.hx +6 -2
@@ -376,14 +376,14 @@ ETEXI DEF("boot", HAS_ARG, QEMU_OPTION_boot, "-boot [order=drives][,once=drives][,menu=on|off]\n" - " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time]\n" + " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]\n" " 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n" " 'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n" " 'sp_time': the period that splash picture last if menu=on, unit is ms\n" " 'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n", QEMU_ARCH_ALL) STEXI -@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}] +@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}][,strict=on|off] @findex -boot Specify boot order @var{drives} as a string of drive letters. Valid drive letters depend on the target achitecture. The x86 PC uses: a, b
@@ -407,6 +407,10 @@ when boot failed, then reboot. If @var{rb_timeout} is '-1', guest will not reboot, qemu passes '-1' to bios by default. Currently Seabios for X86 system support it. +Do strict boot via @option{strict=on} as far as firmware/BIOS +supports it. This only effects when boot priority is changed by +bootindex options. The default is non-strict boot. + @example # try to boot from network first, then from hard disk qemu-system-i386 -boot order=nc
vl.c +21 -1
@@ -230,6 +230,7 @@ int ctrl_grab = 0;unsigned int nb_prom_envs =0 ;const char *prom_envs[MAX_PROM_ENVS ];int boot_menu; +bool boot_strict = false;uint8_t *boot_splash_filedata;int boot_splash_filedata_size;uint8_t qemu_extra_params_fw[2 ];
@@ -1052,6 +1053,12 @@ char *get_boot_devices_list(uint32_t *size) *size = total; +if (boot_strict && *size >0 ) { + list[total-1 ] ='\n' ; + list =g_realloc (list, total +4 ); +memcpy (&list[total],"HALT" ,4 ); + *size = total +4 ; + }return list; }
@@ -2804,7 +2811,7 @@ int main(int argc, char **argv, char **envp)static const char *const params[] = {"order" ,"once" ,"menu" ,"splash" ,"splash-time" , -"reboot-timeout" ,NULL +"reboot-timeout" ,"strict" ,NULL };char buf[sizeof (boot_devices)];char *standard_boot_devices;
@@ -2847,6 +2854,19 @@ int main(int argc, char **argv, char **envp)exit (1 ); } } +if (get_param_value (buf,sizeof (buf), +"strict" , optarg)) { +if (!strcmp (buf,"on" )) { + boot_strict = true; + }else if (!strcmp (buf,"off" )) { + boot_strict = false; + }else { +fprintf (stderr, +"qemu: invalid option value '%s'\n" , + buf); +exit (1 ); + } + }qemu_opts_parse (qemu_find_opts ("boot-opts" ), optarg,0 ); }
Signature · 1 line
1.7.1
Quoted 9 lines · Amos Kong
Current seabios will try to boot from selected devices first, if they are all failed, seabios will also try to boot from un-selected devices.
We need to make it configurable. I already posted a seabios patch to add a new device type to halt booting. Qemu can add "HALT" at the end of bootindex string, then seabios will halt booting after trying to boot from selected devices.
Quoted 8 lines
This option only effects when boot priority is changed by bootindex options, the old style(-boot order=..) will still try to boot from un-selected devices.
v2: add HALT entry in
get_boot_devices_list()
defineboot_strictto boolSigned-off-by Amos Kong <[email protected]>
Quoted 112 lines
---
[SeaBIOS PATCH v3] boot: add a new type to halt booting
https://github.com/kongove/seabios/commit/39aeded2da6254eab2c34de92371ce1cad5c793e
bios.bin: http://kongove.fedorapeople.org/pub/added-halt-type-bios.bin--- qemu-config.c | 3 +++ qemu-options.hx | 8 ++++++-- vl.c | 22 +++++++++++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-)qemu-config.c +3
-0@@ -612,6 +612,9 @@ QemuOptsList qemu_boot_opts = { }, { .name = "reboot-timeout", .type = QEMU_OPT_STRING, + }, { + .name = "strict", + .type = QEMU_OPT_STRING, }, {/*End of list */ } },qemu-options.hx +6
-2@@ -376,14 +376,14 @@ ETEXI DEF("boot", HAS_ARG, QEMU_OPTION_boot, "-boot [order=drives][,once=drives][,menu=on|off]\n" - " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time]\n" + " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]\n" " 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n" " 'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n" " 'sp_time': the period that splash picture last if menu=on, unit is ms\n" " 'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n", QEMU_ARCH_ALL) STEXI -@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}] +@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}][,strict=on|off] @findex -boot Specify boot order @var{drives} as a string of drive letters. Valid drive letters depend on the target achitecture. The x86 PC uses: a, b@@ -407,6 +407,10 @@ when boot failed, then reboot. If @var{rb_timeout} is '-1', guest will not reboot, qemu passes '-1' to bios by default. Currently Seabios for X86 system support it. +Do strict boot via @option{strict=on} as far as firmware/BIOS +supports it. This only effects when boot priority is changed by +bootindex options. The default is non-strict boot. + @example # try to boot from network first, then from hard disk qemu-system-i386 -boot order=ncvl.c +21
-1@@ -230,6 +230,7 @@ int ctrl_grab = 0;unsigned int nb_prom_envs =0 ;const char *prom_envs[MAX_PROM_ENVS ];int boot_menu; +bool boot_strict = false;uint8_t *boot_splash_filedata;int boot_splash_filedata_size;uint8_t qemu_extra_params_fw[2 ];@@ -1052,6 +1053,12 @@ char *get_boot_devices_list(uint32_t *size) *size = total; +if (boot_strict && *size >0 ) { + list[total-1 ] ='\n' ; + list =g_realloc (list, total +4 ); +memcpy (&list[total],"HALT" ,4 ); + *size = total +4 ; + }return list; }@@ -2804,7 +2811,7 @@ int main(int argc, char **argv, char **envp)static const char *const params[] = {"order" ,"once" ,"menu" ,"splash" ,"splash-time" , -"reboot-timeout" ,NULL +"reboot-timeout" ,"strict" ,NULL };char buf[sizeof (boot_devices)];char *standard_boot_devices;@@ -2847,6 +2854,19 @@ int main(int argc, char **argv, char **envp)exit (1 ); } } +if (get_param_value (buf,sizeof (buf), +"strict" , optarg)) { +if (!strcmp (buf,"on" )) { + boot_strict = true; + }else if (!strcmp (buf,"off" )) { + boot_strict = false; + }else { +fprintf (stderr, +"qemu: invalid option value '%s'\n" , + buf); +exit (1 ); + } + }qemu_opts_parse (qemu_find_opts ("boot-opts" ), optarg,0 ); }Signature · 1 line
1.7.1
--
Gleb.
Quoted 13 lines · Amos Kong
Current seabios will try to boot from selected devices first, if they are all failed, seabios will also try to boot from un-selected devices.
We need to make it configurable. I already posted a seabios patch to add a new device type to halt booting. Qemu can add "HALT" at the end of bootindex string, then seabios will halt booting after trying to boot from selected devices.
This option only effects when boot priority is changed by bootindex options, the old style(-boot order=..) will still try to boot from un-selected devices.
Quoted 5 lines
v2: add HALT entry in
get_boot_devices_list()
defineboot_strictto boolSigned-off-by Amos Kong <[email protected]>---
Libvirt will need to expose an attribute that lets the user control whether to use this new option; how do we probe via QMP whether the new -boot strict=on command-line option is available?
qemu-options.hx ETEXI · line 383
Quoted 11 lines
+++ b/qemu-options.hx
qemu-options.hx +1
-1@@ -376,14 +376,14 @@ ETEXI DEF("boot", HAS_ARG, QEMU_OPTION_boot, "-boot [order=drives][,once=drives][,menu=on|off]\n" - " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time]\n" + " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]\n" " 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n" " 'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n" " 'sp_time': the period that splash picture last if menu=on, unit is ms\n" " 'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n",
So if I understand correctly, -boot order=... is incompatible with -boot strict=on; even though you have listed both options under a single -boot entry in the -help. We've already declared that -help output is no longer guaranteed stable, so this doesn't really impact libvirt, but would it make any more sense to list this as two orthogonal entries, to make it clear that they don't mix?
-boot order=drivers[,once=drives]...
-boot strict=on|off[,menu=on|off]...
But this is all bikeshedding, so it's not worth a v3 if you disagree.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 17 lines · Eric Blake
Quoted 16 lines · Amos Kong
Current seabios will try to boot from selected devices first, if they are all failed, seabios will also try to boot from un-selected devices.
We need to make it configurable. I already posted a seabios patch to add a new device type to halt booting. Qemu can add "HALT" at the end of bootindex string, then seabios will halt booting after trying to boot from selected devices.
This option only effects when boot priority is changed by bootindex options, the old style(-boot order=..) will still try to boot from un-selected devices.
v2: add HALT entry in
get_boot_devices_list()
defineboot_strictto bool
Quoted 6 lines
Quoted 2 lines
Signed-off-by Amos Kong <[email protected]>---
Libvirt will need to expose an attribute that lets the user control whether to use this new option; how do we probe via QMP whether the new -boot strict=on command-line option is available?
While libvirt should make use of this, we don't need to expose it in the XML. This new behaviour is what we wanted to have all along, so we should just enable it.
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Quoted 18 lines · Daniel P. Berrange
Quoted 17 lines · Eric Blake
Quoted 16 lines · Amos Kong
Current seabios will try to boot from selected devices first, if they are all failed, seabios will also try to boot from un-selected devices.
We need to make it configurable. I already posted a seabios patch to add a new device type to halt booting. Qemu can add "HALT" at the end of bootindex string, then seabios will halt booting after trying to boot from selected devices.
This option only effects when boot priority is changed by bootindex options, the old style(-boot order=..) will still try to boot from un-selected devices.
v2: add HALT entry in
get_boot_devices_list()
defineboot_strictto bool
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by Amos Kong <[email protected]>---
Libvirt will need to expose an attribute that lets the user control whether to use this new option; how do we probe via QMP whether the new -boot strict=on command-line option is available?
While libvirt should make use of this, we don't need to expose it in the XML. This new behaviour is what we wanted to have all along, so we should just enable it.
I agree that this is the way it *should* always work, but apparently there are people who depend on the old behavior, so just doing a blanket switch to the new behavior could lead to setups that no longer work "properly" after an upgrade, which unfortunately means that existing functionality needs to be maintained, and "correct" functionality must be triggered by a config switch (maybe Gleb can expand on the use cases that require this if more details are needed, as it's him I heard this from)
Quoted 28 lines · Laine Stump
Quoted 18 lines · Daniel P. Berrange
Quoted 17 lines · Eric Blake
Quoted 16 lines · Amos Kong
Current seabios will try to boot from selected devices first, if they are all failed, seabios will also try to boot from un-selected devices.
We need to make it configurable. I already posted a seabios patch to add a new device type to halt booting. Qemu can add "HALT" at the end of bootindex string, then seabios will halt booting after trying to boot from selected devices.
This option only effects when boot priority is changed by bootindex options, the old style(-boot order=..) will still try to boot from un-selected devices.
v2: add HALT entry in
get_boot_devices_list()
defineboot_strictto boolQuoted 8 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by Amos Kong <[email protected]>---
Libvirt will need to expose an attribute that lets the user control whether to use this new option; how do we probe via QMP whether the new -boot strict=on command-line option is available?
While libvirt should make use of this, we don't need to expose it in the XML. This new behaviour is what we wanted to have all along, so we should just enable it.
Quoted 7 lines
I agree that this is the way it *should* always work, but apparently there are people who depend on the old behavior, so just doing a blanket switch to the new behavior could lead to setups that no longer work "properly" after an upgrade, which unfortunately means that existing functionality needs to be maintained, and "correct" functionality must be triggered by a config switch (maybe Gleb can expand on the use cases that require this if more details are needed, as it's him I heard this from)
It is common to configure PXE boot as highest prio for easy re-imaging, Usually boot from PXE fails and other bootable device is used instead, but if re-installation is needed it is as easy as configuring PXE server and rebooting the machine. With current behaviour it is enough to boost PXE priority, if we will change it setups that didn't explicitly specify all devices' priorities will stop working. The rule is easy: if exist command line that will work differently before and after the change you probably break someones setup with your patch.
--
Gleb.
Quoted 17 lines · Eric Blake
Quoted 16 lines · Amos Kong
Current seabios will try to boot from selected devices first, if they are all failed, seabios will also try to boot from un-selected devices.
We need to make it configurable. I already posted a seabios patch to add a new device type to halt booting. Qemu can add "HALT" at the end of bootindex string, then seabios will halt booting after trying to boot from selected devices.
This option only effects when boot priority is changed by bootindex options, the old style(-boot order=..) will still try to boot from un-selected devices.
v2: add HALT entry in
get_boot_devices_list()
defineboot_strictto bool
Quoted 6 lines
Quoted 2 lines
Signed-off-by Amos Kong <[email protected]>---
Libvirt will need to expose an attribute that lets the user control whether to use this new option; how do we probe via QMP whether the new -boot strict=on command-line option is available?
Old style to adjust boot priority by order parameter:
-boot order=n,strict=on (BAD, unselected devices will be tried)
New style to adjust boot priority by bootindex:
-device virtio-net-pci,...,bootindex=1 -boot strict=on (OK)
We only want strict option to support new style.
(those two styles are implemented in two different way insider seabios, the latest simple patch only changed the bootindex way)
Quoted 28 lines
qemu-options.hx ETEXI · line 383
Quoted 11 lines
+++ b/qemu-options.hx
qemu-options.hx +1
-1@@ -376,14 +376,14 @@ ETEXI DEF("boot", HAS_ARG, QEMU_OPTION_boot, "-boot [order=drives][,once=drives][,menu=on|off]\n" - " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time]\n" + " [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]\n" " 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n" " 'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n" " 'sp_time': the period that splash picture last if menu=on, unit is ms\n" " 'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n",So if I understand correctly, -boot order=... is incompatible with -boot strict=on; even though you have listed both options under a single -boot entry in the -help. We've already declared that -help output is no longer guaranteed stable, so this doesn't really impact libvirt, but would it make any more sense to list this as two orthogonal entries, to make it clear that they don't mix?
(quoted diff) +0
-2-boot order=drivers[,once=drives]... -boot strict=on|off[,menu=on|off]...But this is all bikeshedding, so it's not worth a v3 if you disagree.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [Qemu-devel] [RFC] introduce a general query-config cmd
Quoted 57 lines · Amos Kong
Quoted 56 lines · Amos Kong
Quoted 21 lines · Anthony Liguori
Quoted 20 lines · Eric Blake
Quoted 18 lines · Amos Kong
Quoted 8 lines
Quoted 5 lines
Libvirt will need to expose an attribute that lets the user control whether to use this new option; how do we probe via QMP whether the new
-boot strict=on command-line option is available?Hi all,
Quoted 7 lines
How about add new info/query command?
(hmp) info strict-boot
on(qmp) {"execute": "query-strict-boot"}
{"return": {"state": true}}It might be not a good solution, I already updated qemu-options.hx, we can check help message to know if this new option is added or not.
Quoted 8 lines
Quoted 6 lines
Having libvirt probe the -help output is out of the question. We already declared that for qemu 1.3 and beyond, ALL command line behavior must ALSO be probe-able via QMP. I think Anthony had a trick for testing for existence of various command line options without needing to add a new query-strict-boot command, but I don't remember what that trick was.
We need a generic query-config-schema command.
Hi all,
The config info is included in qemu-options.def, current
help()definesQEMU_OPTIONS_GENERATE_HELP, and includesqemu-options-wrapper.h, DEF macro will output the help message of options to the stdio.I tried to add two branches in
qemu-options-wrapper.h, which are used to generate two string arraies (one for option name, one for help message)Thy help message is too long, it's failed to output all message to hmp monitor, always got a segfault, the max limitation maybe reached. It's more clear to only output help message of one option,
eg: {"execute": "query-config", "arguments" : {"name": "boot"}}
{"return": {"config": "-boot [order=drives][,once=drives][,menu=on|off]\n
[,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]\n 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n 'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n 'sp_time': the period that splash picture last if menu=on, unit is ms\n 'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n"}}
Quoted 7 lines
Quoted 2 lines
But info command of hmp doesn't support parameter
(eg: (hmp) info config boot)Hi Anthony,
As we talked in IRC, you will send a patch to resolve the query issue. Can you post patch out when you have time? I will review it.
Anthony, ping :)
[1] http://lists.nongnu.org/archive/html/qemu-devel/2013-01/msg01259.html
[2] http://lists.nongnu.org/archive/html/qemu-devel/2013-01/msg05167.html
Quoted 211 lines
Thanks, Amos
Quoted 209 lines
Q1) Is my patch ok for resolve the issue in last email (libvirt can check the help message of each option)?
Q2) Can we only added a command for qmp monitor?
Q3) Is it ok to output all help message for hmp (info config)?
Q4) query-config or query-config-schema ?
hmp-commands.hx +2
-0@@ -1552,6 +1552,8 @@ show the vnc server status show the current VM name @item info uuid show the current VM UUID +@item info config +show config @item info cpustats show CPU statistics @item info usernethmp.c +11
-0@@ -98,6 +98,17 @@ void hmp_info_uuid(Monitor *mon)qapi_free_UuidInfo (info); } +void hmp_info_config (Monitor *mon) +{ +ConfigInfo *info; + +/* Fixed ME: hmp info command doesn't support parameter */ + + info =qmp_query_config ("boot" ,NULL ); +monitor_printf (mon,"%s\n" , info->config); +qapi_free_ConfigInfo (info); +} +void hmp_info_chardev (Monitor *mon) {ChardevInfoList *char_info, *info;hmp.h +1
-0@@ -23,6 +23,7 @@ void hmp_info_version(Monitor *mon);void hmp_info_kvm (Monitor *mon);void hmp_info_status (Monitor *mon);void hmp_info_uuid (Monitor *mon); +void hmp_info_config (Monitor *mon);void hmp_info_chardev (Monitor *mon);void hmp_info_mice (Monitor *mon);void hmp_info_migrate (Monitor *mon);monitor.c +7
-0@@ -2661,6 +2661,13 @@ static mon_cmd_t info_cmds[] = { .help = "show the current VM UUID", .mhandler.info = hmp_info_uuid, }, + { + .name = "config", + .args_type = "", + .params = "", + .help = "show the config", + .mhandler.info = hmp_info_config, + }, #if defined(TARGET_PPC) { .name = "cpustats",qapi-schema.json +20
-0@@ -3017,3 +3017,23 @@ # Since: 1.3.0 ## { 'command': 'nbd-server-stop' } + +## +# @ConfigInfo: +# +# Commandline configration information. +# +## +{ 'type': 'ConfigInfo', 'data': {'config': 'str'} } + +## +# @query-config +# +# Query configuration information of one option +# +# @name: option name +# +# Returns: configuration information. +# +## +{'command': 'query-config', 'data': {'name': 'str'}, 'returns': 'ConfigInfo'}qemu-options-wrapper.h +16
-0@@ -18,6 +18,22 @@#define DEFHEADING (text) ARCHHEADING(text, QEMU_ARCH_ALL) +#elif defined(QEMU_OPTIONS_GENERATE_CONFIG ) + +#define DEF (option, opt_arg, opt_enum, opt_help, arch_mask) \ + opt_help, + +#define DEFHEADING (text) +#define ARCHHEADING (text, arch_mask) + +#elif defined(QEMU_OPTIONS_GENERATE_NAME ) + +#define DEF (option, opt_arg, opt_enum, opt_help, arch_mask) \ + option, + +#define DEFHEADING (text) +#define ARCHHEADING (text, arch_mask) +#elif defined(QEMU_OPTIONS_GENERATE_OPTIONS )#define DEF (option, opt_arg, opt_enum, opt_help, arch_mask) \qmp-commands.hx +23
-0@@ -2339,7 +2339,30 @@ EQMP .args_type = "", .mhandler.cmd_new = qmp_marshal_input_query_uuid, }, +SQMP +query-config +------------ + +Show config. + +- "Config": config + +Example: +-> {"execute": "query-config", "arguments" : {"name": "boot"}} +<- {"return": {"config": "-boot [order=drives][,once=drives][,menu=on|off]\n + [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]\n + 'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n + 'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n + 'sp_time': the period that splash picture last if menu=on, unit is ms\n + 'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n"}} + +EQMP + { + .name = "query-config", + .args_type = "name:s", + .mhandler.cmd_new = qmp_marshal_input_query_config, + }, SQMP query-migrate -------------qmp.c +26
-0@@ -24,6 +24,7 @@#include "hw/qdev.h" #include "sysemu/blockdev.h" #include "qom/qom-qobject.h" +#include "qemu-options.h" NameInfo *qmp_query_name (Error **errp) {@@ -78,6 +79,31 @@ UuidInfo *qmp_query_uuid(Error **errp)return info; } +ConfigInfo *qmp_query_config (const char *name,Error **errp) +{ +ConfigInfo *info =g_malloc0 (sizeof (*info)); + + char const *optionstr[] = { +#define QEMU_OPTIONS_GENERATE_NAME +#include "qemu-options-wrapper.h" + }; + + char const *configstr[] = { +#define QEMU_OPTIONS_GENERATE_CONFIG +#include "qemu-options-wrapper.h" + }; + +int i; +for (i=0 ; i <sizeof (optionstr) /sizeof (char *); i++) { +if (!strcmp (name, optionstr[i])) { + info->config =g_strdup (configstr[i]); +break ; + } + } + +return info; +} +void qmp_quit (Error **err) { no_shutdown =0 ;