Skip to contentSkip to conversation

hw/s390x: Add the possibility to specify the netboot image on the command line

PATCH Applied Thomas Huth 5 participants 9 messages Feb 27, 2018 – Mar 6, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/s390x: Add the possibility to specify the netboot image on the command line

The file name of the netboot binary is currently hard-coded to "s390-netboot.img", without a possibility for the user to select an alternative firmware image here. That's unfortunate, especially since the basics are already there: The filename is a property of the s390-ipl device. So we just have to add a check whether the user already provided the property and only set the default if the string is still empty. Now it is possible to select a different firmware image with "-global s390-ipl.netboot_fw=/path/to/s390-netboot.img".

---
 hw/s390x/s390-virtio-ccw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +3 -1
index 4abbe89..7b3fb5f 100644
@@ -254,8 +254,10 @@ static void s390_init_ipl_dev(const char *kernel_filename,
     }
     qdev_prop_set_string(dev, "cmdline", kernel_cmdline);
     qdev_prop_set_string(dev, "firmware", firmware);
-    qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
     qdev_prop_set_bit(dev, "enforce_bios", enforce_bios);
+    if (!strlen(object_property_get_str(new, "netboot_fw", &error_abort))) {
+        qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
+    }
     object_property_add_child(qdev_get_machine(), TYPE_S390_IPL,
                               new, NULL);
     object_unref(new);
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 9 lines · Thomas Huth

The file name of the netboot binary is currently hard-coded to "s390-netboot.img", without a possibility for the user to select an alternative firmware image here. That's unfortunate, especially since the basics are already there: The filename is a property of the s390-ipl device. So we just have to add a check whether the user already provided the property and only set the default if the string is still empty. Now it is possible to select a different firmware image with "-global s390-ipl.netboot_fw=/path/to/s390-netboot.img". While I sympathize with the concept, it will be a bit hard to consume

since most of the QEMU instances will be started by libvirt and that has no provisions for this kind of firmware replacement. We could craft some s390-specific variety of the <loader> element.
Another thing to consider is that, while the current netboot firmware doesn't rely on any special QEMU <-> loader interfaces, it might happen that QEMU and the network firmware must match similar to QEMU and the s390-ccw firmware image and I have no idea on how to ensure that.

hw/s390x/s390-virtio-ccw.c static void s390_init_ipl_dev(const char *kernel_filename, · line 256

Quoted 13 lines
---
 hw/s390x/s390-virtio-ccw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +0 -0
index 4abbe89..7b3fb5f 100644
@@ -254,8 +254,10 @@ static void s390_init_ipl_dev(const char *kernel_filename,
     }
     qdev_prop_set_string(dev, "cmdline", kernel_cmdline);
     qdev_prop_set_string(dev, "firmware", firmware);

Wouldn't it be consequent to allow firmware replacement? But then, see above.

Quoted 9 lines
hw/s390x/s390-virtio-ccw.c +3 -1
-    qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
     qdev_prop_set_bit(dev, "enforce_bios", enforce_bios);
+    if (!strlen(object_property_get_str(new, "netboot_fw", &error_abort))) {
+        qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
+    }
     object_property_add_child(qdev_get_machine(), TYPE_S390_IPL,
                               new, NULL);
     object_unref(new);
Signature · 2 lines
Regards,
 Viktor Mihajlovski
#2 lore raw
Quoted 10 lines · Viktor Mihajlovski
Quoted 9 lines · Thomas Huth

The file name of the netboot binary is currently hard-coded to "s390-netboot.img", without a possibility for the user to select an alternative firmware image here. That's unfortunate, especially since the basics are already there: The filename is a property of the s390-ipl device. So we just have to add a check whether the user already provided the property and only set the default if the string is still empty. Now it is possible to select a different firmware image with "-global s390-ipl.netboot_fw=/path/to/s390-netboot.img". While I sympathize with the concept, it will be a bit hard to consume

Quoted 7 lines

since most of the QEMU instances will be started by libvirt and that has no provisions for this kind of firmware replacement. We could craft some s390-specific variety of the <loader> element.
Another thing to consider is that, while the current netboot firmware doesn't rely on any special QEMU <-> loader interfaces, it might happen that QEMU and the network firmware must match similar to QEMU and the s390-ccw firmware image and I have no idea on how to ensure that.

Sure, the normal user likely does not (and should not have to) care about this, and this patch also has not been written with libvirt in mind. It's rather meant for QEMU developer convenience: When I'm changing the code in pc-bios/s390-ccw/ and compiling new images there, I want to use the binary pc-bios/s390-ccw/s390-netboot.img, and not the pre-built image pc-bios/s390-netboot.img. So there must be a way to specify my own images somehow...

Quoted 5 lines
Quoted 5 lines
---
 hw/s390x/s390-virtio-ccw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 10 lines

hw/s390x/s390-virtio-ccw.c static void s390_init_ipl_dev(const char *kernel_filename, · line 256

Quoted 8 lines
hw/s390x/s390-virtio-ccw.c +0 -0
index 4abbe89..7b3fb5f 100644
@@ -254,8 +254,10 @@ static void s390_init_ipl_dev(const char *kernel_filename,
     }
     qdev_prop_set_string(dev, "cmdline", kernel_cmdline);
     qdev_prop_set_string(dev, "firmware", firmware);

Wouldn't it be consequent to allow firmware replacement? But then, see above.

You can already override the main firmware file name with the "-bios" parameter of QEMU, so there's no real need to change this here.

Thomas

#3 lore raw
In reply to Thomas Huth
Quoted 19 lines · Thomas Huth

The file name of the netboot binary is currently hard-coded to "s390-netboot.img", without a possibility for the user to select an alternative firmware image here. That's unfortunate, especially since the basics are already there: The filename is a property of the s390-ipl device. So we just have to add a check whether the user already provided the property and only set the default if the string is still empty. Now it is possible to select a different firmware image with "-global s390-ipl.netboot_fw=/path/to/s390-netboot.img".

---
 hw/s390x/s390-virtio-ccw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +0 -0
index 4abbe89..7b3fb5f 100644

hw/s390x/s390-virtio-ccw.c static void s390_init_ipl_dev(const char *kernel_filename, · line 258

Quoted 6 lines
hw/s390x/s390-virtio-ccw.c +1 -1
@@ -254,8 +254,10 @@ static void s390_init_ipl_dev(const char *kernel_filename,
     }
     qdev_prop_set_string(dev, "cmdline", kernel_cmdline);
     qdev_prop_set_string(dev, "firmware", firmware);
-    qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
     qdev_prop_set_bit(dev, "enforce_bios", enforce_bios);
+    if (!strlen(object_property_get_str(new, "netboot_fw", &error_abort))) {

Isn't it the case that object_property_get_str() can return also NULL?

(looking at s390_ipl_set_loadparm())

Quoted 6 lines
hw/s390x/s390-virtio-ccw.c +2 -0
+        qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
+    }
     object_property_add_child(qdev_get_machine(), TYPE_S390_IPL,
                               new, NULL);
     object_unref(new);
Signature · 3 lines
Thanks,

David / dhildenb
#4 lore raw
Quoted 29 lines · David Hildenbrand
Quoted 19 lines · Thomas Huth

The file name of the netboot binary is currently hard-coded to "s390-netboot.img", without a possibility for the user to select an alternative firmware image here. That's unfortunate, especially since the basics are already there: The filename is a property of the s390-ipl device. So we just have to add a check whether the user already provided the property and only set the default if the string is still empty. Now it is possible to select a different firmware image with "-global s390-ipl.netboot_fw=/path/to/s390-netboot.img".

---
 hw/s390x/s390-virtio-ccw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +0 -0
index 4abbe89..7b3fb5f 100644

hw/s390x/s390-virtio-ccw.c static void s390_init_ipl_dev(const char *kernel_filename, · line 258

Quoted 6 lines
hw/s390x/s390-virtio-ccw.c +1 -1
@@ -254,8 +254,10 @@ static void s390_init_ipl_dev(const char *kernel_filename,
     }
     qdev_prop_set_string(dev, "cmdline", kernel_cmdline);
     qdev_prop_set_string(dev, "firmware", firmware);
-    qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
     qdev_prop_set_bit(dev, "enforce_bios", enforce_bios);
+    if (!strlen(object_property_get_str(new, "netboot_fw", &error_abort))) {

Isn't it the case that object_property_get_str() can return also NULL?

Quoted 1 line

(looking at s390_ipl_set_loadparm())

It can return NULL in case of errors (e.g. the property is not a string or not available at all). In this case, we know that the property is a string and that it is available, so IMHO no need to check for NULL here.

Not sure why s390_ipl_set_loadparm() explicitely checks for this ... maybe this was originally required to support the old s390-virtio (non-ccw) machine, too?

Thomas

#5 lore raw
Quoted 32 lines · On Wed, 28 Feb 2018 13:24:35 +0100 Thomas Huth <[email protected]> wrote:
Quoted 29 lines · David Hildenbrand
Quoted 19 lines · Thomas Huth

The file name of the netboot binary is currently hard-coded to "s390-netboot.img", without a possibility for the user to select an alternative firmware image here. That's unfortunate, especially since the basics are already there: The filename is a property of the s390-ipl device. So we just have to add a check whether the user already provided the property and only set the default if the string is still empty. Now it is possible to select a different firmware image with "-global s390-ipl.netboot_fw=/path/to/s390-netboot.img".

---
 hw/s390x/s390-virtio-ccw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +0 -0
index 4abbe89..7b3fb5f 100644

hw/s390x/s390-virtio-ccw.c static void s390_init_ipl_dev(const char *kernel_filename, · line 258

Quoted 6 lines
hw/s390x/s390-virtio-ccw.c +1 -1
@@ -254,8 +254,10 @@ static void s390_init_ipl_dev(const char *kernel_filename,
     }
     qdev_prop_set_string(dev, "cmdline", kernel_cmdline);
     qdev_prop_set_string(dev, "firmware", firmware);
-    qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
     qdev_prop_set_bit(dev, "enforce_bios", enforce_bios);
+    if (!strlen(object_property_get_str(new, "netboot_fw", &error_abort))) {  

Isn't it the case that object_property_get_str() can return also NULL?

Quoted 1 line

(looking at s390_ipl_set_loadparm())

Quoted 7 lines

It can return NULL in case of errors (e.g. the property is not a string or not available at all). In this case, we know that the property is a string and that it is available, so IMHO no need to check for NULL here.

Not sure why s390_ipl_set_loadparm() explicitely checks for this ... maybe this was originally required to support the old s390-virtio (non-ccw) machine, too?

Probably, IIRC the loadparm patches are quite old. Potential cleanup?

#6 lore raw
In reply to Thomas Huth
Quoted 20 lines · On Tue, 27 Feb 2018 12:32:34 +0100 Thomas Huth <[email protected]> wrote:

The file name of the netboot binary is currently hard-coded to "s390-netboot.img", without a possibility for the user to select an alternative firmware image here. That's unfortunate, especially since the basics are already there: The filename is a property of the s390-ipl device. So we just have to add a check whether the user already provided the property and only set the default if the string is still empty. Now it is possible to select a different firmware image with "-global s390-ipl.netboot_fw=/path/to/s390-netboot.img".

---
 hw/s390x/s390-virtio-ccw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +0 -0
index 4abbe89..7b3fb5f 100644
@@ -254,8 +254,10 @@ static void s390_init_ipl_dev(const char *kernel_filename,
     }

hw/s390x/s390-virtio-ccw.c static void s390_init_ipl_dev(const char *kernel_filename, · line 263

Quoted 10 lines
hw/s390x/s390-virtio-ccw.c +3 -1
     qdev_prop_set_string(dev, "cmdline", kernel_cmdline);
     qdev_prop_set_string(dev, "firmware", firmware);
-    qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
     qdev_prop_set_bit(dev, "enforce_bios", enforce_bios);
+    if (!strlen(object_property_get_str(new, "netboot_fw", &error_abort))) {
+        qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
+    }
     object_property_add_child(qdev_get_machine(), TYPE_S390_IPL,
                               new, NULL);
     object_unref(new);

So, any objections to me merging this? I think this makes sense for Thomas' use case.

#7 lore raw
Quoted 28 lines · Cornelia Huck
Quoted 25 lines · On Tue, 27 Feb 2018 12:32:34 +0100 Thomas Huth <[email protected]> wrote:

The file name of the netboot binary is currently hard-coded to "s390-netboot.img", without a possibility for the user to select an alternative firmware image here. That's unfortunate, especially since the basics are already there: The filename is a property of the s390-ipl device. So we just have to add a check whether the user already provided the property and only set the default if the string is still empty. Now it is possible to select a different firmware image with "-global s390-ipl.netboot_fw=/path/to/s390-netboot.img".

---
 hw/s390x/s390-virtio-ccw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +1 -1
index 4abbe89..7b3fb5f 100644
@@ -254,8 +254,10 @@ static void s390_init_ipl_dev(const char *kernel_filename,
     }
     qdev_prop_set_string(dev, "cmdline", kernel_cmdline);
     qdev_prop_set_string(dev, "firmware", firmware);
-    qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
     qdev_prop_set_bit(dev, "enforce_bios", enforce_bios);
+    if (!strlen(object_property_get_str(new, "netboot_fw", &error_abort))) {
Quoted 8 lines

hw/s390x/s390-virtio-ccw.c static void s390_init_ipl_dev(const char *kernel_filename, · line 263

Quoted 5 lines
hw/s390x/s390-virtio-ccw.c +2 -0
+        qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
+    }
     object_property_add_child(qdev_get_machine(), TYPE_S390_IPL,
                               new, NULL);
     object_unref(new);

So, any objections to me merging this? I think this makes sense for Thomas' use case.

Fine with me.

#8 lore raw
In reply to Thomas Huth
Quoted 20 lines · On Tue, 27 Feb 2018 12:32:34 +0100 Thomas Huth <[email protected]> wrote:

The file name of the netboot binary is currently hard-coded to "s390-netboot.img", without a possibility for the user to select an alternative firmware image here. That's unfortunate, especially since the basics are already there: The filename is a property of the s390-ipl device. So we just have to add a check whether the user already provided the property and only set the default if the string is still empty. Now it is possible to select a different firmware image with "-global s390-ipl.netboot_fw=/path/to/s390-netboot.img".

---
 hw/s390x/s390-virtio-ccw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +0 -0
index 4abbe89..7b3fb5f 100644
@@ -254,8 +254,10 @@ static void s390_init_ipl_dev(const char *kernel_filename,
     }

hw/s390x/s390-virtio-ccw.c static void s390_init_ipl_dev(const char *kernel_filename, · line 263

Quoted 10 lines
hw/s390x/s390-virtio-ccw.c +3 -1
     qdev_prop_set_string(dev, "cmdline", kernel_cmdline);
     qdev_prop_set_string(dev, "firmware", firmware);
-    qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
     qdev_prop_set_bit(dev, "enforce_bios", enforce_bios);
+    if (!strlen(object_property_get_str(new, "netboot_fw", &error_abort))) {
+        qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
+    }
     object_property_add_child(qdev_get_machine(), TYPE_S390_IPL,
                               new, NULL);
     object_unref(new);

Thanks, applied.