public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* CD-ROM size not updated when switching CD-ROM images.
@ 2010-10-19  3:43 Alex Davis
  2010-10-19  8:31 ` Stefan Hajnoczi
  0 siblings, 1 reply; 8+ messages in thread
From: Alex Davis @ 2010-10-19  3:43 UTC (permalink / raw)
  To: kvm

Steps to reproduce:
) Download the first two Slackware-13.1 32-bit CD-ROM ISO images.
) Start KVM with the following command
   qemu-system-x86_64 -m 1024M \
     -cdrom < full path of 1st install disk > \
     -boot d
) Hit return when prompted for extra boot parameters.
) Hit return when asked to select a keyboard map.
) Hit return at the login prompt.
) cat /sys/block/sr0/size: this should return 1209360.
) Press Alt-Ctrl-2 to access the monitor
) eject ide1-cd0
) change ide1-cd0 < full path name of 2nd install disk >
) Press Alt-Ctrl-1 to return to the guest.
) dd if=/dev/sr0 of=/dev/null bs=512 skip=1209360 count=3
  this should return 
   3+0 records in
   3+0 records out.
  instead it returns 0+0....
) cat /sys/block/sr0/size: this still returns 1209360; it should return 1376736.

Oddly, when "mount /dev/sr0 ...." is  executed in the guest, ls of the mounted directory shows the correct contents for the 2nd CD.


KVM version is kvm-qemu-0.13.0

Host CPU model name      : Intel(R) Core(TM)2 Duo CPU     E8600  @ 3.33GHz
Host kernel is 2.6.32.12
Host arch is x86_64

Guest is Slackware 13.1 32-bit 
Guest kernel version is 2.6.33.4

Start command:
qemu-system-x86_64 -m 1024M \
-cdrom /spare2/slackware-13.1-install-d1.iso \
-boot d 

Not affected by -no-kvm-irqchip
Not affected by -no-kvm-pit
Not affected by -no-kvm


I can test patches.


Built with:
bash-3.2$ ./configure --prefix=/usr/kvm-qemu-0.13.0 --extra-ldflags="-L/usr/X11R7.4/lib"
Install prefix    /usr/kvm-qemu-0.13.0
BIOS directory    /usr/kvm-qemu-0.13.0/share/qemu
binary directory  /usr/kvm-qemu-0.13.0/bin
config directory  /usr/kvm-qemu-0.13.0/etc
Manual directory  /usr/kvm-qemu-0.13.0/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path       /sources/qemu-kvm-0.13.0
C compiler        gcc
Host C compiler   gcc
CFLAGS            -O2 -g
QEMU_CFLAGS       -m64 -fstack-protector-all -Wold-style-definition -I. -I$(SRC_PATH) -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing
LDFLAGS           -Wl,--warn-common -m64 -g -L/usr/X11R7.4/lib
make              make
install           install
host CPU          x86_64
host big endian   no
target list       x86_64-softmmu
tcg debug enabled no
Mon debug enabled no
gprof enabled     no
sparse enabled    no
strip binaries    yes
profiler          no
static build      no
-Werror enabled   no
SDL support       yes
curses support    yes
curl support      yes
check support     no
mingw32 support   no
Audio drivers     oss
Extra audio cards ac97 es1370 sb16
Block whitelist
Mixer emulation   no
VNC TLS support   no
VNC SASL support  yes
VNC JPEG support  yes
VNC PNG support   yes
VNC thread        no
xen support       no
CPU emulation     yes
brlapi support    no
bluez  support    no
Documentation     yes
NPTL support      yes
GUEST_BASE        yes
PIE user targets  no
vde support       no
IO thread         no
Linux AIO support no
ATTR/XATTR support yes
Install blobs     yes
KVM support       yes
KVM PIT support   yes
KVM device assig. yes
fdt support       no
preadv support    no
fdatasync         yes
uuid support      yes
vhost-net support yes
I code, therefore I am


      

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CD-ROM size not updated when switching CD-ROM images.
  2010-10-19  3:43 CD-ROM size not updated when switching CD-ROM images Alex Davis
@ 2010-10-19  8:31 ` Stefan Hajnoczi
  2010-10-20  0:03   ` Alex Davis
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Hajnoczi @ 2010-10-19  8:31 UTC (permalink / raw)
  To: Alex Davis; +Cc: kvm

On Tue, Oct 19, 2010 at 4:43 AM, Alex Davis <alex14641@yahoo.com> wrote:
> Steps to reproduce:
> ) Download the first two Slackware-13.1 32-bit CD-ROM ISO images.
> ) Start KVM with the following command
>   qemu-system-x86_64 -m 1024M \
>     -cdrom < full path of 1st install disk > \
>     -boot d
> ) Hit return when prompted for extra boot parameters.
> ) Hit return when asked to select a keyboard map.
> ) Hit return at the login prompt.
> ) cat /sys/block/sr0/size: this should return 1209360.
> ) Press Alt-Ctrl-2 to access the monitor
> ) eject ide1-cd0
> ) change ide1-cd0 < full path name of 2nd install disk >
> ) Press Alt-Ctrl-1 to return to the guest.
> ) dd if=/dev/sr0 of=/dev/null bs=512 skip=1209360 count=3
>  this should return
>   3+0 records in
>   3+0 records out.
>  instead it returns 0+0....
> ) cat /sys/block/sr0/size: this still returns 1209360; it should return 1376736.
>
> Oddly, when "mount /dev/sr0 ...." is  executed in the guest, ls of the mounted directory shows the correct contents for the 2nd CD.

After changing the CD-ROM, does running "blockdev --rereadpt /dev/sr0"
update the size as expected?

You ejected the CD-ROM on the QEMU side, the guest doesn't necessarily
know about the medium change.  What happens when you use "eject
/dev/sr0" inside the guest instead?

I don't know how CD-ROM media change works on real hardware, but that
is the behavior that QEMU should be following.

Stefan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CD-ROM size not updated when switching CD-ROM images.
  2010-10-19  8:31 ` Stefan Hajnoczi
@ 2010-10-20  0:03   ` Alex Davis
  2010-10-20 16:44     ` David Ahern
  0 siblings, 1 reply; 8+ messages in thread
From: Alex Davis @ 2010-10-20  0:03 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: kvm

I code, therefore I am


--- On Tue, 10/19/10, Stefan Hajnoczi <stefanha@gmail.com> wrote:

> From: Stefan Hajnoczi <stefanha@gmail.com>
> Subject: Re: CD-ROM size not updated when switching CD-ROM images.
> To: "Alex Davis" <alex14641@yahoo.com>
> Cc: kvm@vger.kernel.org
> Date: Tuesday, October 19, 2010, 4:31 AM
> On Tue, Oct 19, 2010 at 4:43 AM, Alex
> Davis <alex14641@yahoo.com>
> wrote:
> > Steps to reproduce:
> > ) Download the first two Slackware-13.1 32-bit CD-ROM
> ISO images.
> > ) Start KVM with the following command
> >   qemu-system-x86_64 -m 1024M \
> >     -cdrom < full path of 1st install disk >
> \
> >     -boot d
> > ) Hit return when prompted for extra boot parameters.
> > ) Hit return when asked to select a keyboard map.
> > ) Hit return at the login prompt.
> > ) cat /sys/block/sr0/size: this should return
> 1209360.
> > ) Press Alt-Ctrl-2 to access the monitor
> > ) eject ide1-cd0
> > ) change ide1-cd0 < full path name of 2nd install
> disk >
> > ) Press Alt-Ctrl-1 to return to the guest.
> > ) dd if=/dev/sr0 of=/dev/null bs=512 skip=1209360
> count=3
> >  this should return
> >   3+0 records in
> >   3+0 records out.
> >  instead it returns 0+0....
> > ) cat /sys/block/sr0/size: this still returns 1209360;
> it should return 1376736.
> >
> > Oddly, when "mount /dev/sr0 ...." is  executed in the
> guest, ls of the mounted directory shows the correct
> contents for the 2nd CD.
> 
> After changing the CD-ROM, does running "blockdev
> --rereadpt /dev/sr0"
> update the size as expected?
The install CD does not have the blockdev command.

> You ejected the CD-ROM on the QEMU side, the guest doesn't
> necessarily
> know about the medium change.  What happens when you
> use "eject
> /dev/sr0" inside the guest instead?
I get a 'no medium found' error from the 'dd..' command. After
going into the the monitor, ejecting and reloading the disk, 
I still get the size of the first disk in the guest.
> 
> I don't know how CD-ROM media change works on real
> hardware, but that
> is the behavior that QEMU should be following.
> 
> Stefan


      

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CD-ROM size not updated when switching CD-ROM images.
@ 2010-10-20 12:50 Alex Davis
  0 siblings, 0 replies; 8+ messages in thread
From: Alex Davis @ 2010-10-20 12:50 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: kvm

I code, therefore I am


--- On Tue, 10/19/10, Alex Davis <alex14641@yahoo.com> wrote:

> From: Alex Davis <alex14641@yahoo.com>
> Subject: Re: CD-ROM size not updated when switching CD-ROM images.
> To: "Stefan Hajnoczi" <stefanha@gmail.com>
> Cc: kvm@vger.kernel.org
> Date: Tuesday, October 19, 2010, 8:03 PM
> I code, therefore I am
> 
> 
> --- On Tue, 10/19/10, Stefan Hajnoczi <stefanha@gmail.com>
> wrote:
> 
> > From: Stefan Hajnoczi <stefanha@gmail.com>
> > Subject: Re: CD-ROM size not updated when switching
> CD-ROM images.
> > To: "Alex Davis" <alex14641@yahoo.com>
> > Cc: kvm@vger.kernel.org
> > Date: Tuesday, October 19, 2010, 4:31 AM
> > On Tue, Oct 19, 2010 at 4:43 AM, Alex
> > Davis <alex14641@yahoo.com>
> > wrote:
> > > Steps to reproduce:
> > > ) Download the first two Slackware-13.1 32-bit
> CD-ROM
> > ISO images.
> > > ) Start KVM with the following command
> > >   qemu-system-x86_64 -m 1024M \
> > >     -cdrom < full path of 1st install disk
> >
> > \
> > 
> > After changing the CD-ROM, does running "blockdev
> > --rereadpt /dev/sr0"
> > update the size as expected?
> The install CD does not have the blockdev command.
> 
> > You ejected the CD-ROM on the QEMU side, the guest
> doesn't
> > necessarily
> > know about the medium change.  What happens when you
> > use "eject
> > /dev/sr0" inside the guest instead?
> I get a 'no medium found' error from the 'dd..' command.
> After
> going into the the monitor, ejecting and reloading the
> disk, 
> I still get the size of the first disk in the guest.
> > 
> > I don't know how CD-ROM media change works on real
> > hardware, but that
> > is the behavior that QEMU should be following.
> > 
> > Stefan
> 
> 
I attempted some debugging by putting a printf in the cdrom_change_cb
method in hw/ide/core.c to output nr_sectors after the CD-ROM has been
changed: the value is correct. So the problem seems to be that the
new value isn't being propagated to the guest.


      

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CD-ROM size not updated when switching CD-ROM images.
  2010-10-20  0:03   ` Alex Davis
@ 2010-10-20 16:44     ` David Ahern
  2010-10-20 23:28       ` Alex Davis
  2010-10-30 20:32       ` Alex Davis
  0 siblings, 2 replies; 8+ messages in thread
From: David Ahern @ 2010-10-20 16:44 UTC (permalink / raw)
  To: Alex Davis; +Cc: Stefan Hajnoczi, kvm



On 10/19/10 18:03, Alex Davis wrote:

>> You ejected the CD-ROM on the QEMU side, the guest doesn't
>> necessarily
>> know about the medium change.  What happens when you
>> use "eject
>> /dev/sr0" inside the guest instead?
> I get a 'no medium found' error from the 'dd..' command. After
> going into the the monitor, ejecting and reloading the disk, 
> I still get the size of the first disk in the guest.

As I recall the old data is coming from the host page cache; it is not
seeing the media change. Try dropping the cache in the host on a media
change (echo 3 > /proc/sys/vm/drop_caches) or modify qemu to close and
reopen the cdrom device.

David


>>
>> I don't know how CD-ROM media change works on real
>> hardware, but that
>> is the behavior that QEMU should be following.
>>
>> Stefan
> 
> 
>       
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CD-ROM size not updated when switching CD-ROM images.
  2010-10-20 16:44     ` David Ahern
@ 2010-10-20 23:28       ` Alex Davis
  2010-10-30 20:32       ` Alex Davis
  1 sibling, 0 replies; 8+ messages in thread
From: Alex Davis @ 2010-10-20 23:28 UTC (permalink / raw)
  To: David Ahern; +Cc: Stefan Hajnoczi, kvm

I code, therefore I am


--- On Wed, 10/20/10, David Ahern <dsahern@gmail.com> wrote:

> From: David Ahern <dsahern@gmail.com>
> Subject: Re: CD-ROM size not updated when switching CD-ROM images.
> To: "Alex Davis" <alex14641@yahoo.com>
> Cc: "Stefan Hajnoczi" <stefanha@gmail.com>, kvm@vger.kernel.org
> Date: Wednesday, October 20, 2010, 12:44 PM
> 
> 
> On 10/19/10 18:03, Alex Davis wrote:
> 
> >> You ejected the CD-ROM on the QEMU side, the guest
> doesn't
> >> necessarily
> >> know about the medium change.  What happens
> when you
> >> use "eject
> >> /dev/sr0" inside the guest instead?
> > I get a 'no medium found' error from the 'dd..'
> command. After
> > going into the the monitor, ejecting and reloading the
> disk, 
> > I still get the size of the first disk in the guest.
> 
> As I recall the old data is coming from the host page
> cache; it is not
> seeing the media change. Try dropping the cache in the host
> on a media
> change (echo 3 > /proc/sys/vm/drop_caches) 
This had no effect.

>or modify
> qemu to close and
> reopen the cdrom device.
QEMU already does this.

> David
> 
> 
> >>
> >> I don't know how CD-ROM media change works on
> real
> >> hardware, but that
> >> is the behavior that QEMU should be following.
> >>
> >> Stefan
> > 
> > 
> >       
> > --
> > To unsubscribe from this list: send the line
> "unsubscribe kvm" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> 


      

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CD-ROM size not updated when switching CD-ROM images.
  2010-10-20 16:44     ` David Ahern
  2010-10-20 23:28       ` Alex Davis
@ 2010-10-30 20:32       ` Alex Davis
  1 sibling, 0 replies; 8+ messages in thread
From: Alex Davis @ 2010-10-30 20:32 UTC (permalink / raw)
  To: David Ahern; +Cc: Stefan Hajnoczi, kvm



--- On Wed, 10/20/10, David Ahern <dsahern@gmail.com> wrote:

> From: David Ahern <dsahern@gmail.com>
> Subject: Re: CD-ROM size not updated when switching CD-ROM images.
> To: "Alex Davis" <alex14641@yahoo.com>
> Cc: "Stefan Hajnoczi" <stefanha@gmail.com>, kvm@vger.kernel.org
> Date: Wednesday, October 20, 2010, 12:44 PM
> 
> 
> On 10/19/10 18:03, Alex Davis wrote:
> 
> >> You ejected the CD-ROM on the QEMU side, the guest
> doesn't
> >> necessarily
> >> know about the medium change.  What happens
> when you
> >> use "eject
> >> /dev/sr0" inside the guest instead?
> > I get a 'no medium found' error from the 'dd..'
> command. After
> > going into the the monitor, ejecting and reloading the
> disk, 
> > I still get the size of the first disk in the guest.
> 
> As I recall the old data is coming from the host page
> cache; it is not
> seeing the media change. Try dropping the cache in the host
> on a media
> change (echo 3 > /proc/sys/vm/drop_caches) or modify
> qemu to close and
> reopen the cdrom device.
> 
> David
I am able to reproduce this problem with just a plain kernel using the
ata_piix driver, an initrd that just starts a shell, and plain qemu.
When the disk is changed via the monitor, the guest invokes the error-
handling code on the next read of the CD-ROM, but the code path doesn't
trigger the 'update size' logic. I did an experiment where I placed the
line 'sdev->changed = 1' in the sr_open method in sr.c of the guest
kernel source, the size was updated, but I will look to see if there's
something in qemu that can be changed to make it work properly.

Of course any input from the qemu/kvm developers is appreciated.
 
I code, therefore I am

> 
> >>
> >> I don't know how CD-ROM media change works on
> real
> >> hardware, but that
> >> is the behavior that QEMU should be following.
> >>
> >> Stefan
> > 
> > 
> >       
> > --
> > To unsubscribe from this list: send the line
> "unsubscribe kvm" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> 


      

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CD-ROM size not updated when switching CD-ROM images.
@ 2010-10-30 21:24 Alex Davis
  0 siblings, 0 replies; 8+ messages in thread
From: Alex Davis @ 2010-10-30 21:24 UTC (permalink / raw)
  To: linux-kernel; +Cc: kvm

Forwarding to linux-kernel.

I code, therefore I am


--- On Sat, 10/30/10, Alex Davis <alex14641@yahoo.com> wrote:

> From: Alex Davis <alex14641@yahoo.com>
> Subject: Re: CD-ROM size not updated when switching CD-ROM images.
> To: "David Ahern" <dsahern@gmail.com>
> Cc: "Stefan Hajnoczi" <stefanha@gmail.com>, kvm@vger.kernel.org
> Date: Saturday, October 30, 2010, 4:32 PM
> 
> 
> --- On Wed, 10/20/10, David Ahern <dsahern@gmail.com>
> wrote:
> 
> > From: David Ahern <dsahern@gmail.com>
> > Subject: Re: CD-ROM size not updated when switching
> CD-ROM images.
> > To: "Alex Davis" <alex14641@yahoo.com>
> > Cc: "Stefan Hajnoczi" <stefanha@gmail.com>,
> kvm@vger.kernel.org
> > Date: Wednesday, October 20, 2010, 12:44 PM
> > 
> > 
> > On 10/19/10 18:03, Alex Davis wrote:
> > 
> > >> You ejected the CD-ROM on the QEMU side, the
> guest
> > doesn't
> > >> necessarily
> > >> know about the medium change.  What
> happens
> > when you
> > >> use "eject
> > >> /dev/sr0" inside the guest instead?
> > > I get a 'no medium found' error from the 'dd..'
> > command. After
> > > going into the the monitor, ejecting and
> reloading the
> > disk, 
> > > I still get the size of the first disk in the
> guest.
> > 
> > As I recall the old data is coming from the host page
> > cache; it is not
> > seeing the media change. Try dropping the cache in the
> host
> > on a media
> > change (echo 3 > /proc/sys/vm/drop_caches) or
> modify
> > qemu to close and
> > reopen the cdrom device.
> > 
> > David

> I am able to reproduce this problem with just a plain
> kernel using the ata_piix driver, an initrd that just starts a 
> shell, and plain qemu. When the disk is changed via the monitor,
> the guest invokes the error-handling code on the next read of the
> CD-ROM, but the code path doesn't trigger the 'update size' logic.
> I did an experiment where I placed the line 'sdev->changed = 1'
> in the sr_open method in sr.c of the guest > kernel source, the 
> size was updated, but I will look to see if there's something in
> qemu that can be changed to make it work properly.
> 
> Of course any input from the qemu/kvm developers is
> appreciated.
> 
> I code, therefore I am
> 
> > 
> > >>
> > >> I don't know how CD-ROM media change works
> on
> > real
> > >> hardware, but that
> > >> is the behavior that QEMU should be
> following.
> > >>
> > >> Stefan
> > > 
> > > 
> > >       
> > > --
> > > To unsubscribe from this list: send the line
> > "unsubscribe kvm" in
> > > the body of a message to majordomo@vger.kernel.org
> > > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > > 
> > 
> 
> 
>       
> 


      

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-10-30 21:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-19  3:43 CD-ROM size not updated when switching CD-ROM images Alex Davis
2010-10-19  8:31 ` Stefan Hajnoczi
2010-10-20  0:03   ` Alex Davis
2010-10-20 16:44     ` David Ahern
2010-10-20 23:28       ` Alex Davis
2010-10-30 20:32       ` Alex Davis
  -- strict thread matches above, loose matches on Subject: below --
2010-10-20 12:50 Alex Davis
2010-10-30 21:24 Alex Davis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox