From: Anthony PERARD <anthony.perard@citrix.com>
To: Dmitry Isaykin <isaikin-dmitry@yandex.ru>
Cc: <xen-devel@lists.xenproject.org>,
Ian Jackson <iwj@xenproject.org>, Wei Liu <wl@xen.org>
Subject: Re: [PATCH v3] tools/xl: fix autoballoon regex
Date: Tue, 28 Sep 2021 13:36:45 +0100 [thread overview]
Message-ID: <YVMMXarcqweUD4sK@perard> (raw)
In-Reply-To: <dd3a1e1a7a3f8e7bca18dd4779efbc2af01decc7.1631793876.git.isaikin-dmitry@yandex.ru>
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@yandex.ru>
> ---
> ret = regcomp(®ex,
> - "(^| )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
prev parent reply other threads:[~2021-09-28 12:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-16 12:15 [PATCH v3] tools/xl: fix autoballoon regex Dmitry Isaykin
2021-09-28 12:36 ` Anthony PERARD [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YVMMXarcqweUD4sK@perard \
--to=anthony.perard@citrix.com \
--cc=isaikin-dmitry@yandex.ru \
--cc=iwj@xenproject.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.