[PATCH 1/8] ioctl: add a stub for decoding kvm related ioctls

Masatake YAMATO yamato at redhat.com
Fri Dec 1 05:45:51 UTC 2017


* kvm.c: New file.
* Makefile.am (strace_SOURCES): Add kvm.c.
* configure.ac: Check the existence of linux/kvm.h.
* defs.h: Declare `kvm' as ioctl doecoder.
* ioctl.c: Call `kvm_ioctl'.

Signed-off-by: Masatake YAMATO <yamato at redhat.com>
---
 Makefile.am  |  1 +
 configure.ac |  1 +
 defs.h       |  1 +
 ioctl.c      |  4 ++++
 kvm.c        | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 57 insertions(+)
 create mode 100644 kvm.c

diff --git a/Makefile.am b/Makefile.am
index 2586a3e0..60376056 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -166,6 +166,7 @@ strace_SOURCES =	\
 	kexec.c		\
 	keyctl.c	\
 	keyctl_kdf_params.h \
+	kvm.c \
 	ldt.c		\
 	link.c		\
 	linux/asm_stat.h \
diff --git a/configure.ac b/configure.ac
index 2fc45b76..fa451d84 100644
--- a/configure.ac
+++ b/configure.ac
@@ -395,6 +395,7 @@ AC_CHECK_HEADERS(m4_normalize([
 	linux/ip_vs.h
 	linux/ipc.h
 	linux/kcmp.h
+	linux/kvm.h
 	linux/memfd.h
 	linux/mmtimer.h
 	linux/msg.h
diff --git a/defs.h b/defs.h
index b1a6b955..0187863e 100644
--- a/defs.h
+++ b/defs.h
@@ -658,6 +658,7 @@ name ## _ioctl(struct tcb *, unsigned int request, kernel_ulong_t arg)	\
 DECL_IOCTL(dm);
 DECL_IOCTL(file);
 DECL_IOCTL(fs_x);
+DECL_IOCTL(kvm);
 DECL_IOCTL(nsfs);
 DECL_IOCTL(ptp);
 DECL_IOCTL(scsi);
diff --git a/ioctl.c b/ioctl.c
index b61a5be5..35485172 100644
--- a/ioctl.c
+++ b/ioctl.c
@@ -314,6 +314,10 @@ ioctl_decode(struct tcb *tcp)
 	case 0xfd:
 		return dm_ioctl(tcp, code, arg);
 #endif
+#ifdef HAVE_LINUX_KVM_H
+	case 0xae:
+		return kvm_ioctl(tcp, code, arg);
+#endif
 	default:
 		break;
 	}
diff --git a/kvm.c b/kvm.c
new file mode 100644
index 00000000..8251ce7d
--- /dev/null
+++ b/kvm.c
@@ -0,0 +1,50 @@
+/*
+ * Support for decoding of KVM_* ioctl commands.
+ *
+ * Copyright (c) 2017 Masatake YAMATO <yamato at redhat.com>
+ * Copyright (c) 2017 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "defs.h"
+
+#ifdef HAVE_LINUX_KVM_H
+#include <linux/kvm.h>
+
+int
+kvm_ioctl(struct tcb *const tcp, const unsigned int code, const kernel_ulong_t arg)
+{
+	switch (code) {
+	default:
+		return RVAL_DECODED;
+	}
+}
+#else
+int
+kvm_ioctl(struct tcb *const tcp, const unsigned int code, const kernel_ulong_t arg)
+{
+	return RVAL_DECODED;
+}
+#endif /* HAVE_LINUX_KVM_H */
-- 
2.13.6





More information about the Strace-devel mailing list