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

Re: [PATCH v3] tools/xl: fix autoballoon regex


  • To: Dmitry Isaykin <isaikin-dmitry@xxxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Tue, 28 Sep 2021 13:36:45 +0100
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 28 Sep 2021 12:36:54 +0000
  • Ironport-data: A9a23:Orbkx6nfsWdocTppWZOLq8zo5gxiIURdPkR7XQ2eYbSJt1+Wr1Gzt xIeD2mFPK6LYzPwKthzOtuw9EgEu5PUmtE1GwRq+Hg1FSMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BClVlxJVF/fngqoDUUYYoAQgsA185IMsdoUg7wbdh09Q42YLR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 M1vto2BZTcTAoGPlPUDTD1kECJ4JaITrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBMDtIIMYvGAm1TzDBOwqaZvCX7/L9ZlT2zJYasVmQK2OP ptHN2AHgBLoeQRSOmweDpMExOaupFSvYmFAhEDEnP9ii4TU5FMoi+W8WDbPQfSLWsd9jkuev njB/WnyHlcdLtP34SWB2mKhgKnIhyyTcIMJHby79/gvjFiS2nYCIAwfU1e2sb+jlyaWS99Zb kAZ5Ccqhawz71CwCMnwWQWip3yJtQJaXMBfe9DW8ynUlPCSuVzAQDFZEHgRM7TKqfPaWxQy9 FyYrv/ZPwBD87G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FL+o=
  • Ironport-sdr: CNImGH9CT0ZjBr4wPVxUaBkR+ZDyBk1Co3nXelbXcP2kW691Fk6eaF6q1+NuEVW0dXKNV1zxMN kowoDTSszUG/FJRV9p5L6Fc0B0sZIsPk3pEANQEo+4yDTivM6OthsMd8U0P5K3Y/rCn0q5qZAg 9wInSwKzY9+TCovSlb4LmDaMANGQ0zZZT9fT+k/SXRT9VkSuUBEwJLfEQezQLWSaWTVg3Vlqiq y30UIWRL8NmNmFaeOHFBpG5YIG5wXdZcWvMxLAUbBnJJawEtrgL9qx4JOfwrPtJM1PlkF67+H9 /RUoHvhgd2eBxTLfaI0sPtK3
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Sep 16, 2021 at 03:15:21PM +0300, Dmitry Isaykin wrote:
> This regex is used for auto-balloon mode detection based on Xen command line.
> 
> The case of specifying a negative size was handled incorrectly.
> From misc/xen-command-line documentation:
> 
>     dom0_mem (x86)
>     = List of ( min:<sz> | max:<sz> | <sz> )
> 
>     If a size is positive, it represents an absolute value.
>     If a size is negative, it is subtracted from the total available memory.
> 
> Also add support for [tT] granularity suffix.
> Also add support for memory fractions (i.e. '50%' or '1G+25%').
> 
> Signed-off-by: Dmitry Isaykin <isaikin-dmitry@xxxxxxxxx>
> ---
>      ret = regcomp(&regex,
> -                  "(^| )dom0_mem=((|min:|max:)[0-9]+[bBkKmMgG]?,?)+($| )",
> +                  "(^| 
> )dom0_mem=((|min:|max:)(-?[0-9]+[bBkKmMgGtT]?)?(\+?[0-9]+%)?,?)+($| )",

It seems that by trying to match fractions, the new regex would match
too much. For example, if there is " dom0_mem= " on the command line, xl
would detect it as autoballoon=off, while it isn't the case without this
patch. I don't know if it is possible to have "dom0_mem=" on the command
line as I don't know what Xen would do in this case.

It might be better to make the regex more complicated and match
fraction like they are described in the doc, something like:
    ( <size> | (<size>\+)?<frac>% )

unless xen doesn't boot with bogus value for dom0_mem, but I haven't
checked. (we could use CPP macros to avoid duplicating the <size>
regex.)

Also, <frac> is supposed to be < 100, so [0-9]{1,2} would be better to
only match no more than 2 digit.

Thought?

Thanks,

-- 
Anthony PERARD



 


Rackspace

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