public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Muli Ben-Yehuda <muli-7z/5BgaJwgfQT0dZR+AlfA@public.gmane.org>
Cc: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: Re: [PATCH] check for KVM_GET/SET_REG ioctl failures
Date: Tue, 06 Feb 2007 13:26:56 -0600	[thread overview]
Message-ID: <45C8D680.3020704@us.ibm.com> (raw)
In-Reply-To: <20070206184639.GA4292-k73YwwB0fHlWk0Htik3J/w@public.gmane.org>

Muli Ben-Yehuda wrote:
> check for KVM_GET/SET_REGS ioctl failures
>
> Signed-off-by: Muli Ben-Yehuda <muli-7z/5BgaJwgfQT0dZR+AlfA@public.gmane.org>
>
> diff -r ee6f88782b5f -r 9a3e101daf18 user/kvmctl.c
> --- a/user/kvmctl.c	Tue Feb 06 10:55:17 2007 +0000
> +++ b/user/kvmctl.c	Tue Feb 06 17:05:56 2007 +0200
> @@ -235,19 +235,23 @@ 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, &regs);
> +		r = ioctl(kvm->fd, KVM_GET_REGS, &regs);
> +		if (r == -1) {
> +			perror("KVM_GET_REGS");
> +			exit(1);
>   

Please don't add exit()'s to a library, these are the sort of things we 
should be trying to remove.

In the very least, you should probably expect to see EINTRs.

Regards,

Anthony Liguori

> +		}
>  	}
>  
>  	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 +331,25 @@ static int handle_io(kvm_context_t kvm, 
>  		}
>  		first_time = 0;
>  		if (r) {
> -			ioctl(kvm->fd, KVM_SET_REGS, &regs);
> -			return r;
> -		}
> -	}
> -
> -	if (run->io.string || _in)
> -		ioctl(kvm->fd, KVM_SET_REGS, &regs);
> +			int savedret = r;
> +			r = ioctl(kvm->fd, KVM_SET_REGS, &regs);
> +			if (r == -1) {
> +				perror("KVM_SET_REGS");
> +				exit(1);
> +			}
> +
> +			return savedret;
> +		}
> +	}
> +
> +	if (run->io.string || _in) {
> +		r = ioctl(kvm->fd, KVM_SET_REGS, &regs);
> +		if (r == -1) {
> +			perror("KVM_SET_REGS");
> +			exit(1);
> +		}
> +	}
> +
>  	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
> _______________________________________________
> kvm-devel mailing list
> kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/kvm-devel
>
>   


-------------------------------------------------------------------------
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

  parent reply	other threads:[~2007-02-06 19:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-06 18:46 [PATCH] check for KVM_GET/SET_REG ioctl failures Muli Ben-Yehuda
     [not found] ` <20070206184639.GA4292-k73YwwB0fHlWk0Htik3J/w@public.gmane.org>
2007-02-06 19:26   ` Anthony Liguori [this message]
     [not found]     ` <45C8D680.3020704-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-02-06 19:39       ` Muli Ben-Yehuda
     [not found]         ` <20070206193939.GE4292-k73YwwB0fHlWk0Htik3J/w@public.gmane.org>
2007-02-06 20:59           ` Anthony Liguori
     [not found]             ` <45C8EC44.509-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-02-06 21:09               ` Muli Ben-Yehuda
     [not found]                 ` <20070206210926.GI4292-k73YwwB0fHlWk0Htik3J/w@public.gmane.org>
2007-02-06 21:20                   ` Anthony Liguori
2007-02-06 21:35                   ` [PATCH v2] " Muli Ben-Yehuda
2007-02-06 22:36           ` [PATCH] " James Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45C8D680.3020704@us.ibm.com \
    --to=aliguori-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=muli-7z/5BgaJwgfQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox