hw/xen: Housekeeping
v2 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/.
Since v1:
- added missing include in stubs/xen-hw-stub.c
- added missing 'exec/cpu-common.h' for ram_addr_t
(Due to a bug in 'make', while rebasing the archives
might not be updated... so I missed this missing hunk as hw/core/libhwcore.fa didn't rebuilt stubs/)
Philippe Mathieu-Daudé (6):
hw/i386/q35: Remove unreachable Xen code on Q35 machine hw/i386/xen: Rename X86/PC specific function as xen_hvm_init_pc() sysemu/xen: Add missing 'exec/cpu-common.h' header for ram_addr_t type
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 - include/sysemu/xen.h | 2 ++ 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 | 50 ++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + stubs/meson.build | 1 + 12 files changed, 80 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 v2 1/6 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 v2 2/6 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 v2 3/6 sysemu/xen: Add missing 'exec/cpu-common.h' header for ram_addr_t type
In reply to Philippe Mathieu-DaudéAs this header use the ram_addr_t type, it has to include "exec/cpu-common.h" to avoid odd errors such:
include/sysemu/xen.h:35:44: error: unknown type name 'ram_addr_t'; did you mean 'in_addr_t'?
35 | static inline void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
| ^~~~~~~~~~
| in_addr_t--- include/sysemu/xen.h | 2 ++ 1 file changed, 2 insertions(+)
include/sysemu/xen.h +2 -0
@@ -8,6 +8,8 @@#ifndef SYSEMU_XEN_H #define SYSEMU_XEN_H +#include "exec/cpu-common.h" +#ifdef NEED_CPU_H # ifdef CONFIG_XEN # define CONFIG_XEN_IS_POSSIBLE
Signature · 1 line
2.26.2
PATCH v2 4/6 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
Re: [PATCH v2 4/6] stubs: Split accelerator / hardware related stubs
Quoted 4 lines · Philippe Mathieu-Daudé
Move hardware stubs unrelated from the accelerator to
xen-hw-stub.c.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
...
stubs/meson.build stub_ss.add(files('vm-stop.c')) · line 49
Quoted 11 lines
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'))
Bah wrong place :/ not my day.
Quoted 2 lines
stubs/meson.build +0
-0endif
PATCH v2 5/6 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 + stubs/xen-hw-stub.c | 1 + 5 files changed, 18 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"
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) {
Signature · 1 line
2.26.2
PATCH v2 6/6 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
Paolo Bonzini
AppliedQuoted 22 lines · Philippe Mathieu-Daudé
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/.Since v1:
- added missing include instubs/xen-hw-stub.c
- added missing 'exec/cpu-common.h' forram_addr_t(Due to a bug in 'make', while rebasing the archives
might not be updated... so I missed this missing hunk as hw/core/libhwcore.fa didn't rebuilt stubs/)Philippe Mathieu-Daudé (6):
hw/i386/q35: Remove unreachable Xen code on Q35 machine hw/i386/xen: Rename X86/PC specific function asxen_hvm_init_pc()sysemu/xen: Add missing 'exec/cpu-common.h' header forram_addr_ttype
stubs: Split accelerator / hardware related stubs
hw/xen: Split x86-specific declaration from generic hardware ones
typedefs: Restrict PCMachineState to 'hw/i386/pc.h'
Quoted 16 lines
include/hw/i386/pc.h | 4 ++-- include/hw/xen/xen-x86.h | 15 ++++++++++++ include/hw/xen/xen.h | 2 -- include/qemu/typedefs.h | 1 - include/sysemu/xen.h | 2 ++ 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 | 50 ++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + stubs/meson.build | 1 + 12 files changed, 80 insertions(+), 61 deletions(-) create mode 100644 include/hw/xen/xen-x86.h create mode 100644 stubs/xen-hw-stub.c
Queued, thanks.
Paolo