From: Sasha Levin Date: Mon, 15 Aug 2011 14:33:00 +0000 (+0300) Subject: kvm tools: Use correct data type for pid X-Git-Tag: next-20110824~3^2~21 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=a66148aa576dbd1ffd69694343cedf8adc332930;p=karo-tx-linux.git kvm tools: Use correct data type for pid This patch fixes an error where pids used u64 instead of pid_t, causing them to never be negative. Signed-off-by: Sasha Levin Signed-off-by: Pekka Enberg --- diff --git a/tools/kvm/builtin-balloon.c b/tools/kvm/builtin-balloon.c index cb7d552f33e5..73290635a92a 100644 --- a/tools/kvm/builtin-balloon.c +++ b/tools/kvm/builtin-balloon.c @@ -8,7 +8,7 @@ #include #include -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 43da16d2d62d..4be12cce6a72 100644 --- a/tools/kvm/builtin-debug.c +++ b/tools/kvm/builtin-debug.c @@ -9,7 +9,7 @@ #include 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 e4efb082f481..7b644ff92385 100644 --- a/tools/kvm/builtin-pause.c +++ b/tools/kvm/builtin-pause.c @@ -9,7 +9,7 @@ #include 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 0c11cecae2d5..70de0fc26e1c 100644 --- a/tools/kvm/builtin-resume.c +++ b/tools/kvm/builtin-resume.c @@ -9,7 +9,7 @@ #include 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 d9bc75ddacce..be12d15a16ae 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 d16618a0e696..fd0500e9c2ed 100644 --- a/tools/kvm/builtin-stop.c +++ b/tools/kvm/builtin-stop.c @@ -9,7 +9,7 @@ #include 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 c2d815c7e0f8..d471cee5d60a 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 30aef3a48ecb..bbfdea25588e 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);