Bug 605956 - Need a command to switch ISO image of CDROM device of guest.
Summary: Need a command to switch ISO image of CDROM device of guest.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: xen
Version: 5.6
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Michal Novotny
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 514499
TreeView+ depends on / blocked
 
Reported: 2010-06-19 15:47 UTC by Kirby Zhou
Modified: 2014-02-02 22:37 UTC (History)
11 users (show)

Fixed In Version: xen-3.0.3-123.el5
Doc Type: Bug Fix
Doc Text:
Previously, if the virtual CD-ROM was ejected in the guest operating system, and the "xm block-configure" command was subsequently used to reinsert the same medium, the guest operating system failed to detect the newly inserted medium. With this update, a patch has been provided that handles CD-ROM ejection properly, fixing the bug.
Clone Of:
Environment:
Last Closed: 2011-07-21 09:16:50 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
xm list --long (9.42 KB, text/plain)
2010-07-01 12:12 UTC, Kirby Zhou
no flags Details
xenstore-ls (29.07 KB, text/plain)
2010-07-01 12:13 UTC, Kirby Zhou
no flags Details
Patch to fix eject behaviour (3.46 KB, patch)
2011-01-25 15:33 UTC, Michal Novotny
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1070 0 normal SHIPPED_LIVE xen bug fix and enhancement update 2011-07-21 09:12:56 UTC

Description Kirby Zhou 2010-06-19 15:47:22 UTC
RFE: need a command to switch ISO image of CDROM device of guest.

For example, If I want to install Windows 2003 R2, I have no CLI based method to switch to iso image of disc2 during the installaion.

Comment 1 Daniel Berrangé 2010-06-30 12:29:22 UTC
The virsh command can be used to change media

eg, if you have a guest with a cdrom device 'hdc', you should be able to run

  virsh attach-disk guestname /some/iso/image hdc --mode readonly --type cdrom

Comment 2 Kirby Zhou 2010-07-01 03:43:31 UTC
It actually DO NOT work with Xen-HVM guest.
Dump XML tell us the ISO image is changed, but the guest itself do not.

[@rd-xen01.sohu-rd.com ~]# virsh dumpxml xen-dtbuild       
...
<source file='/usr/share/xenpv-win/xenpv-win.iso'/>
...

~]# virsh attach-disk xen-dtbuild /opt/en_win_srv_2003_r2_enterprise_x64_with_sp2_vl_cd1.iso  hdc --mode readonly --type cdrom --driver=file

[@rd-xen01.sohu-rd.com ~]# virsh dumpxml xen-dtbuild
...
<source file='/opt/en_win_srv_2003_r2_enterprise_x64_with_sp2_vl_cd1.iso'/>
...

The guest still see the xen-pv ISO image.

C:\Documents and Settings\KirbyZhou>dir d:
 Volume in drive D is xenpv-win-1.1.0
 Volume Serial Number is C9D2-8DF7

 Directory of D:\

24/10/2009  00:45    <DIR>          Para-virtualized_Windows_Drivers_Guide
24/10/2009  00:45             7.272 README.txt
24/10/2009  00:45           511.080 RedHatXenPVDrivers-Installation.pdf
29/10/2009  21:52                31 autorun.inf
24/10/2009  00:57         2.619.392 xenpv-win.exe
               4 File(s)      3.137.775 bytes
               1 Dir(s)               0 bytes free

Comment 3 Daniel Berrangé 2010-07-01 10:16:11 UTC
Show me what 'xm list --long'  and 'xenstore-ls'  output after running the virsh command to change the media.

Comment 4 Kirby Zhou 2010-07-01 12:12:57 UTC
Created attachment 428367 [details]
xm list --long

Comment 5 Kirby Zhou 2010-07-01 12:13:32 UTC
Created attachment 428369 [details]
xenstore-ls

Comment 6 Kirby Zhou 2010-07-01 12:18:48 UTC
I eject the iso of cdrom in the guest, so how can I insert back the iso?
attach-disk do not work either.

Comment 7 Kirby Zhou 2010-07-01 12:27:21 UTC
A additional info:

attach-disk works sometime! 

I have typed the command below for 10 times, and it works for 3 time.

virsh attach-disk xen-dtbuild  \
 /opt/en_win_srv_2003_r2_enterprise_x64_with_sp2_vl_cd2.iso hdd \
 --mode readonly --type cdrom --driver=file

and sometimes, it always fail with cd2.iso and ok with cd1.iso.
sometimes, the opposite.

Comment 8 Daniel Berrangé 2010-07-01 12:29:32 UTC
xenstore & xend both confirm that the media has been changed. So if the guest isn't seeing the new media, this must be a Xen bug, not a libvirt bug.

Comment 9 Miroslav Rezanina 2010-07-02 12:42:40 UTC
Can you please try command:

xm block-configure <domid> <frontend> <backend> <mode>

e.g.:

xm block-configure test-hvm file:/root/boot.iso hdc r

Is this switching medium??

Comment 10 Kirby Zhou 2010-07-03 09:18:54 UTC
[@rd-xen01.sohu-rd.com ~]# xm block-configure xen-dtbuild file:/opt/en_win_srv_2003_r2_enterprise_x64_with_sp2_vl_cd1.iso hdc r
[@rd-xen01.sohu-rd.com ~]# xm list
Name                                      ID Mem(MiB) VCPUs State   Time(s)
Domain-0                                   0     1024     4 r-----  25757.1
bbs                                        8      511     3 -b----   4165.3
rd-home                                    9     1535     2 -b----  14467.2
svnserver                                 13     1279     3 -b----  69654.6
www-wiki                                  14      767     3 -b---- 308470.0
xen-dtbuild                               36     2055     3 -b----   2434.3
xen-openvpn                               15      191     1 -b----   5286.6
xen-sambatest                             16      383     2 -b----   2362.0
[@rd-xen01.sohu-rd.com ~]# ls /opt/en_win_srv_2003_r2_enterprise_x64_with_sp2_vl_cd1.iso
/opt/en_win_srv_2003_r2_enterprise_x64_with_sp2_vl_cd1.iso
[@rd-xen01.sohu-rd.com ~]# xm block-configure xen-dtbuild file:/opt/en_win_srv_2003_r2_enterprise_x64_with_sp2_vl_cd1.iso hdc r
Error: Refusing to reconfigure device vbd:5632 to ['vbd', ['uname', 'file:/opt/en_win_srv_2003_r2_enterprise_x64_with_sp2_vl_cd1.iso'], ['dev', 'hdc'], ['mode', 'r']]
Usage: xm block-configure <Domain> <BackDev> <FrontDev> <Mode> [BackDomId]

Change block device configuration

Comment 11 Miroslav Rezanina 2010-07-07 13:14:00 UTC
Ou...my mistake...you have to use hdc:cdrom backend specification. Is this working with 

xm block-configure xen-dtbuild file:/opt/en_win_srv_2003_r2_enterprise_x64_with_sp2_vl_cd1.iso hdc:cdrom r

Comment 12 Kirby Zhou 2010-07-07 16:06:57 UTC
Sometimes DO NOT work as 'virsh attach-disk'.
No error happens, but nothing changed in the guest.

[@rd-xen01.sohu-rd.com ~]# xm block-configure xen-dtbuild file:/opt/en_win_srv_2003_r2_enterprise_x64_with_sp2_vl_cd1.iso hdc:cdrom r

C:\Documents and Settings\KirbyZhou>dir d:
 Volume in drive D is xenpv-win-1.1.0
 Volume Serial Number is C9D2-8DF7

 Directory of D:\

24/10/2009  00:45    <DIR>          Para-virtualized_Windows_Drivers_Guide
24/10/2009  00:45             7.272 README.txt
24/10/2009  00:45           511.080 RedHatXenPVDrivers-Installation.pdf
29/10/2009  21:52                31 autorun.inf
24/10/2009  00:57         2.619.392 xenpv-win.exe
               4 File(s)      3.137.775 bytes
               1 Dir(s)               0 bytes free

Comment 13 Michal Novotny 2010-07-26 15:08:05 UTC
Kirby,
personally I change images using virt-manager by selecting CD-ROM device in the guest details and changing it on the CD-ROM device (Disk hdc) directly.

Also, when not using virt-manager (e.g. using virt-viewer) for Windows 2003 guest I am trying the following procedure (when the device is hdc:cdrom):

virt-viewer Win2003-32fv (no media in CD-ROM drive)
xenstore-ls /local/domain/0/backend/vbd/$(domId)/5632 (params empty)
xenstore-write /local/domain/0/backend/vbd/28/5632/params /path/to/some.iso
virt-viewer Win2003-32fv (there is a media in CD-ROM drive now)

now I tried changing the media using:
xenstore-write /local/domain/0/backend/vbd/28/5632/params /path/to/another.iso

and it was not working now. It was seeing the contents of old media still. But I found out that when I tried to unmount/eject the media using right click on the CD-ROM icon and giving Eject there, after that I changed the media using:

xenstore-write /local/domain/0/backend/vbd/28/5632/params /path/to/someOther.iso

(but only *after* I ejected it) the guest was seeing the new media contents.

Using the virt-manager:

I started up the Win2003 x86 HVM guest and I logged in. After logging in I selected VM details and Disk hdc. There I selected the image and clicked OK. When I switched to the VNC window of VM I was able to see a new media in the drive. Then I changed the disk to some other ISO image but the problem was that Windows system saw there's a new media but it was showing contents of old media so I disconnected the media connected the old media it's contents was the guest still seeing before disconnection. I went to My Computer and ejected the media from the virtual CD-ROM drive. In the VM details (Disk hdc item) I connected the new ISO image to the CD-ROM drive and I was able to see the contents of this media.

So if you want to access the CD-ROM media you should eject the disk in the Windows system first since the device is being accessed by Windows system itself until ejected.

I did also try this using the Linux (RHEL-5) guests and the behaviour was the same. I had to do the same procedure in GNOME desktop environment to eject the disk (or umount) before changing. Otherwise it was not changed. I've tested this with HVM guests and it appears that we need to investigate this in tools/ioemu/hw/ide.c since there's a cdrom_change_cb() function but I don't know whether the function is being called or whether it's defined properly. This needs further investigation.

Versions:
xen-3.0.3-114.el5virttest30.g099810b (available at http://people.redhat.com/minovotn/xen)
kernel-xen-2.6.18-194.8.1.el5

Michal

Comment 14 Miroslav Rezanina 2010-08-02 08:38:40 UTC
Hi Kirby,
when you testing media change, did you ejected it in guest before change??

Comment 15 Kirby Zhou 2010-08-02 16:17:54 UTC
I have tried both with ejecting, but sometimes the new media event did not fired.

Comment 16 Michal Novotny 2010-12-08 09:14:35 UTC
Kirby,
when it happens and you retry it again is it working? Could you please give us the exact and reliable steps to reproduce ?

Thanks,
Michal

Comment 17 Kirby Zhou 2010-12-09 03:26:51 UTC
The latest info:

~]# cat /etc/xen/xen-dtbuild-2008r2 
name = "xen-dtbuild-2008r2"
uuid = "2247e60f-ca37-1d13-2494-efaf508e993b"
maxmem = 3072
memory = 1024
vcpus = 2
builder = "hvm"
kernel = "/usr/lib/xen/boot/hvmloader"
boot = "dc"
pae = 1
acpi = 1
apic = 1
localtime = 0
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
usb = 1
usbdevice = "tablet"
sdl = 0
vnc = 1
vncunused = 1
vncdisplay = 13
device_model = "/usr/lib64/xen/bin/qemu-dm"
disk = [ "phy:/dev/vgold/xen-dtbuild-2008r2,hda,w",  "file:/opt/win2008r2.iso,hdc:cdrom,r", "file:/usr/share/xenpv-win/xenpv-win-1.2.0.iso,hdd:cdrom,r" ]
#disk += [ "phy:/dev/vgold/xen-dtbuild-pool,hdb,r" ]
vif = [ "mac=00:16:36:27:4f:13,bridge=xenbr0,script=vif-bridge" ]
parallel = "none"
serial = "pty"

~]# xm create xen-dtbuild-2008r2 

# eject the cdrom hdc from windows

~]# xm block-configure xen-dtbuild-2008r2 file:/opt/win7.iso hdc:cdrom r 

#it works
#eject again

~]# xm block-configure xen-dtbuild-2008r2 file:/opt/win7.iso hdc:cdrom r 

#it does not work

~]# xm block-configure xen-dtbuild-2008r2 file:/opt/win7.iso hdc:cdrom r 

#it does not work again

~]# xm block-configure xen-dtbuild-2008r2 file:/opt/win7x64.iso hdc:cdrom r 

#it works
#eject again

~]# xm block-configure xen-dtbuild-2008r2 file:/opt/win7x64.iso hdc:cdrom r 
#it does not work


#so, if I eject a iso, then insert the same file as before, it does not work

Comment 18 Michal Novotny 2010-12-09 10:38:53 UTC
[snip]

> ~]# xm create xen-dtbuild-2008r2 
> 
> # eject the cdrom hdc from windows
> 

Kirby, what exactly do you mean by ejecting CD-ROM hdc from Windows? Also, you said you're working with Windows - are you using PV drivers or not?
> 
> #so, if I eject a iso, then insert the same file as before, it does not work

Well, I don't know whether qemu-dm or PV drivers have the option to "see" there was the eject done in the guest. If you use procedure like:

# xm block-configure xen-dtbuild-2008r2 file:/opt/win7.iso hdc:cdrom r 
.. then you don't eject the drive before reconfiguration and ...
# xm block-configure xen-dtbuild-2008r2 file:/opt/some-other.iso hdc:cdrom r 
.. is it now working fine? ...

So I mean... is it working fine if you don't eject the drive in the guest or if you eject the drive in the guest but if you pass another ISO image to the block-configure option?

Thanks,
Michal

Comment 19 Michal Novotny 2011-01-17 12:33:07 UTC
Kirby, any news about this one? Also, one more thing I'm thinking when re-reading all the comments in this bug - you say the change occurs in xenstore-ls and also it happens with HVM guest only (since Windows cannot run as PV guest and there is information about Windows guest only) so I guess the answer whether you're using PV drivers or not could help us. Without using the PV drivers it may be the issue?

Could you please try to reproduce this using the PV guests as well and if it's reproducible could you please try using HVM guest with PV drivers?

Thanks,
Michal

Comment 20 Kirby Zhou 2011-01-21 03:04:07 UTC
To Michal Novotny, I have tried Windows with PV driver. 

"so, if I eject a iso, then insert the same file as before, it does not work"

Comment 21 Kirby Zhou 2011-01-21 04:04:07 UTC
And it is working fine if I don't eject the drive in the guest with passing pass another ISO image. 

It is also working fine if I do eject the drive before passing another ISO image.

It failed if I do eject the drive before passing another ISO image.

Comment 22 Michal Novotny 2011-01-25 09:09:19 UTC
(In reply to comment #21)
> 
> It is also working fine if I do eject the drive before passing another ISO
> image.
> 
> It failed if I do eject the drive before passing another ISO image.

Kirby, so basically it's failing when you do eject in the guest and then you use xm block-configure or not ? Basically I don't know how to understand that it's working fine when you do eject the drive before passing another ISO and in the next sentence you say it's failing if you do eject the before passing another ISO... so when is it failing then?

Michal

Comment 23 Michal Novotny 2011-01-25 09:39:43 UTC
Oh, Kirby, do you mean it's usually working but sometimes it fails ? If so could you please try to reproduce using some kind of Linux guest as well? Maybe it's the issue with the PV drivers for Windows.

Michal

Comment 25 Kirby Zhou 2011-01-25 11:29:53 UTC
I'm sorry, i made a typo. 

It failed if I do eject the drive before passing the same ISO image.

Comment 26 Michal Novotny 2011-01-25 11:38:26 UTC
(In reply to comment #25)
> I'm sorry, i made a typo. 
> 
> It failed if I do eject the drive before passing the same ISO image.

Ok, what exactly do you mean by failure there? If you pass the same ISO there should be not change for the scenario like:

1) create guest with CD-ROM image set to Win2003.iso
2) eject the disk
3) attach the Win2003.iso again

You should still be able to see Win2003.iso contents. The failure is that you can't see it there if I understand correctly, is that right? Well, I think that it is because of the path in xenstore doesn't change at all. So you're using PV drivers in Windows guest, you say?

I'm adding Paolo Bonzini to CC list since he's working on Windows PV drivers and the issue *may* be there.

Michal

Comment 28 Paolo Bonzini 2011-01-25 12:49:47 UTC
PV drivers are not used for the CDROM.  If I remember correctly, the code that you're looking for is already in qemu-dm.  See xenstore_process_event.

Comment 29 Michal Novotny 2011-01-25 15:33:29 UTC
Created attachment 475186 [details]
Patch to fix eject behaviour

Well, I finally found out the problem is when you eject the CD-ROM device since the path in bs_table isn't changed so this is the patch to reset the bs_table filename on eject.

Michal

Comment 30 Michal Novotny 2011-01-26 12:17:48 UTC
Kirby, could you please test using RPMs from:

http://people.redhat.com/minovotn/xen/

and let us know whether it's working fine?

Thanks a lot,
Michal

Comment 33 Yuyu Zhou 2011-03-17 12:58:39 UTC
xen-3.0.3-114 is deleted on brew, so reproduced the bug on xen-3.0.3-122 and verified on xen-3.0.3-123.

Steps:
1. create a Windows 2003 64bit guest with disk option [ "...","file:/exp/iso/Windows2003-64.iso,hdc:cdrom,r" ]
2. eject the disk
3. attach the Win2003-64.iso again
4. repeat step 2 and step 3 several times with same disk
5. repeat step 2 and step 3 several times with different disk

Results:
It works fine on xen-3.0.3-123

So change the Status to VERIFIED.

Comment 34 Yuyu Zhou 2011-03-18 07:00:02 UTC
Plus, also verified on xen-3.0.3-126.el5

Comment 35 Tomas Capek 2011-07-13 13:25:11 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Previously, when an image file was ejected from a CD-ROM device in an HVM guest, the path in the bs_table entry was not changed accordingly. Consequently, it was impossible to switch ISO images in the device. With this update, a patch has been provided that resets the bs_table entry upon an eject, fixing this bug.

Comment 36 Paolo Bonzini 2011-07-13 14:52:39 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-Previously, when an image file was ejected from a CD-ROM device in an HVM guest, the path in the bs_table entry was not changed accordingly. Consequently, it was impossible to switch ISO images in the device. With this update, a patch has been provided that resets the bs_table entry upon an eject, fixing this bug.+Previously, if the virtual CD-ROM was ejected in the guest operating system, and "xm block-configure" was subsequently used to reinsert the same medium, the guest operating system failed to detect the newly inserted medium. With this update, a patch has been provided that handles CD-ROM ejection properly, fixing the bug.

Comment 37 Tomas Capek 2011-07-14 13:27:05 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-Previously, if the virtual CD-ROM was ejected in the guest operating system, and "xm block-configure" was subsequently used to reinsert the same medium, the guest operating system failed to detect the newly inserted medium. With this update, a patch has been provided that handles CD-ROM ejection properly, fixing the bug.+Previously, if the virtual CD-ROM was ejected in the guest operating system, and the "xm block-configure" command was subsequently used to reinsert the same medium, the guest operating system failed to detect the newly inserted medium. With this update, a patch has been provided that handles CD-ROM ejection properly, fixing the bug.

Comment 38 errata-xmlrpc 2011-07-21 09:16:50 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-1070.html

Comment 39 errata-xmlrpc 2011-07-21 11:57:59 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-1070.html


Note You need to log in before you can comment on or make changes to this bug.