From patchwork Fri Aug 13 13:54:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 61682 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8323EB70D6 for ; Sat, 14 Aug 2010 00:02:44 +1000 (EST) Received: from localhost ([127.0.0.1]:38076 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OjuqH-0005KD-4G for incoming@patchwork.ozlabs.org; Fri, 13 Aug 2010 10:02:41 -0400 Received: from [140.186.70.92] (port=46264 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ojumw-000423-KV for qemu-devel@nongnu.org; Fri, 13 Aug 2010 09:59:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ojuim-0004ty-8Y for qemu-devel@nongnu.org; Fri, 13 Aug 2010 09:54:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4382) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ojuil-0004tk-Vx for qemu-devel@nongnu.org; Fri, 13 Aug 2010 09:54:56 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7DDssoG020629 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Aug 2010 09:54:54 -0400 Received: from localhost6.localdomain6 (dhcp-100-18-227.bos.redhat.com [10.16.18.227]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7DDsrjq007716; Fri, 13 Aug 2010 09:54:53 -0400 From: Alex Williamson To: qemu-devel@nongnu.org Date: Fri, 13 Aug 2010 09:54:52 -0400 Message-ID: <20100813135441.14623.25552.stgit@localhost6.localdomain6> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: alex.williamson@redhat.com, mst@redhat.com Subject: [Qemu-devel] [PATCH] vhost: Fix size of dirty log sync on resize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When the vhost log is resized, we want to sync up to the size of the old log. With that end address in place, ignore regions that start after then end rather than hitting assert. Signed-off-by: Alex Williamson --- hw/vhost.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/vhost.c b/hw/vhost.c index 34c4745..f6a7cef 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -27,11 +27,11 @@ static void vhost_dev_sync_region(struct vhost_dev *dev, vhost_log_chunk_t *to = dev->log + end / VHOST_LOG_CHUNK + 1; uint64_t addr = (start / VHOST_LOG_CHUNK) * VHOST_LOG_CHUNK; - assert(end / VHOST_LOG_CHUNK < dev->log_size); - assert(start / VHOST_LOG_CHUNK < dev->log_size); if (end < start) { return; } + assert(end / VHOST_LOG_CHUNK < dev->log_size); + for (;from < to; ++from) { vhost_log_chunk_t log; int bit; @@ -258,8 +258,9 @@ static inline void vhost_dev_log_resize(struct vhost_dev* dev, uint64_t size) log_base = (uint64_t)(unsigned long)log; r = ioctl(dev->control, VHOST_SET_LOG_BASE, &log_base); assert(r >= 0); + /* Sync only the range covered by the old log */ vhost_client_sync_dirty_bitmap(&dev->client, 0, - (target_phys_addr_t)~0x0ull); + dev->log_size * VHOST_LOG_CHUNK - 1); if (dev->log) { qemu_free(dev->log); }