From patchwork Thu Sep 20 08:25:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 185359 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 A01A62C0084 for ; Thu, 20 Sep 2012 18:25:52 +1000 (EST) Received: from localhost ([::1]:52409 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEc50-0001Li-KX for incoming@patchwork.ozlabs.org; Thu, 20 Sep 2012 04:25:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEc4p-0001LM-5Y for qemu-devel@nongnu.org; Thu, 20 Sep 2012 04:25:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TEc4n-0006ju-Q9 for qemu-devel@nongnu.org; Thu, 20 Sep 2012 04:25:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEc4n-0006jo-IQ for qemu-devel@nongnu.org; Thu, 20 Sep 2012 04:25:37 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8K8PWqF006572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 20 Sep 2012 04:25:32 -0400 Received: from localhost (ovpn-113-33.phx2.redhat.com [10.3.113.33]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8K8PT37020227; Thu, 20 Sep 2012 04:25:31 -0400 From: Amit Shah To: qemu list , kvm list Date: Thu, 20 Sep 2012 13:55:20 +0530 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id q8K8PWqF006572 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Raghavendra K T , Marcelo Tosatti , Eric B Munson , Amit Shah , Paolo Bonzini , Laszlo Ersek , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH 1/1] kvmclock: fix guest stop notification 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 Commit f349c12c0434e29c79ecde89029320c4002f7253 added the guest stop notification, but it did it in a way that the stop notification would never reach the kernel. The kvm_vm_state_changed() function gets a value of 0 for the 'running' parameter when the VM is stopped, making all the code added previously dead code. This patch reworks the code so that it's called when 'running' is 0, which indicates the VM was stopped. CC: Eric B Munson CC: Raghavendra K T CC: Andreas Färber CC: Marcelo Tosatti CC: Paolo Bonzini CC: Laszlo Ersek Signed-off-by: Amit Shah --- hw/kvm/clock.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-) diff --git a/hw/kvm/clock.c b/hw/kvm/clock.c index 824b978..f3427eb 100644 --- a/hw/kvm/clock.c +++ b/hw/kvm/clock.c @@ -71,18 +71,19 @@ static void kvmclock_vm_state_change(void *opaque, int running, if (running) { s->clock_valid = false; + return; + } - if (!cap_clock_ctrl) { - return; - } - for (penv = first_cpu; penv != NULL; penv = penv->next_cpu) { - ret = kvm_vcpu_ioctl(penv, KVM_KVMCLOCK_CTRL, 0); - if (ret) { - if (ret != -EINVAL) { - fprintf(stderr, "%s: %s\n", __func__, strerror(-ret)); - } - return; + if (!cap_clock_ctrl) { + return; + } + for (penv = first_cpu; penv != NULL; penv = penv->next_cpu) { + ret = kvm_vcpu_ioctl(penv, KVM_KVMCLOCK_CTRL, 0); + if (ret) { + if (ret != -EINVAL) { + fprintf(stderr, "%s: %s\n", __func__, strerror(-ret)); } + return; } } }