Skip to contentSkip to conversation

hw/ppc/spapr.c Set default boot order

PATCH In review [email protected] 6 participants 20 messages Jan 23, 2015 – Apr 2, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 hw/ppc/spapr.c Set default boot order

From: Dinar Valeev <[email protected]>

In order to use -boot once=X option we need to have default list
where restore to on reset.

---
 hw/ppc/spapr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/spapr.c +1 -1
index b560459..3d2cfa3 100644
@@ -1733,7 +1733,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
     mc->block_default_type = IF_SCSI;
     mc->max_cpus = MAX_CPUS;
     mc->no_parallel = 1;
-    mc->default_boot_order = NULL;
+    mc->default_boot_order = "cdn";
     mc->kvm_type = spapr_kvm_type;
     mc->has_dynamic_sysbus = true;
 
Signature · 1 line
2.1.2
#1 lore raw

PATCH 2/2 hw/ppc/spapr Add qemu_register_boot_set for SPAPR

From: Dinar Valeev <[email protected]>

In order to have -boot once=d functioning, it is required to have qemu_register_boot_set

qemu-system-ppc64 -enable-kvm -boot once=d

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device d
...
0 > reset-all

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device cdn
...

---
 hw/ppc/spapr.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/ppc/spapr.c +12 -0
index 3d2cfa3..38b03fc 100644
@@ -314,6 +314,16 @@ static void add_str(GString *s, const gchar *s1)
     g_string_append_len(s, s1, strlen(s1) + 1);
 }
 
+static void spapr_boot_set(void *opaque, const char *boot_device,
+                           Error **errp)
+{
+    int offset;
+    offset = fdt_path_offset(opaque, "/chosen");
+    fdt_setprop_string(opaque, offset, "qemu,boot-device", boot_device);
+
+}
+
+
 static void *spapr_create_fdt_skel(hwaddr initrd_base,
                                    hwaddr initrd_size,
                                    hwaddr kernel_size,
@@ -414,6 +424,8 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
     if (boot_device) {
         _FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device)));
     }
+    qemu_register_boot_set(spapr_boot_set, fdt);
+
     if (boot_menu) {
         _FDT((fdt_property_cell(fdt, "qemu,boot-menu", boot_menu)));
     }
Signature · 1 line
2.1.2
#13 lore raw
In reply to [email protected]
Quoted 6 lines · On 23.01.15 23:51, [email protected] wrote:

From: Dinar Valeev <[email protected]>

In order to use -boot once=X option we need to have default list
where restore to on reset.

Alexey, Nijunj, where is the default boot order stored usually? Is "cdn" an accurate equivalent?

Alex

Quoted 18 lines
---
 hw/ppc/spapr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/spapr.c +1 -1
index b560459..3d2cfa3 100644
@@ -1733,7 +1733,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
     mc->block_default_type = IF_SCSI;
     mc->max_cpus = MAX_CPUS;
     mc->no_parallel = 1;
-    mc->default_boot_order = NULL;
+    mc->default_boot_order = "cdn";
     mc->kvm_type = spapr_kvm_type;
     mc->has_dynamic_sysbus = true;
 
#2 lore raw

Re: [Qemu-devel] [PATCH 2/2] hw/ppc/spapr Add qemu_register_boot_set for SPAPR

In reply to [email protected]
Quoted 49 lines · On 23.01.15 23:51, [email protected] wrote:

From: Dinar Valeev <[email protected]>

In order to have -boot once=d functioning, it is required to have qemu_register_boot_set

qemu-system-ppc64 -enable-kvm -boot once=d

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device d
...
0 > reset-all

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device cdn
...

---
 hw/ppc/spapr.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/ppc/spapr.c +10 -0
index 3d2cfa3..38b03fc 100644
@@ -314,6 +314,16 @@ static void add_str(GString *s, const gchar *s1)
     g_string_append_len(s, s1, strlen(s1) + 1);
 }
 
+static void spapr_boot_set(void *opaque, const char *boot_device,
+                           Error **errp)
+{
+    int offset;
+    offset = fdt_path_offset(opaque, "/chosen");
+    fdt_setprop_string(opaque, offset, "qemu,boot-device", boot_device);
+
+}
+
+
 static void *spapr_create_fdt_skel(hwaddr initrd_base,
                                    hwaddr initrd_size,
                                    hwaddr kernel_size,

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 427

Quoted 4 lines
hw/ppc/spapr.c +1 -0
@@ -414,6 +424,8 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
     if (boot_device) {
         _FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device)));
     }
+    qemu_register_boot_set(spapr_boot_set, fdt);

If you simply move the code above (the _FDT() one) from create_fdt_skel to spapr_finalize_fdt() you should have the same net effect and much cleaner code :).

Alex

Quoted 5 lines
hw/ppc/spapr.c +1 -0
+
     if (boot_menu) {
         _FDT((fdt_property_cell(fdt, "qemu,boot-menu", boot_menu)));
     }
#3 lore raw

Re: [Qemu-devel] [PATCH 2/2] hw/ppc/spapr Add qemu_register_boot_set for SPAPR

Quoted 52 lines · Alexander Graf
Quoted 49 lines · On 23.01.15 23:51, [email protected] wrote:

From: Dinar Valeev <[email protected]>

In order to have -boot once=d functioning, it is required to have qemu_register_boot_set

qemu-system-ppc64 -enable-kvm -boot once=d

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device d
...
0 > reset-all

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device cdn
...

---
  hw/ppc/spapr.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
hw/ppc/spapr.c +10 -0
index 3d2cfa3..38b03fc 100644
@@ -314,6 +314,16 @@ static void add_str(GString *s, const gchar *s1)
      g_string_append_len(s, s1, strlen(s1) + 1);
  }
 
+static void spapr_boot_set(void *opaque, const char *boot_device,
+                           Error **errp)
+{
+    int offset;
+    offset = fdt_path_offset(opaque, "/chosen");
+    fdt_setprop_string(opaque, offset, "qemu,boot-device", boot_device);
+
+}
+
+
  static void *spapr_create_fdt_skel(hwaddr initrd_base,
                                     hwaddr initrd_size,
                                     hwaddr kernel_size,
@@ -414,6 +424,8 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
Quoted 8 lines

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 427

Quoted 4 lines
hw/ppc/spapr.c +1 -0
      if (boot_device) {
          _FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device)));
      }
+    qemu_register_boot_set(spapr_boot_set, fdt);

If you simply move the code above (the _FDT() one) from create_fdt_skel to spapr_finalize_fdt() you should have the same net effect and much cleaner code :).

Haven't tried it, but I suspect -boot once=d on reset will be still equal to -boot d behaviour.

And does it make sense to split boot_device from the rest?

Quoted 8 lines

Alex

Quoted 5 lines
hw/ppc/spapr.c +1 -0
+
      if (boot_menu) {
          _FDT((fdt_property_cell(fdt, "qemu,boot-menu", boot_menu)));
      }
#16 lore raw
Quoted 9 lines · Markus Armbruster
Quoted 4 lines · [email protected] writes:

From: Dinar Valeev <[email protected]>

In order to use -boot once=X option we need to have default list
where restore to on reset.

Really? What happens without this patch?

qemu segfaults on reset.
0 > reset-all Segmentation fault

#4 lore raw

Re: [Qemu-devel] [PATCH 2/2] hw/ppc/spapr Add qemu_register_boot_set for SPAPR

In reply to Alexander Graf
Quoted 52 lines · Alexander Graf
Quoted 49 lines · On 23.01.15 23:51, [email protected] wrote:

From: Dinar Valeev <[email protected]>

In order to have -boot once=d functioning, it is required to have qemu_register_boot_set

qemu-system-ppc64 -enable-kvm -boot once=d

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device d
...
0 > reset-all

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device cdn
...

---
  hw/ppc/spapr.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
hw/ppc/spapr.c +10 -0
index 3d2cfa3..38b03fc 100644
@@ -314,6 +314,16 @@ static void add_str(GString *s, const gchar *s1)
      g_string_append_len(s, s1, strlen(s1) + 1);
  }
 
+static void spapr_boot_set(void *opaque, const char *boot_device,
+                           Error **errp)
+{
+    int offset;
+    offset = fdt_path_offset(opaque, "/chosen");
+    fdt_setprop_string(opaque, offset, "qemu,boot-device", boot_device);
+
+}
+
+
  static void *spapr_create_fdt_skel(hwaddr initrd_base,
                                     hwaddr initrd_size,
                                     hwaddr kernel_size,
@@ -414,6 +424,8 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
Quoted 8 lines

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 427

Quoted 4 lines
hw/ppc/spapr.c +1 -0
      if (boot_device) {
          _FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device)));
      }
+    qemu_register_boot_set(spapr_boot_set, fdt);

If you simply move the code above (the _FDT() one) from create_fdt_skel to spapr_finalize_fdt() you should have the same net effect and much cleaner code :).

I've tried your proposal, on reset boot-device property stays "d"

qemu,boot-device d
0 > reset-all
qemu,boot-device d

Here is what I tried:
@@ -411,9 +410,6 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,

             _FDT((fdt_property(fdt, "qemu,boot-kernel-le", NULL, 0)));
         }
     }
-    if (boot_device) {
-        _FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device)));
-    }
     if (boot_menu) {
         _FDT((fdt_property_cell(fdt, "qemu,boot-menu", boot_menu)));
     }
@@ -730,6 +726,8 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,
     char *bootlist;
     void *fdt;
     sPAPRPHBState *phb;

+ MachineState *machine = MACHINE(qdev_get_machine());
+ const char *boot_device = machine->boot_order;

     fdt = g_malloc(FDT_MAX_SIZE);

@@ -769,6 +767,14 @@ static void spapr_finalize_fdt(sPAPREnvironment *spapr,

         fprintf(stderr, "Couldn't finalize CPU device tree properties\n");
     }

+ if (boot_device) {

+        int offset = fdt_path_offset(fdt, "/chosen");
+        ret = fdt_setprop_string(fdt, offset, "qemu,boot-device", boot_device);
+        if (ret < 0) {

+ fprintf(stderr, "Couldn't set up boot-device dt property\n");
+ }
+ }
+

     bootlist = get_boot_devices_list(&cb, true);
     if (cb && bootlist) {
         int offset = fdt_path_offset(fdt, "/chosen");

Dinar,

Quoted 8 lines

Alex

Quoted 5 lines
hw/ppc/spapr.c +1 -0
+
      if (boot_menu) {
          _FDT((fdt_property_cell(fdt, "qemu,boot-menu", boot_menu)));
      }
#17 lore raw
In reply to Dinar Valeev
Quoted 5 lines · Dinar Valeev
Quoted 4 lines · Markus Armbruster
Quoted 2 lines · [email protected] writes:

From: Dinar Valeev <[email protected]>

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

In order to use -boot once=X option we need to have default list
where restore to on reset.

Really? What happens without this patch?

qemu segfaults on reset.
0 > reset-all Segmentation fault

Next time, include a backtrace, please.

Here's what I think happens.

Boot order comes from --boot parameter once, order, or else the machine type's .default_boot_order. The latter is null for you.

It gets passed via ppc_spapr_init() to spapr_create_fdt_skel(), which sets qemu,boot-device in the FDT to it, but only when it isn't null.

If it comes from parameter once, we additionally register a reset handler to switch it to parameter order or else .default_boot_order on reset. If you specify once, but not order, this is null for you.

On reset, reset handler restore_boot_order() runs. Unlike spapr_create_fdt_skel(), it doesn't check for null, and crashes in validate_bootdevices().

Correct?

For me, a null .default_boot_order means "machine type does not support boot order" (this is how commit c165473 treats it). Arguably, --boot order and once should be rejected then.

If I understand you correctly, your machine type does support boot order. Giving it a non-null .default_boot_order makes sense then. The appropriate value depends on firmware. It could even be "".

The null check in spapr_create_fdt_skel() looks superfluous then. Consider dropping it.

Makes sense?

#18 lore raw
Quoted 10 lines · Markus Armbruster
Quoted 8 lines · Dinar Valeev
Quoted 7 lines · Markus Armbruster
Quoted 4 lines · [email protected] writes:

From: Dinar Valeev <[email protected]>

In order to use -boot once=X option we need to have default list
where restore to on reset.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Really? What happens without this patch?

qemu segfaults on reset.
0 > reset-all Segmentation fault

Next time, include a backtrace, please.

Ok, sorry for that.

Quoted 13 lines

Here's what I think happens.

Boot order comes from --boot parameter once, order, or else the machine type's .default_boot_order. The latter is null for you.

It gets passed via ppc_spapr_init() to spapr_create_fdt_skel(), which sets qemu,boot-device in the FDT to it, but only when it isn't null.

If it comes from parameter once, we additionally register a reset handler to switch it to parameter order or else .default_boot_order on reset. If you specify once, but not order, this is null for you.

Quoted 5 lines

On reset, reset handler restore_boot_order() runs. Unlike spapr_create_fdt_skel(), it doesn't check for null, and crashes in validate_bootdevices().

Correct?

Yes

qemu_register_boot_set is implemented in PATCH 2/2. on reset boot_device is restored to NULL

Quoted 4 lines

For me, a null .default_boot_order means "machine type does not support boot order" (this is how commit c165473 treats it). Arguably, --boot order and once should be rejected then.

AFICS SLOF handles qemu,boot-device as boot device, if nothing passed then it goes disk, cdrom, network. Which is the same as "cdn" list.

Quoted 9 lines

If I understand you correctly, your machine type does support boot order. Giving it a non-null .default_boot_order makes sense then. The appropriate value depends on firmware. It could even be "".

The null check in spapr_create_fdt_skel() looks superfluous then. Consider dropping it.

Makes sense?

#19 lore raw
Quoted 36 lines · Dinar Valeev
Quoted 10 lines · Markus Armbruster
Quoted 8 lines · Dinar Valeev
Quoted 7 lines · Markus Armbruster
Quoted 4 lines · [email protected] writes:

From: Dinar Valeev <[email protected]>

In order to use -boot once=X option we need to have default list
where restore to on reset.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Really? What happens without this patch?

qemu segfaults on reset.
0 > reset-all Segmentation fault

Next time, include a backtrace, please.

Ok, sorry for that.

Quoted 13 lines

Here's what I think happens.

Boot order comes from --boot parameter once, order, or else the machine type's .default_boot_order. The latter is null for you.

It gets passed via ppc_spapr_init() to spapr_create_fdt_skel(), which sets qemu,boot-device in the FDT to it, but only when it isn't null.

If it comes from parameter once, we additionally register a reset handler to switch it to parameter order or else .default_boot_order on reset. If you specify once, but not order, this is null for you.

Quoted 5 lines

On reset, reset handler restore_boot_order() runs. Unlike spapr_create_fdt_skel(), it doesn't check for null, and crashes in validate_bootdevices().

Correct?

Quoted 8 lines

Yes

qemu_register_boot_set is implemented in PATCH 2/2. on reset boot_device is restored to NULL

Quoted 4 lines

For me, a null .default_boot_order means "machine type does not support boot order" (this is how commit c165473 treats it). Arguably, --boot order and once should be rejected then.

AFICS SLOF handles qemu,boot-device as boot device, if nothing passed then it goes disk, cdrom, network. Which is the same as "cdn" list.

That's not entirely true. If SLOF doesn't see qemu,boot-device, it first goes via its NVRAM configured boot list and only if nothing is there it falls back to "cdn".

Maybe the actual appropriate thing would be "mcdn" with m meaning "NVRAM".

Alex

Quoted 11 lines
Quoted 10 lines

If I understand you correctly, your machine type does support boot order. Giving it a non-null .default_boot_order makes sense then. The appropriate value depends on firmware. It could even be "".

The null check in spapr_create_fdt_skel() looks superfluous then. Consider dropping it.

Makes sense?

#5 lore raw

Re: [Qemu-devel] [PATCH 2/2] hw/ppc/spapr Add qemu_register_boot_set for SPAPR

In reply to Dinar Valeev
Quoted 64 lines · Dinar Valeev
Quoted 55 lines · Alexander Graf
Quoted 52 lines · On 23.01.15 23:51, [email protected] wrote:

From: Dinar Valeev <[email protected]>

In order to have -boot once=d functioning, it is required to have qemu_register_boot_set

qemu-system-ppc64 -enable-kvm -boot once=d

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device d
...
0 > reset-all

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device cdn
...

---
  hw/ppc/spapr.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
hw/ppc/spapr.c +10 -0
index 3d2cfa3..38b03fc 100644
@@ -314,6 +314,16 @@ static void add_str(GString *s, const gchar *s1)
      g_string_append_len(s, s1, strlen(s1) + 1);
  }
 
+static void spapr_boot_set(void *opaque, const char *boot_device,
+                           Error **errp)
+{
+    int offset;
+    offset = fdt_path_offset(opaque, "/chosen");
+    fdt_setprop_string(opaque, offset, "qemu,boot-device", 
 boot_device);
+
+}
+
+
  static void *spapr_create_fdt_skel(hwaddr initrd_base,
                                     hwaddr initrd_size,

hwaddr kernel_size,

hw/ppc/spapr.c +0 -0
@@ -414,6 +424,8 @@ static void *spapr_create_fdt_skel(hwaddr 
 initrd_base,
      if (boot_device) {
Quoted 8 lines

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr · line 429

Quoted 4 lines
hw/ppc/spapr.c +1 -0
          _FDT((fdt_property_string(fdt, "qemu,boot-device", 
 boot_device)));
      }
+    qemu_register_boot_set(spapr_boot_set, fdt);

If you simply move the code above (the _FDT() one) from create_fdt_skel to spapr_finalize_fdt() you should have the same net effect and much cleaner code :).

Quoted 1 line

I've tried your proposal, on reset boot-device property stays "d"

Ugh, the machine field doesn't change on reset. I think it'd be a lot more intuitive if it did. Can you try with the patch below applied as well?

bootdevice.c +2 -0
index 5914417..3b750ff 100644
@@ -50,6 +50,7 @@ void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque)
 void qemu_boot_set(const char *boot_order, Error **errp)
 {
     Error *local_err = NULL;
+    MachineState *machine = MACHINE(qdev_get_machine());
 
     if (!boot_set_handler) {
         error_setg(errp, "no function defined to set boot device list for"
@@ -63,6 +64,7 @@ void qemu_boot_set(const char *boot_order, Error **errp)
         return;
     }
 
+    machine->boot_order = boot_order;
     boot_set_handler(boot_set_opaque, boot_order, errp);
 }
 

Thanks,

Alex

#14 lore raw
In reply to Alexander Graf
Quoted 9 lines · Alexander Graf
Quoted 6 lines · On 23.01.15 23:51, [email protected] wrote:

From: Dinar Valeev <[email protected]>

In order to use -boot once=X option we need to have default list
where restore to on reset.

Alexey, Nijunj, where is the default boot order stored usually?

When -boot argument is not present, the default boot order is NULL for spapr, and SLOF decides to boot from NVRAM set variable or discovered disk.

Quoted 1 line

Is "cdn" an accurate equivalent?

No, we have changed that to NULL.

http://comments.gmane.org/gmane.comp.emulators.qemu/187318

Regards,
Nikunj

#6 lore raw

Re: [Qemu-devel] [PATCH 2/2] hw/ppc/spapr Add qemu_register_boot_set for SPAPR

In reply to Alexander Graf
Quoted 62 lines · Alexander Graf
Quoted 61 lines · Dinar Valeev
Quoted 60 lines · Alexander Graf
Quoted 49 lines · On 23.01.15 23:51, [email protected] wrote:

From: Dinar Valeev <[email protected]>

In order to have -boot once=d functioning, it is required to have qemu_register_boot_set

qemu-system-ppc64 -enable-kvm -boot once=d

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device d
...
0 > reset-all

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device cdn
...

---
  hw/ppc/spapr.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
hw/ppc/spapr.c +10 -0
index 3d2cfa3..38b03fc 100644
@@ -314,6 +314,16 @@ static void add_str(GString *s, const gchar *s1)
      g_string_append_len(s, s1, strlen(s1) + 1);
  }
 
+static void spapr_boot_set(void *opaque, const char *boot_device,
+                           Error **errp)
+{
+    int offset;
+    offset = fdt_path_offset(opaque, "/chosen");
+    fdt_setprop_string(opaque, offset, "qemu,boot-device", boot_device);
+
+}
+
+
  static void *spapr_create_fdt_skel(hwaddr initrd_base,
                                     hwaddr initrd_size,
                                     hwaddr kernel_size,

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 427

Quoted 4 lines
hw/ppc/spapr.c +1 -0
@@ -414,6 +424,8 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
      if (boot_device) {
          _FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device)));
      }
+    qemu_register_boot_set(spapr_boot_set, fdt);

If you simply move the code above (the _FDT() one) from create_fdt_skel to spapr_finalize_fdt() you should have the same net effect and much cleaner code :).

Quoted 4 lines
Quoted 1 line

I've tried your proposal, on reset boot-device property stays "d"

Ugh, the machine field doesn't change on reset. I think it'd be a lot more intuitive if it did. Can you try with the patch below applied as well?

This approach is not good because boot_set_handler is NULL and return error directly. Please using qemu_register_boot_set for this purpose.

Regards,
-Gonglei

Quoted 28 lines
bootdevice.c +2 -0
index 5914417..3b750ff 100644
@@ -50,6 +50,7 @@ void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque)
 void qemu_boot_set(const char *boot_order, Error **errp)
 {
     Error *local_err = NULL;
+    MachineState *machine = MACHINE(qdev_get_machine());
 
     if (!boot_set_handler) {
         error_setg(errp, "no function defined to set boot device list for"
@@ -63,6 +64,7 @@ void qemu_boot_set(const char *boot_order, Error **errp)
         return;
     }
 
+    machine->boot_order = boot_order;
     boot_set_handler(boot_set_opaque, boot_order, errp);
 }
 

Thanks,

Alex

#7 lore raw

Re: [Qemu-devel] [PATCH 2/2] hw/ppc/spapr Add qemu_register_boot_set for SPAPR

Quoted 64 lines · Gonglei
Quoted 62 lines · Alexander Graf
Quoted 61 lines · Dinar Valeev
Quoted 60 lines · Alexander Graf
Quoted 49 lines · On 23.01.15 23:51, [email protected] wrote:

From: Dinar Valeev <[email protected]>

In order to have -boot once=d functioning, it is required to have qemu_register_boot_set

qemu-system-ppc64 -enable-kvm -boot once=d

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device d
...
0 > reset-all

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device cdn
...

---
  hw/ppc/spapr.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
hw/ppc/spapr.c +10 -0
index 3d2cfa3..38b03fc 100644
@@ -314,6 +314,16 @@ static void add_str(GString *s, const gchar *s1)
      g_string_append_len(s, s1, strlen(s1) + 1);
  }
 
+static void spapr_boot_set(void *opaque, const char *boot_device,
+                           Error **errp)
+{
+    int offset;
+    offset = fdt_path_offset(opaque, "/chosen");
+    fdt_setprop_string(opaque, offset, "qemu,boot-device", boot_device);
+
+}
+
+
  static void *spapr_create_fdt_skel(hwaddr initrd_base,
                                     hwaddr initrd_size,
                                     hwaddr kernel_size,

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 427

Quoted 4 lines
hw/ppc/spapr.c +1 -0
@@ -414,6 +424,8 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
      if (boot_device) {
          _FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device)));
      }
+    qemu_register_boot_set(spapr_boot_set, fdt);

If you simply move the code above (the _FDT() one) from create_fdt_skel to spapr_finalize_fdt() you should have the same net effect and much cleaner code :).

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I've tried your proposal, on reset boot-device property stays "d"

Ugh, the machine field doesn't change on reset. I think it'd be a lot more intuitive if it did. Can you try with the patch below applied as well?

This approach is not good because boot_set_handler is NULL and return error directly. Please using qemu_register_boot_set for this purpose.

I'd personally prefer if we get rid of qemu_register_boot_set completely. It duplicates the reset logic as well as information holder locality (machine struct vs parameter).

Alex

#8 lore raw

Re: [Qemu-devel] [PATCH 2/2] hw/ppc/spapr Add qemu_register_boot_set for SPAPR

Quoted 72 lines · Alexander Graf
Quoted 69 lines · Gonglei
Quoted 66 lines · Alexander Graf
Quoted 61 lines · Dinar Valeev
Quoted 52 lines · Alexander Graf
Quoted 49 lines · On 23.01.15 23:51, [email protected] wrote:

From: Dinar Valeev <[email protected]>

In order to have -boot once=d functioning, it is required to have qemu_register_boot_set

qemu-system-ppc64 -enable-kvm -boot once=d

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device d
...
0 > reset-all

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device cdn
...

---
  hw/ppc/spapr.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
hw/ppc/spapr.c +10 -0
index 3d2cfa3..38b03fc 100644
@@ -314,6 +314,16 @@ static void add_str(GString *s, const gchar *s1)
      g_string_append_len(s, s1, strlen(s1) + 1);
  }
 
+static void spapr_boot_set(void *opaque, const char *boot_device,
+                           Error **errp)
+{
+    int offset;
+    offset = fdt_path_offset(opaque, "/chosen");
+    fdt_setprop_string(opaque, offset, "qemu,boot-device", boot_device);
+
+}
+
+
  static void *spapr_create_fdt_skel(hwaddr initrd_base,
                                     hwaddr initrd_size,
                                     hwaddr kernel_size,
@@ -414,6 +424,8 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
Quoted 8 lines

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 427

Quoted 4 lines
hw/ppc/spapr.c +1 -0
      if (boot_device) {
          _FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device)));
      }
+    qemu_register_boot_set(spapr_boot_set, fdt);

If you simply move the code above (the _FDT() one) from create_fdt_skel to spapr_finalize_fdt() you should have the same net effect and much cleaner code :).

Quoted 1 line

I've tried your proposal, on reset boot-device property stays "d"

Ugh, the machine field doesn't change on reset. I think it'd be a lot more intuitive if it did. Can you try with the patch below applied as well?

Quoted 7 lines
Quoted 2 lines

This approach is not good because boot_set_handler is NULL and return error directly. Please using qemu_register_boot_set for this purpose.

I'd personally prefer if we get rid of qemu_register_boot_set completely. It duplicates the reset logic as well as information holder locality (machine struct vs parameter).

Maybe yes. But lots of other machines do not register reset callback. So those machines using qemu_register_boot_set() register a handler callback achieve this purpose.

Regards,
-Gonglei

#9 lore raw

Re: [Qemu-devel] [PATCH 2/2] hw/ppc/spapr Add qemu_register_boot_set for SPAPR

Quoted 77 lines · Gonglei
Quoted 75 lines · Alexander Graf
Quoted 71 lines · Gonglei
Quoted 62 lines · Alexander Graf
Quoted 61 lines · Dinar Valeev
Quoted 60 lines · Alexander Graf
Quoted 49 lines · On 23.01.15 23:51, [email protected] wrote:

From: Dinar Valeev <[email protected]>

In order to have -boot once=d functioning, it is required to have qemu_register_boot_set

qemu-system-ppc64 -enable-kvm -boot once=d

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device d
...
0 > reset-all

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device cdn
...

---
  hw/ppc/spapr.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
hw/ppc/spapr.c +10 -0
index 3d2cfa3..38b03fc 100644
@@ -314,6 +314,16 @@ static void add_str(GString *s, const gchar *s1)
      g_string_append_len(s, s1, strlen(s1) + 1);
  }
 
+static void spapr_boot_set(void *opaque, const char *boot_device,
+                           Error **errp)
+{
+    int offset;
+    offset = fdt_path_offset(opaque, "/chosen");
+    fdt_setprop_string(opaque, offset, "qemu,boot-device", boot_device);
+
+}
+
+
  static void *spapr_create_fdt_skel(hwaddr initrd_base,
                                     hwaddr initrd_size,
                                     hwaddr kernel_size,

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 427

Quoted 4 lines
hw/ppc/spapr.c +1 -0
@@ -414,6 +424,8 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
      if (boot_device) {
          _FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device)));
      }
+    qemu_register_boot_set(spapr_boot_set, fdt);

If you simply move the code above (the _FDT() one) from create_fdt_skel to spapr_finalize_fdt() you should have the same net effect and much cleaner code :).

Quoted 4 lines
Quoted 1 line

I've tried your proposal, on reset boot-device property stays "d"

Ugh, the machine field doesn't change on reset. I think it'd be a lot more intuitive if it did. Can you try with the patch below applied as well?

This approach is not good because boot_set_handler is NULL and return error directly. Please using qemu_register_boot_set for this purpose.

Quoted 8 lines
Quoted 4 lines

I'd personally prefer if we get rid of qemu_register_boot_set completely. It duplicates the reset logic as well as information holder locality (machine struct vs parameter).

Maybe yes. But lots of other machines do not register reset callback. So those machines using qemu_register_boot_set() register a handler callback achieve this purpose.

I think we're better off just registering reset handlers then.

Alex

#10 lore raw

Re: [Qemu-devel] [PATCH 2/2] hw/ppc/spapr Add qemu_register_boot_set for SPAPR

Quoted 85 lines · Alexander Graf
Quoted 82 lines · Gonglei
Quoted 79 lines · Alexander Graf
Quoted 64 lines · Gonglei
Quoted 62 lines · Alexander Graf
Quoted 61 lines · Dinar Valeev
Quoted 60 lines · Alexander Graf
Quoted 49 lines · On 23.01.15 23:51, [email protected] wrote:

From: Dinar Valeev <[email protected]>

In order to have -boot once=d functioning, it is required to have qemu_register_boot_set

qemu-system-ppc64 -enable-kvm -boot once=d

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device d
...
0 > reset-all

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device cdn
...

---
  hw/ppc/spapr.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
hw/ppc/spapr.c +10 -0
index 3d2cfa3..38b03fc 100644
@@ -314,6 +314,16 @@ static void add_str(GString *s, const gchar *s1)
      g_string_append_len(s, s1, strlen(s1) + 1);
  }
 
+static void spapr_boot_set(void *opaque, const char *boot_device,
+                           Error **errp)
+{
+    int offset;
+    offset = fdt_path_offset(opaque, "/chosen");
+    fdt_setprop_string(opaque, offset, "qemu,boot-device", boot_device);
+
+}
+
+
  static void *spapr_create_fdt_skel(hwaddr initrd_base,
                                     hwaddr initrd_size,
                                     hwaddr kernel_size,

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr initrd_base, · line 427

Quoted 4 lines
hw/ppc/spapr.c +1 -0
@@ -414,6 +424,8 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
      if (boot_device) {
          _FDT((fdt_property_string(fdt, "qemu,boot-device", boot_device)));
      }
+    qemu_register_boot_set(spapr_boot_set, fdt);

If you simply move the code above (the _FDT() one) from create_fdt_skel to spapr_finalize_fdt() you should have the same net effect and much cleaner code :).

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I've tried your proposal, on reset boot-device property stays "d"

Ugh, the machine field doesn't change on reset. I think it'd be a lot more intuitive if it did. Can you try with the patch below applied as well?

This approach is not good because boot_set_handler is NULL and return error directly. Please using qemu_register_boot_set for this purpose.

I'd personally prefer if we get rid of qemu_register_boot_set completely. It duplicates the reset logic as well as information holder locality (machine struct vs parameter).

Quoted 6 lines
Quoted 3 lines

Maybe yes. But lots of other machines do not register reset callback. So those machines using qemu_register_boot_set() register a handler callback achieve this purpose.

I think we're better off just registering reset handlers then.

Just like what we said in other thread, remove the check about handler, I will post a patch soon.

Regards,
-Gonglei

#11 lore raw

Re: [Qemu-devel] [PATCH 2/2] hw/ppc/spapr Add qemu_register_boot_set for SPAPR

Quoted 100 lines · Gonglei
Quoted 42 lines · Alexander Graf
Quoted 39 lines · Gonglei
Quoted 37 lines · Alexander Graf
Quoted 34 lines · Gonglei
Quoted 32 lines · Alexander Graf
Quoted 31 lines · Dinar Valeev
Quoted 30 lines · Alexander Graf
Quoted 27 lines · On 23.01.15 23:51, [email protected] wrote:

From: Dinar Valeev <[email protected]>

In order to have -boot once=d functioning, it is required to have qemu_register_boot_set

qemu-system-ppc64 -enable-kvm -boot once=d

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device d
...
0 > reset-all

Ready!
0 > dev /chosen ok
0 > .properties
...
qemu,boot-device cdn
...

---
  hw/ppc/spapr.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

hw/ppc/spapr.c static void add_str(GString *s, const gchar

Quoted 5 lines
hw/ppc/spapr.c +0 -0
index 3d2cfa3..38b03fc 100644
@@ -314,6 +314,16 @@ static void add_str(GString *s, const gchar

*s1)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

hw/ppc/spapr.c static void add_str(GString *s, const gchar · line 322

Quoted 9 lines
hw/ppc/spapr.c +6 -0
      g_string_append_len(s, s1, strlen(s1) + 1);
  }
 
+static void spapr_boot_set(void *opaque, const char *boot_device,
+                           Error **errp)
+{
+    int offset;
+    offset = fdt_path_offset(opaque, "/chosen");
+    fdt_setprop_string(opaque, offset, "qemu,boot-device",

boot_device);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr

Quoted 8 lines
hw/ppc/spapr.c +4 -0
+
+}
+
+
  static void *spapr_create_fdt_skel(hwaddr initrd_base,
                                     hwaddr initrd_size,
                                     hwaddr kernel_size,
@@ -414,6 +424,8 @@ static void *spapr_create_fdt_skel(hwaddr

initrd_base,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr · line 425

Quoted 2 lines
hw/ppc/spapr.c +0 -0
      if (boot_device) {
          _FDT((fdt_property_string(fdt, "qemu,boot-device",

boot_device)));

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

hw/ppc/spapr.c static void *spapr_create_fdt_skel(hwaddr · line 427

Quoted 2 lines
hw/ppc/spapr.c +1 -0
      }
+    qemu_register_boot_set(spapr_boot_set, fdt);

If you simply move the code above (the _FDT() one) from

create_fdt_skel

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

to spapr_finalize_fdt() you should have the same net effect and

much

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

cleaner code :).

I've tried your proposal, on reset boot-device property stays "d"

Ugh, the machine field doesn't change on reset. I think it'd be a

lot more intuitive if it did. Can you try with the patch below applied as well?

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

This approach is not good because boot_set_handler is NULL and return

error directly.

Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
Quoted 1 line

Please using qemu_register_boot_set for this purpose.

I'd personally prefer if we get rid of qemu_register_boot_set completely. It duplicates the reset logic as well as information holder locality (machine struct vs parameter).

Maybe yes. But lots of other machines do not register reset callback. So those machines using qemu_register_boot_set() register a handler callback achieve this purpose.

Quoted 6 lines
Quoted 2 lines

I think we're better off just registering reset handlers then.

Just like what we said in other thread, remove the check about handler, I will post a patch soon.

Have you posted the patch? Cannot find it in the lists so I assume you have not :-) Thanks!

Quoted 6 lines

Regards,
-Gonglei

Signature · 2 lines
-- 
Alexey
#12 lore raw

Re: [Qemu-devel] [PATCH 2/2] hw/ppc/spapr Add qemu_register_boot_set for SPAPR

Quoted 9 lines · Alexey Kardashevskiy
Quoted 4 lines

Just like what we said in other thread, remove the check about handler, I will post a patch soon.

Have you posted the patch? Cannot find it in the lists so I assume you have not :-) Thanks!

I had posted the patch which caused a regression about HMP command hmp_boot_set(). By discussion again and again, we decide to remain the original style. If you guys want to use this feature, please register the handler. BTW I saw somebody had submitted patches with handler in the maillist. :)

Regards,
-Gonglei