From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=42536 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PWb7Q-000201-Su for qemu-devel@nongnu.org; Sat, 25 Dec 2010 15:53:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PWb7P-00025n-9O for qemu-devel@nongnu.org; Sat, 25 Dec 2010 15:53:36 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:2202) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PWb7O-00025f-UL for qemu-devel@nongnu.org; Sat, 25 Dec 2010 15:53:35 -0500 From: Pierre Riteau Date: Sat, 25 Dec 2010 21:52:10 +0100 Message-Id: <1293310330-12067-1-git-send-email-Pierre.Riteau@irisa.fr> Subject: [Qemu-devel] [PATCH] Avoid divide by zero when there is no block device to migrate List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Pierre Riteau When block migration is requested and no read-write block device is present, a divide by zero exception is triggered because total_sector_sum equals zero. Signed-off-by: Pierre Riteau --- block-migration.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/block-migration.c b/block-migration.c index 1475325..d62d63e 100644 --- a/block-migration.c +++ b/block-migration.c @@ -350,7 +350,11 @@ static int blk_mig_save_bulked_block(Monitor *mon, QEMUFile *f) } } - progress = completed_sector_sum * 100 / block_mig_state.total_sector_sum; + if (block_mig_state.total_sector_sum != 0) { + progress = completed_sector_sum * 100 / block_mig_state.total_sector_sum; + } else { + progress = 100; + } if (progress != block_mig_state.prev_progress) { block_mig_state.prev_progress = progress; qemu_put_be64(f, (progress << BDRV_SECTOR_BITS) -- 1.7.3.4