From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=51211 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PccmY-0005jU-97 for qemu-devel@nongnu.org; Tue, 11 Jan 2011 06:52:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PccmT-0005TV-QK for qemu-devel@nongnu.org; Tue, 11 Jan 2011 06:52:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52288) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PccmT-0005TC-Hs for qemu-devel@nongnu.org; Tue, 11 Jan 2011 06:52:53 -0500 Message-ID: <4D2C44E9.5090008@redhat.com> Date: Tue, 11 Jan 2011 12:54:17 +0100 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Avoid divide by zero when there is no block device to migrate References: <1293310330-12067-1-git-send-email-Pierre.Riteau@irisa.fr> In-Reply-To: <1293310330-12067-1-git-send-email-Pierre.Riteau@irisa.fr> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pierre Riteau Cc: qemu-devel@nongnu.org Am 25.12.2010 21:52, schrieb 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 Maybe in this case we should generate an error before actually starting with block migration. If you bothered to request block migration you certainly didn't have in mind to do nothing. > --- > 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; This exceeds 80 characters per line. > + } else { > + progress = 100; > + } > if (progress != block_mig_state.prev_progress) { > block_mig_state.prev_progress = progress; > qemu_put_be64(f, (progress << BDRV_SECTOR_BITS) Kevin