From patchwork Sat May 14 16:34:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 785112 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4EGZedM004141 for ; Sat, 14 May 2011 16:35:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758534Ab1ENQfZ (ORCPT ); Sat, 14 May 2011 12:35:25 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:37999 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758644Ab1ENQfW (ORCPT ); Sat, 14 May 2011 12:35:22 -0400 Received: by fxm17 with SMTP id 17so2305228fxm.19 for ; Sat, 14 May 2011 09:35:21 -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; bh=84lOZWFwDVtx0JgjYTuGXKRnxPC7gpC5HjMyx3CDKyM=; b=TJBjXrLpmNVGXprPG2KuFAWt86VqVKKyh5t39bca2CVndKNNFZ3D6ygDhYksdx/Cte Bj//9wX5L6NVZlvRRe81VceNUYFx+pLzRWIV/pqFxEOFYf769hgKZmaSGQjwcIciCkHU w0zaItMUzLAJ+BfEzWmLvqoLGJgzXHay85ahM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=SaFhnQdjo/crXsNw6QxSAZpVyz+tG8ra02r/599uLEUu7DtqDhc3ghZlRd+1f9Z34P IliDx/lBcU61HH0UeSzXQR/jWNCm4omZZEGo1IXojadDQCC9U3/xj6LymbXZ6h3rlmlm pbWCPNuBWk759AIBqPKyYnE+mQlmXsbe+0EOY= Received: by 10.223.57.5 with SMTP id a5mr1454617fah.90.1305390920898; Sat, 14 May 2011 09:35:20 -0700 (PDT) Received: from localhost.localdomain ([188.120.132.169]) by mx.google.com with ESMTPS id j11sm1213009faa.20.2011.05.14.09.35.18 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 14 May 2011 09:35:20 -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] kvm tools: Return correct values from disk IOV functions Date: Sat, 14 May 2011 19:34:42 +0300 Message-Id: <1305390882-18747-1-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.rc3 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 (demeter1.kernel.org [140.211.167.41]); Sat, 14 May 2011 16:35:41 +0000 (UTC) Return correct amount of bytes read/written from _iov functions. Signed-off-by: Sasha Levin --- tools/kvm/include/kvm/disk-image.h | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/kvm/include/kvm/disk-image.h b/tools/kvm/include/kvm/disk-image.h index 9d7b572..195270f 100644 --- a/tools/kvm/include/kvm/disk-image.h +++ b/tools/kvm/include/kvm/disk-image.h @@ -42,6 +42,8 @@ static inline int disk_image__write_sector(struct disk_image *disk, u64 sector, static inline ssize_t disk_image__read_sector_iov(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount) { + u64 first_sector = sector; + if (disk->ops->read_sector_iov) return disk->ops->read_sector_iov(disk, sector, iov, iovcount); @@ -53,11 +55,13 @@ static inline ssize_t disk_image__read_sector_iov(struct disk_image *disk, u64 s iov++; } - return sector << SECTOR_SHIFT; + return (sector - first_sector) << SECTOR_SHIFT; } static inline ssize_t disk_image__write_sector_iov(struct disk_image *disk, u64 sector, const struct iovec *iov, int iovcount) { + u64 first_sector = sector; + if (disk->ops->write_sector_iov) return disk->ops->write_sector_iov(disk, sector, iov, iovcount); @@ -69,7 +73,7 @@ static inline ssize_t disk_image__write_sector_iov(struct disk_image *disk, u64 iov++; } - return sector << SECTOR_SHIFT; + return (sector - first_sector) << SECTOR_SHIFT; } #endif /* KVM__DISK_IMAGE_H */