check for KVM_GET/SET_REG ioctl failures
PATCH 1/1 check for KVM_GET/SET_REG ioctl failures
check for KVM_GET/SET_REGS ioctl failures
user/kvmctl.c +25 -9
@@ -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 , ®s); + r =ioctl (kvm->fd,KVM_GET_REGS , ®s); +if (r ==-1 ) { +perror ("KVM_GET_REGS" ); +exit (1 ); + } } 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 , ®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 ) { +perror ("KVM_SET_REGS" ); +exit (1 ); + } + +return savedret; + } + } + +if (run->io.string || _in) { + r =ioctl (kvm->fd,KVM_SET_REGS , ®s); +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
A message that is not in the archive (sent off-list or not yet received): 20070206184639.GA4292-k73YwwB0fHlWk0Htik3J/[email protected]
Quoted 13 lines · Muli Ben-Yehuda
check for KVM_GET/SET_REGS ioctl failures
Signed-off-by Muli Ben-Yehuda <muli-7z/[email protected]>diff -r
ee6f88782b5f-r9a3e101daf18user/kvmctl.cuser/kvmctl.c +1
-0@@ -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;
user/kvmctl.c static int handle_io(kvm_context_t kvm, · line 248
Quoted 10 lines
user/kvmctl.c +4
-1translation_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 ) { +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
Quoted 46 lines
user/kvmctl.c +1
-1+ } } 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) {user/kvmctl.c +19
-8if (_in)@@ -327,13 +331,25 @@ 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 ) { +perror ("KVM_SET_REGS" ); +exit (1 ); + } + +return savedret; + } + } + +if (run->io.string || _in) { + r =ioctl (kvm->fd,KVM_SET_REGS , ®s); +if (r ==-1 ) { +perror ("KVM_SET_REGS" ); +exit (1 ); + } + } + run->emulated =1 ;return 0 ; } -------------------------------------------------------------------------
Quoted 10 lines
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 [email protected]
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
A message that is not in the archive (sent off-list or not yet received): 45C8D680.3020704-r/[email protected]
Quoted 2 lines · Anthony Liguori
Please don't add exit()'s to a library, these are the sort of things we should be trying to remove.
I agree on general principles, but do we envision libkvm.a being used in anything outside qemu? in any case, if not exit(), what would you suggest? from a quick reading of the code, it doesn't appear feasible to go on when get or set regs fail.
Quoted 1 line
In the very least, you should probably expect to see EINTRs.
Hmm, which code path do you have in mind that can return EINTR here?
Cheers,
Muli
-------------------------------------------------------------------------
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
A message that is not in the archive (sent off-list or not yet received): 20070206193939.GE4292-k73YwwB0fHlWk0Htik3J/[email protected]
Quoted 12 lines · Muli Ben-Yehuda
Quoted 3 lines · Anthony Liguori
Please don't add exit()'s to a library, these are the sort of things we should be trying to remove.
I agree on general principles, but do we envision libkvm.a being used in anything outside qemu? in any case, if not
exit(), what would you suggest? from a quick reading of the code, it doesn't appear feasible to go on when get or set regs fail.
Propagate it up and let QEMU decide what to do.
There is at least one other user of libkvmctl that I know of.
Quoted 5 lines
Quoted 2 lines
In the very least, you should probably expect to see EINTRs.
Hmm, which code path do you have in mind that can return EINTR here?
QEMU uses signals quite a bit so I think being defensive on syscalls is best. It's stung me a few times.
I don't think that the {GET,SEG}_REGS ioctls would actually return EINTR ATM.
Regards,
Anthony Liguori
Quoted 3 lines
Cheers,
Muli
-------------------------------------------------------------------------
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
A message that is not in the archive (sent off-list or not yet received): 45C8EC44.509-r/[email protected]
Quoted 3 lines · Anthony Liguori
Propagate it up and let QEMU decide what to do.
There is at least one other user of libkvmctl that I know of.
Ok, I'll rework it this way (and fix the rest of exit()'s in libkvm while I'm at it). Do we agree the right thing for qemu to do on ioctl failures at this time is exit()?
Quoted 2 lines
QEMU uses signals quite a bit so I think being defensive on syscalls is best. It's stung me a few times.
Syscalls don't return EINTR unless they're written specifically to check for sigpending() and return EINTR. I don't think there's any point to check for EINTR here when we know that the ioctl() will never return it. If that changes, we'll have to audit all of the callers anyway and change them.
Cheers,
Muli
-------------------------------------------------------------------------
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
A message that is not in the archive (sent off-list or not yet received): 20070206210926.GI4292-k73YwwB0fHlWk0Htik3J/[email protected]
Quoted 12 lines · Muli Ben-Yehuda
Quoted 4 lines · Anthony Liguori
Propagate it up and let QEMU decide what to do.
There is at least one other user of libkvmctl that I know of.
Ok, I'll rework it this way (and fix the rest of exit()'s in libkvm while I'm at it). Do we agree the right thing for qemu to do on ioctl failures at this time is
exit()?
I don't think it's the best thing, but it's acceptable IMHO.
Regards,
Anthony Liguori
Quoted 4 lines
Quoted 3 lines
QEMU uses signals quite a bit so I think being defensive on syscalls is best. It's stung me a few times.
Quoted 9 lines
Syscalls don't return EINTR unless they're written specifically to check for
sigpending()and return EINTR. I don't think there's any point to check for EINTR here when we know that theioctl()will never return it. If that changes, we'll have to audit all of the callers anyway and change them.Cheers,
Muli
-------------------------------------------------------------------------
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
PATCH v2 1/1 check for KVM_GET/SET_REG ioctl failures
In reply to a message not in the archiveCheck for KVM_GET/SET_REGS ioctl failures (and return -errno which the caller of kvm_run will promptely ignore).
user/kvmctl.c +20 -9
@@ -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
Quoted 7 lines · Muli Ben-Yehuda
Quoted 2 lines · Anthony Liguori
Please don't add exit()'s to a library, these are the sort of things we should be trying to remove.
I agree on general principles, but do we envision libkvm.a being used in anything outside qemu?
Definitely.
- James
Signature · 8 lines
James Morris <jmorris-gx6/[email protected]> ------------------------------------------------------------------------- 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