aml-build: don't modify child
this code:
aml_append(foo, bar);
might, non-intuitively, modify bar, which means that e.g. the following might not DTRT:
c = ....;
aml_append(a, c);
aml_append(b, c);to fix, simply allocate an intermediate array,
and always modify that.
--- hw/acpi/aml-build.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
hw/acpi/aml-build.c +10 -6
@@ -335,26 +335,29 @@ static void build_buffer(GArray *array, uint8_t op)void aml_append (Aml *parent_ctx,Aml *child) { +GArray *buf =build_alloc_array (); +build_append_array (buf, child->buf); +switch (child->block_flags) {case AML_OPCODE :build_append_byte (parent_ctx->buf, child->op);break ;case AML_EXT_PACKAGE : -build_extop_package (child->buf, child->op); +build_extop_package (buf, child->op);break ;case AML_PACKAGE : -build_package (child->buf, child->op); +build_package (buf, child->op);break ;case AML_RES_TEMPLATE : -build_append_byte (child->buf,0x79 );/* EndTag */ +build_append_byte (buf,0x79 );/* EndTag */ /* * checksum operations are treated as succeeded if checksum * field is zero. [ACPI Spec 1.0b, 6.4.2.8 End Tag] */ -build_append_byte (child->buf,0 ); +build_append_byte (buf,0 );/* fall through, to pack resources in buffer */ case AML_BUFFER : -build_buffer (child->buf, child->op); +build_buffer (buf, child->op);break ;case AML_NO_OPCODE :break ;
@@ -362,7 +365,8 @@ void aml_append(Aml *parent_ctx, Aml *child)assert (0 );break ; } -build_append_array (parent_ctx->buf, child->buf); +build_append_array (parent_ctx->buf, buf); +build_free_array (buf); }/* ACPI 1.0b: 16.2.5.1 Namespace Modifier Objects Encoding: DefScope */
Signature · 1 line
MST
[Qemu-devel] [PULL 02/25] aml-build: append opcodes using build_append_byte
In reply to a message not in the archiveOpcodes are raw bytes, they shouldn't be added using build_append_int. This only happens to work with 0 and 1 opcodes.
--- hw/acpi/aml-build.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/acpi/aml-build.c +3 -3
@@ -112,7 +112,7 @@ build_append_namestringv(GArray *array, const char *format, va_list ap)switch (seg_count) {case 1 :if (!*s) { -build_append_byte (array,0x0 );/* NullName */ +build_append_byte (array,0x00 );/* NullName */ }else {build_append_nameseg (array, s); }
@@ -448,7 +448,7 @@ Aml *aml_and(Aml *arg1, Aml *arg2)Aml *var =aml_opcode (0x7B /* AndOp */ );aml_append (var, arg1);aml_append (var, arg2); -build_append_int (var->buf,0x00 /* NullNameOp */ ); +build_append_byte (var->buf,0x00 /* NullNameOp */ );return var; }
@@ -546,7 +546,7 @@ Aml *aml_equal(Aml *arg1, Aml *arg2)Aml *var =aml_opcode (0x93 /* LequalOp */ );aml_append (var, arg1);aml_append (var, arg2); -build_append_int (var->buf,0x00 );/* NullNameOp */ +build_append_byte (var->buf,0x00 );/* NullNameOp */ return var; }
Signature · 1 line
MST
[Qemu-devel] [PULL 03/25] acpi: fix aml_equal term implementation
In reply to a message not in the archiveFrom: Marcel Apfelbaum <[email protected]>
The DefLEqual op does not have a target operand. Remove it.
--- hw/acpi/aml-build.c | 1 - 1 file changed, 1 deletion(-)
hw/acpi/aml-build.c +0 -1
@@ -546,7 +546,6 @@ Aml *aml_equal(Aml *arg1, Aml *arg2)Aml *var =aml_opcode (0x93 /* LequalOp */ );aml_append (var, arg1);aml_append (var, arg2); -build_append_byte (var->buf,0x00 );/* NullNameOp */ return var; }
Signature · 1 line
MST
[Qemu-devel] [PULL 04/25] acpi-test: update expected files
In reply to a message not in the archivecommit ecdc7bab095a2cf29d9e9d4a7e1494f586a8b270
"acpi: fix aml_equal term implementation"
dropped a useless Zero in generated code,
update expected files appropriately.
--- tests/acpi-test-data/pc/SSDT | Bin 2476 -> 2475 bytes tests/acpi-test-data/pc/SSDT.bridge | Bin 4335 -> 4334 bytes tests/acpi-test-data/q35/SSDT | Bin 681 -> 680 bytes tests/acpi-test-data/q35/SSDT.bridge | Bin 698 -> 697 bytes 4 files changed, 0 insertions(+), 0 deletions(-)
tests/acpi-test-data/pc/SSDT binary +0 -0
tests/acpi-test-data/pc/SSDT.bridge binary +0 -0
tests/acpi-test-data/q35/SSDT binary +0 -0
tests/acpi-test-data/q35/SSDT.bridge binary +0 -0
Signature · 1 line
MST
[Qemu-devel] [PULL 05/25] pci/shpc: fix signed integer overflow
In reply to a message not in the archiveclang undefined behaviour sanitizer reports:
Quoted 2 lines
hw/pci/shpc.c:162:27: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
Caused by the usual lack of a 'U' qualifier on a constant 1 being shifted left. Fix it up.
--- hw/pci/shpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci/shpc.c +1 -1
@@ -159,7 +159,7 @@ static void shpc_interrupt_update(PCIDevice *d)for (slot =0 ; slot < shpc->nslots; ++slot) {uint8_t event = shpc->config[SHPC_SLOT_EVENT_LATCH (slot)];uint8_t disable = shpc->config[SHPC_SLOT_EVENT_SERR_INT_DIS (d, slot)]; -uint32_t mask =1 <<SHPC_IDX_TO_LOGICAL (slot); +uint32_t mask =1U <<SHPC_IDX_TO_LOGICAL (slot);if (event & ~disable) { int_locator |= mask; }
Signature · 1 line
MST
[Qemu-devel] [PULL 06/25] machine: replace qemu opts with iommu property
In reply to a message not in the archiveFrom: Marcel Apfelbaum <[email protected]>
Fixes a QEMU crash when passing iommu parameter in command line. Running
x86_64-softmmu/qemu-system-x86_64 -machine pc,iommu=on -enable-kvm
leads to crash:
qemu-system-x86_64: qemu/util/qemu-option.c:387: qemu_opt_get_bool_helper:
Assertion `opt->desc && opt->desc->type == QEMU_OPT_BOOL' failed.
Aborted (core dumped)This happens because commit e79d5a6 ("machine: remove qemu_machine_opts global list") removed the global option descriptions and moved them to MachineState's QOM properties.
Fix this by querying machine properties through designated wrappers.
--- include/hw/boards.h | 1 + hw/core/machine.c | 5 +++++ hw/pci-host/q35.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-)
include/hw/boards.h +1 -0
@@ -66,6 +66,7 @@ MachineClass *find_default_machine(void);extern MachineState *current_machine;bool machine_usb (MachineState *machine); +bool machine_iommu (MachineState *machine);/** * MachineClass:
hw/core/machine.c +5 -0
@@ -403,6 +403,11 @@ bool machine_usb(MachineState *machine)return machine->usb; } +bool machine_iommu (MachineState *machine) +{ +return machine->iommu; +} +static const TypeInfo machine_info = { .name =TYPE_MACHINE , .parent =TYPE_OBJECT ,
hw/pci-host/q35.c +1 -1
@@ -415,7 +415,7 @@ static void mch_realize(PCIDevice *d, Error **errp) PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); }/* Intel IOMMU (VT-d) */ -if (qemu_opt_get_bool (qemu_get_machine_opts (),"iommu" , false)) { +if (machine_iommu (current_machine)) {mch_init_dmar (mch); } }
Signature · 1 line
MST
[PULL 08/25] machine: query kernel-irqchip property
In reply to a message not in the archiveFrom: Marcel Apfelbaum <[email protected]>
Running
x86_64-softmmu/qemu-system-x86_64 -machine pc,kernel_irqchip=on -enable-kvm
leads to crash:
qemu-system-x86_64: qemu/util/qemu-option.c:387: qemu_opt_get_bool_helper:
Assertion `opt->desc && opt->desc->type == QEMU_OPT_BOOL' failed. Aborted
(core dumped)This happens because the commit e79d5a6 ("machine: remove qemu_machine_opts global list") removed the global option descriptions and moved them to MachineState's QOM properties.
Fix this by querying machine properties through designated wrappers.
--- hw/ppc/e500.c | 15 +++++---------- hw/ppc/spapr.c | 15 ++++++--------- kvm-all.c | 6 +++--- 3 files changed, 14 insertions(+), 22 deletions(-)
hw/ppc/e500.c +5 -10
@@ -734,8 +734,8 @@ static DeviceState *ppce500_init_mpic_kvm(PPCE500Params *params,return dev; } -static qemu_irq *ppce500_init_mpic (PPCE500Params *params,MemoryRegion *ccsr, -qemu_irq **irqs) +static qemu_irq *ppce500_init_mpic (MachineState *machine,PPCE500Params *params, +MemoryRegion *ccsr,qemu_irq **irqs) {qemu_irq *mpic;DeviceState *dev =NULL ;
@@ -745,17 +745,12 @@ static qemu_irq *ppce500_init_mpic(PPCE500Params *params, MemoryRegion *ccsr, mpic =g_new0 (qemu_irq,256 );if (kvm_enabled ()) { -QemuOpts *machine_opts =qemu_get_machine_opts (); -bool irqchip_allowed =qemu_opt_get_bool (machine_opts, -"kernel_irqchip" , true); -bool irqchip_required =qemu_opt_get_bool (machine_opts, -"kernel_irqchip" , false);Error *err =NULL ; -if (irqchip_allowed) { +if (machine_kernel_irqchip_allowed (machine)) { dev =ppce500_init_mpic_kvm (params, irqs, &err); } -if (irqchip_required && !dev) { +if (machine_kernel_irqchip_required (machine) && !dev) {error_report ("kernel_irqchip requested but unavailable: %s" ,error_get_pretty (err));exit (1 );
@@ -879,7 +874,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)memory_region_add_subregion (address_space_mem, params->ccsrbar_base, ccsr_addr_space); - mpic =ppce500_init_mpic (params, ccsr_addr_space, irqs); + mpic =ppce500_init_mpic (machine, params, ccsr_addr_space, irqs);/* Serial */ if (serial_hds[0 ]) {
hw/ppc/spapr.c +6 -9
@@ -127,22 +127,18 @@ static XICSState *try_create_xics(const char *type, int nr_servers,return XICS_COMMON (dev); } -static XICSState *xics_system_init (int nr_servers,int nr_irqs) +static XICSState *xics_system_init (MachineState *machine, +int nr_servers,int nr_irqs) {XICSState *icp =NULL ;if (kvm_enabled ()) { -QemuOpts *machine_opts =qemu_get_machine_opts (); -bool irqchip_allowed =qemu_opt_get_bool (machine_opts, -"kernel_irqchip" , true); -bool irqchip_required =qemu_opt_get_bool (machine_opts, -"kernel_irqchip" , false);Error *err =NULL ; -if (irqchip_allowed) { +if (machine_kernel_irqchip_allowed (machine)) { icp =try_create_xics (TYPE_KVM_XICS , nr_servers, nr_irqs, &err); } -if (irqchip_required && !icp) { +if (machine_kernel_irqchip_required (machine) && !icp) {error_report ("kernel_irqchip requested but unavailable: %s" ,error_get_pretty (err)); }
@@ -1455,7 +1451,8 @@ static void ppc_spapr_init(MachineState *machine) }/* Set up Interrupt Controller before we create the VCPUs */ - spapr->icp =xics_system_init (smp_cpus *kvmppc_smt_threads () / smp_threads, + spapr->icp =xics_system_init (machine, + smp_cpus *kvmppc_smt_threads () / smp_threads,XICS_IRQS );/* init CPUs */
kvm-all.c +3 -3
@@ -1360,11 +1360,11 @@ int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq) false); } -static int kvm_irqchip_create (KVMState *s) +static int kvm_irqchip_create (MachineState *machine,KVMState *s) {int ret; -if (!qemu_opt_get_bool (qemu_get_machine_opts (),"kernel_irqchip" , true) || +if (!machine_kernel_irqchip_allowed (machine) || (!kvm_check_extension (s,KVM_CAP_IRQCHIP ) && (kvm_vm_enable_cap (s,KVM_CAP_S390_IRQCHIP ,0 ) <0 ))) {return 0 ;
@@ -1603,7 +1603,7 @@ static int kvm_init(MachineState *ms) goto err; } - ret =kvm_irqchip_create (s); + ret =kvm_irqchip_create (ms, s);if (ret <0 ) { goto err; }
Signature · 1 line
MST
[Qemu-devel] [PULL 07/25] machine: allowed/required kernel-irqchip support
In reply to a message not in the archiveFrom: Marcel Apfelbaum <[email protected]>
The code using kernel-irqchip property requires 'allowed/required' functionality. Replace machine's kernel_irqchip field with two fields representing the new functionality and expose them through wrappers.
--- include/hw/boards.h | 5 ++++- hw/core/machine.c | 24 +++++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-)
include/hw/boards.h +4 -1
@@ -67,6 +67,8 @@ extern MachineState *current_machine;bool machine_usb (MachineState *machine);bool machine_iommu (MachineState *machine); +bool machine_kernel_irqchip_allowed (MachineState *machine); +bool machine_kernel_irqchip_required (MachineState *machine);/** * MachineClass:
@@ -125,7 +127,8 @@ struct MachineState {/*< public >*/ char *accel; -bool kernel_irqchip; +bool kernel_irqchip_allowed; +bool kernel_irqchip_required;int kvm_shadow_mem;char *dtb;char *dumpdtb;
hw/core/machine.c +15 -9
@@ -31,18 +31,12 @@ static void machine_set_accel(Object *obj, const char *value, Error **errp) ms->accel =g_strdup (value); } -static bool machine_get_kernel_irqchip (Object *obj,Error **errp) -{ -MachineState *ms =MACHINE (obj); - -return ms->kernel_irqchip; -} -static void machine_set_kernel_irqchip (Object *obj,bool value,Error **errp) {MachineState *ms =MACHINE (obj); - ms->kernel_irqchip = value; + ms->kernel_irqchip_allowed = value; + ms->kernel_irqchip_required = value; } static void machine_get_kvm_shadow_mem(Object *obj, Visitor *v,
@@ -289,13 +283,15 @@ static void machine_initfn(Object *obj) {MachineState *ms =MACHINE (obj); + ms->kernel_irqchip_allowed = true; +object_property_add_str (obj,"accel" , machine_get_accel, machine_set_accel,NULL );object_property_set_description (obj,"accel" ,"Accelerator list" ,NULL );object_property_add_bool (obj,"kernel-irqchip" , - machine_get_kernel_irqchip, +NULL , machine_set_kernel_irqchip,NULL ); object_property_set_description(obj, "kernel-irqchip",
@@ -408,6 +404,16 @@ bool machine_iommu(MachineState *machine)return machine->iommu; } +bool machine_kernel_irqchip_allowed (MachineState *machine) +{ +return machine->kernel_irqchip_allowed; +} + +bool machine_kernel_irqchip_required (MachineState *machine) +{ +return machine->kernel_irqchip_required; +} +static const TypeInfo machine_info = { .name =TYPE_MACHINE , .parent =TYPE_OBJECT ,
Signature · 1 line
MST
[PULL 10/25] machine: query kvm-shadow-mem machine property
In reply to a message not in the archiveFrom: Marcel Apfelbaum <[email protected]>
Commit e79d5a6 ("machine: remove qemu_machine_opts global list") removed the global option descriptions and moved them to MachineState's QOM properties.
Query kvm-shadow-mem by accessing machine properties through designated wrappers.
--- include/hw/boards.h | 1 + hw/core/machine.c | 6 ++++++ target-i386/kvm.c | 3 +-- 3 files changed, 8 insertions(+), 2 deletions(-)
include/hw/boards.h +1 -0
@@ -69,6 +69,7 @@ bool machine_usb(MachineState *machine);bool machine_iommu (MachineState *machine);bool machine_kernel_irqchip_allowed (MachineState *machine);bool machine_kernel_irqchip_required (MachineState *machine); +int machine_kvm_shadow_mem (MachineState *machine);/** * MachineClass:
hw/core/machine.c +6 -0
@@ -284,6 +284,7 @@ static void machine_initfn(Object *obj)MachineState *ms =MACHINE (obj); ms->kernel_irqchip_allowed = true; + ms->kvm_shadow_mem =-1 ;object_property_add_str (obj,"accel" , machine_get_accel, machine_set_accel,NULL );
@@ -414,6 +415,11 @@ bool machine_kernel_irqchip_required(MachineState *machine)return machine->kernel_irqchip_required; } +int machine_kvm_shadow_mem (MachineState *machine) +{ +return machine->kvm_shadow_mem; +} +static const TypeInfo machine_info = { .name =TYPE_MACHINE , .parent =TYPE_OBJECT ,
target-i386/kvm.c +1 -2
@@ -890,8 +890,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) }qemu_register_reset (kvm_unpoison_all,NULL ); - shadow_mem =qemu_opt_get_size (qemu_get_machine_opts (), -"kvm_shadow_mem" ,-1 ); + shadow_mem =machine_kvm_shadow_mem (ms);if (shadow_mem !=-1 ) { shadow_mem /=4096 ; ret =kvm_vm_ioctl (s,KVM_SET_NR_MMU_PAGES , shadow_mem);
Signature · 1 line
MST
[Qemu-devel] [PULL 11/25] machine: query phandle-start machine property
In reply to a message not in the archiveFrom: Marcel Apfelbaum <[email protected]>
Commit e79d5a6 ("machine: remove qemu_machine_opts global list") removed the global option descriptions and moved them to MachineState's QOM properties.
Query phandle-start by accessing machine properties through designated wrappers.
--- include/hw/boards.h | 1 + device_tree.c | 5 ++--- hw/core/machine.c | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-)
include/hw/boards.h +1 -0
@@ -70,6 +70,7 @@ bool machine_iommu(MachineState *machine);bool machine_kernel_irqchip_allowed (MachineState *machine);bool machine_kernel_irqchip_required (MachineState *machine);int machine_kvm_shadow_mem (MachineState *machine); +int machine_phandle_start (MachineState *machine);/** * MachineClass:
device_tree.c +2 -3
@@ -24,7 +24,7 @@#include "sysemu/device_tree.h" #include "sysemu/sysemu.h" #include "hw/loader.h" -#include "qemu/option.h" +#include "hw/boards.h" #include "qemu/config-file.h" #include <libfdt.h>
@@ -245,8 +245,7 @@ uint32_t qemu_fdt_alloc_phandle(void *fdt)* which phandle id to start allocting phandles. */ if (!phandle) { - phandle =qemu_opt_get_number (qemu_get_machine_opts (), -"phandle_start" ,0 ); + phandle =machine_phandle_start (current_machine); }if (!phandle) {
hw/core/machine.c +5 -0
@@ -420,6 +420,11 @@ int machine_kvm_shadow_mem(MachineState *machine)return machine->kvm_shadow_mem; } +int machine_phandle_start (MachineState *machine) +{ +return machine->phandle_start; +} +static const TypeInfo machine_info = { .name =TYPE_MACHINE , .parent =TYPE_OBJECT ,
Signature · 1 line
MST
[Qemu-devel] [PULL 12/25] hw/boards: make it safe to include for linux-user
In reply to a message not in the archiveMake it safe to include hw/boards.h in exec.c
for linux-user configurations.
We don't need any of its contents though.
--- include/hw/boards.h | 4 ++++ 1 file changed, 4 insertions(+)
include/hw/boards.h +4 -0
@@ -3,6 +3,8 @@#ifndef HW_BOARDS_H #define HW_BOARDS_H +#if !defined(CONFIG_USER_ONLY ) +#include "qemu/typedefs.h" #include "sysemu/blockdev.h" #include "sysemu/accel.h"
@@ -154,3 +156,5 @@ struct MachineState { };#endif + +#endif
Signature · 1 line
MST
[PULL 09/25] kvm: add machine state to kvm_arch_init
In reply to a message not in the archiveFrom: Marcel Apfelbaum <[email protected]>
Needed to query machine's properties.
--- include/sysemu/kvm.h | 2 +- kvm-all.c | 2 +- target-arm/kvm.c | 2 +- target-i386/kvm.c | 2 +- target-mips/kvm.c | 2 +- target-ppc/kvm.c | 2 +- target-s390x/kvm.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-)
include/sysemu/kvm.h +1 -1
@@ -259,7 +259,7 @@ int kvm_arch_get_registers(CPUState *cpu);int kvm_arch_put_registers (CPUState *cpu,int level); -int kvm_arch_init (KVMState *s); +int kvm_arch_init (MachineState *ms,KVMState *s);int kvm_arch_init_vcpu (CPUState *cpu);
kvm-all.c +1 -1
@@ -1598,7 +1598,7 @@ static int kvm_init(MachineState *ms) kvm_resamplefds_allowed = (kvm_check_extension (s,KVM_CAP_IRQFD_RESAMPLE ) >0 ); - ret =kvm_arch_init (s); + ret =kvm_arch_init (ms, s);if (ret <0 ) { goto err; }
target-arm/kvm.c +1 -1
@@ -150,7 +150,7 @@ static const TypeInfo host_arm_cpu_type_info = { .class_size = sizeof(ARMHostCPUClass), }; -int kvm_arch_init (KVMState *s) +int kvm_arch_init (MachineState *ms,KVMState *s) {/* For ARM interrupt delivery is always asynchronous, * whether we are using an in-kernel VGIC or not.
target-i386/kvm.c +1 -1
@@ -840,7 +840,7 @@ static int kvm_get_supported_msrs(KVMState *s)return ret; } -int kvm_arch_init (KVMState *s) +int kvm_arch_init (MachineState *ms,KVMState *s) {uint64_t identity_base =0xfffbc000 ;uint64_t shadow_mem;
target-mips/kvm.c +1 -1
@@ -40,7 +40,7 @@ unsigned long kvm_arch_vcpu_id(CPUState *cs)return cs->cpu_index; } -int kvm_arch_init (KVMState *s) +int kvm_arch_init (MachineState *ms,KVMState *s) {/* MIPS has 128 signals */ kvm_set_sigmask_len (s,16 );
target-ppc/kvm.c +1 -1
@@ -95,7 +95,7 @@ static void kvm_kick_cpu(void *opaque)static int kvm_ppc_register_host_cpu_type (void ); -int kvm_arch_init (KVMState *s) +int kvm_arch_init (MachineState *ms,KVMState *s) { cap_interrupt_unset =kvm_check_extension (s,KVM_CAP_PPC_UNSET_IRQ ); cap_interrupt_level =kvm_check_extension (s,KVM_CAP_PPC_IRQ_LEVEL );
target-s390x/kvm.c +1 -1
@@ -173,7 +173,7 @@ static void kvm_s390_enable_cmma(KVMState *s)trace_kvm_enable_cmma (rc); } -int kvm_arch_init (KVMState *s) +int kvm_arch_init (MachineState *ms,KVMState *s) { cap_sync_regs =kvm_check_extension (s,KVM_CAP_SYNC_REGS ); cap_async_pf =kvm_check_extension (s,KVM_CAP_ASYNC_PF );
Signature · 1 line
MST
[Qemu-devel] [PULL 15/25] pci: Convert pci_nic_init() to Error to avoid qdev_init()
In reply to a message not in the archiveFrom: Markus Armbruster <[email protected]>
qdev_init() is deprecated, and will be removed when its callers have been weaned off it.
--- hw/pci/pci.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
hw/pci/pci.c +14 -4
@@ -1613,9 +1613,11 @@ static const char * const pci_nic_names[] = {/* Initialize a PCI NIC. */ static PCIDevice *pci_nic_init (NICInfo *nd,PCIBus *rootbus,const char *default_model, -const char *default_devaddr) +const char *default_devaddr, +Error **errp) {const char *devaddr = nd->devaddr ? nd->devaddr : default_devaddr; +Error *err =NULL ;PCIBus *bus;int devfn;PCIDevice *pci_dev;
@@ -1636,8 +1638,13 @@ static PCIDevice *pci_nic_init(NICInfo *nd, PCIBus *rootbus, pci_dev =pci_create (bus, devfn, pci_nic_names[i]); dev = &pci_dev->qdev;qdev_set_nic_properties (dev, nd); -if (qdev_init (dev) <0 ) + +object_property_set_bool (OBJECT (dev), true,"realized" , &err); +if (err) { +error_propagate (errp, err); +object_unparent (OBJECT (dev));return NULL ; + }return pci_dev; }
@@ -1645,14 +1652,17 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,const char *default_model, const char *default_devaddr) { + Error *err = NULL;PCIDevice *res;if (qemu_show_nic_models (nd->model, pci_nic_models))exit (0 ); - res =pci_nic_init (nd, rootbus, default_model, default_devaddr); -if (!res) + res =pci_nic_init (nd, rootbus, default_model, default_devaddr, &err); +if (!res) { +error_report_err (err);exit (1 ); + }return res; }
Signature · 1 line
MST
[Qemu-devel] [PULL 16/25] virtio-pci: Convert to realize()
In reply to a message not in the archiveFrom: Markus Armbruster <[email protected]>
--- hw/virtio/virtio-pci.h | 2 +- hw/virtio/virtio-pci.c | 88 ++++++++++++++++++++------------------------------ 2 files changed, 36 insertions(+), 54 deletions(-)
hw/virtio/virtio-pci.h +1 -1
@@ -82,7 +82,7 @@ typedef struct {typedef struct VirtioPCIClass {PCIDeviceClass parent_class; -int (*init)(VirtIOPCIProxy *vpci_dev); +void (*realize)(VirtIOPCIProxy *vpci_dev,Error **errp); }VirtioPCIClass ;struct VirtIOPCIProxy {
hw/virtio/virtio-pci.c +35 -53
250 lines not on this page · raw message
Signature · 1 line
MST
[Qemu-devel] [PULL 17/25] tpm: Move memory subregion function into realize function
In reply to a message not in the archiveFrom: Stefan Berger <[email protected]>
Move the memory subregion function into the DeviceClass realize function due to isa_address_space (now) crashing if called in the instance init function.
--- hw/tpm/tpm_tis.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/tpm/tpm_tis.c +3 -3
@@ -959,18 +959,18 @@ static void tpm_tis_realizefn(DeviceState *dev, Error **errp) tis->bh =qemu_bh_new (tpm_tis_receive_bh, s);isa_init_irq (&s->busdev, &tis->irq, tis->irq_num); + +memory_region_add_subregion (isa_address_space (ISA_DEVICE (dev)), +TPM_TIS_ADDR_BASE , &s->mmio); }static void tpm_tis_initfn (Object *obj) { -ISADevice *dev =ISA_DEVICE (obj);TPMState *s =TPM (obj);memory_region_init_io (&s->mmio,OBJECT (s), &tpm_tis_memory_ops, s,"tpm-tis-mmio" ,TPM_TIS_NUM_LOCALITIES <<TPM_TIS_LOCALITY_SHIFT ); -memory_region_add_subregion (isa_address_space (dev),TPM_TIS_ADDR_BASE , - &s->mmio); }static void tpm_tis_class_init (ObjectClass *klass,void *data)
Signature · 1 line
MST
[Qemu-devel] [PULL 18/25] MAINTAINERS: drop [email protected]
In reply to a message not in the archiveIt's sad when a friend leaves, but we have to move on.
Drop Anthony's email from MAINTAINERS so he stops getting irrelevant email.
Got Anthony's ack off-list.
--- MAINTAINERS | 9 --------- 1 file changed, 9 deletions(-)
MAINTAINERS +0 -9
@@ -50,14 +50,12 @@ Descriptions of section entries: General Project Administration ------------------------------ -M: Anthony Liguori <[email protected]> M: Peter Maydell <[email protected]> Responsible Disclosure, Reporting Security Issues ------------------------------ W: http://wiki.qemu.org/SecurityProcess M: Michael S. Tsirkin <[email protected]> -M: Anthony Liguori <[email protected]> L: [email protected] Guest CPU cores (TCG):
@@ -565,7 +563,6 @@ F: hw/unicore32/ X86 Machines ------------ PC -M: Anthony Liguori <[email protected]> M: Michael S. Tsirkin <[email protected]> S: Supported F: include/hw/i386/
@@ -676,7 +673,6 @@ S: Supported F: hw/*/*vhost* virtio -M: Anthony Liguori <[email protected]> M: Michael S. Tsirkin <[email protected]> S: Supported F: hw/*/virtio*
@@ -771,7 +767,6 @@ T: git git://repo.or.cz/qemu/kevin.git block T: git git://github.com/stefanha/qemu.git block Character Devices -M: Anthony Liguori <[email protected]> M: Paolo Bonzini <[email protected]> S: Maintained F: qemu-char.c
@@ -832,7 +827,6 @@ F: audio/spiceaudio.c F: hw/display/qxl* Graphics -M: Anthony Liguori <[email protected]> M: Gerd Hoffmann <[email protected]> S: Odd Fixes F: ui/
@@ -844,7 +838,6 @@ S: Odd Fixes F: ui/cocoa.m Main loop -M: Anthony Liguori <[email protected]> M: Paolo Bonzini <[email protected]> S: Maintained F: cpus.c
@@ -861,7 +854,6 @@ F: hmp-commands.hx T: git git://repo.or.cz/qemu/qmp-unstable.git queue/qmp Network device layer -M: Anthony Liguori <[email protected]> M: Stefan Hajnoczi <[email protected]> M: Jason Wang <[email protected]> S: Maintained
@@ -913,7 +905,6 @@ F: qga/ T: git git://github.com/mdroth/qemu.git qga QOM -M: Anthony Liguori <[email protected]> M: Andreas Färber <[email protected]> S: Supported T: git git://github.com/afaerber/qemu-cpu.git qom-next
Signature · 1 line
MST
[Qemu-devel] [PULL 19/25] acpi: specify format for build_append_namestring
In reply to a message not in the archiveWill catch users if we misused it.
--- hw/acpi/aml-build.c | 1 + 1 file changed, 1 insertion(+)
hw/acpi/aml-build.c +1 -0
@@ -141,6 +141,7 @@ build_append_namestringv(GArray *array, const char *format, va_list ap)g_strfreev (segs); } +GCC_FMT_ATTR(2, 3)static void build_append_namestring (GArray *array,const char *format, ...) {va_list ap;
Signature · 1 line
MST
[Qemu-devel] [PULL 20/25] exec: don't include hw/boards for linux-user
In reply to a message not in the archiveAs noted by Andreas, hw/boards.h shouldn't be used outside softmmu code. Include it conditionally, and drop the (now unnecessary) ifdef guards in hw/boards.h
--- include/hw/boards.h | 4 ---- exec.c | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-)
include/hw/boards.h +0 -4
@@ -3,8 +3,6 @@#ifndef HW_BOARDS_H #define HW_BOARDS_H -#if !defined(CONFIG_USER_ONLY ) -#include "qemu/typedefs.h" #include "sysemu/blockdev.h" #include "sysemu/accel.h"
@@ -158,5 +156,3 @@ struct MachineState { };#endif - -#endif
exec.c +2 -0
@@ -26,7 +26,9 @@#include "cpu.h" #include "tcg.h" #include "hw/hw.h" +#if !defined(CONFIG_USER_ONLY )#include "hw/boards.h" +#endif #include "hw/qdev.h" #include "qemu/osdep.h" #include "sysemu/kvm.h"
Signature · 1 line
MST
[Qemu-devel] [PULL 21/25] virtio-scsi: drop duplicate CDB/SENSE SIZE
In reply to a message not in the archiveThis is duplicated from the kernel header,
drop our copy.
--- include/hw/virtio/virtio-scsi.h | 2 -- 1 file changed, 2 deletions(-)
include/hw/virtio/virtio-scsi.h +0 -2
@@ -30,8 +30,6 @@ OBJECT_CHECK(VirtIOSCSI, (obj), TYPE_VIRTIO_SCSI)#define VIRTIO_SCSI_VQ_SIZE 128 -#define VIRTIO_SCSI_CDB_SIZE 32 -#define VIRTIO_SCSI_SENSE_SIZE 96#define VIRTIO_SCSI_MAX_CHANNEL 0#define VIRTIO_SCSI_MAX_TARGET 255#define VIRTIO_SCSI_MAX_LUN 16383
Signature · 1 line
MST
[Qemu-devel] [PULL 22/25] uapi/virtio_scsi: allow overriding CDB/SENSE size
In reply to a message not in the archiveQEMU wants to use virtio scsi structures with
a different VIRTIO_SCSI_CDB_SIZE/VIRTIO_SCSI_SENSE_SIZE, let's add ifdefs to allow overriding them.
Keep the old defines under new names:
VIRTIO_SCSI_CDB_DEFAULT_SIZE/VIRTIO_SCSI_SENSE_DEFAULT_SIZE, since that's what these values really are:
defaults for cdb/sense size fields.
--- include/standard-headers/linux/virtio_scsi.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
include/standard-headers/linux/virtio_scsi.h +10 -2
@@ -29,8 +29,16 @@#include "standard-headers/linux/virtio_types.h" -#define VIRTIO_SCSI_CDB_SIZE 32 -#define VIRTIO_SCSI_SENSE_SIZE 96 +/* Default values of the CDB and sense data size configuration fields */ +#define VIRTIO_SCSI_CDB_DEFAULT_SIZE 32 +#define VIRTIO_SCSI_SENSE_DEFAULT_SIZE 96 + +#ifndef VIRTIO_SCSI_CDB_SIZE +#define VIRTIO_SCSI_CDB_SIZE VIRTIO_SCSI_CDB_DEFAULT_SIZE +#endif +#ifndef VIRTIO_SCSI_SENSE_SIZE +#define VIRTIO_SCSI_SENSE_SIZE VIRTIO_SCSI_SENSE_DEFAULT_SIZE +#endif /* SCSI command request, followed by data-out */ struct virtio_scsi_cmd_req {
Signature · 1 line
MST
[Qemu-devel] [PULL 23/25] virtio-scsi: fix cdb/sense size
In reply to a message not in the archiveCommit "virtio-scsi: use standard-headers" added cdb and sense into req/rep structures, which breaks uses of sizeof for these structures, since qemu adds its own arrays on top.
To fix, redefine CDB/sense field size to 0.
--- include/hw/virtio/virtio-scsi.h | 3 +++ hw/scsi/virtio-scsi.c | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-)
include/hw/virtio/virtio-scsi.h +3 -0
@@ -14,6 +14,9 @@#ifndef _QEMU_VIRTIO_SCSI_H#define _QEMU_VIRTIO_SCSI_H +/* Override CDB/sense data size: they are dynamic (guest controlled) in QEMU */ +#define VIRTIO_SCSI_CDB_SIZE 0 +#define VIRTIO_SCSI_SENSE_SIZE 0#include "standard-headers/linux/virtio_scsi.h" #include "hw/virtio/virtio.h" #include "hw/pci/pci.h"
hw/scsi/virtio-scsi.c +5 -5
@@ -476,7 +476,7 @@ static int virtio_scsi_parse_cdb(SCSIDevice *dev, SCSICommand *cmd,VirtIOSCSIReq *req = hba_private;if (cmd->len ==0 ) { - cmd->len =MIN (VIRTIO_SCSI_CDB_SIZE ,SCSI_CMD_BUF_SIZE ); + cmd->len =MIN (VIRTIO_SCSI_CDB_DEFAULT_SIZE ,SCSI_CMD_BUF_SIZE );memcpy (cmd->buf, buf, cmd->len); }
@@ -642,8 +642,8 @@ static void virtio_scsi_reset(VirtIODevice *vdev)qbus_reset_all (&s->bus.qbus); s->resetting--; - vs->sense_size =VIRTIO_SCSI_SENSE_SIZE ; - vs->cdb_size =VIRTIO_SCSI_CDB_SIZE ; + vs->sense_size =VIRTIO_SCSI_SENSE_DEFAULT_SIZE ; + vs->cdb_size =VIRTIO_SCSI_CDB_DEFAULT_SIZE ; s->events_dropped = false; }
@@ -830,8 +830,8 @@ void virtio_scsi_common_realize(DeviceState *dev, Error **errp,return ; } s->cmd_vqs = g_new0(VirtQueue *, s->conf.num_queues); - s->sense_size =VIRTIO_SCSI_SENSE_SIZE ; - s->cdb_size =VIRTIO_SCSI_CDB_SIZE ; + s->sense_size =VIRTIO_SCSI_SENSE_DEFAULT_SIZE ; + s->cdb_size =VIRTIO_SCSI_CDB_DEFAULT_SIZE ; s->ctrl_vq =virtio_add_queue (vdev,VIRTIO_SCSI_VQ_SIZE , ctrl);
Signature · 1 line
MST
[Qemu-devel] [PULL 24/25] virtio-scsi: clean out duplicate cdb field
In reply to a message not in the archivecdb is now part of cmd, drop it from req. There's also nothing to check using build assert now.
--- include/hw/virtio/virtio-scsi.h | 7 +------ hw/scsi/virtio-scsi.c | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-)
include/hw/virtio/virtio-scsi.h +1 -6
@@ -109,8 +109,7 @@ typedef struct VirtIOSCSIReq {/* Note: * - fields before elem are initialized by virtio_scsi_init_req; * - elem is uninitialized at the time of allocation. -* - fields after elem (except the ending cdb[]) are zeroed by -* virtio_scsi_init_req. +* - fields after elem are zeroed by virtio_scsi_init_req. * */ VirtQueueElement elem;
@@ -137,16 +136,12 @@ typedef struct VirtIOSCSIReq {union {struct {VirtIOSCSICmdReq cmd; -uint8_t cdb[]; } QEMU_PACKED;VirtIOSCSICtrlTMFReq tmf;VirtIOSCSICtrlANReq an; } req; } VirtIOSCSIReq; -QEMU_BUILD_BUG_ON(offsetof(VirtIOSCSIReq, req.cdb) != - offsetof(VirtIOSCSIReq, req.cmd) + sizeof(VirtIOSCSICmdReq)); -#define DEFINE_VIRTIO_SCSI_PROPERTIES (_state, _conf_field) \ DEFINE_PROP_UINT32("num_queues", _state, _conf_field.num_queues, 1), \ DEFINE_PROP_UINT32("max_sectors", _state, _conf_field.max_sectors, 0xFFFF),\
hw/scsi/virtio-scsi.c +1 -1
@@ -544,7 +544,7 @@ bool virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, VirtIOSCSIReq *req) } req->sreq =scsi_req_new (d, req->req.cmd.tag,virtio_scsi_get_lun (req->req.cmd.lun), - req->req.cdb, req); + req->req.cmd.cdb, req); if (req->sreq->cmd.mode != SCSI_XFER_NONE && (req->sreq->cmd.mode != req->mode ||
Signature · 1 line
MST
[Qemu-devel] [PULL 25/25] virtio-scsi: remove empty wrapper for cmd
In reply to a message not in the archiveThe anonymous struct only has a single field now, drop the wrapper structure.
--- include/hw/virtio/virtio-scsi.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
include/hw/virtio/virtio-scsi.h +1 -3
@@ -134,9 +134,7 @@ typedef struct VirtIOSCSIReq {VirtIOSCSIEvent event; } resp;union { -struct { -VirtIOSCSICmdReq cmd; - } QEMU_PACKED; +VirtIOSCSICmdReq cmd;VirtIOSCSICtrlTMFReq tmf;VirtIOSCSICtrlANReq an; } req;
Signature · 1 line
MST
[Qemu-devel] [PULL 13/25] machine: query dump-guest-core machine property
In reply to a message not in the archiveFrom: Marcel Apfelbaum <[email protected]>
Running
qemu-bin ... -machine pc,dump-guest-core=on
leads to crash:
x86_64-softmmu/qemu-system-x86_64 -machine pc,dump-guest-core=on
qemu-system-x86_64: qemu/util/qemu-option.c:387: qemu_opt_get_bool_helper:
Assertion `opt->desc && opt->desc->type == QEMU_OPT_BOOL' failed. Aborted
(core dumped)This happens because the commit e79d5a6 ("machine: remove qemu_machine_opts global list") removed the global option descriptions and moved them to MachineState's QOM properties.
Fix this by querying machine properties through designated wrappers.
--- include/hw/boards.h | 1 + exec.c | 4 ++-- hw/core/machine.c | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-)
include/hw/boards.h +1 -0
@@ -73,6 +73,7 @@ bool machine_kernel_irqchip_allowed(MachineState *machine);bool machine_kernel_irqchip_required (MachineState *machine);int machine_kvm_shadow_mem (MachineState *machine);int machine_phandle_start (MachineState *machine); +bool machine_dump_guest_core (MachineState *machine);/** * MachineClass:
exec.c +2 -2
@@ -26,6 +26,7 @@#include "cpu.h" #include "tcg.h" #include "hw/hw.h" +#include "hw/boards.h" #include "hw/qdev.h" #include "qemu/osdep.h" #include "sysemu/kvm.h"
@@ -1250,8 +1251,7 @@ static void qemu_ram_setup_dump(void *addr, ram_addr_t size)int ret;/* Use MADV_DONTDUMP, if user doesn't want the guest memory in the core */ -if (!qemu_opt_get_bool (qemu_get_machine_opts (), -"dump-guest-core" , true)) { +if (!machine_dump_guest_core (current_machine)) { ret =qemu_madvise (addr, size,QEMU_MADV_DONTDUMP );if (ret) {perror ("qemu_madvise" );
hw/core/machine.c +6 -0
@@ -285,6 +285,7 @@ static void machine_initfn(Object *obj) ms->kernel_irqchip_allowed = true; ms->kvm_shadow_mem =-1 ; + ms->dump_guest_core = true;object_property_add_str (obj,"accel" , machine_get_accel, machine_set_accel,NULL );
@@ -425,6 +426,11 @@ int machine_phandle_start(MachineState *machine)return machine->phandle_start; } +bool machine_dump_guest_core (MachineState *machine) +{ +return machine->dump_guest_core; +} +static const TypeInfo machine_info = { .name =TYPE_MACHINE , .parent =TYPE_OBJECT ,
Signature · 1 line
MST
[Qemu-devel] [PULL 14/25] machine: query mem-merge machine property
In reply to a message not in the archiveFrom: Marcel Apfelbaum <[email protected]>
Running
qemu-bin ... -machine pc,mem-merge=on
leads to crash:
x86_64-softmmu/qemu-system-x86_64 -machine pc,dump-guest-core=on
qemu-system-x86_64: qemu/util/qemu-option.c:387: qemu_opt_get_bool_helper:
Assertion `opt->desc && opt->desc->type == QEMU_OPT_BOOL' failed. Aborted
(core dumped)This happens because the commit e79d5a6 ("machine: remove qemu_machine_opts global list") removed the global option descriptions and moved them to MachineState's QOM properties.
Fix this by querying machine properties through designated wrappers.
--- include/hw/boards.h | 1 + exec.c | 2 +- hw/core/machine.c | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-)
include/hw/boards.h +1 -0
@@ -74,6 +74,7 @@ bool machine_kernel_irqchip_required(MachineState *machine);int machine_kvm_shadow_mem (MachineState *machine);int machine_phandle_start (MachineState *machine);bool machine_dump_guest_core (MachineState *machine); +bool machine_mem_merge (MachineState *machine);/** * MachineClass:
exec.c +1 -1
@@ -1326,7 +1326,7 @@ void qemu_ram_unset_idstr(ram_addr_t addr)static int memory_try_enable_merging (void *addr,size_t len) { -if (!qemu_opt_get_bool (qemu_get_machine_opts (),"mem-merge" , true)) { +if (!machine_mem_merge (current_machine)) {/* disabled by the user */ return 0 ; }
hw/core/machine.c +6 -0
@@ -286,6 +286,7 @@ static void machine_initfn(Object *obj) ms->kernel_irqchip_allowed = true; ms->kvm_shadow_mem =-1 ; ms->dump_guest_core = true; + ms->mem_merge = true;object_property_add_str (obj,"accel" , machine_get_accel, machine_set_accel,NULL );
@@ -431,6 +432,11 @@ bool machine_dump_guest_core(MachineState *machine)return machine->dump_guest_core; } +bool machine_mem_merge (MachineState *machine) +{ +return machine->mem_merge; +} +static const TypeInfo machine_info = { .name =TYPE_MACHINE , .parent =TYPE_OBJECT ,
Signature · 1 line
MST