xl: support xend empty cdrom device syntax
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 26 Jul 2012 09:35:36 +0000 (10:35 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Thu, 26 Jul 2012 09:35:36 +0000 (10:35 +0100)
xend accepts `,hdc:cdrom,r' as an empty CDROM drive.  However this is
not consistent with the existing xl syntax in
docs/misc/xl-disk-configuration.txt which requires `,,hdc:cdrom,r'
(the additional positional paramter is the format).

We fix this by spotting the case specially: when the target is empty
and the format contains a colon, reinterpret the format as
<vdev>:<devtype>.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
docs/misc/xl-disk-configuration.txt
tools/libxl/check-xl-disk-parse
tools/libxl/libxlu_disk_l.c
tools/libxl/libxlu_disk_l.h
tools/libxl/libxlu_disk_l.l

index 740b8f64299909a9af05c11941161bca6b30ba80..5da5e11ea4a1a6caeb442f6e4796afb7307e8239 100644 (file)
@@ -221,3 +221,14 @@ to specify several of these, for example:
   "tap:aio:/some/path..."
 
 All of these prefixes are now stripped and ignored.
+
+
+Missing format and empty target
+-------------------------------
+
+The following syntax is also supported:
+
+  ,<vdev>:<devtype>,<access>   (deprecated)
+
+This is soley for compatibility with xend's syntax for empty cdroms,
+which is (for example) ",hdc:cdrom,r".
index 7a337802d5056ab5b4613321aeaff952cfe7eadc..ffe3613bdef9a3ab00193a4c28d2462bc3fe9f04 100755 (executable)
@@ -123,6 +123,7 @@ disk: {
 EOF
 one 0 devtype=cdrom,,,hdc
 one 0 ,,hdc:cdrom,r
+one 0 ,hdc:cdrom,r
 one 0 vdev=hdc,access=r,devtype=cdrom,target=
 one 0 ,empty,hdc:cdrom,r
 
index b4ad65108a9213cbf3519e85853d672c3d910600..f6903853ee3c30c0797dc48b760d05d13ad4a3c2 100644 (file)
@@ -1404,7 +1404,11 @@ YY_RULE_SETUP
         SAVESTRING("target", pdev_path, yytext);
     } else if (!DPC->had_depr_prefix &&
                DPC->disk->format == LIBXL_DISK_FORMAT_UNKNOWN) {
-        setformat(DPC,yytext);
+        if (!*DPC->disk->pdev_path && vdev_and_devtype(DPC,yytext)) {
+            DPC->disk->format = LIBXL_DISK_FORMAT_EMPTY;
+        } else {
+            setformat(DPC,yytext);
+        }
     } else if (!DPC->disk->vdev) {
         if (!vdev_and_devtype(DPC,yytext))
             SAVESTRING("vdev", vdev, yytext);
@@ -1419,7 +1423,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 23:
 YY_RULE_SETUP
-#line 233 "libxlu_disk_l.l"
+#line 237 "libxlu_disk_l.l"
 {
     BEGIN(LEXERR);
     yymore();
@@ -1427,17 +1431,17 @@ YY_RULE_SETUP
        YY_BREAK
 case 24:
 YY_RULE_SETUP
-#line 237 "libxlu_disk_l.l"
+#line 241 "libxlu_disk_l.l"
 {
     xlu__disk_err(DPC,yytext,"bad disk syntax"); return 0;
 }
        YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 240 "libxlu_disk_l.l"
+#line 244 "libxlu_disk_l.l"
 YY_FATAL_ERROR( "flex scanner jammed" );
        YY_BREAK
-#line 1441 "libxlu_disk_l.c"
+#line 1445 "libxlu_disk_l.c"
                        case YY_STATE_EOF(INITIAL):
                        case YY_STATE_EOF(LEXERR):
                                yyterminate();
@@ -2529,4 +2533,4 @@ void xlu__disk_yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 240 "libxlu_disk_l.l"
+#line 244 "libxlu_disk_l.l"
index 4d0328e4f544447dad05f89ff23981d43abf13d2..26c9a860d490ac8b35002c4540e8a4ee51cdb6c3 100644 (file)
@@ -340,7 +340,7 @@ extern int xlu__disk_yylex (yyscan_t yyscanner);
 #undef YY_DECL
 #endif
 
-#line 240 "libxlu_disk_l.l"
+#line 244 "libxlu_disk_l.l"
 
 #line 346 "libxlu_disk_l.h"
 #undef xlu__disk_yyIN_HEADER
index 7e0a63532b5e7ee877fcbb2155fe7d64c65a6000..f4e6b1abf39922cca96bb00cf5162d48bc5d5919 100644 (file)
@@ -217,7 +217,11 @@ phy:/.*            { DPC->had_depr_prefix=1; DEPRECATE(0); }
         SAVESTRING("target", pdev_path, yytext);
     } else if (!DPC->had_depr_prefix &&
                DPC->disk->format == LIBXL_DISK_FORMAT_UNKNOWN) {
-        setformat(DPC,yytext);
+        if (!*DPC->disk->pdev_path && vdev_and_devtype(DPC,yytext)) {
+            DPC->disk->format = LIBXL_DISK_FORMAT_EMPTY;
+        } else {
+            setformat(DPC,yytext);
+        }
     } else if (!DPC->disk->vdev) {
         if (!vdev_and_devtype(DPC,yytext))
             SAVESTRING("vdev", vdev, yytext);