This patch fixes an error where pids used u64 instead of pid_t, causing them to never be negative. Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx> --- tools/kvm/builtin-balloon.c | 4 ++-- tools/kvm/builtin-debug.c | 4 ++-- tools/kvm/builtin-pause.c | 4 ++-- tools/kvm/builtin-resume.c | 4 ++-- tools/kvm/builtin-stat.c | 4 ++-- tools/kvm/builtin-stop.c | 4 ++-- tools/kvm/include/kvm/kvm.h | 2 +- tools/kvm/kvm.c | 5 +++-- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/tools/kvm/builtin-balloon.c b/tools/kvm/builtin-balloon.c index cb7d552..7329063 100644 --- a/tools/kvm/builtin-balloon.c +++ b/tools/kvm/builtin-balloon.c @@ -8,7 +8,7 @@ #include <kvm/parse-options.h> #include <kvm/kvm.h> -static u64 instance_pid; +static pid_t instance_pid; static const char *instance_name; static u64 inflate; static u64 deflate; @@ -21,7 +21,7 @@ static const char * const balloon_usage[] = { static const struct option balloon_options[] = { OPT_GROUP("Instance options:"), OPT_STRING('n', "name", &instance_name, "name", "Instance name"), - OPT_U64('p', "pid", &instance_pid, "Instance pid"), + OPT_INTEGER('p', "pid", &instance_pid, "Instance pid"), OPT_GROUP("Balloon options:"), OPT_U64('i', "inflate", &inflate, "Amount to inflate"), OPT_U64('d', "deflate", &deflate, "Amount to deflate"), diff --git a/tools/kvm/builtin-debug.c b/tools/kvm/builtin-debug.c index 43da16d..4be12cc 100644 --- a/tools/kvm/builtin-debug.c +++ b/tools/kvm/builtin-debug.c @@ -9,7 +9,7 @@ #include <signal.h> static bool all; -static u64 instance_pid; +static pid_t instance_pid; static const char *instance_name; static const char * const debug_usage[] = { @@ -21,7 +21,7 @@ static const struct option debug_options[] = { OPT_GROUP("General options:"), OPT_BOOLEAN('a', "all", &all, "Debug all instances"), OPT_STRING('n', "name", &instance_name, "name", "Instance name"), - OPT_U64('p', "pid", &instance_pid, "Instance pid"), + OPT_INTEGER('p', "pid", &instance_pid, "Instance pid"), OPT_END() }; diff --git a/tools/kvm/builtin-pause.c b/tools/kvm/builtin-pause.c index e4efb08..7b644ff 100644 --- a/tools/kvm/builtin-pause.c +++ b/tools/kvm/builtin-pause.c @@ -9,7 +9,7 @@ #include <signal.h> static bool all; -static u64 instance_pid; +static pid_t instance_pid; static const char *instance_name; static const char * const pause_usage[] = { @@ -21,7 +21,7 @@ static const struct option pause_options[] = { OPT_GROUP("General options:"), OPT_BOOLEAN('a', "all", &all, "Pause all instances"), OPT_STRING('n', "name", &instance_name, "name", "Instance name"), - OPT_U64('p', "pid", &instance_pid, "Instance pid"), + OPT_INTEGER('p', "pid", &instance_pid, "Instance pid"), OPT_END() }; diff --git a/tools/kvm/builtin-resume.c b/tools/kvm/builtin-resume.c index 0c11cec..70de0fc 100644 --- a/tools/kvm/builtin-resume.c +++ b/tools/kvm/builtin-resume.c @@ -9,7 +9,7 @@ #include <signal.h> static bool all; -static u64 instance_pid; +static pid_t instance_pid; static const char *instance_name; static const char * const resume_usage[] = { @@ -21,7 +21,7 @@ static const struct option resume_options[] = { OPT_GROUP("General options:"), OPT_BOOLEAN('a', "all", &all, "Resume all instances"), OPT_STRING('n', "name", &instance_name, "name", "Instance name"), - OPT_U64('p', "pid", &instance_pid, "Instance pid"), + OPT_INTEGER('p', "pid", &instance_pid, "Instance pid"), OPT_END() }; diff --git a/tools/kvm/builtin-stat.c b/tools/kvm/builtin-stat.c index d9bc75d..be12d15 100644 --- a/tools/kvm/builtin-stat.c +++ b/tools/kvm/builtin-stat.c @@ -10,7 +10,7 @@ static bool mem; static bool all; -static u64 instance_pid; +static pid_t instance_pid; static const char *instance_name; static const char * const stat_usage[] = { @@ -24,7 +24,7 @@ static const struct option stat_options[] = { OPT_GROUP("Instance options:"), OPT_BOOLEAN('a', "all", &all, "All instances"), OPT_STRING('n', "name", &instance_name, "name", "Instance name"), - OPT_U64('p', "pid", &instance_pid, "Instance pid"), + OPT_INTEGER('p', "pid", &instance_pid, "Instance pid"), OPT_END() }; diff --git a/tools/kvm/builtin-stop.c b/tools/kvm/builtin-stop.c index d16618a..fd0500e 100644 --- a/tools/kvm/builtin-stop.c +++ b/tools/kvm/builtin-stop.c @@ -9,7 +9,7 @@ #include <signal.h> static bool all; -static u64 instance_pid; +static pid_t instance_pid; static const char *instance_name; static const char * const stop_usage[] = { @@ -21,7 +21,7 @@ static const struct option stop_options[] = { OPT_GROUP("General options:"), OPT_BOOLEAN('a', "all", &all, "Stop all instances"), OPT_STRING('n', "name", &instance_name, "name", "Instance name"), - OPT_U64('p', "pid", &instance_pid, "Instance pid"), + OPT_INTEGER('p', "pid", &instance_pid, "Instance pid"), OPT_END() }; diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h index c2d815c..d471cee 100644 --- a/tools/kvm/include/kvm/kvm.h +++ b/tools/kvm/include/kvm/kvm.h @@ -73,7 +73,7 @@ bool kvm__deregister_mmio(struct kvm *kvm, u64 phys_addr); void kvm__pause(void); void kvm__continue(void); void kvm__notify_paused(void); -int kvm__get_pid_by_instance(const char *name); +pid_t kvm__get_pid_by_instance(const char *name); int kvm__enumerate_instances(int (*callback)(const char *name, int pid)); void kvm__remove_pidfile(const char *name); diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c index 30aef3a..bbfdea2 100644 --- a/tools/kvm/kvm.c +++ b/tools/kvm/kvm.c @@ -142,9 +142,10 @@ void kvm__remove_pidfile(const char *name) unlink(full_name); } -int kvm__get_pid_by_instance(const char *name) +pid_t kvm__get_pid_by_instance(const char *name) { - int fd, pid; + int fd; + pid_t pid; char pid_str[10], pid_file[PATH_MAX]; sprintf(pid_file, "%s/%s/%s.pid", HOME_DIR, KVM_PID_FILE_PATH, name); -- 1.7.6 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html