Commit-ID: a54ef434364b377228f4746d52e654e911a7a4dd Gitweb: http://git.kernel.org/tip/a54ef434364b377228f4746d52e654e911a7a4dd Author: Lai Jiangshan <laijs@xxxxxxxxxxxxxx> AuthorDate: Tue, 27 Dec 2011 15:36:38 +0800 Committer: Pekka Enberg <penberg@xxxxxxxxxx> CommitDate: Tue, 3 Jan 2012 19:07:01 +0200 kvm tools: Don't remove any file which is not created by itself It is user's or other program's reponsibility, not the current program. Just try best to let the user know what happen. Also make print_guest() keep the same behavior as do_debug() do_pause() ...etc. when it failed. Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx> Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx> --- tools/kvm/builtin-list.c | 6 +----- tools/kvm/kvm.c | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/tools/kvm/builtin-list.c b/tools/kvm/builtin-list.c index 885543f..9299f17 100644 --- a/tools/kvm/builtin-list.c +++ b/tools/kvm/builtin-list.c @@ -77,7 +77,7 @@ static int print_guest(const char *name, int sock) vmstate = get_vmstate(sock); if ((int)pid < 0 || vmstate < 0) - goto cleanup; + return -1; if (vmstate == KVM_VMSTATE_PAUSED) printf("%5d %-20s %s\n", pid, name, KVM_INSTANCE_PAUSED); @@ -85,10 +85,6 @@ static int print_guest(const char *name, int sock) printf("%5d %-20s %s\n", pid, name, KVM_INSTANCE_RUNNING); return 0; - -cleanup: - kvm__remove_socket(name); - return -1; } static int kvm_list_running_instances(void) diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c index 29cc4b4..cb4e5a0 100644 --- a/tools/kvm/kvm.c +++ b/tools/kvm/kvm.c @@ -150,7 +150,6 @@ static int kvm__create_socket(struct kvm *kvm) return s; local.sun_family = AF_UNIX; strcpy(local.sun_path, full_name); - unlink(local.sun_path); len = strlen(local.sun_path) + sizeof(local.sun_family); r = bind(s, (struct sockaddr *)&local, len); if (r < 0) @@ -190,8 +189,9 @@ int kvm__get_sock_by_instance(const char *name) r = connect(s, &local, len); if (r < 0 && errno == ECONNREFUSED) { - /* Clean ghost socket file */ - unlink(sock_file); + /* Tell the user clean ghost socket file */ + pr_err("\"%s\" could be a ghost socket file, please remove it", + sock_file); return -1; } else if (r < 0) { die("Failed connecting to instance"); -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html