From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MH1kT-0007WN-5k for qemu-devel@nongnu.org; Wed, 17 Jun 2009 16:28:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MH1kO-0007Vb-5v for qemu-devel@nongnu.org; Wed, 17 Jun 2009 16:28:44 -0400 Received: from [199.232.76.173] (port=36779 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MH1kN-0007VO-UK for qemu-devel@nongnu.org; Wed, 17 Jun 2009 16:28:39 -0400 Received: from mx2.redhat.com ([66.187.237.31]:52742) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MH1kN-0008Ih-5R for qemu-devel@nongnu.org; Wed, 17 Jun 2009 16:28:39 -0400 From: Eduardo Habkost Date: Wed, 17 Jun 2009 17:28:26 -0300 Message-Id: <1245270508-23315-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH 0/2] Guess host device type from guest device type for block devices List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org, Cole Robinson This fixes the following issue: https://bugzilla.redhat.com/show_bug.cgi?id=473154 Sometimes a CD-ROM drive path doesn't start with /dev/cdrom, causing problems if a disk isn't inserted on the drive. With this patch, the floppy and cdrom drivers are used if using a host block device as backend and the virtual device type is floppy or CD-ROM. Example: $ ls -l /dev/cdrom /dev/hda lrwxrwxrwx 1 root root 3 Jun 17 10:20 /dev/cdrom -> hda brw-rw---- 1 root disk 3, 0 Jun 17 10:20 /dev/hda Before this series (CD-ROM drive with no disk): $ sudo qemu-system-x86_64 -cdrom /dev/cdrom [works] $ sudo qemu-system-x86_64 -cdrom /dev/hda qemu: could not open disk image /dev/hda After this series (with no disk on the CD-ROM drive, too): $ sudo qemu-system-x86_64 -cdrom /dev/hda [works] This is based on a fix from Cole Robinson, submitted here: http://marc.info/?l=qemu-devel&m=124458617900905 There are other two points where I think the code could be improved: - Redundant stat() calls: stat() is called at hdev_probe_device(), and called again on cdrom_probe_device() and floppy_probe_device() - Duplicated cdrom driver code for Linux and FreeBSD: I don't like #ifdefs, but I don't like the amount of duplicated code, either. Eduardo Habkost (2): Add a BlockDriverState parameter to bdrv_probe_device() Guess host device type from requested guest device type block.c | 6 +++--- block/raw-posix.c | 38 +++++++++++++++++++++++++++++--------- block/raw-win32.c | 2 +- block_int.h | 2 +- 4 files changed, 34 insertions(+), 14 deletions(-) -- Eduardo