Misc changes for QEMU 2.6.0-rc1
Subsystems (4)
The following changes since commit 92741fc4b6cbf7a8f6cce45e9a468d5637a4ff6a:
Merge remote-tracking branch 'remotes/thibault/tags/samuel-thibault' into staging (2016-03-31 11:52:44 +0100)
are available in the git repository at:
git://github.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to 2354bebaa408b97adf008d3e07f439300b0a5c06:
net: fix missing include of qapi/error.h in netmap.c (2016-04-05 11:46:52 +0200)
----------------------------------------------------------------
* FreeBSD build fixes (atomics, qapi/error.h)
* x86 KVM fixes (SynIC, KVM_GET/SET_MSRS)
* Memory API doc fix
* checkpatch fix
* Chardev and socket fixes
* NBD fixes
* exec.c SEGV fix
----------------------------------------------------------------
Alex Bennée (2):
cpus: don't use atomic_read for vm_clock_warp_start include/qemu/atomic: add compile time asserts
Andrey Smetanin (1):
target-i386/kvm: Hyper-V VMBus hypercalls blank handlers
Cao jin (1):
doc/memory: update MMIO section
Cédric Le Goater (1):
checkpatch: add target_ulong to typelist
Daniel P. Berrange (4):
util: retry getaddrinfo if getting EAI_BADFLAGS with AI_V4MAPPED
char: fix broken EAGAIN retry on OS-X due to errno clobbering
char: ensure all clients are in non-blocking mode
net: fix missing include of qapi/error.h in netmap.c
Eric Blake (2):
nbd: don't request FUA on FLUSH
nbd: Fix poor debug message
Marc-André Lureau (1):
memory: fix segv on qemu_ram_free(block=0x0)
Paolo Bonzini (3):
update Linux headers to 4.6
target-i386: do not pass MSR_TSC_AUX to KVM ioctls if CPUID bit is not set
target-i386: assert that KVM_GET/SET_MSRS can set all requested MSRs
block/nbd-client.c | 4 -- cpus.c | 10 ++- docs/memory.txt | 4 +- exec.c | 4 ++ include/qemu/atomic.h | 58 +++++++++------- include/standard-headers/asm-x86/hyperv.h | 4 +- include/standard-headers/linux/input.h | 1 + include/standard-headers/linux/types.h | 5 +- include/standard-headers/linux/virtio_balloon.h | 2 +- include/standard-headers/linux/virtio_blk.h | 6 +- linux-headers/asm-arm64/kvm.h | 6 ++ linux-headers/asm-powerpc/epapr_hcalls.h | 4 +- linux-headers/asm-powerpc/kvm.h | 9 +++ linux-headers/asm-x86/unistd_32.h | 2 + linux-headers/asm-x86/unistd_64.h | 2 + linux-headers/linux/kvm.h | 11 +++ linux-headers/linux/userfaultfd.h | 2 +- linux-headers/linux/vfio.h | 92 ++++++++++++++++++++++++- linux-headers/linux/vhost.h | 6 ++ nbd/client.c | 2 +- net/netmap.c | 1 + qemu-char.c | 39 ++++++----- scripts/checkpatch.pl | 1 + target-i386/hyperv.c | 12 ++++ target-i386/kvm.c | 37 ++++++++-- tests/test-io-channel-socket.c | 5 +- util/qemu-sockets.c | 19 ++++- 27 files changed, 276 insertions(+), 72 deletions(-)
Signature · 1 line
2.5.5
[Qemu-devel] [PULL 01/15] update Linux headers to 4.6
--- include/standard-headers/asm-x86/hyperv.h | 4 +- include/standard-headers/linux/input.h | 1 + include/standard-headers/linux/types.h | 5 +- include/standard-headers/linux/virtio_balloon.h | 2 +- include/standard-headers/linux/virtio_blk.h | 6 +- linux-headers/asm-arm64/kvm.h | 6 ++ linux-headers/asm-powerpc/epapr_hcalls.h | 4 +- linux-headers/asm-powerpc/kvm.h | 9 +++ linux-headers/asm-x86/unistd_32.h | 2 + linux-headers/asm-x86/unistd_64.h | 2 + linux-headers/linux/kvm.h | 11 +++ linux-headers/linux/userfaultfd.h | 2 +- linux-headers/linux/vfio.h | 92 ++++++++++++++++++++++++- linux-headers/linux/vhost.h | 6 ++ 14 files changed, 140 insertions(+), 12 deletions(-)
include/standard-headers/asm-x86/hyperv.h +3 -1
@@ -226,7 +226,9 @@ (~((1ull <<HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT ) -1 )) /* Declare the various hypercall operations. */ -#define HV_X64_HV_NOTIFY_LONG_SPIN_WAIT 0x0008 +#define HVCALL_NOTIFY_LONG_SPIN_WAIT 0x0008 +#define HVCALL_POST_MESSAGE 0x005c +#define HVCALL_SIGNAL_EVENT 0x005d#define HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE 0x00000001#define HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT 12
include/standard-headers/linux/input.h +1 -0
@@ -243,6 +243,7 @@ struct input_mask {#define BUS_GSC 0x1A#define BUS_ATARI 0x1B#define BUS_SPI 0x1C +#define BUS_RMI 0x1D/* * MT_TOOL types
include/standard-headers/linux/types.h +3 -2
@@ -1,2 +1,3 @@ -#include <stdint.h> -#include "qemu/compiler.h" +/* For QEMU all types are already defined via osdep.h, so this +* header does not need to do anything. +*/
include/standard-headers/linux/virtio_balloon.h +1 -1
@@ -51,7 +51,7 @@ struct virtio_balloon_config {#define VIRTIO_BALLOON_S_MINFLT 3/* Number of minor faults */ #define VIRTIO_BALLOON_S_MEMFREE 4/* Total amount of free memory */ #define VIRTIO_BALLOON_S_MEMTOT 5/* Total amount of memory */ -#define VIRTIO_BALLOON_S_AVAIL 6/* Amount of available memory in guest */ +#define VIRTIO_BALLOON_S_AVAIL 6/* Available memory as in /proc */ #define VIRTIO_BALLOON_S_NR 7/*
include/standard-headers/linux/virtio_blk.h +3 -3
@@ -43,10 +43,10 @@#ifndef VIRTIO_BLK_NO_LEGACY #define VIRTIO_BLK_F_BARRIER 0/* Does host support barriers? */ #define VIRTIO_BLK_F_SCSI 7/* Supports scsi command passthru */ -#define VIRTIO_BLK_F_WCE 9/* Writeback mode enabled after reset */ +#define VIRTIO_BLK_F_FLUSH 9/* Flush command supported */ #define VIRTIO_BLK_F_CONFIG_WCE 11/* Writeback mode available in config */ -/* Old (deprecated) name for VIRTIO_BLK_F_WCE. */ -#define VIRTIO_BLK_F_FLUSH VIRTIO_BLK_F_WCE +/* Old (deprecated) name for VIRTIO_BLK_F_FLUSH. */ +#define VIRTIO_BLK_F_WCE VIRTIO_BLK_F_FLUSH#endif /* !VIRTIO_BLK_NO_LEGACY */ #define VIRTIO_BLK_ID_BYTES 20/* ID string length */
linux-headers/asm-arm64/kvm.h +6 -0
@@ -94,6 +94,7 @@ struct kvm_regs {#define KVM_ARM_VCPU_POWER_OFF 0/* CPU is started in OFF state */ #define KVM_ARM_VCPU_EL1_32BIT 1/* CPU running a 32bit VM */ #define KVM_ARM_VCPU_PSCI_0_2 2/* CPU uses PSCI v0.2 */ +#define KVM_ARM_VCPU_PMU_V3 3/* Support guest PMUv3 */ struct kvm_vcpu_init {__u32 target;
@@ -204,6 +205,11 @@ struct kvm_arch_memory_slot {#define KVM_DEV_ARM_VGIC_GRP_CTRL 4#define KVM_DEV_ARM_VGIC_CTRL_INIT 0 +/* Device Control API on vcpu fd */ +#define KVM_ARM_VCPU_PMU_V3_CTRL 0 +#define KVM_ARM_VCPU_PMU_V3_IRQ 0 +#define KVM_ARM_VCPU_PMU_V3_INIT 1 +/* KVM_IRQ_LINE irq field index values */ #define KVM_ARM_IRQ_TYPE_SHIFT 24#define KVM_ARM_IRQ_TYPE_MASK 0xff
linux-headers/asm-powerpc/epapr_hcalls.h +2 -2
@@ -78,7 +78,7 @@#define EV_SUCCESS 0#define EV_EPERM 1/* Operation not permitted */ #define EV_ENOENT 2/* Entry Not Found */ -#define EV_EIO 3/* I/O error occured */ +#define EV_EIO 3/* I/O error occurred */ #define EV_EAGAIN 4/* The operation had insufficient * resources to complete and should be * retried
@@ -89,7 +89,7 @@#define EV_ENODEV 7/* No such device */ #define EV_EINVAL 8/* An argument supplied to the hcall was out of range or invalid */ -#define EV_INTERNAL 9/* An internal error occured */ +#define EV_INTERNAL 9/* An internal error occurred */ #define EV_CONFIG 10/* A configuration error was detected */ #define EV_INVALID_STATE 11/* The object is in an invalid state */ #define EV_UNIMPLEMENTED 12/* Unimplemented hypercall */
linux-headers/asm-powerpc/kvm.h +9 -0
@@ -333,6 +333,15 @@ struct kvm_create_spapr_tce {__u32 window_size; }; +/* for KVM_CAP_SPAPR_TCE_64 */ +struct kvm_create_spapr_tce_64 { +__u64 liobn; +__u32 page_shift; +__u32 flags; +__u64 offset;/* in pages */ +__u64 size;/* in pages */ +}; +/* for KVM_ALLOCATE_RMA */ struct kvm_allocate_rma {__u64 rma_size;
linux-headers/asm-x86/unistd_32.h +2 -0
@@ -375,5 +375,7 @@#define __NR_membarrier 375#define __NR_mlock2 376#define __NR_copy_file_range 377 +#define __NR_preadv2 378 +#define __NR_pwritev2 379#endif /* _ASM_X86_UNISTD_32_H */
linux-headers/asm-x86/unistd_64.h +2 -0
@@ -328,5 +328,7 @@#define __NR_membarrier 324#define __NR_mlock2 325#define __NR_copy_file_range 326 +#define __NR_preadv2 327 +#define __NR_pwritev2 328#endif /* _ASM_X86_UNISTD_64_H */
linux-headers/linux/kvm.h +11 -0
@@ -157,6 +157,7 @@ struct kvm_s390_skeys { struct kvm_hyperv_exit { #define KVM_EXIT_HYPERV_SYNIC 1 +#define KVM_EXIT_HYPERV_HCALL 2 __u32 type; union { struct {
@@ -165,6 +166,11 @@ struct kvm_hyperv_exit {__u64 evt_page;__u64 msg_page; } synic; +struct { +__u64 input; +__u64 result; +__u64 params[2 ]; + } hcall; } u; };
@@ -856,6 +862,9 @@ struct kvm_ppc_smmu_info {#define KVM_CAP_IOEVENTFD_ANY_LENGTH 122#define KVM_CAP_HYPERV_SYNIC 123#define KVM_CAP_S390_RI 124 +#define KVM_CAP_SPAPR_TCE_64 125 +#define KVM_CAP_ARM_PMU_V3 126 +#define KVM_CAP_VCPU_ATTRIBUTES 127#ifdef KVM_CAP_IRQ_ROUTING
@@ -1148,6 +1157,8 @@ struct kvm_s390_ucas_mapping {/* Available with KVM_CAP_PPC_ALLOC_HTAB */ #define KVM_PPC_ALLOCATE_HTAB _IOWR(KVMIO, 0xa7, __u32)#define KVM_CREATE_SPAPR_TCE _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce) +#define KVM_CREATE_SPAPR_TCE_64 _IOW(KVMIO, 0xa8, \ + struct kvm_create_spapr_tce_64)/* Available with KVM_CAP_RMA */ #define KVM_ALLOCATE_RMA _IOR(KVMIO, 0xa9, struct kvm_allocate_rma)/* Available with KVM_CAP_PPC_HTAB_FD */
linux-headers/linux/userfaultfd.h +1 -1
@@ -78,7 +78,7 @@ struct uffd_msg {__u64 reserved3; } reserved; } arg; -} __packed; +} __attribute__((packed));/* * Start at 0x12 and not at 0 to be more strict against bugs.
linux-headers/linux/vfio.h +90 -2
116 lines not on this page · raw message
linux-headers/linux/vhost.h +6 -0
@@ -126,6 +126,12 @@ struct vhost_memory {#define VHOST_SET_VRING_CALL _IOW(VHOST_VIRTIO, 0x21, struct vhost_vring_file)/* Set eventfd to signal an error */ #define VHOST_SET_VRING_ERR _IOW(VHOST_VIRTIO, 0x22, struct vhost_vring_file) +/* Set busy loop timeout (in us) */ +#define VHOST_SET_VRING_BUSYLOOP_TIMEOUT _IOW(VHOST_VIRTIO, 0x23, \ + struct vhost_vring_state) +/* Get busy loop timeout (in us) */ +#define VHOST_GET_VRING_BUSYLOOP_TIMEOUT _IOW(VHOST_VIRTIO, 0x24, \ + struct vhost_vring_state)/* VHOST_NET specific defines */
Signature · 1 line
2.5.5
[Qemu-devel] [PULL 03/15] memory: fix segv on qemu_ram_free(block=0x0)
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
Since f1060c55bf1377b4, the pointer is directly passed to qemu_ram_free(). However, on initialization failure, it may be called with a NULL pointer. Return immediately in this case.
This fixes a SEGV when memory initialization failed, for example permission denied on open backing store /dev/hugepages, with -object memory-backend-file,mem-path=/dev/hugepages.
Program received signal SIGSEGV, Segmentation fault.0x00005555556e67e7 in qemu_ram_free (block=0x0) at /home/elmarco/src/qemu/exec.c:1775
Message-Id: <[email protected]>
--- exec.c | 4 ++++ 1 file changed, 4 insertions(+)
exec.c +4 -0
@@ -1773,6 +1773,10 @@ static void reclaim_ramblock(RAMBlock *block)void qemu_ram_free (RAMBlock *block) { +if (!block) { +return ; + } +qemu_mutex_lock_ramlist ();QLIST_REMOVE_RCU (block, next); ram_list.mru_block =NULL ;
Signature · 1 line
2.5.5
[Qemu-devel] [PULL 04/15] target-i386: do not pass MSR_TSC_AUX to KVM ioctls if CPUID bit is not set
In reply to Paolo BonziniKVM does not let you read or write this MSR if the corresponding CPUID bit is not set. This in turn causes MSRs that come after MSR_TSC_AUX to be ignored by KVM_SET_MSRS.
One visible symptom is that s3.flat from kvm-unit-tests fails with CPUs that do not have RDTSCP, because the SMBASE is not reset to 0x30000 after reset.
--- target-i386/kvm.c | 3 +++ 1 file changed, 3 insertions(+)
target-i386/kvm.c +3 -0
@@ -917,6 +917,9 @@ int kvm_arch_init_vcpu(CPUState *cs)if (env->features[FEAT_1_EDX ] &CPUID_MTRR ) { has_msr_mtrr = true; } +if (!(env->features[FEAT_8000_0001_EDX ] &CPUID_EXT2_RDTSCP )) { + has_msr_tsc_aux = false; + }return 0 ; }
Signature · 1 line
2.5.5
[Qemu-devel] [PULL 02/15] target-i386/kvm: Hyper-V VMBus hypercalls blank handlers
In reply to Paolo BonziniFrom: Andrey Smetanin <[email protected]>
Add Hyper-V VMBus hypercalls blank handlers which just returns error code - HV_STATUS_INVALID_HYPERCALL_CODE. This is required when the synthetic interrupt controller is active.
Message-Id: <[email protected]>
--- target-i386/hyperv.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
target-i386/hyperv.c +12 -0
@@ -44,6 +44,18 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit)return -1 ; }return 0 ; +case KVM_EXIT_HYPERV_HCALL : { +uint16_t code; + + code = exit->u.hcall.input &0xffff ; +switch (code) { +case HVCALL_POST_MESSAGE : +case HVCALL_SIGNAL_EVENT : +default : + exit->u.hcall.result =HV_STATUS_INVALID_HYPERCALL_CODE ; +return 0 ; + } + }default :return -1 ; }
Signature · 1 line
2.5.5
[Qemu-devel] [PULL 05/15] target-i386: assert that KVM_GET/SET_MSRS can set all requested MSRs
In reply to Paolo BonziniThis would have caught the bug in the previous patch.
--- target-i386/kvm.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-)
target-i386/kvm.c +30 -4
@@ -141,6 +141,7 @@ static int kvm_get_tsc(CPUState *cs)return ret; } +assert (ret ==1 ); env->tsc = msr_data.entries[0 ].data;return 0 ; }
@@ -1446,6 +1447,7 @@ static int kvm_put_tscdeadline_msr(X86CPU *cpu)struct kvm_msr_entry entries[1 ]; } msr_data;struct kvm_msr_entry *msrs = msr_data.entries; +int ret;if (!has_msr_tsc_deadline) {return 0 ;
@@ -1457,7 +1459,13 @@ static int kvm_put_tscdeadline_msr(X86CPU *cpu) .nmsrs = 1, }; -return kvm_vcpu_ioctl (CPU (cpu),KVM_SET_MSRS , &msr_data); + ret =kvm_vcpu_ioctl (CPU (cpu),KVM_SET_MSRS , &msr_data); +if (ret <0 ) { +return ret; + } + +assert (ret ==1 ); +return 0 ; }/*
@@ -1472,6 +1480,11 @@ static int kvm_put_msr_feature_control(X86CPU *cpu)struct kvm_msrs info;struct kvm_msr_entry entry; } msr_data; +int ret; + +if (!has_msr_feature_control) { +return 0 ; + }kvm_msr_entry_set (&msr_data.entry,MSR_IA32_FEATURE_CONTROL , cpu->env.msr_ia32_feature_control);
@@ -1480,7 +1493,13 @@ static int kvm_put_msr_feature_control(X86CPU *cpu) .nmsrs = 1, }; -return kvm_vcpu_ioctl (CPU (cpu),KVM_SET_MSRS , &msr_data); + ret =kvm_vcpu_ioctl (CPU (cpu),KVM_SET_MSRS , &msr_data); +if (ret <0 ) { +return ret; + } + +assert (ret ==1 ); +return 0 ; }static int kvm_put_msrs (X86CPU *cpu,int level)
@@ -1492,6 +1511,7 @@ static int kvm_put_msrs(X86CPU *cpu, int level) } msr_data;struct kvm_msr_entry *msrs = msr_data.entries;int n =0 , i; +int ret;kvm_msr_entry_set (&msrs[n++],MSR_IA32_SYSENTER_CS , env->sysenter_cs);kvm_msr_entry_set (&msrs[n++],MSR_IA32_SYSENTER_ESP , env->sysenter_esp);
@@ -1685,8 +1705,13 @@ static int kvm_put_msrs(X86CPU *cpu, int level) .nmsrs = n, }; -return kvm_vcpu_ioctl (CPU (cpu),KVM_SET_MSRS , &msr_data); + ret =kvm_vcpu_ioctl (CPU (cpu),KVM_SET_MSRS , &msr_data); +if (ret <0 ) { +return ret; + } +assert (ret == n); +return 0 ; }
@@ -2055,6 +2080,7 @@ static int kvm_get_msrs(X86CPU *cpu)return ret; } +assert (ret == n);for (i =0 ; i < ret; i++) {uint32_t index = msrs[i].index;switch (index) {
@@ -2511,7 +2537,7 @@ int kvm_arch_put_registers(CPUState *cpu, int level)assert (cpu_is_stopped (cpu) ||qemu_cpu_is_self (cpu)); -if (level >=KVM_PUT_RESET_STATE && has_msr_feature_control) { +if (level >=KVM_PUT_RESET_STATE ) { ret =kvm_put_msr_feature_control (x86_cpu);if (ret <0 ) {return ret;
Signature · 1 line
2.5.5
[Qemu-devel] [PULL 06/15] checkpatch: add target_ulong to typelist
In reply to Paolo BonziniFrom: Cédric Le Goater <[email protected]>
In some occasions, a patch [1] can start with a hunk containing a simple type cast. At the time annotate_values() is run, the type is unknown and the cast type is misinterpreted as a identifier, resulting in an error if it is followed with a negative value:
ERROR: spaces required around that '-' (ctx:WxV)
It seems complex to catch all possible types in a cast expression. So, as a fallback solution, let's add some common qemu types to the typeList array.
[1] http://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg06741.html
Message-Id: <[email protected]>
--- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +1 -0
@@ -212,6 +212,7 @@ our @typeList = ( qr{${Ident}_t}, qr{${Ident}_handler}, qr{${Ident}_handler_fn}, + qr{target_(?:u)?long}, ); # This can be modified by sub possible. Since it can be empty, be careful
Signature · 1 line
2.5.5
[Qemu-devel] [PULL 09/15] char: ensure all clients are in non-blocking mode
In reply to Paolo BonziniFrom: "Daniel P. Berrange" <[email protected]>
Only some callers of tcp_chr_new_client are putting the socket client into non-blocking mode. Move the call to qio_channel_set_blocking() into the tcp_chr_new_client method to guarantee that all code paths set non-blocking mode
Message-Id: <[email protected]>
--- qemu-char.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
qemu-char.c +2 -1
@@ -3081,6 +3081,8 @@ static int tcp_chr_new_client(CharDriverState *chr, QIOChannelSocket *sioc) s->sioc = sioc;object_ref (OBJECT (sioc)); +qio_channel_set_blocking (s->ioc, false,NULL ); +if (s->do_nodelay) {qio_channel_set_delay (s->ioc, false); }
@@ -3112,7 +3114,6 @@ static int tcp_chr_add_client(CharDriverState *chr, int fd)if (!sioc) {return -1 ; } -qio_channel_set_blocking (QIO_CHANNEL (sioc), false,NULL ); ret =tcp_chr_new_client (chr, sioc);object_unref (OBJECT (sioc));return ret;
Signature · 1 line
2.5.5
[Qemu-devel] [PULL 08/15] char: fix broken EAGAIN retry on OS-X due to errno clobbering
In reply to Paolo BonziniFrom: "Daniel P. Berrange" <[email protected]>
Some of the chardev I/O paths really want to write the complete data buffer even though the channel is in non-blocking mode. To achieve this they look for EAGAIN and g_usleep() for 100ms. Unfortunately the code is set to check errno == EAGAIN a second time, after the g_usleep() call has completed. On OS-X at least, g_usleep clobbers errno to ETIMEDOUT, causing the retry to be skipped.
This failure to retry means the full data isn't written to the chardev backend, which causes various failures including making the tests/ahci-test qtest hang.
Rather than playing games trying to reset errno just simplify the code to use a goto to retry instead of a a loop.
Message-Id: <[email protected]>
--- qemu-char.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
qemu-char.c +18 -18
@@ -225,12 +225,12 @@ static void qemu_chr_fe_write_log(CharDriverState *s, }while (done < len) { -do { - ret =write (s->logfd, buf + done, len - done); -if (ret ==-1 && errno ==EAGAIN ) { -g_usleep (100 ); - } - }while (ret ==-1 && errno ==EAGAIN ); + retry: + ret =write (s->logfd, buf + done, len - done); +if (ret ==-1 && errno ==EAGAIN ) { +g_usleep (100 ); + goto retry; + }if (ret <=0 ) {return ;
@@ -246,12 +246,12 @@ static int qemu_chr_fe_write_buffer(CharDriverState *s, const uint8_t *buf, intqemu_mutex_lock (&s->chr_write_lock);while (*offset < len) { -do { - res = s->chr_write (s, buf + *offset, len - *offset); -if (res ==-1 && errno ==EAGAIN ) { -g_usleep (100 ); - } - }while (res ==-1 && errno ==EAGAIN ); + retry: + res = s->chr_write (s, buf + *offset, len - *offset); +if (res <0 && errno ==EAGAIN ) { +g_usleep (100 ); + goto retry; + }if (res <=0 ) {break ;
@@ -333,12 +333,12 @@ int qemu_chr_fe_read_all(CharDriverState *s, uint8_t *buf, int len) }while (offset < len) { -do { - res = s->chr_sync_read (s, buf + offset, len - offset); -if (res ==-1 && errno ==EAGAIN ) { -g_usleep (100 ); - } - }while (res ==-1 && errno ==EAGAIN ); + retry: + res = s->chr_sync_read (s, buf + offset, len - offset); +if (res ==-1 && errno ==EAGAIN ) { +g_usleep (100 ); + goto retry; + }if (res ==0 ) {break ;
Signature · 1 line
2.5.5
[Qemu-devel] [PULL 10/15] doc/memory: update MMIO section
In reply to Paolo BonziniFrom: Cao jin <[email protected]>
There is no memory_region_io(). And remove a stray '-'.
Message-Id: <[email protected]>
--- docs/memory.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
docs/memory.txt +2 -2
@@ -37,8 +37,8 @@ MemoryRegion): - MMIO: a range of guest memory that is implemented by host callbacks; each read or write causes a callback to be called on the host. - You initialize these with memory_region_io(), passing it a MemoryRegionOps - structure describing the callbacks. + You initialize these with memory_region_init_io(), passing it a + MemoryRegionOps structure describing the callbacks. - ROM: a ROM memory region works like RAM for reads (directly accessing a region of host memory), but like MMIO for writes (invoking a callback).
Signature · 1 line
2.5.5
Re: [Qemu-devel] [PULL 10/15] doc/memory: update MMIO section
Quoted 17 lines · Paolo Bonzini
From: Cao jin <[email protected]>
There is no
memory_region_io(). And remove a stray '-'.Signed-off-by Cao jin <[email protected]>Message-Id: <[email protected]>
Signed-off-by Paolo Bonzini <[email protected]>--- docs/memory.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)docs/memory.txt +0
-0
docs/memory.txt MemoryRegion): · line 44
Quoted 10 lines
docs/memory.txt +2
-2@@ -37,8 +37,8 @@ MemoryRegion): - MMIO: a range of guest memory that is implemented by host callbacks; each read or write causes a callback to be called on the host. - You initialize these with memory_region_io(), passing it a MemoryRegionOps - structure describing the callbacks. + You initialize these with memory_region_init_io(), passing it a + MemoryRegionOps structure describing the callbacks. - ROM: a ROM memory region works like RAM for reads (directly accessing a region of host memory), but like MMIO for writes (invoking a callback).
Hi Paolo,
Seems the patch ignore the slight modification on that memory
figure, So commit message isn`t consistent with the patch content. And actually I missed to remove a space between 7000 and 8000, since I removed a "-"
Signature · 3 lines
Yours Sincerely, Cao jin
Re: [Qemu-devel] [PULL 10/15] doc/memory: update MMIO section
Quoted 3 lines · Cao jin
Seems the patch ignore the slight modification on that memory figure, So commit message isn`t consistent with the patch content. And actually I missed to remove a space between 7000 and 8000, since I removed a "-"
Oops, I forgot to adjust the commit message---I was about to answer on your message to explain why I removed the second hunk. Here:
0 1000 2000 3000 4000 5000 6000 7000 8000
|------|------|------|------|------|------|------|-------| A: [ ]
C: [CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC]
B: [ ]
It is correct to put 8000 right _after_ the closing bracket, because A ends at 0x7FFF. You can see how C and B are also aligned before the tick at 6000.
Thanks,
Paolo
[Qemu-devel] [PULL 12/15] cpus: don't use atomic_read for vm_clock_warp_start
In reply to Paolo BonziniFrom: Alex Bennée <[email protected]>
As vm_clock_warp_start is a 64 bit value this causes problems for the compiler trying to come up with a suitable atomic operation on 32 bit hosts. Because the variable is protected by vm_clock_seqlock, we check its value inside a seqlock critical section.
Message-Id: <[email protected]>
--- cpus.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
cpus.c +9 -1
@@ -338,10 +338,18 @@ static int64_t qemu_icount_round(int64_t count)static void icount_warp_rt (void ) { +unsigned seq; +int64_t warp_start; +/* The icount_warp_timer is rescheduled soon after vm_clock_warp_start * changes from -1 to another value, so the race here is okay. */ -if (atomic_read (&vm_clock_warp_start) ==-1 ) { +do { + seq =seqlock_read_begin (&timers_state.vm_clock_seqlock); + warp_start = vm_clock_warp_start; + }while (seqlock_read_retry (&timers_state.vm_clock_seqlock, seq)); + +if (warp_start ==-1 ) {return ; }
Signature · 1 line
2.5.5
[Qemu-devel] [PULL 07/15] util: retry getaddrinfo if getting EAI_BADFLAGS with AI_V4MAPPED
In reply to Paolo BonziniFrom: "Daniel P. Berrange" <[email protected]>
The FreeBSD header files define the AI_V4MAPPED but its implementation of getaddrinfo() always returns an error when that flag is set. eg
address resolution failed for localhost:9000: Invalid value for ai_flags
There are also reports of the same problem on OS-X 10.6
Since AI_V4MAPPED is not critical functionality, if we get an EAI_BADFLAGS error then just retry without the AI_V4MAPPED flag set. Use a static var to cache this status so we don't have to retry on every single call.
Also remove its use from the test suite since it serves no useful purpose there.
Message-Id: <[email protected]>
--- tests/test-io-channel-socket.c | 5 +---- util/qemu-sockets.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-)
tests/test-io-channel-socket.c +1 -4
@@ -27,9 +27,6 @@#ifndef AI_ADDRCONFIG # define AI_ADDRCONFIG 0#endif -#ifndef AI_V4MAPPED -# define AI_V4MAPPED 0 -#endif #ifndef EAI_ADDRFAMILY # define EAI_ADDRFAMILY 0#endif
@@ -42,7 +39,7 @@ static int check_bind(const char *hostname, bool *has_proto)int ret =-1 ;memset (&ai,0 ,sizeof (ai)); - ai.ai_flags =AI_CANONNAME |AI_V4MAPPED |AI_ADDRCONFIG ; + ai.ai_flags =AI_CANONNAME |AI_ADDRCONFIG ; ai.ai_family =AF_UNSPEC ; ai.ai_socktype =SOCK_STREAM ;
util/qemu-sockets.c +18 -1
@@ -29,6 +29,7 @@#ifndef AI_ADDRCONFIG # define AI_ADDRCONFIG 0#endif +#ifndef AI_V4MAPPED # define AI_V4MAPPED 0#endif
@@ -354,10 +355,14 @@ static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr,struct addrinfo ai, *res;int rc;Error *err =NULL ; +static int useV4Mapped =1 ;memset (&ai,0 ,sizeof (ai)); - ai.ai_flags =AI_CANONNAME |AI_V4MAPPED |AI_ADDRCONFIG ; + ai.ai_flags =AI_CANONNAME |AI_ADDRCONFIG ; +if (atomic_read (&useV4Mapped)) { + ai.ai_flags |=AI_V4MAPPED ; + } ai.ai_family =inet_ai_family_from_address (saddr, &err); ai.ai_socktype =SOCK_STREAM ;
@@ -373,6 +378,18 @@ static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr,/* lookup */ rc =getaddrinfo (saddr->host, saddr->port, &ai, &res); + +/* At least FreeBSD and OS-X 10.6 declare AI_V4MAPPED but +* then don't implement it in their getaddrinfo(). Detect +* this and retry without the flag since that's preferrable +* to a fatal error +*/ +if (rc ==EAI_BADFLAGS && + (ai.ai_flags &AI_V4MAPPED )) { +atomic_set (&useV4Mapped,0 ); + ai.ai_flags &= ~AI_V4MAPPED ; + rc =getaddrinfo (saddr->host, saddr->port, &ai, &res); + }if (rc !=0 ) {error_setg (errp,"address resolution failed for %s:%s: %s" , saddr->host, saddr->port,gai_strerror (rc));
Signature · 1 line
2.5.5
[Qemu-devel] [PULL 11/15] nbd: don't request FUA on FLUSH
In reply to Paolo BonziniFrom: Eric Blake <[email protected]>
The NBD protocol does not clearly document what will happen if a client sends NBD_CMD_FLAG_FUA on NBD_CMD_FLUSH. Historically, both the qemu and upstream NBD servers silently ignored that flag, but that feels a bit risky. Meanwhile, the qemu NBD client unconditionally sends the flag (without even bothering to check whether the caller cares; at least with NBD_CMD_WRITE the client only sends FUA if requested by a higher layer).
There is ongoing discussion on the NBD list to fix the protocol documentation to require that the server MUST ignore the flag (unless the kernel folks can better explain what FUA means for a flush), but until those doc improvements land, the current nbd.git master was recently changed to reject the flag with EINVAL (see nbd commit ab22e082), which now makes it impossible for a qemu client to use FLUSH with an upstream NBD server.
We should not send FUA with flush unless the upstream protocol documents what it will do, and even then, it should be something that the caller can opt into, rather than being unconditional.
Message-Id: <[email protected]>
--- block/nbd-client.c | 4 ---- 1 file changed, 4 deletions(-)
block/nbd-client.c +0 -4
@@ -319,10 +319,6 @@ int nbd_client_co_flush(BlockDriverState *bs)return 0 ; } -if (client->nbdflags &NBD_FLAG_SEND_FUA ) { - request.type |=NBD_CMD_FLAG_FUA ; - } - request.from =0 ; request.len =0 ;
Signature · 1 line
2.5.5
[Qemu-devel] [PULL 13/15] include/qemu/atomic: add compile time asserts
In reply to Paolo BonziniFrom: Alex Bennée <[email protected]>
To be safely portable no atomic access should be trying to do more than the natural word width of the host. The most common abuse is trying to atomically access 64 bit values on a 32 bit host.
This patch adds some QEMU_BUILD_BUG_ON to the __atomic instrinsic paths to create a build failure if (sizeof(*ptr) > sizeof(void *)).
Message-Id: <[email protected]>
--- include/qemu/atomic.h | 58 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 24 deletions(-)
include/qemu/atomic.h +34 -24
@@ -42,30 +42,34 @@* loads/stores past the atomic operation load/store. However there is * no explicit memory barrier for the processor. */ -#define atomic_read (ptr) \ - ({ \ - typeof(*ptr) _val; \ - __atomic_load(ptr, &_val, __ATOMIC_RELAXED); \ - _val; \ +#define atomic_read (ptr) \ + ({ \ + QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ + typeof(*ptr) _val; \ + __atomic_load(ptr, &_val, __ATOMIC_RELAXED); \ + _val; \ }) -#define atomic_set (ptr, i) do { \ - typeof(*ptr) _val = (i); \ - __atomic_store(ptr, &_val, __ATOMIC_RELAXED); \ +#define atomic_set (ptr, i) do { \ + QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ + typeof(*ptr) _val = (i); \ + __atomic_store(ptr, &_val, __ATOMIC_RELAXED); \ } while(0)/* Atomic RCU operations imply weak memory barriers */ -#define atomic_rcu_read (ptr) \ - ({ \ - typeof(*ptr) _val; \ - __atomic_load(ptr, &_val, __ATOMIC_CONSUME); \ - _val; \ +#define atomic_rcu_read (ptr) \ + ({ \ + QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ + typeof(*ptr) _val; \ + __atomic_load(ptr, &_val, __ATOMIC_CONSUME); \ + _val; \ }) -#define atomic_rcu_set (ptr, i) do { \ - typeof(*ptr) _val = (i); \ - __atomic_store(ptr, &_val, __ATOMIC_RELEASE); \ +#define atomic_rcu_set (ptr, i) do { \ + QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ + typeof(*ptr) _val = (i); \ + __atomic_store(ptr, &_val, __ATOMIC_RELEASE); \ } while(0)/* atomic_mb_read/set semantics map Java volatile variables. They are
@@ -79,6 +83,7 @@#if defined(_ARCH_PPC)#define atomic_mb_read (ptr) \ ({ \ + QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ typeof(*ptr) _val; \ __atomic_load(ptr, &_val, __ATOMIC_RELAXED); \ smp_rmb(); \
@@ -86,22 +91,25 @@ })#define atomic_mb_set (ptr, i) do { \ + QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ typeof(*ptr) _val = (i); \ smp_wmb(); \ __atomic_store(ptr, &_val, __ATOMIC_RELAXED); \ smp_mb(); \ } while(0)#else -#define atomic_mb_read (ptr) \ - ({ \ - typeof(*ptr) _val; \ - __atomic_load(ptr, &_val, __ATOMIC_SEQ_CST); \ - _val; \ +#define atomic_mb_read (ptr) \ + ({ \ + QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ + typeof(*ptr) _val; \ + __atomic_load(ptr, &_val, __ATOMIC_SEQ_CST); \ + _val; \ }) -#define atomic_mb_set (ptr, i) do { \ - typeof(*ptr) _val = (i); \ - __atomic_store(ptr, &_val, __ATOMIC_SEQ_CST); \ +#define atomic_mb_set (ptr, i) do { \ + QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ + typeof(*ptr) _val = (i); \ + __atomic_store(ptr, &_val, __ATOMIC_SEQ_CST); \ } while(0)#endif
@@ -109,6 +117,7 @@/* All the remaining operations are fully sequentially consistent */ #define atomic_xchg (ptr, i) ({ \ + QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ typeof(*ptr) _new = (i), _old; \ __atomic_exchange(ptr, &_new, &_old, __ATOMIC_SEQ_CST); \ _old; \
@@ -117,6 +126,7 @@/* Returns the eventual value, failed or not */ #define atomic_cmpxchg (ptr, old, new) \ ({ \ + QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ typeof(*ptr) _old = (old), _new = (new); \ __atomic_compare_exchange(ptr, &_old, &_new, false, \ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \
Signature · 1 line
2.5.5
[Qemu-devel] [PULL 14/15] nbd: Fix poor debug message
In reply to Paolo BonziniFrom: Eric Blake <[email protected]>
The client sends messages to the server, not itself.
Message-Id: <[email protected]>
--- nbd/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
nbd/client.c +1 -1
@@ -634,7 +634,7 @@ ssize_t nbd_send_request(QIOChannel *ioc, struct nbd_request *request)cpu_to_be64w ((uint64_t *)(buf +16 ), request->from);cpu_to_be32w ((uint32_t *)(buf +24 ), request->len); -TRACE ("Sending request to client: " +TRACE ("Sending request to server: " "{ .from = %" PRIu64", .len = %u, .handle = %" PRIu64", .type=%i}" , request->from, request->len, request->handle, request->type);
Signature · 1 line
2.5.5
[Qemu-devel] [PULL 15/15] net: fix missing include of qapi/error.h in netmap.c
In reply to Paolo BonziniFrom: "Daniel P. Berrange" <[email protected]>
The netmap.c file fails to build on FreeBSD with
net/netmap.c:95:9: warning: implicit declaration of function 'error_setg_errno' is invalid in C99 [-Wimplicit-function-declaration]
error_setg_errno(errp, errno, "Failed to nm_open() %s",
^net/netmap.c:432:9: warning: implicit declaration of function 'error_propagate' is invalid in C99 [-Wimplicit-function-declaration]
error_propagate(errp, err);
^Message-Id: <[email protected]>
--- net/netmap.c | 1 + 1 file changed, 1 insertion(+)
net/netmap.c +1 -0
@@ -36,6 +36,7 @@#include "clients.h" #include "sysemu/sysemu.h" #include "qemu/error-report.h" +#include "qapi/error.h" #include "qemu/iov.h" #include "qemu/cutils.h"
Signature · 1 line
2.5.5
Peter Maydell
AppliedQuoted 12 lines · Paolo Bonzini
The following changes since commit
92741fc4b6cbf7a8f6cce45e9a468d5637a4ff6a:Merge remote-tracking branch 'remotes/thibault/tags/samuel-thibault' into staging (2016-03-31 11:52:44 +0100)
are available in the git repository at:
git://github.com/bonzini/qemu.gittags/for-upstreamfor you to fetch changes up to
2354bebaa408b97adf008d3e07f439300b0a5c06:net: fix missing include of
qapi/error.hinnetmap.c(2016-04-05 11:46:52 +0200)
Quoted 9 lines
----------------------------------------------------------------
* FreeBSD build fixes (atomics,qapi/error.h)
* x86 KVM fixes (SynIC, KVM_GET/SET_MSRS)
* Memory API doc fix
* checkpatch fix
* Chardev and socket fixes
* NBD fixes
*exec.cSEGV fix
Applied, thanks.
-- PMM