Skip to contentSkip to conversation

libxl: check HVM direct boot parameters

PATCH Superseded Wei Liu 2 participants 3 messages Jan 15, 2015 – Jan 19, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 libxl: check HVM direct boot parameters

We should honour -initrd and -append iff -kernel is specified, because that's how QEMU works.

Check direct boot parameters in libxl__domain_build_info_setdefault. Return failure if kernel is missing while ramdisk (-initrd) and / or cmdline (-append) is present.

Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Chunyan Liu <[email protected]>
---
 tools/libxl/libxl_create.c |    9 +++++++++
 1 file changed, 9 insertions(+)
tools/libxl/libxl_create.c +9 -0
index 1198225..31f681e 100644
@@ -170,6 +170,15 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
             break;
         default:abort();
         }
+
+        /* Check HVM direct boot parameters, we should honour ->ramdisk and
+         * ->cmdline iff ->kernel is set.
+         */
+        if (!b_info->kernel && (b_info->ramdisk || b_info->cmdline)) {
+            LIBXL__LOG(CTX, XLT_ERROR,
+                    "direct boot parameters specified but kernel is missing");
+            return ERROR_INVAL;
+        }
     }
 
     if (b_info->type == LIBXL_DOMAIN_TYPE_HVM &&
Signature · 1 line
1.7.10.4
author
#1 lore raw
Quoted 21 lines · Wei Liu

We should honour -initrd and -append iff -kernel is specified, because that's how QEMU works.

Check direct boot parameters in libxl__domain_build_info_setdefault. Return failure if kernel is missing while ramdisk (-initrd) and / or cmdline (-append) is present.

Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Chunyan Liu <[email protected]>
---
 tools/libxl/libxl_create.c |    9 +++++++++
 1 file changed, 9 insertions(+)
tools/libxl/libxl_create.c +0 -0
index 1198225..31f681e 100644

tools/libxl/libxl_create.c int libxl__domain_build_info_setdefault(libxl__gc *gc, · line 179

Quoted 10 lines
tools/libxl/libxl_create.c +7 -0
@@ -170,6 +170,15 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
             break;
         default:abort();
         }
+
+        /* Check HVM direct boot parameters, we should honour ->ramdisk and
+         * ->cmdline iff ->kernel is set.
+         */
+        if (!b_info->kernel && (b_info->ramdisk || b_info->cmdline)) {
+            LIBXL__LOG(CTX, XLT_ERROR,
+                    "direct boot parameters specified but kernel is missing");

Hmm... There's a formatting error. I can resend if it's necessary.

Quoted 7 lines
tools/libxl/libxl_create.c +2 -0
+            return ERROR_INVAL;
+        }
     }
 
     if (b_info->type == LIBXL_DOMAIN_TYPE_HVM &&
Signature · 1 line
1.7.10.4
Acked-by
#2 lore raw
Quoted 26 lines · Wei Liu
Quoted 25 lines · Wei Liu

We should honour -initrd and -append iff -kernel is specified, because that's how QEMU works.

Check direct boot parameters in libxl__domain_build_info_setdefault. Return failure if kernel is missing while ramdisk (-initrd) and / or cmdline (-append) is present.

Cc Ian Campbell <[email protected]>
Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Chunyan Liu <[email protected]>
---
 tools/libxl/libxl_create.c |    9 +++++++++
 1 file changed, 9 insertions(+)
tools/libxl/libxl_create.c +1 -0
index 1198225..31f681e 100644
@@ -170,6 +170,15 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
             break;
         default:abort();
         }
+
Quoted 8 lines

tools/libxl/libxl_create.c int libxl__domain_build_info_setdefault(libxl__gc *gc, · line 179

Quoted 6 lines
tools/libxl/libxl_create.c +6 -0
+        /* Check HVM direct boot parameters, we should honour ->ramdisk and
+         * ->cmdline iff ->kernel is set.
+         */
+        if (!b_info->kernel && (b_info->ramdisk || b_info->cmdline)) {
+            LIBXL__LOG(CTX, XLT_ERROR,
+                    "direct boot parameters specified but kernel is missing");

Hmm... There's a formatting error. I can resend if it's necessary.

In trying to correctly indent this line while committing I pushed it over 80-columns, rather than my rewrapping more, could you make this use the LOG helper please, and thereby pull everything in a bit?

With that done:

Ian.