From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [Qemu-devel] [PATCH V3] Guest stop notification Date: Sat, 03 Dec 2011 12:25:37 +0100 Message-ID: <4EDA0731.80302@web.de> References: <1322853560-24152-1-git-send-email-emunson@mgebm.net> <4ED9331B.9060708@web.de> <20111202212726.GA5662@mgebm.net> <4ED9E6B0.2000903@web.de> <20111203111935.GA25573@amt.cnet> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigFD44B57EC22D41D9911029C5" Cc: Eric B Munson , "ryanh@linux.vnet.ibm.com" , "aliguori@us.ibm.com" , "kvm@vger.kernel.org" , "qemu-devel@nongnu.org" , Avi Kivity To: Marcelo Tosatti Return-path: Received: from fmmailgate01.web.de ([217.72.192.221]:57984 "EHLO fmmailgate01.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754498Ab1LCLZl (ORCPT ); Sat, 3 Dec 2011 06:25:41 -0500 Received: from moweb002.kundenserver.de (moweb002.kundenserver.de [172.19.20.108]) by fmmailgate01.web.de (Postfix) with ESMTP id 9725D1A425A07 for ; Sat, 3 Dec 2011 12:25:40 +0100 (CET) In-Reply-To: <20111203111935.GA25573@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigFD44B57EC22D41D9911029C5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2011-12-03 12:19, Marcelo Tosatti wrote: > On Sat, Dec 03, 2011 at 10:06:56AM +0100, Jan Kiszka wrote: >> On 2011-12-02 22:27, Eric B Munson wrote: >>> On Fri, 02 Dec 2011, Jan Kiszka wrote: >>> >>>> On 2011-12-02 20:19, Eric B Munson wrote: >>>>> Often when a guest is stopped from the qemu console, it will report= spurious >>>>> soft lockup warnings on resume. There are kernel patches being dis= cussed that >>>>> will give the host the ability to tell the guest that it is being s= topped and >>>>> should ignore the soft lockup warning that generates. >>>>> >>>>> Signed-off-by: Eric B Munson >>>>> Cc: Avi Kivity >>>>> Cc: Marcelo Tosatti >>>>> Cc: Jan Kiszka >>>>> Cc: ryanh@linux.vnet.ibm.com >>>>> Cc: aliguori@us.ibm.com >>>>> Cc: kvm@vger.kernel.org >>>>> >>>>> --- >>>>> Changes from V2: >>>>> Move ioctl into hw/kvmclock.c so as other arches can use it as it = is >>>>> implemented >>>>> >>>>> Changes from V1: >>>>> Remove unnecessary encapsulating function >>>>> >>>>> hw/kvmclock.c | 24 ++++++++++++++++++++++++ >>>>> 1 files changed, 24 insertions(+), 0 deletions(-) >>>>> >>>>> diff --git a/hw/kvmclock.c b/hw/kvmclock.c >>>>> index 5388bc4..756839f 100644 >>>>> --- a/hw/kvmclock.c >>>>> +++ b/hw/kvmclock.c >>>>> @@ -16,6 +16,7 @@ >>>>> #include "sysbus.h" >>>>> #include "kvm.h" >>>>> #include "kvmclock.h" >>>>> +#include "cpu-all.h" >>>>> =20 >>>>> #include >>>>> #include >>>>> @@ -69,11 +70,34 @@ static void kvmclock_vm_state_change(void *opaq= ue, int running, >>>>> } >>>>> } >>>>> =20 >>>>> +static void kvmclock_vm_state_change_vcpu(void *opaque, int runnin= g, >>>>> + RunState state) >>>>> +{ >>>>> + int ret; >>>>> + CPUState *penv =3D first_cpu; >>>>> + >>>>> + if (running) { >>>>> + while (penv) { >>>> >>>> or: for (cpu =3D first_cpu; cpu !=3D NULL; cpu =3D cpu->next_cpu) { >>>> >>> >>> Functionally equivalent and I see both in the code, is there a standa= rd? >> >> Not really. I once tried to introduce an iterator macro, but it was >> refused. The above is just more compact. >> >> But this is only a minor nit. >> >>> >>>>> + ret =3D kvm_vcpu_ioctl(penv, KVM_GUEST_PAUSED, 0); >>>>> + if (ret) { >>>>> + if (ret !=3D ENOSYS) { >>>>> + fprintf(stderr, >>>>> + "kvmclock_vm_state_change_vcpu: %s\n",= >>>>> + strerror(-ret)); >>>>> + } >>>>> + return; >>>>> + } >>>>> + penv =3D (CPUState *)penv->next_cpu; >>>> >>>> Unneeded cast. >>>> >>> >>> Also following an example seen elsewhere. >> >> Generally, we try to avoid those pointless casts. >> >>> >>>>> + } >>>>> + } >>>>> +} >>>>> + >>>> >>>> Again: please use checkpatch.pl. >>>> >>> >>> Sorry, tough to get used to hitting space bar that many times... >>> >>>>> static int kvmclock_init(SysBusDevice *dev) >>>>> { >>>>> KVMClockState *s =3D FROM_SYSBUS(KVMClockState, dev); >>>>> =20 >>>>> qemu_add_vm_change_state_handler(kvmclock_vm_state_change, s);= >>>>> + qemu_add_vm_change_state_handler(kvmclock_vm_state_change_vcpu= , NULL); >>>>> return 0; >>>>> } >>>>> =20 >>>> >>>> Why not extend the existing handler? >>> >>> Because the new handler doesn't touch the KVMClockState object. If t= his is >>> preferred, I have no objection. >> >> The separate registration looks strange to me. And the fact that you >> don't need to object doesn't justify a callback of its own. >> >>> >>>> >>>> I still wonder if the IOCTL interface is actually kvmclock specific.= But >>>> Marcello asked for this, and we could still change it when some arch= >>>> comes around that provides it independent of kvmclock. >>> >>> The flag itself is stored in the pvclock_vcpu_time_info structure, an= d anything >>> else that touches that structure uses ioctls. >> >> That's the host-guest interface. But I'm talking about the kvm-qemu >> interface here which has no relation to how the "was paused" informati= on >> is transferred to the guest. >> >> Jan >=20 > It is one simple, rarely used command. I don't see why another interfac= e > such as kvm_run would be beneficial for this case. >=20 I was referring to the relation between the IOCTL and kvmclock, but IOCTL vs. kvm_run. Jan --------------enigFD44B57EC22D41D9911029C5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk7aBzIACgkQitSsb3rl5xSNCgCeJ4OuZ5WAnc8n7MacPfbJvRh6 JskAn0j7KFeZBFVNnOqGtljMlHV6PNjf =nJNU -----END PGP SIGNATURE----- --------------enigFD44B57EC22D41D9911029C5-- From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:48955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWnix-0007w9-Fr for qemu-devel@nongnu.org; Sat, 03 Dec 2011 06:25:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RWniw-0004L1-5p for qemu-devel@nongnu.org; Sat, 03 Dec 2011 06:25:43 -0500 Received: from fmmailgate02.web.de ([217.72.192.227]:45435) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWniv-0004Kw-Q2 for qemu-devel@nongnu.org; Sat, 03 Dec 2011 06:25:42 -0500 Received: from moweb002.kundenserver.de (moweb002.kundenserver.de [172.19.20.108]) by fmmailgate02.web.de (Postfix) with ESMTP id 9D8D51BB1CBB8 for ; Sat, 3 Dec 2011 12:25:40 +0100 (CET) Message-ID: <4EDA0731.80302@web.de> Date: Sat, 03 Dec 2011 12:25:37 +0100 From: Jan Kiszka MIME-Version: 1.0 References: <1322853560-24152-1-git-send-email-emunson@mgebm.net> <4ED9331B.9060708@web.de> <20111202212726.GA5662@mgebm.net> <4ED9E6B0.2000903@web.de> <20111203111935.GA25573@amt.cnet> In-Reply-To: <20111203111935.GA25573@amt.cnet> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigFD44B57EC22D41D9911029C5" Subject: Re: [Qemu-devel] [PATCH V3] Guest stop notification List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcelo Tosatti Cc: "ryanh@linux.vnet.ibm.com" , "aliguori@us.ibm.com" , "kvm@vger.kernel.org" , "qemu-devel@nongnu.org" , Avi Kivity , Eric B Munson This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigFD44B57EC22D41D9911029C5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2011-12-03 12:19, Marcelo Tosatti wrote: > On Sat, Dec 03, 2011 at 10:06:56AM +0100, Jan Kiszka wrote: >> On 2011-12-02 22:27, Eric B Munson wrote: >>> On Fri, 02 Dec 2011, Jan Kiszka wrote: >>> >>>> On 2011-12-02 20:19, Eric B Munson wrote: >>>>> Often when a guest is stopped from the qemu console, it will report= spurious >>>>> soft lockup warnings on resume. There are kernel patches being dis= cussed that >>>>> will give the host the ability to tell the guest that it is being s= topped and >>>>> should ignore the soft lockup warning that generates. >>>>> >>>>> Signed-off-by: Eric B Munson >>>>> Cc: Avi Kivity >>>>> Cc: Marcelo Tosatti >>>>> Cc: Jan Kiszka >>>>> Cc: ryanh@linux.vnet.ibm.com >>>>> Cc: aliguori@us.ibm.com >>>>> Cc: kvm@vger.kernel.org >>>>> >>>>> --- >>>>> Changes from V2: >>>>> Move ioctl into hw/kvmclock.c so as other arches can use it as it = is >>>>> implemented >>>>> >>>>> Changes from V1: >>>>> Remove unnecessary encapsulating function >>>>> >>>>> hw/kvmclock.c | 24 ++++++++++++++++++++++++ >>>>> 1 files changed, 24 insertions(+), 0 deletions(-) >>>>> >>>>> diff --git a/hw/kvmclock.c b/hw/kvmclock.c >>>>> index 5388bc4..756839f 100644 >>>>> --- a/hw/kvmclock.c >>>>> +++ b/hw/kvmclock.c >>>>> @@ -16,6 +16,7 @@ >>>>> #include "sysbus.h" >>>>> #include "kvm.h" >>>>> #include "kvmclock.h" >>>>> +#include "cpu-all.h" >>>>> =20 >>>>> #include >>>>> #include >>>>> @@ -69,11 +70,34 @@ static void kvmclock_vm_state_change(void *opaq= ue, int running, >>>>> } >>>>> } >>>>> =20 >>>>> +static void kvmclock_vm_state_change_vcpu(void *opaque, int runnin= g, >>>>> + RunState state) >>>>> +{ >>>>> + int ret; >>>>> + CPUState *penv =3D first_cpu; >>>>> + >>>>> + if (running) { >>>>> + while (penv) { >>>> >>>> or: for (cpu =3D first_cpu; cpu !=3D NULL; cpu =3D cpu->next_cpu) { >>>> >>> >>> Functionally equivalent and I see both in the code, is there a standa= rd? >> >> Not really. I once tried to introduce an iterator macro, but it was >> refused. The above is just more compact. >> >> But this is only a minor nit. >> >>> >>>>> + ret =3D kvm_vcpu_ioctl(penv, KVM_GUEST_PAUSED, 0); >>>>> + if (ret) { >>>>> + if (ret !=3D ENOSYS) { >>>>> + fprintf(stderr, >>>>> + "kvmclock_vm_state_change_vcpu: %s\n",= >>>>> + strerror(-ret)); >>>>> + } >>>>> + return; >>>>> + } >>>>> + penv =3D (CPUState *)penv->next_cpu; >>>> >>>> Unneeded cast. >>>> >>> >>> Also following an example seen elsewhere. >> >> Generally, we try to avoid those pointless casts. >> >>> >>>>> + } >>>>> + } >>>>> +} >>>>> + >>>> >>>> Again: please use checkpatch.pl. >>>> >>> >>> Sorry, tough to get used to hitting space bar that many times... >>> >>>>> static int kvmclock_init(SysBusDevice *dev) >>>>> { >>>>> KVMClockState *s =3D FROM_SYSBUS(KVMClockState, dev); >>>>> =20 >>>>> qemu_add_vm_change_state_handler(kvmclock_vm_state_change, s);= >>>>> + qemu_add_vm_change_state_handler(kvmclock_vm_state_change_vcpu= , NULL); >>>>> return 0; >>>>> } >>>>> =20 >>>> >>>> Why not extend the existing handler? >>> >>> Because the new handler doesn't touch the KVMClockState object. If t= his is >>> preferred, I have no objection. >> >> The separate registration looks strange to me. And the fact that you >> don't need to object doesn't justify a callback of its own. >> >>> >>>> >>>> I still wonder if the IOCTL interface is actually kvmclock specific.= But >>>> Marcello asked for this, and we could still change it when some arch= >>>> comes around that provides it independent of kvmclock. >>> >>> The flag itself is stored in the pvclock_vcpu_time_info structure, an= d anything >>> else that touches that structure uses ioctls. >> >> That's the host-guest interface. But I'm talking about the kvm-qemu >> interface here which has no relation to how the "was paused" informati= on >> is transferred to the guest. >> >> Jan >=20 > It is one simple, rarely used command. I don't see why another interfac= e > such as kvm_run would be beneficial for this case. >=20 I was referring to the relation between the IOCTL and kvmclock, but IOCTL vs. kvm_run. Jan --------------enigFD44B57EC22D41D9911029C5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk7aBzIACgkQitSsb3rl5xSNCgCeJ4OuZ5WAnc8n7MacPfbJvRh6 JskAn0j7KFeZBFVNnOqGtljMlHV6PNjf =nJNU -----END PGP SIGNATURE----- --------------enigFD44B57EC22D41D9911029C5--