* [Qemu-devel] [PULL 01/16] kvm: Silence warning from valgrind
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
@ 2015-05-08 12:07 ` Paolo Bonzini
2015-05-08 12:07 ` [Qemu-devel] [PULL 02/16] apic_common: improve readability of apic_reset_common Paolo Bonzini
` (14 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Paolo Bonzini @ 2015-05-08 12:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Thomas Huth
From: Thomas Huth <thuth@redhat.com>
valgrind complains here about uninitialized bytes with the following message:
==17814== Syscall param ioctl(generic) points to uninitialised byte(s)
==17814== at 0x466A780: ioctl (in /usr/lib64/power8/libc-2.17.so)
==17814== by 0x100735B7: kvm_vm_ioctl (kvm-all.c:1920)
==17814== by 0x10074583: kvm_set_ioeventfd_mmio (kvm-all.c:574)
Let's fix it by using a proper struct initializer in kvm_set_ioeventfd_mmio().
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1430153944-24368-1-git-send-email-thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
kvm-all.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/kvm-all.c b/kvm-all.c
index 3f7061a..28f4589 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -552,13 +552,13 @@ static int kvm_set_ioeventfd_mmio(int fd, hwaddr addr, uint32_t val,
bool assign, uint32_t size, bool datamatch)
{
int ret;
- struct kvm_ioeventfd iofd;
-
- iofd.datamatch = datamatch ? adjust_ioeventfd_endianness(val, size) : 0;
- iofd.addr = addr;
- iofd.len = size;
- iofd.flags = 0;
- iofd.fd = fd;
+ struct kvm_ioeventfd iofd = {
+ .datamatch = datamatch ? adjust_ioeventfd_endianness(val, size) : 0,
+ .addr = addr,
+ .len = size,
+ .flags = 0,
+ .fd = fd,
+ };
if (!kvm_enabled()) {
return -ENOSYS;
--
2.3.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PULL 02/16] apic_common: improve readability of apic_reset_common
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
2015-05-08 12:07 ` [Qemu-devel] [PULL 01/16] kvm: Silence warning from valgrind Paolo Bonzini
@ 2015-05-08 12:07 ` Paolo Bonzini
2015-05-08 12:30 ` Andreas Färber
2015-05-08 12:07 ` [Qemu-devel] [PULL 03/16] mtree: tag & indent a bit better Paolo Bonzini
` (13 subsequent siblings)
15 siblings, 1 reply; 22+ messages in thread
From: Paolo Bonzini @ 2015-05-08 12:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Denis V. Lunev, Andreas Färber
From: "Denis V. Lunev" <den@openvz.org>
Replace call of cpu_is_bsp(s->cpu) which really returns
!!(s->apicbase & MSR_IA32_APICBASE_BSP)
with directly collected value. Due to this the tracepoint
trace_cpu_get_apic_base((uint64_t)s->apicbase);
will not be hit anymore in apic_reset_common.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Andreas Färber <afaerber@suse.de>
CC: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1428414832-3104-1-git-send-email-den@openvz.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/intc/apic_common.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index d38d24b..d595d63 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -233,11 +233,10 @@ static void apic_reset_common(DeviceState *dev)
{
APICCommonState *s = APIC_COMMON(dev);
APICCommonClass *info = APIC_COMMON_GET_CLASS(s);
- bool bsp;
+ uint32_t bsp;
- bsp = cpu_is_bsp(s->cpu);
- s->apicbase = APIC_DEFAULT_ADDRESS |
- (bsp ? MSR_IA32_APICBASE_BSP : 0) | MSR_IA32_APICBASE_ENABLE;
+ bsp = s->apicbase & MSR_IA32_APICBASE_BSP;
+ s->apicbase = APIC_DEFAULT_ADDRESS | bsp | MSR_IA32_APICBASE_ENABLE;
s->vapic_paddr = 0;
info->vapic_base_update(s);
--
2.3.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [PULL 02/16] apic_common: improve readability of apic_reset_common
2015-05-08 12:07 ` [Qemu-devel] [PULL 02/16] apic_common: improve readability of apic_reset_common Paolo Bonzini
@ 2015-05-08 12:30 ` Andreas Färber
0 siblings, 0 replies; 22+ messages in thread
From: Andreas Färber @ 2015-05-08 12:30 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: Denis V. Lunev
Am 08.05.2015 um 14:07 schrieb Paolo Bonzini:
> From: "Denis V. Lunev" <den@openvz.org>
>
> Replace call of cpu_is_bsp(s->cpu) which really returns
> !!(s->apicbase & MSR_IA32_APICBASE_BSP)
> with directly collected value. Due to this the tracepoint
> trace_cpu_get_apic_base((uint64_t)s->apicbase);
> will not be hit anymore in apic_reset_common.
>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Andreas Färber <afaerber@suse.de>
I did provide a Reviewed-by for this one, and somehow my name got
castrated here. Please check your tooling.
Andreas
> CC: Paolo Bonzini <pbonzini@redhat.com>
> Message-Id: <1428414832-3104-1-git-send-email-den@openvz.org>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> hw/intc/apic_common.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
> index d38d24b..d595d63 100644
> --- a/hw/intc/apic_common.c
> +++ b/hw/intc/apic_common.c
> @@ -233,11 +233,10 @@ static void apic_reset_common(DeviceState *dev)
> {
> APICCommonState *s = APIC_COMMON(dev);
> APICCommonClass *info = APIC_COMMON_GET_CLASS(s);
> - bool bsp;
> + uint32_t bsp;
>
> - bsp = cpu_is_bsp(s->cpu);
> - s->apicbase = APIC_DEFAULT_ADDRESS |
> - (bsp ? MSR_IA32_APICBASE_BSP : 0) | MSR_IA32_APICBASE_ENABLE;
> + bsp = s->apicbase & MSR_IA32_APICBASE_BSP;
> + s->apicbase = APIC_DEFAULT_ADDRESS | bsp | MSR_IA32_APICBASE_ENABLE;
>
> s->vapic_paddr = 0;
> info->vapic_base_update(s);
>
--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [Qemu-devel] [PULL 03/16] mtree: tag & indent a bit better
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
2015-05-08 12:07 ` [Qemu-devel] [PULL 01/16] kvm: Silence warning from valgrind Paolo Bonzini
2015-05-08 12:07 ` [Qemu-devel] [PULL 02/16] apic_common: improve readability of apic_reset_common Paolo Bonzini
@ 2015-05-08 12:07 ` Paolo Bonzini
2015-05-08 12:07 ` [Qemu-devel] [PULL 04/16] mtree: also print disabled regions Paolo Bonzini
` (12 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Paolo Bonzini @ 2015-05-08 12:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
From: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
memory.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/memory.c b/memory.c
index 0f6cb81..8fe6d79 100644
--- a/memory.c
+++ b/memory.c
@@ -2185,15 +2185,16 @@ void mtree_info(fprintf_function mon_printf, void *f)
QTAILQ_INIT(&ml_head);
QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
- mon_printf(f, "%s\n", as->name);
- mtree_print_mr(mon_printf, f, as->root, 0, 0, &ml_head);
+ mon_printf(f, "address-space: %s\n", as->name);
+ mtree_print_mr(mon_printf, f, as->root, 1, 0, &ml_head);
+ mon_printf(f, "\n");
}
- mon_printf(f, "aliases\n");
/* print aliased regions */
QTAILQ_FOREACH(ml, &ml_head, queue) {
- mon_printf(f, "%s\n", memory_region_name(ml->mr));
- mtree_print_mr(mon_printf, f, ml->mr, 0, 0, &ml_head);
+ mon_printf(f, "memory-region: %s\n", memory_region_name(ml->mr));
+ mtree_print_mr(mon_printf, f, ml->mr, 1, 0, &ml_head);
+ mon_printf(f, "\n");
}
QTAILQ_FOREACH_SAFE(ml, &ml_head, queue, ml2) {
--
2.3.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PULL 04/16] mtree: also print disabled regions
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
` (2 preceding siblings ...)
2015-05-08 12:07 ` [Qemu-devel] [PULL 03/16] mtree: tag & indent a bit better Paolo Bonzini
@ 2015-05-08 12:07 ` Paolo Bonzini
2015-05-08 12:07 ` [Qemu-devel] [PULL 05/16] kvm: add support for memory transaction attributes Paolo Bonzini
` (11 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Paolo Bonzini @ 2015-05-08 12:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
From: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
memory.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/memory.c b/memory.c
index 8fe6d79..03c536b 100644
--- a/memory.c
+++ b/memory.c
@@ -2089,7 +2089,7 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
const MemoryRegion *submr;
unsigned int i;
- if (!mr || !mr->enabled) {
+ if (!mr) {
return;
}
@@ -2115,7 +2115,7 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
}
mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx
" (prio %d, %c%c): alias %s @%s " TARGET_FMT_plx
- "-" TARGET_FMT_plx "\n",
+ "-" TARGET_FMT_plx "%s\n",
base + mr->addr,
base + mr->addr
+ (int128_nz(mr->size) ?
@@ -2131,10 +2131,11 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
mr->alias_offset
+ (int128_nz(mr->size) ?
(hwaddr)int128_get64(int128_sub(mr->size,
- int128_one())) : 0));
+ int128_one())) : 0),
+ mr->enabled ? "" : " [disabled]");
} else {
mon_printf(f,
- TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %c%c): %s\n",
+ TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %c%c): %s%s\n",
base + mr->addr,
base + mr->addr
+ (int128_nz(mr->size) ?
@@ -2144,7 +2145,8 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
mr->romd_mode ? 'R' : '-',
!mr->readonly && !(mr->rom_device && mr->romd_mode) ? 'W'
: '-',
- memory_region_name(mr));
+ memory_region_name(mr),
+ mr->enabled ? "" : " [disabled]");
}
QTAILQ_INIT(&submr_print_queue);
--
2.3.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PULL 05/16] kvm: add support for memory transaction attributes
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
` (3 preceding siblings ...)
2015-05-08 12:07 ` [Qemu-devel] [PULL 04/16] mtree: also print disabled regions Paolo Bonzini
@ 2015-05-08 12:07 ` Paolo Bonzini
2015-05-08 12:07 ` [Qemu-devel] [PULL 06/16] exec: move rcu_read_lock/unlock to address_space_translate callers Paolo Bonzini
` (10 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Paolo Bonzini @ 2015-05-08 12:07 UTC (permalink / raw)
To: qemu-devel
Let kvm_arch_post_run convert fields in the kvm_run struct to MemTxAttrs.
These are then passed to address_space_rw.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/sysemu/kvm.h | 3 ++-
kvm-all.c | 21 ++++++++++++---------
target-arm/kvm.c | 4 +++-
target-i386/kvm.c | 4 +++-
target-mips/kvm.c | 4 +++-
target-ppc/kvm.c | 4 +++-
target-s390x/kvm.c | 4 +++-
7 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 197e6c0..4878959 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -18,6 +18,7 @@
#include "config-host.h"
#include "qemu/queue.h"
#include "qom/cpu.h"
+#include "exec/memattrs.h"
#ifdef CONFIG_KVM
#include <linux/kvm.h>
@@ -254,7 +255,7 @@ int kvm_create_device(KVMState *s, uint64_t type, bool test);
extern const KVMCapabilityInfo kvm_arch_required_capabilities[];
void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run);
-void kvm_arch_post_run(CPUState *cpu, struct kvm_run *run);
+MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct kvm_run *run);
int kvm_arch_handle_exit(CPUState *cpu, struct kvm_run *run);
diff --git a/kvm-all.c b/kvm-all.c
index 28f4589..17a3771 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1669,14 +1669,14 @@ void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len)
s->sigmask_len = sigmask_len;
}
-static void kvm_handle_io(uint16_t port, void *data, int direction, int size,
- uint32_t count)
+static void kvm_handle_io(uint16_t port, MemTxAttrs attrs, void *data, int direction,
+ int size, uint32_t count)
{
int i;
uint8_t *ptr = data;
for (i = 0; i < count; i++) {
- address_space_rw(&address_space_io, port, MEMTXATTRS_UNSPECIFIED,
+ address_space_rw(&address_space_io, port, attrs,
ptr, size,
direction == KVM_EXIT_IO_OUT);
ptr += size;
@@ -1796,6 +1796,8 @@ int kvm_cpu_exec(CPUState *cpu)
}
do {
+ MemTxAttrs attrs;
+
if (cpu->kvm_vcpu_dirty) {
kvm_arch_put_registers(cpu, KVM_PUT_RUNTIME_STATE);
cpu->kvm_vcpu_dirty = false;
@@ -1816,7 +1818,7 @@ int kvm_cpu_exec(CPUState *cpu)
run_ret = kvm_vcpu_ioctl(cpu, KVM_RUN, 0);
qemu_mutex_lock_iothread();
- kvm_arch_post_run(cpu, run);
+ attrs = kvm_arch_post_run(cpu, run);
if (run_ret < 0) {
if (run_ret == -EINTR || run_ret == -EAGAIN) {
@@ -1834,7 +1836,7 @@ int kvm_cpu_exec(CPUState *cpu)
switch (run->exit_reason) {
case KVM_EXIT_IO:
DPRINTF("handle_io\n");
- kvm_handle_io(run->io.port,
+ kvm_handle_io(run->io.port, attrs,
(uint8_t *)run + run->io.data_offset,
run->io.direction,
run->io.size,
@@ -1843,10 +1845,11 @@ int kvm_cpu_exec(CPUState *cpu)
break;
case KVM_EXIT_MMIO:
DPRINTF("handle_mmio\n");
- cpu_physical_memory_rw(run->mmio.phys_addr,
- run->mmio.data,
- run->mmio.len,
- run->mmio.is_write);
+ address_space_rw(&address_space_memory,
+ run->mmio.phys_addr, attrs,
+ run->mmio.data,
+ run->mmio.len,
+ run->mmio.is_write);
ret = 0;
break;
case KVM_EXIT_IRQ_WINDOW_OPEN:
diff --git a/target-arm/kvm.c b/target-arm/kvm.c
index fdd9ba3..16abbf1 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -23,6 +23,7 @@
#include "cpu.h"
#include "internals.h"
#include "hw/arm/arm.h"
+#include "exec/memattrs.h"
const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
KVM_CAP_LAST_INFO
@@ -506,8 +507,9 @@ void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run)
{
}
-void kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
+MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
{
+ return MEMTXATTRS_UNSPECIFIED;
}
int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 41d09e5..a26d25a 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -37,6 +37,7 @@
#include "hw/pci/pci.h"
#include "migration/migration.h"
#include "qapi/qmp/qerror.h"
+#include "exec/memattrs.h"
//#define DEBUG_KVM
@@ -2246,7 +2247,7 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run)
}
}
-void kvm_arch_post_run(CPUState *cpu, struct kvm_run *run)
+MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct kvm_run *run)
{
X86CPU *x86_cpu = X86_CPU(cpu);
CPUX86State *env = &x86_cpu->env;
@@ -2258,6 +2259,7 @@ void kvm_arch_post_run(CPUState *cpu, struct kvm_run *run)
}
cpu_set_apic_tpr(x86_cpu->apic_state, run->cr8);
cpu_set_apic_base(x86_cpu->apic_state, run->apic_base);
+ return MEMTXATTRS_UNSPECIFIED;
}
int kvm_arch_process_async_events(CPUState *cs)
diff --git a/target-mips/kvm.c b/target-mips/kvm.c
index 4d1f7ea..59eb111 100644
--- a/target-mips/kvm.c
+++ b/target-mips/kvm.c
@@ -23,6 +23,7 @@
#include "cpu.h"
#include "sysemu/cpus.h"
#include "kvm_mips.h"
+#include "exec/memattrs.h"
#define DEBUG_KVM 0
@@ -110,9 +111,10 @@ void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run)
}
}
-void kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
+MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
{
DPRINTF("%s\n", __func__);
+ return MEMTXATTRS_UNSPECIFIED;
}
int kvm_arch_process_async_events(CPUState *cs)
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 12328a4..1da9ea8 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -39,6 +39,7 @@
#include "sysemu/watchdog.h"
#include "trace.h"
#include "exec/gdbstub.h"
+#include "exec/memattrs.h"
//#define DEBUG_KVM
@@ -1270,8 +1271,9 @@ void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run)
* anyways, so we will get a chance to deliver the rest. */
}
-void kvm_arch_post_run(CPUState *cpu, struct kvm_run *run)
+MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
{
+ return MEMTXATTRS_UNSPECIFIED;
}
int kvm_arch_process_async_events(CPUState *cs)
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 8e65e43..08cbffb 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -45,6 +45,7 @@
#include "hw/s390x/s390-pci-bus.h"
#include "hw/s390x/ipl.h"
#include "hw/s390x/ebcdic.h"
+#include "exec/memattrs.h"
/* #define DEBUG_KVM */
@@ -769,8 +770,9 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run)
{
}
-void kvm_arch_post_run(CPUState *cpu, struct kvm_run *run)
+MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
{
+ return MEMTXATTRS_UNSPECIFIED;
}
int kvm_arch_process_async_events(CPUState *cs)
--
2.3.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PULL 06/16] exec: move rcu_read_lock/unlock to address_space_translate callers
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
` (4 preceding siblings ...)
2015-05-08 12:07 ` [Qemu-devel] [PULL 05/16] kvm: add support for memory transaction attributes Paolo Bonzini
@ 2015-05-08 12:07 ` Paolo Bonzini
2015-05-08 12:07 ` [Qemu-devel] [PULL 07/16] configure: require __thread support Paolo Bonzini
` (9 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Paolo Bonzini @ 2015-05-08 12:07 UTC (permalink / raw)
To: qemu-devel
Once address_space_translate will be called outside the BQL, the returned
MemoryRegion might disappear as soon as the RCU read-side critical section
ends. Avoid this by moving the critical section to the callers.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1426684909-95030-3-git-send-email-pbonzini@redhat.com>
---
exec.c | 33 +++++++++++++++++++++++++++++----
hw/vfio/common.c | 7 +++++--
include/exec/memory.h | 4 +++-
translate-all.c | 3 +++
4 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/exec.c b/exec.c
index ae37b98..e19ab22 100644
--- a/exec.c
+++ b/exec.c
@@ -373,6 +373,7 @@ static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write)
return false;
}
+/* Called from RCU critical section */
MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr,
hwaddr *xlat, hwaddr *plen,
bool is_write)
@@ -381,7 +382,6 @@ MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr,
MemoryRegionSection *section;
MemoryRegion *mr;
- rcu_read_lock();
for (;;) {
AddressSpaceDispatch *d = atomic_rcu_read(&as->dispatch);
section = address_space_translate_internal(d, addr, &addr, plen, true);
@@ -409,7 +409,6 @@ MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr,
}
*xlat = addr;
- rcu_read_unlock();
return mr;
}
@@ -2329,6 +2328,7 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs,
MemoryRegion *mr;
MemTxResult result = MEMTX_OK;
+ rcu_read_lock();
while (len > 0) {
l = len;
mr = address_space_translate(as, addr, &addr1, &l, is_write);
@@ -2415,6 +2415,7 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs,
buf += l;
addr += l;
}
+ rcu_read_unlock();
return result;
}
@@ -2452,6 +2453,7 @@ static inline void cpu_physical_memory_write_rom_internal(AddressSpace *as,
hwaddr addr1;
MemoryRegion *mr;
+ rcu_read_lock();
while (len > 0) {
l = len;
mr = address_space_translate(as, addr, &addr1, &l, true);
@@ -2477,6 +2479,7 @@ static inline void cpu_physical_memory_write_rom_internal(AddressSpace *as,
buf += l;
addr += l;
}
+ rcu_read_unlock();
}
/* used for ROM loading : can write in RAM and ROM */
@@ -2585,6 +2588,7 @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_
MemoryRegion *mr;
hwaddr l, xlat;
+ rcu_read_lock();
while (len > 0) {
l = len;
mr = address_space_translate(as, addr, &xlat, &l, is_write);
@@ -2598,6 +2602,7 @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_
len -= l;
addr += l;
}
+ rcu_read_unlock();
return true;
}
@@ -2624,9 +2629,12 @@ void *address_space_map(AddressSpace *as,
}
l = len;
+ rcu_read_lock();
mr = address_space_translate(as, addr, &xlat, &l, is_write);
+
if (!memory_access_is_direct(mr, is_write)) {
if (atomic_xchg(&bounce.in_use, true)) {
+ rcu_read_unlock();
return NULL;
}
/* Avoid unbounded allocations */
@@ -2642,6 +2650,7 @@ void *address_space_map(AddressSpace *as,
bounce.buffer, l);
}
+ rcu_read_unlock();
*plen = l;
return bounce.buffer;
}
@@ -2665,6 +2674,7 @@ void *address_space_map(AddressSpace *as,
}
memory_region_ref(mr);
+ rcu_read_unlock();
*plen = done;
return qemu_ram_ptr_length(raddr + base, plen);
}
@@ -2728,6 +2738,7 @@ static inline uint32_t address_space_ldl_internal(AddressSpace *as, hwaddr addr,
hwaddr addr1;
MemTxResult r;
+ rcu_read_lock();
mr = address_space_translate(as, addr, &addr1, &l, false);
if (l < 4 || !memory_access_is_direct(mr, false)) {
/* I/O case */
@@ -2762,6 +2773,7 @@ static inline uint32_t address_space_ldl_internal(AddressSpace *as, hwaddr addr,
if (result) {
*result = r;
}
+ rcu_read_unlock();
return val;
}
@@ -2814,6 +2826,7 @@ static inline uint64_t address_space_ldq_internal(AddressSpace *as, hwaddr addr,
hwaddr addr1;
MemTxResult r;
+ rcu_read_lock();
mr = address_space_translate(as, addr, &addr1, &l,
false);
if (l < 8 || !memory_access_is_direct(mr, false)) {
@@ -2849,6 +2862,7 @@ static inline uint64_t address_space_ldq_internal(AddressSpace *as, hwaddr addr,
if (result) {
*result = r;
}
+ rcu_read_unlock();
return val;
}
@@ -2921,6 +2935,7 @@ static inline uint32_t address_space_lduw_internal(AddressSpace *as,
hwaddr addr1;
MemTxResult r;
+ rcu_read_lock();
mr = address_space_translate(as, addr, &addr1, &l,
false);
if (l < 2 || !memory_access_is_direct(mr, false)) {
@@ -2956,6 +2971,7 @@ static inline uint32_t address_space_lduw_internal(AddressSpace *as,
if (result) {
*result = r;
}
+ rcu_read_unlock();
return val;
}
@@ -3007,6 +3023,7 @@ void address_space_stl_notdirty(AddressSpace *as, hwaddr addr, uint32_t val,
hwaddr addr1;
MemTxResult r;
+ rcu_read_lock();
mr = address_space_translate(as, addr, &addr1, &l,
true);
if (l < 4 || !memory_access_is_direct(mr, true)) {
@@ -3029,6 +3046,7 @@ void address_space_stl_notdirty(AddressSpace *as, hwaddr addr, uint32_t val,
if (result) {
*result = r;
}
+ rcu_read_unlock();
}
void stl_phys_notdirty(AddressSpace *as, hwaddr addr, uint32_t val)
@@ -3049,6 +3067,7 @@ static inline void address_space_stl_internal(AddressSpace *as,
hwaddr addr1;
MemTxResult r;
+ rcu_read_lock();
mr = address_space_translate(as, addr, &addr1, &l,
true);
if (l < 4 || !memory_access_is_direct(mr, true)) {
@@ -3083,6 +3102,7 @@ static inline void address_space_stl_internal(AddressSpace *as,
if (result) {
*result = r;
}
+ rcu_read_unlock();
}
void address_space_stl(AddressSpace *as, hwaddr addr, uint32_t val,
@@ -3152,6 +3172,7 @@ static inline void address_space_stw_internal(AddressSpace *as,
hwaddr addr1;
MemTxResult r;
+ rcu_read_lock();
mr = address_space_translate(as, addr, &addr1, &l, true);
if (l < 2 || !memory_access_is_direct(mr, true)) {
#if defined(TARGET_WORDS_BIGENDIAN)
@@ -3185,6 +3206,7 @@ static inline void address_space_stw_internal(AddressSpace *as,
if (result) {
*result = r;
}
+ rcu_read_unlock();
}
void address_space_stw(AddressSpace *as, hwaddr addr, uint32_t val,
@@ -3322,12 +3344,15 @@ bool cpu_physical_memory_is_io(hwaddr phys_addr)
{
MemoryRegion*mr;
hwaddr l = 1;
+ bool res;
+ rcu_read_lock();
mr = address_space_translate(&address_space_memory,
phys_addr, &phys_addr, &l, false);
- return !(memory_region_is_ram(mr) ||
- memory_region_is_romd(mr));
+ res = !(memory_region_is_ram(mr) || memory_region_is_romd(mr));
+ rcu_read_unlock();
+ return res;
}
void qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index b012620..b1045da 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -270,13 +270,14 @@ static void vfio_iommu_map_notify(Notifier *n, void *data)
* this IOMMU to its immediate target. We need to translate
* it the rest of the way through to memory.
*/
+ rcu_read_lock();
mr = address_space_translate(&address_space_memory,
iotlb->translated_addr,
&xlat, &len, iotlb->perm & IOMMU_WO);
if (!memory_region_is_ram(mr)) {
error_report("iommu map to non memory area %"HWADDR_PRIx"",
xlat);
- return;
+ goto out;
}
/*
* Translation truncates length to the IOMMU page size,
@@ -284,7 +285,7 @@ static void vfio_iommu_map_notify(Notifier *n, void *data)
*/
if (len & iotlb->addr_mask) {
error_report("iommu has granularity incompatible with target AS");
- return;
+ goto out;
}
if ((iotlb->perm & IOMMU_RW) != IOMMU_NONE) {
@@ -307,6 +308,8 @@ static void vfio_iommu_map_notify(Notifier *n, void *data)
iotlb->addr_mask + 1, ret);
}
}
+out:
+ rcu_read_unlock();
}
static void vfio_listener_region_add(MemoryListener *listener,
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 0ccfd3b..b61c84f 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -1233,7 +1233,9 @@ void address_space_stq(AddressSpace *as, hwaddr addr, uint64_t val,
#endif
/* address_space_translate: translate an address range into an address space
- * into a MemoryRegion and an address range into that section
+ * into a MemoryRegion and an address range into that section. Should be
+ * called from an RCU critical section, to avoid that the last reference
+ * to the returned region disappears after address_space_translate returns.
*
* @as: #AddressSpace to be accessed
* @addr: address within that address space
diff --git a/translate-all.c b/translate-all.c
index 65a76c5..536008f 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -1416,14 +1416,17 @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr)
MemoryRegion *mr;
hwaddr l = 1;
+ rcu_read_lock();
mr = address_space_translate(as, addr, &addr, &l, false);
if (!(memory_region_is_ram(mr)
|| memory_region_is_romd(mr))) {
+ rcu_read_unlock();
return;
}
ram_addr = (memory_region_get_ram_addr(mr) & TARGET_PAGE_MASK)
+ addr;
tb_invalidate_phys_page_range(ram_addr, ram_addr + 1, 0);
+ rcu_read_unlock();
}
#endif /* !defined(CONFIG_USER_ONLY) */
--
2.3.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PULL 07/16] configure: require __thread support
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
` (5 preceding siblings ...)
2015-05-08 12:07 ` [Qemu-devel] [PULL 06/16] exec: move rcu_read_lock/unlock to address_space_translate callers Paolo Bonzini
@ 2015-05-08 12:07 ` Paolo Bonzini
2015-05-08 12:07 ` [Qemu-devel] [PULL 08/16] qom: fix typename of 'policy' enum property in hostmem obj Paolo Bonzini
` (8 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Paolo Bonzini @ 2015-05-08 12:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Emilio G. Cota
From: "Emilio G. Cota" <cota@braap.org>
The codebase doesn't build without __thread support.
Formalise this requirement by adding a check for it in the
configure script.
Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
configure | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/configure b/configure
index 75a4def..40bc49a 100755
--- a/configure
+++ b/configure
@@ -1556,6 +1556,17 @@ if test "$static" = "yes" ; then
fi
fi
+# Unconditional check for compiler __thread support
+ cat > $TMPC << EOF
+static __thread int tls_var;
+int main(void) { return tls_var; }
+EOF
+
+if ! compile_prog "-Werror" "" ; then
+ error_exit "Your compiler does not support the __thread specifier for " \
+ "Thread-Local Storage (TLS). Please upgrade to a version that does."
+fi
+
if test "$pie" = ""; then
case "$cpu-$targetos" in
i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
--
2.3.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PULL 08/16] qom: fix typename of 'policy' enum property in hostmem obj
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
` (6 preceding siblings ...)
2015-05-08 12:07 ` [Qemu-devel] [PULL 07/16] configure: require __thread support Paolo Bonzini
@ 2015-05-08 12:07 ` Paolo Bonzini
2015-05-08 12:07 ` [Qemu-devel] [PULL 09/16] qom: document user creatable object types in help text Paolo Bonzini
` (7 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Paolo Bonzini @ 2015-05-08 12:07 UTC (permalink / raw)
To: qemu-devel
From: "Daniel P. Berrange" <berrange@redhat.com>
The 'policy' property was being registered with a typename of
'str', but it is in fact an enum of the 'HostMemPolicy' type.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1430476206-26034-2-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
backends/hostmem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/backends/hostmem.c b/backends/hostmem.c
index b7b6cf8..f6db33c 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -252,7 +252,7 @@ static void host_memory_backend_init(Object *obj)
object_property_add(obj, "host-nodes", "int",
host_memory_backend_get_host_nodes,
host_memory_backend_set_host_nodes, NULL, NULL, NULL);
- object_property_add(obj, "policy", "str",
+ object_property_add(obj, "policy", "HostMemPolicy",
host_memory_backend_get_policy,
host_memory_backend_set_policy, NULL, NULL, NULL);
}
--
2.3.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PULL 09/16] qom: document user creatable object types in help text
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
` (7 preceding siblings ...)
2015-05-08 12:07 ` [Qemu-devel] [PULL 08/16] qom: fix typename of 'policy' enum property in hostmem obj Paolo Bonzini
@ 2015-05-08 12:07 ` Paolo Bonzini
2015-05-08 12:07 ` [Qemu-devel] [PULL 10/16] qom: create objects in two phases Paolo Bonzini
` (6 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Paolo Bonzini @ 2015-05-08 12:07 UTC (permalink / raw)
To: qemu-devel
From: "Daniel P. Berrange" <berrange@redhat.com>
The QEMU help for -object is essentially useless, just giving users
the generic syntax. Move it down into its own section and introduce
a nested table where each user creatable object can be documented.
The existing memory-backend-file, rng-random and rng-egd object
types are documented.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1430476206-26034-3-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
qemu-options.hx | 70 ++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 54 insertions(+), 16 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index 319d971..5ef0ae4 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3421,22 +3421,6 @@ DEF("no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip, "", QEMU_ARCH_I386)
HXCOMM Deprecated (ignored)
DEF("tdf", 0, QEMU_OPTION_tdf,"", QEMU_ARCH_ALL)
-DEF("object", HAS_ARG, QEMU_OPTION_object,
- "-object TYPENAME[,PROP1=VALUE1,...]\n"
- " create an new object of type TYPENAME setting properties\n"
- " in the order they are specified. Note that the 'id'\n"
- " property must be set. These objects are placed in the\n"
- " '/objects' path.\n",
- QEMU_ARCH_ALL)
-STEXI
-@item -object @var{typename}[,@var{prop1}=@var{value1},...]
-@findex -object
-Create an new object of type @var{typename} setting properties
-in the order they are specified. Note that the 'id'
-property must be set. These objects are placed in the
-'/objects' path.
-ETEXI
-
DEF("msg", HAS_ARG, QEMU_OPTION_msg,
"-msg timestamp[=on|off]\n"
" change the format of messages\n"
@@ -3462,6 +3446,60 @@ Dump json-encoded vmstate information for current machine type to file
in @var{file}
ETEXI
+DEFHEADING(Generic object creation)
+
+DEF("object", HAS_ARG, QEMU_OPTION_object,
+ "-object TYPENAME[,PROP1=VALUE1,...]\n"
+ " create an new object of type TYPENAME setting properties\n"
+ " in the order they are specified. Note that the 'id'\n"
+ " property must be set. These objects are placed in the\n"
+ " '/objects' path.\n",
+ QEMU_ARCH_ALL)
+STEXI
+@item -object @var{typename}[,@var{prop1}=@var{value1},...]
+@findex -object
+Create an new object of type @var{typename} setting properties
+in the order they are specified. Note that the 'id'
+property must be set. These objects are placed in the
+'/objects' path.
+
+@table @option
+
+@item -object memory-backend-file,id=@var{id},size=@var{size},mem-path=@var{dir},share=@var{on|off}
+
+Creates a memory file backend object, which can be used to back
+the guest RAM with huge pages. The @option{id} parameter is a
+unique ID that will be used to reference this memory region
+when configuring the @option{-numa} argument. The @option{size}
+option provides the size of the memory region, and accepts
+common suffixes, eg @option{500M}. The @option{mem-path} provides
+the path to either a shared memory or huge page filesystem mount.
+The @option{share} boolean option determines whether the memory
+region is marked as private to QEMU, or shared. The latter allows
+a co-operating external process to access the QEMU memory region.
+
+@item -object rng-random,id=@var{id},filename=@var{/dev/random}
+
+Creates a random number generator backend which obtains entropy from
+a device on the host. The @option{id} parameter is a unique ID that
+will be used to reference this entropy backend from the @option{virtio-rng}
+device. The @option{filename} parameter specifies which file to obtain
+entropy from and if omitted defaults to @option{/dev/random}.
+
+@item -object rng-egd,id=@var{id},chardev=@var{chardevid}
+
+Creates a random number generator backend which obtains entropy from
+an external daemon running on the host. The @option{id} parameter is
+a unique ID that will be used to reference this entropy backend from
+the @option{virtio-rng} device. The @option{chardev} parameter is
+the unique ID of a character device backend that provides the connection
+to the RNG daemon.
+
+@end table
+
+ETEXI
+
+
HXCOMM This is the last statement. Insert new options before this line!
STEXI
@end table
--
2.3.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PULL 10/16] qom: create objects in two phases
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
` (8 preceding siblings ...)
2015-05-08 12:07 ` [Qemu-devel] [PULL 09/16] qom: document user creatable object types in help text Paolo Bonzini
@ 2015-05-08 12:07 ` Paolo Bonzini
2015-05-08 12:07 ` [Qemu-devel] [PULL 11/16] qom: add object_new_propv / object_new_proplist constructors Paolo Bonzini
` (5 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Paolo Bonzini @ 2015-05-08 12:07 UTC (permalink / raw)
To: qemu-devel
From: "Daniel P. Berrange" <berrange@redhat.com>
Some types of object must be created before chardevs, other types of
object must be created after chardevs. As such there is no option but
to create objects in two phases.
This takes the decision to create as many object types as possible
in the first phase, and only delay those which have a dependency on
the chardevs. Hopefully the set which need delaying will remain
small.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1430476206-26034-4-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
vl.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/vl.c b/vl.c
index 74c2681..ee2f70a 100644
--- a/vl.c
+++ b/vl.c
@@ -2591,6 +2591,33 @@ static int machine_set_property(const char *name, const char *value,
return 0;
}
+
+/**
+ * Initial object creation happens before all other
+ * QEMU data types are created. The majority of objects
+ * can be created at this point. The rng-egd object
+ * cannot be created here, as it depends on the chardev
+ * already existing.
+ */
+static bool object_create_initial(const char *type)
+{
+ if (g_str_equal(type, "rng-egd")) {
+ return false;
+ }
+ return true;
+}
+
+
+/**
+ * The remainder of object creation happens after the
+ * creation of chardev, fsdev and device data types.
+ */
+static bool object_create_delayed(const char *type)
+{
+ return !object_create_initial(type);
+}
+
+
static int object_create(QemuOpts *opts, void *opaque)
{
Error *err = NULL;
@@ -2599,6 +2626,7 @@ static int object_create(QemuOpts *opts, void *opaque)
void *dummy = NULL;
OptsVisitor *ov;
QDict *pdict;
+ bool (*type_predicate)(const char *) = opaque;
ov = opts_visitor_new(opts);
pdict = qemu_opts_to_qdict(opts, NULL);
@@ -2613,6 +2641,9 @@ static int object_create(QemuOpts *opts, void *opaque)
if (err) {
goto out;
}
+ if (!type_predicate(type)) {
+ goto out;
+ }
qdict_del(pdict, "id");
visit_type_str(opts_get_visitor(ov), &id, "id", &err);
@@ -4008,6 +4039,12 @@ int main(int argc, char **argv, char **envp)
socket_init();
+ if (qemu_opts_foreach(qemu_find_opts("object"),
+ object_create,
+ object_create_initial, 0) != 0) {
+ exit(1);
+ }
+
if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0)
exit(1);
#ifdef CONFIG_VIRTFS
@@ -4027,7 +4064,8 @@ int main(int argc, char **argv, char **envp)
}
if (qemu_opts_foreach(qemu_find_opts("object"),
- object_create, NULL, 0) != 0) {
+ object_create,
+ object_create_delayed, 0) != 0) {
exit(1);
}
--
2.3.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PULL 11/16] qom: add object_new_propv / object_new_proplist constructors
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
` (9 preceding siblings ...)
2015-05-08 12:07 ` [Qemu-devel] [PULL 10/16] qom: create objects in two phases Paolo Bonzini
@ 2015-05-08 12:07 ` Paolo Bonzini
2015-05-08 12:07 ` [Qemu-devel] [PULL 12/16] qom: make enum string tables const-correct Paolo Bonzini
` (4 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Paolo Bonzini @ 2015-05-08 12:07 UTC (permalink / raw)
To: qemu-devel
From: "Daniel P. Berrange" <berrange@redhat.com>
It is reasonably common to want to create an object, set a
number of properties, register it in the hierarchy and then
mark it as complete (if a user creatable type). This requires
quite a lot of error prone, verbose, boilerplate code to achieve.
The object_new_propv / object_new_proplist constructors will
simplify this task by performing all required steps in one go,
accepting the property names/values as variadic args.
Usage would be:
Error *err = NULL;
Object *obj;
obj = object_new_propv(TYPE_MEMORY_BACKEND_FILE,
container_get(object_get_root(), "/objects"),
"hostmem0",
&err,
"share", "yes",
"mem-path", "/dev/shm/somefile",
"prealloc", "yes",
"size", "1048576",
NULL);
Note all property values are passed in string form and will
be parsed into their required data types.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1430476206-26034-5-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/qom/object.h | 67 ++++++++++++++++
qom/object.c | 66 ++++++++++++++++
tests/.gitignore | 1 +
tests/Makefile | 5 +-
tests/check-qom-proplist.c | 190 +++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 328 insertions(+), 1 deletion(-)
create mode 100644 tests/check-qom-proplist.c
diff --git a/include/qom/object.h b/include/qom/object.h
index d2d7748..15ac314 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -607,6 +607,73 @@ Object *object_new(const char *typename);
Object *object_new_with_type(Type type);
/**
+ * object_new_propv:
+ * @typename: The name of the type of the object to instantiate.
+ * @parent: the parent object
+ * @id: The unique ID of the object
+ * @errp: pointer to error object
+ * @...: list of property names and values
+ *
+ * This function with initialize a new object using heap allocated memory.
+ * The returned object has a reference count of 1, and will be freed when
+ * the last reference is dropped.
+ *
+ * The @id parameter will be used when registering the object as a
+ * child of @parent in the objects hierarchy.
+ *
+ * The variadic parameters are a list of pairs of (propname, propvalue)
+ * strings. The propname of NULL indicates the end of the property
+ * list. If the object implements the user creatable interface, the
+ * object will be marked complete once all the properties have been
+ * processed.
+ *
+ * Error *err = NULL;
+ * Object *obj;
+ *
+ * obj = object_new_propv(TYPE_MEMORY_BACKEND_FILE,
+ * container_get(object_get_root(), "/objects")
+ * "hostmem0",
+ * &err,
+ * "share", "yes",
+ * "mem-path", "/dev/shm/somefile",
+ * "prealloc", "yes",
+ * "size", "1048576",
+ * NULL);
+ *
+ * if (!obj) {
+ * g_printerr("Cannot create memory backend: %s\n",
+ * error_get_pretty(err));
+ * }
+ *
+ * The returned object will have one stable reference maintained
+ * for as long as it is present in the object hierarchy.
+ *
+ * Returns: The newly allocated, instantiated & initialized object.
+ */
+Object *object_new_propv(const char *typename,
+ Object *parent,
+ const char *id,
+ Error **errp,
+ ...)
+ __attribute__((sentinel));
+
+/**
+ * object_new_proplist:
+ * @typename: The name of the type of the object to instantiate.
+ * @parent: the parent object
+ * @id: The unique ID of the object
+ * @errp: pointer to error object
+ * @vargs: list of property names and values
+ *
+ * See object_new_propv for documentation.
+ */
+Object *object_new_proplist(const char *typename,
+ Object *parent,
+ const char *id,
+ Error **errp,
+ va_list vargs);
+
+/**
* object_initialize_with_type:
* @data: A pointer to the memory to be used for the object.
* @size: The maximum size available at @data for the object.
diff --git a/qom/object.c b/qom/object.c
index b8dff43..2115542 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -11,6 +11,7 @@
*/
#include "qom/object.h"
+#include "qom/object_interfaces.h"
#include "qemu-common.h"
#include "qapi/visitor.h"
#include "qapi-visit.h"
@@ -439,6 +440,71 @@ Object *object_new(const char *typename)
return object_new_with_type(ti);
}
+Object *object_new_propv(const char *typename,
+ Object *parent,
+ const char *id,
+ Error **errp,
+ ...)
+{
+ va_list vargs;
+ Object *obj;
+
+ va_start(vargs, errp);
+ obj = object_new_proplist(typename, parent, id, errp, vargs);
+ va_end(vargs);
+
+ return obj;
+}
+
+Object *object_new_proplist(const char *typename,
+ Object *parent,
+ const char *id,
+ Error **errp,
+ va_list vargs)
+{
+ Object *obj;
+ const char *propname;
+
+ obj = object_new(typename);
+
+ if (object_class_is_abstract(object_get_class(obj))) {
+ error_setg(errp, "object type '%s' is abstract", typename);
+ goto error;
+ }
+
+ propname = va_arg(vargs, char *);
+ while (propname != NULL) {
+ const char *value = va_arg(vargs, char *);
+
+ g_assert(value != NULL);
+ object_property_parse(obj, value, propname, errp);
+ if (*errp) {
+ goto error;
+ }
+ propname = va_arg(vargs, char *);
+ }
+
+ object_property_add_child(parent, id, obj, errp);
+ if (*errp) {
+ goto error;
+ }
+
+ if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
+ user_creatable_complete(obj, errp);
+ if (*errp) {
+ object_unparent(obj);
+ goto error;
+ }
+ }
+
+ object_unref(OBJECT(obj));
+ return obj;
+
+ error:
+ object_unref(obj);
+ return NULL;
+}
+
Object *object_dynamic_cast(Object *obj, const char *typename)
{
if (obj && object_class_dynamic_cast(object_get_class(obj), typename)) {
diff --git a/tests/.gitignore b/tests/.gitignore
index 0dcb618..dc813c2 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -5,6 +5,7 @@ check-qjson
check-qlist
check-qstring
check-qom-interface
+check-qom-proplist
rcutorture
test-aio
test-bitops
diff --git a/tests/Makefile b/tests/Makefile
index 309e869..e0a831c 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -68,6 +68,8 @@ check-unit-y += tests/test-bitops$(EXESUF)
check-unit-$(CONFIG_HAS_GLIB_SUBPROCESS_TESTS) += tests/test-qdev-global-props$(EXESUF)
check-unit-y += tests/check-qom-interface$(EXESUF)
gcov-files-check-qom-interface-y = qom/object.c
+check-unit-y += tests/check-qom-proplist$(EXESUF)
+gcov-files-check-qom-proplist-y = qom/object.c
check-unit-y += tests/test-qemu-opts$(EXESUF)
gcov-files-test-qemu-opts-y = qom/test-qemu-opts.c
check-unit-y += tests/test-write-threshold$(EXESUF)
@@ -240,7 +242,7 @@ test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o \
$(test-obj-y): QEMU_INCLUDES += -Itests
QEMU_CFLAGS += -I$(SRC_PATH)/tests
-qom-core-obj = qom/object.o qom/qom-qobject.o qom/container.o
+qom-core-obj = qom/object.o qom/qom-qobject.o qom/container.o qom/object_interfaces.o
tests/check-qint$(EXESUF): tests/check-qint.o libqemuutil.a
tests/check-qstring$(EXESUF): tests/check-qstring.o libqemuutil.a
@@ -249,6 +251,7 @@ tests/check-qlist$(EXESUF): tests/check-qlist.o libqemuutil.a
tests/check-qfloat$(EXESUF): tests/check-qfloat.o libqemuutil.a
tests/check-qjson$(EXESUF): tests/check-qjson.o libqemuutil.a libqemustub.a
tests/check-qom-interface$(EXESUF): tests/check-qom-interface.o $(qom-core-obj) libqemuutil.a libqemustub.a
+tests/check-qom-proplist$(EXESUF): tests/check-qom-proplist.o $(qom-core-obj) libqemuutil.a libqemustub.a
tests/test-coroutine$(EXESUF): tests/test-coroutine.o $(block-obj-y) libqemuutil.a libqemustub.a
tests/test-aio$(EXESUF): tests/test-aio.o $(block-obj-y) libqemuutil.a libqemustub.a
tests/test-rfifolock$(EXESUF): tests/test-rfifolock.o libqemuutil.a libqemustub.a
diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
new file mode 100644
index 0000000..9f16cdb
--- /dev/null
+++ b/tests/check-qom-proplist.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2015 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Daniel P. Berrange <berrange@redhat.com>
+ */
+
+#include <glib.h>
+
+#include "qom/object.h"
+#include "qemu/module.h"
+
+
+#define TYPE_DUMMY "qemu:dummy"
+
+typedef struct DummyObject DummyObject;
+typedef struct DummyObjectClass DummyObjectClass;
+
+#define DUMMY_OBJECT(obj) \
+ OBJECT_CHECK(DummyObject, (obj), TYPE_DUMMY)
+
+struct DummyObject {
+ Object parent;
+
+ bool bv;
+ char *sv;
+};
+
+struct DummyObjectClass {
+ ObjectClass parent;
+};
+
+
+static void dummy_set_bv(Object *obj,
+ bool value,
+ Error **errp)
+{
+ DummyObject *dobj = DUMMY_OBJECT(obj);
+
+ dobj->bv = value;
+}
+
+static bool dummy_get_bv(Object *obj,
+ Error **errp)
+{
+ DummyObject *dobj = DUMMY_OBJECT(obj);
+
+ return dobj->bv;
+}
+
+
+static void dummy_set_sv(Object *obj,
+ const char *value,
+ Error **errp)
+{
+ DummyObject *dobj = DUMMY_OBJECT(obj);
+
+ g_free(dobj->sv);
+ dobj->sv = g_strdup(value);
+}
+
+static char *dummy_get_sv(Object *obj,
+ Error **errp)
+{
+ DummyObject *dobj = DUMMY_OBJECT(obj);
+
+ return g_strdup(dobj->sv);
+}
+
+
+static void dummy_init(Object *obj)
+{
+ object_property_add_bool(obj, "bv",
+ dummy_get_bv,
+ dummy_set_bv,
+ NULL);
+ object_property_add_str(obj, "sv",
+ dummy_get_sv,
+ dummy_set_sv,
+ NULL);
+}
+
+static void dummy_finalize(Object *obj)
+{
+ DummyObject *dobj = DUMMY_OBJECT(obj);
+
+ g_free(dobj->sv);
+}
+
+
+static const TypeInfo dummy_info = {
+ .name = TYPE_DUMMY,
+ .parent = TYPE_OBJECT,
+ .instance_size = sizeof(DummyObject),
+ .instance_init = dummy_init,
+ .instance_finalize = dummy_finalize,
+ .class_size = sizeof(DummyObjectClass),
+};
+
+static void test_dummy_createv(void)
+{
+ Error *err = NULL;
+ Object *parent = container_get(object_get_root(),
+ "/objects");
+ DummyObject *dobj = DUMMY_OBJECT(
+ object_new_propv(TYPE_DUMMY,
+ parent,
+ "dummy0",
+ &err,
+ "bv", "yes",
+ "sv", "Hiss hiss hiss",
+ NULL));
+
+ g_assert(dobj != NULL);
+ g_assert(err == NULL);
+ g_assert(g_str_equal(dobj->sv, "Hiss hiss hiss"));
+ g_assert(dobj->bv == true);
+
+ g_assert(object_resolve_path_component(parent, "dummy0")
+ == OBJECT(dobj));
+
+ object_unparent(OBJECT(dobj));
+}
+
+
+static Object *new_helper(Error **errp,
+ Object *parent,
+ ...)
+{
+ va_list vargs;
+ Object *obj;
+
+ va_start(vargs, parent);
+ obj = object_new_proplist(TYPE_DUMMY,
+ parent,
+ "dummy0",
+ errp,
+ vargs);
+ va_end(vargs);
+ return obj;
+}
+
+static void test_dummy_createlist(void)
+{
+ Error *err = NULL;
+ Object *parent = container_get(object_get_root(),
+ "/objects");
+ DummyObject *dobj = DUMMY_OBJECT(
+ new_helper(&err,
+ parent,
+ "bv", "yes",
+ "sv", "Hiss hiss hiss",
+ NULL));
+
+ g_assert(dobj != NULL);
+ g_assert(err == NULL);
+ g_assert(g_str_equal(dobj->sv, "Hiss hiss hiss"));
+ g_assert(dobj->bv == true);
+
+ g_assert(object_resolve_path_component(parent, "dummy0")
+ == OBJECT(dobj));
+
+ object_unparent(OBJECT(dobj));
+}
+
+int main(int argc, char **argv)
+{
+ g_test_init(&argc, &argv, NULL);
+
+ module_call_init(MODULE_INIT_QOM);
+ type_register_static(&dummy_info);
+
+ g_test_add_func("/qom/proplist/createlist", test_dummy_createlist);
+ g_test_add_func("/qom/proplist/createv", test_dummy_createv);
+
+ return g_test_run();
+}
--
2.3.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PULL 12/16] qom: make enum string tables const-correct
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
` (10 preceding siblings ...)
2015-05-08 12:07 ` [Qemu-devel] [PULL 11/16] qom: add object_new_propv / object_new_proplist constructors Paolo Bonzini
@ 2015-05-08 12:07 ` Paolo Bonzini
2015-05-08 12:07 ` [Qemu-devel] [PULL 13/16] qom: add a object_property_add_enum helper method Paolo Bonzini
` (3 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Paolo Bonzini @ 2015-05-08 12:07 UTC (permalink / raw)
To: qemu-devel
From: "Daniel P. Berrange" <berrange@redhat.com>
The enum string table parameters in various QOM/QAPI methods
are declared 'const char *strings[]'. This results in const
warnings if passed a variable that was declared as
static const char * const strings[] = { .... };
Add the extra const annotation to the parameters, since
neither the string elements, nor the array itself should
ever be modified.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1430476206-26034-6-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/hw/qdev-core.h | 2 +-
include/qapi/util.h | 2 +-
include/qapi/visitor-impl.h | 6 +++---
include/qapi/visitor.h | 2 +-
include/qom/object.h | 2 +-
qapi/qapi-dealloc-visitor.c | 3 ++-
qapi/qapi-util.c | 2 +-
qapi/qapi-visit-core.c | 6 +++---
qom/object.c | 2 +-
scripts/qapi-types.py | 4 ++--
10 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 4e673f9..913963e 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -236,7 +236,7 @@ struct Property {
struct PropertyInfo {
const char *name;
const char *description;
- const char **enum_table;
+ const char * const *enum_table;
int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
ObjectPropertyAccessor *get;
ObjectPropertyAccessor *set;
diff --git a/include/qapi/util.h b/include/qapi/util.h
index de9238b..7ad26c0 100644
--- a/include/qapi/util.h
+++ b/include/qapi/util.h
@@ -11,7 +11,7 @@
#ifndef QAPI_UTIL_H
#define QAPI_UTIL_H
-int qapi_enum_parse(const char *lookup[], const char *buf,
+int qapi_enum_parse(const char * const lookup[], const char *buf,
int max, int def, Error **errp);
#endif
diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h
index 09bb0fd..f4a2f74 100644
--- a/include/qapi/visitor-impl.h
+++ b/include/qapi/visitor-impl.h
@@ -30,7 +30,7 @@ struct Visitor
GenericList *(*next_list)(Visitor *v, GenericList **list, Error **errp);
void (*end_list)(Visitor *v, Error **errp);
- void (*type_enum)(Visitor *v, int *obj, const char *strings[],
+ void (*type_enum)(Visitor *v, int *obj, const char * const strings[],
const char *kind, const char *name, Error **errp);
void (*get_next_type)(Visitor *v, int *kind, const int *qobjects,
const char *name, Error **errp);
@@ -59,9 +59,9 @@ struct Visitor
void (*end_union)(Visitor *v, bool data_present, Error **errp);
};
-void input_type_enum(Visitor *v, int *obj, const char *strings[],
+void input_type_enum(Visitor *v, int *obj, const char * const strings[],
const char *kind, const char *name, Error **errp);
-void output_type_enum(Visitor *v, int *obj, const char *strings[],
+void output_type_enum(Visitor *v, int *obj, const char * const strings[],
const char *kind, const char *name, Error **errp);
#endif
diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h
index 5934f59..00ba104 100644
--- a/include/qapi/visitor.h
+++ b/include/qapi/visitor.h
@@ -43,7 +43,7 @@ void visit_optional(Visitor *v, bool *present, const char *name,
Error **errp);
void visit_get_next_type(Visitor *v, int *obj, const int *qtypes,
const char *name, Error **errp);
-void visit_type_enum(Visitor *v, int *obj, const char *strings[],
+void visit_type_enum(Visitor *v, int *obj, const char * const strings[],
const char *kind, const char *name, Error **errp);
void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp);
void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp);
diff --git a/include/qom/object.h b/include/qom/object.h
index 15ac314..bf76f7a 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1020,7 +1020,7 @@ int64_t object_property_get_int(Object *obj, const char *name,
* an enum).
*/
int object_property_get_enum(Object *obj, const char *name,
- const char *strings[], Error **errp);
+ const char * const strings[], Error **errp);
/**
* object_property_get_uint16List:
diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c
index a14a1c7..d7f92c5 100644
--- a/qapi/qapi-dealloc-visitor.c
+++ b/qapi/qapi-dealloc-visitor.c
@@ -156,7 +156,8 @@ static void qapi_dealloc_type_size(Visitor *v, uint64_t *obj, const char *name,
{
}
-static void qapi_dealloc_type_enum(Visitor *v, int *obj, const char *strings[],
+static void qapi_dealloc_type_enum(Visitor *v, int *obj,
+ const char * const strings[],
const char *kind, const char *name,
Error **errp)
{
diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c
index 1d8fb96..bcdc94d 100644
--- a/qapi/qapi-util.c
+++ b/qapi/qapi-util.c
@@ -14,7 +14,7 @@
#include "qapi/error.h"
#include "qapi/util.h"
-int qapi_enum_parse(const char *lookup[], const char *buf,
+int qapi_enum_parse(const char * const lookup[], const char *buf,
int max, int def, Error **errp)
{
int i;
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index b66b93a..a18ba16 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -89,7 +89,7 @@ void visit_get_next_type(Visitor *v, int *obj, const int *qtypes,
}
}
-void visit_type_enum(Visitor *v, int *obj, const char *strings[],
+void visit_type_enum(Visitor *v, int *obj, const char * const strings[],
const char *kind, const char *name, Error **errp)
{
v->type_enum(v, obj, strings, kind, name, errp);
@@ -260,7 +260,7 @@ void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp)
v->type_number(v, obj, name, errp);
}
-void output_type_enum(Visitor *v, int *obj, const char *strings[],
+void output_type_enum(Visitor *v, int *obj, const char * const strings[],
const char *kind, const char *name,
Error **errp)
{
@@ -279,7 +279,7 @@ void output_type_enum(Visitor *v, int *obj, const char *strings[],
visit_type_str(v, &enum_str, name, errp);
}
-void input_type_enum(Visitor *v, int *obj, const char *strings[],
+void input_type_enum(Visitor *v, int *obj, const char * const strings[],
const char *kind, const char *name,
Error **errp)
{
diff --git a/qom/object.c b/qom/object.c
index 2115542..077a5fe 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1027,7 +1027,7 @@ int64_t object_property_get_int(Object *obj, const char *name,
}
int object_property_get_enum(Object *obj, const char *name,
- const char *strings[], Error **errp)
+ const char * const strings[], Error **errp)
{
StringOutputVisitor *sov;
StringInputVisitor *siv;
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index db87218..c8d6db6 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -118,7 +118,7 @@ struct %(name)s
def generate_enum_lookup(name, values):
ret = mcgen('''
-const char *%(name)s_lookup[] = {
+const char * const %(name)s_lookup[] = {
''',
name=name)
i = 0
@@ -140,7 +140,7 @@ const char *%(name)s_lookup[] = {
def generate_enum(name, values):
lookup_decl = mcgen('''
-extern const char *%(name)s_lookup[];
+extern const char * const %(name)s_lookup[];
''',
name=name)
--
2.3.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PULL 13/16] qom: add a object_property_add_enum helper method
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
` (11 preceding siblings ...)
2015-05-08 12:07 ` [Qemu-devel] [PULL 12/16] qom: make enum string tables const-correct Paolo Bonzini
@ 2015-05-08 12:07 ` Paolo Bonzini
2015-05-08 12:07 ` [Qemu-devel] [PULL 14/16] qom: don't pass string table to object_get_enum method Paolo Bonzini
` (2 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Paolo Bonzini @ 2015-05-08 12:07 UTC (permalink / raw)
To: qemu-devel
From: "Daniel P. Berrange" <berrange@redhat.com>
A QOM property can be parsed as enum using the visit_type_enum()
helper method, but this forces callers to use the more complex
generic object_property_add() method when registering it. It
also requires that users of that object have access to the
string map when they want to read the property value.
This patch introduces a specialized object_property_add_enum()
method which simplifies the use of enum properties, so the
setters/getters directly get passed the int value.
typedef enum {
MYDEV_TYPE_FROG,
MYDEV_TYPE_ALLIGATOR,
MYDEV_TYPE_PLATYPUS,
MYDEV_TYPE_LAST
} MyDevType;
Then provide a table of enum <-> string mappings
static const char *const mydevtypemap[MYDEV_TYPE_LAST + 1] = {
[MYDEV_TYPE_FROG] = "frog",
[MYDEV_TYPE_ALLIGATOR] = "alligator",
[MYDEV_TYPE_PLATYPUS] = "platypus",
[MYDEV_TYPE_LAST] = NULL,
};
Assuming an object struct of
typedef struct {
Object parent;
MyDevType devtype;
...other fields...
} MyDev;
The property can then be registered as follows:
static int mydev_prop_get_devtype(Object *obj,
Error **errp G_GNUC_UNUSED)
{
MyDev *dev = MYDEV(obj);
return dev->devtype;
}
static void mydev_prop_set_devtype(Object *obj,
int value,
Error **errp G_GNUC_UNUSED)
{
MyDev *dev = MYDEV(obj);
dev->endpoint = value;
}
object_property_add_enum(obj, "devtype",
mydevtypemap, "MyDevType",
mydev_prop_get_devtype,
mydev_prop_set_devtype,
NULL);
Note there is no need to check the range of 'value' in
the setter, because the string->enum conversion code will
have already done that and reported an error as required.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1430476206-26034-7-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/qom/object.h | 19 ++++++++++++
qom/object.c | 58 ++++++++++++++++++++++++++++++++++++
tests/check-qom-proplist.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 151 insertions(+)
diff --git a/include/qom/object.h b/include/qom/object.h
index bf76f7a..f6a2a9d 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1271,6 +1271,25 @@ void object_property_add_bool(Object *obj, const char *name,
Error **errp);
/**
+ * object_property_add_enum:
+ * @obj: the object to add a property to
+ * @name: the name of the property
+ * @typename: the name of the enum data type
+ * @get: the getter or NULL if the property is write-only.
+ * @set: the setter or NULL if the property is read-only
+ * @errp: if an error occurs, a pointer to an area to store the error
+ *
+ * Add a enum property using getters/setters. This function will add a
+ * property of type 'enum'.
+ */
+void object_property_add_enum(Object *obj, const char *name,
+ const char *typename,
+ const char * const *strings,
+ int (*get)(Object *, Error **),
+ void (*set)(Object *, int, Error **),
+ Error **errp);
+
+/**
* object_property_add_tm:
* @obj: the object to add a property to
* @name: the name of the property
diff --git a/qom/object.c b/qom/object.c
index 077a5fe..ba0e4b8 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1609,6 +1609,64 @@ void object_property_add_bool(Object *obj, const char *name,
}
}
+typedef struct EnumProperty {
+ const char * const *strings;
+ int (*get)(Object *, Error **);
+ void (*set)(Object *, int, Error **);
+} EnumProperty;
+
+static void property_get_enum(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ EnumProperty *prop = opaque;
+ int value;
+
+ value = prop->get(obj, errp);
+ visit_type_enum(v, &value, prop->strings, NULL, name, errp);
+}
+
+static void property_set_enum(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ EnumProperty *prop = opaque;
+ int value;
+
+ visit_type_enum(v, &value, prop->strings, NULL, name, errp);
+ prop->set(obj, value, errp);
+}
+
+static void property_release_enum(Object *obj, const char *name,
+ void *opaque)
+{
+ EnumProperty *prop = opaque;
+ g_free(prop);
+}
+
+void object_property_add_enum(Object *obj, const char *name,
+ const char *typename,
+ const char * const *strings,
+ int (*get)(Object *, Error **),
+ void (*set)(Object *, int, Error **),
+ Error **errp)
+{
+ Error *local_err = NULL;
+ EnumProperty *prop = g_malloc0(sizeof(*prop));
+
+ prop->strings = strings;
+ prop->get = get;
+ prop->set = set;
+
+ object_property_add(obj, name, typename,
+ get ? property_get_enum : NULL,
+ set ? property_set_enum : NULL,
+ property_release_enum,
+ prop, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ g_free(prop);
+ }
+}
+
typedef struct TMProperty {
void (*get)(Object *, struct tm *, Error **);
} TMProperty;
diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
index 9f16cdb..de142e3 100644
--- a/tests/check-qom-proplist.c
+++ b/tests/check-qom-proplist.c
@@ -32,10 +32,28 @@ typedef struct DummyObjectClass DummyObjectClass;
#define DUMMY_OBJECT(obj) \
OBJECT_CHECK(DummyObject, (obj), TYPE_DUMMY)
+typedef enum DummyAnimal DummyAnimal;
+
+enum DummyAnimal {
+ DUMMY_FROG,
+ DUMMY_ALLIGATOR,
+ DUMMY_PLATYPUS,
+
+ DUMMY_LAST,
+};
+
+static const char *const dummyanimalmap[DUMMY_LAST + 1] = {
+ [DUMMY_FROG] = "frog",
+ [DUMMY_ALLIGATOR] = "alligator",
+ [DUMMY_PLATYPUS] = "platypus",
+ [DUMMY_LAST] = NULL,
+};
+
struct DummyObject {
Object parent;
bool bv;
+ DummyAnimal av;
char *sv;
};
@@ -62,6 +80,24 @@ static bool dummy_get_bv(Object *obj,
}
+static void dummy_set_av(Object *obj,
+ int value,
+ Error **errp)
+{
+ DummyObject *dobj = DUMMY_OBJECT(obj);
+
+ dobj->av = value;
+}
+
+static int dummy_get_av(Object *obj,
+ Error **errp)
+{
+ DummyObject *dobj = DUMMY_OBJECT(obj);
+
+ return dobj->av;
+}
+
+
static void dummy_set_sv(Object *obj,
const char *value,
Error **errp)
@@ -91,6 +127,12 @@ static void dummy_init(Object *obj)
dummy_get_sv,
dummy_set_sv,
NULL);
+ object_property_add_enum(obj, "av",
+ "DummyAnimal",
+ dummyanimalmap,
+ dummy_get_av,
+ dummy_set_av,
+ NULL);
}
static void dummy_finalize(Object *obj)
@@ -122,12 +164,14 @@ static void test_dummy_createv(void)
&err,
"bv", "yes",
"sv", "Hiss hiss hiss",
+ "av", "platypus",
NULL));
g_assert(dobj != NULL);
g_assert(err == NULL);
g_assert(g_str_equal(dobj->sv, "Hiss hiss hiss"));
g_assert(dobj->bv == true);
+ g_assert(dobj->av == DUMMY_PLATYPUS);
g_assert(object_resolve_path_component(parent, "dummy0")
== OBJECT(dobj));
@@ -163,12 +207,14 @@ static void test_dummy_createlist(void)
parent,
"bv", "yes",
"sv", "Hiss hiss hiss",
+ "av", "platypus",
NULL));
g_assert(dobj != NULL);
g_assert(err == NULL);
g_assert(g_str_equal(dobj->sv, "Hiss hiss hiss"));
g_assert(dobj->bv == true);
+ g_assert(dobj->av == DUMMY_PLATYPUS);
g_assert(object_resolve_path_component(parent, "dummy0")
== OBJECT(dobj));
@@ -176,6 +222,33 @@ static void test_dummy_createlist(void)
object_unparent(OBJECT(dobj));
}
+static void test_dummy_badenum(void)
+{
+ Error *err = NULL;
+ Object *parent = container_get(object_get_root(),
+ "/objects");
+ DummyObject *dobj = DUMMY_OBJECT(
+ object_new_propv(TYPE_DUMMY,
+ parent,
+ "dummy0",
+ &err,
+ "bv", "yes",
+ "sv", "Hiss hiss hiss",
+ "av", "yeti",
+ NULL));
+
+ g_assert(dobj == NULL);
+ g_assert(err != NULL);
+ g_assert(g_str_equal(error_get_pretty(err),
+ "Invalid parameter 'yeti'"));
+
+ g_assert(object_resolve_path_component(parent, "dummy0")
+ == NULL);
+
+ error_free(err);
+}
+
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
@@ -185,6 +258,7 @@ int main(int argc, char **argv)
g_test_add_func("/qom/proplist/createlist", test_dummy_createlist);
g_test_add_func("/qom/proplist/createv", test_dummy_createv);
+ g_test_add_func("/qom/proplist/badenum", test_dummy_badenum);
return g_test_run();
}
--
2.3.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PULL 14/16] qom: don't pass string table to object_get_enum method
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
` (12 preceding siblings ...)
2015-05-08 12:07 ` [Qemu-devel] [PULL 13/16] qom: add a object_property_add_enum helper method Paolo Bonzini
@ 2015-05-08 12:07 ` Paolo Bonzini
2015-05-08 12:08 ` [Qemu-devel] [PULL 16/16] qemu-nbd: only send a limited number of errno codes on the wire Paolo Bonzini
2015-05-08 12:29 ` [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Andreas Färber
15 siblings, 0 replies; 22+ messages in thread
From: Paolo Bonzini @ 2015-05-08 12:07 UTC (permalink / raw)
To: qemu-devel
From: "Daniel P. Berrange" <berrange@redhat.com>
Now that properties can be explicitly registered as an enum
type, there is no need to pass the string table to the
object_get_enum method. The object property registration
already has a pointer to the string table.
In changing this method signature, the hostmem backend object
has to be converted to use the new enum property registration
code, which simplifies it somewhat.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1430476206-26034-8-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
backends/hostmem.c | 22 ++++++++--------------
include/qom/object.h | 4 ++--
numa.c | 2 +-
qom/object.c | 32 ++++++++++++++++++++++++--------
tests/check-qom-proplist.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 81 insertions(+), 25 deletions(-)
diff --git a/backends/hostmem.c b/backends/hostmem.c
index f6db33c..7d74be0 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -113,24 +113,17 @@ host_memory_backend_set_host_nodes(Object *obj, Visitor *v, void *opaque,
#endif
}
-static void
-host_memory_backend_get_policy(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+static int
+host_memory_backend_get_policy(Object *obj, Error **errp G_GNUC_UNUSED)
{
HostMemoryBackend *backend = MEMORY_BACKEND(obj);
- int policy = backend->policy;
-
- visit_type_enum(v, &policy, HostMemPolicy_lookup, NULL, name, errp);
+ return backend->policy;
}
static void
-host_memory_backend_set_policy(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
+host_memory_backend_set_policy(Object *obj, int policy, Error **errp)
{
HostMemoryBackend *backend = MEMORY_BACKEND(obj);
- int policy;
-
- visit_type_enum(v, &policy, HostMemPolicy_lookup, NULL, name, errp);
backend->policy = policy;
#ifndef CONFIG_NUMA
@@ -252,9 +245,10 @@ static void host_memory_backend_init(Object *obj)
object_property_add(obj, "host-nodes", "int",
host_memory_backend_get_host_nodes,
host_memory_backend_set_host_nodes, NULL, NULL, NULL);
- object_property_add(obj, "policy", "HostMemPolicy",
- host_memory_backend_get_policy,
- host_memory_backend_set_policy, NULL, NULL, NULL);
+ object_property_add_enum(obj, "policy", "HostMemPolicy",
+ HostMemPolicy_lookup,
+ host_memory_backend_get_policy,
+ host_memory_backend_set_policy, NULL);
}
MemoryRegion *
diff --git a/include/qom/object.h b/include/qom/object.h
index f6a2a9d..fc347b9 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1012,7 +1012,7 @@ int64_t object_property_get_int(Object *obj, const char *name,
* object_property_get_enum:
* @obj: the object
* @name: the name of the property
- * @strings: strings corresponding to enums
+ * @typename: the name of the enum data type
* @errp: returns an error if this function fails
*
* Returns: the value of the property, converted to an integer, or
@@ -1020,7 +1020,7 @@ int64_t object_property_get_int(Object *obj, const char *name,
* an enum).
*/
int object_property_get_enum(Object *obj, const char *name,
- const char * const strings[], Error **errp);
+ const char *typename, Error **errp);
/**
* object_property_get_uint16List:
diff --git a/numa.c b/numa.c
index c975fb2..a64279a 100644
--- a/numa.c
+++ b/numa.c
@@ -457,7 +457,7 @@ static int query_memdev(Object *obj, void *opaque)
m->value->policy = object_property_get_enum(obj,
"policy",
- HostMemPolicy_lookup,
+ "HostMemPolicy",
&err);
if (err) {
goto error;
diff --git a/qom/object.c b/qom/object.c
index ba0e4b8..6d2a2a9 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1026,13 +1026,35 @@ int64_t object_property_get_int(Object *obj, const char *name,
return retval;
}
+typedef struct EnumProperty {
+ const char * const *strings;
+ int (*get)(Object *, Error **);
+ void (*set)(Object *, int, Error **);
+} EnumProperty;
+
+
int object_property_get_enum(Object *obj, const char *name,
- const char * const strings[], Error **errp)
+ const char *typename, Error **errp)
{
StringOutputVisitor *sov;
StringInputVisitor *siv;
char *str;
int ret;
+ ObjectProperty *prop = object_property_find(obj, name, errp);
+ EnumProperty *enumprop;
+
+ if (prop == NULL) {
+ return 0;
+ }
+
+ if (!g_str_equal(prop->type, typename)) {
+ error_setg(errp, "Property %s on %s is not '%s' enum type",
+ name, object_class_get_name(
+ object_get_class(obj)), typename);
+ return 0;
+ }
+
+ enumprop = prop->opaque;
sov = string_output_visitor_new(false);
object_property_get(obj, string_output_get_visitor(sov), name, errp);
@@ -1040,7 +1062,7 @@ int object_property_get_enum(Object *obj, const char *name,
siv = string_input_visitor_new(str);
string_output_visitor_cleanup(sov);
visit_type_enum(string_input_get_visitor(siv),
- &ret, strings, NULL, name, errp);
+ &ret, enumprop->strings, NULL, name, errp);
g_free(str);
string_input_visitor_cleanup(siv);
@@ -1609,12 +1631,6 @@ void object_property_add_bool(Object *obj, const char *name,
}
}
-typedef struct EnumProperty {
- const char * const *strings;
- int (*get)(Object *, Error **);
- void (*set)(Object *, int, Error **);
-} EnumProperty;
-
static void property_get_enum(Object *obj, Visitor *v, void *opaque,
const char *name, Error **errp)
{
diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
index de142e3..d5cd38b 100644
--- a/tests/check-qom-proplist.c
+++ b/tests/check-qom-proplist.c
@@ -249,6 +249,51 @@ static void test_dummy_badenum(void)
}
+
+static void test_dummy_getenum(void)
+{
+ Error *err = NULL;
+ int val;
+ Object *parent = container_get(object_get_root(),
+ "/objects");
+ DummyObject *dobj = DUMMY_OBJECT(
+ object_new_propv(TYPE_DUMMY,
+ parent,
+ "dummy0",
+ &err,
+ "av", "platypus",
+ NULL));
+
+ g_assert(dobj != NULL);
+ g_assert(err == NULL);
+ g_assert(dobj->av == DUMMY_PLATYPUS);
+
+ val = object_property_get_enum(OBJECT(dobj),
+ "av",
+ "DummyAnimal",
+ &err);
+ g_assert(err == NULL);
+ g_assert(val == DUMMY_PLATYPUS);
+
+ /* A bad enum type name */
+ val = object_property_get_enum(OBJECT(dobj),
+ "av",
+ "BadAnimal",
+ &err);
+ g_assert(err != NULL);
+ error_free(err);
+ err = NULL;
+
+ /* A non-enum property name */
+ val = object_property_get_enum(OBJECT(dobj),
+ "iv",
+ "DummyAnimal",
+ &err);
+ g_assert(err != NULL);
+ error_free(err);
+}
+
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
@@ -259,6 +304,7 @@ int main(int argc, char **argv)
g_test_add_func("/qom/proplist/createlist", test_dummy_createlist);
g_test_add_func("/qom/proplist/createv", test_dummy_createv);
g_test_add_func("/qom/proplist/badenum", test_dummy_badenum);
+ g_test_add_func("/qom/proplist/getenum", test_dummy_getenum);
return g_test_run();
}
--
2.3.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [Qemu-devel] [PULL 16/16] qemu-nbd: only send a limited number of errno codes on the wire
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
` (13 preceding siblings ...)
2015-05-08 12:07 ` [Qemu-devel] [PULL 14/16] qom: don't pass string table to object_get_enum method Paolo Bonzini
@ 2015-05-08 12:08 ` Paolo Bonzini
2015-05-08 12:29 ` [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Andreas Färber
15 siblings, 0 replies; 22+ messages in thread
From: Paolo Bonzini @ 2015-05-08 12:08 UTC (permalink / raw)
To: qemu-devel
Right now, NBD includes potentially platform-specific error values in
the wire protocol.
Luckily, most common error values are more or less universal: in
particular, of all errno values <= 34 (up to ERANGE), they are all the
same on supported platforms except for 11 (which is EAGAIN on Windows and
Linux, but EDEADLK on Darwin and the *BSDs). So, in order to guarantee
some portability, only keep a handful of possible error codes and squash
everything else to EINVAL.
This patch defines a limited set of errno values that are valid for the
NBD protocol, and specifies recommendations for what error to return
in specific corner cases. The set of errno values is roughly based on
the errors listed in the read(2) and write(2) man pages, with some
exceptions:
- ENOMEM is added for servers that implement copy-on-write or other
formats that require dynamic allocation.
- EDQUOT is not part of the universal set of errors; it can be changed
to ENOSPC on the wire format.
- EFBIG is part of the universal set of errors, but it is also changed
to ENOSPC because it is pretty similar to ENOSPC or EDQUOT.
Incoming values will in general match system errno values, but not
on the Hurd which has different errno values (they have a "subsystem
code" equal to 0x10 in bits 24-31). The Hurd is probably not something
to which QEMU has been ported, but still do the right thing and
reverse-map the NBD errno values to the system errno values.
The corresponding patch to the NBD protocol description can be found at
http://article.gmane.org/gmane.linux.drivers.nbd.general/3154.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
nbd.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/nbd.c b/nbd.c
index cb1b9bb..57d71b2 100644
--- a/nbd.c
+++ b/nbd.c
@@ -86,6 +86,54 @@
#define NBD_OPT_ABORT (2)
#define NBD_OPT_LIST (3)
+/* NBD errors are based on errno numbers, so there is a 1:1 mapping,
+ * but only a limited set of errno values is specified in the protocol.
+ * Everything else is squashed to EINVAL.
+ */
+#define NBD_EPERM 1
+#define NBD_EIO 5
+#define NBD_ENOMEM 12
+#define NBD_EINVAL 22
+#define NBD_ENOSPC 28
+
+static int system_errno_to_nbd_errno(int err)
+{
+ switch (err) {
+ case EPERM:
+ return NBD_EPERM;
+ case EIO:
+ return NBD_EIO;
+ case ENOMEM:
+ return NBD_ENOMEM;
+#ifdef EDQUOT
+ case EDQUOT:
+#endif
+ case EFBIG:
+ case ENOSPC:
+ return NBD_ENOSPC;
+ case EINVAL:
+ default:
+ return NBD_EINVAL;
+ }
+}
+
+static int nbd_errno_to_system_errno(int err)
+{
+ switch (err) {
+ case NBD_EPERM:
+ return EPERM;
+ case NBD_EIO:
+ return EIO;
+ case NBD_ENOMEM:
+ return ENOMEM;
+ case NBD_ENOSPC:
+ return ENOSPC;
+ case NBD_EINVAL:
+ default:
+ return EINVAL;
+ }
+}
+
/* Definitions for opaque data types */
typedef struct NBDRequest NBDRequest;
@@ -856,6 +904,8 @@ ssize_t nbd_receive_reply(int csock, struct nbd_reply *reply)
reply->error = be32_to_cpup((uint32_t*)(buf + 4));
reply->handle = be64_to_cpup((uint64_t*)(buf + 8));
+ reply->error = nbd_errno_to_system_errno(reply->error);
+
TRACE("Got reply: "
"{ magic = 0x%x, .error = %d, handle = %" PRIu64" }",
magic, reply->error, reply->handle);
@@ -872,6 +922,8 @@ static ssize_t nbd_send_reply(int csock, struct nbd_reply *reply)
uint8_t buf[NBD_REPLY_SIZE];
ssize_t ret;
+ reply->error = system_errno_to_nbd_errno(reply->error);
+
/* Reply
[ 0 .. 3] magic (NBD_REPLY_MAGIC)
[ 4 .. 7] error (0 == no error)
--
2.3.5
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08
2015-05-08 12:07 [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Paolo Bonzini
` (14 preceding siblings ...)
2015-05-08 12:08 ` [Qemu-devel] [PULL 16/16] qemu-nbd: only send a limited number of errno codes on the wire Paolo Bonzini
@ 2015-05-08 12:29 ` Andreas Färber
2015-05-08 12:34 ` Daniel P. Berrange
2015-05-12 16:57 ` Daniel P. Berrange
15 siblings, 2 replies; 22+ messages in thread
From: Andreas Färber @ 2015-05-08 12:29 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel, Peter Maydell
Am 08.05.2015 um 14:07 schrieb Paolo Bonzini:
> The following changes since commit 498147529d1f8e902e6528a0115143b53475791e:
>
> Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20150430' into staging (2015-04-30 14:15:56 +0100)
>
> are available in the git repository at:
>
> git://github.com/bonzini/qemu.git tags/for-upstream
>
> for you to fetch changes up to d51026b22b97332a95d91acfb6c23cd9b087955c:
>
> qemu-nbd: only send a limited number of errno codes on the wire (2015-05-08 13:14:54 +0200)
>
> ----------------------------------------------------------------
> - Daniel's QOM improvements
Once again, objection.
Andreas
> - build bugfix from Fam and new configure check from Emilio
> - two improvements to "info mtere" from Gerd
> - KVM support for memory transaction attributes
> - one more small step towards unlocked MMIO dispatch
> - one piece of the qemu-nbd errno fixes
> - trivial-ish patches from Denis and Thomas
>
> ----------------------------------------------------------------
> Daniel P. Berrange (7):
> qom: fix typename of 'policy' enum property in hostmem obj
> qom: document user creatable object types in help text
> qom: create objects in two phases
> qom: add object_new_propv / object_new_proplist constructors
> qom: make enum string tables const-correct
> qom: add a object_property_add_enum helper method
> qom: don't pass string table to object_get_enum method
>
> Denis V. Lunev (1):
> apic_common: improve readability of apic_reset_common
>
> Emilio G. Cota (1):
> configure: require __thread support
>
> Fam Zheng (1):
> rules.mak: Force CFLAGS for all objects in DSO
>
> Gerd Hoffmann (2):
> mtree: tag & indent a bit better
> mtree: also print disabled regions
>
> Paolo Bonzini (3):
> kvm: add support for memory transaction attributes
> exec: move rcu_read_lock/unlock to address_space_translate callers
> qemu-nbd: only send a limited number of errno codes on the wire
>
> Thomas Huth (1):
> kvm: Silence warning from valgrind
>
> backends/hostmem.c | 22 ++--
> configure | 11 ++
> exec.c | 33 ++++-
> hw/intc/apic_common.c | 7 +-
> hw/vfio/common.c | 7 +-
> include/exec/memory.h | 4 +-
> include/hw/qdev-core.h | 2 +-
> include/qapi/util.h | 2 +-
> include/qapi/visitor-impl.h | 6 +-
> include/qapi/visitor.h | 2 +-
> include/qom/object.h | 90 ++++++++++++-
> include/sysemu/kvm.h | 3 +-
> kvm-all.c | 35 ++---
> memory.c | 23 ++--
> nbd.c | 52 ++++++++
> numa.c | 2 +-
> qapi/qapi-dealloc-visitor.c | 3 +-
> qapi/qapi-util.c | 2 +-
> qapi/qapi-visit-core.c | 6 +-
> qemu-options.hx | 70 +++++++---
> qom/object.c | 144 +++++++++++++++++++-
> rules.mak | 4 +-
> scripts/qapi-types.py | 4 +-
> target-arm/kvm.c | 4 +-
> target-i386/kvm.c | 4 +-
> target-mips/kvm.c | 4 +-
> target-ppc/kvm.c | 4 +-
> target-s390x/kvm.c | 4 +-
> tests/.gitignore | 1 +
> tests/Makefile | 5 +-
> tests/check-qom-proplist.c | 310 ++++++++++++++++++++++++++++++++++++++++++++
> translate-all.c | 3 +
> vl.c | 40 +++++-
> 33 files changed, 819 insertions(+), 94 deletions(-)
> create mode 100644 tests/check-qom-proplist.c
>
--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08
2015-05-08 12:29 ` [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Andreas Färber
@ 2015-05-08 12:34 ` Daniel P. Berrange
2015-05-08 12:39 ` Andreas Färber
2015-05-12 16:57 ` Daniel P. Berrange
1 sibling, 1 reply; 22+ messages in thread
From: Daniel P. Berrange @ 2015-05-08 12:34 UTC (permalink / raw)
To: Andreas Färber; +Cc: Paolo Bonzini, qemu-devel, Peter Maydell
On Fri, May 08, 2015 at 02:29:01PM +0200, Andreas Färber wrote:
> Am 08.05.2015 um 14:07 schrieb Paolo Bonzini:
> > The following changes since commit 498147529d1f8e902e6528a0115143b53475791e:
> >
> > Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20150430' into staging (2015-04-30 14:15:56 +0100)
> >
> > are available in the git repository at:
> >
> > git://github.com/bonzini/qemu.git tags/for-upstream
> >
> > for you to fetch changes up to d51026b22b97332a95d91acfb6c23cd9b087955c:
> >
> > qemu-nbd: only send a limited number of errno codes on the wire (2015-05-08 13:14:54 +0200)
> >
> > ----------------------------------------------------------------
> > - Daniel's QOM improvements
>
> Once again, objection.
If you have any specific technical comments I'm happy to respond to them,
but I've not seen any further negative feedback on the patches since last
time I posted them.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08
2015-05-08 12:34 ` Daniel P. Berrange
@ 2015-05-08 12:39 ` Andreas Färber
2015-05-08 12:42 ` Daniel P. Berrange
0 siblings, 1 reply; 22+ messages in thread
From: Andreas Färber @ 2015-05-08 12:39 UTC (permalink / raw)
To: Daniel P. Berrange; +Cc: Paolo Bonzini, qemu-devel, Peter Maydell
Am 08.05.2015 um 14:34 schrieb Daniel P. Berrange:
> On Fri, May 08, 2015 at 02:29:01PM +0200, Andreas Färber wrote:
>> Am 08.05.2015 um 14:07 schrieb Paolo Bonzini:
>>> The following changes since commit 498147529d1f8e902e6528a0115143b53475791e:
>>>
>>> Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20150430' into staging (2015-04-30 14:15:56 +0100)
>>>
>>> are available in the git repository at:
>>>
>>> git://github.com/bonzini/qemu.git tags/for-upstream
>>>
>>> for you to fetch changes up to d51026b22b97332a95d91acfb6c23cd9b087955c:
>>>
>>> qemu-nbd: only send a limited number of errno codes on the wire (2015-05-08 13:14:54 +0200)
>>>
>>> ----------------------------------------------------------------
>>> - Daniel's QOM improvements
>>
>> Once again, objection.
>
> If you have any specific technical comments I'm happy to respond to them,
> but I've not seen any further negative feedback on the patches since last
> time I posted them.
The point is, I am still the QOM maintainer, so I need to review them,
not just not-negatively-comment. I have two QOM patches from Eduardo in
my queue already. And unless I'm totally mistaken, I was only CC'ed on
the very last v3, not any previous versions.
I will take a look at them shortly and, assuming everything is fine and
no conflicts, they can then go through Paolo's queue with my Ab/Rb.
Regards,
Andreas
--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08
2015-05-08 12:39 ` Andreas Färber
@ 2015-05-08 12:42 ` Daniel P. Berrange
0 siblings, 0 replies; 22+ messages in thread
From: Daniel P. Berrange @ 2015-05-08 12:42 UTC (permalink / raw)
To: Andreas Färber; +Cc: Paolo Bonzini, qemu-devel, Peter Maydell
On Fri, May 08, 2015 at 02:39:57PM +0200, Andreas Färber wrote:
> Am 08.05.2015 um 14:34 schrieb Daniel P. Berrange:
> > On Fri, May 08, 2015 at 02:29:01PM +0200, Andreas Färber wrote:
> >> Am 08.05.2015 um 14:07 schrieb Paolo Bonzini:
> >>> The following changes since commit 498147529d1f8e902e6528a0115143b53475791e:
> >>>
> >>> Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20150430' into staging (2015-04-30 14:15:56 +0100)
> >>>
> >>> are available in the git repository at:
> >>>
> >>> git://github.com/bonzini/qemu.git tags/for-upstream
> >>>
> >>> for you to fetch changes up to d51026b22b97332a95d91acfb6c23cd9b087955c:
> >>>
> >>> qemu-nbd: only send a limited number of errno codes on the wire (2015-05-08 13:14:54 +0200)
> >>>
> >>> ----------------------------------------------------------------
> >>> - Daniel's QOM improvements
> >>
> >> Once again, objection.
> >
> > If you have any specific technical comments I'm happy to respond to them,
> > but I've not seen any further negative feedback on the patches since last
> > time I posted them.
>
> The point is, I am still the QOM maintainer, so I need to review them,
> not just not-negatively-comment. I have two QOM patches from Eduardo in
> my queue already. And unless I'm totally mistaken, I was only CC'ed on
> the very last v3, not any previous versions.
I did copy you on the v2 a couple of days before, but I had indeed left
you off the v1 - it was part of a much larger RFC series which I hadn't
copied all the subsystem maintainers on.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08
2015-05-08 12:29 ` [Qemu-devel] [PULL 00/16] KVM, QOM, NBD, build fixes for 2015-05-08 Andreas Färber
2015-05-08 12:34 ` Daniel P. Berrange
@ 2015-05-12 16:57 ` Daniel P. Berrange
1 sibling, 0 replies; 22+ messages in thread
From: Daniel P. Berrange @ 2015-05-12 16:57 UTC (permalink / raw)
To: Andreas Färber; +Cc: Paolo Bonzini, qemu-devel, Peter Maydell
On Fri, May 08, 2015 at 02:29:01PM +0200, Andreas Färber wrote:
> Am 08.05.2015 um 14:07 schrieb Paolo Bonzini:
> > The following changes since commit 498147529d1f8e902e6528a0115143b53475791e:
> >
> > Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20150430' into staging (2015-04-30 14:15:56 +0100)
> >
> > are available in the git repository at:
> >
> > git://github.com/bonzini/qemu.git tags/for-upstream
> >
> > for you to fetch changes up to d51026b22b97332a95d91acfb6c23cd9b087955c:
> >
> > qemu-nbd: only send a limited number of errno codes on the wire (2015-05-08 13:14:54 +0200)
> >
> > ----------------------------------------------------------------
> > - Daniel's QOM improvements
>
> Once again, objection.
Paolo, I'll re-send a v4 of these QOM related improvements that
incorporate Andreas' feedback.
> > - build bugfix from Fam and new configure check from Emilio
> > - two improvements to "info mtere" from Gerd
> > - KVM support for memory transaction attributes
> > - one more small step towards unlocked MMIO dispatch
> > - one piece of the qemu-nbd errno fixes
> > - trivial-ish patches from Denis and Thomas
> >
> > ----------------------------------------------------------------
> > Daniel P. Berrange (7):
> > qom: fix typename of 'policy' enum property in hostmem obj
> > qom: document user creatable object types in help text
> > qom: create objects in two phases
> > qom: add object_new_propv / object_new_proplist constructors
> > qom: make enum string tables const-correct
> > qom: add a object_property_add_enum helper method
> > qom: don't pass string table to object_get_enum method
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
^ permalink raw reply [flat|nested] 22+ messages in thread