Author Topic: KVM/QEMU physical CD  (Read 2974 times)

Tim Hall

  • Victoria is my queen
KVM/QEMU physical CD
« on: 28 October, 2020, 11:38:18 pm »
Having slavishly followed a couple of how-tos, I've got a W7 virtual machine running on my Ubuntu box.

I can't get it to recognise the physical CD Drive.

I can create virtual CD drives and mount ISOs in them - that's how I installed W7 in the first place and is the work around I've used for this issue.

If I click Add Hardware and Storage I can add a CDROM device but it's a Virtual Disk and it seems I then have to select a source path (this is where I'd point at an ISO)

How can I just have a CD Drive that I can open from W7? Which obvious step am I missing?
There are two ways you can get exercise out of a bicycle: you can
"overhaul" it, or you can ride it.  (Jerome K Jerome)

Re: KVM/QEMU physical CD
« Reply #1 on: 29 October, 2020, 07:27:07 am »
Its a long time since I used KVM like that but if I remember rightly there is a cdrom "connect" option in the virtual machine manager GUI to pass through the CD drive to a virtual machine.
I think you'll find it's a bit more complicated than that.

Tim Hall

  • Victoria is my queen
Re: KVM/QEMU physical CD
« Reply #2 on: 29 October, 2020, 08:51:55 am »
That's what the guides I've found suggest but I can't see one on my machine.

Options are:

1. It's right in front of me and I can't see for looking
2. It's not there as the version of virt-manager I'm using is not the same as the one being demoed
3. It's not there as virt-manager hasn't installed properly.
There are two ways you can get exercise out of a bicycle: you can
"overhaul" it, or you can ride it.  (Jerome K Jerome)

Re: KVM/QEMU physical CD
« Reply #3 on: 29 October, 2020, 10:08:53 am »
As the Linux system has an address (mount point) for the CD drive, can you point the VM at this address or does it have to be an iso file? Or am I missing something stupid?

Re: KVM/QEMU physical CD
« Reply #4 on: 29 October, 2020, 10:32:37 am »
It's probably a USB drive, yes? If so, you will probably find the drive under "USB host".

Tim Hall

  • Victoria is my queen
Re: KVM/QEMU physical CD
« Reply #5 on: 29 October, 2020, 10:43:49 am »
matthew, I'll look at using the mount point (although I went part way down that rabbit hole last night)

philip, no, it's a SATA drive.  I've succesfully added a couple of USB host devices (go me!) already. 
There are two ways you can get exercise out of a bicycle: you can
"overhaul" it, or you can ride it.  (Jerome K Jerome)

Re: KVM/QEMU physical CD
« Reply #6 on: 29 October, 2020, 11:12:03 am »
Perhaps the GUI is lacking, if so the command line interface would be "virsh attach-disk".

Tim Hall

  • Victoria is my queen
Re: KVM/QEMU physical CD
« Reply #7 on: 29 October, 2020, 11:16:24 am »
Perhaps the GUI is lacking, if so the command line interface would be "virsh attach-disk".
Great, I'll have a look at that this evening
There are two ways you can get exercise out of a bicycle: you can
"overhaul" it, or you can ride it.  (Jerome K Jerome)

Kim

  • Timelord
    • Fediverse
Re: KVM/QEMU physical CD
« Reply #8 on: 29 October, 2020, 03:05:36 pm »
Perhaps the mount point for the CD drive isn't where the virtualisation thinger expects it to be?  Possibly solvable by tactical application of symlinks?

Tim Hall

  • Victoria is my queen
Re: KVM/QEMU physical CD
« Reply #9 on: 30 October, 2020, 07:01:38 pm »
Sorry, been busy.

Attaching the CD drive from a command line didn't work.

Trying it with the virtual machine open but off gets me this error:

Code: [Select]
tim@Dalamar2:~$ virsh attach-disk win7 /dev/sr0 hdc --type cdrom
error: Failed to attach disk
error: Requested operation is not valid: domain is not running
Trying it with the virtual machine on gets this:

Code: [Select]
tim@Dalamar2:~$ virsh attach-disk win7 /dev/sr0 hdc --type cdrom
error: Failed to attach disk
error: Operation not supported: cdrom/floppy device hotplug isn't supported

I've also got an issue with the way virt-manager starts up. If I just click the virt-manager icon I just get the option to choose Libvirt-LXC. I don't (I think) have any virtual machines using Libvirt-LXC. The W7 machine I have uses KVM/QEMU and appears under that heading if I sudo virt-manager. Are these two issues connected?   FWIW groups gives me this:
Code: [Select]
tim@Dalamar2:~$ groups tim
tim : tim adm cdrom sudo dip plugdev kvm lpadmin lxd sambashare libvirt

Keen to learn. Lots to learn.
There are two ways you can get exercise out of a bicycle: you can
"overhaul" it, or you can ride it.  (Jerome K Jerome)

Re: KVM/QEMU physical CD
« Reply #10 on: 30 October, 2020, 07:06:25 pm »
OK lets have a little bit more info.

What version of Ubuntu is this ?

Is /dev/sd0 definitely your CDROM device ? If you forget about KVM/QEMU and just mount the CDROM in Ubuntu is /dev/sd0 that is getting mounted ?

How did you instal QEMU and KVM ? Was it from teh official Ubuntu repositories or did you download it from somewhere else ?
I think you'll find it's a bit more complicated than that.

Re: KVM/QEMU physical CD
« Reply #11 on: 30 October, 2020, 07:59:49 pm »
The other thing you can try is "virsh edit" which allows you to modify the XML configuration for the virtual machine. You could add another <disk> section.

Tim Hall

  • Victoria is my queen
Re: KVM/QEMU physical CD
« Reply #12 on: 30 October, 2020, 08:08:53 pm »
20.04 LTS

Mount point is /dev/sr0 which is what I'd put in the command.

Putting a cd into the drive and checking the properties show the mount point as /dev/sr0

QEMU and KVM both came from Ubuntu repositories. Under "other software" my repository list only has https://packages.microsoft.com/repos/ms-teams stable main (where I got the *nix version of MS Teams) and http://dl.google.com/linus/chrome/deb/stable main (for Chrome)
There are two ways you can get exercise out of a bicycle: you can
"overhaul" it, or you can ride it.  (Jerome K Jerome)

Re: KVM/QEMU physical CD
« Reply #13 on: 30 October, 2020, 08:14:15 pm »
I don't have a CDROM or windows but I can make a SATA hard drive available on a debian virtual machine by adding a <disk> stanza using "virsh edit":

Code: [Select]
<disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sdd'/>
      <target dev='vdb' bus='virtio'/>
 </disk>

Tim Hall

  • Victoria is my queen
Re: KVM/QEMU physical CD
« Reply #14 on: 30 October, 2020, 08:17:35 pm »
Thanks. Off to the supermarket just now. I'll have a look at that later.
There are two ways you can get exercise out of a bicycle: you can
"overhaul" it, or you can ride it.  (Jerome K Jerome)

Tim Hall

  • Victoria is my queen
Re: KVM/QEMU physical CD
« Reply #15 on: 30 October, 2020, 10:03:13 pm »
OK, back from scaring people at Tesco.

Using your suggestion plus hints from the web I used this in virsh edit
Code: [Select]
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sr0'/>
      <target dev='sdd' bus='sata'/>
      <readonly/>
      <shareable/>
      <address type='drive' controller='0' bus='0' target='0' unit='3'/>
</disk.
The drive shows up in the W7 machine but when I click it I get "Windows can't access this disc. The disc might be corrupt. Make sure the disc uses a format that Windows recognizes. If the disc is unformatted you need to format it before using it."
I tried changing the bus to virtio but virsh edit didn't like that.

I've just noticed I've got an unknown device in the device manager, The drivers for this device are not installed. Getting it to search the Win7 ISO and the virtual machine drivers ISO doesn't do anything.
There are two ways you can get exercise out of a bicycle: you can
"overhaul" it, or you can ride it.  (Jerome K Jerome)

Re: KVM/QEMU physical CD
« Reply #16 on: 30 October, 2020, 10:27:28 pm »
I'm a bit out of my depth with Windows, perhaps installing the Windows virtio drivers will help: https://pve.proxmox.com/wiki/Windows_VirtIO_Drivers