Add a command line debug option to add a fix amount of delay in read and
write operation.
From Ingo "the delays are *constant* [make sure you use a high-res timers
kernel], so they do not result in nearly as much measurement noise as real
block IO does.
[...]
This way you are basically 'emulating' a real disk drive but you will
emulate uniform latencies, which makes measurements a lot more
reliable - while still relevant to the end result."
Suggested-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
#include "kvm/disk-image.h"
#include "kvm/qcow.h"
+int debug_iodelay;
+
struct disk_image *disk_image__new(int fd, u64 size, struct disk_image_operations *ops, int use_mmap)
{
struct disk_image *disk;
ssize_t total = 0;
ssize_t nr;
+ if (debug_iodelay)
+ msleep(debug_iodelay);
+
if (disk->ops->read_sector_iov) {
/*
* Try mulitple buffer based operation first
ssize_t total = 0;
ssize_t nr;
+ if (debug_iodelay)
+ msleep(debug_iodelay);
+
if (disk->ops->write_sector_iov) {
/*
* Try writev based operation first
return strncmp(str, prefix, len) ? NULL : str + len;
}
+#define MSECS_TO_USECS(s) ((s) * 1000)
+
+/* Millisecond sleep */
+static inline void msleep(unsigned int msecs)
+{
+ usleep(MSECS_TO_USECS(msecs));
+}
#endif /* KVM__UTIL_H */
static bool sdl;
extern bool ioport_debug;
extern int active_console;
+extern int debug_iodelay;
bool do_debug_print = false;
"Enable single stepping"),
OPT_BOOLEAN('\0', "debug-ioport-debug", &ioport_debug,
"Enable ioport debugging"),
+ OPT_INTEGER('\0', "debug_iodelay", &debug_iodelay,
+ "Delay IO by millisecond"),
OPT_END()
};