[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCHv4 31/43] plat/kvm: Parse command line from device tree for Arm64


  • To: <minios-devel@xxxxxxxxxxxxxxxxxxxx>, <simon.kuenzer@xxxxxxxxx>
  • From: Wei Chen <Wei.Chen@xxxxxxx>
  • Date: Fri, 6 Jul 2018 09:03:44 +0000
  • Authentication-results: spf=fail (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=arm.com;
  • Cc: Kaly.Xin@xxxxxxx, nd@xxxxxxx, wei.chen@xxxxxxx
  • Delivery-date: Fri, 06 Jul 2018 09:05:54 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Nodisclaimer: True
  • Spamdiagnosticmetadata: NSPM
  • Spamdiagnosticoutput: 1:99

QEMU/KVM can pass parameters to virtual machine through command
line. For Arm64, this command line has been stored in device
tree. We should parse it from device tree for further usage.

Signed-off-by: Wei Chen <Wei.Chen@xxxxxxx>
---
 plat/kvm/arm/setup.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c
index 892a0a9..a881152 100644
--- a/plat/kvm/arm/setup.c
+++ b/plat/kvm/arm/setup.c
@@ -36,6 +36,9 @@
 #include <uk/assert.h>
 #include <uk/essentials.h>
 
+#define MAX_CMDLINE_SIZE 1024
+static char cmdline[MAX_CMDLINE_SIZE];
+
 void *_libkvmplat_dtb;
 
 static void _init_dtb(void *dtb_pointer)
@@ -49,6 +52,32 @@ static void _init_dtb(void *dtb_pointer)
        uk_printd(DLVL_INFO, "Found device tree on: %p\n", dtb_pointer);
 }
 
+static void _dtb_get_cmdline(char *cmdline, size_t maxlen)
+{
+       int fdtchosen, len;
+       const char *fdtcmdline;
+
+       /* TODO: Proper error handling */
+       fdtchosen = fdt_path_offset(_libkvmplat_dtb, "/chosen");
+       if (!fdtchosen)
+               goto enocmdl;
+       fdtcmdline = fdt_getprop(_libkvmplat_dtb, fdtchosen, "bootargs", &len);
+       if (!fdtcmdline || (len <= 0))
+               goto enocmdl;
+
+       strncpy(cmdline, fdtcmdline, MIN(maxlen, (unsigned int) len));
+       /* ensure null termination */
+       cmdline[((unsigned int) len - 1) <= (maxlen - 1) ?
+               ((unsigned int) len - 1) : (maxlen - 1)] = '\0';
+
+       uk_printd(DLVL_INFO, "Command line: %s\n", cmdline);
+       return;
+
+enocmdl:
+       uk_printd(DLVL_INFO, "No command line found\n");
+       strcpy(cmdline, CONFIG_UK_NAME);
+}
+
 static void _init_cpufeatures(void)
 {
        /* TODO */
@@ -61,4 +90,7 @@ void _libkvmplat_start(void *dtb_pointer)
        _libkvmplat_init_console();
 
        uk_printd(DLVL_INFO, "Entering from KVM (arm64)...\n");
+
+       /* Get command line from DTB */
+       _dtb_get_cmdline(cmdline, sizeof(cmdline));
 }
-- 
2.17.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.