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 From: Alex Williamson Date: Fri, 13 Aug 2010 09:54:52 -0400 Message-ID: <20100813135441.14623.25552.stgit@localhost6.localdomain6> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] vhost: Fix size of dirty log sync on resize List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, mst@redhat.com 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); }