diff mbox

[1/6] pc: introduce 2.5 machine type

Message ID 1440147950-1178-2-git-send-email-jasowang@redhat.com
State New
Headers show

Commit Message

Jason Wang Aug. 21, 2015, 9:05 a.m. UTC
This will be used by virtio 1.0 virtio-pci virtqueue migration
backward compatibility.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/i386/pc_piix.c    | 21 +++++++++++++++++++--
 hw/i386/pc_q35.c     | 23 +++++++++++++++++++++--
 include/hw/compat.h  |  3 +++
 include/hw/i386/pc.h |  3 +++
 4 files changed, 46 insertions(+), 4 deletions(-)

Comments

Eduardo Habkost Aug. 21, 2015, 3:47 p.m. UTC | #1
On Fri, Aug 21, 2015 at 05:05:45PM +0800, Jason Wang wrote:
[...]
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index a896624..2a7b7d9 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -304,9 +304,15 @@ static void pc_init1(MachineState *machine)
>      }
>  }
>  
> +static void pc_compat_2_4(MachineState *machine)
> +{
> +}
> +
>  static void pc_compat_2_3(MachineState *machine)
>  {
>      PCMachineState *pcms = PC_MACHINE(machine);
> +
> +    pc_compat_2_4(machine);
>      savevm_skip_section_footers();
>      if (kvm_enabled()) {
>          pcms->smm = ON_OFF_AUTO_OFF;
> @@ -477,7 +483,7 @@ static void pc_i440fx_machine_options(MachineClass *m)
>      m->hot_add_cpu = pc_hot_add_cpu;
>  }
>  
> -static void pc_i440fx_2_4_machine_options(MachineClass *m)
> +static void pc_i440fx_2_5_machine_options(MachineClass *m)
>  {
>      pc_i440fx_machine_options(m);
>      m->default_machine_opts = "firmware=bios-256k.bin";
> @@ -486,7 +492,18 @@ static void pc_i440fx_2_4_machine_options(MachineClass *m)
>      m->is_default = 1;
>  }
>  
> -DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL,
> +DEFINE_I440FX_MACHINE(v2_5, "pc-i440fx-2.5", NULL,
> +                      pc_i440fx_2_5_machine_options)
> +
> +static void pc_i440fx_2_4_machine_options(MachineClass *m)
> +{
> +    pc_i440fx_machine_options(m);
> +    m->default_machine_opts = "firmware=bios-256k.bin";
> +    m->default_display = "std";
> +    SET_MACHINE_COMPAT(m, PC_COMPAT_2_4);

Please don't duplicate pc_i440fx_2_5_machine_options() code here. Call
pc_i440fx_2_5_machine_options() instead.

Otherwise pc-2.4 will never inherit the compat settings from pc-2.8,
pc-2.7, pc-2.6, when we create those machines.
Jason Wang Aug. 24, 2015, 5:45 a.m. UTC | #2
On 08/21/2015 11:47 PM, Eduardo Habkost wrote:
> On Fri, Aug 21, 2015 at 05:05:45PM +0800, Jason Wang wrote:
> [...]
>> > diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
>> > index a896624..2a7b7d9 100644
>> > --- a/hw/i386/pc_piix.c
>> > +++ b/hw/i386/pc_piix.c
>> > @@ -304,9 +304,15 @@ static void pc_init1(MachineState *machine)
>> >      }
>> >  }
>> >  
>> > +static void pc_compat_2_4(MachineState *machine)
>> > +{
>> > +}
>> > +
>> >  static void pc_compat_2_3(MachineState *machine)
>> >  {
>> >      PCMachineState *pcms = PC_MACHINE(machine);
>> > +
>> > +    pc_compat_2_4(machine);
>> >      savevm_skip_section_footers();
>> >      if (kvm_enabled()) {
>> >          pcms->smm = ON_OFF_AUTO_OFF;
>> > @@ -477,7 +483,7 @@ static void pc_i440fx_machine_options(MachineClass *m)
>> >      m->hot_add_cpu = pc_hot_add_cpu;
>> >  }
>> >  
>> > -static void pc_i440fx_2_4_machine_options(MachineClass *m)
>> > +static void pc_i440fx_2_5_machine_options(MachineClass *m)
>> >  {
>> >      pc_i440fx_machine_options(m);
>> >      m->default_machine_opts = "firmware=bios-256k.bin";
>> > @@ -486,7 +492,18 @@ static void pc_i440fx_2_4_machine_options(MachineClass *m)
>> >      m->is_default = 1;
>> >  }
>> >  
>> > -DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL,
>> > +DEFINE_I440FX_MACHINE(v2_5, "pc-i440fx-2.5", NULL,
>> > +                      pc_i440fx_2_5_machine_options)
>> > +
>> > +static void pc_i440fx_2_4_machine_options(MachineClass *m)
>> > +{
>> > +    pc_i440fx_machine_options(m);
>> > +    m->default_machine_opts = "firmware=bios-256k.bin";
>> > +    m->default_display = "std";
>> > +    SET_MACHINE_COMPAT(m, PC_COMPAT_2_4);
> Please don't duplicate pc_i440fx_2_5_machine_options() code here. Call
> pc_i440fx_2_5_machine_options() instead.
>
> Otherwise pc-2.4 will never inherit the compat settings from pc-2.8,
> pc-2.7, pc-2.6, when we create those machines.

Right, will fix this in V2.

Thanks
diff mbox

Patch

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index a896624..2a7b7d9 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -304,9 +304,15 @@  static void pc_init1(MachineState *machine)
     }
 }
 
+static void pc_compat_2_4(MachineState *machine)
+{
+}
+
 static void pc_compat_2_3(MachineState *machine)
 {
     PCMachineState *pcms = PC_MACHINE(machine);
+
+    pc_compat_2_4(machine);
     savevm_skip_section_footers();
     if (kvm_enabled()) {
         pcms->smm = ON_OFF_AUTO_OFF;
@@ -477,7 +483,7 @@  static void pc_i440fx_machine_options(MachineClass *m)
     m->hot_add_cpu = pc_hot_add_cpu;
 }
 
-static void pc_i440fx_2_4_machine_options(MachineClass *m)
+static void pc_i440fx_2_5_machine_options(MachineClass *m)
 {
     pc_i440fx_machine_options(m);
     m->default_machine_opts = "firmware=bios-256k.bin";
@@ -486,7 +492,18 @@  static void pc_i440fx_2_4_machine_options(MachineClass *m)
     m->is_default = 1;
 }
 
-DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL,
+DEFINE_I440FX_MACHINE(v2_5, "pc-i440fx-2.5", NULL,
+                      pc_i440fx_2_5_machine_options)
+
+static void pc_i440fx_2_4_machine_options(MachineClass *m)
+{
+    pc_i440fx_machine_options(m);
+    m->default_machine_opts = "firmware=bios-256k.bin";
+    m->default_display = "std";
+    SET_MACHINE_COMPAT(m, PC_COMPAT_2_4);
+}
+
+DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", pc_compat_2_4,
                       pc_i440fx_2_4_machine_options)
 
 
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 974aead..88d3076 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -287,9 +287,15 @@  static void pc_q35_init(MachineState *machine)
     }
 }
 
+static void pc_compat_2_4(MachineState *machine)
+{
+}
+
 static void pc_compat_2_3(MachineState *machine)
 {
     PCMachineState *pcms = PC_MACHINE(machine);
+
+    pc_compat_2_4(machine);
     savevm_skip_section_footers();
     if (kvm_enabled()) {
         pcms->smm = ON_OFF_AUTO_OFF;
@@ -392,7 +398,7 @@  static void pc_q35_machine_options(MachineClass *m)
     m->units_per_default_bus = 1;
 }
 
-static void pc_q35_2_4_machine_options(MachineClass *m)
+static void pc_q35_2_5_machine_options(MachineClass *m)
 {
     pc_q35_machine_options(m);
     m->default_machine_opts = "firmware=bios-256k.bin";
@@ -402,7 +408,20 @@  static void pc_q35_2_4_machine_options(MachineClass *m)
     m->alias = "q35";
 }
 
-DEFINE_Q35_MACHINE(v2_4, "pc-q35-2.4", NULL,
+DEFINE_Q35_MACHINE(v2_5, "pc-q35-2.5", NULL,
+                   pc_q35_2_5_machine_options);
+
+static void pc_q35_2_4_machine_options(MachineClass *m)
+{
+    pc_q35_machine_options(m);
+    m->default_machine_opts = "firmware=bios-256k.bin";
+    m->default_display = "std";
+    m->no_floppy = 1;
+    m->no_tco = 0;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_2_4);
+}
+
+DEFINE_Q35_MACHINE(v2_4, "pc-q35-2.4", pc_compat_2_4,
                    pc_q35_2_4_machine_options);
 
 
diff --git a/include/hw/compat.h b/include/hw/compat.h
index 94c8097..095de5d 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -1,6 +1,9 @@ 
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
+#define HW_COMPAT_2_4 \
+        /* empty */
+
 #define HW_COMPAT_2_3 \
         {\
             .driver   = "virtio-blk-pci",\
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 954203d..156b4ef 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -292,6 +292,9 @@  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_4 \
+        HW_COMPAT_2_4
+
 #define PC_COMPAT_2_3 \
         HW_COMPAT_2_3 \
         {\