Skip to contentSkip to conversation

Introduce common QEMU_COMPAT_* macros

PATCH Superseded Eduardo Habkost 6 participants 25 messages Jun 24, 2014 – Jun 25, 2014

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Introduce common QEMU_COMPAT_* macros

This series is an attempt to make the compat_props lists from the PC code reusable by other machine-types. All the compat bits that are on those lists are not tied to a specific machine-type, but instead to the device code that was present on a given QEMU version.

The last patch is a proposal to simply eliminate the PC-specific compat props macros, because we don't really need them today. All compat properties we have can be on global QEMU-version-specific lists, because PC-specific properties are not going to affect other machine-types anyway.

Eduardo Habkost (4):
q35: Move q35-specific compat macros to pc_q35.c
pc: Eliminate nesting of common PC_COMPAT_* macros
machine: Introduce QEMU_COMPAT_* macros [RFC] Eliminate PC-specific compat_props

 hw/i386/pc_piix.c    |  31 +++++--
 hw/i386/pc_q35.c     |  19 +++++
 include/hw/boards.h  | 207 +++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 224 ---------------------------------------------------
 4 files changed, 251 insertions(+), 230 deletions(-)
Signature · 1 line
1.9.3
#1 lore raw

PATCH 1/4 q35: Move q35-specific compat macros to pc_q35.c

They are not used anywhere else, to it is simpler to just keep them closer to the places where they are used.

---
 hw/i386/pc_q35.c     | 37 +++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 37 -------------------------------------
 2 files changed, 37 insertions(+), 37 deletions(-)
hw/i386/pc_q35.c +37 -0
index 155db99..c640e7b 100644
@@ -354,6 +354,22 @@ static QEMUMachine pc_q35_machine_v2_1 = {
     .init = pc_q35_init,
 };
 
+#define PC_Q35_COMPAT_2_0 \
+        PC_COMPAT_2_0, \
+        {\
+            .driver   = "ICH9-LPC",\
+            .property = "memory-hotplug-support",\
+            .value    = "off",\
+        },{\
+            .driver   = "xio3130-downstream",\
+            .property = COMPAT_PROP_PCP,\
+            .value    = "off",\
+        },{\
+            .driver   = "ioh3420",\
+            .property = COMPAT_PROP_PCP,\
+            .value    = "off",\
+        }
+
 #define PC_Q35_2_0_MACHINE_OPTIONS PC_Q35_2_1_MACHINE_OPTIONS
 
 static QEMUMachine pc_q35_machine_v2_0 = {
@@ -366,6 +382,15 @@ static QEMUMachine pc_q35_machine_v2_0 = {
     },
 };
 
+#define PC_Q35_COMPAT_1_7 \
+        PC_COMPAT_1_7, \
+        PC_Q35_COMPAT_2_0, \
+        {\
+            .driver   = "hpet",\
+            .property = HPET_INTCAP,\
+            .value    = stringify(4),\
+        }
+
 #define PC_Q35_1_7_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
 
 static QEMUMachine pc_q35_machine_v1_7 = {
@@ -378,6 +403,10 @@ static QEMUMachine pc_q35_machine_v1_7 = {
     },
 };
 
+#define PC_Q35_COMPAT_1_6 \
+        PC_COMPAT_1_6, \
+        PC_Q35_COMPAT_1_7
+
 #define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
 
 static QEMUMachine pc_q35_machine_v1_6 = {
@@ -390,6 +419,10 @@ static QEMUMachine pc_q35_machine_v1_6 = {
     },
 };
 
+#define PC_Q35_COMPAT_1_5 \
+        PC_COMPAT_1_5, \
+        PC_Q35_COMPAT_1_6
+
 static QEMUMachine pc_q35_machine_v1_5 = {
     PC_Q35_1_6_MACHINE_OPTIONS,
     .name = "pc-q35-1.5",
@@ -400,6 +433,10 @@ static QEMUMachine pc_q35_machine_v1_5 = {
     },
 };
 
+#define PC_Q35_COMPAT_1_4 \
+        PC_COMPAT_1_4, \
+        PC_Q35_COMPAT_1_5
+
 #define PC_Q35_1_4_MACHINE_OPTIONS \
     PC_Q35_1_6_MACHINE_OPTIONS, \
     .hot_add_cpu = NULL
include/hw/i386/pc.h +0 -37
index 486e98f..fb7d68d 100644
@@ -294,43 +294,6 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
 int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
-#define PC_Q35_COMPAT_2_0 \
-        PC_COMPAT_2_0, \
-        {\
-            .driver   = "ICH9-LPC",\
-            .property = "memory-hotplug-support",\
-            .value    = "off",\
-        },{\
-            .driver   = "xio3130-downstream",\
-            .property = COMPAT_PROP_PCP,\
-            .value    = "off",\
-        },{\
-            .driver   = "ioh3420",\
-            .property = COMPAT_PROP_PCP,\
-            .value    = "off",\
-        }
- 
-#define PC_Q35_COMPAT_1_7 \
-        PC_COMPAT_1_7, \
-        PC_Q35_COMPAT_2_0, \
-        {\
-            .driver   = "hpet",\
-            .property = HPET_INTCAP,\
-            .value    = stringify(4),\
-        }
-
-#define PC_Q35_COMPAT_1_6 \
-        PC_COMPAT_1_6, \
-        PC_Q35_COMPAT_1_7
-
-#define PC_Q35_COMPAT_1_5 \
-        PC_COMPAT_1_5, \
-        PC_Q35_COMPAT_1_6
-
-#define PC_Q35_COMPAT_1_4 \
-        PC_COMPAT_1_4, \
-        PC_Q35_COMPAT_1_5
-
 #define PC_COMPAT_2_0 \
         {\
             .driver   = "virtio-scsi-pci",\
Signature · 1 line
1.9.3
Reviewed-by on v1 1/4
#2 lore raw

Re: [Qemu-devel] [PATCH 1/4] q35: Move q35-specific compat macros to pc_q35.c

Quoted 2 lines · Eduardo Habkost

They are not used anywhere else, to it is simpler to just keep them closer to the places where they are used.

Isolation is always welcomed.

Quoted 131 lines
---
 hw/i386/pc_q35.c     | 37 +++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 37 -------------------------------------
 2 files changed, 37 insertions(+), 37 deletions(-)
hw/i386/pc_q35.c +37 -0
index 155db99..c640e7b 100644
@@ -354,6 +354,22 @@ static QEMUMachine pc_q35_machine_v2_1 = {
     .init = pc_q35_init,
 };
 
+#define PC_Q35_COMPAT_2_0 \
+        PC_COMPAT_2_0, \
+        {\
+            .driver   = "ICH9-LPC",\
+            .property = "memory-hotplug-support",\
+            .value    = "off",\
+        },{\
+            .driver   = "xio3130-downstream",\
+            .property = COMPAT_PROP_PCP,\
+            .value    = "off",\
+        },{\
+            .driver   = "ioh3420",\
+            .property = COMPAT_PROP_PCP,\
+            .value    = "off",\
+        }
+
 #define PC_Q35_2_0_MACHINE_OPTIONS PC_Q35_2_1_MACHINE_OPTIONS
 
 static QEMUMachine pc_q35_machine_v2_0 = {
@@ -366,6 +382,15 @@ static QEMUMachine pc_q35_machine_v2_0 = {
     },
 };
 
+#define PC_Q35_COMPAT_1_7 \
+        PC_COMPAT_1_7, \
+        PC_Q35_COMPAT_2_0, \
+        {\
+            .driver   = "hpet",\
+            .property = HPET_INTCAP,\
+            .value    = stringify(4),\
+        }
+
 #define PC_Q35_1_7_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
 
 static QEMUMachine pc_q35_machine_v1_7 = {
@@ -378,6 +403,10 @@ static QEMUMachine pc_q35_machine_v1_7 = {
     },
 };
 
+#define PC_Q35_COMPAT_1_6 \
+        PC_COMPAT_1_6, \
+        PC_Q35_COMPAT_1_7
+
 #define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
 
 static QEMUMachine pc_q35_machine_v1_6 = {
@@ -390,6 +419,10 @@ static QEMUMachine pc_q35_machine_v1_6 = {
     },
 };
 
+#define PC_Q35_COMPAT_1_5 \
+        PC_COMPAT_1_5, \
+        PC_Q35_COMPAT_1_6
+
 static QEMUMachine pc_q35_machine_v1_5 = {
     PC_Q35_1_6_MACHINE_OPTIONS,
     .name = "pc-q35-1.5",
@@ -400,6 +433,10 @@ static QEMUMachine pc_q35_machine_v1_5 = {
     },
 };
 
+#define PC_Q35_COMPAT_1_4 \
+        PC_COMPAT_1_4, \
+        PC_Q35_COMPAT_1_5
+
 #define PC_Q35_1_4_MACHINE_OPTIONS \
     PC_Q35_1_6_MACHINE_OPTIONS, \
     .hot_add_cpu = NULL
include/hw/i386/pc.h +0 -37
index 486e98f..fb7d68d 100644
@@ -294,43 +294,6 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
 int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
-#define PC_Q35_COMPAT_2_0 \
-        PC_COMPAT_2_0, \
-        {\
-            .driver   = "ICH9-LPC",\
-            .property = "memory-hotplug-support",\
-            .value    = "off",\
-        },{\
-            .driver   = "xio3130-downstream",\
-            .property = COMPAT_PROP_PCP,\
-            .value    = "off",\
-        },{\
-            .driver   = "ioh3420",\
-            .property = COMPAT_PROP_PCP,\
-            .value    = "off",\
-        }
- 
-#define PC_Q35_COMPAT_1_7 \
-        PC_COMPAT_1_7, \
-        PC_Q35_COMPAT_2_0, \
-        {\
-            .driver   = "hpet",\
-            .property = HPET_INTCAP,\
-            .value    = stringify(4),\
-        }
-
-#define PC_Q35_COMPAT_1_6 \
-        PC_COMPAT_1_6, \
-        PC_Q35_COMPAT_1_7
-
-#define PC_Q35_COMPAT_1_5 \
-        PC_COMPAT_1_5, \
-        PC_Q35_COMPAT_1_6
-
-#define PC_Q35_COMPAT_1_4 \
-        PC_COMPAT_1_4, \
-        PC_Q35_COMPAT_1_5
-
 #define PC_COMPAT_2_0 \
         {\
             .driver   = "virtio-scsi-pci",\
#3 lore raw

PATCH 2/4 pc: Eliminate nesting of common PC_COMPAT_* macros

In reply to Eduardo Habkost

The PC_COMPAT_* macros include each other, and the PC_Q35_COMPAT_* macros _also_ included each other. That caused lots of properties to appear multiple times on PC_Q35_COMPAT_*.

For example, PC_Q35_COMPAT_1_4 expanded to the following:

PC_Q35_COMPAT_1_4:

 |-> PC_COMPAT_1_4:
 |   |-> PC_COMPAT_1_5:
 |   |   |-> PC_COMPAT_1_6:
 |   |   |   |-> PC_COMPAT_1_7:
 |   |   |   |   |-> PC_COMPAT_2_0:
 |   |   |   |   |   `-> [pc-2.0 vars]
 |   |   |   |   `-> [pc-1.7 vars]
 |   |   |   `-> [pc-1.6 vars]
 |   |   `-> [pc-1.5 vars]
 |   `-> [pc-1.4 vars]
 |-> PC_Q35_COMPAT_1_5:
 |   |-> PC_COMPAT_1_5:
 |   |   |-> PC_COMPAT_1_6:
 |   |   |   |-> PC_COMPAT_1_7:
 |   |   |   |   |-> PC_COMPAT_2_0:
 |   |   |   |   |   `-> [pc-2.0 vars]
 |   |   |   |   `-> [pc-1.7 vars]
 |   |   |   `-> [pc-1.6 vars]
 |   |   `-> [pc-1.5 vars]
 |   |-> PC_Q35_COMPAT_1_6:
 |   |   |-> PC_COMPAT_1_6:
 |   |   |   |-> PC_COMPAT_1_7:
 |   |   |   |   |-> PC_COMPAT_2_0:
 |   |   |   |   |   `-> [pc-2.0 vars]
 |   |   |   |   `-> [pc-1.7 vars]
 |   |   |   `-> [pc-1.6 vars]
 |   |   |-> PC_Q35_COMPAT_1_7:
 |   |   |   |-> PC_COMPAT_1_7:
 |   |   |   |   |-> PC_COMPAT_2_0:
 |   |   |   |   |   `-> [pc-2.0 vars]
 |   |   |   |   `-> [pc-1.7 vars]
 |   |   |   |-> PC_Q35_COMPAT_2_0:
 |   |   |   |   |-> PC_COMPAT_2_0:
 |   |   |   |   |   `-> [pc-2.0 vars]
 |   |   |   |   `-> [pc-q35-2.0 vars]
 |   |   |   `-> [pc-q35-1.7 vars]
 |   |   `-> [pc-q35-1.6 vars]
 |   `-> [pc-q35-1.5 vars]

`-> [pc-q35-1.4 vars]

In other words, the pc-2.0 variables from PC_COMPAT_2_0 appeared 5 times inside PC_Q35_COMPAT_1_4.

This makes the following changes:

* Reusable PC_COMPAT_* macros on pc.h have NO nesting;
* Instead of using PC_COMPAT_* directly, now pc_piix.c has its own PC_I440FX_COMPAT_* macros.
* Machine-type-specific PC_*_COMPAT_* macros on .c files are nested, and reuse the common PC_COMPAT_* macros.

Thus the expansion of PC_Q35_COMPAT_1_4 becomes:

PC_Q35_COMPAT_1_4:

 |-> PC_Q35_COMPAT_1_5:
 |   |-> PC_Q35_COMPAT_1_6:
 |   |   |-> PC_Q35_COMPAT_1_7:
 |   |   |   |-> PC_Q35_COMPAT_2_0:
 |   |   |   |   |-> PC_COMPAT_2_0:
 |   |   |   |   |   `-> [pc-2.0 vars]
 |   |   |   |   `-> [pc-q35-2.0 vars]
 |   |   |   |-> PC_COMPAT_1_7:
 |   |   |   |   `-> [pc-1.7 vars]
 |   |   |   `-> [pc-q35-1.7 vars]
 |   |   |-> PC_COMPAT_1_6:
 |   |   |   `-> [pc-1.6 vars]
 |   |   `-> [pc-q35-1.6 vars]
 |   |-> PC_COMPAT_1_5:
 |   |   `-> [pc-1.5 vars]
 |   `-> [pc-q35-1.5 vars]
 |-> PC_COMPAT_1_4:
 |   `-> [pc-1.4 vars]

`-> [pc-q35-1.4 vars]

---
 hw/i386/pc_piix.c    | 31 +++++++++++++++++++++++++------
 hw/i386/pc_q35.c     | 14 +++++++-------
 include/hw/i386/pc.h |  4 ----
 3 files changed, 32 insertions(+), 17 deletions(-)
hw/i386/pc_piix.c +25 -6
index 47546b7..d8010d16 100644
@@ -441,6 +441,9 @@ static QEMUMachine pc_i440fx_machine_v2_1 = {
     .is_default = 1,
 };
 
+#define PC_I440FX_COMPAT_2_0 \
+    PC_COMPAT_2_0
+
 #define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS
 
 static QEMUMachine pc_i440fx_machine_v2_0 = {
@@ -448,11 +451,15 @@ static QEMUMachine pc_i440fx_machine_v2_0 = {
     .name = "pc-i440fx-2.0",
     .init = pc_init_pci_2_0,
     .compat_props = (GlobalProperty[]) {
-        PC_COMPAT_2_0,
+        PC_I440FX_COMPAT_2_0,
         { /* end of list */ }
     },
 };
 
+#define PC_I440FX_COMPAT_1_7 \
+    PC_I440FX_COMPAT_2_0, \
+    PC_COMPAT_1_7
+
 #define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
 
 static QEMUMachine pc_i440fx_machine_v1_7 = {
@@ -460,11 +467,15 @@ static QEMUMachine pc_i440fx_machine_v1_7 = {
     .name = "pc-i440fx-1.7",
     .init = pc_init_pci_1_7,
     .compat_props = (GlobalProperty[]) {
-        PC_COMPAT_1_7,
+        PC_I440FX_COMPAT_1_7,
         { /* end of list */ }
     },
 };
 
+#define PC_I440FX_COMPAT_1_6 \
+    PC_I440FX_COMPAT_1_7, \
+    PC_COMPAT_1_6
+
 #define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
 
 static QEMUMachine pc_i440fx_machine_v1_6 = {
@@ -472,21 +483,29 @@ static QEMUMachine pc_i440fx_machine_v1_6 = {
     .name = "pc-i440fx-1.6",
     .init = pc_init_pci_1_6,
     .compat_props = (GlobalProperty[]) {
-        PC_COMPAT_1_6,
+        PC_I440FX_COMPAT_1_6,
         { /* end of list */ }
     },
 };
 
+#define PC_I440FX_COMPAT_1_5 \
+    PC_I440FX_COMPAT_1_6, \
+    PC_COMPAT_1_5
+
 static QEMUMachine pc_i440fx_machine_v1_5 = {
     PC_I440FX_1_6_MACHINE_OPTIONS,
     .name = "pc-i440fx-1.5",
     .init = pc_init_pci_1_5,
     .compat_props = (GlobalProperty[]) {
-        PC_COMPAT_1_5,
+        PC_I440FX_COMPAT_1_5,
         { /* end of list */ }
     },
 };
 
+#define PC_I440FX_COMPAT_1_4 \
+    PC_I440FX_COMPAT_1_5, \
+    PC_COMPAT_1_4
+
 #define PC_I440FX_1_4_MACHINE_OPTIONS \
     PC_I440FX_1_6_MACHINE_OPTIONS, \
     .hot_add_cpu = NULL
@@ -496,13 +515,13 @@ static QEMUMachine pc_i440fx_machine_v1_4 = {
     .name = "pc-i440fx-1.4",
     .init = pc_init_pci_1_4,
     .compat_props = (GlobalProperty[]) {
-        PC_COMPAT_1_4,
+        PC_I440FX_COMPAT_1_4,
         { /* end of list */ }
     },
 };
 
 #define PC_COMPAT_1_3 \
-	PC_COMPAT_1_4, \
+	PC_I440FX_COMPAT_1_4, \
         {\
             .driver   = "usb-tablet",\
             .property = "usb_version",\
hw/i386/pc_q35.c +7 -7
index c640e7b..57eecc3 100644
@@ -383,8 +383,8 @@ static QEMUMachine pc_q35_machine_v2_0 = {
 };
 
 #define PC_Q35_COMPAT_1_7 \
-        PC_COMPAT_1_7, \
         PC_Q35_COMPAT_2_0, \
+        PC_COMPAT_1_7, \
         {\
             .driver   = "hpet",\
             .property = HPET_INTCAP,\
@@ -404,8 +404,8 @@ static QEMUMachine pc_q35_machine_v1_7 = {
 };
 
 #define PC_Q35_COMPAT_1_6 \
-        PC_COMPAT_1_6, \
-        PC_Q35_COMPAT_1_7
+        PC_Q35_COMPAT_1_7, \
+        PC_COMPAT_1_6
 
 #define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
 
@@ -420,8 +420,8 @@ static QEMUMachine pc_q35_machine_v1_6 = {
 };
 
 #define PC_Q35_COMPAT_1_5 \
-        PC_COMPAT_1_5, \
-        PC_Q35_COMPAT_1_6
+        PC_Q35_COMPAT_1_6, \
+        PC_COMPAT_1_5
 
 static QEMUMachine pc_q35_machine_v1_5 = {
     PC_Q35_1_6_MACHINE_OPTIONS,
@@ -434,8 +434,8 @@ static QEMUMachine pc_q35_machine_v1_5 = {
 };
 
 #define PC_Q35_COMPAT_1_4 \
-        PC_COMPAT_1_4, \
-        PC_Q35_COMPAT_1_5
+        PC_Q35_COMPAT_1_5, \
+        PC_COMPAT_1_4
 
 #define PC_Q35_1_4_MACHINE_OPTIONS \
     PC_Q35_1_6_MACHINE_OPTIONS, \
include/hw/i386/pc.h +0 -4
index fb7d68d..d988b80 100644
@@ -336,7 +336,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_7 \
-        PC_COMPAT_2_0, \
         {\
             .driver   = TYPE_USB_DEVICE,\
             .property = "msos-desc",\
@@ -349,7 +348,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_6 \
-        PC_COMPAT_1_7, \
         {\
             .driver   = "e1000",\
             .property = "mitigation",\
@@ -373,7 +371,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_5 \
-        PC_COMPAT_1_6, \
         {\
             .driver   = "Conroe-" TYPE_X86_CPU,\
             .property = "model",\
@@ -417,7 +414,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_4 \
-        PC_COMPAT_1_5, \
         {\
             .driver   = "scsi-hd",\
             .property = "discard_granularity",\
Signature · 1 line
1.9.3
#4 lore raw

Re: [Qemu-devel] [PATCH 2/4] pc: Eliminate nesting of common PC_COMPAT_* macros

Quoted 79 lines · Eduardo Habkost

The PC_COMPAT_* macros include each other, and the PC_Q35_COMPAT_* macros _also_ included each other. That caused lots of properties to appear multiple times on PC_Q35_COMPAT_*.

For example, PC_Q35_COMPAT_1_4 expanded to the following:

PC_Q35_COMPAT_1_4:

 |-> PC_COMPAT_1_4:
 |   |-> PC_COMPAT_1_5:
 |   |   |-> PC_COMPAT_1_6:
 |   |   |   |-> PC_COMPAT_1_7:
 |   |   |   |   |-> PC_COMPAT_2_0:
 |   |   |   |   |   `-> [pc-2.0 vars]
 |   |   |   |   `-> [pc-1.7 vars]
 |   |   |   `-> [pc-1.6 vars]
 |   |   `-> [pc-1.5 vars]
 |   `-> [pc-1.4 vars]
 |-> PC_Q35_COMPAT_1_5:
 |   |-> PC_COMPAT_1_5:
 |   |   |-> PC_COMPAT_1_6:
 |   |   |   |-> PC_COMPAT_1_7:
 |   |   |   |   |-> PC_COMPAT_2_0:
 |   |   |   |   |   `-> [pc-2.0 vars]
 |   |   |   |   `-> [pc-1.7 vars]
 |   |   |   `-> [pc-1.6 vars]
 |   |   `-> [pc-1.5 vars]
 |   |-> PC_Q35_COMPAT_1_6:
 |   |   |-> PC_COMPAT_1_6:
 |   |   |   |-> PC_COMPAT_1_7:
 |   |   |   |   |-> PC_COMPAT_2_0:
 |   |   |   |   |   `-> [pc-2.0 vars]
 |   |   |   |   `-> [pc-1.7 vars]
 |   |   |   `-> [pc-1.6 vars]
 |   |   |-> PC_Q35_COMPAT_1_7:
 |   |   |   |-> PC_COMPAT_1_7:
 |   |   |   |   |-> PC_COMPAT_2_0:
 |   |   |   |   |   `-> [pc-2.0 vars]
 |   |   |   |   `-> [pc-1.7 vars]
 |   |   |   |-> PC_Q35_COMPAT_2_0:
 |   |   |   |   |-> PC_COMPAT_2_0:
 |   |   |   |   |   `-> [pc-2.0 vars]
 |   |   |   |   `-> [pc-q35-2.0 vars]
 |   |   |   `-> [pc-q35-1.7 vars]
 |   |   `-> [pc-q35-1.6 vars]
 |   `-> [pc-q35-1.5 vars]

`-> [pc-q35-1.4 vars]

In other words, the pc-2.0 variables from PC_COMPAT_2_0 appeared 5 times inside PC_Q35_COMPAT_1_4.

This makes the following changes:

* Reusable PC_COMPAT_* macros on pc.h have NO nesting;
* Instead of using PC_COMPAT_* directly, now pc_piix.c has its own PC_I440FX_COMPAT_* macros.
* Machine-type-specific PC_*_COMPAT_* macros on .c files are nested, and reuse the common PC_COMPAT_* macros.

Thus the expansion of PC_Q35_COMPAT_1_4 becomes:

PC_Q35_COMPAT_1_4:

 |-> PC_Q35_COMPAT_1_5:
 |   |-> PC_Q35_COMPAT_1_6:
 |   |   |-> PC_Q35_COMPAT_1_7:
 |   |   |   |-> PC_Q35_COMPAT_2_0:
 |   |   |   |   |-> PC_COMPAT_2_0:
 |   |   |   |   |   `-> [pc-2.0 vars]
 |   |   |   |   `-> [pc-q35-2.0 vars]
 |   |   |   |-> PC_COMPAT_1_7:
 |   |   |   |   `-> [pc-1.7 vars]
 |   |   |   `-> [pc-q35-1.7 vars]
 |   |   |-> PC_COMPAT_1_6:
 |   |   |   `-> [pc-1.6 vars]
 |   |   `-> [pc-q35-1.6 vars]
 |   |-> PC_COMPAT_1_5:
 |   |   `-> [pc-1.5 vars]
 |   `-> [pc-q35-1.5 vars]
 |-> PC_COMPAT_1_4:
 |   `-> [pc-1.4 vars]
Quoted 8 lines

`-> [pc-q35-1.4 vars]

---
 hw/i386/pc_piix.c    | 31 +++++++++++++++++++++++++------
 hw/i386/pc_q35.c     | 14 +++++++-------
 include/hw/i386/pc.h |  4 ----
 3 files changed, 32 insertions(+), 17 deletions(-)

More boiler-plate to add with each new machine, yeh. How about this instead:

#define PC_Q35_COMPAT_2_0 \

-        PC_COMPAT_2_0, \
         {\
             .driver   = "ICH9-LPC",\
             .property = "memory-hotplug-support",\
             .value    = "off",\
         },{\
             .driver   = "xio3130-downstream",\
             .property = COMPAT_PROP_PCP,\
             .value    = "off",\
         },{\
             .driver   = "ioh3420",\                                                                                             
             .property = COMPAT_PROP_PCP,\
             .value    = "off",\
         }
 static QEMUMachine pc_q35_machine_v2_0 = {
     PC_Q35_2_0_MACHINE_OPTIONS,
     .name = "pc-q35-2.0",
     .init = pc_q35_init_2_0,
     .compat_props = (GlobalProperty[]) {
+        PC_COMPAT_2_0,
         PC_Q35_COMPAT_2_0,
         { /* end of list */ }
     },

};

Quoted 182 lines
hw/i386/pc_piix.c +25 -6
index 47546b7..d8010d16 100644
@@ -441,6 +441,9 @@ static QEMUMachine pc_i440fx_machine_v2_1 = {
     .is_default = 1,
 };
 
+#define PC_I440FX_COMPAT_2_0 \
+    PC_COMPAT_2_0
+
 #define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS
 
 static QEMUMachine pc_i440fx_machine_v2_0 = {
@@ -448,11 +451,15 @@ static QEMUMachine pc_i440fx_machine_v2_0 = {
     .name = "pc-i440fx-2.0",
     .init = pc_init_pci_2_0,
     .compat_props = (GlobalProperty[]) {
-        PC_COMPAT_2_0,
+        PC_I440FX_COMPAT_2_0,
         { /* end of list */ }
     },
 };
 
+#define PC_I440FX_COMPAT_1_7 \
+    PC_I440FX_COMPAT_2_0, \
+    PC_COMPAT_1_7
+
 #define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
 
 static QEMUMachine pc_i440fx_machine_v1_7 = {
@@ -460,11 +467,15 @@ static QEMUMachine pc_i440fx_machine_v1_7 = {
     .name = "pc-i440fx-1.7",
     .init = pc_init_pci_1_7,
     .compat_props = (GlobalProperty[]) {
-        PC_COMPAT_1_7,
+        PC_I440FX_COMPAT_1_7,
         { /* end of list */ }
     },
 };
 
+#define PC_I440FX_COMPAT_1_6 \
+    PC_I440FX_COMPAT_1_7, \
+    PC_COMPAT_1_6
+
 #define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
 
 static QEMUMachine pc_i440fx_machine_v1_6 = {
@@ -472,21 +483,29 @@ static QEMUMachine pc_i440fx_machine_v1_6 = {
     .name = "pc-i440fx-1.6",
     .init = pc_init_pci_1_6,
     .compat_props = (GlobalProperty[]) {
-        PC_COMPAT_1_6,
+        PC_I440FX_COMPAT_1_6,
         { /* end of list */ }
     },
 };
 
+#define PC_I440FX_COMPAT_1_5 \
+    PC_I440FX_COMPAT_1_6, \
+    PC_COMPAT_1_5
+
 static QEMUMachine pc_i440fx_machine_v1_5 = {
     PC_I440FX_1_6_MACHINE_OPTIONS,
     .name = "pc-i440fx-1.5",
     .init = pc_init_pci_1_5,
     .compat_props = (GlobalProperty[]) {
-        PC_COMPAT_1_5,
+        PC_I440FX_COMPAT_1_5,
         { /* end of list */ }
     },
 };
 
+#define PC_I440FX_COMPAT_1_4 \
+    PC_I440FX_COMPAT_1_5, \
+    PC_COMPAT_1_4
+
 #define PC_I440FX_1_4_MACHINE_OPTIONS \
     PC_I440FX_1_6_MACHINE_OPTIONS, \
     .hot_add_cpu = NULL
@@ -496,13 +515,13 @@ static QEMUMachine pc_i440fx_machine_v1_4 = {
     .name = "pc-i440fx-1.4",
     .init = pc_init_pci_1_4,
     .compat_props = (GlobalProperty[]) {
-        PC_COMPAT_1_4,
+        PC_I440FX_COMPAT_1_4,
         { /* end of list */ }
     },
 };
 
 #define PC_COMPAT_1_3 \
-	PC_COMPAT_1_4, \
+	PC_I440FX_COMPAT_1_4, \
         {\
             .driver   = "usb-tablet",\
             .property = "usb_version",\
hw/i386/pc_q35.c +7 -7
index c640e7b..57eecc3 100644
@@ -383,8 +383,8 @@ static QEMUMachine pc_q35_machine_v2_0 = {
 };
 
 #define PC_Q35_COMPAT_1_7 \
-        PC_COMPAT_1_7, \
         PC_Q35_COMPAT_2_0, \
+        PC_COMPAT_1_7, \
         {\
             .driver   = "hpet",\
             .property = HPET_INTCAP,\
@@ -404,8 +404,8 @@ static QEMUMachine pc_q35_machine_v1_7 = {
 };
 
 #define PC_Q35_COMPAT_1_6 \
-        PC_COMPAT_1_6, \
-        PC_Q35_COMPAT_1_7
+        PC_Q35_COMPAT_1_7, \
+        PC_COMPAT_1_6
 
 #define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
 
@@ -420,8 +420,8 @@ static QEMUMachine pc_q35_machine_v1_6 = {
 };
 
 #define PC_Q35_COMPAT_1_5 \
-        PC_COMPAT_1_5, \
-        PC_Q35_COMPAT_1_6
+        PC_Q35_COMPAT_1_6, \
+        PC_COMPAT_1_5
 
 static QEMUMachine pc_q35_machine_v1_5 = {
     PC_Q35_1_6_MACHINE_OPTIONS,
@@ -434,8 +434,8 @@ static QEMUMachine pc_q35_machine_v1_5 = {
 };
 
 #define PC_Q35_COMPAT_1_4 \
-        PC_COMPAT_1_4, \
-        PC_Q35_COMPAT_1_5
+        PC_Q35_COMPAT_1_5, \
+        PC_COMPAT_1_4
 
 #define PC_Q35_1_4_MACHINE_OPTIONS \
     PC_Q35_1_6_MACHINE_OPTIONS, \
include/hw/i386/pc.h +0 -4
index fb7d68d..d988b80 100644
@@ -336,7 +336,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_7 \
-        PC_COMPAT_2_0, \
         {\
             .driver   = TYPE_USB_DEVICE,\
             .property = "msos-desc",\
@@ -349,7 +348,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_6 \
-        PC_COMPAT_1_7, \
         {\
             .driver   = "e1000",\
             .property = "mitigation",\
@@ -373,7 +371,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_5 \
-        PC_COMPAT_1_6, \
         {\
             .driver   = "Conroe-" TYPE_X86_CPU,\
             .property = "model",\
@@ -417,7 +414,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_4 \
-        PC_COMPAT_1_5, \
         {\
             .driver   = "scsi-hd",\
             .property = "discard_granularity",\
Signature · 1 line
1.9.3
#5 lore raw

PATCH 3/4 machine: Introduce QEMU_COMPAT_* macros

In reply to Eduardo Habkost

The QEMU_COMPAT_* macros will contain compat properties that are not specific to PC, and may be reused by other machine-types.

PC-specific properties were left on the PC_COMPAT_* macros.

---
 include/hw/boards.h  | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 150 ++---------------------------------------------
 2 files changed, 166 insertions(+), 145 deletions(-)
include/hw/boards.h +161 -0
index 605a970..709b582 100644
@@ -134,4 +134,165 @@ struct MachineState {
     const char *cpu_model;
 };
 
+
+/* Macros for compat_props corresponding to specific QEMU versions: */
+
+#define QEMU_COMPAT_2_0 \
+    {\
+        .driver   = "virtio-scsi-pci",\
+        .property = "any_layout",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "apic",\
+        .property = "version",\
+        .value    = stringify(0x11),\
+    },\
+    {\
+        .driver   = "nec-usb-xhci",\
+        .property = "superspeed-ports-first",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "pci-serial",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-2x",\
+        .property = "prof_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-4x",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "virtio-net-pci",\
+        .property = "guest_announce",\
+        .value    = "off",\
+    }
+
+#define QEMU_COMPAT_1_7 \
+    {\
+        .driver   = TYPE_USB_DEVICE,\
+        .property = "msos-desc",\
+        .value    = "no",\
+    }
+
+#define QEMU_COMPAT_1_6 \
+    {\
+        .driver   = "e1000",\
+        .property = "mitigation",\
+        .value    = "off",\
+    },{\
+        .driver   = "qemu64-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "qemu32-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(3),\
+    }
+
+#define QEMU_COMPAT_1_5 \
+    {\
+        .driver   = "Conroe-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Conroe-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Penryn-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Penryn-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Nehalem-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Nehalem-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "any_layout",\
+        .value    = "off",\
+    },{\
+        .driver = TYPE_X86_CPU,\
+        .property = "pmu",\
+        .value = "on",\
+    }
+
+#define QEMU_COMPAT_1_4 \
+    {\
+        .driver   = "scsi-hd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "scsi-cd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "scsi-disk",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-hd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-cd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-drive",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "virtio-blk-pci",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "virtio-serial-pci",\
+        .property = "vectors",\
+        /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
+        .value    = stringify(0xFFFFFFFF),\
+    },{ \
+        .driver   = "virtio-net-pci", \
+        .property = "ctrl_guest_offloads", \
+        .value    = "off", \
+    },{\
+        .driver   = "e1000",\
+        .property = "romfile",\
+        .value    = "pxe-e1000.rom",\
+    },{\
+        .driver   = "ne2k_pci",\
+        .property = "romfile",\
+        .value    = "pxe-ne2k_pci.rom",\
+    },{\
+        .driver   = "pcnet",\
+        .property = "romfile",\
+        .value    = "pxe-pcnet.rom",\
+    },{\
+        .driver   = "rtl8139",\
+        .property = "romfile",\
+        .value    = "pxe-rtl8139.rom",\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "romfile",\
+        .value    = "pxe-virtio.rom",\
+    },{\
+        .driver   = "486-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(0),\
+    }
+
 #endif
include/hw/i386/pc.h +5 -145

183 lines not on this page · raw message

Signature · 1 line
1.9.3
#6 lore raw

Re: [Qemu-devel] [PATCH 3/4] machine: Introduce QEMU_COMPAT_* macros

Quoted 16 lines · Eduardo Habkost

The QEMU_COMPAT_* macros will contain compat properties that are not specific to PC, and may be reused by other machine-types.

PC-specific properties were left on the PC_COMPAT_* macros.

---
 include/hw/boards.h  | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 150 ++---------------------------------------------
 2 files changed, 166 insertions(+), 145 deletions(-)
include/hw/boards.h +0 -0
index 605a970..709b582 100644

include/hw/boards.h struct MachineState { · line 138

Quoted 5 lines
include/hw/boards.h +2 -0
@@ -134,4 +134,165 @@ struct MachineState {
     const char *cpu_model;
 };
 
+
+/* Macros for compat_props corresponding to specific QEMU versions: */

Only a suggestion: Maybe we can move all the compat props to a new header file, say include/hw/compat.h so we don't need to modify board.h every time we need a compat prop? board.h will remain cleaner this way.

Thanks,
Marcel

Quoted 351 lines
include/hw/boards.h +159 -0
+
+#define QEMU_COMPAT_2_0 \
+    {\
+        .driver   = "virtio-scsi-pci",\
+        .property = "any_layout",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "apic",\
+        .property = "version",\
+        .value    = stringify(0x11),\
+    },\
+    {\
+        .driver   = "nec-usb-xhci",\
+        .property = "superspeed-ports-first",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "pci-serial",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-2x",\
+        .property = "prof_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-4x",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "virtio-net-pci",\
+        .property = "guest_announce",\
+        .value    = "off",\
+    }
+
+#define QEMU_COMPAT_1_7 \
+    {\
+        .driver   = TYPE_USB_DEVICE,\
+        .property = "msos-desc",\
+        .value    = "no",\
+    }
+
+#define QEMU_COMPAT_1_6 \
+    {\
+        .driver   = "e1000",\
+        .property = "mitigation",\
+        .value    = "off",\
+    },{\
+        .driver   = "qemu64-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "qemu32-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(3),\
+    }
+
+#define QEMU_COMPAT_1_5 \
+    {\
+        .driver   = "Conroe-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Conroe-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Penryn-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Penryn-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Nehalem-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Nehalem-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "any_layout",\
+        .value    = "off",\
+    },{\
+        .driver = TYPE_X86_CPU,\
+        .property = "pmu",\
+        .value = "on",\
+    }
+
+#define QEMU_COMPAT_1_4 \
+    {\
+        .driver   = "scsi-hd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "scsi-cd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "scsi-disk",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-hd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-cd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-drive",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "virtio-blk-pci",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "virtio-serial-pci",\
+        .property = "vectors",\
+        /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
+        .value    = stringify(0xFFFFFFFF),\
+    },{ \
+        .driver   = "virtio-net-pci", \
+        .property = "ctrl_guest_offloads", \
+        .value    = "off", \
+    },{\
+        .driver   = "e1000",\
+        .property = "romfile",\
+        .value    = "pxe-e1000.rom",\
+    },{\
+        .driver   = "ne2k_pci",\
+        .property = "romfile",\
+        .value    = "pxe-ne2k_pci.rom",\
+    },{\
+        .driver   = "pcnet",\
+        .property = "romfile",\
+        .value    = "pxe-pcnet.rom",\
+    },{\
+        .driver   = "rtl8139",\
+        .property = "romfile",\
+        .value    = "pxe-rtl8139.rom",\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "romfile",\
+        .value    = "pxe-virtio.rom",\
+    },{\
+        .driver   = "486-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(0),\
+    }
+
 #endif
include/hw/i386/pc.h +5 -145
index d988b80..631afe7 100644
@@ -295,52 +295,15 @@ int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
 #define PC_COMPAT_2_0 \
+        QEMU_COMPAT_2_0,\
         {\
-            .driver   = "virtio-scsi-pci",\
-            .property = "any_layout",\
-            .value    = "off",\
-        },{\
             .driver   = "PIIX4_PM",\
             .property = "memory-hotplug-support",\
             .value    = "off",\
-        },\
-        {\
-            .driver   = "apic",\
-            .property = "version",\
-            .value    = stringify(0x11),\
-        },\
-        {\
-            .driver   = "nec-usb-xhci",\
-            .property = "superspeed-ports-first",\
-            .value    = "off",\
-        },\
-        {\
-            .driver   = "pci-serial",\
-            .property = "prog_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "pci-serial-2x",\
-            .property = "prof_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "pci-serial-4x",\
-            .property = "prog_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "virtio-net-pci",\
-            .property = "guest_announce",\
-            .value    = "off",\
         }
 
 #define PC_COMPAT_1_7 \
-        {\
-            .driver   = TYPE_USB_DEVICE,\
-            .property = "msos-desc",\
-            .value    = "no",\
-        },\
+        QEMU_COMPAT_1_7,\
         {\
             .driver   = "PIIX4_PM",\
             .property = "acpi-pci-hotplug-with-bridge-support",\
@@ -348,19 +311,8 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_6 \
+        QEMU_COMPAT_1_6,\
         {\
-            .driver   = "e1000",\
-            .property = "mitigation",\
-            .value    = "off",\
-        },{\
-            .driver   = "qemu64-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "qemu32-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(3),\
-        },{\
             .driver   = "i440FX-pcihost",\
             .property = "short_root_bus",\
             .value    = stringify(1),\
@@ -371,39 +323,8 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_5 \
+        QEMU_COMPAT_1_7,\
         {\
-            .driver   = "Conroe-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Conroe-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Penryn-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Penryn-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Nehalem-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Nehalem-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "virtio-net-pci",\
-            .property = "any_layout",\
-            .value    = "off",\
-        },{\
-            .driver = TYPE_X86_CPU,\
-            .property = "pmu",\
-            .value = "on",\
-        },{\
             .driver   = "i440FX-pcihost",\
             .property = "short_root_bus",\
             .value    = stringify(0),\
@@ -414,68 +335,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_4 \
-        {\
-            .driver   = "scsi-hd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "scsi-cd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "scsi-disk",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-hd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-cd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-drive",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-        },{\
-            .driver   = "virtio-blk-pci",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "virtio-serial-pci",\
-            .property = "vectors",\
-            /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
-            .value    = stringify(0xFFFFFFFF),\
-        },{ \
-            .driver   = "virtio-net-pci", \
-            .property = "ctrl_guest_offloads", \
-            .value    = "off", \
-        },{\
-            .driver   = "e1000",\
-            .property = "romfile",\
-            .value    = "pxe-e1000.rom",\
-        },{\
-            .driver   = "ne2k_pci",\
-            .property = "romfile",\
-            .value    = "pxe-ne2k_pci.rom",\
-        },{\
-            .driver   = "pcnet",\
-            .property = "romfile",\
-            .value    = "pxe-pcnet.rom",\
-        },{\
-            .driver   = "rtl8139",\
-            .property = "romfile",\
-            .value    = "pxe-rtl8139.rom",\
-        },{\
-            .driver   = "virtio-net-pci",\
-            .property = "romfile",\
-            .value    = "pxe-virtio.rom",\
-        },{\
-            .driver   = "486-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(0),\
-        }
+    QEMU_COMPAT_1_4
 
 #define PC_COMMON_MACHINE_OPTIONS \
     .default_boot_order = "cad"
#7 lore raw

Re: [Qemu-devel] [PATCH 3/4] machine: Introduce QEMU_COMPAT_* macros

Quoted 20 lines · On Tue, 24 Jun 2014 22:20:50 +0300 Marcel Apfelbaum <[email protected]> wrote:
Quoted 19 lines · Eduardo Habkost

The QEMU_COMPAT_* macros will contain compat properties that are not specific to PC, and may be reused by other machine-types.

PC-specific properties were left on the PC_COMPAT_* macros.

---
 include/hw/boards.h  | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 150 ++---------------------------------------------
 2 files changed, 166 insertions(+), 145 deletions(-)
include/hw/boards.h +0 -0
index 605a970..709b582 100644
@@ -134,4 +134,165 @@ struct MachineState {
     const char *cpu_model;
 };
 
Quoted 5 lines

include/hw/boards.h struct MachineState { · line 138

Quoted 2 lines
include/hw/boards.h +2 -0
+
+/* Macros for compat_props corresponding to specific QEMU versions: */

Only a suggestion: Maybe we can move all the compat props to a new header file, say include/hw/compat.h so we don't need to modify board.h every time we need a compat prop? board.h will remain cleaner this way.

these are PC specific compat props, so it should be moved into target specific pc.h instead of global header.

Quoted 357 lines

Thanks,
Marcel

Quoted 351 lines
include/hw/boards.h +159 -0
+
+#define QEMU_COMPAT_2_0 \
+    {\
+        .driver   = "virtio-scsi-pci",\
+        .property = "any_layout",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "apic",\
+        .property = "version",\
+        .value    = stringify(0x11),\
+    },\
+    {\
+        .driver   = "nec-usb-xhci",\
+        .property = "superspeed-ports-first",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "pci-serial",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-2x",\
+        .property = "prof_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-4x",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "virtio-net-pci",\
+        .property = "guest_announce",\
+        .value    = "off",\
+    }
+
+#define QEMU_COMPAT_1_7 \
+    {\
+        .driver   = TYPE_USB_DEVICE,\
+        .property = "msos-desc",\
+        .value    = "no",\
+    }
+
+#define QEMU_COMPAT_1_6 \
+    {\
+        .driver   = "e1000",\
+        .property = "mitigation",\
+        .value    = "off",\
+    },{\
+        .driver   = "qemu64-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "qemu32-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(3),\
+    }
+
+#define QEMU_COMPAT_1_5 \
+    {\
+        .driver   = "Conroe-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Conroe-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Penryn-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Penryn-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Nehalem-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Nehalem-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "any_layout",\
+        .value    = "off",\
+    },{\
+        .driver = TYPE_X86_CPU,\
+        .property = "pmu",\
+        .value = "on",\
+    }
+
+#define QEMU_COMPAT_1_4 \
+    {\
+        .driver   = "scsi-hd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "scsi-cd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "scsi-disk",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-hd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-cd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-drive",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "virtio-blk-pci",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "virtio-serial-pci",\
+        .property = "vectors",\
+        /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
+        .value    = stringify(0xFFFFFFFF),\
+    },{ \
+        .driver   = "virtio-net-pci", \
+        .property = "ctrl_guest_offloads", \
+        .value    = "off", \
+    },{\
+        .driver   = "e1000",\
+        .property = "romfile",\
+        .value    = "pxe-e1000.rom",\
+    },{\
+        .driver   = "ne2k_pci",\
+        .property = "romfile",\
+        .value    = "pxe-ne2k_pci.rom",\
+    },{\
+        .driver   = "pcnet",\
+        .property = "romfile",\
+        .value    = "pxe-pcnet.rom",\
+    },{\
+        .driver   = "rtl8139",\
+        .property = "romfile",\
+        .value    = "pxe-rtl8139.rom",\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "romfile",\
+        .value    = "pxe-virtio.rom",\
+    },{\
+        .driver   = "486-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(0),\
+    }
+
 #endif
include/hw/i386/pc.h +5 -145
index d988b80..631afe7 100644
@@ -295,52 +295,15 @@ int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
 #define PC_COMPAT_2_0 \
+        QEMU_COMPAT_2_0,\
         {\
-            .driver   = "virtio-scsi-pci",\
-            .property = "any_layout",\
-            .value    = "off",\
-        },{\
             .driver   = "PIIX4_PM",\
             .property = "memory-hotplug-support",\
             .value    = "off",\
-        },\
-        {\
-            .driver   = "apic",\
-            .property = "version",\
-            .value    = stringify(0x11),\
-        },\
-        {\
-            .driver   = "nec-usb-xhci",\
-            .property = "superspeed-ports-first",\
-            .value    = "off",\
-        },\
-        {\
-            .driver   = "pci-serial",\
-            .property = "prog_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "pci-serial-2x",\
-            .property = "prof_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "pci-serial-4x",\
-            .property = "prog_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "virtio-net-pci",\
-            .property = "guest_announce",\
-            .value    = "off",\
         }
 
 #define PC_COMPAT_1_7 \
-        {\
-            .driver   = TYPE_USB_DEVICE,\
-            .property = "msos-desc",\
-            .value    = "no",\
-        },\
+        QEMU_COMPAT_1_7,\
         {\
             .driver   = "PIIX4_PM",\
             .property = "acpi-pci-hotplug-with-bridge-support",\
@@ -348,19 +311,8 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_6 \
+        QEMU_COMPAT_1_6,\
         {\
-            .driver   = "e1000",\
-            .property = "mitigation",\
-            .value    = "off",\
-        },{\
-            .driver   = "qemu64-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "qemu32-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(3),\
-        },{\
             .driver   = "i440FX-pcihost",\
             .property = "short_root_bus",\
             .value    = stringify(1),\
@@ -371,39 +323,8 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_5 \
+        QEMU_COMPAT_1_7,\
         {\
-            .driver   = "Conroe-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Conroe-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Penryn-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Penryn-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Nehalem-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Nehalem-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "virtio-net-pci",\
-            .property = "any_layout",\
-            .value    = "off",\
-        },{\
-            .driver = TYPE_X86_CPU,\
-            .property = "pmu",\
-            .value = "on",\
-        },{\
             .driver   = "i440FX-pcihost",\
             .property = "short_root_bus",\
             .value    = stringify(0),\
@@ -414,68 +335,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_4 \
-        {\
-            .driver   = "scsi-hd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "scsi-cd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "scsi-disk",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-hd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-cd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-drive",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-        },{\
-            .driver   = "virtio-blk-pci",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "virtio-serial-pci",\
-            .property = "vectors",\
-            /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
-            .value    = stringify(0xFFFFFFFF),\
-        },{ \
-            .driver   = "virtio-net-pci", \
-            .property = "ctrl_guest_offloads", \
-            .value    = "off", \
-        },{\
-            .driver   = "e1000",\
-            .property = "romfile",\
-            .value    = "pxe-e1000.rom",\
-        },{\
-            .driver   = "ne2k_pci",\
-            .property = "romfile",\
-            .value    = "pxe-ne2k_pci.rom",\
-        },{\
-            .driver   = "pcnet",\
-            .property = "romfile",\
-            .value    = "pxe-pcnet.rom",\
-        },{\
-            .driver   = "rtl8139",\
-            .property = "romfile",\
-            .value    = "pxe-rtl8139.rom",\
-        },{\
-            .driver   = "virtio-net-pci",\
-            .property = "romfile",\
-            .value    = "pxe-virtio.rom",\
-        },{\
-            .driver   = "486-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(0),\
-        }
+    QEMU_COMPAT_1_4
 
 #define PC_COMMON_MACHINE_OPTIONS \
     .default_boot_order = "cad"
#8 lore raw

Re: [Qemu-devel] [PATCH 3/4] machine: Introduce QEMU_COMPAT_* macros

In reply to Eduardo Habkost
Quoted 36 lines · Eduardo Habkost

The QEMU_COMPAT_* macros will contain compat properties that are not specific to PC, and may be reused by other machine-types.

PC-specific properties were left on the PC_COMPAT_* macros.

---
include/hw/boards.h | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/i386/pc.h | 150 ++---------------------------------------------

2 files changed, 166 insertions(+), 145 deletions(-)
include/hw/boards.h +17 -0
index 605a970..709b582 100644
@@ -134,4 +134,165 @@ struct MachineState {
    const char *cpu_model;
 };
 
+
+/* Macros for compat_props corresponding to specific QEMU versions: */
+
+#define QEMU_COMPAT_2_0 \
+    {\
+        .driver   = "virtio-scsi-pci",\
+        .property = "any_layout",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "apic",\
+        .property = "version",\
+        .value    = stringify(0x11),\
+    },\
+    {\
+        .driver   = "nec-usb-xhci",\
+        .property = "superspeed-ports-first",\

include/hw/boards.h struct MachineState { · line 163

Quoted 10 lines
include/hw/boards.h +10 -0
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "pci-serial",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-2x",\
+        .property = "prof_if",\

Just noticed a typo now in this part which was added by me previously. This should also be "prog_if" instead of "prof_if". Can you also correct that while changing this or otherwise while merging or should I send a separate patch with just this change?

Regards,
BALATON Zoltan

Quoted 14 lines
include/hw/boards.h +14 -0
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-4x",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "virtio-net-pci",\
+        .property = "guest_announce",\
+        .value    = "off",\
+    }
+
+#define QEMU_COMPAT_1_7 \
#9 lore raw

Re: [Qemu-devel] [PATCH 3/4] machine: Introduce QEMU_COMPAT_* macros

Quoted 1 line · BALATON Zoltan

On Tue, 24 Jun 2014, Eduardo Habkost wrote:

[...]

Quoted 8 lines

include/hw/boards.h struct MachineState { · line 163

Quoted 7 lines
include/hw/boards.h +7 -0
+        .driver   = "pci-serial",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-2x",\
+        .property = "prof_if",\
Quoted 4 lines

Just noticed a typo now in this part which was added by me previously. This should also be "prog_if" instead of "prof_if". Can you also correct that while changing this or otherwise while merging or should I send a separate patch with just this change?

I just sent a separate patch for that. I prefer not to change code while moving it.

Signature · 1 line
Eduardo
#10 lore raw

Re: [Qemu-devel] [PATCH 3/4] machine: Introduce QEMU_COMPAT_* macros

In reply to Eduardo Habkost
Quoted 96 lines · Eduardo Habkost

The QEMU_COMPAT_* macros will contain compat properties that are not specific to PC, and may be reused by other machine-types.

PC-specific properties were left on the PC_COMPAT_* macros.

---
 include/hw/boards.h  | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 150 ++---------------------------------------------
 2 files changed, 166 insertions(+), 145 deletions(-)
include/hw/boards.h +77 -0
index 605a970..709b582 100644
@@ -134,4 +134,165 @@ struct MachineState {
     const char *cpu_model;
 };
 
+
+/* Macros for compat_props corresponding to specific QEMU versions: */
+
+#define QEMU_COMPAT_2_0 \
+    {\
+        .driver   = "virtio-scsi-pci",\
+        .property = "any_layout",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "apic",\
+        .property = "version",\
+        .value    = stringify(0x11),\
+    },\
+    {\
+        .driver   = "nec-usb-xhci",\
+        .property = "superspeed-ports-first",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "pci-serial",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-2x",\
+        .property = "prof_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-4x",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "virtio-net-pci",\
+        .property = "guest_announce",\
+        .value    = "off",\
+    }
+
+#define QEMU_COMPAT_1_7 \
+    {\
+        .driver   = TYPE_USB_DEVICE,\
+        .property = "msos-desc",\
+        .value    = "no",\
+    }
+
+#define QEMU_COMPAT_1_6 \
+    {\
+        .driver   = "e1000",\
+        .property = "mitigation",\
+        .value    = "off",\
+    },{\
+        .driver   = "qemu64-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "qemu32-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(3),\
+    }
+
+#define QEMU_COMPAT_1_5 \
+    {\
+        .driver   = "Conroe-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Conroe-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Penryn-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Penryn-" TYPE_X86_CPU,\

include/hw/boards.h struct MachineState { · line 223

Quoted 10 lines
include/hw/boards.h +10 -0
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Nehalem-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Nehalem-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\

Above are x86 CPUs - why have them in a common header? There's no chance any machine except PIIX&Q35 needs these.

include/hw/boards.h struct MachineState { · line 227

Quoted 3 lines
include/hw/boards.h +3 -0
+        .driver   = "virtio-net-pci",\
+        .property = "any_layout",\
+        .value    = "off",\

Here's an example.
If you are using a non x86 target, QEMU 2.0
has no way to select a machine with this
value.
So why expose it?

Quoted 264 lines
include/hw/boards.h +70 -0
+    },{\
+        .driver = TYPE_X86_CPU,\
+        .property = "pmu",\
+        .value = "on",\
+    }
+
+#define QEMU_COMPAT_1_4 \
+    {\
+        .driver   = "scsi-hd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "scsi-cd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "scsi-disk",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-hd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-cd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-drive",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "virtio-blk-pci",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "virtio-serial-pci",\
+        .property = "vectors",\
+        /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
+        .value    = stringify(0xFFFFFFFF),\
+    },{ \
+        .driver   = "virtio-net-pci", \
+        .property = "ctrl_guest_offloads", \
+        .value    = "off", \
+    },{\
+        .driver   = "e1000",\
+        .property = "romfile",\
+        .value    = "pxe-e1000.rom",\
+    },{\
+        .driver   = "ne2k_pci",\
+        .property = "romfile",\
+        .value    = "pxe-ne2k_pci.rom",\
+    },{\
+        .driver   = "pcnet",\
+        .property = "romfile",\
+        .value    = "pxe-pcnet.rom",\
+    },{\
+        .driver   = "rtl8139",\
+        .property = "romfile",\
+        .value    = "pxe-rtl8139.rom",\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "romfile",\
+        .value    = "pxe-virtio.rom",\
+    },{\
+        .driver   = "486-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(0),\
+    }
+
 #endif
include/hw/i386/pc.h +5 -145
index d988b80..631afe7 100644
@@ -295,52 +295,15 @@ int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
 #define PC_COMPAT_2_0 \
+        QEMU_COMPAT_2_0,\
         {\
-            .driver   = "virtio-scsi-pci",\
-            .property = "any_layout",\
-            .value    = "off",\
-        },{\
             .driver   = "PIIX4_PM",\
             .property = "memory-hotplug-support",\
             .value    = "off",\
-        },\
-        {\
-            .driver   = "apic",\
-            .property = "version",\
-            .value    = stringify(0x11),\
-        },\
-        {\
-            .driver   = "nec-usb-xhci",\
-            .property = "superspeed-ports-first",\
-            .value    = "off",\
-        },\
-        {\
-            .driver   = "pci-serial",\
-            .property = "prog_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "pci-serial-2x",\
-            .property = "prof_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "pci-serial-4x",\
-            .property = "prog_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "virtio-net-pci",\
-            .property = "guest_announce",\
-            .value    = "off",\
         }
 
 #define PC_COMPAT_1_7 \
-        {\
-            .driver   = TYPE_USB_DEVICE,\
-            .property = "msos-desc",\
-            .value    = "no",\
-        },\
+        QEMU_COMPAT_1_7,\
         {\
             .driver   = "PIIX4_PM",\
             .property = "acpi-pci-hotplug-with-bridge-support",\
@@ -348,19 +311,8 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_6 \
+        QEMU_COMPAT_1_6,\
         {\
-            .driver   = "e1000",\
-            .property = "mitigation",\
-            .value    = "off",\
-        },{\
-            .driver   = "qemu64-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "qemu32-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(3),\
-        },{\
             .driver   = "i440FX-pcihost",\
             .property = "short_root_bus",\
             .value    = stringify(1),\
@@ -371,39 +323,8 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_5 \
+        QEMU_COMPAT_1_7,\
         {\
-            .driver   = "Conroe-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Conroe-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Penryn-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Penryn-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Nehalem-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Nehalem-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "virtio-net-pci",\
-            .property = "any_layout",\
-            .value    = "off",\
-        },{\
-            .driver = TYPE_X86_CPU,\
-            .property = "pmu",\
-            .value = "on",\
-        },{\
             .driver   = "i440FX-pcihost",\
             .property = "short_root_bus",\
             .value    = stringify(0),\
@@ -414,68 +335,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_4 \
-        {\
-            .driver   = "scsi-hd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "scsi-cd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "scsi-disk",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-hd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-cd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-drive",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-        },{\
-            .driver   = "virtio-blk-pci",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "virtio-serial-pci",\
-            .property = "vectors",\
-            /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
-            .value    = stringify(0xFFFFFFFF),\
-        },{ \
-            .driver   = "virtio-net-pci", \
-            .property = "ctrl_guest_offloads", \
-            .value    = "off", \
-        },{\
-            .driver   = "e1000",\
-            .property = "romfile",\
-            .value    = "pxe-e1000.rom",\
-        },{\
-            .driver   = "ne2k_pci",\
-            .property = "romfile",\
-            .value    = "pxe-ne2k_pci.rom",\
-        },{\
-            .driver   = "pcnet",\
-            .property = "romfile",\
-            .value    = "pxe-pcnet.rom",\
-        },{\
-            .driver   = "rtl8139",\
-            .property = "romfile",\
-            .value    = "pxe-rtl8139.rom",\
-        },{\
-            .driver   = "virtio-net-pci",\
-            .property = "romfile",\
-            .value    = "pxe-virtio.rom",\
-        },{\
-            .driver   = "486-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(0),\
-        }
+    QEMU_COMPAT_1_4
 
 #define PC_COMMON_MACHINE_OPTIONS \
     .default_boot_order = "cad"
Signature · 1 line
1.9.3
#11 lore raw

Re: [Qemu-devel] [PATCH 3/4] machine: Introduce QEMU_COMPAT_* macros

Quoted 115 lines · Michael S. Tsirkin
Quoted 96 lines · Eduardo Habkost

The QEMU_COMPAT_* macros will contain compat properties that are not specific to PC, and may be reused by other machine-types.

PC-specific properties were left on the PC_COMPAT_* macros.

---
 include/hw/boards.h  | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 150 ++---------------------------------------------
 2 files changed, 166 insertions(+), 145 deletions(-)
include/hw/boards.h +77 -0
index 605a970..709b582 100644
@@ -134,4 +134,165 @@ struct MachineState {
     const char *cpu_model;
 };
 
+
+/* Macros for compat_props corresponding to specific QEMU versions: */
+
+#define QEMU_COMPAT_2_0 \
+    {\
+        .driver   = "virtio-scsi-pci",\
+        .property = "any_layout",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "apic",\
+        .property = "version",\
+        .value    = stringify(0x11),\
+    },\
+    {\
+        .driver   = "nec-usb-xhci",\
+        .property = "superspeed-ports-first",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "pci-serial",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-2x",\
+        .property = "prof_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-4x",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "virtio-net-pci",\
+        .property = "guest_announce",\
+        .value    = "off",\
+    }
+
+#define QEMU_COMPAT_1_7 \
+    {\
+        .driver   = TYPE_USB_DEVICE,\
+        .property = "msos-desc",\
+        .value    = "no",\
+    }
+
+#define QEMU_COMPAT_1_6 \
+    {\
+        .driver   = "e1000",\
+        .property = "mitigation",\
+        .value    = "off",\
+    },{\
+        .driver   = "qemu64-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "qemu32-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(3),\
+    }
+
+#define QEMU_COMPAT_1_5 \
+    {\
+        .driver   = "Conroe-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Conroe-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Penryn-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Penryn-" TYPE_X86_CPU,\

include/hw/boards.h struct MachineState { · line 223

Quoted 10 lines
include/hw/boards.h +10 -0
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Nehalem-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Nehalem-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\

Above are x86 CPUs - why have them in a common header? There's no chance any machine except PIIX&Q35 needs these.

include/hw/boards.h struct MachineState { · line 227

Quoted 3 lines
include/hw/boards.h +3 -0
+        .driver   = "virtio-net-pci",\
+        .property = "any_layout",\
+        .value    = "off",\
Quoted 5 lines

Here's an example.
If you are using a non x86 target, QEMU 2.0
has no way to select a machine with this
value.
So why expose it?

As we talked on the KVM call, the objective is to assign the compat properties per QEMU version and close to their device. As a *middle* step we shall put all together in a common file per version and not per machine type, and then work on a registration mechanism that will be based on the fact that compat properties are per device and versioned by QEMU.

Thanks,
Marcel

Quoted 266 lines
Quoted 266 lines
include/hw/boards.h +70 -0
+    },{\
+        .driver = TYPE_X86_CPU,\
+        .property = "pmu",\
+        .value = "on",\
+    }
+
+#define QEMU_COMPAT_1_4 \
+    {\
+        .driver   = "scsi-hd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "scsi-cd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "scsi-disk",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-hd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-cd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-drive",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "virtio-blk-pci",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "virtio-serial-pci",\
+        .property = "vectors",\
+        /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
+        .value    = stringify(0xFFFFFFFF),\
+    },{ \
+        .driver   = "virtio-net-pci", \
+        .property = "ctrl_guest_offloads", \
+        .value    = "off", \
+    },{\
+        .driver   = "e1000",\
+        .property = "romfile",\
+        .value    = "pxe-e1000.rom",\
+    },{\
+        .driver   = "ne2k_pci",\
+        .property = "romfile",\
+        .value    = "pxe-ne2k_pci.rom",\
+    },{\
+        .driver   = "pcnet",\
+        .property = "romfile",\
+        .value    = "pxe-pcnet.rom",\
+    },{\
+        .driver   = "rtl8139",\
+        .property = "romfile",\
+        .value    = "pxe-rtl8139.rom",\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "romfile",\
+        .value    = "pxe-virtio.rom",\
+    },{\
+        .driver   = "486-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(0),\
+    }
+
 #endif
include/hw/i386/pc.h +5 -145
index d988b80..631afe7 100644
@@ -295,52 +295,15 @@ int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
 #define PC_COMPAT_2_0 \
+        QEMU_COMPAT_2_0,\
         {\
-            .driver   = "virtio-scsi-pci",\
-            .property = "any_layout",\
-            .value    = "off",\
-        },{\
             .driver   = "PIIX4_PM",\
             .property = "memory-hotplug-support",\
             .value    = "off",\
-        },\
-        {\
-            .driver   = "apic",\
-            .property = "version",\
-            .value    = stringify(0x11),\
-        },\
-        {\
-            .driver   = "nec-usb-xhci",\
-            .property = "superspeed-ports-first",\
-            .value    = "off",\
-        },\
-        {\
-            .driver   = "pci-serial",\
-            .property = "prog_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "pci-serial-2x",\
-            .property = "prof_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "pci-serial-4x",\
-            .property = "prog_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "virtio-net-pci",\
-            .property = "guest_announce",\
-            .value    = "off",\
         }
 
 #define PC_COMPAT_1_7 \
-        {\
-            .driver   = TYPE_USB_DEVICE,\
-            .property = "msos-desc",\
-            .value    = "no",\
-        },\
+        QEMU_COMPAT_1_7,\
         {\
             .driver   = "PIIX4_PM",\
             .property = "acpi-pci-hotplug-with-bridge-support",\
@@ -348,19 +311,8 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_6 \
+        QEMU_COMPAT_1_6,\
         {\
-            .driver   = "e1000",\
-            .property = "mitigation",\
-            .value    = "off",\
-        },{\
-            .driver   = "qemu64-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "qemu32-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(3),\
-        },{\
             .driver   = "i440FX-pcihost",\
             .property = "short_root_bus",\
             .value    = stringify(1),\
@@ -371,39 +323,8 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_5 \
+        QEMU_COMPAT_1_7,\
         {\
-            .driver   = "Conroe-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Conroe-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Penryn-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Penryn-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Nehalem-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Nehalem-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "virtio-net-pci",\
-            .property = "any_layout",\
-            .value    = "off",\
-        },{\
-            .driver = TYPE_X86_CPU,\
-            .property = "pmu",\
-            .value = "on",\
-        },{\
             .driver   = "i440FX-pcihost",\
             .property = "short_root_bus",\
             .value    = stringify(0),\
@@ -414,68 +335,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_4 \
-        {\
-            .driver   = "scsi-hd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "scsi-cd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "scsi-disk",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-hd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-cd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-drive",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-        },{\
-            .driver   = "virtio-blk-pci",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "virtio-serial-pci",\
-            .property = "vectors",\
-            /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
-            .value    = stringify(0xFFFFFFFF),\
-        },{ \
-            .driver   = "virtio-net-pci", \
-            .property = "ctrl_guest_offloads", \
-            .value    = "off", \
-        },{\
-            .driver   = "e1000",\
-            .property = "romfile",\
-            .value    = "pxe-e1000.rom",\
-        },{\
-            .driver   = "ne2k_pci",\
-            .property = "romfile",\
-            .value    = "pxe-ne2k_pci.rom",\
-        },{\
-            .driver   = "pcnet",\
-            .property = "romfile",\
-            .value    = "pxe-pcnet.rom",\
-        },{\
-            .driver   = "rtl8139",\
-            .property = "romfile",\
-            .value    = "pxe-rtl8139.rom",\
-        },{\
-            .driver   = "virtio-net-pci",\
-            .property = "romfile",\
-            .value    = "pxe-virtio.rom",\
-        },{\
-            .driver   = "486-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(0),\
-        }
+    QEMU_COMPAT_1_4
 
 #define PC_COMMON_MACHINE_OPTIONS \
     .default_boot_order = "cad"
Signature · 1 line
1.9.3
#12 lore raw

Re: [Qemu-devel] [PATCH 3/4] machine: Introduce QEMU_COMPAT_* macros

Quoted 128 lines · Marcel Apfelbaum
Quoted 115 lines · Michael S. Tsirkin
Quoted 96 lines · Eduardo Habkost

The QEMU_COMPAT_* macros will contain compat properties that are not specific to PC, and may be reused by other machine-types.

PC-specific properties were left on the PC_COMPAT_* macros.

---
 include/hw/boards.h  | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 150 ++---------------------------------------------
 2 files changed, 166 insertions(+), 145 deletions(-)
include/hw/boards.h +77 -0
index 605a970..709b582 100644
@@ -134,4 +134,165 @@ struct MachineState {
     const char *cpu_model;
 };
 
+
+/* Macros for compat_props corresponding to specific QEMU versions: */
+
+#define QEMU_COMPAT_2_0 \
+    {\
+        .driver   = "virtio-scsi-pci",\
+        .property = "any_layout",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "apic",\
+        .property = "version",\
+        .value    = stringify(0x11),\
+    },\
+    {\
+        .driver   = "nec-usb-xhci",\
+        .property = "superspeed-ports-first",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "pci-serial",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-2x",\
+        .property = "prof_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-4x",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "virtio-net-pci",\
+        .property = "guest_announce",\
+        .value    = "off",\
+    }
+
+#define QEMU_COMPAT_1_7 \
+    {\
+        .driver   = TYPE_USB_DEVICE,\
+        .property = "msos-desc",\
+        .value    = "no",\
+    }
+
+#define QEMU_COMPAT_1_6 \
+    {\
+        .driver   = "e1000",\
+        .property = "mitigation",\
+        .value    = "off",\
+    },{\
+        .driver   = "qemu64-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "qemu32-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(3),\
+    }
+
+#define QEMU_COMPAT_1_5 \
+    {\
+        .driver   = "Conroe-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Conroe-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Penryn-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Penryn-" TYPE_X86_CPU,\

include/hw/boards.h struct MachineState { · line 223

Quoted 10 lines
include/hw/boards.h +10 -0
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Nehalem-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Nehalem-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\

Above are x86 CPUs - why have them in a common header? There's no chance any machine except PIIX&Q35 needs these.

include/hw/boards.h struct MachineState { · line 227

Quoted 3 lines
include/hw/boards.h +3 -0
+        .driver   = "virtio-net-pci",\
+        .property = "any_layout",\
+        .value    = "off",\
Quoted 5 lines

Here's an example.
If you are using a non x86 target, QEMU 2.0
has no way to select a machine with this
value.
So why expose it?

As we talked on the KVM call, the objective is to assign the compat properties per QEMU version and close to their device. As a *middle* step we shall put all together in a common file per version and not per machine type, and then work on a registration mechanism that will be based on the fact that compat properties are per device and versioned by QEMU.

Quoted 2 lines

Thanks,
Marcel

Yes but that'll stay on a branch and get merged after 2.1. Let's keep this patch on that branch there as well.

Quoted 268 lines
Quoted 266 lines
Quoted 266 lines
include/hw/boards.h +70 -0
+    },{\
+        .driver = TYPE_X86_CPU,\
+        .property = "pmu",\
+        .value = "on",\
+    }
+
+#define QEMU_COMPAT_1_4 \
+    {\
+        .driver   = "scsi-hd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "scsi-cd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "scsi-disk",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-hd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-cd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-drive",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "virtio-blk-pci",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "virtio-serial-pci",\
+        .property = "vectors",\
+        /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
+        .value    = stringify(0xFFFFFFFF),\
+    },{ \
+        .driver   = "virtio-net-pci", \
+        .property = "ctrl_guest_offloads", \
+        .value    = "off", \
+    },{\
+        .driver   = "e1000",\
+        .property = "romfile",\
+        .value    = "pxe-e1000.rom",\
+    },{\
+        .driver   = "ne2k_pci",\
+        .property = "romfile",\
+        .value    = "pxe-ne2k_pci.rom",\
+    },{\
+        .driver   = "pcnet",\
+        .property = "romfile",\
+        .value    = "pxe-pcnet.rom",\
+    },{\
+        .driver   = "rtl8139",\
+        .property = "romfile",\
+        .value    = "pxe-rtl8139.rom",\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "romfile",\
+        .value    = "pxe-virtio.rom",\
+    },{\
+        .driver   = "486-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(0),\
+    }
+
 #endif
include/hw/i386/pc.h +5 -145
index d988b80..631afe7 100644
@@ -295,52 +295,15 @@ int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
 #define PC_COMPAT_2_0 \
+        QEMU_COMPAT_2_0,\
         {\
-            .driver   = "virtio-scsi-pci",\
-            .property = "any_layout",\
-            .value    = "off",\
-        },{\
             .driver   = "PIIX4_PM",\
             .property = "memory-hotplug-support",\
             .value    = "off",\
-        },\
-        {\
-            .driver   = "apic",\
-            .property = "version",\
-            .value    = stringify(0x11),\
-        },\
-        {\
-            .driver   = "nec-usb-xhci",\
-            .property = "superspeed-ports-first",\
-            .value    = "off",\
-        },\
-        {\
-            .driver   = "pci-serial",\
-            .property = "prog_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "pci-serial-2x",\
-            .property = "prof_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "pci-serial-4x",\
-            .property = "prog_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "virtio-net-pci",\
-            .property = "guest_announce",\
-            .value    = "off",\
         }
 
 #define PC_COMPAT_1_7 \
-        {\
-            .driver   = TYPE_USB_DEVICE,\
-            .property = "msos-desc",\
-            .value    = "no",\
-        },\
+        QEMU_COMPAT_1_7,\
         {\
             .driver   = "PIIX4_PM",\
             .property = "acpi-pci-hotplug-with-bridge-support",\
@@ -348,19 +311,8 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_6 \
+        QEMU_COMPAT_1_6,\
         {\
-            .driver   = "e1000",\
-            .property = "mitigation",\
-            .value    = "off",\
-        },{\
-            .driver   = "qemu64-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "qemu32-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(3),\
-        },{\
             .driver   = "i440FX-pcihost",\
             .property = "short_root_bus",\
             .value    = stringify(1),\
@@ -371,39 +323,8 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_5 \
+        QEMU_COMPAT_1_7,\
         {\
-            .driver   = "Conroe-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Conroe-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Penryn-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Penryn-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Nehalem-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Nehalem-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "virtio-net-pci",\
-            .property = "any_layout",\
-            .value    = "off",\
-        },{\
-            .driver = TYPE_X86_CPU,\
-            .property = "pmu",\
-            .value = "on",\
-        },{\
             .driver   = "i440FX-pcihost",\
             .property = "short_root_bus",\
             .value    = stringify(0),\
@@ -414,68 +335,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_4 \
-        {\
-            .driver   = "scsi-hd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "scsi-cd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "scsi-disk",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-hd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-cd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-drive",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-        },{\
-            .driver   = "virtio-blk-pci",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "virtio-serial-pci",\
-            .property = "vectors",\
-            /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
-            .value    = stringify(0xFFFFFFFF),\
-        },{ \
-            .driver   = "virtio-net-pci", \
-            .property = "ctrl_guest_offloads", \
-            .value    = "off", \
-        },{\
-            .driver   = "e1000",\
-            .property = "romfile",\
-            .value    = "pxe-e1000.rom",\
-        },{\
-            .driver   = "ne2k_pci",\
-            .property = "romfile",\
-            .value    = "pxe-ne2k_pci.rom",\
-        },{\
-            .driver   = "pcnet",\
-            .property = "romfile",\
-            .value    = "pxe-pcnet.rom",\
-        },{\
-            .driver   = "rtl8139",\
-            .property = "romfile",\
-            .value    = "pxe-rtl8139.rom",\
-        },{\
-            .driver   = "virtio-net-pci",\
-            .property = "romfile",\
-            .value    = "pxe-virtio.rom",\
-        },{\
-            .driver   = "486-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(0),\
-        }
+    QEMU_COMPAT_1_4
 
 #define PC_COMMON_MACHINE_OPTIONS \
     .default_boot_order = "cad"
Signature · 1 line
1.9.3
#13 lore raw

Re: [Qemu-devel] [PATCH 3/4] machine: Introduce QEMU_COMPAT_* macros

Quoted 129 lines · Michael S. Tsirkin
Quoted 128 lines · Marcel Apfelbaum
Quoted 115 lines · Michael S. Tsirkin
Quoted 96 lines · Eduardo Habkost

The QEMU_COMPAT_* macros will contain compat properties that are not specific to PC, and may be reused by other machine-types.

PC-specific properties were left on the PC_COMPAT_* macros.

---
 include/hw/boards.h  | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 150 ++---------------------------------------------
 2 files changed, 166 insertions(+), 145 deletions(-)
include/hw/boards.h +77 -0
index 605a970..709b582 100644
@@ -134,4 +134,165 @@ struct MachineState {
     const char *cpu_model;
 };
 
+
+/* Macros for compat_props corresponding to specific QEMU versions: */
+
+#define QEMU_COMPAT_2_0 \
+    {\
+        .driver   = "virtio-scsi-pci",\
+        .property = "any_layout",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "apic",\
+        .property = "version",\
+        .value    = stringify(0x11),\
+    },\
+    {\
+        .driver   = "nec-usb-xhci",\
+        .property = "superspeed-ports-first",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "pci-serial",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-2x",\
+        .property = "prof_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "pci-serial-4x",\
+        .property = "prog_if",\
+        .value    = stringify(0),\
+    },\
+    {\
+        .driver   = "virtio-net-pci",\
+        .property = "guest_announce",\
+        .value    = "off",\
+    }
+
+#define QEMU_COMPAT_1_7 \
+    {\
+        .driver   = TYPE_USB_DEVICE,\
+        .property = "msos-desc",\
+        .value    = "no",\
+    }
+
+#define QEMU_COMPAT_1_6 \
+    {\
+        .driver   = "e1000",\
+        .property = "mitigation",\
+        .value    = "off",\
+    },{\
+        .driver   = "qemu64-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "qemu32-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(3),\
+    }
+
+#define QEMU_COMPAT_1_5 \
+    {\
+        .driver   = "Conroe-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Conroe-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Penryn-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Penryn-" TYPE_X86_CPU,\

include/hw/boards.h struct MachineState { · line 223

Quoted 10 lines
include/hw/boards.h +10 -0
+        .property = "level",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Nehalem-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(2),\
+    },{\
+        .driver   = "Nehalem-" TYPE_X86_CPU,\
+        .property = "level",\
+        .value    = stringify(2),\

Above are x86 CPUs - why have them in a common header? There's no chance any machine except PIIX&Q35 needs these.

include/hw/boards.h struct MachineState { · line 227

Quoted 3 lines
include/hw/boards.h +3 -0
+        .driver   = "virtio-net-pci",\
+        .property = "any_layout",\
+        .value    = "off",\
Quoted 5 lines

Here's an example.
If you are using a non x86 target, QEMU 2.0
has no way to select a machine with this
value.
So why expose it?

As we talked on the KVM call, the objective is to assign the compat properties per QEMU version and close to their device. As a *middle* step we shall put all together in a common file per version and not per machine type, and then work on a registration mechanism that will be based on the fact that compat properties are per device and versioned by QEMU.

Quoted 5 lines
Quoted 2 lines

Thanks,
Marcel

Yes but that'll stay on a branch and get merged after 2.1. Let's keep this patch on that branch there as well.

Fine by me

Thanks,
Marcel

Quoted 270 lines
Quoted 270 lines
Quoted 268 lines
Quoted 268 lines
include/hw/boards.h +70 -0
+    },{\
+        .driver = TYPE_X86_CPU,\
+        .property = "pmu",\
+        .value = "on",\
+    }
+
+#define QEMU_COMPAT_1_4 \
+    {\
+        .driver   = "scsi-hd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "scsi-cd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "scsi-disk",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-hd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-cd",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "ide-drive",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "virtio-blk-pci",\
+        .property = "discard_granularity",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "virtio-serial-pci",\
+        .property = "vectors",\
+        /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
+        .value    = stringify(0xFFFFFFFF),\
+    },{ \
+        .driver   = "virtio-net-pci", \
+        .property = "ctrl_guest_offloads", \
+        .value    = "off", \
+    },{\
+        .driver   = "e1000",\
+        .property = "romfile",\
+        .value    = "pxe-e1000.rom",\
+    },{\
+        .driver   = "ne2k_pci",\
+        .property = "romfile",\
+        .value    = "pxe-ne2k_pci.rom",\
+    },{\
+        .driver   = "pcnet",\
+        .property = "romfile",\
+        .value    = "pxe-pcnet.rom",\
+    },{\
+        .driver   = "rtl8139",\
+        .property = "romfile",\
+        .value    = "pxe-rtl8139.rom",\
+    },{\
+        .driver   = "virtio-net-pci",\
+        .property = "romfile",\
+        .value    = "pxe-virtio.rom",\
+    },{\
+        .driver   = "486-" TYPE_X86_CPU,\
+        .property = "model",\
+        .value    = stringify(0),\
+    }
+
 #endif
include/hw/i386/pc.h +5 -145
index d988b80..631afe7 100644
@@ -295,52 +295,15 @@ int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
 #define PC_COMPAT_2_0 \
+        QEMU_COMPAT_2_0,\
         {\
-            .driver   = "virtio-scsi-pci",\
-            .property = "any_layout",\
-            .value    = "off",\
-        },{\
             .driver   = "PIIX4_PM",\
             .property = "memory-hotplug-support",\
             .value    = "off",\
-        },\
-        {\
-            .driver   = "apic",\
-            .property = "version",\
-            .value    = stringify(0x11),\
-        },\
-        {\
-            .driver   = "nec-usb-xhci",\
-            .property = "superspeed-ports-first",\
-            .value    = "off",\
-        },\
-        {\
-            .driver   = "pci-serial",\
-            .property = "prog_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "pci-serial-2x",\
-            .property = "prof_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "pci-serial-4x",\
-            .property = "prog_if",\
-            .value    = stringify(0),\
-        },\
-        {\
-            .driver   = "virtio-net-pci",\
-            .property = "guest_announce",\
-            .value    = "off",\
         }
 
 #define PC_COMPAT_1_7 \
-        {\
-            .driver   = TYPE_USB_DEVICE,\
-            .property = "msos-desc",\
-            .value    = "no",\
-        },\
+        QEMU_COMPAT_1_7,\
         {\
             .driver   = "PIIX4_PM",\
             .property = "acpi-pci-hotplug-with-bridge-support",\
@@ -348,19 +311,8 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_6 \
+        QEMU_COMPAT_1_6,\
         {\
-            .driver   = "e1000",\
-            .property = "mitigation",\
-            .value    = "off",\
-        },{\
-            .driver   = "qemu64-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "qemu32-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(3),\
-        },{\
             .driver   = "i440FX-pcihost",\
             .property = "short_root_bus",\
             .value    = stringify(1),\
@@ -371,39 +323,8 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_5 \
+        QEMU_COMPAT_1_7,\
         {\
-            .driver   = "Conroe-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Conroe-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Penryn-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Penryn-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Nehalem-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "Nehalem-" TYPE_X86_CPU,\
-            .property = "level",\
-            .value    = stringify(2),\
-        },{\
-            .driver   = "virtio-net-pci",\
-            .property = "any_layout",\
-            .value    = "off",\
-        },{\
-            .driver = TYPE_X86_CPU,\
-            .property = "pmu",\
-            .value = "on",\
-        },{\
             .driver   = "i440FX-pcihost",\
             .property = "short_root_bus",\
             .value    = stringify(0),\
@@ -414,68 +335,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_4 \
-        {\
-            .driver   = "scsi-hd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "scsi-cd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "scsi-disk",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-hd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-cd",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "ide-drive",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-        },{\
-            .driver   = "virtio-blk-pci",\
-            .property = "discard_granularity",\
-            .value    = stringify(0),\
-	},{\
-            .driver   = "virtio-serial-pci",\
-            .property = "vectors",\
-            /* DEV_NVECTORS_UNSPECIFIED as a uint32_t string */\
-            .value    = stringify(0xFFFFFFFF),\
-        },{ \
-            .driver   = "virtio-net-pci", \
-            .property = "ctrl_guest_offloads", \
-            .value    = "off", \
-        },{\
-            .driver   = "e1000",\
-            .property = "romfile",\
-            .value    = "pxe-e1000.rom",\
-        },{\
-            .driver   = "ne2k_pci",\
-            .property = "romfile",\
-            .value    = "pxe-ne2k_pci.rom",\
-        },{\
-            .driver   = "pcnet",\
-            .property = "romfile",\
-            .value    = "pxe-pcnet.rom",\
-        },{\
-            .driver   = "rtl8139",\
-            .property = "romfile",\
-            .value    = "pxe-rtl8139.rom",\
-        },{\
-            .driver   = "virtio-net-pci",\
-            .property = "romfile",\
-            .value    = "pxe-virtio.rom",\
-        },{\
-            .driver   = "486-" TYPE_X86_CPU,\
-            .property = "model",\
-            .value    = stringify(0),\
-        }
+    QEMU_COMPAT_1_4
 
 #define PC_COMMON_MACHINE_OPTIONS \
     .default_boot_order = "cad"
Signature · 1 line
1.9.3
#14 lore raw

RFC PATCH 4/4 Eliminate PC-specific compat_props

In reply to Eduardo Habkost

All compat properties are only applied if a device of an specific type is instantiated. There's no need to keep a PC-specific list of compat properties, as properties for PC-specific devices won't affect other machine-types anyway.

This patch moves all compat_props properties from PC compat macros, to QEMU_COMPAT_*.

In case somebody wonders why the nesting was kept on the machine-type-specific PC_*_COMPAT_* macros instead of making QEMU_COMPAT_* macros nested. The answer is that making QEMU_COMPAT_* nested would make it more difficult to migrate the existing machine-type code to QOM later using class_init reuse. See:
https://github.com/ehabkost/qemu-hacks/commit/9edb1f70fc2bd74131f54a2dfed1e890a5859736

PC_COMPAT_1_3 and older are being left untouched by now, as they still need some additional cleanup and are unlikely to be reused by new machine-types anyway.

---
 hw/i386/pc_piix.c    | 10 +++++-----
 hw/i386/pc_q35.c     | 28 +++++-----------------------
 include/hw/boards.h  | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 43 -------------------------------------------
 4 files changed, 56 insertions(+), 71 deletions(-)
hw/i386/pc_piix.c +5 -5
index d8010d16..5e3d24d 100644
@@ -442,7 +442,7 @@ static QEMUMachine pc_i440fx_machine_v2_1 = {
 };
 
 #define PC_I440FX_COMPAT_2_0 \
-    PC_COMPAT_2_0
+    QEMU_COMPAT_2_0
 
 #define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS
 
@@ -458,7 +458,7 @@ static QEMUMachine pc_i440fx_machine_v2_0 = {
 
 #define PC_I440FX_COMPAT_1_7 \
     PC_I440FX_COMPAT_2_0, \
-    PC_COMPAT_1_7
+    QEMU_COMPAT_1_7
 
 #define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
 
@@ -474,7 +474,7 @@ static QEMUMachine pc_i440fx_machine_v1_7 = {
 
 #define PC_I440FX_COMPAT_1_6 \
     PC_I440FX_COMPAT_1_7, \
-    PC_COMPAT_1_6
+    QEMU_COMPAT_1_6
 
 #define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
 
@@ -490,7 +490,7 @@ static QEMUMachine pc_i440fx_machine_v1_6 = {
 
 #define PC_I440FX_COMPAT_1_5 \
     PC_I440FX_COMPAT_1_6, \
-    PC_COMPAT_1_5
+    QEMU_COMPAT_1_5
 
 static QEMUMachine pc_i440fx_machine_v1_5 = {
     PC_I440FX_1_6_MACHINE_OPTIONS,
@@ -504,7 +504,7 @@ static QEMUMachine pc_i440fx_machine_v1_5 = {
 
 #define PC_I440FX_COMPAT_1_4 \
     PC_I440FX_COMPAT_1_5, \
-    PC_COMPAT_1_4
+    QEMU_COMPAT_1_4
 
 #define PC_I440FX_1_4_MACHINE_OPTIONS \
     PC_I440FX_1_6_MACHINE_OPTIONS, \
hw/i386/pc_q35.c +5 -23
index 57eecc3..b59d22d 100644
@@ -355,20 +355,7 @@ static QEMUMachine pc_q35_machine_v2_1 = {
 };
 
 #define PC_Q35_COMPAT_2_0 \
-        PC_COMPAT_2_0, \
-        {\
-            .driver   = "ICH9-LPC",\
-            .property = "memory-hotplug-support",\
-            .value    = "off",\
-        },{\
-            .driver   = "xio3130-downstream",\
-            .property = COMPAT_PROP_PCP,\
-            .value    = "off",\
-        },{\
-            .driver   = "ioh3420",\
-            .property = COMPAT_PROP_PCP,\
-            .value    = "off",\
-        }
+        QEMU_COMPAT_2_0
 
 #define PC_Q35_2_0_MACHINE_OPTIONS PC_Q35_2_1_MACHINE_OPTIONS
 
@@ -384,12 +371,7 @@ static QEMUMachine pc_q35_machine_v2_0 = {
 
 #define PC_Q35_COMPAT_1_7 \
         PC_Q35_COMPAT_2_0, \
-        PC_COMPAT_1_7, \
-        {\
-            .driver   = "hpet",\
-            .property = HPET_INTCAP,\
-            .value    = stringify(4),\
-        }
+        QEMU_COMPAT_1_7
 
 #define PC_Q35_1_7_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
 
@@ -405,7 +387,7 @@ static QEMUMachine pc_q35_machine_v1_7 = {
 
 #define PC_Q35_COMPAT_1_6 \
         PC_Q35_COMPAT_1_7, \
-        PC_COMPAT_1_6
+        QEMU_COMPAT_1_6
 
 #define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
 
@@ -421,7 +403,7 @@ static QEMUMachine pc_q35_machine_v1_6 = {
 
 #define PC_Q35_COMPAT_1_5 \
         PC_Q35_COMPAT_1_6, \
-        PC_COMPAT_1_5
+        QEMU_COMPAT_1_5
 
 static QEMUMachine pc_q35_machine_v1_5 = {
     PC_Q35_1_6_MACHINE_OPTIONS,
@@ -435,7 +417,7 @@ static QEMUMachine pc_q35_machine_v1_5 = {
 
 #define PC_Q35_COMPAT_1_4 \
         PC_Q35_COMPAT_1_5, \
-        PC_COMPAT_1_4
+        QEMU_COMPAT_1_4
 
 #define PC_Q35_1_4_MACHINE_OPTIONS \
     PC_Q35_1_6_MACHINE_OPTIONS, \
include/hw/boards.h +46 -0

70 lines not on this page · raw message

include/hw/i386/pc.h +0 -43

49 lines not on this page · raw message

Signature · 1 line
1.9.3
#15 lore raw

Re: [Qemu-devel] [PATCH 4/4] [RFC] Eliminate PC-specific compat_props

Quoted 4 lines · Eduardo Habkost

All compat properties are only applied if a device of an specific type is instantiated. There's no need to keep a PC-specific list of compat properties, as properties for PC-specific devices won't affect other machine-types anyway.

So why do we still need 2 sets of hierarchies PC_I440FX_COMPAT_x_y and PC_Q35_COMPAT_x_y? It seems that QEMU_COMPAT_x_y is enough. Am I missing something?

Thanks,
Marcel

Quoted 271 lines

This patch moves all compat_props properties from PC compat macros, to QEMU_COMPAT_*.

In case somebody wonders why the nesting was kept on the machine-type-specific PC_*_COMPAT_* macros instead of making QEMU_COMPAT_* macros nested. The answer is that making QEMU_COMPAT_* nested would make it more difficult to migrate the existing machine-type code to QOM later using class_init reuse. See:
https://github.com/ehabkost/qemu-hacks/commit/9edb1f70fc2bd74131f54a2dfed1e890a5859736

PC_COMPAT_1_3 and older are being left untouched by now, as they still need some additional cleanup and are unlikely to be reused by new machine-types anyway.

---
 hw/i386/pc_piix.c    | 10 +++++-----
 hw/i386/pc_q35.c     | 28 +++++-----------------------
 include/hw/boards.h  | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 43 -------------------------------------------
 4 files changed, 56 insertions(+), 71 deletions(-)
hw/i386/pc_piix.c +5 -5
index d8010d16..5e3d24d 100644
@@ -442,7 +442,7 @@ static QEMUMachine pc_i440fx_machine_v2_1 = {
 };
 
 #define PC_I440FX_COMPAT_2_0 \
-    PC_COMPAT_2_0
+    QEMU_COMPAT_2_0
 
 #define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS
 
@@ -458,7 +458,7 @@ static QEMUMachine pc_i440fx_machine_v2_0 = {
 
 #define PC_I440FX_COMPAT_1_7 \
     PC_I440FX_COMPAT_2_0, \
-    PC_COMPAT_1_7
+    QEMU_COMPAT_1_7
 
 #define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
 
@@ -474,7 +474,7 @@ static QEMUMachine pc_i440fx_machine_v1_7 = {
 
 #define PC_I440FX_COMPAT_1_6 \
     PC_I440FX_COMPAT_1_7, \
-    PC_COMPAT_1_6
+    QEMU_COMPAT_1_6
 
 #define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
 
@@ -490,7 +490,7 @@ static QEMUMachine pc_i440fx_machine_v1_6 = {
 
 #define PC_I440FX_COMPAT_1_5 \
     PC_I440FX_COMPAT_1_6, \
-    PC_COMPAT_1_5
+    QEMU_COMPAT_1_5
 
 static QEMUMachine pc_i440fx_machine_v1_5 = {
     PC_I440FX_1_6_MACHINE_OPTIONS,
@@ -504,7 +504,7 @@ static QEMUMachine pc_i440fx_machine_v1_5 = {
 
 #define PC_I440FX_COMPAT_1_4 \
     PC_I440FX_COMPAT_1_5, \
-    PC_COMPAT_1_4
+    QEMU_COMPAT_1_4
 
 #define PC_I440FX_1_4_MACHINE_OPTIONS \
     PC_I440FX_1_6_MACHINE_OPTIONS, \
hw/i386/pc_q35.c +5 -23
index 57eecc3..b59d22d 100644
@@ -355,20 +355,7 @@ static QEMUMachine pc_q35_machine_v2_1 = {
 };
 
 #define PC_Q35_COMPAT_2_0 \
-        PC_COMPAT_2_0, \
-        {\
-            .driver   = "ICH9-LPC",\
-            .property = "memory-hotplug-support",\
-            .value    = "off",\
-        },{\
-            .driver   = "xio3130-downstream",\
-            .property = COMPAT_PROP_PCP,\
-            .value    = "off",\
-        },{\
-            .driver   = "ioh3420",\
-            .property = COMPAT_PROP_PCP,\
-            .value    = "off",\
-        }
+        QEMU_COMPAT_2_0
 
 #define PC_Q35_2_0_MACHINE_OPTIONS PC_Q35_2_1_MACHINE_OPTIONS
 
@@ -384,12 +371,7 @@ static QEMUMachine pc_q35_machine_v2_0 = {
 
 #define PC_Q35_COMPAT_1_7 \
         PC_Q35_COMPAT_2_0, \
-        PC_COMPAT_1_7, \
-        {\
-            .driver   = "hpet",\
-            .property = HPET_INTCAP,\
-            .value    = stringify(4),\
-        }
+        QEMU_COMPAT_1_7
 
 #define PC_Q35_1_7_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
 
@@ -405,7 +387,7 @@ static QEMUMachine pc_q35_machine_v1_7 = {
 
 #define PC_Q35_COMPAT_1_6 \
         PC_Q35_COMPAT_1_7, \
-        PC_COMPAT_1_6
+        QEMU_COMPAT_1_6
 
 #define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
 
@@ -421,7 +403,7 @@ static QEMUMachine pc_q35_machine_v1_6 = {
 
 #define PC_Q35_COMPAT_1_5 \
         PC_Q35_COMPAT_1_6, \
-        PC_COMPAT_1_5
+        QEMU_COMPAT_1_5
 
 static QEMUMachine pc_q35_machine_v1_5 = {
     PC_Q35_1_6_MACHINE_OPTIONS,
@@ -435,7 +417,7 @@ static QEMUMachine pc_q35_machine_v1_5 = {
 
 #define PC_Q35_COMPAT_1_4 \
         PC_Q35_COMPAT_1_5, \
-        PC_COMPAT_1_4
+        QEMU_COMPAT_1_4
 
 #define PC_Q35_1_4_MACHINE_OPTIONS \
     PC_Q35_1_6_MACHINE_OPTIONS, \
include/hw/boards.h +46 -0
index 709b582..fa7ceb7 100644
@@ -172,6 +172,24 @@ struct MachineState {
         .driver   = "virtio-net-pci",\
         .property = "guest_announce",\
         .value    = "off",\
+    },\
+    {\
+        .driver   = "PIIX4_PM",\
+        .property = "memory-hotplug-support",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "ICH9-LPC",\
+        .property = "memory-hotplug-support",\
+        .value    = "off",\
+    },{\
+        .driver   = "xio3130-downstream",\
+        .property = COMPAT_PROP_PCP,\
+        .value    = "off",\
+    },{\
+        .driver   = "ioh3420",\
+        .property = COMPAT_PROP_PCP,\
+        .value    = "off",\
     }
 
 #define QEMU_COMPAT_1_7 \
@@ -179,6 +197,16 @@ struct MachineState {
         .driver   = TYPE_USB_DEVICE,\
         .property = "msos-desc",\
         .value    = "no",\
+    },\
+    {\
+        .driver   = "PIIX4_PM",\
+        .property = "acpi-pci-hotplug-with-bridge-support",\
+        .value    = "off",\
+    }, \
+    {\
+        .driver   = "hpet",\
+        .property = HPET_INTCAP,\
+        .value    = stringify(4),\
     }
 
 #define QEMU_COMPAT_1_6 \
@@ -194,6 +222,15 @@ struct MachineState {
         .driver   = "qemu32-" TYPE_X86_CPU,\
         .property = "model",\
         .value    = stringify(3),\
+    },\
+    {\
+        .driver   = "i440FX-pcihost",\
+        .property = "short_root_bus",\
+        .value    = stringify(1),\
+    },{\
+        .driver   = "q35-pcihost",\
+        .property = "short_root_bus",\
+        .value    = stringify(1),\
     }
 
 #define QEMU_COMPAT_1_5 \
@@ -229,6 +266,15 @@ struct MachineState {
         .driver = TYPE_X86_CPU,\
         .property = "pmu",\
         .value = "on",\
+    },\
+    {\
+        .driver   = "i440FX-pcihost",\
+        .property = "short_root_bus",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "q35-pcihost",\
+        .property = "short_root_bus",\
+        .value    = stringify(0),\
     }
 
 #define QEMU_COMPAT_1_4 \
include/hw/i386/pc.h +0 -43
index 631afe7..8503bee 100644
@@ -294,49 +294,6 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
 int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
-#define PC_COMPAT_2_0 \
-        QEMU_COMPAT_2_0,\
-        {\
-            .driver   = "PIIX4_PM",\
-            .property = "memory-hotplug-support",\
-            .value    = "off",\
-        }
-
-#define PC_COMPAT_1_7 \
-        QEMU_COMPAT_1_7,\
-        {\
-            .driver   = "PIIX4_PM",\
-            .property = "acpi-pci-hotplug-with-bridge-support",\
-            .value    = "off",\
-        }
-
-#define PC_COMPAT_1_6 \
-        QEMU_COMPAT_1_6,\
-        {\
-            .driver   = "i440FX-pcihost",\
-            .property = "short_root_bus",\
-            .value    = stringify(1),\
-        },{\
-            .driver   = "q35-pcihost",\
-            .property = "short_root_bus",\
-            .value    = stringify(1),\
-        }
-
-#define PC_COMPAT_1_5 \
-        QEMU_COMPAT_1_7,\
-        {\
-            .driver   = "i440FX-pcihost",\
-            .property = "short_root_bus",\
-            .value    = stringify(0),\
-        },{\
-            .driver   = "q35-pcihost",\
-            .property = "short_root_bus",\
-            .value    = stringify(0),\
-        }
-
-#define PC_COMPAT_1_4 \
-    QEMU_COMPAT_1_4
-
 #define PC_COMMON_MACHINE_OPTIONS \
     .default_boot_order = "cad"
 
#16 lore raw

Re: [Qemu-devel] [PATCH 4/4] [RFC] Eliminate PC-specific compat_props

Quoted 9 lines · Marcel Apfelbaum
Quoted 4 lines · Eduardo Habkost

All compat properties are only applied if a device of an specific type is instantiated. There's no need to keep a PC-specific list of compat properties, as properties for PC-specific devices won't affect other machine-types anyway.

So why do we still need 2 sets of hierarchies PC_I440FX_COMPAT_x_y and PC_Q35_COMPAT_x_y? It seems that QEMU_COMPAT_x_y is enough. Am I missing something?

A single PC_COMPAT_* hierarchy should be enough after this patch, yes. I left them there because I was not sure this RFC would be accepted, and wanted to keep the changes simple.

If people are OK with this patch, I can reorder the changes in this series and move everything to QEMU_COMPAT_* in fewer steps, without even creating the new PC_I440FX_COMPAT_* macros.

Signature · 1 line
Eduardo
#17 lore raw

Re: [Qemu-devel] [PATCH 4/4] [RFC] Eliminate PC-specific compat_props

In reply to Eduardo Habkost
Quoted 41 lines · Eduardo Habkost

All compat properties are only applied if a device of an specific type is instantiated. There's no need to keep a PC-specific list of compat properties, as properties for PC-specific devices won't affect other machine-types anyway.

This patch moves all compat_props properties from PC compat macros, to QEMU_COMPAT_*.

In case somebody wonders why the nesting was kept on the machine-type-specific PC_*_COMPAT_* macros instead of making QEMU_COMPAT_* macros nested. The answer is that making QEMU_COMPAT_* nested would make it more difficult to migrate the existing machine-type code to QOM later using class_init reuse. See:
https://github.com/ehabkost/qemu-hacks/commit/9edb1f70fc2bd74131f54a2dfed1e890a5859736

PC_COMPAT_1_3 and older are being left untouched by now, as they still need some additional cleanup and are unlikely to be reused by new machine-types anyway.

---
 hw/i386/pc_piix.c    | 10 +++++-----
 hw/i386/pc_q35.c     | 28 +++++-----------------------
 include/hw/boards.h  | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 43 -------------------------------------------
 4 files changed, 56 insertions(+), 71 deletions(-)
hw/i386/pc_piix.c +1 -1
index d8010d16..5e3d24d 100644
@@ -442,7 +442,7 @@ static QEMUMachine pc_i440fx_machine_v2_1 = {
 };
 
 #define PC_I440FX_COMPAT_2_0 \
-    PC_COMPAT_2_0
+    QEMU_COMPAT_2_0
 
 #define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS
 

hw/i386/pc_piix.c static QEMUMachine pc_i440fx_machine_v2_0 = { · line 464

Quoted 8 lines
hw/i386/pc_piix.c +1 -1
@@ -458,7 +458,7 @@ static QEMUMachine pc_i440fx_machine_v2_0 = {
 
 #define PC_I440FX_COMPAT_1_7 \
     PC_I440FX_COMPAT_2_0, \
-    PC_COMPAT_1_7
+    QEMU_COMPAT_1_7
 
 #define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
 

As far as I can tell this will break hpet,
because you set it incorrectly for PIIX

#define QEMU_COMPAT_1_7 \

 @@ -179,6 +197,16 @@ struct MachineState {
          .driver   = TYPE_USB_DEVICE,\
          .property = "msos-desc",\
          .value    = "no",\
 +    },\
 +    {\
 +        .driver   = "PIIX4_PM",\
 +        .property = "acpi-pci-hotplug-with-bridge-support",\
 +        .value    = "off",\
 +    }, \
 +    {\
 +        .driver   = "hpet",\
 +        .property = HPET_INTCAP,\
 +        .value    = stringify(4),\
      }

AFAIK above is appropriate for Q35 but not PIIX.

See commit log for
commit 7a10ef51c2397ac4323bc786af02c58b413b5cd2
hpet: enable to entitle more irq pins for hpet

Quoted 228 lines
hw/i386/pc_piix.c +3 -3
@@ -474,7 +474,7 @@ static QEMUMachine pc_i440fx_machine_v1_7 = {
 
 #define PC_I440FX_COMPAT_1_6 \
     PC_I440FX_COMPAT_1_7, \
-    PC_COMPAT_1_6
+    QEMU_COMPAT_1_6
 
 #define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
 
@@ -490,7 +490,7 @@ static QEMUMachine pc_i440fx_machine_v1_6 = {
 
 #define PC_I440FX_COMPAT_1_5 \
     PC_I440FX_COMPAT_1_6, \
-    PC_COMPAT_1_5
+    QEMU_COMPAT_1_5
 
 static QEMUMachine pc_i440fx_machine_v1_5 = {
     PC_I440FX_1_6_MACHINE_OPTIONS,
@@ -504,7 +504,7 @@ static QEMUMachine pc_i440fx_machine_v1_5 = {
 
 #define PC_I440FX_COMPAT_1_4 \
     PC_I440FX_COMPAT_1_5, \
-    PC_COMPAT_1_4
+    QEMU_COMPAT_1_4
 
 #define PC_I440FX_1_4_MACHINE_OPTIONS \
     PC_I440FX_1_6_MACHINE_OPTIONS, \
hw/i386/pc_q35.c +5 -23
index 57eecc3..b59d22d 100644
@@ -355,20 +355,7 @@ static QEMUMachine pc_q35_machine_v2_1 = {
 };
 
 #define PC_Q35_COMPAT_2_0 \
-        PC_COMPAT_2_0, \
-        {\
-            .driver   = "ICH9-LPC",\
-            .property = "memory-hotplug-support",\
-            .value    = "off",\
-        },{\
-            .driver   = "xio3130-downstream",\
-            .property = COMPAT_PROP_PCP,\
-            .value    = "off",\
-        },{\
-            .driver   = "ioh3420",\
-            .property = COMPAT_PROP_PCP,\
-            .value    = "off",\
-        }
+        QEMU_COMPAT_2_0
 
 #define PC_Q35_2_0_MACHINE_OPTIONS PC_Q35_2_1_MACHINE_OPTIONS
 
@@ -384,12 +371,7 @@ static QEMUMachine pc_q35_machine_v2_0 = {
 
 #define PC_Q35_COMPAT_1_7 \
         PC_Q35_COMPAT_2_0, \
-        PC_COMPAT_1_7, \
-        {\
-            .driver   = "hpet",\
-            .property = HPET_INTCAP,\
-            .value    = stringify(4),\
-        }
+        QEMU_COMPAT_1_7
 
 #define PC_Q35_1_7_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
 
@@ -405,7 +387,7 @@ static QEMUMachine pc_q35_machine_v1_7 = {
 
 #define PC_Q35_COMPAT_1_6 \
         PC_Q35_COMPAT_1_7, \
-        PC_COMPAT_1_6
+        QEMU_COMPAT_1_6
 
 #define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
 
@@ -421,7 +403,7 @@ static QEMUMachine pc_q35_machine_v1_6 = {
 
 #define PC_Q35_COMPAT_1_5 \
         PC_Q35_COMPAT_1_6, \
-        PC_COMPAT_1_5
+        QEMU_COMPAT_1_5
 
 static QEMUMachine pc_q35_machine_v1_5 = {
     PC_Q35_1_6_MACHINE_OPTIONS,
@@ -435,7 +417,7 @@ static QEMUMachine pc_q35_machine_v1_5 = {
 
 #define PC_Q35_COMPAT_1_4 \
         PC_Q35_COMPAT_1_5, \
-        PC_COMPAT_1_4
+        QEMU_COMPAT_1_4
 
 #define PC_Q35_1_4_MACHINE_OPTIONS \
     PC_Q35_1_6_MACHINE_OPTIONS, \
include/hw/boards.h +46 -0
index 709b582..fa7ceb7 100644
@@ -172,6 +172,24 @@ struct MachineState {
         .driver   = "virtio-net-pci",\
         .property = "guest_announce",\
         .value    = "off",\
+    },\
+    {\
+        .driver   = "PIIX4_PM",\
+        .property = "memory-hotplug-support",\
+        .value    = "off",\
+    },\
+    {\
+        .driver   = "ICH9-LPC",\
+        .property = "memory-hotplug-support",\
+        .value    = "off",\
+    },{\
+        .driver   = "xio3130-downstream",\
+        .property = COMPAT_PROP_PCP,\
+        .value    = "off",\
+    },{\
+        .driver   = "ioh3420",\
+        .property = COMPAT_PROP_PCP,\
+        .value    = "off",\
     }
 
 #define QEMU_COMPAT_1_7 \
@@ -179,6 +197,16 @@ struct MachineState {
         .driver   = TYPE_USB_DEVICE,\
         .property = "msos-desc",\
         .value    = "no",\
+    },\
+    {\
+        .driver   = "PIIX4_PM",\
+        .property = "acpi-pci-hotplug-with-bridge-support",\
+        .value    = "off",\
+    }, \
+    {\
+        .driver   = "hpet",\
+        .property = HPET_INTCAP,\
+        .value    = stringify(4),\
     }
 
 #define QEMU_COMPAT_1_6 \
@@ -194,6 +222,15 @@ struct MachineState {
         .driver   = "qemu32-" TYPE_X86_CPU,\
         .property = "model",\
         .value    = stringify(3),\
+    },\
+    {\
+        .driver   = "i440FX-pcihost",\
+        .property = "short_root_bus",\
+        .value    = stringify(1),\
+    },{\
+        .driver   = "q35-pcihost",\
+        .property = "short_root_bus",\
+        .value    = stringify(1),\
     }
 
 #define QEMU_COMPAT_1_5 \
@@ -229,6 +266,15 @@ struct MachineState {
         .driver = TYPE_X86_CPU,\
         .property = "pmu",\
         .value = "on",\
+    },\
+    {\
+        .driver   = "i440FX-pcihost",\
+        .property = "short_root_bus",\
+        .value    = stringify(0),\
+    },{\
+        .driver   = "q35-pcihost",\
+        .property = "short_root_bus",\
+        .value    = stringify(0),\
     }
 
 #define QEMU_COMPAT_1_4 \
include/hw/i386/pc.h +0 -43
index 631afe7..8503bee 100644
@@ -294,49 +294,6 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
 int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
-#define PC_COMPAT_2_0 \
-        QEMU_COMPAT_2_0,\
-        {\
-            .driver   = "PIIX4_PM",\
-            .property = "memory-hotplug-support",\
-            .value    = "off",\
-        }
-
-#define PC_COMPAT_1_7 \
-        QEMU_COMPAT_1_7,\
-        {\
-            .driver   = "PIIX4_PM",\
-            .property = "acpi-pci-hotplug-with-bridge-support",\
-            .value    = "off",\
-        }
-
-#define PC_COMPAT_1_6 \
-        QEMU_COMPAT_1_6,\
-        {\
-            .driver   = "i440FX-pcihost",\
-            .property = "short_root_bus",\
-            .value    = stringify(1),\
-        },{\
-            .driver   = "q35-pcihost",\
-            .property = "short_root_bus",\
-            .value    = stringify(1),\
-        }
-
-#define PC_COMPAT_1_5 \
-        QEMU_COMPAT_1_7,\
-        {\
-            .driver   = "i440FX-pcihost",\
-            .property = "short_root_bus",\
-            .value    = stringify(0),\
-        },{\
-            .driver   = "q35-pcihost",\
-            .property = "short_root_bus",\
-            .value    = stringify(0),\
-        }
-
-#define PC_COMPAT_1_4 \
-    QEMU_COMPAT_1_4
-
 #define PC_COMMON_MACHINE_OPTIONS \
     .default_boot_order = "cad"
 
Signature · 1 line
1.9.3
#18 lore raw

Re: [Qemu-devel] [PATCH 4/4] [RFC] Eliminate PC-specific compat_props

On Wed, Jun 25, 2014 at 07:55:53AM +0300, Michael S. Tsirkin wrote:
[...]

Quoted 22 lines

As far as I can tell this will break hpet,
because you set it incorrectly for PIIX

#define QEMU_COMPAT_1_7 \

 @@ -179,6 +197,16 @@ struct MachineState {
          .driver   = TYPE_USB_DEVICE,\
          .property = "msos-desc",\
          .value    = "no",\
 +    },\
 +    {\
 +        .driver   = "PIIX4_PM",\
 +        .property = "acpi-pci-hotplug-with-bridge-support",\
 +        .value    = "off",\
 +    }, \
 +    {\
 +        .driver   = "hpet",\
 +        .property = HPET_INTCAP,\
 +        .value    = stringify(4),\
      }
Quoted 5 lines

AFAIK above is appropriate for Q35 but not PIIX.

See commit log for
commit 7a10ef51c2397ac4323bc786af02c58b413b5cd2
hpet: enable to entitle more irq pins for hpet

I assume this was explained in the v2 commit message, and there was no bug here, right?

Signature · 1 line
Eduardo
#19 lore raw

Re: [Qemu-devel] [PATCH 4/4] [RFC] Eliminate PC-specific compat_props

Quoted 24 lines · Eduardo Habkost

On Wed, Jun 25, 2014 at 07:55:53AM +0300, Michael S. Tsirkin wrote:
[...]

Quoted 22 lines

As far as I can tell this will break hpet,
because you set it incorrectly for PIIX

#define QEMU_COMPAT_1_7 \

 @@ -179,6 +197,16 @@ struct MachineState {
          .driver   = TYPE_USB_DEVICE,\
          .property = "msos-desc",\
          .value    = "no",\
 +    },\
 +    {\
 +        .driver   = "PIIX4_PM",\
 +        .property = "acpi-pci-hotplug-with-bridge-support",\
 +        .value    = "off",\
 +    }, \
 +    {\
 +        .driver   = "hpet",\
 +        .property = HPET_INTCAP,\
 +        .value    = stringify(4),\
      }
Quoted 11 lines
Quoted 5 lines

AFAIK above is appropriate for Q35 but not PIIX.

See commit log for
commit 7a10ef51c2397ac4323bc786af02c58b413b5cd2
hpet: enable to entitle more irq pins for hpet

I assume this was explained in the v2 commit message, and there was no bug here, right?

Signature · 1 line
Eduardo

yes.

#20 lore raw
In reply to Eduardo Habkost
Quoted 9 lines · Eduardo Habkost

This series is an attempt to make the compat_props lists from the PC code reusable by other machine-types. All the compat bits that are on those lists are not tied to a specific machine-type, but instead to the device code that was present on a given QEMU version.

The last patch is a proposal to simply eliminate the PC-specific compat props macros, because we don't really need them today. All compat properties we have can be on global QEMU-version-specific lists, because PC-specific properties are not going to affect other machine-types anyway.

The idea is cool, the separation of which properties go to boards.h and which stay in hw/i386/pc_piix.c is not clear though (PIIX is unlikely to be wanted somewhere else but virtio is).

Quoted 12 lines

Eduardo Habkost (4):
q35: Move q35-specific compat macros to pc_q35.c
pc: Eliminate nesting of common PC_COMPAT_* macros
machine: Introduce QEMU_COMPAT_* macros [RFC] Eliminate PC-specific compat_props

 hw/i386/pc_piix.c    |  31 +++++--
 hw/i386/pc_q35.c     |  19 +++++
 include/hw/boards.h  | 207 +++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 224 ---------------------------------------------------
 4 files changed, 251 insertions(+), 230 deletions(-)
Signature · 1 line
Alexey
#21 lore raw
Quoted 6 lines · Alexey Kardashevskiy
Quoted 5 lines · Eduardo Habkost

This series is an attempt to make the compat_props lists from the PC code reusable by other machine-types. All the compat bits that are on those lists are not tied to a specific machine-type, but instead to the device code that was present on a given QEMU version.

Quoted 8 lines
Quoted 4 lines

The last patch is a proposal to simply eliminate the PC-specific compat props macros, because we don't really need them today. All compat properties we have can be on global QEMU-version-specific lists, because PC-specific properties are not going to affect other machine-types anyway.

The idea is cool, the separation of which properties go to boards.h and which stay in hw/i386/pc_piix.c is not clear though (PIIX is unlikely to be wanted somewhere else but virtio is).

virtio compat < 2.0 is not useful to non x86 either.

Quoted 20 lines
Quoted 13 lines

Eduardo Habkost (4):
q35: Move q35-specific compat macros to pc_q35.c
pc: Eliminate nesting of common PC_COMPAT_* macros
machine: Introduce QEMU_COMPAT_* macros [RFC] Eliminate PC-specific compat_props

 hw/i386/pc_piix.c    |  31 +++++--
 hw/i386/pc_q35.c     |  19 +++++
 include/hw/boards.h  | 207 +++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 224 ---------------------------------------------------
 4 files changed, 251 insertions(+), 230 deletions(-)
Signature · 1 line
Alexey
#22 lore raw
In reply to Eduardo Habkost
Quoted 9 lines · Eduardo Habkost

This series is an attempt to make the compat_props lists from the PC code reusable by other machine-types. All the compat bits that are on those lists are not tied to a specific machine-type, but instead to the device code that was present on a given QEMU version.

The last patch is a proposal to simply eliminate the PC-specific compat props macros, because we don't really need them today. All compat properties we have can be on global QEMU-version-specific lists, because PC-specific properties are not going to affect other machine-types anyway.

How was this tested?
I would suggest compiling qemu before and after this patch. stripped objects should be identical.

Quoted 14 lines

Eduardo Habkost (4):
q35: Move q35-specific compat macros to pc_q35.c
pc: Eliminate nesting of common PC_COMPAT_* macros
machine: Introduce QEMU_COMPAT_* macros [RFC] Eliminate PC-specific compat_props

 hw/i386/pc_piix.c    |  31 +++++--
 hw/i386/pc_q35.c     |  19 +++++
 include/hw/boards.h  | 207 +++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 224 ---------------------------------------------------
 4 files changed, 251 insertions(+), 230 deletions(-)
Signature · 1 line
1.9.3
#23 lore raw
In reply to Eduardo Habkost
Quoted 9 lines · Eduardo Habkost

This series is an attempt to make the compat_props lists from the PC code reusable by other machine-types. All the compat bits that are on those lists are not tied to a specific machine-type, but instead to the device code that was present on a given QEMU version.

The last patch is a proposal to simply eliminate the PC-specific compat props macros, because we don't really need them today. All compat properties we have can be on global QEMU-version-specific lists, because PC-specific properties are not going to affect other machine-types anyway.

So global properties are really not so special. They just need to be specified with <X>.<Y>=<Z> syntax. Can we just make them properties of a QEMU object?

I would like to make it possible for management to ask "what's the default value for that property with that machine type".

Need to add API to make this painless, with not more lines of code than currently.

Quoted 14 lines

Eduardo Habkost (4):
q35: Move q35-specific compat macros to pc_q35.c
pc: Eliminate nesting of common PC_COMPAT_* macros
machine: Introduce QEMU_COMPAT_* macros [RFC] Eliminate PC-specific compat_props

 hw/i386/pc_piix.c    |  31 +++++--
 hw/i386/pc_q35.c     |  19 +++++
 include/hw/boards.h  | 207 +++++++++++++++++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h | 224 ---------------------------------------------------
 4 files changed, 251 insertions(+), 230 deletions(-)
Signature · 1 line
1.9.3
#24 lore raw
Quoted 15 lines · Michael S. Tsirkin
Quoted 9 lines · Eduardo Habkost

This series is an attempt to make the compat_props lists from the PC code reusable by other machine-types. All the compat bits that are on those lists are not tied to a specific machine-type, but instead to the device code that was present on a given QEMU version.

The last patch is a proposal to simply eliminate the PC-specific compat props macros, because we don't really need them today. All compat properties we have can be on global QEMU-version-specific lists, because PC-specific properties are not going to affect other machine-types anyway.

So global properties are really not so special. They just need to be specified with <X>.<Y>=<Z> syntax. Can we just make them properties of a QEMU object?

Quoted 7 lines

I would like to make it possible for management to ask "what's the default value for that property with that machine type".

Need to add API to make this painless, with not more lines of code than currently.

We don't even have an API for asking for class property info (with no machine-type-specific data) yet. I keep asking if we are going to move towards some day. But the current plan is unclear to me, and the only available method today seems to be "just create an object and ask for its properties" (the same seems to be necessary even for listing the available property _names_).

There has been some discussion about it at:
http://marc.info/?l=qemu-devel&m=139170340408156
but the conclusion was unclear.

Signature · 1 line
Eduardo