[libvirt PATCH v2 5/5] vmx: Treat missing cdrom-image as empty drive

Martin Kletzander mkletzan at redhat.com
Mon Dec 21 16:19:17 UTC 2020


This is perfectly valid in VMWare and the VM just boots with an empty drive.  We
used to just skip the whole drive before, but since we changed how we parse
empty cdrom drives this results in an error.  Make it behave more closer to
VMWare.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1903953

Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 src/vmx/vmx.c                                   | 2 +-
 tests/vmx2xmldata/vmx2xml-cdrom-ide-missing.vmx | 6 ++++++
 tests/vmx2xmltest.c                             | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 tests/vmx2xmldata/vmx2xml-cdrom-ide-missing.vmx

diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 4d098a5fa4d6..2c631e32e7df 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -2447,10 +2447,10 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
                 goto cleanup;
             }
 
-            virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
             if (ctx->parseFileName(fileName, ctx->opaque, &tmp, true) < 0)
                 goto cleanup;
             virDomainDiskSetSource(*def, tmp);
+            virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
             VIR_FREE(tmp);
         } else if (deviceType && STRCASEEQ(deviceType, "atapi-cdrom")) {
             virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-ide-missing.vmx b/tests/vmx2xmldata/vmx2xml-cdrom-ide-missing.vmx
new file mode 100644
index 000000000000..bef1ebbba272
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-cdrom-ide-missing.vmx
@@ -0,0 +1,6 @@
+config.version = "8"
+virtualHW.version = "4"
+ide0:0.present = "true"
+ide0:0.deviceType = "cdrom-image"
+ide0:0.fileName = "/vmfs/volumes/missing/dir/file.iso"
+displayName = "test"
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index 116d729a0147..624ee14ece12 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -232,6 +232,7 @@ mymain(void)
     DO_TEST("cdrom-ide-raw-device", "cdrom-ide-raw-device");
     DO_TEST("cdrom-ide-raw-auto-detect", "cdrom-ide-raw-auto-detect");
     DO_TEST("cdrom-ide-raw-auto-detect", "cdrom-ide-raw-auto-detect");
+    DO_TEST("cdrom-ide-missing", "cdrom-ide-empty");
 
     DO_TEST("floppy-file", "floppy-file");
     DO_TEST("floppy-device", "floppy-device");
-- 
2.29.2




More information about the libvir-list mailing list