From dcf208cbd1b6e8be2e1e4c7b42977cff32ccded8 Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Tue, 20 Dec 2011 17:08:45 +0800 Subject: [PATCH] kvm tools: cleanup kvm_cmd_pause() Use stack variable. Remove unneeded branch. Close opened file. Signed-off-by: Lai Jiangshan Signed-off-by: Pekka Enberg --- tools/kvm/builtin-pause.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/kvm/builtin-pause.c b/tools/kvm/builtin-pause.c index 107641ccd494..eb89ff7e9abb 100644 --- a/tools/kvm/builtin-pause.c +++ b/tools/kvm/builtin-pause.c @@ -15,7 +15,6 @@ struct pause_cmd { }; static bool all; -static int instance; static const char *instance_name; static const char * const pause_usage[] = { @@ -59,20 +58,25 @@ static int do_pause(const char *name, int sock) int kvm_cmd_pause(int argc, const char **argv, const char *prefix) { + int instance; + int r; + parse_pause_options(argc, argv); if (all) return kvm__enumerate_instances(do_pause); - if (instance_name == NULL && - instance == 0) + if (instance_name == NULL) kvm_pause_help(); - if (instance_name) - instance = kvm__get_sock_by_instance(instance_name); + instance = kvm__get_sock_by_instance(instance_name); if (instance <= 0) die("Failed locating instance"); - return do_pause(instance_name, instance); + r = do_pause(instance_name, instance); + + close(instance); + + return r; } -- 2.39.5