Misc patches for QEMU 2.10 soft freeze
The following changes since commit 49bcce4b9c11759678fd223aefb48691c4959d4f:
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2017-07-12' into staging (2017-07-13 16:56:06 +0100)
are available in the git repository at:
git://github.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to 68c761e19c2ea453f880dbbd04e867d34d1468b8:
spapr_rng: Convert to DEFINE_PROP_LINK (2017-07-14 12:04:43 +0200)
----------------------------------------------------------------
* gdbstub fixes (Alex)
* IOMMU MemoryRegion subclass (Alexey)
* Chardev hotswap (Anton)
* NBD_OPT_GO support (Eric)
* Misc bugfixes
* DEFINE_PROP_LINK (minus the ARM patches - Fam)
* MAINTAINERS updates (Philippe)
----------------------------------------------------------------
Alex Bennée (4):
gdbstub: modernise DEBUG_GDB
gdbstub: rename cpu_index -> cpu_gdb_index qom/cpu: remove host_tid field
gdbstub: don't fail on vCont; C04:0; c packets
Alexey Kardashevskiy (2):
memory/iommu: QOM'fy IOMMU MemoryRegion memory/iommu: introduce IOMMUMemoryRegionClass
Anton Nefedov (13):
char: move QemuOpts->ChardevBackend translation to a separate func
char: add backend hotswap handler
char: chardevice hotswap
char: forbid direct chardevice access for hotswap devices
char: avoid chardevice direct access
test-char: destroy chardev-udp after test
test-char: split char_udp_test
test-char: split char_file_test
test-char: add hotswap test
hmp: add hmp analogue for qmp-chardev-change
virtio-console: chardev hotswap support
serial: move TIOCM update to a separate function
serial: chardev hotswap support
Emilio G. Cota (2):
vl: fix breakage of -tb-size
translate-all: remove redundant !tcg_enabled check in dump_exec_info
Eric Blake (9):
nbd: Create struct for tracking export info
nbd: Don't bother tracing an NBD_OPT_ABORT response failure
nbd: Expose and debug more NBD constants
nbd: Simplify trace of client flags in negotiation
nbd: Refactor reply to NBD_OPT_EXPORT_NAME
nbd: Implement NBD_OPT_GO on server
nbd: Implement NBD_OPT_GO on client
nbd: Implement NBD_INFO_BLOCK_SIZE on server
nbd: Implement NBD_INFO_BLOCK_SIZE on client
Fam Zheng (13):
qdev: Introduce PropertyInfo.create
qdev: Introduce DEFINE_PROP_LINK
qmp: Use ObjectProperty.type if present
qdev: Add const qualifier to PropertyInfo definitions
virtio-blk: Convert to DEFINE_PROP_LINK
virtio-scsi: Convert to DEFINE_PROP_LINK
virtio-rng: Convert to DEFINE_PROP_LINK
virtio-crypto: Convert to DEFINE_PROP_LINK
dimm: Convert to DEFINE_PROP_LINK
ivshmem: Convert to DEFINE_PROP_LINK
mips_cmgcr: Convert to DEFINE_PROP_LINK
cpu: Convert to DEFINE_PROP_LINK
spapr_rng: Convert to DEFINE_PROP_LINK
Igor Mammedov (1):
qom: enforce readonly nature of link's check callback
Marc-André Lureau (1):
chardev: block during sync read
Paolo Bonzini (1):
build: add -Wexpansion-to-defined
Peng Hao (1):
chardev: fix parallel device can't be reconnect
Philippe Mathieu-Daudé (5):
MAINTAINERS: update TCG entries
MAINTAINERS: update KVM entries
MAINTAINERS: update Xen entries
MAINTAINERS: update TCI entry
MAINTAINERS: add entry for "Unimplemented" device
Pranith Kumar (2):
Revert "exec.c: Fix breakpoint invalidation race" mttcg/i386: Patch instruction using async_safe_* framework
Prasad J Pandit (1):
exec: use qemu_ram_ptr_length to access guest ram
MAINTAINERS | 18 +-- accel/tcg/translate-all.c | 5 - backends/rng-egd.c | 2 +- block/nbd-client.c | 22 +-- block/nbd-client.h | 3 +- block/nbd.c | 16 ++- bsd-user/qemu.h | 2 + chardev/char-fe.c | 16 ++- chardev/char-mux.c | 1 + chardev/char-socket.c | 2 + chardev/char.c | 164 +++++++++++++++++---- configure | 2 +- exec.c | 70 +++++---- gdbstub.c | 119 ++++++++------- hmp-commands.hx | 18 ++- hmp.c | 34 +++++ hmp.h | 1 + hw/alpha/typhoon.c | 31 ++-- hw/arm/pxa2xx.c | 3 +- hw/arm/strongarm.c | 4 +- hw/block/virtio-blk.c | 6 +- hw/char/bcm2835_aux.c | 2 +- hw/char/cadence_uart.c | 4 +- hw/char/debugcon.c | 4 +- hw/char/digic-uart.c | 2 +- hw/char/escc.c | 8 +- hw/char/etraxfs_ser.c | 2 +- hw/char/exynos4210_uart.c | 4 +- hw/char/grlib_apbuart.c | 4 +- hw/char/imx_serial.c | 2 +- hw/char/ipoctal232.c | 4 +- hw/char/lm32_juart.c | 2 +- hw/char/lm32_uart.c | 2 +- hw/char/mcf_uart.c | 2 +- hw/char/milkymist-uart.c | 2 +- hw/char/parallel.c | 8 +- hw/char/pl011.c | 2 +- hw/char/sclpconsole-lm.c | 4 +- hw/char/sclpconsole.c | 4 +- hw/char/serial.c | 63 ++++++-- hw/char/sh_serial.c | 4 +- hw/char/spapr_vty.c | 4 +- hw/char/stm32f2xx_usart.c | 3 +- hw/char/terminal3270.c | 4 +- hw/char/virtio-console.c | 35 ++++- hw/char/xen_console.c | 4 +- hw/char/xilinx_uartlite.c | 2 +- hw/core/qdev-properties-system.c | 8 +- hw/core/qdev-properties.c | 63 +++++--- hw/core/qdev.c | 31 ++-- hw/display/xlnx_dp.c | 2 +- hw/dma/rc4030.c | 34 +++-- hw/i386/amd_iommu.c | 33 +++-- hw/i386/amd_iommu.h | 5 +- hw/i386/intel_iommu.c | 42 ++++-- hw/i386/kvmvapic.c | 85 +++++------ hw/ipmi/ipmi.c | 2 +- hw/ipmi/ipmi_bmc_extern.c | 4 +- hw/mem/pc-dimm.c | 30 +--- hw/mips/boston.c | 2 +- hw/mips/mips_jazz.c | 2 +- hw/mips/mips_malta.c | 2 +- hw/misc/ivshmem.c | 30 ++-- hw/misc/mips_cmgcr.c | 16 +-- hw/pci-host/apb.c | 29 ++-- hw/ppc/spapr_iommu.c | 42 ++++-- hw/ppc/spapr_rng.c | 8 +- hw/s390x/css.c | 4 +- hw/s390x/s390-pci-bus.c | 31 ++-- hw/s390x/s390-pci-bus.h | 3 +- hw/s390x/s390-pci-inst.c | 11 +- hw/s390x/virtio-ccw.c | 9 -- hw/scsi/virtio-scsi.c | 13 +- hw/usb/ccid-card-passthru.c | 6 +- hw/usb/dev-serial.c | 7 +- hw/usb/redirect.c | 7 +- hw/vfio/common.c | 12 +- hw/vfio/spapr.c | 3 +- hw/virtio/virtio-crypto-pci.c | 2 - hw/virtio/virtio-crypto.c | 27 +--- hw/virtio/virtio-pci.c | 6 - hw/virtio/virtio-rng.c | 12 +- include/block/nbd.h | 58 ++++++-- include/chardev/char-fe.h | 22 +++ include/chardev/char.h | 19 +++ include/exec/exec-all.h | 3 + include/exec/gdbstub.h | 9 -- include/exec/memory.h | 94 ++++++++---- include/hw/i386/intel_iommu.h | 5 +- include/hw/mips/mips.h | 2 +- include/hw/ppc/spapr.h | 7 +- include/hw/qdev-core.h | 6 +- include/hw/qdev-properties.h | 62 ++++---- include/hw/s390x/css.h | 4 +- include/hw/vfio/vfio-common.h | 2 +- include/qemu/typedefs.h | 1 + include/qom/cpu.h | 3 +- include/qom/object.h | 6 +- linux-user/syscall.c | 1 - memory.c | 113 ++++++++++----- monitor.c | 4 +- nbd/client.c | 283 ++++++++++++++++++++++++++++++------ nbd/common.c | 92 ++++++++++++ nbd/nbd-internal.h | 13 +- nbd/server.c | 304 +++++++++++++++++++++++++++++++++------ nbd/trace-events | 25 ++-- net/colo-compare.c | 10 +- net/filter-mirror.c | 8 +- net/slirp.c | 2 +- net/vhost-user.c | 7 +- qapi-schema.json | 40 ++++++ qemu-nbd.c | 10 +- qmp.c | 5 +- qom/cpu.c | 1 + qom/object.c | 8 +- qtest.c | 2 +- target/i386/cpu.c | 2 +- target/ppc/translate_init.c | 2 +- target/xtensa/xtensa-semi.c | 2 +- tests/test-char.c | 275 ++++++++++++++++++++++++++--------- tests/test-hmp.c | 1 + tests/vhost-user-test.c | 2 +- vl.c | 8 +- 123 files changed, 2006 insertions(+), 860 deletions(-)
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 22/55] Revert "exec.c: Fix breakpoint invalidation race"
From: Pranith Kumar <[email protected]>
Now that we have proper locking after MTTCG patches have landed, we can revert the commit. This reverts commit
a9353fe897ca2687e5b3385ed39e3db3927a90e0.
Message-Id: <[email protected]>
--- exec.c | 25 +++++++++++++++++++------ include/exec/exec-all.h | 3 +++ 2 files changed, 22 insertions(+), 6 deletions(-)
exec.c +19 -6
@@ -775,15 +775,28 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)#endif } +#if defined(CONFIG_USER_ONLY )static void breakpoint_invalidate (CPUState *cpu,target_ulong pc) { -/* Flush the whole TB as this will not have race conditions -* even if we don't have proper locking yet. -* Ideally we would just invalidate the TBs for the -* specified PC. -*/ -tb_flush (cpu); +mmap_lock (); +tb_lock (); +tb_invalidate_phys_page_range (pc, pc +1 ,0 ); +tb_unlock (); +mmap_unlock (); } +#else +static void breakpoint_invalidate (CPUState *cpu,target_ulong pc) +{ +MemTxAttrs attrs; +hwaddr phys =cpu_get_phys_page_attrs_debug (cpu, pc, &attrs); +int asidx =cpu_asidx_from_attrs (cpu, attrs); +if (phys !=-1 ) { +/* Locks grabbed by tb_invalidate_phys_addr */ +tb_invalidate_phys_addr (cpu->cpu_ases[asidx].as, + phys | (pc & ~TARGET_PAGE_MASK )); + } +} +#endif #if defined(CONFIG_USER_ONLY )void cpu_watchpoint_remove_all (CPUState *cpu,int mask)
include/exec/exec-all.h +3 -0
@@ -290,6 +290,9 @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, uint16_t idxmap) { } +static inline void tb_invalidate_phys_addr (AddressSpace *as,hwaddr addr) +{ +}#endif #define CODE_GEN_ALIGN 16/* must be >= of the size of a icache line */
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 23/55] mttcg/i386: Patch instruction using async_safe_* framework
In reply to Paolo BonziniFrom: Pranith Kumar <[email protected]>
In mttcg, calling pause_all_vcpus() during execution from the generated TBs causes a deadlock if some vCPU is waiting for exclusive execution in start_exclusive(). Fix this by using the aync_safe_* framework instead of pausing vcpus for patching instructions.
Message-Id: <[email protected]>
--- hw/i386/kvmvapic.c | 85 +++++++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 46 deletions(-)
hw/i386/kvmvapic.c +39 -46
@@ -383,8 +383,7 @@ static void patch_byte(X86CPU *cpu, target_ulong addr, uint8_t byte)cpu_memory_rw_debug (CPU (cpu), addr, &byte,1 ,1 ); } -static void patch_call (VAPICROMState *s,X86CPU *cpu,target_ulong ip, -uint32_t target) +static void patch_call (X86CPU *cpu,target_ulong ip,uint32_t target) {uint32_t offset;
@@ -393,77 +392,71 @@ static void patch_call(VAPICROMState *s, X86CPU *cpu, target_ulong ip,cpu_memory_rw_debug (CPU (cpu), ip +1 , (void *)&offset,sizeof (offset),1 ); } -static void patch_instruction (VAPICROMState *s,X86CPU *cpu,target_ulong ip) +typedef struct PatchInfo { +VAPICHandlers *handler; +target_ulong ip; +}PatchInfo ; + +static void do_patch_instruction (CPUState *cs,run_on_cpu_data data) { -CPUState *cs =CPU (cpu); -CPUX86State *env = &cpu->env; -VAPICHandlers *handlers; +X86CPU *x86_cpu =X86_CPU (cs); +PatchInfo *info = (PatchInfo *) data.host_ptr; +VAPICHandlers *handlers = info->handler; +target_ulong ip = info->ip;uint8_t opcode[2 ];uint32_t imm32 =0 ; -target_ulong current_pc =0 ; -target_ulong current_cs_base =0 ; -uint32_t current_flags =0 ; - -if (smp_cpus ==1 ) { - handlers = &s->rom_state.up; - }else { - handlers = &s->rom_state.mp; - } - -if (tcg_enabled ()) { -cpu_restore_state (cs, cs->mem_io_pc); -cpu_get_tb_cpu_state (env, ¤t_pc, ¤t_cs_base, - ¤t_flags); -/* Account this instruction, because we will exit the tb. -This is the first instruction in the block. Therefore -there is no need in restoring CPU state. */ -if (use_icount) { - --cs->icount_decr.u16.low; - } - } - -pause_all_vcpus ();cpu_memory_rw_debug (cs, ip, opcode,sizeof (opcode),0 );switch (opcode[0 ]) {case 0x89 :/* mov r32 to r/m32 */ -patch_byte (cpu, ip,0x50 +modrm_reg (opcode[1 ]));/* push reg */ -patch_call (s, cpu, ip +1 , handlers->set_tpr); +patch_byte (x86_cpu, ip,0x50 +modrm_reg (opcode[1 ]));/* push reg */ +patch_call (x86_cpu, ip +1 , handlers->set_tpr);break ;case 0x8b :/* mov r/m32 to r32 */ -patch_byte (cpu, ip,0x90 ); -patch_call (s, cpu, ip +1 , handlers->get_tpr[modrm_reg (opcode[1 ])]); +patch_byte (x86_cpu, ip,0x90 ); +patch_call (x86_cpu, ip +1 , handlers->get_tpr[modrm_reg (opcode[1 ])]);break ;case 0xa1 :/* mov abs to eax */ -patch_call (s, cpu, ip, handlers->get_tpr[0 ]); +patch_call (x86_cpu, ip, handlers->get_tpr[0 ]);break ;case 0xa3 :/* mov eax to abs */ -patch_call (s, cpu, ip, handlers->set_tpr_eax); +patch_call (x86_cpu, ip, handlers->set_tpr_eax);break ;case 0xc7 :/* mov imm32, r/m32 (c7/0) */ -patch_byte (cpu, ip,0x68 );/* push imm32 */ +patch_byte (x86_cpu, ip,0x68 );/* push imm32 */ cpu_memory_rw_debug (cs, ip +6 , (void *)&imm32,sizeof (imm32),0 );cpu_memory_rw_debug (cs, ip +1 , (void *)&imm32,sizeof (imm32),1 ); -patch_call (s, cpu, ip +5 , handlers->set_tpr); +patch_call (x86_cpu, ip +5 , handlers->set_tpr);break ;case 0xff :/* push r/m32 */ -patch_byte (cpu, ip,0x50 );/* push eax */ -patch_call (s, cpu, ip +1 , handlers->get_tpr_stack); +patch_byte (x86_cpu, ip,0x50 );/* push eax */ +patch_call (x86_cpu, ip +1 , handlers->get_tpr_stack);break ;default :abort (); } -resume_all_vcpus (); +g_free (info); +} + +static void patch_instruction (VAPICROMState *s,X86CPU *cpu,target_ulong ip) +{ +CPUState *cs =CPU (cpu); +VAPICHandlers *handlers; +PatchInfo *info; -if (tcg_enabled ()) { -/* Both tb_lock and iothread_mutex will be reset when -* longjmps back into the cpu_exec loop. */ -tb_lock (); -tb_gen_code (cs, current_pc, current_cs_base, current_flags,1 ); -cpu_loop_exit_noexc (cs); +if (smp_cpus ==1 ) { + handlers = &s->rom_state.up; + }else { + handlers = &s->rom_state.mp; } + + info =g_new (PatchInfo,1 ); + info->handler = handlers; + info->ip = ip; + +async_safe_run_on_cpu (cs, do_patch_instruction,RUN_ON_CPU_HOST_PTR (info)); } void vapic_report_tpr_access(DeviceState *dev, CPUState *cs, target_ulong ip,
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 42/55] qom: enforce readonly nature of link's check callback
In reply to Paolo BonziniFrom: Igor Mammedov <[email protected]>
link's check callback is supposed to verify/permit setting it, however currently nothing restricts it from misusing it and modifying target object from within.
Make sure that readonly semantics are checked by compiler to prevent callback's misuse.
Message-Id: <[email protected]>
--- hw/core/qdev-properties.c | 3 ++- hw/display/xlnx_dp.c | 2 +- hw/ipmi/ipmi.c | 2 +- hw/mem/pc-dimm.c | 2 +- hw/misc/ivshmem.c | 2 +- hw/virtio/virtio-crypto.c | 2 +- include/hw/qdev-properties.h | 3 ++- include/qom/object.h | 6 +++--- qom/object.c | 8 ++++---- 9 files changed, 16 insertions(+), 14 deletions(-)
hw/core/qdev-properties.c +2 -1
@@ -25,7 +25,8 @@ void qdev_prop_set_after_realize(DeviceState *dev, const char *name, } } -void qdev_prop_allow_set_link_before_realize (Object *obj,const char *name, +void qdev_prop_allow_set_link_before_realize (const Object *obj, +const char *name,Object *val,Error **errp) {DeviceState *dev =DEVICE (obj);
hw/display/xlnx_dp.c +1 -1
@@ -515,7 +515,7 @@ static void xlnx_dp_aux_set_command(XlnxDPState *s, uint32_t value) s->core_registers[DP_INTERRUPT_SIGNAL_STATE ] |=0x04 ; } -static void xlnx_dp_set_dpdma (Object *obj,const char *name,Object *val, +static void xlnx_dp_set_dpdma (const Object *obj,const char *name,Object *val,Error **errp) {XlnxDPState *s =XLNX_DP (obj);
hw/ipmi/ipmi.c +1 -1
@@ -90,7 +90,7 @@ static TypeInfo ipmi_interface_type_info = { .class_init = ipmi_interface_class_init, }; -static void isa_ipmi_bmc_check (Object *obj,const char *name, +static void isa_ipmi_bmc_check (const Object *obj,const char *name,Object *val,Error **errp) {IPMIBmc *bmc =IPMI_BMC (val);
hw/mem/pc-dimm.c +1 -1
@@ -367,7 +367,7 @@ static void pc_dimm_get_size(Object *obj, Visitor *v, const char *name,visit_type_uint64 (v, name, &value, errp); } -static void pc_dimm_check_memdev_is_busy (Object *obj,const char *name, +static void pc_dimm_check_memdev_is_busy (const Object *obj,const char *name,Object *val,Error **errp) {Error *local_err =NULL ;
hw/misc/ivshmem.c +1 -1
@@ -1009,7 +1009,7 @@ static const TypeInfo ivshmem_common_info = { .class_init = ivshmem_common_class_init, }; -static void ivshmem_check_memdev_is_busy (Object *obj,const char *name, +static void ivshmem_check_memdev_is_busy (const Object *obj,const char *name,Object *val,Error **errp) {if (host_memory_backend_is_mapped (MEMORY_BACKEND (val))) {
hw/virtio/virtio-crypto.c +1 -1
@@ -889,7 +889,7 @@ static void virtio_crypto_class_init(ObjectClass *klass, void *data) }static void -virtio_crypto_check_cryptodev_is_used (Object *obj,const char *name, +virtio_crypto_check_cryptodev_is_used (const Object *obj,const char *name,Object *val,Error **errp) {if (cryptodev_backend_is_used (CRYPTODEV_BACKEND (val))) {
include/hw/qdev-properties.h +2 -1
@@ -272,7 +272,8 @@ void qdev_prop_set_after_realize(DeviceState *dev, const char *name,* This function should be used as the check() argument to * object_property_add_link(). */ -void qdev_prop_allow_set_link_before_realize (Object *obj,const char *name, +void qdev_prop_allow_set_link_before_realize (const Object *obj, +const char *name,Object *val,Error **errp);#endif
include/qom/object.h +3 -3
@@ -764,7 +764,7 @@ ObjectClass *object_get_class(Object *obj);* * Returns: The QOM typename of @obj. */ -const char *object_get_typename (Object *obj); +const char *object_get_typename (const Object *obj);/** * type_register_static:
@@ -1319,7 +1319,7 @@ typedef enum {* callback function. It allows the link property to be set and never returns * an error. */ -void object_property_allow_set_link (Object *,const char *, +void object_property_allow_set_link (const Object *,const char *,Object *,Error **);/**
@@ -1352,7 +1352,7 @@ void object_property_allow_set_link(Object *, const char *,*/ void object_property_add_link (Object *obj,const char *name,const char *type,Object **child, -void (*check)(Object *obj,const char *name, +void (*check)(const Object *obj,const char *name,Object *val,Error **errp),ObjectPropertyLinkFlags flags,Error **errp);
qom/object.c +4 -4
@@ -740,7 +740,7 @@ out:return ret; } -const char *object_get_typename (Object *obj) +const char *object_get_typename (const Object *obj) {return obj->class->type->name; }
@@ -1428,7 +1428,7 @@ out:g_free (type); } -void object_property_allow_set_link (Object *obj,const char *name, +void object_property_allow_set_link (const Object *obj,const char *name,Object *val,Error **errp) {/* Allow the link to be set, always */
@@ -1436,7 +1436,7 @@ void object_property_allow_set_link(Object *obj, const char *name,typedef struct {Object **child; -void (*check)(Object *,const char *,Object *,Error **); +void (*check)(const Object *,const char *,Object *,Error **);ObjectPropertyLinkFlags flags; }LinkProperty ;
@@ -1552,7 +1552,7 @@ static void object_release_link_property(Object *obj, const char *name,void object_property_add_link (Object *obj,const char *name,const char *type,Object **child, -void (*check)(Object *,const char *, +void (*check)(const Object *,const char *,Object *,Error **),ObjectPropertyLinkFlags flags,Error **errp)
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 43/55] qdev: Introduce PropertyInfo.create
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
This allows property implementation to provide a specialized property creation method.
Update conditions guarding property types accordingly.
Message-Id: <[email protected]>
--- hw/core/qdev.c | 31 +++++++++++++++++++------------ include/hw/qdev-core.h | 1 + qmp.c | 2 +- 3 files changed, 21 insertions(+), 13 deletions(-)
hw/core/qdev.c +19 -12
@@ -744,6 +744,10 @@ static void qdev_property_add_legacy(DeviceState *dev, Property *prop,return ; } +if (prop->info->create) { +return ; + } + name =g_strdup_printf ("legacy-%s" , prop->name); object_property_add(OBJECT(dev), name, "str", prop->info->print ? qdev_get_legacy_property : prop->info->get,
@@ -770,20 +774,23 @@ void qdev_property_add_static(DeviceState *dev, Property *prop,Error *local_err =NULL ;Object *obj =OBJECT (dev); -/* -* TODO qdev_prop_ptr does not have getters or setters. It must -* go now that it can be replaced with links. The test should be -* removed along with it: all static properties are read/write. -*/ -if (!prop->info->get && !prop->info->set) { -return ; +if (prop->info->create) { + prop->info->create (obj, prop, &local_err); + }else { +/* +* TODO qdev_prop_ptr does not have getters or setters. It must +* go now that it can be replaced with links. The test should be +* removed along with it: all static properties are read/write. +*/ +if (!prop->info->get && !prop->info->set) { +return ; + } +object_property_add (obj, prop->name, prop->info->name, + prop->info->get, prop->info->set, + prop->info->release, + prop, &local_err); } -object_property_add (obj, prop->name, prop->info->name, - prop->info->get, prop->info->set, - prop->info->release, - prop, &local_err); -if (local_err) {error_propagate (errp, local_err);return ;
include/hw/qdev-core.h +1 -0
@@ -241,6 +241,7 @@ struct PropertyInfo {const char *const *enum_table;int (*print)(DeviceState *dev,Property *prop,char *dest,size_t len);void (*set_default_value)(Object *obj,const Property *prop); +void (*create)(Object *obj,Property *prop,Error **errp);ObjectPropertyAccessor *get;ObjectPropertyAccessor *set;ObjectPropertyRelease *release;
qmp.c +1 -1
@@ -480,7 +480,7 @@ static DevicePropertyInfo *make_device_property_info(ObjectClass *klass,* for removal. This conditional should be removed along with * it. */ -if (!prop->info->set) { +if (!prop->info->set && !prop->info->create) {return NULL ;/* no way to set it, don't show */ }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 44/55] qdev: Introduce DEFINE_PROP_LINK
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
This property can be used to replace the object_property_add_link in device code, to add a link to other objects, which is a common pattern.
Message-Id: <[email protected]>
--- hw/core/qdev-properties.c | 18 ++++++++++++++++++ include/hw/qdev-core.h | 1 + include/hw/qdev-properties.h | 9 +++++++++ 3 files changed, 28 insertions(+)
hw/core/qdev-properties.c +18 -0
@@ -1214,3 +1214,21 @@ PropertyInfo qdev_prop_size = { .set = set_size, .set_default_value = set_default_value_uint, }; + +/* --- object link property --- */ + +static void create_link_property (Object *obj,Property *prop,Error **errp) +{ +Object **child =qdev_get_prop_ptr (DEVICE (obj), prop); + +object_property_add_link (obj, prop->name, prop->link_type, + child, + qdev_prop_allow_set_link_before_realize, +OBJ_PROP_LINK_UNREF_ON_RELEASE , + errp); +} + +PropertyInfo qdev_prop_link = { + .name ="link" , + .create = create_link_property, +};
include/hw/qdev-core.h +1 -0
@@ -233,6 +233,7 @@ struct Property {int arrayoffset;PropertyInfo *arrayinfo;int arrayfieldsize; +const char *link_type; };struct PropertyInfo {
include/hw/qdev-properties.h +9 -0
@@ -30,6 +30,7 @@ extern PropertyInfo qdev_prop_pci_devfn;extern PropertyInfo qdev_prop_blocksize;extern PropertyInfo qdev_prop_pci_host_devaddr;extern PropertyInfo qdev_prop_arraylen; +extern PropertyInfo qdev_prop_link;#define DEFINE_PROP (_name, _state, _field, _prop, _type) { \ .name = (_name), \
@@ -117,6 +118,14 @@ extern PropertyInfo qdev_prop_arraylen; .arrayoffset = offsetof(_state, _arrayfield), \ } +#define DEFINE_PROP_LINK (_name, _state, _field, _type, _ptr_type) { \ + .name = (_name), \ + .info = &(qdev_prop_link), \ + .offset = offsetof(_state, _field) \ + + type_check(_ptr_type, typeof_field(_state, _field)), \ + .link_type = _type, \ + } +#define DEFINE_PROP_UINT8 (_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)#define DEFINE_PROP_UINT16 (_n, _s, _f, _d) \
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 45/55] qmp: Use ObjectProperty.type if present
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
The dynamic value is more informative in the case of link property, otherwise it is the same.
Message-Id: <[email protected]>
--- qmp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
qmp.c +2 -1
@@ -486,7 +486,8 @@ static DevicePropertyInfo *make_device_property_info(ObjectClass *klass, info =g_malloc0 (sizeof (*info)); info->name =g_strdup (prop->name); - info->type =g_strdup (prop->info->name); + info->type = default_type ?g_strdup (default_type) + :g_strdup (prop->info->name); info->has_description = !!prop->info->description; info->description =g_strdup (prop->info->description);return info;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 46/55] qdev: Add const qualifier to PropertyInfo definitions
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
The remaining non-const ones are in e1000e which modifies description at runtime. They can be addressed separatedly.
Message-Id: <[email protected]>
--- hw/core/qdev-properties-system.c | 8 +++---- hw/core/qdev-properties.c | 44 +++++++++++++++++----------------- hw/s390x/css.c | 4 ++-- hw/s390x/s390-pci-bus.c | 2 +- include/hw/qdev-core.h | 4 ++-- include/hw/qdev-properties.h | 52 ++++++++++++++++++++-------------------- include/hw/s390x/css.h | 4 ++-- target/i386/cpu.c | 2 +- target/ppc/translate_init.c | 2 +- 9 files changed, 61 insertions(+), 61 deletions(-)
hw/core/qdev-properties-system.c +4 -4
@@ -159,7 +159,7 @@ static void set_drive(Object *obj, Visitor *v, const char *name, void *opaque,set_pointer (obj, v, opaque, parse_drive, name, errp); } -PropertyInfo qdev_prop_drive = { +const PropertyInfo qdev_prop_drive = { .name ="str" , .description ="Node name or ID of a block device to use as a backend" , .get = get_drive,
@@ -228,7 +228,7 @@ static void release_chr(Object *obj, const char *name, void *opaque)qemu_chr_fe_deinit (be, false); } -PropertyInfo qdev_prop_chr = { +const PropertyInfo qdev_prop_chr = { .name ="str" , .description ="ID of a chardev to use as a backend" , .get = get_chr,
@@ -313,7 +313,7 @@ out:g_free (str); } -PropertyInfo qdev_prop_netdev = { +const PropertyInfo qdev_prop_netdev = { .name ="str" , .description ="ID of a netdev to use as a backend" , .get = get_netdev,
@@ -393,7 +393,7 @@ static void set_vlan(Object *obj, Visitor *v, const char *name, void *opaque, *ptr = hubport; } -PropertyInfo qdev_prop_vlan = { +const PropertyInfo qdev_prop_vlan = { .name ="int32" , .description ="Integer VLAN id to connect to" , .print = print_vlan,
hw/core/qdev-properties.c +22 -22
176 lines not on this page · raw message
hw/s390x/css.c +2 -2
@@ -2095,7 +2095,7 @@ out:g_free (str); } -PropertyInfo css_devid_propinfo = { +const PropertyInfo css_devid_propinfo = { .name ="str" , .description ="Identifier of an I/O device in the channel " "subsystem, example: fe.1.23ab" ,
@@ -2103,7 +2103,7 @@ PropertyInfo css_devid_propinfo = { .set = set_css_devid, }; -PropertyInfo css_devid_ro_propinfo = { +const PropertyInfo css_devid_ro_propinfo = { .name ="str" , .description ="Read-only identifier of an I/O device in the channel " "subsystem, example: fe.1.23ab" ,
hw/s390x/s390-pci-bus.c +1 -1
@@ -1015,7 +1015,7 @@ static void s390_pci_set_fid(Object *obj, Visitor *v, const char *name, zpci->fid_defined = true; } -static PropertyInfo s390_pci_fid_propinfo = { +static const PropertyInfo s390_pci_fid_propinfo = { .name ="zpci_fid" , .get = s390_pci_get_fid, .set = s390_pci_set_fid,
include/hw/qdev-core.h +2 -2
@@ -223,7 +223,7 @@ struct BusState {struct Property {const char *name; -PropertyInfo *info; +const PropertyInfo *info;ptrdiff_t offset;uint8_t bitnr;union {
@@ -231,7 +231,7 @@ struct Property {uint64_t u; } defval;int arrayoffset; -PropertyInfo *arrayinfo; +const PropertyInfo *arrayinfo;int arrayfieldsize;const char *link_type; };
include/hw/qdev-properties.h +26 -26
58 lines not on this page · raw message
include/hw/s390x/css.h +2 -2
@@ -112,7 +112,7 @@ typedef struct CssDevId {bool valid; } CssDevId; -extern PropertyInfo css_devid_propinfo; +extern const PropertyInfo css_devid_propinfo;#define DEFINE_PROP_CSS_DEV_ID (_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, css_devid_propinfo, CssDevId)
@@ -196,7 +196,7 @@ int css_do_rchp(uint8_t cssid, uint8_t chpid);bool css_present (uint8_t cssid);#endif -extern PropertyInfo css_devid_ro_propinfo; +extern const PropertyInfo css_devid_ro_propinfo;#define DEFINE_PROP_CSS_DEV_ID_RO (_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, css_devid_ro_propinfo, CssDevId)
target/i386/cpu.c +1 -1
@@ -1961,7 +1961,7 @@ static void x86_set_hv_spinlocks(Object *obj, Visitor *v, const char *name, cpu->hyperv_spinlock_attempts = value; } -static PropertyInfo qdev_prop_spinlocks = { +static const PropertyInfo qdev_prop_spinlocks = { .name ="int" , .get = x86_get_hv_spinlocks, .set = x86_set_hv_spinlocks,
target/ppc/translate_init.c +1 -1
@@ -8435,7 +8435,7 @@ static void getset_compat_deprecated(Object *obj, Visitor *v, const char *name,visit_type_null (v, name,NULL ); } -static PropertyInfo ppc_compat_deprecated_propinfo = { +static const PropertyInfo ppc_compat_deprecated_propinfo = { .name ="str" , .description ="compatibility mode (deprecated)" , .get = getset_compat_deprecated,
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 47/55] virtio-blk: Convert to DEFINE_PROP_LINK
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
Message-Id: <[email protected]>
--- hw/block/virtio-blk.c | 6 ++---- hw/s390x/virtio-ccw.c | 2 -- hw/virtio/virtio-pci.c | 2 -- 3 files changed, 2 insertions(+), 8 deletions(-)
hw/block/virtio-blk.c +2 -4
@@ -983,10 +983,6 @@ static void virtio_blk_instance_init(Object *obj) {VirtIOBlock *s =VIRTIO_BLK (obj); -object_property_add_link (obj,"iothread" ,TYPE_IOTHREAD , - (Object **)&s->conf.iothread, - qdev_prop_allow_set_link_before_realize, -OBJ_PROP_LINK_UNREF_ON_RELEASE ,NULL );device_add_bootindex_property (obj, &s->conf.conf.bootindex,"bootindex" ,"/disk@0,0" ,DEVICE (obj),NULL );
@@ -1014,6 +1010,8 @@ static Property virtio_blk_properties[] = {DEFINE_PROP_BIT ("request-merging" , VirtIOBlock, conf.request_merging,0 , true),DEFINE_PROP_UINT16 ("num-queues" , VirtIOBlock, conf.num_queues,1 ), +DEFINE_PROP_LINK ("iothread" , VirtIOBlock, conf.iothread,TYPE_IOTHREAD , + IOThread *), DEFINE_PROP_END_OF_LIST(), };
hw/s390x/virtio-ccw.c +0 -2
@@ -867,8 +867,6 @@ static void virtio_ccw_blk_instance_init(Object *obj)virtio_instance_init_common (obj, &dev->vdev,sizeof (dev->vdev),TYPE_VIRTIO_BLK ); -object_property_add_alias (obj,"iothread" ,OBJECT (&dev->vdev),"iothread" , - &error_abort);object_property_add_alias (obj,"bootindex" ,OBJECT (&dev->vdev),"bootindex" , &error_abort); }
hw/virtio/virtio-pci.c +0 -2
@@ -2000,8 +2000,6 @@ static void virtio_blk_pci_instance_init(Object *obj)virtio_instance_init_common (obj, &dev->vdev,sizeof (dev->vdev),TYPE_VIRTIO_BLK ); -object_property_add_alias (obj,"iothread" ,OBJECT (&dev->vdev),"iothread" , - &error_abort);object_property_add_alias (obj,"bootindex" ,OBJECT (&dev->vdev),"bootindex" , &error_abort); }
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 49/55] virtio-rng: Convert to DEFINE_PROP_LINK
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
Message-Id: <[email protected]>
--- hw/s390x/virtio-ccw.c | 2 -- hw/virtio/virtio-pci.c | 2 -- hw/virtio/virtio-rng.c | 12 +----------- 3 files changed, 1 insertion(+), 15 deletions(-)
hw/s390x/virtio-ccw.c +0 -2
@@ -1548,8 +1548,6 @@ static void virtio_ccw_rng_instance_init(Object *obj)virtio_instance_init_common (obj, &dev->vdev,sizeof (dev->vdev),TYPE_VIRTIO_RNG ); -object_property_add_alias (obj,"rng" ,OBJECT (&dev->vdev), -"rng" , &error_abort); }static Property virtio_ccw_rng_properties[] = {
hw/virtio/virtio-pci.c +0 -2
@@ -2463,8 +2463,6 @@ static void virtio_rng_initfn(Object *obj)virtio_instance_init_common (obj, &dev->vdev,sizeof (dev->vdev),TYPE_VIRTIO_RNG ); -object_property_add_alias (obj,"rng" ,OBJECT (&dev->vdev),"rng" , - &error_abort); }static const TypeInfo virtio_rng_pci_info = {
hw/virtio/virtio-rng.c +1 -11
@@ -246,6 +246,7 @@ static Property virtio_rng_properties[] = {*/ DEFINE_PROP_UINT64 ("max-bytes" , VirtIORNG, conf.max_bytes,INT64_MAX ),DEFINE_PROP_UINT32 ("period" , VirtIORNG, conf.period_ms,1 <<16 ), + DEFINE_PROP_LINK("rng", VirtIORNG, conf.rng, TYPE_RNG_BACKEND, RngBackend *), DEFINE_PROP_END_OF_LIST(), };
@@ -262,21 +263,10 @@ static void virtio_rng_class_init(ObjectClass *klass, void *data) vdc->get_features = get_features; } -static void virtio_rng_initfn (Object *obj) -{ -VirtIORNG *vrng =VIRTIO_RNG (obj); - -object_property_add_link (obj,"rng" ,TYPE_RNG_BACKEND , - (Object **)&vrng->conf.rng, - qdev_prop_allow_set_link_before_realize, -OBJ_PROP_LINK_UNREF_ON_RELEASE ,NULL ); -} -static const TypeInfo virtio_rng_info = { .name =TYPE_VIRTIO_RNG , .parent =TYPE_VIRTIO_DEVICE , .instance_size =sizeof (VirtIORNG), - .instance_init = virtio_rng_initfn, .class_init = virtio_rng_class_init, };
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 48/55] virtio-scsi: Convert to DEFINE_PROP_LINK
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
Message-Id: <[email protected]>
--- hw/s390x/virtio-ccw.c | 2 -- hw/scsi/virtio-scsi.c | 13 ++----------- hw/virtio/virtio-pci.c | 2 -- 3 files changed, 2 insertions(+), 15 deletions(-)
hw/s390x/virtio-ccw.c +0 -2
@@ -950,8 +950,6 @@ static void virtio_ccw_scsi_instance_init(Object *obj)virtio_instance_init_common (obj, &dev->vdev,sizeof (dev->vdev),TYPE_VIRTIO_SCSI ); -object_property_add_alias (obj,"iothread" ,OBJECT (&dev->vdev),"iothread" , - &error_abort); }#ifdef CONFIG_VHOST_SCSI
hw/scsi/virtio-scsi.c +2 -11
@@ -898,16 +898,6 @@ static void virtio_scsi_device_realize(DeviceState *dev, Error **errp)virtio_scsi_dataplane_setup (s, errp); } -static void virtio_scsi_instance_init (Object *obj) -{ -VirtIOSCSICommon *vs =VIRTIO_SCSI_COMMON (obj); - -object_property_add_link (obj,"iothread" ,TYPE_IOTHREAD , - (Object **)&vs->conf.iothread, - qdev_prop_allow_set_link_before_realize, -OBJ_PROP_LINK_UNREF_ON_RELEASE , &error_abort); -} -void virtio_scsi_common_unrealize (DeviceState *dev,Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);
@@ -935,6 +925,8 @@ static Property virtio_scsi_properties[] = { VIRTIO_SCSI_F_HOTPLUG, true),DEFINE_PROP_BIT ("param_change" , VirtIOSCSI, host_features,VIRTIO_SCSI_F_CHANGE , true), +DEFINE_PROP_LINK ("iothread" , VirtIOSCSI, parent_obj.conf.iothread, + TYPE_IOTHREAD, IOThread *), DEFINE_PROP_END_OF_LIST(), };
@@ -989,7 +981,6 @@ static const TypeInfo virtio_scsi_info = { .name = TYPE_VIRTIO_SCSI, .parent = TYPE_VIRTIO_SCSI_COMMON, .instance_size = sizeof(VirtIOSCSI), - .instance_init = virtio_scsi_instance_init, .class_init = virtio_scsi_class_init, .interfaces = (InterfaceInfo []) { {TYPE_HOTPLUG_HANDLER },
hw/virtio/virtio-pci.c +0 -2
@@ -2069,8 +2069,6 @@ static void virtio_scsi_pci_instance_init(Object *obj)virtio_instance_init_common (obj, &dev->vdev,sizeof (dev->vdev),TYPE_VIRTIO_SCSI ); -object_property_add_alias (obj,"iothread" ,OBJECT (&dev->vdev),"iothread" , - &error_abort); }static const TypeInfo virtio_scsi_pci_info = {
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 50/55] virtio-crypto: Convert to DEFINE_PROP_LINK
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
Unlike other object_property_add_link() occurrences in virtio devices, virtio-crypto checks the "in use" state of the linked backend object in addition to qdev_prop_allow_set_link_before_realize. To convert it without needing to specialize DEFINE_PROP_LINK which always uses the qdev callback, move the "in use" check to device realize time.
Message-Id: <[email protected]>
--- hw/s390x/virtio-ccw.c | 3 --- hw/virtio/virtio-crypto-pci.c | 2 -- hw/virtio/virtio-crypto.c | 27 +++++++-------------------- 3 files changed, 7 insertions(+), 25 deletions(-)
hw/s390x/virtio-ccw.c +0 -3
@@ -1594,9 +1594,6 @@ static void virtio_ccw_crypto_instance_init(Object *obj) ccw_dev->force_revision_1 = true;virtio_instance_init_common (obj, &dev->vdev,sizeof (dev->vdev),TYPE_VIRTIO_CRYPTO ); - -object_property_add_alias (obj,"cryptodev" ,OBJECT (&dev->vdev), -"cryptodev" , &error_abort); }static void virtio_ccw_crypto_class_init (ObjectClass *klass,void *data)
hw/virtio/virtio-crypto-pci.c +0 -2
@@ -62,8 +62,6 @@ static void virtio_crypto_initfn(Object *obj)virtio_instance_init_common (obj, &dev->vdev,sizeof (dev->vdev),TYPE_VIRTIO_CRYPTO ); -object_property_add_alias (obj,"cryptodev" ,OBJECT (&dev->vdev), -"cryptodev" , &error_abort); }static const TypeInfo virtio_crypto_pci_info = {
hw/virtio/virtio-crypto.c +7 -20
@@ -781,6 +781,11 @@ static void virtio_crypto_device_realize(DeviceState *dev, Error **errp)if (vcrypto->cryptodev ==NULL ) {error_setg (errp,"'cryptodev' parameter expects a valid object" );return ; + }else if (cryptodev_backend_is_used (vcrypto->cryptodev)) { +char *path =object_get_canonical_path_component (OBJECT (vcrypto->conf.cryptodev)); +error_setg (errp,"can't use already used cryptodev backend: %s" , path); +g_free (path); +return ; } vcrypto->max_queues =MAX (vcrypto->cryptodev->conf.peers.queues,1 );
@@ -845,6 +850,8 @@ static const VMStateDescription vmstate_virtio_crypto = { };static Property virtio_crypto_properties[] = { +DEFINE_PROP_LINK ("cryptodev" , VirtIOCrypto, conf.cryptodev, + TYPE_CRYPTODEV_BACKEND, CryptoDevBackend *),DEFINE_PROP_END_OF_LIST (), };
@@ -888,20 +895,6 @@ static void virtio_crypto_class_init(ObjectClass *klass, void *data) vdc->reset = virtio_crypto_reset; } -static void -virtio_crypto_check_cryptodev_is_used (const Object *obj,const char *name, -Object *val,Error **errp) -{ -if (cryptodev_backend_is_used (CRYPTODEV_BACKEND (val))) { -char *path =object_get_canonical_path_component (val); -error_setg (errp, -"can't use already used cryptodev backend: %s" , path); -g_free (path); - }else { -qdev_prop_allow_set_link_before_realize (obj, name, val, errp); - } -} -static void virtio_crypto_instance_init (Object *obj) {VirtIOCrypto *vcrypto =VIRTIO_CRYPTO (obj);
@@ -911,12 +904,6 @@ static void virtio_crypto_instance_init(Object *obj)* Can be overriden with virtio_crypto_set_config_size. */ vcrypto->config_size =sizeof (struct virtio_crypto_config ); - -object_property_add_link (obj,"cryptodev" , -TYPE_CRYPTODEV_BACKEND , - (Object **)&vcrypto->conf.cryptodev, - virtio_crypto_check_cryptodev_is_used, -OBJ_PROP_LINK_UNREF_ON_RELEASE ,NULL ); }static const TypeInfo virtio_crypto_info = {
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 51/55] dimm: Convert to DEFINE_PROP_LINK
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
Unlike the usual object_property_add_link() invocations in other devices, dimm checks the "is mapped" state of the backend in addition to qdev_prop_allow_set_link_before_realize. To convert it without specializing DEFINE_PROP_LINK which always uses the qdev general check callback, move the extra check to device realize time.
Message-Id: <[email protected]>
--- hw/mem/pc-dimm.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-)
hw/mem/pc-dimm.c +7 -23
@@ -350,6 +350,8 @@ static Property pc_dimm_properties[] = {DEFINE_PROP_UINT32 (PC_DIMM_NODE_PROP , PCDIMMDevice, node,0 ),DEFINE_PROP_INT32 (PC_DIMM_SLOT_PROP , PCDIMMDevice, slot,PC_DIMM_UNASSIGNED_SLOT ), +DEFINE_PROP_LINK (PC_DIMM_MEMDEV_PROP , PCDIMMDevice, hostmem, + TYPE_MEMORY_BACKEND, HostMemoryBackend *), DEFINE_PROP_END_OF_LIST(), };
@@ -367,33 +369,10 @@ static void pc_dimm_get_size(Object *obj, Visitor *v, const char *name,visit_type_uint64 (v, name, &value, errp); } -static void pc_dimm_check_memdev_is_busy (const Object *obj,const char *name, -Object *val,Error **errp) -{ -Error *local_err =NULL ; - -if (host_memory_backend_is_mapped (MEMORY_BACKEND (val))) { -char *path =object_get_canonical_path_component (val); -error_setg (&local_err,"can't use already busy memdev: %s" , path); -g_free (path); - }else { -qdev_prop_allow_set_link_before_realize (obj, name, val, &local_err); - } - -error_propagate (errp, local_err); -} -static void pc_dimm_init (Object *obj) { -PCDIMMDevice *dimm =PC_DIMM (obj); -object_property_add (obj,PC_DIMM_SIZE_PROP ,"uint64" , pc_dimm_get_size,NULL ,NULL ,NULL , &error_abort); -object_property_add_link (obj,PC_DIMM_MEMDEV_PROP ,TYPE_MEMORY_BACKEND , - (Object **)&dimm->hostmem, - pc_dimm_check_memdev_is_busy, -OBJ_PROP_LINK_UNREF_ON_RELEASE , - &error_abort); }static void pc_dimm_realize (DeviceState *dev,Error **errp)
@@ -404,6 +383,11 @@ static void pc_dimm_realize(DeviceState *dev, Error **errp)if (!dimm->hostmem) {error_setg (errp,"'" PC_DIMM_MEMDEV_PROP "' property is not set" );return ; + }else if (host_memory_backend_is_mapped (dimm->hostmem)) { +char *path =object_get_canonical_path_component (OBJECT (dimm->hostmem)); +error_setg (errp,"can't use already busy memdev: %s" , path); +g_free (path); +return ; }if (((nb_numa_nodes >0 ) && (dimm->node >= nb_numa_nodes)) || (!nb_numa_nodes && dimm->node)) {
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 52/55] ivshmem: Convert to DEFINE_PROP_LINK
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
Unlike the usual object_property_add_link() invocations in other devices, ivshmem checks the "is mapped" state of the backend in addition to qdev_prop_allow_set_link_before_realize. To convert it without specializing DEFINE_PROP_LINK which always uses the qdev callback, move the extra check to device realize time.
Message-Id: <[email protected]>
--- hw/misc/ivshmem.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-)
hw/misc/ivshmem.c +7 -17
@@ -1009,18 +1009,6 @@ static const TypeInfo ivshmem_common_info = { .class_init = ivshmem_common_class_init, }; -static void ivshmem_check_memdev_is_busy (const Object *obj,const char *name, -Object *val,Error **errp) -{ -if (host_memory_backend_is_mapped (MEMORY_BACKEND (val))) { -char *path =object_get_canonical_path_component (val); -error_setg (errp,"can't use already busy memdev: %s" , path); -g_free (path); - }else { -qdev_prop_allow_set_link_before_realize (obj, name, val, errp); - } -} -static const VMStateDescription ivshmem_plain_vmsd = { .name =TYPE_IVSHMEM_PLAIN , .version_id =0 ,
@@ -1037,6 +1025,8 @@ static const VMStateDescription ivshmem_plain_vmsd = {static Property ivshmem_plain_properties[] = {DEFINE_PROP_ON_OFF_AUTO ("master" , IVShmemState, master,ON_OFF_AUTO_OFF ), +DEFINE_PROP_LINK ("memdev" , IVShmemState, hostmem,TYPE_MEMORY_BACKEND , + HostMemoryBackend *),DEFINE_PROP_END_OF_LIST (), };
@@ -1044,11 +1034,6 @@ static void ivshmem_plain_init(Object *obj) {IVShmemState *s =IVSHMEM_PLAIN (obj); -object_property_add_link (obj,"memdev" ,TYPE_MEMORY_BACKEND , - (Object **)&s->hostmem, - ivshmem_check_memdev_is_busy, -OBJ_PROP_LINK_UNREF_ON_RELEASE , - &error_abort); s->not_legacy_32bit =1 ; }
@@ -1059,6 +1044,11 @@ static void ivshmem_plain_realize(PCIDevice *dev, Error **errp)if (!s->hostmem) {error_setg (errp,"You must specify a 'memdev'" );return ; + }else if (host_memory_backend_is_mapped (s->hostmem)) { +char *path =object_get_canonical_path_component (OBJECT (s->hostmem)); +error_setg (errp,"can't use already busy memdev: %s" , path); +g_free (path); +return ; }ivshmem_common_realize (dev, errp);
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 53/55] mips_cmgcr: Convert to DEFINE_PROP_LINK
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
Message-Id: <[email protected]>
--- hw/misc/mips_cmgcr.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
hw/misc/mips_cmgcr.c +4 -12
@@ -181,18 +181,6 @@ static void mips_gcr_init(Object *obj)SysBusDevice *sbd =SYS_BUS_DEVICE (obj);MIPSGCRState *s =MIPS_GCR (obj); -object_property_add_link (obj,"gic" ,TYPE_MEMORY_REGION , - (Object **)&s->gic_mr, - qdev_prop_allow_set_link_before_realize, -OBJ_PROP_LINK_UNREF_ON_RELEASE , - &error_abort); - -object_property_add_link (obj,"cpc" ,TYPE_MEMORY_REGION , - (Object **)&s->cpc_mr, - qdev_prop_allow_set_link_before_realize, -OBJ_PROP_LINK_UNREF_ON_RELEASE , - &error_abort); -memory_region_init_io (&s->iomem,OBJECT (s), &gcr_ops, s,"mips-gcr" ,GCR_ADDRSPACE_SZ );sysbus_init_mmio (sbd, &s->iomem);
@@ -227,6 +215,10 @@ static Property mips_gcr_properties[] = {DEFINE_PROP_INT32 ("num-vp" , MIPSGCRState, num_vps,1 ),DEFINE_PROP_INT32 ("gcr-rev" , MIPSGCRState, gcr_rev,0x800 ),DEFINE_PROP_UINT64 ("gcr-base" , MIPSGCRState, gcr_base,GCR_BASE_ADDR ), +DEFINE_PROP_LINK ("gic" , MIPSGCRState, gic_mr,TYPE_MEMORY_REGION , + MemoryRegion *), +DEFINE_PROP_LINK ("cpc" , MIPSGCRState, cpc_mr,TYPE_MEMORY_REGION , + MemoryRegion *), DEFINE_PROP_END_OF_LIST(), };
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 54/55] cpu: Convert to DEFINE_PROP_LINK
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
Message-Id: <[email protected]>
--- exec.c | 27 +++++++++++++++------------ include/qom/cpu.h | 1 + qom/cpu.c | 1 + 3 files changed, 17 insertions(+), 12 deletions(-)
exec.c +15 -12
@@ -27,6 +27,7 @@#include "exec/target_page.h" #include "tcg.h" #include "hw/qdev-core.h" +#include "hw/qdev-properties.h" #if !defined(CONFIG_USER_ONLY )#include "hw/boards.h" #include "hw/xen/xen.h"
@@ -737,6 +738,20 @@ void cpu_exec_unrealizefn(CPUState *cpu) } } +Property cpu_common_props[] = { +#ifndef CONFIG_USER_ONLY +/* Create a memory property for softmmu CPU object, +* so users can wire up its memory. (This can't go in qom/cpu.c +* because that file is compiled only once for both user-mode +* and system builds.) The default if no link is set up is to use +* the system address space. +*/ +DEFINE_PROP_LINK ("memory" , CPUState, memory,TYPE_MEMORY_REGION , + MemoryRegion *), +#endif + DEFINE_PROP_END_OF_LIST(), +}; +void cpu_exec_initfn (CPUState *cpu) { cpu->as =NULL ;
@@ -744,18 +759,6 @@ void cpu_exec_initfn(CPUState *cpu)#ifndef CONFIG_USER_ONLY cpu->thread_id =qemu_get_thread_id (); - -/* This is a softmmu CPU object, so create a property for it -* so users can wire up its memory. (This can't go in qom/cpu.c -* because that file is compiled only once for both user-mode -* and system builds.) The default if no link is set up is to use -* the system address space. -*/ -object_property_add_link (OBJECT (cpu),"memory" ,TYPE_MEMORY_REGION , - (Object **)&cpu->memory, - qdev_prop_allow_set_link_before_realize, -OBJ_PROP_LINK_UNREF_ON_RELEASE , - &error_abort); cpu->memory = system_memory;object_ref (OBJECT (cpu->memory));#endif
include/qom/cpu.h +1 -0
@@ -1013,6 +1013,7 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx); void QEMU_NORETURN cpu_abort(CPUState *cpu, const char *fmt, ...) GCC_FMT_ATTR(2, 3); +extern Property cpu_common_props[];void cpu_exec_initfn (CPUState *cpu);void cpu_exec_realizefn (CPUState *cpu,Error **errp);void cpu_exec_unrealizefn (CPUState *cpu);
qom/cpu.c +1 -0
@@ -458,6 +458,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)set_bit (DEVICE_CATEGORY_CPU , dc->categories); dc->realize = cpu_common_realizefn; dc->unrealize = cpu_common_unrealizefn; + dc->props = cpu_common_props;/* * Reason: CPUs still need special care by board code: wiring up * IRQs, adding reset handlers, halting non-first CPUs, ...
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 55/55] spapr_rng: Convert to DEFINE_PROP_LINK
In reply to Paolo BonziniFrom: Fam Zheng <[email protected]>
Message-Id: <[email protected]>
--- hw/ppc/spapr_rng.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
hw/ppc/spapr_rng.c +2 -6
@@ -96,17 +96,11 @@ static target_ulong h_random(PowerPCCPU *cpu, sPAPRMachineState *spapr,static void spapr_rng_instance_init (Object *obj) { -sPAPRRngState *rngstate =SPAPR_RNG (obj); -if (object_resolve_path_type ("" ,TYPE_SPAPR_RNG ,NULL ) !=NULL ) {error_report ("spapr-rng can not be instantiated twice!" );return ; } -object_property_add_link (obj,"rng" ,TYPE_RNG_BACKEND , - (Object **)&rngstate->backend, - object_property_allow_set_link, -OBJ_PROP_LINK_UNREF_ON_RELEASE ,NULL );object_property_set_description (obj,"rng" ,"ID of the random number generator backend" ,NULL );
@@ -163,6 +157,8 @@ int spapr_rng_populate_dt(void *fdt)static Property spapr_rng_properties[] = {DEFINE_PROP_BOOL ("use-kvm" , sPAPRRngState, use_kvm, false), +DEFINE_PROP_LINK ("rng" , sPAPRRngState, backend,TYPE_RNG_BACKEND , + RngBackend *),DEFINE_PROP_END_OF_LIST (), };
Signature · 1 line
1.8.3.1
Peter Maydell
AppliedQuoted 13 lines · Paolo Bonzini
The following changes since commit
49bcce4b9c11759678fd223aefb48691c4959d4f:Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2017-07-12' into staging (2017-07-13 16:56:06 +0100)
are available in the git repository at:
git://github.com/bonzini/qemu.gittags/for-upstreamfor you to fetch changes up to
68c761e19c2ea453f880dbbd04e867d34d1468b8:
spapr_rng: Convert toDEFINE_PROP_LINK(2017-07-14 12:04:43 +0200)
Quoted 8 lines
----------------------------------------------------------------
* gdbstub fixes (Alex)
* IOMMU MemoryRegion subclass (Alexey)
* Chardev hotswap (Anton)
*NBD_OPT_GOsupport (Eric)
* Misc bugfixes
*DEFINE_PROP_LINK(minus the ARM patches - Fam)
*MAINTAINERSupdates (Philippe)
Applied, thanks.
-- PMM