From: Muli Ben-Yehuda Subject: [PATCH v2] check for KVM_GET/SET_REG ioctl failures Date: Tue, 6 Feb 2007 23:35:11 +0200 Message-ID: <20070206213511.GK4292@rhun.ibm.com> References: <20070206184639.GA4292@rhun.ibm.com> <45C8D680.3020704@us.ibm.com> <20070206193939.GE4292@rhun.ibm.com> <45C8EC44.509@us.ibm.com> <20070206210926.GI4292@rhun.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel To: Avi Kivity Return-path: Content-Disposition: inline In-Reply-To: <20070206210926.GI4292-k73YwwB0fHlWk0Htik3J/w@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 Check for KVM_GET/SET_REGS ioctl failures (and return -errno which the caller of kvm_run will promptely ignore). Signed-off-by: Muli Ben-Yehuda diff -r d116fd1b3260 -r 74c55612f99d user/kvmctl.c --- a/user/kvmctl.c Tue Feb 06 21:26:46 2007 +0200 +++ b/user/kvmctl.c Tue Feb 06 23:29:49 2007 +0200 @@ -235,19 +235,21 @@ static int handle_io(kvm_context_t kvm, int delta; struct translation_cache tr; int _in = (run->io.direction == KVM_EXIT_IO_IN); + int r; translation_cache_init(&tr); if (run->io.string || _in) { regs.vcpu = run->vcpu; - ioctl(kvm->fd, KVM_GET_REGS, ®s); + r = ioctl(kvm->fd, KVM_GET_REGS, ®s); + if (r == -1) + return -errno; } delta = run->io.string_down ? -run->io.size : run->io.size; while (more_io(run, first_time)) { void *value_addr; - int r; if (!run->io.string) { if (_in) @@ -327,13 +329,22 @@ static int handle_io(kvm_context_t kvm, } first_time = 0; if (r) { - ioctl(kvm->fd, KVM_SET_REGS, ®s); - return r; - } - } - - if (run->io.string || _in) - ioctl(kvm->fd, KVM_SET_REGS, ®s); + int savedret = r; + r = ioctl(kvm->fd, KVM_SET_REGS, ®s); + if (r == -1) + return -errno; + + return savedret; + } + } + + if (run->io.string || _in) { + r = ioctl(kvm->fd, KVM_SET_REGS, ®s); + if (r == -1) + return -errno; + + } + run->emulated = 1; return 0; } ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642