From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCsN3-0005eB-E5 for qemu-devel@nongnu.org; Wed, 28 Mar 2012 08:53:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCsMs-0007we-Ay for qemu-devel@nongnu.org; Wed, 28 Mar 2012 08:53:00 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 28 Mar 2012 14:52:33 +0200 Message-Id: <1332939159-16434-31-git-send-email-afaerber@suse.de> In-Reply-To: <1332939159-16434-1-git-send-email-afaerber@suse.de> References: <1332939159-16434-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH stable-0.15 30/36] pc: Fix floppy drives with if=none List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , kvm@suse.de, qemu-stable@nongnu.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= , Bruce Rogers From: Kevin Wolf Commit 63ffb564 broke floppy devices specified on the command line like -drive file=3D...,if=3Dnone,id=3Dfloppy -global isa-fdc.driveA=3Dfloppy b= ecause it relies on drive_get() which works only with -fda/-drive if=3Dfloppy. This patch resembles what we're already doing for IDE, i.e. remember the = floppy device that was created and use that to extract the BlockDriverStates whe= re needed. Signed-off-by: Kevin Wolf Reviewed-by: Markus Armbruster (cherry picked from commit 34d4260e1846d69d7241f690534e3dd4b3e6fd5b) [BR: bnc#733777] Signed-off-by: Bruce Rogers [AF: backported] Signed-off-by: Andreas F=C3=A4rber --- hw/fdc.c | 12 ++++++++++++ hw/fdc.h | 9 +++++++-- hw/pc.c | 25 ++++++++++++++----------- hw/pc.h | 3 ++- hw/pc_piix.c | 5 +++-- 5 files changed, 38 insertions(+), 16 deletions(-) diff --git a/hw/fdc.c b/hw/fdc.c index 9fdbc75..cf675ce 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -1911,6 +1911,18 @@ static int sun4m_fdc_init1(SysBusDevice *dev) return fdctrl_init_common(fdctrl); } =20 +void fdc_get_bs(BlockDriverState *bs[], ISADevice *dev) +{ + FDCtrlISABus *isa =3D DO_UPCAST(FDCtrlISABus, busdev, dev); + FDCtrl *fdctrl =3D &isa->state; + int i; + + for (i =3D 0; i < MAX_FD; i++) { + bs[i] =3D fdctrl->drives[i].bs; + } +} + + static const VMStateDescription vmstate_isa_fdc =3D{ .name =3D "fdc", .version_id =3D 2, diff --git a/hw/fdc.h b/hw/fdc.h index 09f73c6..506feb6 100644 --- a/hw/fdc.h +++ b/hw/fdc.h @@ -7,14 +7,15 @@ /* fdc.c */ #define MAX_FD 2 =20 -static inline void fdctrl_init_isa(DriveInfo **fds) +static inline ISADevice *fdctrl_init_isa(DriveInfo **fds) { ISADevice *dev; =20 dev =3D isa_try_create("isa-fdc"); if (!dev) { - return; + return NULL; } + if (fds[0]) { qdev_prop_set_drive_nofail(&dev->qdev, "driveA", fds[0]->bdrv); } @@ -22,10 +23,14 @@ static inline void fdctrl_init_isa(DriveInfo **fds) qdev_prop_set_drive_nofail(&dev->qdev, "driveB", fds[1]->bdrv); } qdev_init_nofail(&dev->qdev); + + return dev; } =20 void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, target_phys_addr_t mmio_base, DriveInfo **fds); void sun4m_fdctrl_init(qemu_irq irq, target_phys_addr_t io_base, DriveInfo **fds, qemu_irq *fdc_tc); +void fdc_get_bs(BlockDriverState *bs[], ISADevice *dev); + #endif diff --git a/hw/pc.c b/hw/pc.c index 14ce684..1d2b61e 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -333,12 +333,12 @@ static void pc_cmos_init_late(void *opaque) =20 void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, const char *boot_device, - BusState *idebus0, BusState *idebus1, + ISADevice *floppy, BusState *idebus0, BusState *idebus= 1, ISADevice *s) { int val, nb, nb_heads, max_track, last_sect, i; FDriveType fd_type[2]; - DriveInfo *fd[2]; + BlockDriverState *fd[MAX_FD]; static pc_cmos_init_late_arg arg; =20 /* various important CMOS locations needed by PC/Bochs bios */ @@ -380,14 +380,16 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t a= bove_4g_mem_size, } =20 /* floppy type */ - for (i =3D 0; i < 2; i++) { - fd[i] =3D drive_get(IF_FLOPPY, 0, i); - if (fd[i] && bdrv_is_inserted(fd[i]->bdrv)) { - bdrv_get_floppy_geometry_hint(fd[i]->bdrv, &nb_heads, &max_t= rack, - &last_sect, FDRIVE_DRV_NONE, - &fd_type[i]); - } else { - fd_type[i] =3D FDRIVE_DRV_NONE; + if (floppy) { + fdc_get_bs(fd, floppy); + for (i =3D 0; i < 2; i++) { + if (fd[i] && bdrv_is_inserted(fd[i])) { + bdrv_get_floppy_geometry_hint(fd[i], &nb_heads, &max_tra= ck, + &last_sect, FDRIVE_DRV_NON= E, + &fd_type[i]); + } else { + fd_type[i] =3D FDRIVE_DRV_NONE; + } } } val =3D (cmos_get_fd_drive_type(fd_type[0]) << 4) | @@ -1091,6 +1093,7 @@ static void cpu_request_exit(void *opaque, int irq,= int level) =20 void pc_basic_device_init(qemu_irq *isa_irq, ISADevice **rtc_state, + ISADevice **floppy, bool no_vmport) { int i; @@ -1155,7 +1158,7 @@ void pc_basic_device_init(qemu_irq *isa_irq, for(i =3D 0; i < MAX_FD; i++) { fd[i] =3D drive_get(IF_FLOPPY, 0, i); } - fdctrl_init_isa(fd); + *floppy =3D fdctrl_init_isa(fd); } =20 void pc_pci_device_init(PCIBus *pci_bus) diff --git a/hw/pc.h b/hw/pc.h index 6d5730b..24b7fe2 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -138,11 +138,12 @@ qemu_irq *pc_allocate_cpu_irq(void); void pc_vga_init(PCIBus *pci_bus); void pc_basic_device_init(qemu_irq *isa_irq, ISADevice **rtc_state, + ISADevice **floppy, bool no_vmport); void pc_init_ne2k_isa(NICInfo *nd); void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, const char *boot_device, - BusState *ide0, BusState *ide1, + ISADevice *floppy, BusState *ide0, BusState *ide1, ISADevice *s); void pc_pci_device_init(PCIBus *pci_bus); =20 diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 31552fd..b8e0841 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -89,6 +89,7 @@ static void pc_init1(ram_addr_t ram_size, DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; BusState *idebus[MAX_IDE_BUS]; ISADevice *rtc_state; + ISADevice *floppy; =20 pc_cpus_init(cpu_model); =20 @@ -141,7 +142,7 @@ static void pc_init1(ram_addr_t ram_size, } =20 /* init basic PC hardware */ - pc_basic_device_init(isa_irq, &rtc_state, xen_enabled()); + pc_basic_device_init(isa_irq, &rtc_state, &floppy, xen_enabled()); =20 for(i =3D 0; i < nb_nics; i++) { NICInfo *nd =3D &nd_table[i]; @@ -170,7 +171,7 @@ static void pc_init1(ram_addr_t ram_size, audio_init(isa_irq, pci_enabled ? pci_bus : NULL); =20 pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, - idebus[0], idebus[1], rtc_state); + floppy, idebus[0], idebus[1], rtc_state); =20 if (pci_enabled && usb_enabled) { usb_uhci_piix3_init(pci_bus, piix3_devfn + 2); --=20 1.7.7