From patchwork Fri Feb 15 17:46:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 220833 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 53DD02C007B for ; Sat, 16 Feb 2013 06:25:46 +1100 (EST) Received: from localhost ([::1]:54734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6PP9-0007VH-10 for incoming@patchwork.ozlabs.org; Fri, 15 Feb 2013 12:48:59 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6POi-0006pz-FZ for qemu-devel@nongnu.org; Fri, 15 Feb 2013 12:48:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U6POd-0004QR-Ub for qemu-devel@nongnu.org; Fri, 15 Feb 2013 12:48:32 -0500 Received: from mail-vb0-f44.google.com ([209.85.212.44]:58275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6POd-0004QK-Pt for qemu-devel@nongnu.org; Fri, 15 Feb 2013 12:48:27 -0500 Received: by mail-vb0-f44.google.com with SMTP id fr13so2368132vbb.3 for ; Fri, 15 Feb 2013 09:48:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=6oyd/3jQgXxfwz31FHhmjnnkwDZ0Rgjz3MznqCtPw7Q=; b=JgqueOOncerH/RH3cCs6NjpSB0E2NTQ4JhVMO4YK6xCo7P6YV0GSa8EONx9ThRCvhW VSL934nwqAPc6vG44PPIRk5gkPR3zQrDg6ktdhnd5sRO/avX3Kj2lmdNSAl1hpFanLwl yQBwLTNefN7MyvBoSXex7iig5Wr3frpzSf2C7Hz9BTFYVjOrhH2QdnrE90NoO9Rbc5oe VOXWLYlsH3M2cetWV5DEfWwemtFssSMO5cihSe/i/Vi/E2ALKl0mMQUU5a4jFp6/hwIL 4hf9nQhUPHoGEjwReYoI7RTFZrGN0YJcqCyBGMZSMLk85N2OL0e56J5DutZsuZZiZ4iO zAyw== X-Received: by 10.52.174.201 with SMTP id bu9mr3873902vdc.45.1360950498078; Fri, 15 Feb 2013 09:48:18 -0800 (PST) Received: from yakj.usersys.redhat.com (93-34-179-137.ip50.fastwebnet.it. [93.34.179.137]) by mx.google.com with ESMTPS id yu12sm65402142vec.6.2013.02.15.09.48.15 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 15 Feb 2013 09:48:17 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 15 Feb 2013 18:46:57 +0100 Message-Id: <1360950433-17106-26-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1360950433-17106-1-git-send-email-pbonzini@redhat.com> References: <1360950433-17106-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.212.44 Cc: owasserm@redhat.com, chegu_vinod@hp.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 25/41] migration: eliminate last_round X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We will go around the loop exactly once after setting last_round. Eliminate the variable altogether. Signed-off-by: Paolo Bonzini Reviewed-by: Orit Wasserman Reviewed-by: Juan Quintela --- migration.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diff --git a/migration.c b/migration.c index bfe6be1..5e2077e 100644 --- a/migration.c +++ b/migration.c @@ -614,7 +614,6 @@ static void *migration_thread(void *opaque) int64_t max_size = 0; int64_t start_time = initial_time; bool old_vm_running = false; - bool last_round = false; DPRINTF("beginning savevm\n"); qemu_savevm_state_begin(s->file, &s->params); @@ -638,8 +637,11 @@ static void *migration_thread(void *opaque) vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); s->xfer_limit = INT_MAX; qemu_savevm_state_complete(s->file); - last_round = true; qemu_mutex_unlock_iothread(); + if (!qemu_file_get_error(s->file)) { + __sync_val_compare_and_swap(&s->state, MIG_STATE_ACTIVE, MIG_STATE_COMPLETED); + break; + } } } if (current_time >= initial_time + BUFFER_DELAY) { @@ -655,14 +657,12 @@ static void *migration_thread(void *opaque) s->bytes_xfer = 0; initial_time = current_time; } - if (!last_round && (s->bytes_xfer >= s->xfer_limit)) { + if (s->bytes_xfer >= s->xfer_limit) { /* usleep expects microseconds */ g_usleep((initial_time + BUFFER_DELAY - current_time)*1000); } if (qemu_file_get_error(s->file)) { __sync_val_compare_and_swap(&s->state, MIG_STATE_ACTIVE, MIG_STATE_ERROR); - } else if (last_round) { - __sync_val_compare_and_swap(&s->state, MIG_STATE_ACTIVE, MIG_STATE_COMPLETED); } } @@ -674,7 +674,6 @@ static void *migration_thread(void *opaque) runstate_set(RUN_STATE_POSTMIGRATE); } else { if (old_vm_running) { - assert(last_round); vm_start(); } }