Syscall 269
Hi All,
I am trying to chroot to a gentoo flavor of arm linux on my AMD tbird-1.4GHz. I have set up binfmt_misc and qemu to allow me to do the chroot, and all seems to be working well. Now I wanted to emerge some stuff, and I get the following message:
qemu: Unsupported syscall: 269.
Looking at the arm linux kernel source, I see that 269 is utimes. Looking at the source code for qemu it seems that all I have to do is to add a define for TARGET_NR_utimes in all linux-user/*/syscall_nr.h and then add a new case in linux-user/syscall.c.
So, I gave it a shot. The patch is at the bottom of this message. This is the first time I have looked at the qemu sources, so I am likely missing something, but the patch does seem to allow emerge to work properly under gentoo. If a correct implementation requires more work, I am happy to do that too, just let me know. BTW, I am not subscribed to this list to please CC me.
Many thanks for a wonderful app.
Cheers,
Signature · 47 lines
*****************************
James A. Pellow, President
Alent Design Solutions
www.alentdesignsolutions.com
(509) 526-0682
*****************************
diff -ruN qemu-0.6.1/linux-user/arm/syscall_nr.h
qemu-0.6.1_new/linux-user/arm/syscall_nr.h
--- qemu-0.6.1/linux-user/arm/syscall_nr.h 2004-11-14 12:51:33.000000000
-0800
+++ qemu-0.6.1_new/linux-user/arm/syscall_nr.h 2004-11-18 00:58:44.973757936
-0800
@@ -259,3 +259,5 @@
/* 254 for set_thread_area */
/* 255 for get_thread_area */
/* 256 for set_tid_address */
+#define TARGET_NR_utimes (269)
+
diff -ruN qemu-0.6.1/linux-user/i386/syscall_nr.h
qemu-0.6.1_new/linux-user/i386/syscall_nr.h
--- qemu-0.6.1/linux-user/i386/syscall_nr.h 2004-11-14 12:51:33.000000000
-0800
+++ qemu-0.6.1_new/linux-user/i386/syscall_nr.h 2004-11-18 01:28:59.324934632
-0800
@@ -271,3 +271,5 @@
#define TARGET_NR_clock_getres (TARGET_NR_timer_create+7)
#define TARGET_NR_clock_nanosleep (TARGET_NR_timer_create+8)
+#define TARGET_NR_utimes 271
+
diff -ruN qemu-0.6.1/linux-user/syscall.c qemu-0.6.1_new/linux-user/syscall.c
--- qemu-0.6.1/linux-user/syscall.c 2004-11-14 12:51:33.000000000 -0800
+++ qemu-0.6.1_new/linux-user/syscall.c 2004-11-18 01:15:54.561236848 -0800
@@ -3025,6 +3025,10 @@
case TARGET_NR_get_thread_area:
goto unimplemented_nowarn;
#endif
+ case TARGET_NR_utimes:
+ ret = get_errno(utimes((const char *)arg1,
+ (const struct timeval *)arg2));
+ break;
default:
unimplemented:
gemu_log("qemu: Unsupported syscall: %d\n", num);Quoted 14 lines · James Pellow
Hi All,
I am trying to chroot to a gentoo flavor of arm linux on my AMD tbird-1.4GHz. I have set up
binfmt_miscand qemu to allow me to do the chroot, and all seems to be working well. Now I wanted to emerge some stuff, and I get the following message:qemu: Unsupported syscall: 269.
Looking at the arm linux kernel source, I see that 269 is utimes. Looking at the source code for qemu it seems that all I have to do is to add a define for
TARGET_NR_utimesin alllinux-user/*/syscall_nr.hand then add a new case inlinux-user/syscall.c.
Quoted 6 lines
So, I gave it a shot. The patch is at the bottom of this message. This is the first time I have looked at the qemu sources, so I am likely missing something, but the patch does seem to allow emerge to work properly under gentoo. If a correct implementation requires more work, I am happy to do that too, just let me know. BTW, I am not subscribed to this list to please CC me.
You also need to do proper 32/64bit and big/little endian conversion of struct timeval. It happens to work in your case because arm-linux and i686-linux both use the same word size and endianness.
Paul
Yes, I thought about that, and realized I wouldn't have a problem in my case. I'll take a closer look at the syscall.c file and see how that was done for other syscalls, and see if I can get a better patch put together. Thanks for the reply.
-James
Quoted 27 lines · you
Quoted 14 lines · James Pellow
Hi All,
I am trying to chroot to a gentoo flavor of arm linux on my AMD tbird-1.4GHz. I have set up
binfmt_miscand qemu to allow me to do the chroot, and all seems to be working well. Now I wanted to emerge some stuff, and I get the following message:qemu: Unsupported syscall: 269.
Looking at the arm linux kernel source, I see that 269 is utimes. Looking at the source code for qemu it seems that all I have to do is to add a define for
TARGET_NR_utimesin alllinux-user/*/syscall_nr.hand then add a new case inlinux-user/syscall.c.Quoted 6 lines
So, I gave it a shot. The patch is at the bottom of this message. This is the first time I have looked at the qemu sources, so I am likely missing something, but the patch does seem to allow emerge to work properly under gentoo. If a correct implementation requires more work, I am happy to do that too, just let me know. BTW, I am not subscribed to this list to please CC me.
You also need to do proper 32/64bit and big/little endian conversion of struct timeval. It happens to work in your case because arm-linux and i686-linux both use the same word size and endianness.
Paul
Signature · 6 lines
***************************** James A. Pellow, President Alent Design Solutions www.alentdesignsolutions.com (509) 526-0682 *****************************
Hi Paul,
Is this closer to what you want? I saw the swap functions. I wasn't sure what long translated to for all supported archs. Do I need to do 32/64 bit translation? tv_sec and tv_usec are both long.
Thanks,
James Pellow
------------------------------------------------------------------------------------------------------------
diff -ruN qemu-0.6.1/linux-user/arm/syscall_nr.h qemu-0.6.1_new/linux-user/arm/syscall_nr.h
--- qemu-0.6.1/linux-user/arm/syscall_nr.h 2004-11-14 12:51:33.000000000
-0800
+++ qemu-0.6.1_new/linux-user/arm/syscall_nr.h 2004-11-18 00:58:44.000000000 -0800
@@ -259,3 +259,5 @@
/* 254 for set_thread_area */
/* 255 for get_thread_area */
/* 256 for set_tid_address */+#define TARGET_NR_utimes (269)
+
diff -ruN qemu-0.6.1/linux-user/i386/syscall_nr.h qemu-0.6.1_new/linux-user/i386/syscall_nr.h
--- qemu-0.6.1/linux-user/i386/syscall_nr.h 2004-11-14 12:51:33.000000000
-0800
+++ qemu-0.6.1_new/linux-user/i386/syscall_nr.h 2004-11-18 01:28:59.000000000 -0800
@@ -271,3 +271,5 @@
#define TARGET_NR_clock_getres (TARGET_NR_timer_create+7)
#define TARGET_NR_clock_nanosleep (TARGET_NR_timer_create+8)
+#define TARGET_NR_utimes 271
+
linux-user/syscall.c 2004-12-03 15:44:37.174197904 -0800 renamed from linux-user/syscall.c 2004-11-14 12:51:33.000000000 -0800 +9 -0
@@ -3025,6 +3025,15 @@ case TARGET_NR_get_thread_area: goto unimplemented_nowarn; #endif + case TARGET_NR_utimes: + { + struct timeval tv; + struct timeval *target_tv = (struct timeval *)arg2; + tv.tv_sec = tswapl(target_tv->tv_sec); + tv.tv_usec = tswapl(target_tv->tv_usec); + ret = get_errno(utimes((const char *)arg1, &tv)); + break; + } default: unimplemented: gemu_log("qemu: Unsupported syscall: %d\n", num);
------------------------------------------------------------------------------------------------------------------------
Quoted 27 lines · Paul Brook
Quoted 14 lines · James Pellow
Hi All,
I am trying to chroot to a gentoo flavor of arm linux on my AMD tbird-1.4GHz. I have set up
binfmt_miscand qemu to allow me to do the chroot, and all seems to be working well. Now I wanted to emerge some stuff, and I get the following message:qemu: Unsupported syscall: 269.
Looking at the arm linux kernel source, I see that 269 is utimes. Looking at the source code for qemu it seems that all I have to do is to add a define for
TARGET_NR_utimesin alllinux-user/*/syscall_nr.hand then add a new case inlinux-user/syscall.c.Quoted 6 lines
So, I gave it a shot. The patch is at the bottom of this message. This is the first time I have looked at the qemu sources, so I am likely missing something, but the patch does seem to allow emerge to work properly under gentoo. If a correct implementation requires more work, I am happy to do that too, just let me know. BTW, I am not subscribed to this list to please CC me.
You also need to do proper 32/64bit and big/little endian conversion of struct timeval. It happens to work in your case because arm-linux and i686-linux both use the same word size and endianness.
Paul
Signature · 6 lines
***************************** James A. Pellow, President Alent Design Solutions www.alentdesignsolutions.com (509) 526-0682 *****************************
Quoted 5 lines · James Pellow
Hi Paul,
Is this closer to what you want? I saw the swap functions. I wasn't sure what long translated to for all supported archs. Do I need to do 32/64 bit translation?
tv_secandtv_usecare both long.
There is already code to properly handle struct timeval, you should use that. See the code for TARGET_NR_settimeofday.
Paul
Hi Paul,
Ok, third time is the charm right... It looks like the functions you referred to that handle struct timeval, are doing exactly what I had done. Here is an updated patch that factors out the swap code using the existing function. Hopefully this is ready for inclusion. Thanks for your help with this and for a truely incredible project!
-James Pellow
-----------------------------------------------------------------------------------------------------------------
diff -ruN qemu-0.6.1/linux-user/arm/syscall_nr.h qemu-0.6.1_new/linux-user/arm/syscall_nr.h
--- qemu-0.6.1/linux-user/arm/syscall_nr.h 2004-11-14 12:51:33.000000000
-0800
+++ qemu-0.6.1_new/linux-user/arm/syscall_nr.h 2004-11-18 00:58:44.000000000 -0800
@@ -259,3 +259,5 @@
/* 254 for set_thread_area */
/* 255 for get_thread_area */
/* 256 for set_tid_address */+#define TARGET_NR_utimes (269)
+
diff -ruN qemu-0.6.1/linux-user/i386/syscall_nr.h qemu-0.6.1_new/linux-user/i386/syscall_nr.h
--- qemu-0.6.1/linux-user/i386/syscall_nr.h 2004-11-14 12:51:33.000000000
-0800
+++ qemu-0.6.1_new/linux-user/i386/syscall_nr.h 2004-11-18 01:28:59.000000000 -0800
@@ -271,3 +271,5 @@
#define TARGET_NR_clock_getres (TARGET_NR_timer_create+7)
#define TARGET_NR_clock_nanosleep (TARGET_NR_timer_create+8)
+#define TARGET_NR_utimes 271
+
linux-user/syscall.c 2004-12-05 17:03:18.278887920 -0800 renamed from linux-user/syscall.c 2004-11-14 12:51:33.000000000 -0800 +8 -0
@@ -3025,6 +3025,14 @@ case TARGET_NR_get_thread_area: goto unimplemented_nowarn; #endif + case TARGET_NR_utimes: + { + struct target_timeval *target_tv = (void *)arg2; + struct timeval tv; + target_to_host_timeval(&tv, target_tv); + ret = get_errno(utimes((const char *)arg1, &tv)); + break; + } default: unimplemented: gemu_log("qemu: Unsupported syscall: %d\n", num);
-----------------------------------------------------------------------------------------------------------------
Quoted 11 lines · Paul Brook
Quoted 5 lines · James Pellow
Hi Paul,
Is this closer to what you want? I saw the swap functions. I wasn't sure what long translated to for all supported archs. Do I need to do 32/64 bit translation?
tv_secandtv_usecare both long.There is already code to properly handle struct timeval, you should use that. See the code for
TARGET_NR_settimeofday.Paul
Signature · 6 lines
***************************** James A. Pellow, President Alent Design Solutions www.alentdesignsolutions.com (509) 526-0682 *****************************
Quoted 7 lines · James Pellow
Hi Paul,
Ok, third time is the charm right... It looks like the functions you referred to that handle struct timeval, are doing exactly what I had done. Here is an updated patch that factors out the swap code using the existing function. Hopefully this is ready for inclusion. Thanks for your help with this and for a truely incredible project!
Still not quite there. utimes takes [a pointer to] an array of two struct timeval. You only thunk the first one.
Paul
Hi Paul,
Ok, you got me that time. I guess I have been trying to hury my way through this to get it working. The man page I was looking at that defined utimes defines it as:
int utimes(char *filename, struct timeval *tvp);
If you go looking further in the page, a discussion is found about *tvp actually being a two member array. I hadn't looked down that far I guess. (a bit red in the face...) So, this should be it:
--------------------------------------------------------------------------------------------------------
diff -ruN qemu-0.6.1/linux-user/arm/syscall_nr.h qemu-0.6.1_new/linux-user/arm/syscall_nr.h
--- qemu-0.6.1/linux-user/arm/syscall_nr.h 2004-11-14 12:51:33.000000000
-0800
+++ qemu-0.6.1_new/linux-user/arm/syscall_nr.h 2004-11-18 00:58:44.000000000 -0800
@@ -259,3 +259,5 @@
/* 254 for set_thread_area */
/* 255 for get_thread_area */
/* 256 for set_tid_address */+#define TARGET_NR_utimes (269)
+
diff -ruN qemu-0.6.1/linux-user/i386/syscall_nr.h qemu-0.6.1_new/linux-user/i386/syscall_nr.h
--- qemu-0.6.1/linux-user/i386/syscall_nr.h 2004-11-14 12:51:33.000000000
-0800
+++ qemu-0.6.1_new/linux-user/i386/syscall_nr.h 2004-11-18 01:28:59.000000000 -0800
@@ -271,3 +271,5 @@
#define TARGET_NR_clock_getres (TARGET_NR_timer_create+7)
#define TARGET_NR_clock_nanosleep (TARGET_NR_timer_create+8)
+#define TARGET_NR_utimes 271
+
linux-user/syscall.c 2004-12-05 18:49:23.208271576 -0800 renamed from linux-user/syscall.c 2004-11-14 12:51:33.000000000 -0800 +9 -0
@@ -3025,6 +3025,15 @@ case TARGET_NR_get_thread_area: goto unimplemented_nowarn; #endif + case TARGET_NR_utimes: + { + struct target_timeval *target_tv = (void *)arg2; + struct timeval tv[2]; + target_to_host_timeval(&tv[0], &target_tv[0]); + target_to_host_timeval(&tv[1], &target_tv[1]); + ret = get_errno(utimes((const char *)arg1, tv)); + break; + } default: unimplemented: gemu_log("qemu: Unsupported syscall: %d\n", num);
---------------------------------------------------------------------------------------------------------------------------
Thanks for your help.
-James Pellow
Quoted 13 lines · Paul Brook
Quoted 7 lines · James Pellow
Hi Paul,
Ok, third time is the charm right... It looks like the functions you referred to that handle struct timeval, are doing exactly what I had done. Here is an updated patch that factors out the swap code using the existing function. Hopefully this is ready for inclusion. Thanks for your help with this and for a truely incredible project!
Still not quite there. utimes takes [a pointer to] an array of two struct timeval. You only thunk the first one.
Paul
Signature · 6 lines
***************************** James A. Pellow, President Alent Design Solutions www.alentdesignsolutions.com (509) 526-0682 *****************************
[Qemu-devel] Trivial (but useful) patch to save qemu pid to file
In reply to James PellowHi everyone,
Here's a very trivial patch that allows qemu's pid to be saved to a file. This is useful if you're using qemu as a service, instrumenting
it with other code, or doing other unixy things,
cheers,
Nile
---------------------------------------------------------------------------------------------------
vl.c 2004-12-08 00:11:34.232243744 -0500 renamed from vl.c 2004-12-07 22:11:54.898668344 -0500 +0 -0
@@ -2549,6 +2549,7 @@ " (default is CL-GD5446 PCI VGA)\n" #endif "-loadvm file start right away with a saved state (loadvm in
monitor)\n"
+ "-pid file save the qemu process id to a file\n"
"\n"
"During emulation, the following keys are useful:\n"
"ctrl-alt-f toggle full screen\n"
@@ -2619,6 +2620,7 @@
QEMU_OPTION_prep,
QEMU_OPTION_localtime,
QEMU_OPTION_cirrusvga,
+ QEMU_OPTION_pid,
QEMU_OPTION_g,
QEMU_OPTION_std_vga,
QEMU_OPTION_monitor,
@@ -2689,6 +2691,7 @@
/* temporary options */
{ "pci", 0, QEMU_OPTION_pci },
{ "cirrusvga", 0, QEMU_OPTION_cirrusvga },
+ { "pid", HAS_ARG, QEMU_OPTION_pid },
{ NULL },};
@@ -2765,6 +2768,8 @@
char serial_devices[MAX_SERIAL_PORTS][128];
int serial_device_index;
const char *loadvm = NULL;+ int pid;
+ FILE * pid_file;
#if !defined(CONFIG_SOFTMMU)
/* we never want that malloc() uses mmap() */
@@ -3110,6 +3115,11 @@
case QEMU_OPTION_full_screen:
full_screen = 1;
break;
+ case QEMU_OPTION_pid:
+ pid = getpid();
+ pid_file = fopen(optarg, "w");
+ fprintf(pid_file, "%d", pid);
+ fclose(pid_file);
}
}
}Re: [Qemu-devel] Trivial (but useful) patch to save qemu pid to file
Quoted 3 lines · Nile Geisinger
Here's a very trivial patch that allows qemu's pid to be saved to a file. This is useful if you're using qemu as a service, instrumenting it with other code, or doing other unixy things,
Hello Nile, a somewhat more complete patch for doing this was already posted a while ago:
http://lists.gnu.org/archive/html/qemu-devel/2004-11/msg00450.html
Any comments are very welcome :-)
Re: [Qemu-devel] Trivial (but useful) patch to save qemu pid to file
Quoted 10 lines · Felipe Sanchez
Quoted 3 lines · Nile Geisinger
Here's a very trivial patch that allows qemu's pid to be saved to a file. This is useful if you're using qemu as a service, instrumenting it with other code, or doing other unixy things,
Quoted 7 lines
Hello Nile, a somewhat more complete patch for doing this was already posted a while ago:
http://lists.gnu.org/archive/html/qemu-devel/2004-11/msg00450.html
Any comments are very welcome :-)
I can include this patch if it helps some people as it seems rather non intrusive.
Fabrice.
Re: [Qemu-devel] Trivial (but useful) patch to save qemu pid to file
Quoted 2 lines
I can include this patch if it helps some people as it seems rather non intrusive.
I personally rather manage my daemons with something like daemontools or runit:
http://cr.yp.to/daemontools.html
http://smarden.org/runit/
But like you say, it is pretty non-intrusive as it is off by default. For some it will probably help out.
tim
Re: [Qemu-devel] Trivial (but useful) patch to save qemu pid to file
In reply to Fabrice BellardHi Fabrice,
First, thanks for QEMU!
I find it useful and the previous patcher found it useful, but I'm fine patching for now. When a third person posts a patch, though, it should probably be included since it would be a sign that QEMU is being increasingly instrumented by other programs,
cheers,
Nile
Quoted 25 lines · Fabrice Bellard
Quoted 5 lines · Felipe Sanchez
Quoted 3 lines · Nile Geisinger
Here's a very trivial patch that allows qemu's pid to be saved to a file. This is useful if you're using qemu as a service, instrumenting it with other code, or doing other unixy things,
Quoted 7 lines
Hello Nile, a somewhat more complete patch for doing this was already posted a while ago:
http://lists.gnu.org/archive/html/qemu-devel/2004-11/msg00450.html
Any comments are very welcome :-)
I can include this patch if it helps some people as it seems rather non intrusive.
Fabrice.
_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel