[libvirt] [PATCHv2 02/16] storage: treat 'aio' like 'raw' at parse time

Eric Blake eblake at redhat.com
Mon Oct 15 21:44:52 UTC 2012


On 10/15/2012 12:31 PM, Eric Blake wrote:
> 
> Should I post a v2 that does:
> 
> if (STREQ_NULLABLE(driverType, "aio")) {
>     /* In-place conversion to "raw" */
>     driverType[0] = 'r';
>     driverType[1] = 'a';
>     driverType[2] = 'w';
> }
> 
> Or, since this area of code is changed again later in the series when I
> rename 'char *driverType' to 'int format', should I just leave this
> as-is since it is just temporary ugliness?
> 
>>
>> Past the nits above. Visual ACK as well.
>>
> 
> We'll see if anyone has an opinion about the above in the next day or so.


Here's what I'm tested squashing in, if you like this alternative (note
that two of the three uses are immediately undone later in patch 4/16):

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a2fb7dd..3679e1b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3724,8 +3724,12 @@ virDomainDiskDefParseXML(virCapsPtr caps,
                        xmlStrEqual(cur->name, BAD_CAST "driver")) {
                 driverName = virXMLPropString(cur, "name");
                 driverType = virXMLPropString(cur, "type");
-                if (STREQ_NULLABLE(driverType, "aio"))
-                    memcpy(driverType, "raw", strlen("raw"));
+                if (STREQ_NULLABLE(driverType, "aio")) {
+                    /* In-place conversion to "raw", for 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");
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index 3d20350..38a7e13 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -443,8 +443,12 @@ xenParseSxprDisks(virDomainDefPtr def,
                                        src);
                         goto error;
                     }
-                    if (STREQ(disk->driverType, "aio"))
-                        memcpy(disk->driverType, "raw", strlen("raw"));
+                    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
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 41e6744..c564d35 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -566,8 +566,12 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
                                        disk->src);
                         goto cleanup;
                     }
-                    if (STREQ(disk->driverType, "aio"))
-                        memcpy(disk->driverType, "raw", strlen("raw"));
+                    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,


-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 617 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20121015/0b8478bf/attachment-0001.sig>


More information about the libvir-list mailing list