Commit e0f084bfc941109047055e229d70695af11a0541

Authored by Jan Kiszka
Committed by Anthony Liguori
1 parent dda9b29f

Add boot-once support

This allows to specify an exceptional boot order only for the first
startup of the guest. After reboot, qemu will switch back to the default
order (or what was specified via 'order='). Makes installing from CD
images and then booting the freshly set up harddisk more handy.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing 1 changed file with 22 additions and 1 deletions
... ... @@ -2402,6 +2402,16 @@ static int parse_bootdevices(char *devices)
2402 2402 return bitmap;
2403 2403 }
2404 2404  
  2405 +static void restore_boot_devices(void *opaque)
  2406 +{
  2407 + char *standard_boot_devices = opaque;
  2408 +
  2409 + qemu_boot_set(standard_boot_devices);
  2410 +
  2411 + qemu_unregister_reset(restore_boot_devices, standard_boot_devices);
  2412 + qemu_free(standard_boot_devices);
  2413 +}
  2414 +
2405 2415 static void numa_add(const char *optarg)
2406 2416 {
2407 2417 char option[128];
... ... @@ -5111,9 +5121,10 @@ int main(int argc, char **argv, char **envp)
5111 5121 case QEMU_OPTION_boot:
5112 5122 {
5113 5123 static const char * const params[] = {
5114   - "order", NULL
  5124 + "order", "once", NULL
5115 5125 };
5116 5126 char buf[sizeof(boot_devices)];
  5127 + char *standard_boot_devices;
5117 5128 int legacy = 0;
5118 5129  
5119 5130 if (!strchr(optarg, '=')) {
... ... @@ -5131,6 +5142,16 @@ int main(int argc, char **argv, char **envp)
5131 5142 boot_devices_bitmap = parse_bootdevices(buf);
5132 5143 pstrcpy(boot_devices, sizeof(boot_devices), buf);
5133 5144 }
  5145 + if (!legacy) {
  5146 + if (get_param_value(buf, sizeof(buf),
  5147 + "once", optarg)) {
  5148 + boot_devices_bitmap |= parse_bootdevices(buf);
  5149 + standard_boot_devices = qemu_strdup(boot_devices);
  5150 + pstrcpy(boot_devices, sizeof(boot_devices), buf);
  5151 + qemu_register_reset(restore_boot_devices,
  5152 + standard_boot_devices);
  5153 + }
  5154 + }
5134 5155 }
5135 5156 break;
5136 5157 case QEMU_OPTION_fda:
... ...