From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
kvm@suse.de, qemu-stable@nongnu.org,
"Andreas Färber" <afaerber@suse.de>,
"Bruce Rogers" <brogers@suse.com>
Subject: [Qemu-devel] [PATCH stable-0.15 30/36] pc: Fix floppy drives with if=none
Date: Wed, 28 Mar 2012 14:52:33 +0200 [thread overview]
Message-ID: <1332939159-16434-31-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1332939159-16434-1-git-send-email-afaerber@suse.de>
From: Kevin Wolf <kwolf@redhat.com>
Commit 63ffb564 broke floppy devices specified on the command line like
-drive file=...,if=none,id=floppy -global isa-fdc.driveA=floppy because it
relies on drive_get() which works only with -fda/-drive if=floppy.
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 where
needed.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
(cherry picked from commit 34d4260e1846d69d7241f690534e3dd4b3e6fd5b)
[BR: bnc#733777]
Signed-off-by: Bruce Rogers <brogers@suse.com>
[AF: backported]
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
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);
}
+void fdc_get_bs(BlockDriverState *bs[], ISADevice *dev)
+{
+ FDCtrlISABus *isa = DO_UPCAST(FDCtrlISABus, busdev, dev);
+ FDCtrl *fdctrl = &isa->state;
+ int i;
+
+ for (i = 0; i < MAX_FD; i++) {
+ bs[i] = fdctrl->drives[i].bs;
+ }
+}
+
+
static const VMStateDescription vmstate_isa_fdc ={
.name = "fdc",
.version_id = 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
-static inline void fdctrl_init_isa(DriveInfo **fds)
+static inline ISADevice *fdctrl_init_isa(DriveInfo **fds)
{
ISADevice *dev;
dev = 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;
}
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)
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 *idebus1,
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;
/* 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 above_4g_mem_size,
}
/* floppy type */
- for (i = 0; i < 2; i++) {
- fd[i] = 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_track,
- &last_sect, FDRIVE_DRV_NONE,
- &fd_type[i]);
- } else {
- fd_type[i] = FDRIVE_DRV_NONE;
+ if (floppy) {
+ fdc_get_bs(fd, floppy);
+ for (i = 0; i < 2; i++) {
+ if (fd[i] && bdrv_is_inserted(fd[i])) {
+ bdrv_get_floppy_geometry_hint(fd[i], &nb_heads, &max_track,
+ &last_sect, FDRIVE_DRV_NONE,
+ &fd_type[i]);
+ } else {
+ fd_type[i] = FDRIVE_DRV_NONE;
+ }
}
}
val = (cmos_get_fd_drive_type(fd_type[0]) << 4) |
@@ -1091,6 +1093,7 @@ static void cpu_request_exit(void *opaque, int irq, int level)
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 = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
- fdctrl_init_isa(fd);
+ *floppy = fdctrl_init_isa(fd);
}
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);
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;
pc_cpus_init(cpu_model);
@@ -141,7 +142,7 @@ static void pc_init1(ram_addr_t ram_size,
}
/* 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());
for(i = 0; i < nb_nics; i++) {
NICInfo *nd = &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);
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);
if (pci_enabled && usb_enabled) {
usb_uhci_piix3_init(pci_bus, piix3_devfn + 2);
--
1.7.7
next prev parent reply other threads:[~2012-03-28 12:53 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-28 12:52 [Qemu-devel] [PATCH stable-0.15 00/36] Preparing 0.15.2 Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 01/36] ccid: Fix buffer overrun in handling of VSC_ATR message Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 02/36] qdev: Reset hot-plugged devices Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 03/36] e1000: use MII status register for link up/down Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 04/36] e1000: Don't set the Capabilities List bit Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 05/36] e1000: bounds packet size against buffer size Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 06/36] compatfd.c: Don't pass NULL pointer to SYS_signalfd Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 07/36] kvm: avoid reentring kvm_flush_coalesced_mmio_buffer() Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 08/36] vmdk: vmdk_read_cid returns garbage if p_name is NULL Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 09/36] block: Fix bdrv_open use after free Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 10/36] ide: Fix off-by-one error in array index check Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 11/36] acl: Fix use after free in qemu_acl_reset() Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 12/36] migration: flush migration data to disk Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 13/36] Fix X86 CPU topology in KVM mode Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 14/36] hw/lan9118.c: Add missing 'break' to fix buffer overrun Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 15/36] ac97: don't override the pci subsystem id Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 16/36] vvfat: Fix potential buffer overflow Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 17/36] vns/tls: don't use depricated gnutls functions Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 18/36] block/curl: Implement a flush function on the fd handlers Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 19/36] hda: do not mix output and input streams, RHBZ #740493 Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 20/36] hda: do not mix output and input stream states, " Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 21/36] Teach block/vdi about "discarded" (no longer allocated) blocks Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 22/36] vmdk: Improve error handling Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 23/36] block: set bs->read_only before .bdrv_open() Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 24/36] console: Fix rendering of VGA underline Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 25/36] block: Fix vpc initialization of the Dynamic Disk Header Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 26/36] qcow: Fix bdrv_write_compressed error handling Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 27/36] block: reinitialize across bdrv_close()/bdrv_open() Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 28/36] qxl: stride fixup Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 29/36] vmdk: Fix possible segfaults Andreas Färber
2012-03-28 12:52 ` Andreas Färber [this message]
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 31/36] cpu-common: Have a ram_addr_t of uint64 with Xen Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 32/36] Error check find_ram_offset Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 33/36] pc: add pc-0.15 Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 34/36] pc: fix event_idx compatibility for virtio devices Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 35/36] Add missing trace call to oslib-posix.c:qemu_vmalloc() Andreas Färber
2012-03-28 12:52 ` [Qemu-devel] [PATCH stable-0.15 36/36] qemu_vmalloc: align properly for transparent hugepages and KVM Andreas Färber
2012-03-28 17:06 ` [Qemu-devel] [PATCH stable-0.15 00/36] Preparing 0.15.2 Stefan Weil
2012-06-10 22:11 ` Andreas Färber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1332939159-16434-31-git-send-email-afaerber@suse.de \
--to=afaerber@suse.de \
--cc=brogers@suse.com \
--cc=kvm@suse.de \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).