From: Patrick Eads <patrick.eads@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Patrick Eads" <patrick.eads@gmail.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Zhao Liu" <zhao1.liu@intel.com>,
"Laurent Vivier" <laurent@vivier.eu>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH] Plumbed previously ununsed defaults_enabled in vl.c, s.t. it provides the status of the '-nodefaults' flag to created machines
Date: Mon, 28 Oct 2024 22:13:46 +0000 [thread overview]
Message-ID: <20241028221814.329577-2-peads@users.noreply.github.com> (raw)
From: Patrick Eads <patrick.eads@gmail.com>
Signed-off-by: Patrick Eads <patrick.eads@gmail.com>
---
.gitignore | 2 ++
hw/core/machine.c | 15 +++++++++++++++
hw/m68k/q800.c | 15 ++++++++-------
include/hw/boards.h | 1 +
system/vl.c | 2 +-
5 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore
index 61fa39967b..306799820c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,3 +20,5 @@ GTAGS
*.swp
*.patch
*.gcov
+.idea
+buildDir
diff --git a/hw/core/machine.c b/hw/core/machine.c
index adaba17eba..5b133cc3f2 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -475,6 +475,16 @@ static void machine_set_usb(Object *obj, bool value, Error **errp)
ms->usb_disabled = !value;
}
+static bool machine_get_defaults(Object *obj, __attribute__((unused)) Error **errp) {
+ MachineState *ms = MACHINE(obj);
+ return ms->has_defaults;
+}
+
+static void machine_set_defaults(Object *obj, bool val, __attribute__((unused)) Error **errp) {
+ MachineState *ms = MACHINE(obj);
+ ms->has_defaults = val;
+}
+
static bool machine_get_graphics(Object *obj, Error **errp)
{
MachineState *ms = MACHINE(obj);
@@ -1083,6 +1093,11 @@ static void machine_class_init(ObjectClass *oc, void *data)
object_class_property_set_description(oc, "usb",
"Set on/off to enable/disable usb");
+ object_class_property_add_bool(oc, "defaults",
+ machine_get_defaults, machine_set_defaults);
+ object_class_property_set_description(oc, "defaults",
+ "Set on/off to enable/disable hardware defaults");
+
object_class_property_add_bool(oc, "graphics",
machine_get_graphics, machine_set_graphics);
object_class_property_set_description(oc, "graphics",
diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index 556604e1dc..63782315fe 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -262,13 +262,13 @@ static void q800_machine_init(MachineState *machine)
const char *initrd_filename = machine->initrd_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *bios_name = machine->firmware ?: MACROM_FILENAME;
+ const bool has_defaults = m->parent_obj.has_defaults;
hwaddr parameters_base;
CPUState *cs;
DeviceState *dev;
SysBusESPState *sysbus_esp;
ESPState *esp;
SysBusDevice *sysbus;
- BusState *adb_bus;
NubusBus *nubus;
DriveInfo *dinfo;
NICInfo *nd;
@@ -354,12 +354,13 @@ static void q800_machine_init(MachineState *machine)
qdev_connect_gpio_out(DEVICE(&m->via1), 0,
qdev_get_gpio_in_named(DEVICE(&m->glue),
"auxmode", 0));
-
- adb_bus = qdev_get_child_bus(DEVICE(&m->via1), "adb.0");
- dev = qdev_new(TYPE_ADB_KEYBOARD);
- qdev_realize_and_unref(dev, adb_bus, &error_fatal);
- dev = qdev_new(TYPE_ADB_MOUSE);
- qdev_realize_and_unref(dev, adb_bus, &error_fatal);
+ if (has_defaults) {
+ BusState *adb_bus = qdev_get_child_bus(DEVICE(&m->via1), "adb.0");
+ dev = qdev_new(TYPE_ADB_KEYBOARD);
+ qdev_realize_and_unref(dev, adb_bus, &error_fatal);
+ dev = qdev_new(TYPE_ADB_MOUSE);
+ qdev_realize_and_unref(dev, adb_bus, &error_fatal);
+ }
/* VIA 2 */
object_initialize_child(OBJECT(machine), "via2", &m->via2,
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 5966069baa..6d0e22e73a 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -387,6 +387,7 @@ struct MachineState {
bool mem_merge;
bool usb;
bool usb_disabled;
+ bool has_defaults;
char *firmware;
bool iommu;
bool suppress_vmdesc;
diff --git a/system/vl.c b/system/vl.c
index e83b3b2608..e4f330f49b 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -2122,7 +2122,7 @@ static void qemu_create_machine(QDict *qdict)
object_property_add_child(container_get(OBJECT(current_machine),
"/unattached"),
"sysbus", OBJECT(sysbus_get_default()));
-
+ current_machine->has_defaults = defaults_enabled();
if (machine_class->minimum_page_bits) {
if (!set_preferred_target_page_bits(machine_class->minimum_page_bits)) {
/* This would be a board error: specifying a minimum smaller than
--
2.45.2
reply other threads:[~2024-10-28 22:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20241028221814.329577-2-peads@users.noreply.github.com \
--to=patrick.eads@gmail.com \
--cc=eduardo@habkost.net \
--cc=laurent@vivier.eu \
--cc=marcel.apfelbaum@gmail.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=wangyanan55@huawei.com \
--cc=zhao1.liu@intel.com \
/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).