diff options
author | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-07-26 10:35:36 +0100 |
---|---|---|
committer | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-07-26 10:35:36 +0100 |
commit | c902f397d67d3fa959d46a0373230da3f8c8af92 (patch) | |
tree | 32fed48be6609271c5533e09384f7a40499a9efb /tools/libxl/libxlu_disk_l.l | |
parent | 79702808336453e6ec75777ea94f01027d439ebd (diff) | |
download | xen-c902f397d67d3fa959d46a0373230da3f8c8af92.tar.gz xen-c902f397d67d3fa959d46a0373230da3f8c8af92.tar.bz2 xen-c902f397d67d3fa959d46a0373230da3f8c8af92.zip |
xl: disk parsing preparation for empty cdrom devices
Prepare the ground for parsing the xend empty cdrom syntax, by
separating out some non-functional changes as this pre-patch:
* Clarify the disk syntax documentation wording to refer to deprecated
syntaxes too.
* Make DPC in libxlu_disk_l.l useable in the helper functions as well
as in lexer rules, by providing two definitions, each in force in
the appropriate parts of the file.
* Break the <vdev>[:<devtype>] parsing out into a helper function,
`vdev_and_devtype'.
No functional change.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxl/libxlu_disk_l.l')
-rw-r--r-- | tools/libxl/libxlu_disk_l.l | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/tools/libxl/libxlu_disk_l.l b/tools/libxl/libxlu_disk_l.l index 6e53928664..7e0a63532b 100644 --- a/tools/libxl/libxlu_disk_l.l +++ b/tools/libxl/libxlu_disk_l.l @@ -45,8 +45,6 @@ void xlu__disk_yyset_column(int column_no, yyscan_t yyscanner); * and particularly to avoid repeating boilerplate values such as * DPC->disk, yytext, etc. */ -#define DPC ((DiskParseContext*)yyextra) - /* Sets an enum, checking it hasn't already been set to a different value */ #define DSET(dpc,member,enumname,str,valname) do{ \ if (dpc->disk->member != LIBXL_DISK_##enumname##_UNKNOWN && \ @@ -79,6 +77,8 @@ static void savestring(DiskParseContext *dpc, const char *what_respecified, *update = strdup(value); } +#define DPC dpc /* our convention in lexer helper functions */ + /* Sets ->readwrite from the string. This ought to be an enum, perhaps. */ static void setaccess(DiskParseContext *dpc, const char *str) { if (!strcmp(str, "r") || !strcmp(str, "ro")) { @@ -111,6 +111,30 @@ static void setbackendtype(DiskParseContext *dpc, const char *str) { #define DEPRECATE(usewhatinstead) /* not currently reported */ +/* Handles a vdev positional parameter which includes a devtype. */ +static int vdev_and_devtype(DiskParseContext *dpc, char *str) { + /* returns 1 if it was <vdev>:<devtype>, 0 (doing nothing) otherwise */ + char *colon = strrchr(str, ':'); + if (!colon) + return 0; + + DEPRECATE("use `devtype=...'"); + *colon++ = 0; + SAVESTRING("vdev", vdev, str); + + if (!strcmp(colon,"cdrom")) { + DPC->disk->is_cdrom = 1; + } else if (!strcmp(colon,"disk")) { + DPC->disk->is_cdrom = 0; + } else { + xlu__disk_err(DPC,colon,"unknown deprecated type"); + } + return 1; +} + +#undef DPC /* needs to be defined differently the actual lexer */ +#define DPC ((DiskParseContext*)yyextra) + %} %option warn @@ -185,7 +209,6 @@ phy:/.* { DPC->had_depr_prefix=1; DEPRECATE(0); } /* positional parameters */ [^=,]*,|[^=,]+,? { - char *colon; STRIP(','); if (DPC->err) { @@ -196,19 +219,8 @@ phy:/.* { DPC->had_depr_prefix=1; DEPRECATE(0); } DPC->disk->format == LIBXL_DISK_FORMAT_UNKNOWN) { setformat(DPC,yytext); } else if (!DPC->disk->vdev) { - colon = strrchr(yytext, ':'); - if (colon) { - DEPRECATE("use `devtype=...'"); - *colon++ = 0; - if (!strcmp(colon,"cdrom")) { - DPC->disk->is_cdrom = 1; - } else if (!strcmp(colon,"disk")) { - DPC->disk->is_cdrom = 0; - } else { - xlu__disk_err(DPC,colon,"unknown deprecated type"); - } - } - SAVESTRING("vdev", vdev, yytext); + if (!vdev_and_devtype(DPC,yytext)) + SAVESTRING("vdev", vdev, yytext); } else if (!DPC->access_set) { DPC->access_set = 1; setaccess(DPC,yytext); |