Re: [Qemu-devel] [PATCHv2] target/ppc, spapr: Move VPA information to machine_data
On Fri, Jun 15, 2018 at 04:00:24PM +0200, Greg Kurz wrote: > On Fri, 15 Jun 2018 22:29:28 +1000 > David Gibson wrote: > > > CPUPPCState currently contains a number of fields containing the state of > > the VPA. The VPA is a PAPR specific concept covering several guest/host > > shared memory areas used to communicate some information with the > > hypervisor. > > > > As a PAPR concept this is really machine specific information, although it > > is per-cpu, so it doesn't really belong in the core CPU state structure. > > > > There's also other information that's per-cpu, but platform/machine > > specific. So create a (void *)machine_data in PowerPCCPU which can be > > used by the machine to locate per-cpu data. Intialization, lifetime and > > cleanup of machine_data is entirely up to the machine type. > > > > Signed-off-by: David Gibson > > --- > > Reviewed-by: Greg Kurz > > and > > Tested-by: Greg Kurz > > (threads=4 with hotplug, both success and error paths) Thanks. I've merged this into ppc-for-3.0 again. > And now I'll look into migrating this *new* state. Great. > > > hw/ppc/spapr_cpu_core.c | 13 ++ > > hw/ppc/spapr_hcall.c| 77 ++--- > > include/hw/ppc/spapr_cpu_core.h | 11 + > > target/ppc/cpu.h| 7 +-- > > target/ppc/kvm.c| 39 + > > target/ppc/translate_init.inc.c | 8 > > 6 files changed, 88 insertions(+), 67 deletions(-) > > > > Changes in v2: > > * Move alloc/free of machine_data to spapr_{create,delete}_vcpu() > >instead of spapr_{,un}realize_vcpu() (fixing a possible leak in the > >process) > > > > diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c > > index 4f0c168784..f416212ae0 100644 > > --- a/hw/ppc/spapr_cpu_core.c > > +++ b/hw/ppc/spapr_cpu_core.c > > @@ -28,6 +28,7 @@ static void spapr_cpu_reset(void *opaque) > > CPUState *cs = CPU(cpu); > > CPUPPCState *env = &cpu->env; > > PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); > > +sPAPRCPUState *spapr_cpu = spapr_cpu_state(cpu); > > target_ulong lpcr; > > > > cpu_reset(cs); > > @@ -69,6 +70,12 @@ static void spapr_cpu_reset(void *opaque) > > > > /* Set a full AMOR so guest can use the AMR as it sees fit */ > > env->spr[SPR_AMOR] = 0xull; > > + > > +spapr_cpu->vpa_addr = 0; > > +spapr_cpu->slb_shadow_addr = 0; > > +spapr_cpu->slb_shadow_size = 0; > > +spapr_cpu->dtl_addr = 0; > > +spapr_cpu->dtl_size = 0; > > } > > > > void spapr_cpu_set_entry_state(PowerPCCPU *cpu, target_ulong nip, > > target_ulong r3) > > @@ -186,6 +193,8 @@ static PowerPCCPU *spapr_create_vcpu(sPAPRCPUCore *sc, > > int i, Error **errp) > > goto err; > > } > > > > +cpu->machine_data = g_new0(sPAPRCPUState, 1); > > + > > object_unref(obj); > > return cpu; > > > > @@ -197,6 +206,10 @@ err: > > > > static void spapr_delete_vcpu(PowerPCCPU *cpu) > > { > > +sPAPRCPUState *spapr_cpu = spapr_cpu_state(cpu); > > + > > +cpu->machine_data = NULL; > > +g_free(spapr_cpu); > > object_unparent(OBJECT(cpu)); > > } > > > > diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c > > index 8b9a4b577f..ae913d070f 100644 > > --- a/hw/ppc/spapr_hcall.c > > +++ b/hw/ppc/spapr_hcall.c > > @@ -8,6 +8,7 @@ > > #include "exec/exec-all.h" > > #include "helper_regs.h" > > #include "hw/ppc/spapr.h" > > +#include "hw/ppc/spapr_cpu_core.h" > > #include "mmu-hash64.h" > > #include "cpu-models.h" > > #include "trace.h" > > @@ -908,9 +909,11 @@ unmap_out: > > #define VPA_SHARED_PROC_OFFSET 0x9 > > #define VPA_SHARED_PROC_VAL0x2 > > > > -static target_ulong register_vpa(CPUPPCState *env, target_ulong vpa) > > +static target_ulong register_vpa(PowerPCCPU *cpu, target_ulong vpa) > > { > > -CPUState *cs = CPU(ppc_env_get_cpu(env)); > > +CPUState *cs = CPU(cpu); > > +CPUPPCState *env = &cpu->env; > > +sPAPRCPUState *spapr_cpu = spapr_cpu_state(cpu); > > uint16_t size; > > uint8_t tmp; > > > > @@ -935,32 +938,34 @@ static target_ulong register_vpa(CPUPPCState *env, > > target_ulong vpa) > > return H_PARAMETER; > > } > > > > -env->vpa_addr = vpa; > > +spapr_cpu->vpa_addr = vpa; > > > > -tmp = ldub_phys(cs->as, env->vpa_addr + VPA_SHARED_PROC_OFFSET); > > +tmp = ldub_phys(cs->as, spapr_cpu->vpa_addr + VPA_SHARED_PROC_OFFSET); > > tmp |= VPA_SHARED_PROC_VAL; > > -stb_phys(cs->as, env->vpa_addr + VPA_SHARED_PROC_OFFSET, tmp); > > +stb_phys(cs->as, spapr_cpu->vpa_addr + VPA_SHARED_PROC_OFFSET, tmp); > > > > return H_SUCCESS; > > } > > > > -static target_ulong deregister_vpa(CPUPPCState *env, target_ulong vpa) > > +static target_ulong deregister_vpa(PowerPCCPU *cpu, target_ulong vpa) > > { > > -if (env->slb_shadow_addr) { > > +sPAPRCPUState *spapr_cpu = spapr_cpu_state(cpu); > > + > > +if (spapr_cpu->slb_sha
Re: [Qemu-devel] [PATCH 3/5] spapr_cpu_core: add missing rollback on realization path
On Fri, Jun 15, 2018 at 03:24:18PM +0200, Greg Kurz wrote: > On Fri, 15 Jun 2018 22:32:44 +1000 > David Gibson wrote: > > > On Fri, Jun 15, 2018 at 10:01:47AM +0200, Greg Kurz wrote: > > > On Fri, 15 Jun 2018 09:07:24 +0200 > > > Greg Kurz wrote: > > > > > > > On Fri, 15 Jun 2018 16:29:15 +1000 > > > > David Gibson wrote: > > > > > > > > > On Fri, Jun 15, 2018 at 07:58:05AM +0200, Greg Kurz wrote: > > > > > > On Fri, 15 Jun 2018 10:14:31 +1000 > > > > > > David Gibson wrote: > > > > > > > > > > > > > On Fri, Jun 15, 2018 at 10:02:25AM +1000, David Gibson wrote: > > > > > > > > > > > > > > > On Thu, Jun 14, 2018 at 11:50:42PM +0200, Greg Kurz wrote: > > > > > > > > > > > > > > > > > The spapr_realize_vcpu() function doesn't rollback in case of > > > > > > > > > error. > > > > > > > > > This isn't a problem with coldplugged CPUs because the > > > > > > > > > machine won't > > > > > > > > > start and QEMU will exit. Hotplug is a different story > > > > > > > > > though: the > > > > > > > > > CPU thread is started under object_property_set_bool() and it > > > > > > > > > assumes > > > > > > > > > it can access the CPU object. > > > > > > > > > > > > > > > > > > If icp_create() fails, we return an error without > > > > > > > > > unregistering the > > > > > > > > > reset handler for this CPU, and we let the underlying QEMU > > > > > > > > > thread for > > > > > > > > > this CPU alive. Since spapr_cpu_core_realize() doesn't care > > > > > > > > > to unrealize > > > > > > > > > already realized CPUs either, but happily frees all of them > > > > > > > > > anyway, the > > > > > > > > > CPU thread crashes instantly: > > > > > > > > > > > > > > > > > > (qemu) device_add host-spapr-cpu-core,core-id=1,id=gku > > > > > > > > > GKU: failing icp_create (cpu 0x11497fd0) > > > > > > > > > ^^ > > > > > > > > > Program received signal SIGSEGV, Segmentation fault. > > > > > > > > > [Switching to Thread 0x7fffee3feaa0 (LWP 24725)] > > > > > > > > > 0x104c8374 in object_dynamic_cast_assert > > > > > > > > > (obj=0x11497fd0, > > > > > > > > > > > > > > > > > > ^^ > > > > > > > > > pointer to the > > > > > > > > > CPU object > > > > > > > > > 623 trace_object_dynamic_cast_assert(obj ? > > > > > > > > > obj->class->type->name > > > > > > > > > (gdb) p obj->class->type > > > > > > > > > $1 = (Type) 0x0 > > > > > > > > > (gdb) p * obj > > > > > > > > > $2 = {class = 0x10ea9c10, free = 0x11244620, > > > > > > > > > ^^ > > > > > > > > > should be g_free > > > > > > > > > (gdb) p g_free > > > > > > > > > $3 = {} 0x7282bef0 > > > > > > > > > > > > > > > > > > obj is a dangling pointer to the CPU that was just destroyed > > > > > > > > > in > > > > > > > > > spapr_cpu_core_realize(). > > > > > > > > > > > > > > > > > > This patch adds proper rollback to both spapr_realize_vcpu() > > > > > > > > > and > > > > > > > > > spapr_cpu_core_realize(). > > > > > > > > > > > > > > > > > > Signed-off-by: Greg Kurz > > > > > > > > > > > > > > > > Applied to ppc-for-3.0, since it definitely looks to fix some > > > > > > > > problems. > > > > > > > > > > > > > > Uh.. actually it has a definite bug - the first exit point will > > > > > > > call > > > > > > > g_free() on an uninitialized spapr_cpu. I fixed it up with a NULL > > > > > > > initialization in my tree. > > > > > > > > > > > > Ah... as said in the cover letter, all the series is based on > > > > > > machine_data > > > > > > being set before the call to object_property_set_bool()... Maybe I > > > > > > should > > > > > > have made that explicit with a preparatory patch... Sorry. > > > > > > > > > > Ah, that makes sense. > > > > > > > > > > So, I ended up having to rework a little differently, after I yanked > > > > > by intc -> machine_data patch because it broke things for clg. I > > > > > think I've fixed it up correctly now - if you can check the latest > > > > > ppc-for-3.0 I pushed out, that would be great. > > > > > > > > > > > > > I'll do this ASAP. > > > > > > Oops, I've just spotted a nit in my original patch, that causes > > > QEMU to crash if threads > 1... but I had only tested with single > > > threaded cores :) > > > > > > > > > +err_unrealize: > > > > +while (--j >= 0) { > > > > +spapr_unrealize_vcpu(sc->threads[i]); > > >^^^ > > >should be j > > > > Ah, yes. I've fixed that up in my tree. > > > > +spapr_unrealize_vcpu(sc->threads[j); > > Almost fixed ;) Oops, fixed now. > > > > > > > > > Appart from that, it looks good. > > > > > > > -- David Gibson| I'll have my music baroque, and my code davi
Re: [Qemu-devel] [PATCH] hw/isa/smc37c669: Change the parallel I/O base to 378H
On 06/14/2018 01:39 PM, Philippe Mathieu-Daudé wrote: > On the Alpha DP264 machine, the Cirrus VGA is I/O mapped > in the 3C0H-3CFH range, thus I/O base used by the parallel > device clashes, and since a4cb773928e the VGA is not > working: > > (qemu) info mtree > address-space: memory > - (prio 0, i/o): system > 0801fc00-0801fdff (prio 0, i/o): pci0-io > ... > 0801fc0003b4-0801fc0003b5 (prio 0, i/o): vga > 0801fc0003ba-0801fc0003ba (prio 0, i/o): vga > 0801fc0003bc-0801fc0003c3 (prio 0, i/o): parallel > ^^^ > 0801fc0003c0-0801fc0003cf (prio 0, i/o): vga >^^^ > 0801fc0003d4-0801fc0003d5 (prio 0, i/o): vga > 0801fc0003da-0801fc0003da (prio 0, i/o): vga > ... > > As there is no particular reason to use this base address > (introduced in 7bea0dd434e), change to 378H which is the > default on PC machines. > > Reported-by: Emilio G. Cota > Suggested-by: Paolo Bonzini > Signed-off-by: Philippe Mathieu-Daudé > --- > RFC: http://lists.nongnu.org/archive/html/qemu-devel/2018-06/msg04011.html > > hw/isa/smc37c669-superio.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Queued to tgt-axp. r~
Re: [Qemu-devel] [RFC PATCH v4 1/1] SPARC64: add icount support
On 06/14/2018 09:33 PM, Mark Cave-Ayland wrote: > This patch adds gen_io_start()/gen_io_end() to various instructions as > required > in order to boot my OpenBIOS test images on qemu-system-sparc64 with icount > enabled. > > Signed-off-by: Mark Cave-Ayland > --- > target/sparc/translate.c | 111 > ++- > 1 file changed, 110 insertions(+), 1 deletion(-) Reviewed-by: Richard Henderson r~
Re: [Qemu-devel] [PATCH] target/arm: Allow ARMv6-M Thumb2 instructions
On 06/15/2018 12:55 AM, Peter Maydell wrote: >> +uint32_t armv6m_insn[] = {0xf3808000 /* msr */, 0xf3b08040 /* dsb */, >> + 0xf3b08050 /* dmb */, 0xf3b08060 /* isb */, >> + 0xf3e08000 /* mrs */, 0xf000d000 /* bl */}; >> +uint32_t armv6m_mask[] = {0xffe0d000, 0xfff0d0f0, 0xfff0d0f0, >> + 0xfff0d0f0, 0xffe0d000, 0xf800d000}; > I think these arrays should be 'const'; we can also move them closer > to their point of use, inside the scope of the if() below. static as well. r~
[Qemu-devel] [Bug 1777293] [NEW] [REQUEST[ SHARING MEMORY WITH HOST
Public bug reported: Instead of a preallocated memory heap I would like for QEMU to share memory using shm. Example: Instead of using 16gb out of 32gb of ram to run Windows 10, there would be no option to allocate it, but to share the hosts resources; ie giving the host full access to the entire ram stack I'm not a great programmer but I'm pretty sure QEMU's team could find this useful ** Affects: qemu Importance: Undecided Status: New -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1777293 Title: [REQUEST[ SHARING MEMORY WITH HOST Status in QEMU: New Bug description: Instead of a preallocated memory heap I would like for QEMU to share memory using shm. Example: Instead of using 16gb out of 32gb of ram to run Windows 10, there would be no option to allocate it, but to share the hosts resources; ie giving the host full access to the entire ram stack I'm not a great programmer but I'm pretty sure QEMU's team could find this useful To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1777293/+subscriptions
[Qemu-devel] [PATCH v3 11/13] 9p: darwin: Implement compatibility for mknodat
Darwin does not support mknodat. However, to avoid race conditions with later setting the permissions, we must avoid using mknod on the full path instead. We could try to fchdir, but that would cause problems if multiple threads try to call mknodat at the same time. However, luckily there is a solution: Darwin as an (unexposed in the C library) system call that sets the cwd for the current thread only. This should suffice to use mknod safely. Signed-off-by: Keno Fischer --- Changes since v2: - Silence clang warning for deprecated uses of `syscall`. It is unforunate that we have to use this depreacted interface, but there does not seem to be a better option. hw/9pfs/9p-local.c | 5 +++-- hw/9pfs/9p-util-darwin.c | 31 +++ hw/9pfs/9p-util-linux.c | 5 + hw/9pfs/9p-util.h| 2 ++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 56bcabf..450f31c 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -668,7 +668,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, if (fs_ctx->export_flags & V9FS_SM_MAPPED || fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { -err = mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); +err = qemu_mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); if (err == -1) { goto out; } @@ -683,7 +683,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, } } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || fs_ctx->export_flags & V9FS_SM_NONE) { -err = mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); +err = qemu_mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); if (err == -1) { goto out; } @@ -696,6 +696,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, err_end: unlinkat_preserve_errno(dirfd, name, 0); + out: close_preserve_errno(dirfd); return err; diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index ac414bc..194f068 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -158,3 +158,34 @@ done: close_preserve_errno(fd); return ret; } + +#ifndef SYS___pthread_fchdir +# define SYS___pthread_fchdir 349 +#endif + +// This is an undocumented OS X syscall. It would be best to avoid it, +// but there doesn't seem to be another safe way to implement mknodat. +// Dear Apple, please implement mknodat before you remove this syscall. +static int fchdir_thread_local(int fd) +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +return syscall(SYS___pthread_fchdir, fd); +#pragma clang diagnostic pop +} + +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ +int preserved_errno, err; +if (fchdir_thread_local(dirfd) < 0) { +return -1; +} +err = mknod(filename, mode, dev); +preserved_errno = errno; +/* Stop using the thread-local cwd */ +fchdir_thread_local(-1); +if (err < 0) { +errno = preserved_errno; +} +return err; +} diff --git a/hw/9pfs/9p-util-linux.c b/hw/9pfs/9p-util-linux.c index 3902378..06399c5 100644 --- a/hw/9pfs/9p-util-linux.c +++ b/hw/9pfs/9p-util-linux.c @@ -63,3 +63,8 @@ int utimensat_nofollow(int dirfd, const char *filename, { return utimensat(dirfd, filename, times, AT_SYMLINK_NOFOLLOW); } + +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ +return mknodat(dirfd, filename, mode, dev); +} diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index b1dc08a..127564d 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -90,4 +90,6 @@ ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, int utimensat_nofollow(int dirfd, const char *filename, const struct timespec times[2]); +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev); + #endif -- 2.8.1
[Qemu-devel] [PATCH v3 12/13] 9p: darwin: virtfs-proxy: Implement setuid code for darwin
Darwin does not have linux capabilities, so make that code linux-only. Darwin also does not have setresuid/gid. The correct way to temporarily drop capabilities is to call seteuid/gid. Also factor out the code that acquires acquire_dac_override into a separate function in the linux implementation. I had originally done this when I thought it made sense to have only one `setugid` function, but I retained this because it seems clearer this way. Signed-off-by: Keno Fischer --- fsdev/virtfs-proxy-helper.c | 200 +++- 1 file changed, 125 insertions(+), 75 deletions(-) diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index d8dd3f5..6baf2a6 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -82,6 +82,7 @@ static void do_perror(const char *string) } } +#ifdef CONFIG_LINUX static int do_cap_set(cap_value_t *cap_value, int size, int reset) { cap_t caps; @@ -121,6 +122,85 @@ error: return -1; } +static int acquire_dac_override(void) +{ +cap_value_t cap_list[] = { +CAP_DAC_OVERRIDE, +}; +return do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0); +} + +/* + * from man 7 capabilities, section + * Effect of User ID Changes on Capabilities: + * If the effective user ID is changed from nonzero to 0, then the permitted + * set is copied to the effective set. If the effective user ID is changed + * from 0 to nonzero, then all capabilities are are cleared from the effective + * set. + * + * The setfsuid/setfsgid man pages warn that changing the effective user ID may + * expose the program to unwanted signals, but this is not true anymore: for an + * unprivileged (without CAP_KILL) program to send a signal, the real or + * effective user ID of the sending process must equal the real or saved user + * ID of the target process. Even when dropping privileges, it is enough to + * keep the saved UID to a "privileged" value and virtfs-proxy-helper won't + * be exposed to signals. So just use setresuid/setresgid. + */ +static int setugid(int uid, int gid, int *suid, int *sgid) +{ +int retval; + +*suid = geteuid(); +*sgid = getegid(); + +if (setresgid(-1, gid, *sgid) == -1) { +retval = -errno; +goto err_out; +} + +if (setresuid(-1, uid, *suid) == -1) { +retval = -errno; +goto err_sgid; +} + +if (uid != 0 || gid != 0) { +/* +* We still need DAC_OVERRIDE because we don't change +* supplementary group ids, and hence may be subjected DAC rules +*/ +if (acquire_dac_override() < 0) { +retval = -errno; +goto err_suid; +} +} +return 0; + +err_suid: +if (setresuid(-1, *suid, *suid) == -1) { +abort(); +} +err_sgid: +if (setresgid(-1, *sgid, *sgid) == -1) { +abort(); +} +err_out: +return retval; +} + +/* + * This is used to reset the ugid back with the saved values + * There is nothing much we can do checking error values here. + */ +static void resetugid(int suid, int sgid) +{ +if (setresgid(-1, sgid, sgid) == -1) { +abort(); +} +if (setresuid(-1, suid, suid) == -1) { +abort(); +} +} + static int init_capabilities(void) { /* helper needs following capabilities only */ @@ -135,6 +215,51 @@ static int init_capabilities(void) }; return do_cap_set(cap_list, ARRAY_SIZE(cap_list), 1); } +#else +static int setugid(int uid, int gid, int *suid, int *sgid) +{ +int retval; + +*suid = geteuid(); +*sgid = getegid(); + +if (setegid(gid) == -1) { +retval = -errno; +goto err_out; +} + +if (seteuid(uid) == -1) { +retval = -errno; +goto err_sgid; +} + +err_sgid: +if (setgid(*sgid) == -1) { +abort(); +} +err_out: +return retval; +} + +/* + * This is used to reset the ugid back with the saved values + * There is nothing much we can do checking error values here. + */ +static void resetugid(int suid, int sgid) +{ +if (setegid(sgid) == -1) { +abort(); +} +if (seteuid(suid) == -1) { +abort(); +} +} + +static int init_capabilities(void) +{ +return 0; +} +#endif static int socket_read(int sockfd, void *buff, ssize_t size) { @@ -279,81 +404,6 @@ static int send_status(int sockfd, struct iovec *iovec, int status) } /* - * from man 7 capabilities, section - * Effect of User ID Changes on Capabilities: - * If the effective user ID is changed from nonzero to 0, then the permitted - * set is copied to the effective set. If the effective user ID is changed - * from 0 to nonzero, then all capabilities are are cleared from the effective - * set. - * - * The setfsuid/setfsgid man pages warn that changing the effective user ID may - * expose the program to unwanted signals, but this is not true anymore: for an - * unprivileged (without CAP_KILL) program to send a signal, the real or - * effective u
[Qemu-devel] [PATCH v3 13/13] 9p: darwin: configure: Allow VirtFS on Darwin
Signed-off-by: Keno Fischer --- Makefile.objs | 1 + configure | 22 +++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Makefile.objs b/Makefile.objs index 7a9828d..c968a9a 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -104,6 +104,7 @@ common-obj-$(CONFIG_WIN32) += os-win32.o common-obj-$(CONFIG_POSIX) += os-posix.o common-obj-$(CONFIG_LINUX) += fsdev/ +common-obj-$(CONFIG_DARWIN) += fsdev/ common-obj-y += migration/ diff --git a/configure b/configure index 195c9bd..74f593a 100755 --- a/configure +++ b/configure @@ -5568,16 +5568,28 @@ if test "$want_tools" = "yes" ; then fi fi if test "$softmmu" = yes ; then - if test "$linux" = yes; then -if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then + if test "$virtfs" != no; then +if test "$linux" = yes; then + if test "$cap" = yes && test "$attr" = yes ; then +virtfs=yes +tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)" + else +if test "$virtfs" = yes; then + error_exit "VirtFS requires libcap devel and libattr devel under Linux" +fi +virtfs=no + fi +elif test "$darwin" = yes; then virtfs=yes tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)" else if test "$virtfs" = yes; then -error_exit "VirtFS requires libcap devel and libattr devel" +error_exit "VirtFS is supported only on Linux and Darwin" fi virtfs=no fi + fi + if test "$linux" = yes; then if test "$mpath" != no && test "$mpathpersist" = yes ; then mpath=yes else @@ -5588,10 +5600,6 @@ if test "$softmmu" = yes ; then fi tools="$tools scsi/qemu-pr-helper\$(EXESUF)" else -if test "$virtfs" = yes; then - error_exit "VirtFS is supported only on Linux" -fi -virtfs=no if test "$mpath" = yes; then error_exit "Multipath is supported only on Linux" fi -- 2.8.1
[Qemu-devel] [PATCH v3 04/13] 9p: darwin: Handle struct dirent differences
On darwin d_seekoff exists, but is optional and does not seem to be commonly used by file systems. Use `telldir` instead to obtain the seek offset. Signed-off-by: Keno Fischer --- hw/9pfs/9p-synth.c | 2 ++ hw/9pfs/9p.c | 36 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index eb68b42..a312f8c 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -221,7 +221,9 @@ static void synth_direntry(V9fsSynthNode *node, { strcpy(entry->d_name, node->name); entry->d_ino = node->attr->inode; +#ifndef CONFIG_DARWIN entry->d_off = off + 1; +#endif } static struct dirent *synth_get_dentry(V9fsSynthNode *dir, diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 8e6b908..06139c9 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1738,6 +1738,25 @@ static int v9fs_xattr_read(V9fsState *s, V9fsPDU *pdu, V9fsFidState *fidp, return offset; } +/** + * Get the seek offset of a dirent. If not available from the structure itself, + * obtain it by calling telldir. + */ +static int v9fs_dent_telldir(V9fsPDU *pdu, V9fsFidState *fidp, + struct dirent *dent) +{ +#ifdef CONFIG_DARWIN +/* + * Darwin has d_seekoff, which appears to function similarly to d_off. + * However, it does not appear to be supported on all file systems, + * so use telldir for correctness. + */ +return v9fs_co_telldir(pdu, fidp); +#else +return dent->d_off; +#endif +} + static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu, V9fsFidState *fidp, uint32_t max_count) @@ -1801,7 +1820,11 @@ static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu, count += len; v9fs_stat_free(&v9stat); v9fs_path_free(&path); -saved_dir_pos = dent->d_off; +saved_dir_pos = v9fs_dent_telldir(pdu, fidp, dent); +if (saved_dir_pos < 0) { +err = saved_dir_pos; +break; +} } v9fs_readdir_unlock(&fidp->fs.dir); @@ -1915,7 +1938,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString name; int len, err = 0; int32_t count = 0; -off_t saved_dir_pos; +off_t saved_dir_pos, off; struct dirent *dent; /* save the directory position */ @@ -1951,10 +1974,15 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, /* Fill the other fields with dummy values */ qid.type = 0; qid.version = 0; +off = v9fs_dent_telldir(pdu, fidp, dent); +if (off < 0) { +err = off; +break; +} /* 11 = 7 + 4 (7 = start offset, 4 = space for storing count) */ len = pdu_marshal(pdu, 11 + count, "Qqbs", - &qid, dent->d_off, + &qid, off, dent->d_type, &name); v9fs_readdir_unlock(&fidp->fs.dir); @@ -1966,7 +1994,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, } count += len; v9fs_string_free(&name); -saved_dir_pos = dent->d_off; +saved_dir_pos = off; } v9fs_readdir_unlock(&fidp->fs.dir); -- 2.8.1
[Qemu-devel] [PATCH v3 10/13] 9p: darwin: Provide a fallback implementation for utimensat
This function is new in Mac OS 10.13. Provide a fallback implementation when building against older SDKs. The complication in the definition comes having to separately handle the used SDK version and the target OS version. - If the SDK version is too low (__MAC_10_13 not defined), utimensat is not defined in the header, so we must not try to use it (doing so would error). - Otherwise, if the targetted OS version is at least 10.13, we know this function is available, so we can unconditionally call it. - Lastly, we check for the availability of the __builtin_available macro to potentially insert a dynamic check for this OS version. However, __builtin_available is only available with sufficiently recent versions of clang and while all Apple clang versions that ship with Xcode versions that support the 10.13 SDK support with builtin, we want to allow building with compilers other than Apple clang that may not support this builtin. Signed-off-by: Keno Fischer --- fsdev/virtfs-proxy-helper.c | 3 +- hw/9pfs/9p-local.c | 2 +- hw/9pfs/9p-util-darwin.c| 96 + hw/9pfs/9p-util-linux.c | 6 +++ hw/9pfs/9p-util.h | 8 hw/9pfs/9p.c| 1 + 6 files changed, 113 insertions(+), 3 deletions(-) diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index a26f8b8..d8dd3f5 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -957,8 +957,7 @@ static int process_requests(int sock) &spec[0].tv_sec, &spec[0].tv_nsec, &spec[1].tv_sec, &spec[1].tv_nsec); if (retval > 0) { -retval = utimensat(AT_FDCWD, path.data, spec, - AT_SYMLINK_NOFOLLOW); +retval = utimensat_nofollow(AT_FDCWD, path.data, spec); if (retval < 0) { retval = -errno; } diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 768ef6f..56bcabf 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1071,7 +1071,7 @@ static int local_utimensat(FsContext *s, V9fsPath *fs_path, goto out; } -ret = utimensat(dirfd, name, buf, AT_SYMLINK_NOFOLLOW); +ret = utimensat_nofollow(dirfd, name, buf); close_preserve_errno(dirfd); out: g_free(dirpath); diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index cdb4c9e..ac414bc 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -62,3 +62,99 @@ int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, close_preserve_errno(fd); return ret; } + +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + +static int update_times_from_stat(int fd, struct timespec times[2], + int update0, int update1) +{ +struct stat buf; +int ret = fstat(fd, &buf); +if (ret == -1) { +return ret; +} +if (update0) { +times[0] = buf.st_atimespec; +} +if (update1) { +times[1] = buf.st_mtimespec; +} +return 0; +} + +int utimensat_nofollow(int dirfd, const char *filename, + const struct timespec times_in[2]) +{ +int ret, fd; +int special0, special1; +struct timeval futimes_buf[2]; +struct timespec times[2]; +memcpy(times, times_in, 2 * sizeof(struct timespec)); + +/* Check whether we have an SDK version that defines utimensat */ +#if defined(__MAC_10_13) +# if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_13 +# define UTIMENSAT_AVAILABLE 1 +# elif __has_builtin(__builtin_available) +# define UTIMENSAT_AVAILABLE __builtin_available(macos 10.13, *) +# else +# define UTIMENSAT_AVAILABLE 0 +# endif +if (UTIMENSAT_AVAILABLE) { +return utimensat(dirfd, filename, times, AT_SYMLINK_NOFOLLOW); +} +#endif + +/* utimensat not available. Use futimes. */ +fd = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); +if (fd == -1) { +return -1; +} + +special0 = times[0].tv_nsec == UTIME_OMIT; +special1 = times[1].tv_nsec == UTIME_OMIT; +if (special0 || special1) { +/* If both are set, nothing to do */ +if (special0 && special1) { +ret = 0; +goto done; +} + +ret = update_times_from_stat(fd, times, special0, special1); +if (ret < 0) { +goto done; +} +} + +special0 = times[0].tv_nsec == UTIME_NOW; +special1 = times[1].tv_nsec == UTIME_NOW; +if (special0 || special1) { +ret = futimes(fd, NULL); +if (ret < 0) { +goto done; +} + +/* If both are set, we are done */ +if (special0 && special1) { +ret = 0; +goto done; +} + +ret = update_times_from_stat(fd, times, special0, special1); +if (ret < 0) { +goto done; +} +
[Qemu-devel] [PATCH v3 08/13] 9p: darwin: *xattr_nofollow implementations
This implements the darwin equivalent of the functions that were moved to 9p-util(-linux) earlier in this series in the new 9p-util-darwin file. Signed-off-by: Keno Fischer --- hw/9pfs/9p-util-darwin.c | 64 hw/9pfs/Makefile.objs| 1 + 2 files changed, 65 insertions(+) create mode 100644 hw/9pfs/9p-util-darwin.c diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c new file mode 100644 index 000..cdb4c9e --- /dev/null +++ b/hw/9pfs/9p-util-darwin.c @@ -0,0 +1,64 @@ +/* + * 9p utilities (Darwin Implementation) + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/xattr.h" +#include "9p-util.h" + +ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name, + void *value, size_t size) +{ +int ret; +int fd = openat_file(dirfd, filename, + O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); +if (fd == -1) { +return -1; +} +ret = fgetxattr(fd, name, value, size, 0, 0); +close_preserve_errno(fd); +return ret; +} + +ssize_t flistxattrat_nofollow(int dirfd, const char *filename, + char *list, size_t size) +{ +int ret; +int fd = openat_file(dirfd, filename, + O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); +if (fd == -1) { +return -1; +} +ret = flistxattr(fd, list, size, 0); +close_preserve_errno(fd); +return ret; +} + +ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, +const char *name) +{ +int ret; +int fd = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); +if (fd == -1) { +return -1; +} +ret = fremovexattr(fd, name, 0); +close_preserve_errno(fd); +return ret; +} + +int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, + void *value, size_t size, int flags) +{ +int ret; +int fd = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); +if (fd == -1) { +return -1; +} +ret = fsetxattr(fd, name, value, size, 0, flags); +close_preserve_errno(fd); +return ret; +} diff --git a/hw/9pfs/Makefile.objs b/hw/9pfs/Makefile.objs index 95e3bc0..0de39af 100644 --- a/hw/9pfs/Makefile.objs +++ b/hw/9pfs/Makefile.objs @@ -1,6 +1,7 @@ ifeq ($(call lor,$(CONFIG_VIRTIO_9P),$(CONFIG_XEN)),y) common-obj-y = 9p.o common-obj-$(CONFIG_LINUX) += 9p-util-linux.o +common-obj-$(CONFIG_DARWIN) += 9p-util-darwin.o common-obj-y += 9p-local.o 9p-xattr.o common-obj-y += 9p-xattr-user.o 9p-posix-acl.o common-obj-y += coth.o cofs.o codir.o cofile.o -- 2.8.1
[Qemu-devel] [PATCH v3 09/13] 9p: darwin: Compatibility for f/l*xattr
On darwin `fgetxattr` takes two extra optional arguments, and the l* variants are not defined (in favor of an extra flag to the regular variants. Signed-off-by: Keno Fischer --- Makefile| 6 ++ fsdev/virtfs-proxy-helper.c | 9 + hw/9pfs/9p-local.c | 12 hw/9pfs/9p-util.h | 17 + 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index e46f2b6..046e553 100644 --- a/Makefile +++ b/Makefile @@ -545,7 +545,13 @@ qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS) qemu-keymap$(EXESUF): qemu-keymap.o ui/input-keymap.o $(COMMON_LDADDS) fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o $(COMMON_LDADDS) +ifdef CONFIG_DARWIN +fsdev/virtfs-proxy-helper$(EXESUF): hw/9pfs/9p-util-darwin.o +endif +ifdef CONFIG_LINUX +fsdev/virtfs-proxy-helper$(EXESUF): hw/9pfs/9p-util-linux.o fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap +endif scsi/qemu-pr-helper$(EXESUF): scsi/qemu-pr-helper.o scsi/utils.o $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS) ifdef CONFIG_MPATH diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index 3bc1269..a26f8b8 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -28,6 +28,7 @@ #include "qemu/statfs.h" #include "9p-iov-marshal.h" #include "hw/9pfs/9p-proxy.h" +#include "hw/9pfs/9p-util.h" #include "fsdev/9p-iov-marshal.h" #define PROGNAME "virtfs-proxy-helper" @@ -459,7 +460,7 @@ static int do_getxattr(int type, struct iovec *iovec, struct iovec *out_iovec) v9fs_string_init(&name); retval = proxy_unmarshal(iovec, offset, "s", &name); if (retval > 0) { -retval = lgetxattr(path.data, name.data, xattr.data, size); +retval = qemu_lgetxattr(path.data, name.data, xattr.data, size); if (retval < 0) { retval = -errno; } else { @@ -469,7 +470,7 @@ static int do_getxattr(int type, struct iovec *iovec, struct iovec *out_iovec) v9fs_string_free(&name); break; case T_LLISTXATTR: -retval = llistxattr(path.data, xattr.data, size); +retval = qemu_llistxattr(path.data, xattr.data, size); if (retval < 0) { retval = -errno; } else { @@ -1000,7 +1001,7 @@ static int process_requests(int sock) retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sssdd", &path, &name, &value, &size, &flags); if (retval > 0) { -retval = lsetxattr(path.data, +retval = qemu_lsetxattr(path.data, name.data, value.data, size, flags); if (retval < 0) { retval = -errno; @@ -1016,7 +1017,7 @@ static int process_requests(int sock) retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "ss", &path, &name); if (retval > 0) { -retval = lremovexattr(path.data, name.data); +retval = qemu_lremovexattr(path.data, name.data); if (retval < 0) { retval = -errno; } diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 98d4073..768ef6f 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -776,16 +776,20 @@ static int local_fstat(FsContext *fs_ctx, int fid_type, mode_t tmp_mode; dev_t tmp_dev; -if (fgetxattr(fd, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0) { +if (qemu_fgetxattr(fd, "user.virtfs.uid", + &tmp_uid, sizeof(uid_t)) > 0) { stbuf->st_uid = le32_to_cpu(tmp_uid); } -if (fgetxattr(fd, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0) { +if (qemu_fgetxattr(fd, "user.virtfs.gid", + &tmp_gid, sizeof(gid_t)) > 0) { stbuf->st_gid = le32_to_cpu(tmp_gid); } -if (fgetxattr(fd, "user.virtfs.mode", &tmp_mode, sizeof(mode_t)) > 0) { +if (qemu_fgetxattr(fd, "user.virtfs.mode", + &tmp_mode, sizeof(mode_t)) > 0) { stbuf->st_mode = le32_to_cpu(tmp_mode); } -if (fgetxattr(fd, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0) { +if (qemu_fgetxattr(fd, "user.virtfs.rdev", + &tmp_dev, sizeof(dev_t)) > 0) { stbuf->st_rdev = le64_to_cpu(tmp_dev); } } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 79ed6b2..50a03c7 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -19,6 +19,23 @@ #define O_PATH_9P_UTIL 0 #endif +#ifdef CONFIG_DARWIN +#define qemu_fgetxattr(...) fgetxattr(__VA_ARGS__, 0, 0) +#define qemu_lgetxattr(...) getxattr(__VA_ARGS__, 0, XATTR_NOFOLLOW) +#define qemu_llistxa
[Qemu-devel] [PATCH v3 02/13] 9p: Rename 9p-util -> 9p-util-linux
The current file only has the Linux versions of these functions. Rename the file accordingly and update the Makefile to only build it on Linux. A Darwin version of these will follow later in the series. Signed-off-by: Keno Fischer --- hw/9pfs/9p-util-linux.c | 59 + hw/9pfs/9p-util.c | 59 - hw/9pfs/Makefile.objs | 3 ++- 3 files changed, 61 insertions(+), 60 deletions(-) create mode 100644 hw/9pfs/9p-util-linux.c delete mode 100644 hw/9pfs/9p-util.c diff --git a/hw/9pfs/9p-util-linux.c b/hw/9pfs/9p-util-linux.c new file mode 100644 index 000..defa3a4 --- /dev/null +++ b/hw/9pfs/9p-util-linux.c @@ -0,0 +1,59 @@ +/* + * 9p utilities (Linux Implementation) + * + * Copyright IBM, Corp. 2017 + * + * Authors: + * Greg Kurz + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/xattr.h" +#include "9p-util.h" + +ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name, + void *value, size_t size) +{ +char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); +int ret; + +ret = lgetxattr(proc_path, name, value, size); +g_free(proc_path); +return ret; +} + +ssize_t flistxattrat_nofollow(int dirfd, const char *filename, + char *list, size_t size) +{ +char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); +int ret; + +ret = llistxattr(proc_path, list, size); +g_free(proc_path); +return ret; +} + +ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, +const char *name) +{ +char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); +int ret; + +ret = lremovexattr(proc_path, name); +g_free(proc_path); +return ret; +} + +int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, + void *value, size_t size, int flags) +{ +char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); +int ret; + +ret = lsetxattr(proc_path, name, value, size, flags); +g_free(proc_path); +return ret; +} diff --git a/hw/9pfs/9p-util.c b/hw/9pfs/9p-util.c deleted file mode 100644 index 614b7fc..000 --- a/hw/9pfs/9p-util.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 9p utilities - * - * Copyright IBM, Corp. 2017 - * - * Authors: - * Greg Kurz - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#include "qemu/osdep.h" -#include "qemu/xattr.h" -#include "9p-util.h" - -ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name, - void *value, size_t size) -{ -char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); -int ret; - -ret = lgetxattr(proc_path, name, value, size); -g_free(proc_path); -return ret; -} - -ssize_t flistxattrat_nofollow(int dirfd, const char *filename, - char *list, size_t size) -{ -char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); -int ret; - -ret = llistxattr(proc_path, list, size); -g_free(proc_path); -return ret; -} - -ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, -const char *name) -{ -char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); -int ret; - -ret = lremovexattr(proc_path, name); -g_free(proc_path); -return ret; -} - -int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, - void *value, size_t size, int flags) -{ -char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); -int ret; - -ret = lsetxattr(proc_path, name, value, size, flags); -g_free(proc_path); -return ret; -} diff --git a/hw/9pfs/Makefile.objs b/hw/9pfs/Makefile.objs index e3fa673..95e3bc0 100644 --- a/hw/9pfs/Makefile.objs +++ b/hw/9pfs/Makefile.objs @@ -1,5 +1,6 @@ ifeq ($(call lor,$(CONFIG_VIRTIO_9P),$(CONFIG_XEN)),y) -common-obj-y = 9p.o 9p-util.o +common-obj-y = 9p.o +common-obj-$(CONFIG_LINUX) += 9p-util-linux.o common-obj-y += 9p-local.o 9p-xattr.o common-obj-y += 9p-xattr-user.o 9p-posix-acl.o common-obj-y += coth.o cofs.o codir.o cofile.o -- 2.8.1
[Qemu-devel] [PATCH v3 05/13] 9p: darwin: Explicitly cast comparisons of mode_t with -1
Comparisons of mode_t with -1 require an explicit cast, since mode_t is unsigned on Darwin. Signed-off-by: Keno Fischer --- hw/9pfs/9p-local.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index d713983..98d4073 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -310,7 +310,7 @@ update_map_file: if (credp->fc_gid != -1) { gid = credp->fc_gid; } -if (credp->fc_mode != -1) { +if (credp->fc_mode != (mode_t)-1) { mode = credp->fc_mode; } if (credp->fc_rdev != -1) { @@ -416,7 +416,7 @@ static int local_set_xattrat(int dirfd, const char *path, FsCred *credp) return err; } } -if (credp->fc_mode != -1) { +if (credp->fc_mode != (mode_t)-1) { uint32_t tmp_mode = cpu_to_le32(credp->fc_mode); err = fsetxattrat_nofollow(dirfd, path, "user.virtfs.mode", &tmp_mode, sizeof(mode_t), 0); -- 2.8.1
[Qemu-devel] [PATCH v3 01/13] 9p: linux: Fix a couple Linux assumptions
From: Keno Fischer - Guard Linux only headers. - Add qemu/statfs.h header to abstract over the which headers are needed for struct statfs - Define `ENOATTR` only if not only defined (it's defined in system headers on Darwin). Signed-off-by: Keno Fischer --- fsdev/file-op-9p.h | 2 +- fsdev/virtfs-proxy-helper.c | 4 +++- hw/9pfs/9p-local.c | 2 ++ include/qemu/statfs.h | 19 +++ include/qemu/xattr.h| 4 +++- 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 include/qemu/statfs.h diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h index 3fa062b..111f804 100644 --- a/fsdev/file-op-9p.h +++ b/fsdev/file-op-9p.h @@ -16,7 +16,7 @@ #include #include -#include +#include "qemu/statfs.h" #include "qemu-fsdev-throttle.h" #define SM_LOCAL_MODE_BITS0600 diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index 6f132c5..94fb069 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -13,17 +13,19 @@ #include #include #include +#ifdef CONFIG_LINUX #include #include -#include #include #include #ifdef CONFIG_LINUX_MAGIC_H #include #endif +#endif #include "qemu-common.h" #include "qemu/sockets.h" #include "qemu/xattr.h" +#include "qemu/statfs.h" #include "9p-iov-marshal.h" #include "hw/9pfs/9p-proxy.h" #include "fsdev/9p-iov-marshal.h" diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 828e8d6..d713983 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -27,10 +27,12 @@ #include "qemu/error-report.h" #include "qemu/option.h" #include +#ifdef CONFIG_LINUX #include #ifdef CONFIG_LINUX_MAGIC_H #include #endif +#endif #include #ifndef XFS_SUPER_MAGIC diff --git a/include/qemu/statfs.h b/include/qemu/statfs.h new file mode 100644 index 000..dde289f --- /dev/null +++ b/include/qemu/statfs.h @@ -0,0 +1,19 @@ +/* + * Host statfs header abstraction + * + * This work is licensed under the terms of the GNU GPL, version 2, or any + * later version. See the COPYING file in the top-level directory. + * + */ +#ifndef QEMU_STATFS_H +#define QEMU_STATFS_H + +#ifdef CONFIG_LINUX +# include +#endif +#ifdef CONFIG_DARWIN +# include +# include +#endif + +#endif diff --git a/include/qemu/xattr.h b/include/qemu/xattr.h index a83fe8e..f1d0f7b 100644 --- a/include/qemu/xattr.h +++ b/include/qemu/xattr.h @@ -22,7 +22,9 @@ #ifdef CONFIG_LIBATTR # include #else -# define ENOATTR ENODATA +# if !defined(ENOATTR) +#define ENOATTR ENODATA +# endif # include #endif -- 2.8.1
[Qemu-devel] [PATCH v3 00/13] 9p: Add support for Darwin
Hi Greg, this is the rebased version of the patch series adding support for building the 9p server on Darwin. As you know a number of patches from the v2 version of this series are already landed. This is the remaining patches. Other than rebasing, there is onnly one minor change in patch 11. Keno Keno Fischer (13): 9p: linux: Fix a couple Linux assumptions 9p: Rename 9p-util -> 9p-util-linux 9p: darwin: Handle struct stat(fs) differences 9p: darwin: Handle struct dirent differences 9p: darwin: Explicitly cast comparisons of mode_t with -1 9p: darwin: Ignore O_{NOATIME, DIRECT} 9p: darwin: Provide a compatibility definition for XATTR_SIZE_MAX 9p: darwin: *xattr_nofollow implementations 9p: darwin: Compatibility for f/l*xattr 9p: darwin: Provide a fallback implementation for utimensat 9p: darwin: Implement compatibility for mknodat 9p: darwin: virtfs-proxy: Implement setuid code for darwin 9p: darwin: configure: Allow VirtFS on Darwin Makefile| 6 ++ Makefile.objs | 1 + configure | 22 +++-- fsdev/file-op-9p.h | 2 +- fsdev/virtfs-proxy-helper.c | 230 hw/9pfs/9p-local.c | 25 +++-- hw/9pfs/9p-proxy.c | 17 +++- hw/9pfs/9p-synth.c | 4 + hw/9pfs/9p-util-darwin.c| 191 hw/9pfs/9p-util-linux.c | 70 ++ hw/9pfs/9p-util.c | 59 hw/9pfs/9p-util.h | 27 ++ hw/9pfs/9p.c| 71 -- hw/9pfs/Makefile.objs | 4 +- include/qemu/statfs.h | 19 include/qemu/xattr.h| 4 +- 16 files changed, 579 insertions(+), 173 deletions(-) create mode 100644 hw/9pfs/9p-util-darwin.c create mode 100644 hw/9pfs/9p-util-linux.c delete mode 100644 hw/9pfs/9p-util.c create mode 100644 include/qemu/statfs.h -- 2.8.1
[Qemu-devel] [PATCH v3 07/13] 9p: darwin: Provide a compatibility definition for XATTR_SIZE_MAX
Signed-off-by: Keno Fischer --- hw/9pfs/9p.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index e650459..abfb8dc 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3374,6 +3374,13 @@ out_nofid: v9fs_string_free(&name); } +#if defined(CONFIG_DARWIN) && !defined(XATTR_SIZE_MAX) +/* Darwin doesn't seem to define a maximum xattr size in its user + user space header, but looking at the kernel source, HFS supports + up to INT32_MAX, so use that as the maximum. +*/ +#define XATTR_SIZE_MAX INT32_MAX +#endif static void coroutine_fn v9fs_xattrcreate(void *opaque) { int flags, rflags = 0; -- 2.8.1
[Qemu-devel] [PATCH v3 03/13] 9p: darwin: Handle struct stat(fs) differences
Signed-off-by: Keno Fischer --- fsdev/virtfs-proxy-helper.c | 14 +++--- hw/9pfs/9p-proxy.c | 17 ++--- hw/9pfs/9p-synth.c | 2 ++ hw/9pfs/9p.c| 16 ++-- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index 94fb069..3bc1269 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -506,12 +506,15 @@ static void stat_to_prstat(ProxyStat *pr_stat, struct stat *stat) pr_stat->st_size = stat->st_size; pr_stat->st_blksize = stat->st_blksize; pr_stat->st_blocks = stat->st_blocks; +#ifdef CONFIG_DARWIN +pr_stat->st_atim_nsec = stat->st_atimespec.tv_nsec; +pr_stat->st_mtim_nsec = stat->st_mtimespec.tv_nsec; +pr_stat->st_ctim_nsec = stat->st_ctimespec.tv_nsec; +#else pr_stat->st_atim_sec = stat->st_atim.tv_sec; -pr_stat->st_atim_nsec = stat->st_atim.tv_nsec; pr_stat->st_mtim_sec = stat->st_mtim.tv_sec; -pr_stat->st_mtim_nsec = stat->st_mtim.tv_nsec; pr_stat->st_ctim_sec = stat->st_ctim.tv_sec; -pr_stat->st_ctim_nsec = stat->st_ctim.tv_nsec; +#endif } static void statfs_to_prstatfs(ProxyStatFS *pr_stfs, struct statfs *stfs) @@ -524,10 +527,15 @@ static void statfs_to_prstatfs(ProxyStatFS *pr_stfs, struct statfs *stfs) pr_stfs->f_bavail = stfs->f_bavail; pr_stfs->f_files = stfs->f_files; pr_stfs->f_ffree = stfs->f_ffree; +#ifdef CONFIG_DARWIN +pr_stfs->f_fsid[0] = stfs->f_fsid.val[0]; +pr_stfs->f_fsid[1] = stfs->f_fsid.val[1]; +#else pr_stfs->f_fsid[0] = stfs->f_fsid.__val[0]; pr_stfs->f_fsid[1] = stfs->f_fsid.__val[1]; pr_stfs->f_namelen = stfs->f_namelen; pr_stfs->f_frsize = stfs->f_frsize; +#endif } /* diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index 47a94e0..8a2c174 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -117,10 +117,15 @@ static void prstatfs_to_statfs(struct statfs *stfs, ProxyStatFS *prstfs) stfs->f_bavail = prstfs->f_bavail; stfs->f_files = prstfs->f_files; stfs->f_ffree = prstfs->f_ffree; +#ifdef CONFIG_DARWIN +stfs->f_fsid.val[0] = prstfs->f_fsid[0] & 0xU; +stfs->f_fsid.val[1] = prstfs->f_fsid[1] >> 32 & 0xU; +#else stfs->f_fsid.__val[0] = prstfs->f_fsid[0] & 0xU; stfs->f_fsid.__val[1] = prstfs->f_fsid[1] >> 32 & 0xU; stfs->f_namelen = prstfs->f_namelen; stfs->f_frsize = prstfs->f_frsize; +#endif } /* Converts proxy_stat structure to VFS stat structure */ @@ -137,12 +142,18 @@ static void prstat_to_stat(struct stat *stbuf, ProxyStat *prstat) stbuf->st_size = prstat->st_size; stbuf->st_blksize = prstat->st_blksize; stbuf->st_blocks = prstat->st_blocks; - stbuf->st_atim.tv_sec = prstat->st_atim_sec; - stbuf->st_atim.tv_nsec = prstat->st_atim_nsec; + stbuf->st_atime = prstat->st_atim_sec; stbuf->st_mtime = prstat->st_mtim_sec; - stbuf->st_mtim.tv_nsec = prstat->st_mtim_nsec; stbuf->st_ctime = prstat->st_ctim_sec; +#ifdef CONFIG_DARWIN + stbuf->st_atimespec.tv_nsec = prstat->st_atim_nsec; + stbuf->st_mtimespec.tv_nsec = prstat->st_mtim_nsec; + stbuf->st_ctimespec.tv_nsec = prstat->st_ctim_nsec; +#else + stbuf->st_atim.tv_nsec = prstat->st_atim_nsec; + stbuf->st_mtim.tv_nsec = prstat->st_mtim_nsec; stbuf->st_ctim.tv_nsec = prstat->st_ctim_nsec; +#endif } /* diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index 54239c9..eb68b42 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -426,7 +426,9 @@ static int synth_statfs(FsContext *s, V9fsPath *fs_path, stbuf->f_bsize = 512; stbuf->f_blocks = 0; stbuf->f_files = synth_node_count; +#ifndef CONFIG_DARWIN stbuf->f_namelen = NAME_MAX; +#endif return 0; } diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index eef289e..8e6b908 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -905,11 +905,17 @@ static void stat_to_v9stat_dotl(V9fsState *s, const struct stat *stbuf, v9lstat->st_blksize = stbuf->st_blksize; v9lstat->st_blocks = stbuf->st_blocks; v9lstat->st_atime_sec = stbuf->st_atime; -v9lstat->st_atime_nsec = stbuf->st_atim.tv_nsec; v9lstat->st_mtime_sec = stbuf->st_mtime; -v9lstat->st_mtime_nsec = stbuf->st_mtim.tv_nsec; v9lstat->st_ctime_sec = stbuf->st_ctime; +#ifdef CONFIG_DARWIN +v9lstat->st_atime_nsec = stbuf->st_atimespec.tv_nsec; +v9lstat->st_mtime_nsec = stbuf->st_mtimespec.tv_nsec; +v9lstat->st_ctime_nsec = stbuf->st_ctimespec.tv_nsec; +#else +v9lstat->st_atime_nsec = stbuf->st_atim.tv_nsec; +v9lstat->st_mtime_nsec = stbuf->st_mtim.tv_nsec; v9lstat->st_ctime_nsec = stbuf->st_ctim.tv_nsec; +#endif /* Currently we only support BASIC fields in stat */ v9lstat->st_result_mask = P9_STATS_BASIC; @@ -2959,9 +2965,15 @@ static int v9fs_fill_statfs(V9fsState *s, V9fsPDU *pdu, struct statfs *stbuf) f_bavail = stbuf->f_bavail/bsize_factor;
[Qemu-devel] [PATCH v3 06/13] 9p: darwin: Ignore O_{NOATIME, DIRECT}
Darwin doesn't have either of these flags. Darwin does have F_NOCACHE, which is similar to O_DIRECT, but has different enough semantics that other projects don't generally map them automatically. In any case, we don't support O_DIRECT on Linux at the moment either. Signed-off-by: Keno Fischer --- hw/9pfs/9p.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 06139c9..e650459 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -123,11 +123,18 @@ static int dotl_to_open_flags(int flags) { P9_DOTL_NONBLOCK, O_NONBLOCK } , { P9_DOTL_DSYNC, O_DSYNC }, { P9_DOTL_FASYNC, FASYNC }, +#ifndef CONFIG_DARWIN +{ P9_DOTL_NOATIME, O_NOATIME }, +/* On Darwin, we could map to F_NOCACHE, which is + similar, but doesn't quite have the same + semantics. However, we don't support O_DIRECT + even on linux at the moment, so we just ignore + it here. */ { P9_DOTL_DIRECT, O_DIRECT }, +#endif { P9_DOTL_LARGEFILE, O_LARGEFILE }, { P9_DOTL_DIRECTORY, O_DIRECTORY }, { P9_DOTL_NOFOLLOW, O_NOFOLLOW }, -{ P9_DOTL_NOATIME, O_NOATIME }, { P9_DOTL_SYNC, O_SYNC }, }; @@ -156,10 +163,12 @@ static int get_dotl_openflags(V9fsState *s, int oflags) */ flags = dotl_to_open_flags(oflags); flags &= ~(O_NOCTTY | O_ASYNC | O_CREAT); +#ifndef CONFIG_DARWIN /* * Ignore direct disk access hint until the server supports it. */ flags &= ~O_DIRECT; +#endif return flags; } -- 2.8.1
Re: [Qemu-devel] [PATCH v7 29/54] tests/docker/Makefile.include: fix mipsel-cross dependancy
On 06/15/2018 04:46 PM, Alex Bennée wrote: > This got broken in commit 4319db7 but generally only shows up when you > try and do massive parallel builds on fresh machines. > > Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé > --- > tests/docker/Makefile.include | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include > index 8afb383478..4a2b028a3b 100644 > --- a/tests/docker/Makefile.include > +++ b/tests/docker/Makefile.include > @@ -57,6 +57,7 @@ docker-image-debian-armel-cross: docker-image-debian9 > docker-image-debian-armhf-cross: docker-image-debian9 > docker-image-debian-arm64-cross: docker-image-debian9 > docker-image-debian-mips-cross: docker-image-debian9 > +docker-image-debian-mipsel-cross: docker-image-debian9 > docker-image-debian-mips64el-cross: docker-image-debian9 > docker-image-debian-powerpc-cross: docker-image-debian8 > docker-image-debian-ppc64el-cross: docker-image-debian9 >
Re: [Qemu-devel] [PATCH v7 12/54] tests/tcg/multiarch: don't hard code paths/ports for linux-test
Hi Alex, On 06/15/2018 04:46 PM, Alex Bennée wrote: > The fixed path and ports get in the way of running our tests and > builds in parallel. Instead of using TESTPATH we use mkdtemp() and > instead of a fixed port we allow the kernel to assign one and query it > afterwards. > > Signed-off-by: Alex Bennée > --- > tests/tcg/multiarch/linux-test.c | 37 > 1 file changed, 19 insertions(+), 18 deletions(-) > > diff --git a/tests/tcg/multiarch/linux-test.c > b/tests/tcg/multiarch/linux-test.c > index 6f2c531474..3f73b96420 100644 > --- a/tests/tcg/multiarch/linux-test.c > +++ b/tests/tcg/multiarch/linux-test.c > @@ -41,8 +41,6 @@ > #include > #include > > -#define TESTPATH "/tmp/linux-test.tmp" > -#define TESTPORT 7654 > #define STACK_SIZE 16384 > > static void error1(const char *filename, int line, const char *fmt, ...) > @@ -85,19 +83,15 @@ static void test_file(void) > struct iovec vecs[2]; > DIR *dir; > struct dirent *de; > +char template[] = "/tmp/linux-test-XX"; Since /tmp doesn't always fit, can this be: char *tmpbase = getenv("TMPDIR"); char *template = g_strdup_printf("%s/qemu-test-XX", tmpbase ? tmpbase : "/tmp"); > +char *tmpdir = mkdtemp(template); g_free(template); > > -/* clean up, just in case */ > -unlink(TESTPATH "/file1"); > -unlink(TESTPATH "/file2"); > -unlink(TESTPATH "/file3"); > -rmdir(TESTPATH); > +chk_error(strlen(tmpdir)); > > if (getcwd(cur_dir, sizeof(cur_dir)) == NULL) > error("getcwd"); > > -chk_error(mkdir(TESTPATH, 0755)); > - > -chk_error(chdir(TESTPATH)); > +chk_error(chdir(tmpdir)); > > /* open/read/write/close/readv/writev/lseek */ > > @@ -163,7 +157,7 @@ static void test_file(void) > st.st_mtime != 1000) > error("stat time"); > > -chk_error(stat(TESTPATH, &st)); > +chk_error(stat(tmpdir, &st)); > if (!S_ISDIR(st.st_mode)) > error("stat mode"); > > @@ -185,7 +179,7 @@ static void test_file(void) > error("stat mode"); > > /* getdents */ > -dir = opendir(TESTPATH); > +dir = opendir(tmpdir); > if (!dir) > error("opendir"); > len = 0; > @@ -207,7 +201,7 @@ static void test_file(void) > chk_error(unlink("file3")); > chk_error(unlink("file2")); > chk_error(chdir(cur_dir)); > -chk_error(rmdir(TESTPATH)); > +chk_error(rmdir(tmpdir)); > } > > static void test_fork(void) > @@ -264,7 +258,7 @@ static int server_socket(void) > chk_error(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val))); > > sockaddr.sin_family = AF_INET; > -sockaddr.sin_port = htons(TESTPORT); > +sockaddr.sin_port = htons(0); /* choose random ephemeral port) */ > sockaddr.sin_addr.s_addr = 0; > chk_error(bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr))); > chk_error(listen(fd, 0)); > @@ -272,7 +266,7 @@ static int server_socket(void) > > } > > -static int client_socket(void) > +static int client_socket(uint16_t port) > { > int fd; > struct sockaddr_in sockaddr; > @@ -280,7 +274,7 @@ static int client_socket(void) > /* server socket */ > fd = chk_error(socket(PF_INET, SOCK_STREAM, 0)); > sockaddr.sin_family = AF_INET; > -sockaddr.sin_port = htons(TESTPORT); > +sockaddr.sin_port = htons(port); > inet_aton("127.0.0.1", &sockaddr.sin_addr); > chk_error(connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr))); > return fd; > @@ -292,10 +286,17 @@ static void test_socket(void) > { > int server_fd, client_fd, fd, pid, ret, val; > struct sockaddr_in sockaddr; > -socklen_t len; > +struct sockaddr_in server_addr; > +socklen_t len, socklen; > +uint16_t server_port; > char buf[512]; > > server_fd = server_socket(); > +/* find out what port we got */ > +socklen = sizeof(server_addr); > +ret = getsockname(server_fd, &server_addr, &socklen); > +chk_error(ret); > +server_port = ntohs(server_addr.sin_port); > > /* test a few socket options */ > len = sizeof(val); > @@ -305,7 +306,7 @@ static void test_socket(void) > > pid = chk_error(fork()); > if (pid == 0) { > -client_fd = client_socket(); > +client_fd = client_socket(server_port); > send(client_fd, socket_msg, sizeof(socket_msg), 0); > close(client_fd); > exit(0); >
[Qemu-devel] [Bug 1721222] Re: qemu crashes with Assertion `fdctrl->dma' failed
Fixed here: https://git.qemu.org/?p=qemu.git;a=commitdiff;h=b3da551389c86ce214 ** Changed in: qemu Status: Confirmed => Fix Released -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1721222 Title: qemu crashes with Assertion `fdctrl->dma' failed Status in QEMU: Fix Released Bug description: Re-production steps: git clone today's qemu git tree (4th Oct 2017) ./configure --target-list=ppc64-softmmu && make -j 8 Run the device-crash-test from scripts folder, seeing the following error INFO: running test case: machine=powernv binary=ppc64-softmmu/qemu-system-ppc64 device=isa-fdc accel=tcg WARNING: qemu received signal -6: ppc64-softmmu/qemu-system-ppc64 -chardev socket,id=mon,path=/var/tmp/qemu-30972-monitor.sock -mon chardev=mon,mode=control -display none -vga none -S -machine powernv,accel=tcg -device isa-fdc CRITICAL: failed: machine=powernv binary=ppc64-softmmu/qemu-system-ppc64 device=isa-fdc accel=tcg CRITICAL: cmdline: ppc64-softmmu/qemu-system-ppc64 -S -machine powernv,accel=tcg -device isa-fdc CRITICAL: log: qemu-system-ppc64: hw/block/fdc.c:2703: isabus_fdc_realize: Assertion `fdctrl->dma' failed. CRITICAL: exit code: -6 To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1721222/+subscriptions
Re: [Qemu-devel] [PATCH v7 13/54] tests/tcg/multiarch: move most output to stdout
On 15.06.2018 21:46, Alex Bennée wrote: > The default test run outputs to stdout so it can be re-directed. > Errors are still reported to stderr. > > Signed-off-by: Alex Bennée > Reviewed-by: Philippe Mathieu-Daudé > Tested-by: Philippe Mathieu-Daudé > Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth
Re: [Qemu-devel] [PATCH v7 12/54] tests/tcg/multiarch: don't hard code paths/ports for linux-test
On 15.06.2018 21:46, Alex Bennée wrote: > The fixed path and ports get in the way of running our tests and > builds in parallel. Instead of using TESTPATH we use mkdtemp() and > instead of a fixed port we allow the kernel to assign one and query it > afterwards. > > Signed-off-by: Alex Bennée > --- > tests/tcg/multiarch/linux-test.c | 37 > 1 file changed, 19 insertions(+), 18 deletions(-) > > diff --git a/tests/tcg/multiarch/linux-test.c > b/tests/tcg/multiarch/linux-test.c > index 6f2c531474..3f73b96420 100644 > --- a/tests/tcg/multiarch/linux-test.c > +++ b/tests/tcg/multiarch/linux-test.c > @@ -41,8 +41,6 @@ > #include > #include > > -#define TESTPATH "/tmp/linux-test.tmp" > -#define TESTPORT 7654 > #define STACK_SIZE 16384 > > static void error1(const char *filename, int line, const char *fmt, ...) > @@ -85,19 +83,15 @@ static void test_file(void) > struct iovec vecs[2]; > DIR *dir; > struct dirent *de; > +char template[] = "/tmp/linux-test-XX"; > +char *tmpdir = mkdtemp(template); > > -/* clean up, just in case */ > -unlink(TESTPATH "/file1"); > -unlink(TESTPATH "/file2"); > -unlink(TESTPATH "/file3"); > -rmdir(TESTPATH); > +chk_error(strlen(tmpdir)); That line looks wrong to me. According to my man-page of mkdtemp(), it returns either NULL or a pointer to the modified string. In case of NULL, strlen(tmpdir) will simply crash. And even if it would not crash, strlen() only returns values >= 0, so there is no way the chk_error could ever report an error here. Thomas
[Qemu-devel] [Bug 1777252] Re: tests/Makefile.include trying to add linking library '-lutil' that break the build on Solaris
I'm sorry, but Solaris is currently unsupported and might get removed in a future release, see: https://wiki.qemu.org/ChangeLog/2.12#Warning:_unsupported_host_systems So it would be great if you could contribute patches, or find someone who's willing to maintain QEMU on Solaris. -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1777252 Title: tests/Makefile.include trying to add linking library '-lutil' that break the build on Solaris Status in QEMU: New Bug description: Building script 'tests/Makefile.include' contains following code ``` ifeq ($(CONFIG_POSIX),y) LIBS += -lutil endif ``` library -lutil is not available on Solaris, so the building will failed, like ``` ld: fatal: library -lutil: not found make: *** [SOMEWHERE/src/qemu-2.12.0/rules.mak:121: qemu-nbd] Error 1 ``` Commenting those code out fixed the error. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1777252/+subscriptions
[Qemu-devel] [Bug 1777252] [NEW] tests/Makefile.include trying to add linking library '-lutil' that break the build on Solaris
Public bug reported: Building script 'tests/Makefile.include' contains following code ``` ifeq ($(CONFIG_POSIX),y) LIBS += -lutil endif ``` library -lutil is not available on Solaris, so the building will failed, like ``` ld: fatal: library -lutil: not found make: *** [SOMEWHERE/src/qemu-2.12.0/rules.mak:121: qemu-nbd] Error 1 ``` Commenting those code out fixed the error. ** Affects: qemu Importance: Undecided Status: New ** Tags: solaris -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1777252 Title: tests/Makefile.include trying to add linking library '-lutil' that break the build on Solaris Status in QEMU: New Bug description: Building script 'tests/Makefile.include' contains following code ``` ifeq ($(CONFIG_POSIX),y) LIBS += -lutil endif ``` library -lutil is not available on Solaris, so the building will failed, like ``` ld: fatal: library -lutil: not found make: *** [SOMEWHERE/src/qemu-2.12.0/rules.mak:121: qemu-nbd] Error 1 ``` Commenting those code out fixed the error. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1777252/+subscriptions
[Qemu-devel] Design Decision for KVM based anti rootkit
Following up on these threads: - https://marc.info/?l=kvm&m=151929803301378&w=2 - http://www.openwall.com/lists/kernel-hardening/2018/02/22/18 I lost the original emails so I couldn't reply to them, and also sorry for being late, it was the end of semester exams. I was adviced on #qemu and #kernelnewbies IRCs to ask here as it will help having better insights. To wrap things up, the basic design will be a method for communication between host and guest is guest can request certain pages to be read only, and then host will force them to be read-only by guest until next guest reboot, then it will impossible for guest OS to have them as RW again. The choice of which pages to be set as read only is the guest's. So this way mixed pages can still be mixed with R/W content even if holds kernel code. I was planning to use KVM as my hypervisor, until I found out that KVM can't do that on its own so one will need a custom virtio driver to do this kind of guest-host communication/coordination, I am still sticking to KVM, and have no plans to do this for Xen at least for now, this means that in order to get it to work there must be a QEMU support our specific driver we are planning to write in order for things to work properly. The question is is this the right approach? or is there a simpler way to achieve this goal?
[Qemu-devel] [Bug 1777236] [NEW] NVME is missing support for mandatory features through "Get/Set Feature" command
Public bug reported: The following are features which are marked as mandatory by the 1.2 specification (NVMe 1.2, Section 5.14.1, Figure 108) as currently not implemented - 0x1 Arbitration - 0x2 Power Management - 0x4 Temperature Threshold - 0x5 Error Recovery - 0x6 Interrupt Coalescing - 0x7 Interrupt Vector Configuration - 0x8 Write Atomicity Normal - 0x9 Asynchronous Event Configuration ** Affects: qemu Importance: Undecided Status: New -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1777236 Title: NVME is missing support for mandatory features through "Get/Set Feature" command Status in QEMU: New Bug description: The following are features which are marked as mandatory by the 1.2 specification (NVMe 1.2, Section 5.14.1, Figure 108) as currently not implemented - 0x1 Arbitration - 0x2 Power Management - 0x4 Temperature Threshold - 0x5 Error Recovery - 0x6 Interrupt Coalescing - 0x7 Interrupt Vector Configuration - 0x8 Write Atomicity Normal - 0x9 Asynchronous Event Configuration To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1777236/+subscriptions
[Qemu-devel] [Bug 1777235] [NEW] NVME is missing support for Get Log Page command
Public bug reported: "Get Log Page" is a mandatory admin command by the specification (NVMe 1.2, Section 5, Figure 40) currently not implemented by device. ** Affects: qemu Importance: Undecided Status: New -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1777235 Title: NVME is missing support for Get Log Page command Status in QEMU: New Bug description: "Get Log Page" is a mandatory admin command by the specification (NVMe 1.2, Section 5, Figure 40) currently not implemented by device. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1777235/+subscriptions
[Qemu-devel] [Bug 1777232] [NEW] NVME fails on big writes
Public bug reported: NVME Compliance test 8:3.3.0 tries to write and read back big chunks of pages. Currently, on the latest QEMU operation of size 1024 blocks will fail when device is backed by a file. NVME specification has several types of data transfers from guests, one of the is the PRP list (Physical Region Page List). PRP is a list of entries pointing to pages to be written. The list it self resides in a single or multiple pages. NVME device maps the PRP list into QEMUSGList which will be me mapped into linux IO vectors. Finally, when the file driver will write the changes, it uses the posix pwritev, which fails if the number of vectors exceeds the maximum. NVME Compliance - https://github.com/nvmecompliance/tnvme/wiki ** Affects: qemu Importance: Undecided Status: New -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1777232 Title: NVME fails on big writes Status in QEMU: New Bug description: NVME Compliance test 8:3.3.0 tries to write and read back big chunks of pages. Currently, on the latest QEMU operation of size 1024 blocks will fail when device is backed by a file. NVME specification has several types of data transfers from guests, one of the is the PRP list (Physical Region Page List). PRP is a list of entries pointing to pages to be written. The list it self resides in a single or multiple pages. NVME device maps the PRP list into QEMUSGList which will be me mapped into linux IO vectors. Finally, when the file driver will write the changes, it uses the posix pwritev, which fails if the number of vectors exceeds the maximum. NVME Compliance - https://github.com/nvmecompliance/tnvme/wiki To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1777232/+subscriptions
[Qemu-devel] [Bug 1777226] [NEW] qemu-user warnings confuse userland applications
Public bug reported: I recently observed that warning messages emitted by qemu-user can confuse applications when reading from stdout/stderr. This was observed with the configure script of OpenJDK-11 on qemu-sh4: configure: Found potential Boot JDK using configure arguments configure: Potential Boot JDK found at /usr/lib/jvm/java-10-openjdk-sh4 is incorrect JDK version (qemu: Unsupported syscall: 318); ignoring configure: (Your Boot JDK version must be one of: 10 11) configure: error: The path given by --with-boot-jdk does not contain a valid Boot JDK configure exiting with result code 1 See: https://buildd.debian.org/status/fetch.php?pkg=openjdk-11&arch=sh4&ver=11%7E18-1&stamp=1529119043&raw=0 Commenting out the line of code which emits the warning fixes the problem for me and the configure script finishes without problems. Thus, qemu should be modified to avoid cluttering stdout or stderr with its own messages and rather send those warnings to a log file or similar. ** Affects: qemu Importance: Undecided Status: New -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1777226 Title: qemu-user warnings confuse userland applications Status in QEMU: New Bug description: I recently observed that warning messages emitted by qemu-user can confuse applications when reading from stdout/stderr. This was observed with the configure script of OpenJDK-11 on qemu-sh4: configure: Found potential Boot JDK using configure arguments configure: Potential Boot JDK found at /usr/lib/jvm/java-10-openjdk-sh4 is incorrect JDK version (qemu: Unsupported syscall: 318); ignoring configure: (Your Boot JDK version must be one of: 10 11) configure: error: The path given by --with-boot-jdk does not contain a valid Boot JDK configure exiting with result code 1 See: https://buildd.debian.org/status/fetch.php?pkg=openjdk-11&arch=sh4&ver=11%7E18-1&stamp=1529119043&raw=0 Commenting out the line of code which emits the warning fixes the problem for me and the configure script finishes without problems. Thus, qemu should be modified to avoid cluttering stdout or stderr with its own messages and rather send those warnings to a log file or similar. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1777226/+subscriptions
[Qemu-devel] Kernel requirement for membarriers feature
Hi, When the membarriers feature was introduced, the kernel requirement was set to 4.14, however if my understanding of what is needed is correct that is rather strict? http://lists.gnu.org/archive/html/qemu-devel/2018-03/msg02748.html As far as i can tell the feature was introduced in 4.3 see: https://elixir.bootlin.com/linux/v4.3.6/ident/MEMBARRIER_CMD_SHARED If I patch out that requirement Qemu also seems to run just fine, with SMP enabled (should hit the runtime check?) on a 4.9 LTS kernel. Can someone provide insights into why the requirement is set to 4.14? Br, Kim