Skip to contentSkip to conversation

make SMBUS/SATA/PIT configurable and introduce

PATCH In review Chao Peng 3 participants 12 messages Nov 5, 2016 – Dec 14, 2016

lore
Share & tools
lore

Chao Peng

author
#0 lore raw

cover make SMBUS/SATA/PIT configurable and introduce

This patchset makes SMBUS/SATA/PIT configurable and introduces a new machine type q35-lite with these features disabled by default. This is useful for creating light weight virtual machine without boot time penalty when these devices are unused.

See https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg00422.html
for the background.

Chao Peng (4):
pc: make smbus configurable
pc: make sata configurable
pc: make pit configurable
q35: introduce q35-lite

 hw/i386/pc.c         | 68 +++++++++++++++++++++++++++++++++++++++++++++++-----
 hw/i386/pc_piix.c    |  2 +-
 hw/i386/pc_q35.c     | 57 ++++++++++++++++++++++++++++++-------------
 include/hw/i386/pc.h |  8 +++++++
 4 files changed, 112 insertions(+), 23 deletions(-)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/4 pc: make smbus configurable

---
 hw/i386/pc.c         | 18 ++++++++++++++++++
 hw/i386/pc_q35.c     | 12 +++++++-----
 include/hw/i386/pc.h |  3 +++
 3 files changed, 28 insertions(+), 5 deletions(-)
hw/i386/pc.c +18 -0
index c011552..95d68d5 100644
@@ -2180,6 +2180,20 @@ static void pc_machine_set_nvdimm(Object *obj, bool value, Error **errp)
     pcms->acpi_nvdimm_state.is_enabled = value;
 }
 
+static bool pc_machine_get_smbus(Object *obj, Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+
+    return pcms->smbus;
+}
+
+static void pc_machine_set_smbus(Object *obj, bool value, Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+
+    pcms->smbus = value;
+}
+
 static void pc_machine_initfn(Object *obj)
 {
     PCMachineState *pcms = PC_MACHINE(obj);
@@ -2189,6 +2203,7 @@ static void pc_machine_initfn(Object *obj)
     pcms->vmport = ON_OFF_AUTO_AUTO;
     /* nvdimm is disabled on default. */
     pcms->acpi_nvdimm_state.is_enabled = false;
+    pcms->smbus = true;
 }
 
 static void pc_machine_reset(void)
@@ -2350,6 +2365,9 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
 
     object_class_property_add_bool(oc, PC_MACHINE_NVDIMM,
         pc_machine_get_nvdimm, pc_machine_set_nvdimm, &error_abort);
+
+    object_class_property_add_bool(oc, PC_MACHINE_SMBUS,
+        pc_machine_get_smbus, pc_machine_set_smbus, &error_abort);
 }
 
 static const TypeInfo pc_machine_info = {
hw/i386/pc_q35.c +7 -5
index b40d19e..5efc65a 100644
@@ -248,11 +248,13 @@ static void pc_q35_init(MachineState *machine)
         ehci_create_ich9_with_companions(host_bus, 0x1d);
     }
 
-    /* TODO: Populate SPD eeprom data.  */
-    smbus_eeprom_init(ich9_smb_init(host_bus,
-                                    PCI_DEVFN(ICH9_SMB_DEV, ICH9_SMB_FUNC),
-                                    0xb100),
-                      8, NULL, 0);
+    if (pcms->smbus) {
+        /* TODO: Populate SPD eeprom data.  */
+        smbus_eeprom_init(ich9_smb_init(host_bus,
+                                        PCI_DEVFN(ICH9_SMB_DEV, ICH9_SMB_FUNC),
+                                        0xb100),
+                          8, NULL, 0);
+    }
 
     pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
 
include/hw/i386/pc.h +3 -0
index 98dc772..dfa1129 100644
@@ -62,6 +62,8 @@ struct PCMachineState {
 
     AcpiNVDIMMState acpi_nvdimm_state;
 
+    bool smbus;
+
     /* RAM information (sizes, addresses, configuration): */
     ram_addr_t below_4g_mem_size, above_4g_mem_size;
 
@@ -86,6 +88,7 @@ struct PCMachineState {
 #define PC_MACHINE_VMPORT           "vmport"
 #define PC_MACHINE_SMM              "smm"
 #define PC_MACHINE_NVDIMM           "nvdimm"
+#define PC_MACHINE_SMBUS            "smbus"
 
 /**
  * PCMachineClass:
Signature · 1 line
1.8.3.1
author
#4 lore raw

PATCH 4/4 q35: introduce q35-lite

In reply to Chao Peng

This patch introduces a light weight machine type which shares the same codebase with existing q35 machine type but with some features disabled by default.

---
 hw/i386/pc_q35.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
hw/i386/pc_q35.c +18 -0
index d042fe0..1c6b476 100644
@@ -276,6 +276,15 @@ static void pc_q35_init(MachineState *machine)
     }
 }
 
+static void pc_q35_lite_init(MachineState *machine)
+{
+    PCMachineState *pcms = PC_MACHINE(machine);
+
+    pcms->smbus = false;
+    pcms->sata = false;
+    pcms->pit = false;
+}
+
 #define DEFINE_Q35_MACHINE(suffix, name, compatfn, optionfn) \
     static void pc_init_##suffix(MachineState *machine) \
     { \
@@ -301,6 +310,15 @@ static void pc_q35_machine_options(MachineClass *m)
     m->max_cpus = 288;
 }
 
+static void pc_q35_lite_machine_options(MachineClass *m)
+{
+    pc_q35_machine_options(m);
+    m->alias = "q35-lite";
+}
+
+DEFINE_Q35_MACHINE(lite, "pc-q35-lite", pc_q35_lite_init,
+                   pc_q35_lite_machine_options);
+
 static void pc_q35_2_8_machine_options(MachineClass *m)
 {
     pc_q35_machine_options(m);
Signature · 1 line
1.8.3.1
author
#2 lore raw

PATCH 2/4 pc: make sata configurable

In reply to Chao Peng
---
 hw/i386/pc.c         | 29 ++++++++++++++++++++++++-----
 hw/i386/pc_q35.c     | 24 ++++++++++++++----------
 include/hw/i386/pc.h |  2 ++
 3 files changed, 40 insertions(+), 15 deletions(-)
hw/i386/pc.c +24 -5
index 95d68d5..c5c65ce 100644
@@ -400,13 +400,13 @@ static void pc_cmos_init_late(void *opaque)
     int i, trans;
 
     val = 0;
-    if (ide_get_geometry(arg->idebus[0], 0,
-                         &cylinders, &heads, &sectors) >= 0) {
+    if (arg->idebus[0] && ide_get_geometry(arg->idebus[0], 0,
+                                           &cylinders, &heads, &sectors) >= 0) {
         cmos_init_hd(s, 0x19, 0x1b, cylinders, heads, sectors);
         val |= 0xf0;
     }
-    if (ide_get_geometry(arg->idebus[0], 1,
-                         &cylinders, &heads, &sectors) >= 0) {
+    if (arg->idebus[0] && ide_get_geometry(arg->idebus[0], 1,
+                                           &cylinders, &heads, &sectors) >= 0) {
         cmos_init_hd(s, 0x1a, 0x24, cylinders, heads, sectors);
         val |= 0x0f;
     }
@@ -418,7 +418,8 @@ static void pc_cmos_init_late(void *opaque)
            geometry.  It is always such that: 1 <= sects <= 63, 1
            <= heads <= 16, 1 <= cylinders <= 16383. The BIOS
            geometry can be different if a translation is done. */
-        if (ide_get_geometry(arg->idebus[i / 2], i % 2,
+        if (arg->idebus[i / 2] &&
+            ide_get_geometry(arg->idebus[i / 2], i % 2,
                              &cylinders, &heads, &sectors) >= 0) {
             trans = ide_get_bios_chs_trans(arg->idebus[i / 2], i % 2) - 1;
             assert((trans & ~3) == 0);
@@ -2194,6 +2195,20 @@ static void pc_machine_set_smbus(Object *obj, bool value, Error **errp)
     pcms->smbus = value;
 }
 
+static bool pc_machine_get_sata(Object *obj, Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+
+    return pcms->sata;
+}
+
+static void pc_machine_set_sata(Object *obj, bool value, Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+
+    pcms->sata = value;
+}
+
 static void pc_machine_initfn(Object *obj)
 {
     PCMachineState *pcms = PC_MACHINE(obj);
@@ -2204,6 +2219,7 @@ static void pc_machine_initfn(Object *obj)
     /* nvdimm is disabled on default. */
     pcms->acpi_nvdimm_state.is_enabled = false;
     pcms->smbus = true;
+    pcms->sata = true;
 }
 
 static void pc_machine_reset(void)
@@ -2368,6 +2384,9 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
 
     object_class_property_add_bool(oc, PC_MACHINE_SMBUS,
         pc_machine_get_smbus, pc_machine_set_smbus, &error_abort);
+
+    object_class_property_add_bool(oc, PC_MACHINE_SATA,
+        pc_machine_get_sata, pc_machine_set_sata, &error_abort);
 }
 
 static const TypeInfo pc_machine_info = {
hw/i386/pc_q35.c +14 -10
index 5efc65a..205c33e 100644
@@ -232,16 +232,20 @@ static void pc_q35_init(MachineState *machine)
     /* connect pm stuff to lpc */
     ich9_lpc_pm_init(lpc, pc_machine_is_smm_enabled(pcms));
 
-    /* ahci and SATA device, for q35 1 ahci controller is built-in */
-    ahci = pci_create_simple_multifunction(host_bus,
-                                           PCI_DEVFN(ICH9_SATA1_DEV,
-                                                     ICH9_SATA1_FUNC),
-                                           true, "ich9-ahci");
-    idebus[0] = qdev_get_child_bus(&ahci->qdev, "ide.0");
-    idebus[1] = qdev_get_child_bus(&ahci->qdev, "ide.1");
-    g_assert(MAX_SATA_PORTS == ICH_AHCI(ahci)->ahci.ports);
-    ide_drive_get(hd, ICH_AHCI(ahci)->ahci.ports);
-    ahci_ide_create_devs(ahci, hd);
+    if (pcms->sata) {
+        /* ahci and SATA device, for q35 1 ahci controller is built-in */
+        ahci = pci_create_simple_multifunction(host_bus,
+                                               PCI_DEVFN(ICH9_SATA1_DEV,
+                                                         ICH9_SATA1_FUNC),
+                                               true, "ich9-ahci");
+        idebus[0] = qdev_get_child_bus(&ahci->qdev, "ide.0");
+        idebus[1] = qdev_get_child_bus(&ahci->qdev, "ide.1");
+        g_assert(MAX_SATA_PORTS == ICH_AHCI(ahci)->ahci.ports);
+        ide_drive_get(hd, ICH_AHCI(ahci)->ahci.ports);
+        ahci_ide_create_devs(ahci, hd);
+    } else {
+        idebus[0] = idebus[1] = NULL;
+    }
 
     if (machine_usb(machine)) {
         /* Should we create 6 UHCI according to ich9 spec? */
include/hw/i386/pc.h +2 -0
index dfa1129..d7dfda6 100644
@@ -63,6 +63,7 @@ struct PCMachineState {
     AcpiNVDIMMState acpi_nvdimm_state;
 
     bool smbus;
+    bool sata;
 
     /* RAM information (sizes, addresses, configuration): */
     ram_addr_t below_4g_mem_size, above_4g_mem_size;
@@ -89,6 +90,7 @@ struct PCMachineState {
 #define PC_MACHINE_SMM              "smm"
 #define PC_MACHINE_NVDIMM           "nvdimm"
 #define PC_MACHINE_SMBUS            "smbus"
+#define PC_MACHINE_SATA             "sata"
 
 /**
  * PCMachineClass:
Signature · 1 line
1.8.3.1
author
#3 lore raw

PATCH 3/4 pc: make pit configurable

In reply to Chao Peng
---
 hw/i386/pc.c         | 21 ++++++++++++++++++++-
 hw/i386/pc_piix.c    |  2 +-
 hw/i386/pc_q35.c     |  3 ++-
 include/hw/i386/pc.h |  3 +++
 4 files changed, 26 insertions(+), 3 deletions(-)
hw/i386/pc.c +20 -1
index c5c65ce..f58c75c 100644
@@ -1539,6 +1539,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
                           ISADevice **rtc_state,
                           bool create_fdctrl,
                           bool no_vmport,
+                          bool has_pit,
                           uint32_t hpet_irqs)
 {
     int i;
@@ -1592,7 +1593,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
 
     qemu_register_boot_set(pc_boot_set, *rtc_state);
 
-    if (!xen_enabled()) {
+    if (!xen_enabled() && has_pit) {
         if (kvm_pit_in_kernel()) {
             pit = kvm_pit_init(isa_bus, 0x40);
         } else {
@@ -2209,6 +2210,20 @@ static void pc_machine_set_sata(Object *obj, bool value, Error **errp)
     pcms->sata = value;
 }
 
+static bool pc_machine_get_pit(Object *obj, Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+
+    return pcms->pit;
+}
+
+static void pc_machine_set_pit(Object *obj, bool value, Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+
+    pcms->pit = value;
+}
+
 static void pc_machine_initfn(Object *obj)
 {
     PCMachineState *pcms = PC_MACHINE(obj);
@@ -2220,6 +2235,7 @@ static void pc_machine_initfn(Object *obj)
     pcms->acpi_nvdimm_state.is_enabled = false;
     pcms->smbus = true;
     pcms->sata = true;
+    pcms->pit = true;
 }
 
 static void pc_machine_reset(void)
@@ -2387,6 +2403,9 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
 
     object_class_property_add_bool(oc, PC_MACHINE_SATA,
         pc_machine_get_sata, pc_machine_set_sata, &error_abort);
+
+    object_class_property_add_bool(oc, PC_MACHINE_PIT,
+        pc_machine_get_pit, pc_machine_set_pit, &error_abort);
 }
 
 static const TypeInfo pc_machine_info = {
hw/i386/pc_piix.c +1 -1
index a54a468..5e1adbe 100644
@@ -235,7 +235,7 @@ static void pc_init1(MachineState *machine,
 
     /* init basic PC hardware */
     pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, true,
-                         (pcms->vmport != ON_OFF_AUTO_ON), 0x4);
+                         (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit, 0x4);
 
     pc_nic_init(isa_bus, pci_bus);
 
hw/i386/pc_q35.c +2 -1
index 205c33e..d042fe0 100644
@@ -227,7 +227,8 @@ static void pc_q35_init(MachineState *machine)
 
     /* init basic PC hardware */
     pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, !mc->no_floppy,
-                         (pcms->vmport != ON_OFF_AUTO_ON), 0xff0104);
+                         (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit,
+                         0xff0104);
 
     /* connect pm stuff to lpc */
     ich9_lpc_pm_init(lpc, pc_machine_is_smm_enabled(pcms));
include/hw/i386/pc.h +3 -0
index d7dfda6..5fb03c0 100644
@@ -64,6 +64,7 @@ struct PCMachineState {
 
     bool smbus;
     bool sata;
+    bool pit;
 
     /* RAM information (sizes, addresses, configuration): */
     ram_addr_t below_4g_mem_size, above_4g_mem_size;
@@ -91,6 +92,7 @@ struct PCMachineState {
 #define PC_MACHINE_NVDIMM           "nvdimm"
 #define PC_MACHINE_SMBUS            "smbus"
 #define PC_MACHINE_SATA             "sata"
+#define PC_MACHINE_PIT              "pit"
 
 /**
  * PCMachineClass:
@@ -263,6 +265,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
                           ISADevice **rtc_state,
                           bool create_fdctrl,
                           bool no_vmport,
+                          bool has_pit,
                           uint32_t hpet_irqs);
 void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd);
 void pc_cmos_init(PCMachineState *pcms,
Signature · 1 line
1.8.3.1
#5 lore raw

Re: [Qemu-devel] [PATCH 4/4] q35: introduce q35-lite

In reply to Chao Peng
Quoted 5 lines · Chao Peng

This patch introduces a light weight machine type which shares the same codebase with existing q35 machine type but with some features disabled by default.

I don't find this too useful, but if others do and send acks, I'll merge it, but only if it also has migration disabled.

Quoted 42 lines
---
 hw/i386/pc_q35.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
hw/i386/pc_q35.c +18 -0
index d042fe0..1c6b476 100644
@@ -276,6 +276,15 @@ static void pc_q35_init(MachineState *machine)
     }
 }
 
+static void pc_q35_lite_init(MachineState *machine)
+{
+    PCMachineState *pcms = PC_MACHINE(machine);
+
+    pcms->smbus = false;
+    pcms->sata = false;
+    pcms->pit = false;
+}
+
 #define DEFINE_Q35_MACHINE(suffix, name, compatfn, optionfn) \
     static void pc_init_##suffix(MachineState *machine) \
     { \
@@ -301,6 +310,15 @@ static void pc_q35_machine_options(MachineClass *m)
     m->max_cpus = 288;
 }
 
+static void pc_q35_lite_machine_options(MachineClass *m)
+{
+    pc_q35_machine_options(m);
+    m->alias = "q35-lite";
+}
+
+DEFINE_Q35_MACHINE(lite, "pc-q35-lite", pc_q35_lite_init,
+                   pc_q35_lite_machine_options);
+
 static void pc_q35_2_8_machine_options(MachineClass *m)
 {
     pc_q35_machine_options(m);
Signature · 1 line
1.8.3.1
#6 lore raw

Re: [Qemu-devel] [PATCH 4/4] q35: introduce q35-lite

Quoted 9 lines · Michael S. Tsirkin
Quoted 5 lines · Chao Peng
Quoted 5 lines

This patch introduces a light weight machine type which shares the same codebase with existing q35 machine type but with some features disabled by default.

I don't find this too useful, but if others do and send acks, I'll merge it, but only if it also has migration disabled.

Agreed, it's enough to have patches 1-3.

Paolo

Reviewed-by on the v1 series
#10 lore raw
In reply to Chao Peng
Quoted 7 lines · Chao Peng

This patchset makes SMBUS/SATA/PIT configurable and introduces a new machine type q35-lite with these features disabled by default. This is useful for creating light weight virtual machine without boot time penalty when these devices are unused.

See https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg00422.html
for the background.

As we are in freeze now, please remember to re-test and ping after the release to get this applied.

Quoted 14 lines

Chao Peng (4):
pc: make smbus configurable
pc: make sata configurable
pc: make pit configurable
q35: introduce q35-lite

 hw/i386/pc.c         | 68 +++++++++++++++++++++++++++++++++++++++++++++++-----
 hw/i386/pc_piix.c    |  2 +-
 hw/i386/pc_q35.c     | 57 ++++++++++++++++++++++++++++++-------------
 include/hw/i386/pc.h |  8 +++++++
 4 files changed, 112 insertions(+), 23 deletions(-)
Signature · 1 line
1.8.3.1
author
#11 lore raw
Quoted 13 lines · Michael S. Tsirkin
Quoted 11 lines · Chao Peng

This patchset makes SMBUS/SATA/PIT configurable and introduces a new
machine type q35-lite with these features disabled by default. This is
useful for creating light weight virtual machine without boot time penalty when these devices are unused.

See https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg00422.
html
for the background.

Quoted 6 lines

As we are in freeze now, please remember to re-test and ping after the
release to get this applied.

Sure, I will ping you after the re-testing.

Thanks,
Chao

Quoted 19 lines
Quoted 18 lines

Chao Peng (4):
  pc: make smbus configurable
  pc: make sata configurable
  pc: make pit configurable
  q35: introduce q35-lite

 hw/i386/pc.c         | 68
+++++++++++++++++++++++++++++++++++++++++++++++-----
 hw/i386/pc_piix.c    |  2 +-
 hw/i386/pc_q35.c     | 57 ++++++++++++++++++++++++++++++--------
-----
 include/hw/i386/pc.h |  8 +++++++

 4 files changed, 112 insertions(+), 23 deletions(-)

--
1.8.3.1

author
#7 lore raw

Re: [Qemu-devel] [PATCH 4/4] q35: introduce q35-lite

In reply to Paolo Bonzini
Quoted 12 lines · Paolo Bonzini
Quoted 10 lines · Michael S. Tsirkin
Quoted 8 lines · Chao Peng
Quoted 8 lines

This patch introduces a light weight machine type which shares the
same codebase with existing q35 machine type but with some features
disabled by default.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

I don't find this too useful, but if others do and send acks, I'll merge
it, but only if it also has migration disabled.

Agreed, it's enough to have patches 1-3.

I'm fine.

#8 lore raw

Re: [Qemu-devel] [PATCH 4/4] q35: introduce q35-lite

Quoted 19 lines · Chao Peng
Quoted 18 lines · Paolo Bonzini
Quoted 15 lines · Michael S. Tsirkin
Quoted 9 lines · Chao Peng
Quoted 9 lines

This patch introduces a light weight machine type which shares the
same codebase with existing q35 machine type but with some features
disabled by default.

I don't find this too useful, but if others do and send acks, I'll merge
it, but only if it also has migration disabled.

Quoted 4 lines
Quoted 2 lines

Agreed, it's enough to have patches 1-3.

I'm fine.

Pls post just the correct patches after the release.

#9 lore raw

Re: [Qemu-devel] [PATCH 4/4] q35: introduce q35-lite

Quoted 20 lines · Michael S. Tsirkin
Quoted 19 lines · Chao Peng
Quoted 18 lines · Paolo Bonzini
Quoted 15 lines · Michael S. Tsirkin
Quoted 9 lines · Chao Peng
Quoted 9 lines

This patch introduces a light weight machine type which shares the
same codebase with existing q35 machine type but with some features
disabled by default.

I don't find this too useful, but if others do and send acks, I'll merge
it, but only if it also has migration disabled.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Agreed, it's enough to have patches 1-3.

I'm fine.

Pls post just the correct patches after the release.

Since I was cleaning my inbox, I've already queued 1-3.

Paolo