From patchwork Wed May 18 08:19:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 793092 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 p4I8O3wo004358 for ; Wed, 18 May 2011 08:24:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755620Ab1ERIX1 (ORCPT ); Wed, 18 May 2011 04:23:27 -0400 Received: from mail-pw0-f46.google.com ([209.85.160.46]:41627 "EHLO mail-pw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755595Ab1ERIX0 (ORCPT ); Wed, 18 May 2011 04:23:26 -0400 Received: by mail-pw0-f46.google.com with SMTP id 15so644382pwi.19 for ; Wed, 18 May 2011 01:23:26 -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=ghwk8vmRD3UWZEsBWBRvVJrMHHwfME/bjO7KpVPhh14=; b=Lgi+LJR1v2FgEpXU3rpGojZAsyPGkqUeq7XgGaByGB33b6+3IyRYBfCQNWKUwvrNBM 4LTd0cXlytdyq9uSLAWNMupXL4Tt+t31Q6WwwpssQPTpz+UPdwv8+y1w5H1Lfvo8TXyn sAa5bK7f+oUIXeApPSZV0Arrm8jwOdH+/iYUw= 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=lNIHQxJiy1Kkm8qPTI/sowNEWKdbdrTcu6viwUlykcOBX+nDZweylAGe8vzZCblC+q v6qbJvyTQwHKjDAR44hDda8U7i/HIRNaZIPuKsU36bGdfIJOfNpS7t5dT439g+rILEnT RouSgwlmlIVhshGdKPRdCh2ZZ9b+NRXR3ImrM= Received: by 10.68.64.168 with SMTP id p8mr2440352pbs.312.1305707006010; Wed, 18 May 2011 01:23:26 -0700 (PDT) Received: from localhost.localdomain ([219.224.169.130]) by mx.google.com with ESMTPS id q10sm912018pbk.39.2011.05.18.01.23.20 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 May 2011 01:23:25 -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 09/14] kvm tools: Rename struct disk_image_operations ops name for raw image Date: Wed, 18 May 2011 16:19:10 +0800 Message-Id: <1305706755-2816-9-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 renames: raw_image__read_sector_ro_mmap to raw_image__read_sector raw_image__write_sector_ro_mmap to raw_image__write_sector raw_image__close_ro_mmap to raw_image__close Signed-off-by: Asias He --- tools/kvm/disk/blk.c | 10 +++++----- tools/kvm/disk/qcow.c | 2 +- tools/kvm/disk/raw.c | 26 ++++++++++++++++---------- tools/kvm/include/kvm/disk-image.h | 6 +++--- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/tools/kvm/disk/blk.c b/tools/kvm/disk/blk.c index ece4d2a..7383967 100644 --- a/tools/kvm/disk/blk.c +++ b/tools/kvm/disk/blk.c @@ -3,10 +3,10 @@ /* * raw image and blk dev are similar, so reuse raw image ops. */ -static struct disk_image_operations raw_image_ro_mmap_ops = { - .read_sector = raw_image__read_sector_ro_mmap, - .write_sector = raw_image__write_sector_ro_mmap, - .close = raw_image__close_ro_mmap, +static struct disk_image_operations raw_image_ops = { + .read_sector = raw_image__read_sector, + .write_sector = raw_image__write_sector, + .close = raw_image__close, }; struct disk_image *blkdev__probe(const char *filename, struct stat *st) @@ -26,5 +26,5 @@ struct disk_image *blkdev__probe(const char *filename, struct stat *st) return NULL; } - return disk_image__new(fd, size, &raw_image_ro_mmap_ops, DISK_IMAGE_MMAP); + return disk_image__new(fd, size, &raw_image_ops, DISK_IMAGE_MMAP); } diff --git a/tools/kvm/disk/qcow.c b/tools/kvm/disk/qcow.c index 956775e..dd11ed97 100644 --- a/tools/kvm/disk/qcow.c +++ b/tools/kvm/disk/qcow.c @@ -351,7 +351,7 @@ static struct disk_image_operations qcow1_disk_readonly_ops = { static struct disk_image_operations qcow1_disk_ops = { .read_sector = qcow1_read_sector, .write_sector = qcow1_write_sector, - .close = qcow1_disk_close + .close = qcow1_disk_close, }; static int qcow_read_l1_table(struct qcow *q) diff --git a/tools/kvm/disk/raw.c b/tools/kvm/disk/raw.c index b58837b..7f3f8db 100644 --- a/tools/kvm/disk/raw.c +++ b/tools/kvm/disk/raw.c @@ -14,7 +14,7 @@ ssize_t raw_image__write_sector_iov(struct disk_image *disk, u64 sector, const s return pwritev_in_full(disk->fd, iov, iovcount, offset); } -ssize_t raw_image__read_sector_ro_mmap(struct disk_image *disk, u64 sector, void *dst, u32 dst_len) +ssize_t raw_image__read_sector(struct disk_image *disk, u64 sector, void *dst, u32 dst_len) { u64 offset = sector << SECTOR_SHIFT; @@ -26,7 +26,7 @@ ssize_t raw_image__read_sector_ro_mmap(struct disk_image *disk, u64 sector, void return dst_len; } -ssize_t raw_image__write_sector_ro_mmap(struct disk_image *disk, u64 sector, void *src, u32 src_len) +ssize_t raw_image__write_sector(struct disk_image *disk, u64 sector, void *src, u32 src_len) { u64 offset = sector << SECTOR_SHIFT; @@ -38,7 +38,7 @@ ssize_t raw_image__write_sector_ro_mmap(struct disk_image *disk, u64 sector, voi return src_len; } -int raw_image__close_ro_mmap(struct disk_image *disk) +int raw_image__close(struct disk_image *disk) { int ret = 0; @@ -48,15 +48,21 @@ int raw_image__close_ro_mmap(struct disk_image *disk) return ret; } -static struct disk_image_operations raw_image_ops = { +/* + * multiple buffer based disk image operations + */ +static struct disk_image_operations raw_image_iov_ops = { .read_sector_iov = raw_image__read_sector_iov, .write_sector_iov = raw_image__write_sector_iov, }; -static struct disk_image_operations raw_image_ro_mmap_ops = { - .read_sector = raw_image__read_sector_ro_mmap, - .write_sector = raw_image__write_sector_ro_mmap, - .close = raw_image__close_ro_mmap, +/* + * single buffer based disk image operations + */ +static struct disk_image_operations raw_image_ops = { + .read_sector = raw_image__read_sector, + .write_sector = raw_image__write_sector, + .close = raw_image__close, }; struct disk_image *raw_image__probe(int fd, struct stat *st, bool readonly) @@ -67,10 +73,10 @@ struct disk_image *raw_image__probe(int fd, struct stat *st, bool readonly) * Use mmap's MAP_PRIVATE to implement non-persistent write * FIXME: This does not work on 32-bit host. */ - return disk_image__new(fd, st->st_size, &raw_image_ro_mmap_ops, DISK_IMAGE_MMAP); + return disk_image__new(fd, st->st_size, &raw_image_ops, DISK_IMAGE_MMAP); else /* * Use read/write instead of mmap */ - return disk_image__new(fd, st->st_size, &raw_image_ops, DISK_IMAGE_NOMMAP); + return disk_image__new(fd, st->st_size, &raw_image_iov_ops, DISK_IMAGE_NOMMAP); } diff --git a/tools/kvm/include/kvm/disk-image.h b/tools/kvm/include/kvm/disk-image.h index 6531a93..82884fb 100644 --- a/tools/kvm/include/kvm/disk-image.h +++ b/tools/kvm/include/kvm/disk-image.h @@ -69,8 +69,8 @@ struct disk_image *blkdev__probe(const char *filename, struct stat *st); ssize_t raw_image__read_sector_iov(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount); ssize_t raw_image__write_sector_iov(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount); -ssize_t raw_image__read_sector_ro_mmap(struct disk_image *disk, u64 sector, void *dst, u32 dst_len); -ssize_t raw_image__write_sector_ro_mmap(struct disk_image *disk, u64 sector, void *src, u32 src_len); -int raw_image__close_ro_mmap(struct disk_image *disk); +ssize_t raw_image__read_sector(struct disk_image *disk, u64 sector, void *dst, u32 dst_len); +ssize_t raw_image__write_sector(struct disk_image *disk, u64 sector, void *src, u32 src_len); +int raw_image__close(struct disk_image *disk); #endif /* KVM__DISK_IMAGE_H */