VMWare Fusion 5 can set the CD-ROM's file name to be 'auto detect' when
using the physical drive via 'cdrom-raw' device type. VMWare will then
connect to first available host CD-ROM to the virtual machine upon start
up according to VMWare documentation.
---
src/vmx/vmx.c | 9 +++++++--
.../vmx2xml-cdrom-ide-raw-auto-detect.vmx | 5 +++++
.../vmx2xml-cdrom-ide-raw-auto-detect.xml | 23 ++++++++++++++++++++++
tests/vmx2xmltest.c | 1 +
4 files changed, 36 insertions(+), 2 deletions(-)
create mode 100644 tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-auto-detect.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-auto-detect.xml
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index e6b2c74..7eaff65 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -2219,9 +2219,14 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt,
virConfPtr con
} else if (STRCASEEQ(deviceType, "atapi-cdrom") ||
STRCASEEQ(deviceType, "cdrom-raw")) {
(*def)->type = VIR_DOMAIN_DISK_TYPE_BLOCK;
- (*def)->src = fileName;
- fileName = NULL;
+ if (STRCASEEQ(fileName, "auto detect")) {
+ (*def)->tray_status = VIR_DOMAIN_DISK_TRAY_OPEN;
+ (*def)->src = NULL;
+ } else {
+ (*def)->src = fileName;
+ fileName = NULL;
+ }
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid or not yet handled value '%s' "
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-auto-detect.vmx
b/tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-auto-detect.vmx
new file mode 100644
index 0000000..b2c4caf
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-auto-detect.vmx
@@ -0,0 +1,5 @@
+config.version = "8"
+virtualHW.version = "4"
+ide0:0.present = "true"
+ide0:0.deviceType = "cdrom-raw"
+ide0:0.fileName = "auto detect"
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-auto-detect.xml
b/tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-auto-detect.xml
new file mode 100644
index 0000000..feae3c5
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-auto-detect.xml
@@ -0,0 +1,23 @@
+<domain type='vmware'>
+ <uuid>00000000-0000-0000-0000-000000000000</uuid>
+ <memory unit='KiB'>32768</memory>
+ <currentMemory unit='KiB'>32768</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686'>hvm</type>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='block' device='cdrom'>
+ <target dev='hda' bus='ide' tray='open'/>
+ <address type='drive' controller='0' bus='0'
target='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <video>
+ <model type='vmvga' vram='4096'/>
+ </video>
+ </devices>
+</domain>
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index 1b97520..12e775c 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -240,6 +240,7 @@ mymain(void)
DO_TEST("cdrom-ide-file", "cdrom-ide-file");
DO_TEST("cdrom-ide-device", "cdrom-ide-device");
DO_TEST("cdrom-ide-raw-device", "cdrom-ide-raw-device");
+ DO_TEST("cdrom-ide-raw-auto-detect",
"cdrom-ide-raw-auto-detect");
DO_TEST("floppy-file", "floppy-file");
DO_TEST("floppy-device", "floppy-device");
--
1.8.1.5