hw/xen: Housekeeping
cover hw/xen: Housekeeping
Hard to make an exciting cover of this series.
Basically:
- Make better separation between Xen accel and Xen hardware,
- Move stuff around to restrict PCMachineState to hw/i386/.
Philippe Mathieu-Daudé (5):
hw/i386/q35: Remove unreachable Xen code on Q35 machine hw/i386/xen: Rename X86/PC specific function as xen_hvm_init_pc()
stubs: Split accelerator / hardware related stubs hw/xen: Split x86-specific declaration from generic hardware ones
typedefs: Restrict PCMachineState to 'hw/i386/pc.h'
include/hw/i386/pc.h | 4 ++-- include/hw/xen/xen-x86.h | 15 ++++++++++++ include/hw/xen/xen.h | 2 -- include/qemu/typedefs.h | 1 - accel/stubs/xen-stub.c | 41 +-------------------------------- hw/i386/pc_piix.c | 8 +++---- hw/i386/pc_q35.c | 13 ++--------- hw/i386/xen/xen-hvm.c | 3 ++- stubs/xen-hw-stub.c | 49 ++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + stubs/meson.build | 1 + 11 files changed, 77 insertions(+), 61 deletions(-) create mode 100644 include/hw/xen/xen-x86.h create mode 100644 stubs/xen-hw-stub.c
Signature · 1 line
2.26.2
PATCH 1/5 hw/i386/q35: Remove unreachable Xen code on Q35 machine
Xen accelerator requires specific changes to a machine to be able to use it. See for example the 'Xen PC' machine configure its PCI bus calling pc_xen_hvm_init_pci(). There is no 'Xen Q35' machine declared. This code was probably added while introducing the Q35 machine, based on the existing PC machine (see commit df2d8b3ed4 "Introduce q35 pc based chipset emulator"). Remove the unreachable code to simplify this file.
--- hw/i386/pc_q35.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
hw/i386/pc_q35.c +2 -11
@@ -34,9 +34,7 @@#include "sysemu/arch_init.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/rtc/mc146818rtc.h" -#include "hw/xen/xen.h" #include "sysemu/kvm.h" -#include "sysemu/xen.h" #include "hw/kvm/clock.h" #include "hw/pci-host/q35.h" #include "hw/qdev-properties.h"
@@ -179,10 +177,6 @@ static void pc_q35_init(MachineState *machine) x86ms->below_4g_mem_size = machine->ram_size; } -if (xen_enabled ()) { -xen_hvm_init (pcms, &ram_memory); - } -x86_cpus_init (x86ms, pcmc->default_cpu_version);kvmclock_create ();
@@ -208,10 +202,7 @@ static void pc_q35_init(MachineState *machine) }/* allocate ram and load rom/bios */ -if (!xen_enabled ()) { -pc_memory_init (pcms,get_system_memory (), - rom_memory, &ram_memory); - } +pc_memory_init (pcms,get_system_memory (), rom_memory, &ram_memory);/* create pci host bus */ q35_host =Q35_HOST_DEVICE (qdev_new (TYPE_Q35_HOST_DEVICE ));
@@ -271,7 +262,7 @@ static void pc_q35_init(MachineState *machine)assert (pcms->vmport !=ON_OFF_AUTO__MAX );if (pcms->vmport ==ON_OFF_AUTO_AUTO ) { - pcms->vmport =xen_enabled () ?ON_OFF_AUTO_OFF :ON_OFF_AUTO_ON ; + pcms->vmport =ON_OFF_AUTO_ON ; }/* init basic PC hardware */
Signature · 1 line
2.26.2
PATCH 2/5 hw/i386/xen: Rename X86/PC specific function as xen_hvm_init_pc()
In reply to Philippe Mathieu-Daudéxen_hvm_init() is only meanful to initialize a X86/PC machine, rename it as xen_hvm_init_pc().
--- include/hw/xen/xen.h | 2 +- accel/stubs/xen-stub.c | 2 +- hw/i386/pc_piix.c | 6 +++--- hw/i386/xen/xen-hvm.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
include/hw/xen/xen.h +1 -1
@@ -30,7 +30,7 @@ qemu_irq *xen_interrupt_controller_init(void);void xenstore_store_pv_console_info (int i,struct Chardev *chr); -void xen_hvm_init (PCMachineState *pcms,MemoryRegion **ram_memory); +void xen_hvm_init_pc (PCMachineState *pcms,MemoryRegion **ram_memory);void xen_register_framebuffer (struct MemoryRegion *mr);
accel/stubs/xen-stub.c +1 -1
@@ -46,7 +46,7 @@ void xen_register_framebuffer(MemoryRegion *mr) { } -void xen_hvm_init (PCMachineState *pcms,MemoryRegion **ram_memory) +void xen_hvm_init_pc (PCMachineState *pcms,MemoryRegion **ram_memory) { }
hw/i386/pc_piix.c +3 -3
@@ -117,8 +117,8 @@ static void pc_init1(MachineState *machine,* so legacy non-PAE guests can get as much memory as possible in * the 32bit address space below 4G. * -* - Note that Xen has its own ram setp code in xen_ram_init(), -* called via xen_hvm_init(). +* - Note that Xen has its own ram setup code in xen_ram_init(), +* called via xen_hvm_init_pc(). * * Examples: * qemu -M pc-1.7 -m 4G (old default) -> 3584M low, 512M high
@@ -127,7 +127,7 @@ static void pc_init1(MachineState *machine,* qemu -M pc,max-ram-below-4g=4G -m 3968M -> 3968M low (=4G-128M) */ if (xen_enabled ()) { -xen_hvm_init (pcms, &ram_memory); +xen_hvm_init_pc (pcms, &ram_memory); }else {if (!pcms->max_ram_below_4g) { pcms->max_ram_below_4g =0xe0000000 ;/* default: 3.5G */
hw/i386/xen/xen-hvm.c +1 -1
@@ -1395,7 +1395,7 @@ static int xen_map_ioreq_server(XenIOState *state)return 0 ; } -void xen_hvm_init (PCMachineState *pcms,MemoryRegion **ram_memory) +void xen_hvm_init_pc (PCMachineState *pcms,MemoryRegion **ram_memory) {MachineState *ms =MACHINE (pcms);unsigned int max_cpus = ms->smp.max_cpus;
Signature · 1 line
2.26.2
PATCH 3/5 stubs: Split accelerator / hardware related stubs
In reply to Philippe Mathieu-DaudéMove hardware stubs unrelated from the accelerator to xen-hw-stub.c.
--- accel/stubs/xen-stub.c | 41 +---------------------------------- stubs/xen-hw-stub.c | 49 ++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + stubs/meson.build | 1 + 4 files changed, 52 insertions(+), 40 deletions(-) create mode 100644 stubs/xen-hw-stub.c
accel/stubs/xen-stub.c +1 -40
@@ -6,50 +6,11 @@*/ #include "qemu/osdep.h" -#include "hw/xen/xen.h" +#include "sysemu/xen.h" #include "qapi/qapi-commands-misc.h" bool xen_allowed; -void xenstore_store_pv_console_info (int i,Chardev *chr) -{ -} - -int xen_pci_slot_get_pirq (PCIDevice *pci_dev,int irq_num) -{ -return -1 ; -} - -void xen_piix3_set_irq (void *opaque,int irq_num,int level) -{ -} - -void xen_piix_pci_write_config_client (uint32_t address,uint32_t val,int len) -{ -} - -void xen_hvm_inject_msi (uint64_t addr,uint32_t data) -{ -} - -int xen_is_pirq_msi (uint32_t msi_data) -{ -return 0 ; -} - -qemu_irq *xen_interrupt_controller_init (void ) -{ -return NULL ; -} - -void xen_register_framebuffer (MemoryRegion *mr) -{ -} - -void xen_hvm_init_pc (PCMachineState *pcms,MemoryRegion **ram_memory) -{ -} -void qmp_xen_set_global_dirty_log (bool enable,Error **errp) { }
stubs/xen-hw-stub.c new file +49 -0
49 lines not on this page · raw message
MAINTAINERS +1 -0
@@ -480,6 +480,7 @@ F: include/hw/block/dataplane/xen* F: include/hw/xen/ F: include/sysemu/xen.h F: include/sysemu/xen-mapcache.h +F: stubs/xen-hw-stub.c Guest CPU Cores (HAXM) ---------------------
stubs/meson.build +1 -0
@@ -46,4 +46,5 @@ stub_ss.add(files('vm-stop.c')) stub_ss.add(files('win32-kbd-hook.c')) if have_system stub_ss.add(files('semihost.c')) + stub_ss.add(when: 'CONFIG_XEN', if_false: files('xen-hw-stub.c')) endif
Signature · 1 line
2.26.2
PATCH 4/5 hw/xen: Split x86-specific declaration from generic hardware ones
In reply to Philippe Mathieu-Daudéxen_hvm_init() is restricted to the X86 architecture.
--- include/hw/xen/xen-x86.h | 15 +++++++++++++++ include/hw/xen/xen.h | 2 -- hw/i386/pc_piix.c | 2 +- hw/i386/xen/xen-hvm.c | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 include/hw/xen/xen-x86.h
include/hw/xen/xen-x86.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* Xen X86-specific +* +* Copyright 2020 Red Hat, Inc. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef QEMU_HW_XEN_X86_H +#define QEMU_HW_XEN_X86_H + +#include "hw/i386/pc.h" + +void xen_hvm_init_pc (PCMachineState *pcms,MemoryRegion **ram_memory); + +#endif /* QEMU_HW_XEN_X86_H */
include/hw/xen/xen.h +0 -2
@@ -30,8 +30,6 @@ qemu_irq *xen_interrupt_controller_init(void);void xenstore_store_pv_console_info (int i,struct Chardev *chr); -void xen_hvm_init_pc (PCMachineState *pcms,MemoryRegion **ram_memory); -void xen_register_framebuffer (struct MemoryRegion *mr);#endif /* QEMU_HW_XEN_H */
hw/i386/pc_piix.c +1 -1
@@ -46,7 +46,7 @@#include "hw/sysbus.h" #include "sysemu/arch_init.h" #include "hw/i2c/smbus_eeprom.h" -#include "hw/xen/xen.h" +#include "hw/xen/xen-x86.h" #include "exec/memory.h" #include "exec/address-spaces.h" #include "hw/acpi/acpi.h"
hw/i386/xen/xen-hvm.c +1 -0
@@ -22,6 +22,7 @@#include "hw/xen/xen_common.h" #include "hw/xen/xen-legacy-backend.h" #include "hw/xen/xen-bus.h" +#include "hw/xen/xen-x86.h" #include "qapi/error.h" #include "qapi/qapi-commands-misc.h" #include "qemu/error-report.h"
Signature · 1 line
2.26.2
Re: [PATCH 4/5] hw/xen: Split x86-specific declaration from generic hardware ones
Quoted 64 lines · Philippe Mathieu-Daudé
xen_hvm_init()is restricted to the X86 architecture.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/xen/xen-x86.h | 15 +++++++++++++++ include/hw/xen/xen.h | 2 -- hw/i386/pc_piix.c | 2 +- hw/i386/xen/xen-hvm.c | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 include/hw/xen/xen-x86.hinclude/hw/xen/xen-x86.h new file +15
-0@@ -0,0 +1,15 @@ +/* +* Xen X86-specific +* +* Copyright 2020 Red Hat, Inc. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef QEMU_HW_XEN_X86_H +#define QEMU_HW_XEN_X86_H + +#include "hw/i386/pc.h" + +void xen_hvm_init_pc (PCMachineState *pcms,MemoryRegion **ram_memory); + +#endif /* QEMU_HW_XEN_X86_H */ include/hw/xen/xen.h +0
-2@@ -30,8 +30,6 @@ qemu_irq *xen_interrupt_controller_init(void);void xenstore_store_pv_console_info (int i,struct Chardev *chr); -void xen_hvm_init_pc (PCMachineState *pcms,MemoryRegion **ram_memory); -void xen_register_framebuffer (struct MemoryRegion *mr);#endif /* QEMU_HW_XEN_H */ hw/i386/pc_piix.c +1
-1@@ -46,7 +46,7 @@#include "hw/sysbus.h" #include "sysemu/arch_init.h" #include "hw/i2c/smbus_eeprom.h" -#include "hw/xen/xen.h" +#include "hw/xen/xen-x86.h" #include "exec/memory.h" #include "exec/address-spaces.h" #include "hw/acpi/acpi.h" hw/i386/xen/xen-hvm.c +0
-0
hw/i386/xen/xen-hvm.c line 28
Quoted 7 lines
hw/i386/xen/xen-hvm.c +1
-0@@ -22,6 +22,7 @@#include "hw/xen/xen_common.h" #include "hw/xen/xen-legacy-backend.h" #include "hw/xen/xen-bus.h" +#include "hw/xen/xen-x86.h" #include "qapi/error.h" #include "qapi/qapi-commands-misc.h" #include "qemu/error-report.h"
I forgot to commit this hunk:
---
stubs/xen-hw-stub.c +1 -0
@@ -8,6 +8,7 @@#include "qemu/osdep.h" #include "hw/xen/xen.h" +#include "hw/xen/xen-x86.h" void xenstore_store_pv_console_info (int i,Chardev *chr) {
---
PATCH 5/5 typedefs: Restrict PCMachineState to 'hw/i386/pc.h'
In reply to Philippe Mathieu-DaudéThe PCMachineState type is only used under hw/i386/. We don't need to forward-declare it for all architectures, restrict it to the X86 one.
--- include/hw/i386/pc.h | 4 ++-- include/qemu/typedefs.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-)
include/hw/i386/pc.h +2 -2
@@ -19,7 +19,7 @@* @boot_cpus: number of present VCPUs * @smp_dies: number of dies per one package */ -struct PCMachineState { +typedef struct PCMachineState { /*< private >*/ X86MachineState parent_obj;
@@ -50,7 +50,7 @@ struct PCMachineState {/* ACPI Memory hotplug IO base address */ hwaddr memhp_io_base; -}; +} PCMachineState;#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"#define PC_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g"
include/qemu/typedefs.h +0 -1
@@ -90,7 +90,6 @@ typedef struct PCIExpressDevice PCIExpressDevice;typedef struct PCIExpressHost PCIExpressHost ;typedef struct PCIHostDeviceAddress PCIHostDeviceAddress ;typedef struct PCIHostState PCIHostState ; -typedef struct PCMachineState PCMachineState ;typedef struct PostcopyDiscardState PostcopyDiscardState ;typedef struct Property Property ;typedef struct PropertyInfo PropertyInfo ;
Signature · 1 line
2.26.2