Преглед изворни кода

Merge remote-tracking branch 'remotes/gonglei/tags/bootdevice-next-20150303' into staging

bootdevice: bug fixes

# gpg: Signature made Tue Mar  3 05:18:39 2015 GMT using RSA key ID DDE30FBB
# gpg: Good signature from "Gonglei <arei.gonglei@huawei.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 5178 9C82 617F 2F58 8693  63B1 BA7A 65B0 DDE3 0FBB

* remotes/gonglei/tags/bootdevice-next-20150303:
  bootdevice: add check in restore_boot_order()
  bootdevice: check boot order argument validation before vm running

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Peter Maydell пре 10 година
родитељ
комит
fff795ab38
2 измењених фајлова са 25 додато и 15 уклоњено
  1. 3 1
      bootdevice.c
  2. 22 14
      vl.c

+ 3 - 1
bootdevice.c

@@ -105,7 +105,9 @@ void restore_boot_order(void *opaque)
         return;
         return;
     }
     }
 
 
-    qemu_boot_set(normal_boot_order, NULL);
+    if (boot_set_handler) {
+        qemu_boot_set(normal_boot_order, &error_abort);
+    }
 
 
     qemu_unregister_reset(restore_boot_order, normal_boot_order);
     qemu_unregister_reset(restore_boot_order, normal_boot_order);
     g_free(normal_boot_order);
     g_free(normal_boot_order);

+ 22 - 14
vl.c

@@ -2733,7 +2733,8 @@ int main(int argc, char **argv, char **envp)
     int snapshot, linux_boot;
     int snapshot, linux_boot;
     const char *initrd_filename;
     const char *initrd_filename;
     const char *kernel_filename, *kernel_cmdline;
     const char *kernel_filename, *kernel_cmdline;
-    const char *boot_order;
+    const char *boot_order = NULL;
+    const char *boot_once = NULL;
     DisplayState *ds;
     DisplayState *ds;
     int cyls, heads, secs, translation;
     int cyls, heads, secs, translation;
     QemuOpts *hda_opts = NULL, *opts, *machine_opts, *icount_opts = NULL;
     QemuOpts *hda_opts = NULL, *opts, *machine_opts, *icount_opts = NULL;
@@ -4048,39 +4049,36 @@ int main(int argc, char **argv, char **envp)
     kernel_cmdline = qemu_opt_get(machine_opts, "append");
     kernel_cmdline = qemu_opt_get(machine_opts, "append");
     bios_name = qemu_opt_get(machine_opts, "firmware");
     bios_name = qemu_opt_get(machine_opts, "firmware");
 
 
-    boot_order = machine_class->default_boot_order;
     opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
     opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
     if (opts) {
     if (opts) {
-        char *normal_boot_order;
-        const char *order, *once;
         Error *local_err = NULL;
         Error *local_err = NULL;
 
 
-        order = qemu_opt_get(opts, "order");
-        if (order) {
-            validate_bootdevices(order, &local_err);
+        boot_order = qemu_opt_get(opts, "order");
+        if (boot_order) {
+            validate_bootdevices(boot_order, &local_err);
             if (local_err) {
             if (local_err) {
                 error_report_err(local_err);
                 error_report_err(local_err);
                 exit(1);
                 exit(1);
             }
             }
-            boot_order = order;
         }
         }
 
 
-        once = qemu_opt_get(opts, "once");
-        if (once) {
-            validate_bootdevices(once, &local_err);
+        boot_once = qemu_opt_get(opts, "once");
+        if (boot_once) {
+            validate_bootdevices(boot_once, &local_err);
             if (local_err) {
             if (local_err) {
                 error_report_err(local_err);
                 error_report_err(local_err);
                 exit(1);
                 exit(1);
             }
             }
-            normal_boot_order = g_strdup(boot_order);
-            boot_order = once;
-            qemu_register_reset(restore_boot_order, normal_boot_order);
         }
         }
 
 
         boot_menu = qemu_opt_get_bool(opts, "menu", boot_menu);
         boot_menu = qemu_opt_get_bool(opts, "menu", boot_menu);
         boot_strict = qemu_opt_get_bool(opts, "strict", false);
         boot_strict = qemu_opt_get_bool(opts, "strict", false);
     }
     }
 
 
+    if (!boot_order) {
+        boot_order = machine_class->default_boot_order;
+    }
+
     if (!kernel_cmdline) {
     if (!kernel_cmdline) {
         kernel_cmdline = "";
         kernel_cmdline = "";
         current_machine->kernel_cmdline = (char *)kernel_cmdline;
         current_machine->kernel_cmdline = (char *)kernel_cmdline;
@@ -4244,6 +4242,16 @@ int main(int argc, char **argv, char **envp)
 
 
     net_check_clients();
     net_check_clients();
 
 
+    if (boot_once) {
+        Error *local_err = NULL;
+        qemu_boot_set(boot_once, &local_err);
+        if (local_err) {
+            error_report("%s", error_get_pretty(local_err));
+            exit(1);
+        }
+        qemu_register_reset(restore_boot_order, g_strdup(boot_order));
+    }
+
     ds = init_displaystate();
     ds = init_displaystate();
 
 
     /* init local displays */
     /* init local displays */