]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: treat 'aio' like 'raw' at parse time
authorEric Blake <eblake@redhat.com>
Fri, 28 Sep 2012 23:48:58 +0000 (17:48 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 19 Oct 2012 23:35:09 +0000 (17:35 -0600)
We have historically allowed 'aio' as a synonym for 'raw' for
back-compat to xen, but since a future patch will move to using
an enum value, we have to pick one to be our preferred output
name.  This is a slight change in the output XML, but the sexpr
and xm outputs should still be identical, and the input XML can
still use either form.

* src/conf/domain_conf.c (virDomainDiskDefForeachPath): Move aio
back-compat...
(virDomainDiskDefParseXML): ...to parse time.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenFormatSxprDisk): ...and
to output time.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/sexpr2xmldata/sexpr2xml-*.xml: Update tests.

src/conf/domain_conf.c
src/xenxs/xen_sxpr.c
src/xenxs/xen_xm.c
tests/sexpr2xmldata/sexpr2xml-curmem.xml
tests/sexpr2xmldata/sexpr2xml-disk-block-shareable.xml
tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap-raw.xml
tests/sexpr2xmldata/sexpr2xml-disk-drv-blktap2-raw.xml

index 8c99f35dd2f26075161d9cec52572985a83bf18a..b8f742e51941d972518e8e9b571bce59965f092e 100644 (file)
@@ -3728,6 +3728,12 @@ virDomainDiskDefParseXML(virCapsPtr caps,
                        xmlStrEqual(cur->name, BAD_CAST "driver")) {
                 driverName = virXMLPropString(cur, "name");
                 driverType = virXMLPropString(cur, "type");
+                if (STREQ_NULLABLE(driverType, "aio")) {
+                    /* In-place conversion to "raw", for Xen back-compat */
+                    driverType[0] = 'r';
+                    driverType[1] = 'a';
+                    driverType[2] = 'w';
+                }
                 cachetag = virXMLPropString(cur, "cache");
                 error_policy = virXMLPropString(cur, "error_policy");
                 rerror_policy = virXMLPropString(cur, "rerror_policy");
@@ -14844,8 +14850,6 @@ int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
 
     if (disk->driverType) {
         const char *formatStr = disk->driverType;
-        if (STREQ(formatStr, "aio"))
-            formatStr = "raw"; /* Xen compat */
 
         if ((format = virStorageFileFormatTypeFromString(formatStr)) <= 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
index 6ac7dffda8150edfe91232194e95a3cbb901ff22..38a7e137d7b009e37bc18be6288c9df92dc332a4 100644 (file)
@@ -443,6 +443,12 @@ xenParseSxprDisks(virDomainDefPtr def,
                                        src);
                         goto error;
                     }
+                    if (STREQ(disk->driverType, "aio")) {
+                        /* In-place conversion to "raw" */
+                        disk->driverType[0] = 'r';
+                        disk->driverType[1] = 'a';
+                        disk->driverType[2] = 'w';
+                    }
 
                     src = offset + 1;
                     /* Its possible to use blktap driver for block devs
@@ -1831,9 +1837,11 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
         if (def->driverName) {
             if (STREQ(def->driverName, "tap") ||
                 STREQ(def->driverName, "tap2")) {
+                const char *type = def->driverType ? def->driverType : "aio";
+                if (STREQ(type, "raw"))
+                    type = "aio";
                 virBufferEscapeSexpr(buf, "(uname '%s:", def->driverName);
-                virBufferEscapeSexpr(buf, "%s:",
-                                     def->driverType ? def->driverType : "aio");
+                virBufferEscapeSexpr(buf, "%s:", type);
                 virBufferEscapeSexpr(buf, "%s')", def->src);
             } else {
                 virBufferEscapeSexpr(buf, "(uname '%s:", def->driverName);
index 40a99be3784feee24770c03f19136cdf362bdba9..c564d35fbd50fc487a28e4eb282feb1ecad44414 100644 (file)
@@ -566,6 +566,12 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
                                        disk->src);
                         goto cleanup;
                     }
+                    if (STREQ(disk->driverType, "aio")) {
+                        /* In-place conversion to "raw" */
+                        disk->driverType[0] = 'r';
+                        disk->driverType[1] = 'a';
+                        disk->driverType[2] = 'w';
+                    }
 
                     /* Strip the prefix we found off the source file name */
                     memmove(disk->src, disk->src+(tmp-disk->src)+1,
@@ -1203,9 +1209,12 @@ static int xenFormatXMDisk(virConfValuePtr list,
 
     if(disk->src) {
         if (disk->driverName) {
+            const char *type = disk->driverType ? disk->driverType : "aio";
+            if (STREQ(type, "raw"))
+                type = "aio";
             virBufferAsprintf(&buf, "%s:", disk->driverName);
             if (STREQ(disk->driverName, "tap"))
-                virBufferAsprintf(&buf, "%s:", disk->driverType ? disk->driverType : "aio");
+                virBufferAsprintf(&buf, "%s:", type);
         } else {
             switch (disk->type) {
             case VIR_DOMAIN_DISK_TYPE_FILE:
index ac5ab513033ad22e129c86adec224830cd58b36f..1edc52b27bb47e0bc201dfb0d99610949f0bc3ec 100644 (file)
@@ -17,7 +17,7 @@
   <on_crash>restart</on_crash>
   <devices>
     <disk type='file' device='disk'>
-      <driver name='tap' type='aio'/>
+      <driver name='tap' type='raw'/>
       <source file='/xen/rhel5.img'/>
       <target dev='xvda' bus='xen'/>
     </disk>
index e4cd3a876f3067b7b07c819a4b959b2f3f9c20b4..571b34906802a319a70897e7db82b4acbdb540d9 100644 (file)
@@ -14,7 +14,7 @@
   <on_crash>restart</on_crash>
   <devices>
     <disk type='file' device='disk'>
-      <driver name='tap' type='aio'/>
+      <driver name='tap' type='raw'/>
       <source file='/var/lib/xen/images/rhel5pv.img'/>
       <target dev='xvda' bus='xen'/>
       <shareable/>
index 98ed5c5a8b0a8da58d882ea77451f903fbead2c5..df8e7ecb2e85cdddbe9f4acd60d6a5d9834ae7b8 100644 (file)
@@ -16,7 +16,7 @@
   <on_crash>destroy</on_crash>
   <devices>
     <disk type='file' device='disk'>
-      <driver name='tap' type='aio'/>
+      <driver name='tap' type='raw'/>
       <source file='/root/some.img'/>
       <target dev='xvda' bus='xen'/>
     </disk>
index b61182ba24a1c60351f9c8665179b104d1a74a79..ea93195c8d045aa09bf573de0f5189db81b35388 100644 (file)
@@ -16,7 +16,7 @@
   <on_crash>destroy</on_crash>
   <devices>
     <disk type='file' device='disk'>
-      <driver name='tap2' type='aio'/>
+      <driver name='tap2' type='raw'/>
       <source file='/root/some.img'/>
       <target dev='xvda' bus='xen'/>
     </disk>