All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	qemu-block@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	Max Reitz <mreitz@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>, John Snow <jsnow@redhat.com>
Subject: [PATCH 7/7] pc: add floppy=OnOffAuto
Date: Wed,  4 Aug 2021 16:27:37 +0200	[thread overview]
Message-ID: <20210804142737.3366441-8-kraxel@redhat.com> (raw)
In-Reply-To: <20210804142737.3366441-1-kraxel@redhat.com>

Allows to enable/disable the floppy controller.  Default depends on
MachineClass->no_floppy.  It's ON for now, but we can flip the default
for 6.2+ machine types.

NOTE: This requires -nodefaults or no_floppy=1 to actually have an
effect.  Otherwise the default floppy drive created by qemu will
auto-enable the floppy controller.  Not sure how to deal with that best.
IMHO we should simply stop creating a default floppy, unfortunaly
that will break live migration.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/hw/i386/pc.h |  2 ++
 hw/i386/pc.c         | 23 +++++++++++++++++++++++
 hw/i386/pc_piix.c    |  8 +++++++-
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 88dffe751724..b418ead6c260 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -38,6 +38,7 @@ typedef struct PCMachineState {
     /* Configuration options: */
     uint64_t max_ram_below_4g;
     OnOffAuto vmport;
+    OnOffAuto floppy;
 
     bool acpi_build_enabled;
     bool smbus_enabled;
@@ -59,6 +60,7 @@ typedef struct PCMachineState {
 #define PC_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g"
 #define PC_MACHINE_DEVMEM_REGION_SIZE "device-memory-region-size"
 #define PC_MACHINE_VMPORT           "vmport"
+#define PC_MACHINE_FLOPPY           "floppy"
 #define PC_MACHINE_SMBUS            "smbus"
 #define PC_MACHINE_SATA             "sata"
 #define PC_MACHINE_PIT              "pit"
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index c2b9d62a358f..832ea9cc8ef8 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1468,6 +1468,23 @@ static void pc_machine_set_vmport(Object *obj, Visitor *v, const char *name,
     visit_type_OnOffAuto(v, name, &pcms->vmport, errp);
 }
 
+static void pc_machine_get_floppy(Object *obj, Visitor *v, const char *name,
+                                  void *opaque, Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+    OnOffAuto floppy = pcms->floppy;
+
+    visit_type_OnOffAuto(v, name, &floppy, errp);
+}
+
+static void pc_machine_set_floppy(Object *obj, Visitor *v, const char *name,
+                                  void *opaque, Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+
+    visit_type_OnOffAuto(v, name, &pcms->floppy, errp);
+}
+
 static bool pc_machine_get_smbus(Object *obj, Error **errp)
 {
     PCMachineState *pcms = PC_MACHINE(obj);
@@ -1751,6 +1768,12 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
     object_class_property_set_description(oc, PC_MACHINE_VMPORT,
         "Enable vmport (pc & q35)");
 
+    object_class_property_add(oc, PC_MACHINE_FLOPPY, "OnOffAuto",
+        pc_machine_get_floppy, pc_machine_set_floppy,
+        NULL, NULL);
+    object_class_property_set_description(oc, PC_MACHINE_FLOPPY,
+        "Enable floppy (pc only)");
+
     object_class_property_add_bool(oc, PC_MACHINE_SMBUS,
         pc_machine_get_smbus, pc_machine_set_smbus);
 
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 30b8bd6ea92d..7f81729e42cd 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -235,8 +235,14 @@ static void pc_init1(MachineState *machine,
         pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
     }
 
+    if (pcms->floppy == ON_OFF_AUTO_AUTO) {
+        pcms->floppy = MACHINE_CLASS(pcmc)->no_floppy
+            ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
+    }
+
     /* init basic PC hardware */
-    pc_basic_device_init(pcms, isa_bus, x86ms->gsi, &rtc_state, true,
+    pc_basic_device_init(pcms, isa_bus, x86ms->gsi, &rtc_state,
+                         pcms->floppy == ON_OFF_AUTO_ON,
                          0x4);
 
     pc_nic_init(pcmc, isa_bus, pci_bus);
-- 
2.31.1



  parent reply	other threads:[~2021-08-04 14:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-04 14:27 [PATCH 0/7] floppy: build as modules Gerd Hoffmann
2021-08-04 14:27 ` [PATCH 1/7] floppy: move isa_fdc_get_drive_type to separate source file Gerd Hoffmann
2021-08-04 14:27 ` [PATCH 2/7] floppy: move isa_fdc_init_drives + fdctrl_init_drives Gerd Hoffmann
2021-08-04 14:27 ` [PATCH 3/7] floppy: move fdctrl_init_sysbus Gerd Hoffmann
2021-08-04 14:27 ` [PATCH 4/7] floppy: move sun4m_fdctrl_init Gerd Hoffmann
2021-08-04 14:27 ` [PATCH 5/7] floppy: move cmos_get_fd_drive_type Gerd Hoffmann
2021-08-04 14:27 ` [PATCH 6/7] floppy: build as modules Gerd Hoffmann
2021-08-04 14:27 ` Gerd Hoffmann [this message]
2021-08-04 15:19 ` [PATCH 0/7] " Philippe Mathieu-Daudé
2021-08-05  7:11   ` Gerd Hoffmann
2021-08-16 21:55     ` John Snow
2021-08-17  9:09       ` Philippe Mathieu-Daudé
2021-08-17 13:19         ` John Snow

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=20210804142737.3366441-8-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.