mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-06-16 02:15:47 +00:00
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 <levinsasha928@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
+2
-2
@@ -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"),
|
||||
|
||||
+2
-2
@@ -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()
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -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()
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -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()
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -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()
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -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()
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user