VOGONS


First post, by Exploit

User metadata
Rank Newbie
Rank
Newbie

If I booted DOS (whether FreeDOS, MS-DOS or DR-DOS doesn't matter) in QEMU from the hard drive and defined an ISO image file as a CD-ROM before starting the virtual machine, then I can view the contents of it with the

DIR D: 

command.
But if I then load another ISO image file into the VM while the guest machine is running, DOS does not recognize that the disk has been changed. A call of

DIR D:

then leads to an error message.

With real hardware, you would press a key on the drive and this would trigger an eject signal. This also gives MSCDEX and the CD-ROM drivers the signal that the CD-ROM media should be ejected. So that they unmount the medium and are ready to mount a new medium.

Does QEMU offer any way to replicate this behavior?

Or is there an eject command for DOS with which you can give the command to a real drive that the CD-ROM media should be ejected. At least there is something like this in Linux.

Reply 1 of 5, by darry

User metadata
Rank l33t++
Rank
l33t++

It took me a while to find, but this should work.

https://web.archive.org/web/20050624115042/ht … files/eject.zip

It should work in a non VM DOS setting too, as it was designed for that

EDIT: This one is meant for Goldstar (now LG), but might work on other drives.

https://web.archive.org/web/20010203182900/ht … wnload/gscd.exe

Reference for these is this thread : https://arstechnica.com/civis/threads/dos-com … ct-a-cd.967981/

EDIT2: You should be able to use virt-manger to eject a virtual optical drive connected to a VM.

Another option is to use cdemu to mount an image to a virtual lun and use lun passthrough in qemu to access the drive in the VM. Then you can mount and umount (eject) using Linux CLI commands on the host system.

Reply 2 of 5, by Exploit

User metadata
Rank Newbie
Rank
Newbie
darry wrote on 2023-11-14, 08:04:

It took me a while to find, but this should work.

https://web.archive.org/web/20050624115042/ht … files/eject.zip

Thank you. I will try that.

EDIT2: You should be able to use virt-manger to eject a virtual optical drive connected to a VM.

Well, i am using virt-manager already. Modern operating systems get a signal and don't have a problem, when the CD media changes in the guest system. But in DOS, i have the above error.

Another option is to use cdemu to mount an image to a virtual lun and use lun passthrough in qemu to access the drive in the VM. Then you can mount and umount (eject) using Linux CLI commands on the host system.

Thanks, this sounds too much work. At the moment I shut down the guest machine, then I change the CD media and restart the guest machine again. This is no more work than using any network solution.
I will definitely try the eject command above.

EDIT:
Okay, I checked the eject command. The ZIP file contains the source code written in BASIC.
A look at the code showed that it was probably written for Windows 95. Because it includes the file WIN32API.INC.

To check my assumption, I simply ran it in a DOSBOX because that's the fastest way. Copying it to a disk image and then loading it into the VM would have taken longer.
And my suspicion was confirmed. If you start it in DOSBOX, it reports "This is a Win32 program.". It will therefore not work in DOS.

Reply 3 of 5, by darry

User metadata
Rank l33t++
Rank
l33t++
Exploit wrote on 2023-11-14, 08:51:
Thank you. I will try that. […]
Show full quote
darry wrote on 2023-11-14, 08:04:

It took me a while to find, but this should work.

https://web.archive.org/web/20050624115042/ht … files/eject.zip

Thank you. I will try that.

EDIT2: You should be able to use virt-manger to eject a virtual optical drive connected to a VM.

Well, i am using virt-manager already. Modern operating systems get a signal and don't have a problem, when the CD media changes in the guest system. But in DOS, i have the above error.

Another option is to use cdemu to mount an image to a virtual lun and use lun passthrough in qemu to access the drive in the VM. Then you can mount and umount (eject) using Linux CLI commands on the host system.

Thanks, this sounds too much work. At the moment I shut down the guest machine, then I change the CD media and restart the guest machine again. This is no more work than using any network solution.
I will definitely try the eject command above.

EDIT:
Okay, I checked the eject command. The ZIP file contains the source code written in BASIC.
A look at the code showed that it was probably written for Windows 95. Because it includes the file WIN32API.INC.

To check my assumption, I simply ran it in a DOSBOX because that's the fastest way. Copying it to a disk image and then loading it into the VM would have taken longer.
And my suspicion was confirmed. If you start it in DOSBOX, it reports "This is a Win32 program.". It will therefore not work in DOS.

Thank you for reporting back and sorry for not having found a solution yet (taking this as personal challenge 😉 )

Have you tried the GSCD one that I also mentioned ?

Some DOS based audio CD players had eject functionality as well. I will try to dig some up.

Reply 4 of 5, by Exploit

User metadata
Rank Newbie
Rank
Newbie

I found a solution on the FreeDOS Bonus CD.

https://www.ibiblio.org/pub/micro/pc-stuff/fr … ystem/cdrom2ui/

cdrom2ui does have a command called "CDROM".
This has the following possible options/parameters:

EJECT
CLOSE
LOCK
UNLOCK
RESET
CDROM EJECT D:

Does work. But virtually closing the drive to load it again with CLOSE, like you would on a real machine to close the drives bay doesnt't work.

CDROM CLOSE D:

So I tried the other parameters and found that EJECT and CLOSE wasn't necessary at all.
It is enough to simply use the RESET option after replacing the loaded ISO image in Virt Manager.

So this will work:

CDROM RESET D:

Reply 5 of 5, by darry

User metadata
Rank l33t++
Rank
l33t++
Exploit wrote on 2023-11-14, 09:16:
I found a solution on the FreeDOS Bonus CD. […]
Show full quote

I found a solution on the FreeDOS Bonus CD.

https://www.ibiblio.org/pub/micro/pc-stuff/fr … ystem/cdrom2ui/

cdrom2ui does have a command called "CDROM".
This has the following possible options/parameters:

EJECT
CLOSE
LOCK
UNLOCK
RESET
CDROM EJECT D:

Does work. But virtually closing the drive to load it again with CLOSE, like you would on a real machine to close the drives bay doesnt't work.

CDROM CLOSE D:

So I tried the other parameters and found that EJECT and CLOSE wasn't necessary at all.
It is enough to simply use the RESET option after replacing the loaded ISO image in Virt Manager.

So this will work:

CDROM RESET D:

Cool!

Glad you it to work and thanks for sharing the info.