From patchwork Tue Jul 5 09:35:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 944082 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p659aIcQ012523 for ; Tue, 5 Jul 2011 09:36:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754978Ab1GEJgJ (ORCPT ); Tue, 5 Jul 2011 05:36:09 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:60757 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754949Ab1GEJgH (ORCPT ); Tue, 5 Jul 2011 05:36:07 -0400 Received: by wyg8 with SMTP id 8so3858098wyg.19 for ; Tue, 05 Jul 2011 02:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=wJ6Sd6EkaJe3YdZyJQMnKwd6gizwAyQBhNKNtDQHegE=; b=UeqHAGR8royN8eJLVcEUFFScDTbuVUQKYtoGyZglPNGoiqIP1e+WIKkwZWBg+RTPDi lPQgKQgAi99P5hYXrtkUYlOaD9V3SdV2z2nBgbXk3P9KpP8QXPWs3fRFaF3O3MVibFT9 QZQUpKQ8TqTLziF/vqKH9ge1TXjlCCNvLaiOc= Received: by 10.227.202.209 with SMTP id ff17mr6207847wbb.23.1309858566246; Tue, 05 Jul 2011 02:36:06 -0700 (PDT) Received: from localhost.localdomain ([31.210.184.221]) by mx.google.com with ESMTPS id e11sm2944792wbh.36.2011.07.05.02.36.03 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Jul 2011 02:36:06 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: mingo@elte.hu, asias.hejun@gmail.com, prasadjoshi124@gmail.com, gorcunov@gmail.com, kvm@vger.kernel.org, Sasha Levin Subject: [PATCH 1/2] kvm tools: Export kvm__remove_pidfile Date: Tue, 5 Jul 2011 12:35:44 +0300 Message-Id: <1309858545-10344-1-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.6 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 05 Jul 2011 09:36:18 +0000 (UTC) This will allow cleaning up ghost pid files outside of the module. Signed-off-by: Sasha Levin --- tools/kvm/include/kvm/kvm.h | 1 + tools/kvm/kvm.c | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h index da9e12c..5cfb0d8 100644 --- a/tools/kvm/include/kvm/kvm.h +++ b/tools/kvm/include/kvm/kvm.h @@ -68,6 +68,7 @@ void kvm__continue(void); void kvm__notify_paused(void); int kvm__get_pid_by_instance(const char *name); int kvm__enumerate_instances(void (*callback)(const char *name, int pid)); +void kvm__remove_pidfile(const char *name); /* * Debugging diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c index 075c8d8..cd3cb19 100644 --- a/tools/kvm/kvm.c +++ b/tools/kvm/kvm.c @@ -134,14 +134,11 @@ static void kvm__create_pidfile(struct kvm *kvm) close(fd); } -static void kvm__remove_pidfile(struct kvm *kvm) +void kvm__remove_pidfile(const char *name) { char full_name[PATH_MAX]; - if (!kvm->name) - return; - - sprintf(full_name, "%s/%s/%s.pid", HOME_DIR, KVM_PID_FILE_PATH, kvm->name); + sprintf(full_name, "%s/%s/%s.pid", HOME_DIR, KVM_PID_FILE_PATH, name); unlink(full_name); } @@ -194,7 +191,7 @@ void kvm__delete(struct kvm *kvm) kvm__stop_timer(kvm); munmap(kvm->ram_start, kvm->ram_size); - kvm__remove_pidfile(kvm); + kvm__remove_pidfile(kvm->name); free(kvm); }