From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [RFC][PATCH] qemu-kvm: x86: Refactor persistent CPU state Date: Sun, 24 May 2009 15:13:00 +0300 Message-ID: <4A1939CC.8030206@redhat.com> References: <4A15BFCB.6050403@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Cc: Gleb Natapov , kvm-devel To: Jan Kiszka Return-path: Received: from mx2.redhat.com ([66.187.237.31]:34724 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752428AbZEXMNB (ORCPT ); Sun, 24 May 2009 08:13:01 -0400 In-Reply-To: <4A15BFCB.6050403@web.de> Sender: kvm-owner@vger.kernel.org List-ID: Jan Kiszka wrote: > This patch reworks the KVM-related layout and encoding of the CPU state > to be saved to disk or migrated. The goal is to define a format, version > 9, that is also acceptable for upstream and can later be merged into > QEMU. Besides unconditionally writing KVM states, this format compresses > interrupt_bitmap into a single number as there can be no more than one > pending IRQ at a time. > > > - if (kvm_enabled()) { > - for (i = 0; i < sizeof(env->interrupt_bitmap)/8 ; i++) { > - qemu_put_be64s(f, &env->interrupt_bitmap[i]); > + /* KVM-related states */ > + > + /* There can only be one pending IRQ set in the bitmap at a time, so try > + to find it and save its number instead (-1 for none). */ > + pending_irq = -1; > + for (i = 0; i < sizeof(env->interrupt_bitmap)/2; i++) { > + bit = ffs(((uint16_t *)env->interrupt_bitmap)[i]); > + if (bit) { > + pending_irq = i * 16 + bit; > bit - 1 > + break; > } > Why are you using uint64_t? It would be more natural to use ffsll and the natural type of the bitmap vector. > + } else { > + kvm_load_registers(env); > + kvm_load_tsc(env); > kvm_load_mpstate(env); > } > } > Don't you need to load the pending interrupt? -- error compiling committee.c: too many arguments to function