Skip to contentSkip to conversation

hw/i386: Add the possibility to disable the 'isapc' machine

PATCH In review Thomas Huth 3 participants 4 messages Jan 7, 2022 – Jan 13, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/i386: Add the possibility to disable the 'isapc' machine

We already have a CONFIG_ISAPC switch - but we're not using it yet. Add some "#ifdefs" to make it possible to disable this machine now.

---
 hw/i386/pc_piix.c        | 5 ++++-
 tests/qtest/cdrom-test.c | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)
hw/i386/pc_piix.c +4 -1
index 1999190276..5147e1ee74 100644
@@ -357,10 +357,12 @@ static void pc_compat_1_4_fn(MachineState *machine)
     pc_compat_1_5_fn(machine);
 }
 
+#ifdef CONFIG_ISAPC
 static void pc_init_isa(MachineState *machine)
 {
     pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE);
 }
+#endif
 
 #ifdef CONFIG_XEN
 static void pc_xen_hvm_init_pci(MachineState *machine)
@@ -916,6 +918,7 @@ void igd_passthrough_isa_bridge_create(PCIBus *bus, uint16_t gpu_dev_id)
     pci_config_set_revision(bridge_dev->config, pch_rev_id);
 }
 
+#ifdef CONFIG_ISAPC
 static void isapc_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
@@ -935,7 +938,7 @@ static void isapc_machine_options(MachineClass *m)
 
 DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
                   isapc_machine_options);
-
+#endif
 
 #ifdef CONFIG_XEN
 static void xenfv_4_2_machine_options(MachineClass *m)
tests/qtest/cdrom-test.c +1 -1
index cfca24fa94..fdd889a487 100644
@@ -138,7 +138,7 @@ static void add_x86_tests(void)
      * Unstable CI test under load
      * See https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg05509.html
      */
-    if (g_test_slow()) {
+    if (g_test_slow() && qtest_has_machine("isapc")) {
         qtest_add_data_func("cdrom/boot/isapc", "-M isapc "
                             "-drive if=ide,media=cdrom,file=", test_cdboot);
     }
Signature · 1 line
2.27.0
Acked-by on v1 1/1
#1 lore raw
Quoted 48 lines · Thomas Huth

We already have a CONFIG_ISAPC switch - but we're not using it yet. Add some "#ifdefs" to make it possible to disable this machine now.

---
  hw/i386/pc_piix.c        | 5 ++++-
  tests/qtest/cdrom-test.c | 2 +-
  2 files changed, 5 insertions(+), 2 deletions(-)
hw/i386/pc_piix.c +4 -1
index 1999190276..5147e1ee74 100644
@@ -357,10 +357,12 @@ static void pc_compat_1_4_fn(MachineState *machine)
      pc_compat_1_5_fn(machine);
  }
 
+#ifdef CONFIG_ISAPC
  static void pc_init_isa(MachineState *machine)
  {
      pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE);
  }
+#endif
 
  #ifdef CONFIG_XEN
  static void pc_xen_hvm_init_pci(MachineState *machine)
@@ -916,6 +918,7 @@ void igd_passthrough_isa_bridge_create(PCIBus *bus, uint16_t gpu_dev_id)
      pci_config_set_revision(bridge_dev->config, pch_rev_id);
  }
 
+#ifdef CONFIG_ISAPC
  static void isapc_machine_options(MachineClass *m)
  {
      PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
@@ -935,7 +938,7 @@ static void isapc_machine_options(MachineClass *m)
 
  DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
                    isapc_machine_options);
-
+#endif
 
  #ifdef CONFIG_XEN
  static void xenfv_4_2_machine_options(MachineClass *m)
tests/qtest/cdrom-test.c +0 -0
index cfca24fa94..fdd889a487 100644

tests/qtest/cdrom-test.c static void add_x86_tests(void) · line 144

Quoted 8 lines
tests/qtest/cdrom-test.c +1 -1
@@ -138,7 +138,7 @@ static void add_x86_tests(void)
       * Unstable CI test under load
       * See https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg05509.html
       */
-    if (g_test_slow()) {
+    if (g_test_slow() && qtest_has_machine("isapc")) {
          qtest_add_data_func("cdrom/boot/isapc", "-M isapc "
                              "-drive if=ide,media=cdrom,file=", test_cdboot);
      }
Reviewed-by on v1 1/1
#2 lore raw
In reply to Thomas Huth
Quoted 35 lines · Thomas Huth

We already have a CONFIG_ISAPC switch - but we're not using it yet. Add some "#ifdefs" to make it possible to disable this machine now.

---
 hw/i386/pc_piix.c        | 5 ++++-
 tests/qtest/cdrom-test.c | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)
hw/i386/pc_piix.c +3 -0
index 1999190276..5147e1ee74 100644
@@ -357,10 +357,12 @@ static void pc_compat_1_4_fn(MachineState *machine)
     pc_compat_1_5_fn(machine);
 }
 
+#ifdef CONFIG_ISAPC
 static void pc_init_isa(MachineState *machine)
 {
     pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE);
 }
+#endif
 
 #ifdef CONFIG_XEN
 static void pc_xen_hvm_init_pci(MachineState *machine)
@@ -916,6 +918,7 @@ void igd_passthrough_isa_bridge_create(PCIBus *bus, uint16_t gpu_dev_id)
     pci_config_set_revision(bridge_dev->config, pch_rev_id);
 }
 
+#ifdef CONFIG_ISAPC
 static void isapc_machine_options(MachineClass *m)
 {
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);

hw/i386/pc_piix.c static void isapc_machine_options(MachineClass *m) · line 941

Quoted 5 lines
hw/i386/pc_piix.c +1 -1
@@ -935,7 +938,7 @@ static void isapc_machine_options(MachineClass *m)
 
 DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
                   isapc_machine_options);
-
+#endif

Wouldn't it be cleaner to extract the isapc machine to a new C unit (after renaming/declaring pc_init1 public)? Anyway this is what is done for Xen, so why not...

#3 lore raw
Quoted 37 lines · Philippe Mathieu-Daudé
Quoted 36 lines · Thomas Huth

We already have a CONFIG_ISAPC switch - but we're not using it yet. Add some "#ifdefs" to make it possible to disable this machine now.

---
  hw/i386/pc_piix.c        | 5 ++++-
  tests/qtest/cdrom-test.c | 2 +-
  2 files changed, 5 insertions(+), 2 deletions(-)
hw/i386/pc_piix.c +3 -0
index 1999190276..5147e1ee74 100644
@@ -357,10 +357,12 @@ static void pc_compat_1_4_fn(MachineState *machine)
      pc_compat_1_5_fn(machine);
  }
 
+#ifdef CONFIG_ISAPC
  static void pc_init_isa(MachineState *machine)
  {
      pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE);
  }
+#endif
 
  #ifdef CONFIG_XEN
  static void pc_xen_hvm_init_pci(MachineState *machine)
@@ -916,6 +918,7 @@ void igd_passthrough_isa_bridge_create(PCIBus *bus, uint16_t gpu_dev_id)
      pci_config_set_revision(bridge_dev->config, pch_rev_id);
  }
 
+#ifdef CONFIG_ISAPC
  static void isapc_machine_options(MachineClass *m)
  {
      PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
@@ -935,7 +938,7 @@ static void isapc_machine_options(MachineClass *m)
 
Quoted 7 lines

hw/i386/pc_piix.c static void isapc_machine_options(MachineClass *m) · line 941

Quoted 4 lines
hw/i386/pc_piix.c +1 -1
  DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
                    isapc_machine_options);
-
+#endif

Wouldn't it be cleaner to extract the isapc machine to a new C unit (after renaming/declaring pc_init1 public)?

That would be cleaner, of course, but that would also mean a major refactoring: We could rearrange the code so that it is possible to compile a binary that has isapc, but not i440fx... but that likely means a complete rework of pc_piix.c so that the code that is common between i440fx and isapc needs to be moved into a separate file, too. And that's likely not worth the effort, I guess, since people rather want to compile without isapc than compiling without i440fx, I think. So let's go with this low-hanging fruit here for now, and keep the possible clean-up in mind for later.

Quoted 1 line

Thanks!

Thomas