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

[PATCH v4 3/3] cmdline: parse multiple instances of the vga option


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Wed, 5 Jul 2023 13:47:41 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zgKxqQHr4ShwbPmBjiVo8c6X9VCkUpAoN5RBLlpefTM=; b=DppKI6M5d3lSBQNoAb02xgH3QpVsPthQuyXOa38WYOdjHe1fT5sOXyXzX9Kq9lxPqd+to8CkirXTNS4+jXZVf1ReHzB1b/e+OBFIN9ka4LxwLe3Bmx1uOODqKe6DzZakGphgGrDJenL4k47lVP6zCmftF+gJLLDL/jVDj5g9AUFf+d4EZ4Xpnb/v7T1YEQmCO7nO3C7WeBNCiGZpgMEHCcACP5T3M7QWDORf+kwvZ7JjofPq8JuNqU6wMZJcNGIErgILi6wPyeN4G6NakNYcRBXxxpPpoXTMYFgj701Nv4ic+aMaehYaa9rxNFxtSt3fbiL3ZmRFLWKA7nQTLSmDbg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U4HFPfDsqOmfzYJUGO2R+PhYV8yuirtcum/mLRVgy0Teu1gXq5C8xNAPoQqEmG+rPw0geVpf+rd4L4KBiWV6+OyjtLD0xRawGwPeTbY5dnsb/fajSY+f2qhBi4YmbDP0PWaiME0F2os8y5gI9Yq0c2buPl9faVgsEhFPSiY3TzJub/zEf8p4ufizDfegXK5rBVQbfoTHbyaT7pG/r6BICup19fyb4CbOpxmIMaKgQV4XQ8BEedpdB6ZKbLPr1+lvL3AxK4L5xJRMD82ZBCUb9E2G+M8GOEziQJjl+SJlXSc+qC2DJkigcgyL3qo2caffXBWGYJ3cIOTutUPUvoH3hg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Wed, 05 Jul 2023 11:48:19 +0000
  • Ironport-data: A9a23:qYjbrKC7V3IToRVW/w7iw5YqxClBgxIJ4kV8jS/XYbTApGkk3zQBz mAZXT2Fa/eJNDT8c9EkOYzn9R5XsJeGmtBrQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nOHuGmYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbCRMsspvlDs15K6p4GxA4wRkDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIw1txMJmF/r 9MiawshZSCsgOuW8oyxRbw57igjBJGD0II3nFhFlWucNtB/BJfJTuPN+MNS2yo2ioZWB/HCa sEFaD1pKhPdfxlIPVRRA5U79AuqriCnL3sE9xTI+uxruAA/zyQouFTpGMDSddGQA91cg26Tp 37c/nS/CRYfXDCa4WPcrS382LGfzUsXXqopM+GS+PB1r2G3z00eKSMuXlC4kaGQ3xvWt9V3b hZ8FjAVhbg/8gmnQ8fwWzW8oWWYpVgMVtxICeo45QqRjK3O7G6xBGIJUzpAY9wOr9ItSHoh0 Vrht8ztLSxitvuSU331y1uPhTa7OCxQNmlbYyYBFVEB+4O7/Np1iQ/TRNF+FqLzlsfyBTz73 zGNqm45mqkXiskIka68+Dgrng6Rm3QAdSZtji2/Y45vxlkRiFKND2Bw1WXm0A==
  • Ironport-hdrordr: A9a23:uPEUa6FEr4c6R+1xpLqFVZHXdLJyesId70hD6qkvc3Nom52j+/ xGws536fatskdqZJkh8erwWpVoMkmsiKKdgLNhd4tKMzOW3ldAQLsD0WKm+UyaJ8SczJ8R6U 4DSdkGNDSYNzET5qyVgTVQUexQuOVvmJrYwts2pE0dKD2CHpsQiDuRfTzrdnGeKjM2ZqYRJd 653I5qtjCgcXMYYoCQHX8eRdXOoNXNidbPfQMGLwRP0njDsRqYrJrBVzSI1BYXVD1ChZ0493 LergD/7qK/99mm1x7n0XPJ5Zg+oqqv9jIDPr3DtiEmEESttu+aXvUjZ1REhkF2nAib0idqrD ALmWZkAy080QKUQoj/m2qQ5+Cp6kdQ15al8y7fvZKrm72JeBsqT4dam4JFeBqx0TtfgPhslK 1MxG6XrJxREFfJmzn8/cHBU1VwmlOzumdKq59bs5Vza/poVFZql/1owGpFVJMbWC7q4oEuF+ djSMna+fZNaFufK3TUpHNmztCgVmk6Wk7ueDlIhuWFlzxN2HxpxUoRw8IS2n8G6ZImUpFBo+ DJKL5hmr1CRtIfKah9GOACS82qDXGle2OFDEuCZVD8UK0XMXPErJD6pL0z+eGxYZQNiIA/nZ zQOWkowVLau3iefPFm8Kc7gCwlGl/NLQgF4vsulKREhg==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Parse all instances of the vga= option on the command line, in order
to always enforce the last selection on the command line.

Note that it's not safe to parse just the last occurrence of the vga=
option, as then a command line with `vga=current vga=keep` would
result in current being ignored.

Adjust the command line documentation to describe the new behavior.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Changes since v3:
 - Remove xen-command-line doc addition.
 - Set mode to 'ask' by default.

Changes since v2:
 - New in this version.
---
Build tested only, as I don't have a system that does legacy boot and
has VGA output I can check.

It's mostly encapsulating the current code inside of a while loop and
adding an extra else if for the "ask" option, there's a lot of
indentation changes.
---
 xen/arch/x86/boot/cmdline.c | 83 +++++++++++++++++++------------------
 1 file changed, 42 insertions(+), 41 deletions(-)

diff --git a/xen/arch/x86/boot/cmdline.c b/xen/arch/x86/boot/cmdline.c
index fc11c6d3c5c4..10dcc6142c85 100644
--- a/xen/arch/x86/boot/cmdline.c
+++ b/xen/arch/x86/boot/cmdline.c
@@ -277,59 +277,60 @@ static u16 rows2vmode(unsigned int rows)
 
 static void vga_parse(const char *cmdline, early_boot_opts_t *ebo)
 {
-    const char *c;
-    unsigned int tmp, vesa_depth, vesa_height, vesa_width;
-
-    c = find_opt(cmdline, "vga=", true);
-
-    if ( !c )
-        return;
+    const char *c = cmdline;
 
     ebo->boot_vid_mode = ASK_VGA;
 
-    if ( !strmaxcmp(c, "current", delim_chars_comma) )
-        ebo->boot_vid_mode = VIDEO_CURRENT_MODE;
-    else if ( !strsubcmp(c, "text-80x") )
-    {
-        c += strlen("text-80x");
-        ebo->boot_vid_mode = rows2vmode(strtoui(c, delim_chars_comma, NULL));
-    }
-    else if ( !strsubcmp(c, "gfx-") )
+    while ( (c = find_opt(c, "vga=", true)) != NULL )
     {
-        vesa_width = strtoui(c + strlen("gfx-"), "x", &c);
+        unsigned int tmp, vesa_depth, vesa_height, vesa_width;
+
+        if ( !strmaxcmp(c, "current", delim_chars_comma) )
+            ebo->boot_vid_mode = VIDEO_CURRENT_MODE;
+        else if ( !strsubcmp(c, "text-80x") )
+        {
+            c += strlen("text-80x");
+            ebo->boot_vid_mode = rows2vmode(strtoui(c, delim_chars_comma, 
NULL));
+        }
+        else if ( !strsubcmp(c, "gfx-") )
+        {
+            vesa_width = strtoui(c + strlen("gfx-"), "x", &c);
 
-        if ( vesa_width > U16_MAX )
-            return;
+            if ( vesa_width > U16_MAX )
+                return;
 
-        /*
-         * Increment c outside of strtoui() because otherwise some
-         * compiler may complain with following message:
-         * warning: operation on 'c' may be undefined.
-         */
-        ++c;
-        vesa_height = strtoui(c, "x", &c);
+            /*
+             * Increment c outside of strtoui() because otherwise some
+             * compiler may complain with following message:
+             * warning: operation on 'c' may be undefined.
+             */
+            ++c;
+            vesa_height = strtoui(c, "x", &c);
 
-        if ( vesa_height > U16_MAX )
-            return;
+            if ( vesa_height > U16_MAX )
+                return;
 
-        vesa_depth = strtoui(++c, delim_chars_comma, NULL);
+            vesa_depth = strtoui(++c, delim_chars_comma, NULL);
 
-        if ( vesa_depth > U16_MAX )
-            return;
+            if ( vesa_depth > U16_MAX )
+                return;
 
-        ebo->vesa_width = vesa_width;
-        ebo->vesa_height = vesa_height;
-        ebo->vesa_depth = vesa_depth;
-        ebo->boot_vid_mode = VIDEO_VESA_BY_SIZE;
-    }
-    else if ( !strsubcmp(c, "mode-") )
-    {
-        tmp = strtoui(c + strlen("mode-"), delim_chars_comma, NULL);
+            ebo->vesa_width = vesa_width;
+            ebo->vesa_height = vesa_height;
+            ebo->vesa_depth = vesa_depth;
+            ebo->boot_vid_mode = VIDEO_VESA_BY_SIZE;
+        }
+        else if ( !strsubcmp(c, "mode-") )
+        {
+            tmp = strtoui(c + strlen("mode-"), delim_chars_comma, NULL);
 
-        if ( tmp > U16_MAX )
-            return;
+            if ( tmp > U16_MAX )
+                return;
 
-        ebo->boot_vid_mode = tmp;
+            ebo->boot_vid_mode = tmp;
+        }
+        else if ( !strmaxcmp(c, "ask", delim_chars_comma) )
+            ebo->boot_vid_mode = ASK_VGA;
     }
 }
 #endif
-- 
2.41.0




 


Rackspace

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