From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: kernel device reset support Date: Mon, 08 Oct 2007 12:24:22 +0200 Message-ID: <470A0556.80903@qumranet.com> References: <10EA09EFD8728347A513008B6B0DA77A0231BB36@pdsmsx411.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel To: "Dong, Eddie" Return-path: In-Reply-To: <10EA09EFD8728347A513008B6B0DA77A0231BB36-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org Dong, Eddie wrote: > Kernel side patch to introduce a new API for kernel device reset and > force > vcpu mp_state to UNINATIALIZED state if it is reset. > thx,eddie > > > > + > +/* > + * Reset VM. > + * > + */ > +int kvm_vm_reset(struct kvm *kvm) > +{ > + struct kvm_vcpu *vcpu; > + int i; > + > + kvm_reset_devices(kvm); > + for (i = 0; i < KVM_MAX_VCPUS; i++) { > + vcpu = kvm->vcpus[i]; > + if (!vcpu) > + continue; > + /* active VCPU */ > + if (vcpu->vcpu_id) > + vcpu->mp_state = VCPU_MP_STATE_UNINITIALIZED; > + else { > + vcpu->mp_state = VCPU_MP_STATE_RUNNABLE; > + kvm_lapic_reset(vcpu); > Why is the handling here different? > + } > + vcpu->force_to_quit = 1; > + kvm_vcpu_kick(vcpu); > + } > + return 0; > +} > + > static long kvm_vm_ioctl(struct file *filp, > unsigned int ioctl, unsigned long arg) > { > @@ -3163,6 +3200,12 @@ static long kvm_vm_ioctl(struct file *filp, > else > goto out; > break; > + case KVM_RESET: > + r = -EFAULT; > -EINVAL. Or better accept it always and only reset the vcpu if !irqchip_in_kernel(). > + if (!irqchip_in_kernel(kvm)) > + goto out; > + r = kvm_vm_reset(kvm); > + break; > case KVM_IRQ_LINE: { > struct kvm_irq_level irq_event; > > diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c > index 3d8e01e..0799aad 100644 > --- a/drivers/kvm/vmx.c > +++ b/drivers/kvm/vmx.c > @@ -1860,6 +1860,10 @@ static int handle_external_interrupt(struct > kvm_vcpu *vcpu, > struct kvm_run *kvm_run) > { > ++vcpu->stat.irq_exits; > + if (vcpu->force_to_quit) { > + vcpu->force_to_quit = 0; > + return -EINTR; > + } > return 1; > } > Why is this needed? Userspace can always force an exit by sending a signal. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/