[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 76/86] hw/i386: Make pit a property of common x86 base machine
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 76/86] hw/i386: Make pit a property of common x86 base machine type |
Date: |
Mon, 16 May 2022 16:55:23 -0400 |
From: Xiaoyao Li <xiaoyao.li@intel.com>
Both pc and microvm have pit property individually. Let's just make it
the property of common x86 base machine type.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Sergio Lopez <slp@redhat.com>
Message-Id: <20220310122811.807794-2-xiaoyao.li@intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/i386/microvm.h | 2 --
include/hw/i386/pc.h | 2 --
include/hw/i386/x86.h | 2 ++
hw/i386/microvm.c | 27 +--------------------------
hw/i386/pc.c | 24 +++---------------------
hw/i386/x86.c | 25 +++++++++++++++++++++++++
6 files changed, 31 insertions(+), 51 deletions(-)
diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h
index efcbd926fd..83f9ac0b2a 100644
--- a/include/hw/i386/microvm.h
+++ b/include/hw/i386/microvm.h
@@ -67,7 +67,6 @@
#define PCIE_ECAM_SIZE 0x10000000
/* Machine type options */
-#define MICROVM_MACHINE_PIT "pit"
#define MICROVM_MACHINE_PIC "pic"
#define MICROVM_MACHINE_RTC "rtc"
#define MICROVM_MACHINE_PCIE "pcie"
@@ -87,7 +86,6 @@ struct MicrovmMachineState {
/* Machine type options */
OnOffAuto pic;
- OnOffAuto pit;
OnOffAuto rtc;
OnOffAuto pcie;
OnOffAuto ioapic2;
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index aff8add155..ffcac5121e 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -46,7 +46,6 @@ typedef struct PCMachineState {
bool acpi_build_enabled;
bool smbus_enabled;
bool sata_enabled;
- bool pit_enabled;
bool hpet_enabled;
bool i8042_enabled;
bool default_bus_bypass_iommu;
@@ -64,7 +63,6 @@ typedef struct PCMachineState {
#define PC_MACHINE_VMPORT "vmport"
#define PC_MACHINE_SMBUS "smbus"
#define PC_MACHINE_SATA "sata"
-#define PC_MACHINE_PIT "pit"
#define PC_MACHINE_I8042 "i8042"
#define PC_MACHINE_MAX_FW_SIZE "max-fw-size"
#define PC_MACHINE_SMBIOS_EP "smbios-entry-point-type"
diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
index 4841a49f86..b81fce54a0 100644
--- a/include/hw/i386/x86.h
+++ b/include/hw/i386/x86.h
@@ -65,6 +65,7 @@ struct X86MachineState {
OnOffAuto smm;
OnOffAuto acpi;
+ OnOffAuto pit;
char *oem_id;
char *oem_table_id;
@@ -84,6 +85,7 @@ struct X86MachineState {
#define X86_MACHINE_SMM "smm"
#define X86_MACHINE_ACPI "acpi"
+#define X86_MACHINE_PIT "pit"
#define X86_MACHINE_OEM_ID "x-oem-id"
#define X86_MACHINE_OEM_TABLE_ID "x-oem-table-id"
#define X86_MACHINE_BUS_LOCK_RATELIMIT "bus-lock-ratelimit"
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index 4b3b1dd262..89b555a2f5 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -257,7 +257,7 @@ static void microvm_devices_init(MicrovmMachineState *mms)
g_free(i8259);
}
- if (mms->pit == ON_OFF_AUTO_ON || mms->pit == ON_OFF_AUTO_AUTO) {
+ if (x86ms->pit == ON_OFF_AUTO_ON || x86ms->pit == ON_OFF_AUTO_AUTO) {
if (kvm_pit_in_kernel()) {
kvm_pit_init(isa_bus, 0x40);
} else {
@@ -508,23 +508,6 @@ static void microvm_machine_set_pic(Object *obj, Visitor
*v, const char *name,
visit_type_OnOffAuto(v, name, &mms->pic, errp);
}
-static void microvm_machine_get_pit(Object *obj, Visitor *v, const char *name,
- void *opaque, Error **errp)
-{
- MicrovmMachineState *mms = MICROVM_MACHINE(obj);
- OnOffAuto pit = mms->pit;
-
- visit_type_OnOffAuto(v, name, &pit, errp);
-}
-
-static void microvm_machine_set_pit(Object *obj, Visitor *v, const char *name,
- void *opaque, Error **errp)
-{
- MicrovmMachineState *mms = MICROVM_MACHINE(obj);
-
- visit_type_OnOffAuto(v, name, &mms->pit, errp);
-}
-
static void microvm_machine_get_rtc(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
@@ -650,7 +633,6 @@ static void microvm_machine_initfn(Object *obj)
/* Configuration */
mms->pic = ON_OFF_AUTO_AUTO;
- mms->pit = ON_OFF_AUTO_AUTO;
mms->rtc = ON_OFF_AUTO_AUTO;
mms->pcie = ON_OFF_AUTO_AUTO;
mms->ioapic2 = ON_OFF_AUTO_AUTO;
@@ -709,13 +691,6 @@ static void microvm_class_init(ObjectClass *oc, void *data)
object_class_property_set_description(oc, MICROVM_MACHINE_PIC,
"Enable i8259 PIC");
- object_class_property_add(oc, MICROVM_MACHINE_PIT, "OnOffAuto",
- microvm_machine_get_pit,
- microvm_machine_set_pit,
- NULL, NULL);
- object_class_property_set_description(oc, MICROVM_MACHINE_PIT,
- "Enable i8254 PIT");
-
object_class_property_add(oc, MICROVM_MACHINE_RTC, "OnOffAuto",
microvm_machine_get_rtc,
microvm_machine_set_rtc,
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 15f37d8dc6..7c39c91335 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1123,6 +1123,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
ISADevice *pit = NULL;
MemoryRegion *ioport80_io = g_new(MemoryRegion, 1);
MemoryRegion *ioportF0_io = g_new(MemoryRegion, 1);
+ X86MachineState *x86ms = X86_MACHINE(pcms);
memory_region_init_io(ioport80_io, NULL, &ioport80_io_ops, NULL,
"ioport80", 1);
memory_region_add_subregion(isa_bus->address_space_io, 0x80, ioport80_io);
@@ -1167,7 +1168,8 @@ void pc_basic_device_init(struct PCMachineState *pcms,
qemu_register_boot_set(pc_boot_set, *rtc_state);
- if (!xen_enabled() && pcms->pit_enabled) {
+ if (!xen_enabled() &&
+ (x86ms->pit == ON_OFF_AUTO_AUTO || x86ms->pit == ON_OFF_AUTO_ON)) {
if (kvm_pit_in_kernel()) {
pit = kvm_pit_init(isa_bus, 0x40);
} else {
@@ -1537,20 +1539,6 @@ static void pc_machine_set_sata(Object *obj, bool value,
Error **errp)
pcms->sata_enabled = value;
}
-static bool pc_machine_get_pit(Object *obj, Error **errp)
-{
- PCMachineState *pcms = PC_MACHINE(obj);
-
- return pcms->pit_enabled;
-}
-
-static void pc_machine_set_pit(Object *obj, bool value, Error **errp)
-{
- PCMachineState *pcms = PC_MACHINE(obj);
-
- pcms->pit_enabled = value;
-}
-
static bool pc_machine_get_hpet(Object *obj, Error **errp)
{
PCMachineState *pcms = PC_MACHINE(obj);
@@ -1707,7 +1695,6 @@ static void pc_machine_initfn(Object *obj)
pcms->acpi_build_enabled = PC_MACHINE_GET_CLASS(pcms)->has_acpi_build;
pcms->smbus_enabled = true;
pcms->sata_enabled = true;
- pcms->pit_enabled = true;
pcms->i8042_enabled = true;
pcms->max_fw_size = 8 * MiB;
#ifdef CONFIG_HPET
@@ -1836,11 +1823,6 @@ static void pc_machine_class_init(ObjectClass *oc, void
*data)
object_class_property_set_description(oc, PC_MACHINE_SATA,
"Enable/disable Serial ATA bus");
- object_class_property_add_bool(oc, PC_MACHINE_PIT,
- pc_machine_get_pit, pc_machine_set_pit);
- object_class_property_set_description(oc, PC_MACHINE_PIT,
- "Enable/disable Intel 8254 programmable interval timer emulation");
-
object_class_property_add_bool(oc, "hpet",
pc_machine_get_hpet, pc_machine_set_hpet);
object_class_property_set_description(oc, "hpet",
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index f79e720cc2..784d54efa9 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -1244,6 +1244,23 @@ static void x86_machine_set_acpi(Object *obj, Visitor
*v, const char *name,
visit_type_OnOffAuto(v, name, &x86ms->acpi, errp);
}
+static void x86_machine_get_pit(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
+{
+ X86MachineState *x86ms = X86_MACHINE(obj);
+ OnOffAuto pit = x86ms->pit;
+
+ visit_type_OnOffAuto(v, name, &pit, errp);
+}
+
+static void x86_machine_set_pit(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
+{
+ X86MachineState *x86ms = X86_MACHINE(obj);;
+
+ visit_type_OnOffAuto(v, name, &x86ms->pit, errp);
+}
+
static char *x86_machine_get_oem_id(Object *obj, Error **errp)
{
X86MachineState *x86ms = X86_MACHINE(obj);
@@ -1333,6 +1350,7 @@ static void x86_machine_initfn(Object *obj)
x86ms->smm = ON_OFF_AUTO_AUTO;
x86ms->acpi = ON_OFF_AUTO_AUTO;
+ x86ms->pit = ON_OFF_AUTO_AUTO;
x86ms->pci_irq_mask = ACPI_BUILD_PCI_IRQS;
x86ms->oem_id = g_strndup(ACPI_BUILD_APPNAME6, 6);
x86ms->oem_table_id = g_strndup(ACPI_BUILD_APPNAME8, 8);
@@ -1364,6 +1382,13 @@ static void x86_machine_class_init(ObjectClass *oc, void
*data)
object_class_property_set_description(oc, X86_MACHINE_ACPI,
"Enable ACPI");
+ object_class_property_add(oc, X86_MACHINE_PIT, "OnOffAuto",
+ x86_machine_get_pit,
+ x86_machine_set_pit,
+ NULL, NULL);
+ object_class_property_set_description(oc, X86_MACHINE_PIT,
+ "Enable i8254 PIT");
+
object_class_property_add_str(oc, X86_MACHINE_OEM_ID,
x86_machine_get_oem_id,
x86_machine_set_oem_id);
--
MST
- [PULL v2 66/86] docs/devel: start documenting writing VirtIO devices, (continued)
- [PULL v2 66/86] docs/devel: start documenting writing VirtIO devices, Michael S. Tsirkin, 2022/05/16
- [PULL v2 67/86] include/hw: start documenting the vhost API, Michael S. Tsirkin, 2022/05/16
- [PULL v2 68/86] hw/virtio/vhost-user: don't suppress F_CONFIG when supported, Michael S. Tsirkin, 2022/05/16
- [PULL v2 69/86] virtio/vhost-user: dynamically assign VhostUserHostNotifiers, Michael S. Tsirkin, 2022/05/16
- [PULL v2 70/86] virtio: drop name parameter for virtio_init(), Michael S. Tsirkin, 2022/05/16
- [PULL v2 71/86] virtio: add vhost support for virtio devices, Michael S. Tsirkin, 2022/05/16
- [PULL v2 75/86] include/hw/pci/pcie_host: Correct PCIE_MMCFG_SIZE_MAX, Michael S. Tsirkin, 2022/05/16
- [PULL v2 72/86] vhost-user: more master/slave things, Michael S. Tsirkin, 2022/05/16
- [PULL v2 73/86] docs/vhost-user: Clarifications for VHOST_USER_ADD/REM_MEM_REG, Michael S. Tsirkin, 2022/05/16
- [PULL v2 74/86] include/hw/pci/pcie_host: Correct PCIE_MMCFG_BUS_MASK, Michael S. Tsirkin, 2022/05/16
- [PULL v2 76/86] hw/i386: Make pit a property of common x86 base machine type,
Michael S. Tsirkin <=
- [PULL v2 77/86] hw/i386: Make pic a property of common x86 base machine type, Michael S. Tsirkin, 2022/05/16
- [PULL v2 78/86] hw/i386/amd_iommu: Fix IOMMU event log encoding errors, Michael S. Tsirkin, 2022/05/16
- [PULL v2 79/86] virtio-net: setup vhost_dev and notifiers for cvq only when feature is negotiated, Michael S. Tsirkin, 2022/05/16
- [PULL v2 80/86] virtio-net: align ctrl_vq index for non-mq guest for vhost_vdpa, Michael S. Tsirkin, 2022/05/16
- [PULL v2 81/86] vhost-vdpa: fix improper cleanup in net_init_vhost_vdpa, Michael S. Tsirkin, 2022/05/16
- [PULL v2 83/86] vhost-vdpa: backend feature should set only once, Michael S. Tsirkin, 2022/05/16
- [PULL v2 82/86] vhost-net: fix improper cleanup in vhost_net_start, Michael S. Tsirkin, 2022/05/16
- [PULL v2 84/86] vhost-vdpa: change name and polarity for vhost_vdpa_one_time_request(), Michael S. Tsirkin, 2022/05/16
- [PULL v2 85/86] virtio-net: don't handle mq request in userspace handler for vhost-vdpa, Michael S. Tsirkin, 2022/05/16
- [PULL v2 86/86] vhost-user-scsi: avoid unlink(NULL) with fd passing, Michael S. Tsirkin, 2022/05/16