]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
esx: Fix floppy.fileName handling in the vmx file parser
authorGeoff Hickey <ghickey@datagravity.com>
Mon, 14 Oct 2013 22:14:33 +0000 (18:14 -0400)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 15 Oct 2013 10:39:02 +0000 (11:39 +0100)
The vmx file parsing code was reporting errors when parsing floppy.fileName
entries if the filename didn't end in .flp. There is no such restriction in
ESX; even using the GUI to configure floppy filenames you can specify any
arbitrary file with any extension.

Fix by changing the vmx parsing code so that it uses the floppy.fileType
value to determine whether floppy.fileName refers to a block device or a
regular file.

Also remove code that would have generated an error if no floppy.fileName
was specified. This is not an error either.

Updated the floppy tests in vmx2xmltest.c and xml2vmxtest.c.

src/vmx/vmx.c
tests/vmx2xmldata/vmx2xml-floppy-file.vmx
tests/vmx2xmldata/vmx2xml-floppy-file.xml
tests/xml2vmxdata/xml2vmx-floppy-file.vmx
tests/xml2vmxdata/xml2vmx-floppy-file.xml

index 36bc33886b61cc8f1a0f6f95bb6624b8d9c5ba9b..48487f832fcb4836d38fc2e155c5c2405dca7c61 100644 (file)
@@ -2250,27 +2250,14 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
             goto cleanup;
         }
     } else if (device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
-        if (virFileHasSuffix(fileName, ".flp")) {
-            if (fileType != NULL) {
-                if (STRCASENEQ(fileType, "file")) {
-                    virReportError(VIR_ERR_INTERNAL_ERROR,
-                                   _("Expecting VMX entry '%s' to be 'file' but "
-                                     "found '%s'"), fileType_name, fileType);
-                    goto cleanup;
-                }
-            }
-
-            (*def)->type = VIR_DOMAIN_DISK_TYPE_FILE;
-            (*def)->src = ctx->parseFileName(fileName, ctx->opaque);
-
-            if ((*def)->src == NULL) {
-                goto cleanup;
-            }
-        } else if (fileType != NULL && STRCASEEQ(fileType, "device")) {
+        if (fileType != NULL && STRCASEEQ(fileType, "device")) {
             (*def)->type = VIR_DOMAIN_DISK_TYPE_BLOCK;
             (*def)->src = fileName;
 
             fileName = NULL;
+        } else if (fileType != NULL && STRCASEEQ(fileType, "file")) {
+            (*def)->type = VIR_DOMAIN_DISK_TYPE_FILE;
+            (*def)->src = ctx->parseFileName(fileName, ctx->opaque);
         } else {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Invalid or not yet handled value '%s' "
@@ -3538,13 +3525,6 @@ virVMXFormatFloppy(virVMXContext *ctx, virDomainDiskDefPtr def,
         virBufferAsprintf(buffer, "floppy%d.fileType = \"file\"\n", unit);
 
         if (def->src != NULL) {
-            if (! virFileHasSuffix(def->src, ".flp")) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               _("Image file for floppy '%s' has unsupported "
-                                 "suffix, expecting '.flp'"), def->dst);
-                return -1;
-            }
-
             fileName = ctx->formatFileName(def->src, ctx->opaque);
 
             if (fileName == NULL) {
index b9ee81baf4cb47447460649ae610ce23894463cf..ff50117d16387ef3ff8665c7cd6f041a0a6da5dd 100644 (file)
@@ -3,3 +3,6 @@ virtualHW.version = "4"
 floppy0.present = "true"
 floppy0.fileType = "file"
 floppy0.fileName = "floppy.flp"
+floppy1.present = "true"
+floppy1.fileType = "file"
+floppy1.fileName = "floppy"
index f62320f832a7ef2ad54f7f0318bb663c8a61571d..40f70d30520236ead20612ade6885135f190e79b 100644 (file)
       <target dev='fda' bus='fdc'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
     </disk>
+    <disk type='file' device='floppy'>
+      <source file='[datastore] directory/floppy'/>
+      <target dev='fdb' bus='fdc'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
+    </disk>
     <controller type='fdc' index='0'/>
     <video>
       <model type='vmvga' vram='4096'/>
index 11ffb0119bcc44fdc23ed7d72651b9176a255806..b8ffc1e68215b9b017b2e3c10a2960252ff2fc6c 100644 (file)
@@ -9,4 +9,6 @@ numvcpus = "1"
 floppy0.present = "true"
 floppy0.fileType = "file"
 floppy0.fileName = "/vmfs/volumes/testing/floppy.flp"
-floppy1.present = "false"
+floppy1.present = "true"
+floppy1.fileType = "file"
+floppy1.fileName = "/vmfs/volumes/testing/floppy1"
index 83598b3fd20bd041467345db19605b6ec98d56f5..119113abdde8e8f1b1d8e59d2ec80f4315a27bf8 100644 (file)
@@ -10,5 +10,9 @@
       <source file='[testing] floppy.flp'/>
       <target dev='fda' bus='fdc'/>
     </disk>
+    <disk type='file' device='floppy'>
+      <source file='[testing] floppy1'/>
+      <target dev='fdb' bus='fdc'/>
+    </disk>
   </devices>
 </domain>