From patchwork Wed May 18 08:19:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 793122 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4I8O3wq004358 for ; Wed, 18 May 2011 08:24:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755672Ab1ERIXm (ORCPT ); Wed, 18 May 2011 04:23:42 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:37524 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755691Ab1ERIXl (ORCPT ); Wed, 18 May 2011 04:23:41 -0400 Received: by mail-pz0-f46.google.com with SMTP id 9so601787pzk.19 for ; Wed, 18 May 2011 01:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=pLB28nt4u5iF0fyNPVJPSiQuaANr2Yf8+Oo6FAlH10c=; b=CKENZR7pnrBmvMsYUJ4/AoqpjXGXKKk+5W6gFKz01tu/4QRFSO+arNW24CbAZZupq3 WMa20jYfebB5TrrD1XVEF+isi1PF7FQhgLWonOpRr1I46ZXm+AfuLp7rjw4YeLLhz0T9 4PIFMlt29oeNwyZQOoNiUa6aWU3oYLNK0wKFc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=X+fkETYIc2tI0jIHhhAJ8vXU3t2sd38ICXre16HDYimGtYxLb/R1WXJGkp618Qv5Tb 5U1zXma/7UiusZCVfOwWEnFPHH7A8KE6+j/L3G6GcM70mgRQZ1XecoFXDhEiXhg52nSu HT3KZI+0IvJbz2JXIRdb7PqIbF0CDXIlcAuEI= Received: by 10.68.42.36 with SMTP id k4mr2518614pbl.285.1305707021086; Wed, 18 May 2011 01:23:41 -0700 (PDT) Received: from localhost.localdomain ([219.224.169.130]) by mx.google.com with ESMTPS id q10sm912018pbk.39.2011.05.18.01.23.35 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 May 2011 01:23:40 -0700 (PDT) From: Asias He To: Pekka Enberg Cc: Cyrill Gorcunov , Ingo Molnar , Sasha Levin , Prasad Joshi , kvm@vger.kernel.org, Asias He Subject: [PATCH 11/14] kvm tools: Remove unnecessary S_ISBLK check Date: Wed, 18 May 2011 16:19:12 +0800 Message-Id: <1305706755-2816-11-git-send-email-asias.hejun@gmail.com> X-Mailer: git-send-email 1.7.5.1 In-Reply-To: <1305706755-2816-1-git-send-email-asias.hejun@gmail.com> References: <1305706755-2816-1-git-send-email-asias.hejun@gmail.com> 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]); Wed, 18 May 2011 08:24:07 +0000 (UTC) Let's do it in blkdev__probe. Signed-off-by: Asias He --- tools/kvm/disk/core.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/kvm/disk/core.c b/tools/kvm/disk/core.c index a0ccdc5..6894b17 100644 --- a/tools/kvm/disk/core.c +++ b/tools/kvm/disk/core.c @@ -34,18 +34,22 @@ struct disk_image *disk_image__open(const char *filename, bool readonly) if (stat(filename, &st) < 0) return NULL; - if (S_ISBLK(st.st_mode)) - return blkdev__probe(filename, &st); + /* blk device ?*/ + disk = blkdev__probe(filename, &st); + if (disk) + return disk; fd = open(filename, readonly ? O_RDONLY : O_RDWR); if (fd < 0) return NULL; - disk = qcow_probe(fd, readonly); + /* qcow image ?*/ + disk = qcow_probe(fd, readonly); if (disk) return disk; - disk = raw_image__probe(fd, &st, readonly); + /* raw image ?*/ + disk = raw_image__probe(fd, &st, readonly); if (disk) return disk;