From patchwork Wed May 18 08:19:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 793112 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 p4I8O3wp004358 for ; Wed, 18 May 2011 08:24:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755651Ab1ERIXg (ORCPT ); Wed, 18 May 2011 04:23:36 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:53347 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755638Ab1ERIXf (ORCPT ); Wed, 18 May 2011 04:23:35 -0400 Received: by pvg12 with SMTP id 12so602294pvg.19 for ; Wed, 18 May 2011 01:23:34 -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=0ILaWY1M3slmbddYb78mfaLiY6vKr1lRd73IuBzfPpA=; b=VZ3jmQNGXw3mg05BjVED0H33keeamGf6wKEd60wkN5rJG/T3QpVHrV0aDYaXBgYugM yAJoL2UlS5Ektx7SO7aqlp9TQNTGPJrF9LhLGt1RERKLBV5iAQT4jEkvt+weXxEYcfz2 pEGBIhcInGx9RO/szTAAgOnPKrFM5c1Nt4blo= 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=eeAq76cGJgQJmWcDVKhph2AVaQEvoxlcfv/9Tf6fmcE4iYoFLAYXDWLrmNaKmEkzQf g0POenSyYsgfm7ynw2AinrJ1r6CD3ZVoGcA8EXhSXGkeM0wxzCGBRhSFH8c/okNqb5b8 UAW9rDstbOaGNer22IXl+aZXc1GhGW+fjanCQ= Received: by 10.68.30.73 with SMTP id q9mr2315584pbh.431.1305707014774; Wed, 18 May 2011 01:23:34 -0700 (PDT) Received: from localhost.localdomain ([219.224.169.130]) by mx.google.com with ESMTPS id q10sm912018pbk.39.2011.05.18.01.23.26 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 May 2011 01:23:34 -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 10/14] kvm tools: Rename raw_image_ops to blk_dev_ops Date: Wed, 18 May 2011 16:19:11 +0800 Message-Id: <1305706755-2816-10-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:06 +0000 (UTC) This patch also adds some comments to disk/blk.c Signed-off-by: Asias He --- tools/kvm/disk/blk.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/kvm/disk/blk.c b/tools/kvm/disk/blk.c index 7383967..59294e8 100644 --- a/tools/kvm/disk/blk.c +++ b/tools/kvm/disk/blk.c @@ -3,7 +3,7 @@ /* * raw image and blk dev are similar, so reuse raw image ops. */ -static struct disk_image_operations raw_image_ops = { +static struct disk_image_operations blk_dev_ops = { .read_sector = raw_image__read_sector, .write_sector = raw_image__write_sector, .close = raw_image__close, @@ -17,7 +17,11 @@ struct disk_image *blkdev__probe(const char *filename, struct stat *st) if (!S_ISBLK(st->st_mode)) return NULL; - fd = open(filename, O_RDONLY); + /* + * Be careful! We are opening host block device! + * Open it readonly since we do not want to break user's data on disk. + */ + fd = open(filename, O_RDONLY); if (fd < 0) return NULL; @@ -26,5 +30,10 @@ struct disk_image *blkdev__probe(const char *filename, struct stat *st) return NULL; } - return disk_image__new(fd, size, &raw_image_ops, DISK_IMAGE_MMAP); + /* + * FIXME: This will not work on 32-bit host because we can not + * mmap large disk. There is not enough virtual address space + * in 32-bit host. However, this works on 64-bit host. + */ + return disk_image__new(fd, size, &blk_dev_ops, DISK_IMAGE_MMAP); }