[Qemu-devel] [PATCH v3] linux-user: Fix register used for 6th and 7th syscall argument on aarch64
This unbreaks the testcase from http://lists.nongnu.org/archive/html/qemu-arm/2018-01/msg00514.html Thanks to Laurent Vivier for spotting the 7th one. Signed-off-by: Guido Günther <a...@sigxcpu.org> Tested-by: Philippe Mathieu-Daudé <f4...@amsat.org> Suggested-by: Laurent Vivier <laur...@vivier.eu> Reviewed-by: Philippe Mathieu-Daudé <f4...@amsat.org> Reviewed-by: Richard Henderson <richard.hender...@linaro.org> --- v3 collects *-by: replies. Anything else I can do to get this applied? linux-user/host/aarch64/safe-syscall.inc.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux-user/host/aarch64/safe-syscall.inc.S b/linux-user/host/aarch64/safe-syscall.inc.S index 58a2329b37..bc1f5a9792 100644 --- a/linux-user/host/aarch64/safe-syscall.inc.S +++ b/linux-user/host/aarch64/safe-syscall.inc.S @@ -36,7 +36,7 @@ safe_syscall_base: * and return the result in x0 * and the syscall instruction needs * x8 == syscall number -* x0 ... x7 == syscall arguments +* x0 ... x6 == syscall arguments * and returns the result in x0 * Shuffle everything around appropriately. */ @@ -47,8 +47,8 @@ safe_syscall_base: mov x2, x4 mov x3, x5 mov x4, x6 - mov x6, x7 - ldr x7, [sp] + mov x5, x7 + ldr x6, [sp] /* This next sequence of code works in conjunction with the * rewind_if_safe_syscall_function(). If a signal is taken -- 2.15.1
Re: [Qemu-devel] [PATCH 00/11] linux-user: improve NETLINK strace
Hi, On Wed, Jan 24, 2018 at 10:01:15AM -0300, Philippe Mathieu-Daudé wrote: > Few patches I'v been writting while trying to figure out this issue: > http://lists.nongnu.org/archive/html/qemu-arm/2018-01/msg00514.html Whole series Tested-By: Guido Günther <a...@sigxcpu.org> > > Regards, > > Phil. > > Philippe Mathieu-Daudé (11): > linux-user/strace: dump AF_NETLINK sockaddr content > linux-user/strace: improve sendto() output > linux-user/strace: add print_sockaddr_ptr() to handle plain/pointer addrlen > linux-user/strace: improve recvfrom() output > linux-user/strace: improve getsockname() output > linux-user/strace: improve recvmsg() output > linux-user/strace: improve bind() output > linux-user/strace: improve gettimeofday() output > linux-user/strace: improve capget()/capset() output > linux-user/syscall: verify recvfrom(addr) is user-writable > linux-user/syscall: simplify recvfrom() > > linux-user/syscall_defs.h | 7 +++ > linux-user/strace.c | 122 > +- > linux-user/syscall.c | 16 +++--- > linux-user/strace.list| 16 +++--- > 4 files changed, 144 insertions(+), 17 deletions(-) > > -- > 2.15.1 >
Re: [Qemu-devel] [PATCH 00/11] linux-user: improve NETLINK strace
Hi, On Wed, Jan 24, 2018 at 10:01:15AM -0300, Philippe Mathieu-Daudé wrote: > Few patches I'v been writting while trying to figure out this issue: > http://lists.nongnu.org/archive/html/qemu-arm/2018-01/msg00514.html I can't comment code wise but it makes the -strace output much more useful in this area. -- Guido > > Regards, > > Phil. > > Philippe Mathieu-Daudé (11): > linux-user/strace: dump AF_NETLINK sockaddr content > linux-user/strace: improve sendto() output > linux-user/strace: add print_sockaddr_ptr() to handle plain/pointer addrlen > linux-user/strace: improve recvfrom() output > linux-user/strace: improve getsockname() output > linux-user/strace: improve recvmsg() output > linux-user/strace: improve bind() output > linux-user/strace: improve gettimeofday() output > linux-user/strace: improve capget()/capset() output > linux-user/syscall: verify recvfrom(addr) is user-writable > linux-user/syscall: simplify recvfrom() > > linux-user/syscall_defs.h | 7 +++ > linux-user/strace.c | 122 > +- > linux-user/syscall.c | 16 +++--- > linux-user/strace.list| 16 +++--- > 4 files changed, 144 insertions(+), 17 deletions(-) > > -- > 2.15.1 >
Re: [Qemu-devel] [PATCH] linux-user: Fix register used for 6th syscall argument on aarch64
Hi, On Wed, Jan 24, 2018 at 10:59:05AM +0100, Laurent Vivier wrote: > Le 24/01/2018 à 10:14, Guido Günther a écrit : > > Unbreaks the testcase from > > > > http://lists.nongnu.org/archive/html/qemu-arm/2018-01/msg00514.html > > > > Signed-off-by: Guido Günther <a...@sigxcpu.org> > > --- > > linux-user/host/aarch64/safe-syscall.inc.S | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/linux-user/host/aarch64/safe-syscall.inc.S > > b/linux-user/host/aarch64/safe-syscall.inc.S > > index 58a2329b37..e4fbc31454 100644 > > --- a/linux-user/host/aarch64/safe-syscall.inc.S > > +++ b/linux-user/host/aarch64/safe-syscall.inc.S > > @@ -36,7 +36,7 @@ safe_syscall_base: > > * and return the result in x0 > > * and the syscall instruction needs > > * x8 == syscall number > > -* x0 ... x7 == syscall arguments > > +* x0 ... x5 == syscall arguments > > * and returns the result in x0 > > * Shuffle everything around appropriately. > > */ > > @@ -47,7 +47,7 @@ safe_syscall_base: > > mov x2, x4 > > mov x3, x5 > > mov x4, x6 > > - mov x6, x7 > > + mov x5, x7 > > ldr x7, [sp] > > > > /* This next sequence of code works in conjunction with the > > > > According to glibc/unix/sysv/linux/aarch64/syscall.S: > > AArch64 system calls take between 0 and 7 arguments. > ... and any other system call arguments are in register x1..x7. > > And it seems for qemu last argument is on the stack. > ... > x2 ... x7, (stack) == syscall arguments > ... > > Should we have something like this? > > @@ -47,8 +47,8 @@ safe_syscall_base: > mov x2, x4 > mov x3, x5 > mov x4, x6 > - mov x6, x7 > - ldr x7, [sp] > + mov x5, x7 > + ldr x6, [sp] > > /* This next sequence of code works in conjunction with the > * rewind_if_safe_syscall_function(). If a signal is taken > > But do we need to set x7 from the stack too? That makes sense. The maximum number of arguments in linux-user/syscall.c is syscall6 so we won't notice but it's better to have this correct, I'll send an updated patch. Cheers -- Guido
[Qemu-devel] [PATCH] linux-user: Fix register used for 6th and 7th syscall argument on aarch64
Unbreaks the testcase from http://lists.nongnu.org/archive/html/qemu-arm/2018-01/msg00514.html Thanks to Laurent Vivier for spotting the 7th one. Signed-off-by: Guido Günther <a...@sigxcpu.org> --- linux-user/host/aarch64/safe-syscall.inc.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux-user/host/aarch64/safe-syscall.inc.S b/linux-user/host/aarch64/safe-syscall.inc.S index 58a2329b37..bc1f5a9792 100644 --- a/linux-user/host/aarch64/safe-syscall.inc.S +++ b/linux-user/host/aarch64/safe-syscall.inc.S @@ -36,7 +36,7 @@ safe_syscall_base: * and return the result in x0 * and the syscall instruction needs * x8 == syscall number -* x0 ... x7 == syscall arguments +* x0 ... x6 == syscall arguments * and returns the result in x0 * Shuffle everything around appropriately. */ @@ -47,8 +47,8 @@ safe_syscall_base: mov x2, x4 mov x3, x5 mov x4, x6 - mov x6, x7 - ldr x7, [sp] + mov x5, x7 + ldr x6, [sp] /* This next sequence of code works in conjunction with the * rewind_if_safe_syscall_function(). If a signal is taken -- 2.15.1
[Qemu-devel] [PATCH] linux-user: Fix register used for 6th syscall argument on aarch64
Unbreaks the testcase from http://lists.nongnu.org/archive/html/qemu-arm/2018-01/msg00514.html Signed-off-by: Guido Günther <a...@sigxcpu.org> --- linux-user/host/aarch64/safe-syscall.inc.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/host/aarch64/safe-syscall.inc.S b/linux-user/host/aarch64/safe-syscall.inc.S index 58a2329b37..e4fbc31454 100644 --- a/linux-user/host/aarch64/safe-syscall.inc.S +++ b/linux-user/host/aarch64/safe-syscall.inc.S @@ -36,7 +36,7 @@ safe_syscall_base: * and return the result in x0 * and the syscall instruction needs * x8 == syscall number -* x0 ... x7 == syscall arguments +* x0 ... x5 == syscall arguments * and returns the result in x0 * Shuffle everything around appropriately. */ @@ -47,7 +47,7 @@ safe_syscall_base: mov x2, x4 mov x3, x5 mov x4, x6 - mov x6, x7 + mov x5, x7 ldr x7, [sp] /* This next sequence of code works in conjunction with the -- 2.15.1
Re: [Qemu-devel] [PATCH] linux-user/syscall: let recvfrom(struct sockaddr *) use abi_ulong
Hi, On Tue, Jan 23, 2018 at 05:12:26PM +0100, Laurent Vivier wrote: > Le 23/01/2018 à 16:23, Guido Günther a écrit : > > Hi, > > Thanks for having a look! > > > > On Tue, Jan 23, 2018 at 11:52:22AM -0300, Philippe Mathieu-Daudé wrote: > >> Currently recvfrom() is restricted to handle 32-bit pointers, > >> remove this limit for 64-bit hosts. > >> > >> This fixes: > >> > >> 31572 socket(AF_NETLINK, SOCK_RAW, NETLINK_AUDIT) = 3 > >> ... > >> 31572 sendto(3, {{len=124, type=0x454 /* NLMSG_??? */, > >> flags=NLM_F_REQUEST|NLM_F_ACK, seq=1, pid=0}, "op=test:message acct=\"?\" > >> exe=\"/tmp/nl-bad-addr\" hostname=localhost addr=? terminal=/dev/pts/2 > >> res=success\0\0\0"}, 124, 0, 0xfa3897d0, 0) = 124 > >> 31572 ppoll([{fd=3, events=POLLIN}], 1, {tv_sec=0, tv_nsec=5}, > >> NULL, 0) = 1 ([{fd=3, revents=POLLIN}], left {tv_sec=0, tv_nsec=43180}) > >> 31572 recvfrom(3, 0x112a50eb4, 8988, MSG_PEEK|MSG_DONTWAIT, > >> 0xfa3897e0, 0x42) = -1 EFAULT (Bad address) > >> > >> Reported-by: Guido Günther <a...@sigxcpu.org> > >> Message-id: 20180123120541.ga14...@bogon.m.sigxcpu.org > >> Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> > >> --- > >> linux-user/syscall.c | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/linux-user/syscall.c b/linux-user/syscall.c > >> index 11c9116c4a..28805b1785 100644 > >> --- a/linux-user/syscall.c > >> +++ b/linux-user/syscall.c > >> @@ -4032,7 +4032,7 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, > >> size_t len, int flags, > >> if (!host_msg) > >> return -TARGET_EFAULT; > >> if (target_addr) { > >> -if (get_user_u32(addrlen, target_addrlen)) { > >> +if (get_user_ual(addrlen, target_addrlen)) { > >> ret = -TARGET_EFAULT; > >> goto fail; > >> } > >> @@ -4053,7 +4053,7 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, > >> size_t len, int flags, > >> } > >> if (target_addr) { > >> host_to_target_sockaddr(target_addr, addr, addrlen); > >> -if (put_user_u32(addrlen, target_addrlen)) { > >> +if (put_user_ual(addrlen, target_addrlen)) { > >> ret = -TARGET_EFAULT; > >> goto fail; > >> } > > > > Ahh...I saw these and was wondering how this would work on > > 64bit. Unfortunately the patch doesn't change things: > > > > 4824 recvfrom(3, 0x1401f8eb4, 8988, MSG_PEEK|MSG_DONTWAIT, > > 0xe10a8620, 0x42) = -1 EFAULT (Bad address) > > > > If you want me to report qemu -strace or s.th. please let me know. > > Cheers, > > -- Guido > > > > Could you try: > > strace -f chroot . /usr/bin/qemu-arm-static tmp/nl-bad-addr > > to see if the fault comes from the kernel or from QEMU. Full strace is attached of strace -f -s2048 -onl-bad-addr.strace chroot armhf-chroot/ tmp/qemu-arm-static tmp/a.out is attched. The error is at the very end. Cheers, -- Guido 9559 execve("/usr/sbin/chroot", ["chroot", "armhf-chroot/", "tmp/qemu-arm-static", "tmp/a.out"], [/* 20 vars */]) = 0 9559 brk(NULL) = 0xe718a000 9559 faccessat(AT_FDCWD, "/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) 9559 mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x8e8a4000 9559 faccessat(AT_FDCWD, "/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) 9559 openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 9559 fstat(3, {st_mode=S_IFREG|0644, st_size=16129, ...}) = 0 9559 mmap(NULL, 16129, PROT_READ, MAP_PRIVATE, 3, 0) = 0x8e8a 9559 close(3) = 0 9559 faccessat(AT_FDCWD, "/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) 9559 openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 9559 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\270\364\1\0\0\0\0\0@\0\0\0\0\0\0\0Xd\23\0\0\0\0\0\0\0\0\0@\0008\0\n\0@\0K\0J\0\6\0\0\0\5\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\\2\0\0\0\0\0\\2\0\0\0\0\0\0\10\0\0\0\0\0\0\0\3\0\0\0\4\0\0\0\370\16\22\0\0\0\0\0\370\16\22\0\0\0\0\0\370\16\22\0\0\0\0\0\33\0\0\0\0\0\0\0\33\0\0\0\0\0\0\0\10\0\0\0\0\0\0\0\1\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
Re: [Qemu-devel] [PATCH] linux-user/syscall: let recvfrom(struct sockaddr *) use abi_ulong
Hi, Thanks for having a look! On Tue, Jan 23, 2018 at 11:52:22AM -0300, Philippe Mathieu-Daudé wrote: > Currently recvfrom() is restricted to handle 32-bit pointers, > remove this limit for 64-bit hosts. > > This fixes: > > 31572 socket(AF_NETLINK, SOCK_RAW, NETLINK_AUDIT) = 3 > ... > 31572 sendto(3, {{len=124, type=0x454 /* NLMSG_??? */, > flags=NLM_F_REQUEST|NLM_F_ACK, seq=1, pid=0}, "op=test:message acct=\"?\" > exe=\"/tmp/nl-bad-addr\" hostname=localhost addr=? terminal=/dev/pts/2 > res=success\0\0\0"}, 124, 0, 0xfa3897d0, 0) = 124 > 31572 ppoll([{fd=3, events=POLLIN}], 1, {tv_sec=0, tv_nsec=5}, > NULL, 0) = 1 ([{fd=3, revents=POLLIN}], left {tv_sec=0, tv_nsec=43180}) > 31572 recvfrom(3, 0x112a50eb4, 8988, MSG_PEEK|MSG_DONTWAIT, 0xfa3897e0, > 0x42) = -1 EFAULT (Bad address) > > Reported-by: Guido Günther <a...@sigxcpu.org> > Message-id: 20180123120541.ga14...@bogon.m.sigxcpu.org > Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> > --- > linux-user/syscall.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/linux-user/syscall.c b/linux-user/syscall.c > index 11c9116c4a..28805b1785 100644 > --- a/linux-user/syscall.c > +++ b/linux-user/syscall.c > @@ -4032,7 +4032,7 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, > size_t len, int flags, > if (!host_msg) > return -TARGET_EFAULT; > if (target_addr) { > -if (get_user_u32(addrlen, target_addrlen)) { > +if (get_user_ual(addrlen, target_addrlen)) { > ret = -TARGET_EFAULT; > goto fail; > } > @@ -4053,7 +4053,7 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, > size_t len, int flags, > } > if (target_addr) { > host_to_target_sockaddr(target_addr, addr, addrlen); > -if (put_user_u32(addrlen, target_addrlen)) { > +if (put_user_ual(addrlen, target_addrlen)) { > ret = -TARGET_EFAULT; > goto fail; > } Ahh...I saw these and was wondering how this would work on 64bit. Unfortunately the patch doesn't change things: 4824 recvfrom(3, 0x1401f8eb4, 8988, MSG_PEEK|MSG_DONTWAIT, 0xe10a8620, 0x42) = -1 EFAULT (Bad address) If you want me to report qemu -strace or s.th. please let me know. Cheers, -- Guido
Re: [Qemu-devel] [PATCH] Add guest-get-hostname to retrieve the guests current hostname
On Wed, Aug 22, 2012 at 09:32:02AM +0100, Daniel P. Berrange wrote: On Wed, Aug 22, 2012 at 10:04:33AM +0200, Guido Günther wrote: On Tue, Aug 21, 2012 at 07:31:17PM +0100, Daniel P. Berrange wrote: On Tue, Aug 21, 2012 at 01:57:54PM +0200, Guido Günther wrote: [..snip..] Why no impl ? Winsock has the gethostname() API too $ grep gethostname /usr/i686-w64-mingw32/sys-root/mingw/include/*.h /usr/i686-w64-mingw32/sys-root/mingw/include/winsock2.h: WINSOCK_API_LINKAGE int WSAAPI gethostname(char *name,int namelen); This was mostly due to the lack of a test system. Are there any pointers on how to cross compile qemu-qa for Windows? Assuming you have the Mingw64 toolchain installed, then compilation is just a case of passing the --cross-prefix arg to configure. eg on Fedora 17 I would do: ./configure --target-list=x86_64-softmmu --cross-prefix=i686-w64-mingw32- which causes it to use i686-w64-mingw32-gcc as the compiler That helped! I had to additionally install mingw32-pkg-config mingw32-zlib mingw32-glib2 to cross build qemu-ga. Howver running this on a win7-pro evaluation version I get: .\qemu-ga timestamp: critical: error opening path timestamp: critical: error opening channel timestamp: critical: failed to create guest agent channel timestamp: critical: failed to initialize guest agent channel qemu-ga is current git while the host is qemu-kvm 1.1.0. The virtio serial driver is installed in the guest but running the test program gives errors as well: .\VIOSER-TEST Running in non blocking mode. Cannot find vioserial device \\?\.\{uuid}#vioserialport#... , error 5 Libvirt creates the guest agent channel via: channel type='unix' source mode='bind' path='/var/lib/libvirt/qemu/win7-32.agent'/ target type='virtio' name='org.qemu.guest_agent.0'/ alias name='channel0'/ address type='virtio-serial' controller='0' bus='0' port='1'/ /channel While the same works well with linux guests. Any ideas what I'm missing on the Windows side? Cheers, -- Guido Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Re: [Qemu-devel] [PATCH] Add guest-get-hostname to retrieve the guests current hostname
On Tue, Aug 21, 2012 at 07:31:17PM +0100, Daniel P. Berrange wrote: On Tue, Aug 21, 2012 at 01:57:54PM +0200, Guido Günther wrote: [..snip..] Why no impl ? Winsock has the gethostname() API too $ grep gethostname /usr/i686-w64-mingw32/sys-root/mingw/include/*.h /usr/i686-w64-mingw32/sys-root/mingw/include/winsock2.h: WINSOCK_API_LINKAGE int WSAAPI gethostname(char *name,int namelen); This was mostly due to the lack of a test system. Are there any pointers on how to cross compile qemu-qa for Windows? Cheers, -- Guido Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
[Qemu-devel] [PATCH] Add guest-get-hostname to retrieve the guests current hostname
This allows to retrieve the guest's hostname via gethostname(2). This can be useful to identify a VM e.g. one without network. Signed-off-by: Guido Günther a...@sigxcpu.org --- We have an API in libvirt for that (virDomainGetHostname). Cheers -- Guido qapi-schema-guest.json | 12 qga/commands-posix.c | 12 qga/commands-win32.c |6 ++ 3 files changed, 30 insertions(+) diff --git a/qapi-schema-guest.json b/qapi-schema-guest.json index d955cf1..8c7a4a5 100644 --- a/qapi-schema-guest.json +++ b/qapi-schema-guest.json @@ -515,3 +515,15 @@ ## { 'command': 'guest-network-get-interfaces', 'returns': ['GuestNetworkInterface'] } + +## +# @guest-get-hostname: +# +# Get the guest's hostname +# +# Returns: The guest's hostname +# +# Since: 1.2 +## +{ 'command': 'guest-get-hostname', + 'returns': 'str' } diff --git a/qga/commands-posix.c b/qga/commands-posix.c index ce90421..9223f18 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -15,6 +15,7 @@ #include sys/types.h #include sys/ioctl.h #include sys/wait.h +#include unistd.h #include qga/guest-agent-core.h #include qga-qmp-commands.h #include qerror.h @@ -993,6 +994,17 @@ void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err) } #endif +char *qmp_guest_get_hostname(Error **err) +{ +char hostname[HOST_NAME_MAX]; + +if (gethostname(hostname, HOST_NAME_MAX)) { +error_set(err, QERR_QGA_COMMAND_FAILED, strerror(errno)); +return NULL; +} +return g_strdup(hostname); +} + /* register init/cleanup routines for stateful command groups */ void ga_command_state_init(GAState *s, GACommandState *cs) { diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 54bc546..55e8162 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -280,6 +280,12 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **err) return NULL; } +char *qmp_guest_get_hostname(Error **err) +{ +error_set(err, QERR_UNSUPPORTED); +return NULL; +} + /* register init/cleanup routines for stateful command groups */ void ga_command_state_init(GAState *s, GACommandState *cs) { -- 1.7.10.4