[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 09/16] bsd-user: h2g_rusage
From: |
Warner Losh |
Subject: |
[PATCH 09/16] bsd-user: h2g_rusage |
Date: |
Wed, 5 Apr 2023 15:36:05 -0600 |
From: Stacey Son <sson@FreeBSD.org>
Converts host's rusage to the guest's rusage.
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/bsd-proc.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
bsd-user/meson.build | 1 +
bsd-user/qemu-bsd.h | 30 +++++++++++++++++++++++++++
3 files changed, 79 insertions(+)
create mode 100644 bsd-user/bsd-proc.c
create mode 100644 bsd-user/qemu-bsd.h
diff --git a/bsd-user/bsd-proc.c b/bsd-user/bsd-proc.c
new file mode 100644
index 00000000000..e64eb958947
--- /dev/null
+++ b/bsd-user/bsd-proc.c
@@ -0,0 +1,48 @@
+/*
+ * BSD process related system call helpers
+ *
+ * Copyright (c) 2013-14 Stacey D. Son
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#include "qemu/osdep.h"
+
+#include "qemu.h"
+#include "qemu-bsd.h"
+#include "signal-common.h"
+
+void h2g_rusage(const struct rusage *rusage,
+ struct target_freebsd_rusage *target_rusage)
+{
+ __put_user(rusage->ru_utime.tv_sec, &target_rusage->ru_utime.tv_sec);
+ __put_user(rusage->ru_utime.tv_usec, &target_rusage->ru_utime.tv_usec);
+
+ __put_user(rusage->ru_stime.tv_sec, &target_rusage->ru_stime.tv_sec);
+ __put_user(rusage->ru_stime.tv_usec, &target_rusage->ru_stime.tv_usec);
+
+ __put_user(rusage->ru_maxrss, &target_rusage->ru_maxrss);
+ __put_user(rusage->ru_idrss, &target_rusage->ru_idrss);
+ __put_user(rusage->ru_idrss, &target_rusage->ru_idrss);
+ __put_user(rusage->ru_isrss, &target_rusage->ru_isrss);
+ __put_user(rusage->ru_minflt, &target_rusage->ru_minflt);
+ __put_user(rusage->ru_majflt, &target_rusage->ru_majflt);
+ __put_user(rusage->ru_nswap, &target_rusage->ru_nswap);
+ __put_user(rusage->ru_inblock, &target_rusage->ru_inblock);
+ __put_user(rusage->ru_oublock, &target_rusage->ru_oublock);
+ __put_user(rusage->ru_msgsnd, &target_rusage->ru_msgsnd);
+ __put_user(rusage->ru_msgrcv, &target_rusage->ru_msgrcv);
+ __put_user(rusage->ru_nsignals, &target_rusage->ru_nsignals);
+ __put_user(rusage->ru_nvcsw, &target_rusage->ru_nvcsw);
+ __put_user(rusage->ru_nivcsw, &target_rusage->ru_nivcsw);
+}
diff --git a/bsd-user/meson.build b/bsd-user/meson.build
index 5243122fc56..7d1b4de78b1 100644
--- a/bsd-user/meson.build
+++ b/bsd-user/meson.build
@@ -8,6 +8,7 @@ common_user_inc += include_directories('include')
bsd_user_ss.add(files(
'bsdload.c',
+ 'bsd-proc.c',
'elfload.c',
'main.c',
'mmap.c',
diff --git a/bsd-user/qemu-bsd.h b/bsd-user/qemu-bsd.h
new file mode 100644
index 00000000000..96e7f34b27c
--- /dev/null
+++ b/bsd-user/qemu-bsd.h
@@ -0,0 +1,30 @@
+/*
+ * BSD conversion extern declarations
+ *
+ * Copyright (c) 2013 Stacey D. Son
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef QEMU_BSD_H
+#define QEMU_BSD_H
+
+#include <sys/types.h>
+#include <sys/resource.h>
+
+/* bsd-proc.c */
+void h2g_rusage(const struct rusage *rusage,
+ struct target_freebsd_rusage *target_rusage);
+
+#endif /* QEMU_BSD_H */
--
2.40.0
- [PATCH 00/16] bsd-user 2023 Q2 first batch, Warner Losh, 2023/04/05
- [PATCH 02/16] bsd-user: Ifdef a few MAP_ constants for NetBSD, Warner Losh, 2023/04/05
- [PATCH 04/16] bsd-user: Move system FreeBSD call table to freebsd/os-syscall.c, Warner Losh, 2023/04/05
- [PATCH 01/16] bsd-user: Make print_* public, Warner Losh, 2023/04/05
- [PATCH 08/16] bsd-user: Remove useless mmap definitions, Warner Losh, 2023/04/05
- [PATCH 09/16] bsd-user: h2g_rusage,
Warner Losh <=
- [PATCH 03/16] bsd-user: Cleanup style., Warner Losh, 2023/04/05
- [PATCH 05/16] bsd-user: Remove NetBSD specific syscall printing, Warner Losh, 2023/04/05
- [PATCH 06/16] bsd-user: Remove OpenBSD specific syscall printing, Warner Losh, 2023/04/05
- [PATCH 13/16] bsd-user: Implement sysctl kern.proc, except kern.proc.full_path, Warner Losh, 2023/04/05
- [PATCH 11/16] bsd-user: Implement do_sysctl_kern_proc_filedesc, Warner Losh, 2023/04/05