* [Qemu-devel] [PATCH] kvm: work around supported cpuid ioctl() brokenness
@ 2009-05-12 11:40 Mark McLoughlin
2009-05-17 22:56 ` [Qemu-devel] " Avi Kivity
0 siblings, 1 reply; 3+ messages in thread
From: Mark McLoughlin @ 2009-05-12 11:40 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Mark McLoughlin, qemu-devel, Avi Kivity
KVM_GET_SUPPORTED_CPUID has been known to fail to return -E2BIG
when it runs out of entries. Detect this by always trying again
with a bigger table if the ioctl() fills the table.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
target-i386/kvm.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index fe67eed..d2e1651 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -45,6 +45,8 @@ static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
cpuid = (struct kvm_cpuid2 *)qemu_mallocz(size);
cpuid->nent = max;
r = kvm_ioctl(s, KVM_GET_SUPPORTED_CPUID, cpuid);
+ if (r == 0 && cpuid->nent >= max)
+ r = -E2BIG;
if (r < 0) {
if (r == -E2BIG) {
qemu_free(cpuid);
--
1.6.0.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Qemu-devel] Re: [PATCH] kvm: work around supported cpuid ioctl() brokenness
2009-05-12 11:40 [Qemu-devel] [PATCH] kvm: work around supported cpuid ioctl() brokenness Mark McLoughlin
@ 2009-05-17 22:56 ` Avi Kivity
2009-05-19 17:55 ` [Qemu-devel] [PATCH v2] " Mark McLoughlin
0 siblings, 1 reply; 3+ messages in thread
From: Avi Kivity @ 2009-05-17 22:56 UTC (permalink / raw)
To: Mark McLoughlin; +Cc: Anthony Liguori, qemu-devel
Mark McLoughlin wrote:
> KVM_GET_SUPPORTED_CPUID has been known to fail to return -E2BIG
> when it runs out of entries. Detect this by always trying again
> with a bigger table if the ioctl() fills the table.
>
>
Looks good, except for
> cpuid = (struct kvm_cpuid2 *)qemu_mallocz(size);
> cpuid->nent = max;
> r = kvm_ioctl(s, KVM_GET_SUPPORTED_CPUID, cpuid);
> + if (r == 0 && cpuid->nent >= max)
> + r = -E2BIG;
>
Missing braces.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH v2] kvm: work around supported cpuid ioctl() brokenness
2009-05-17 22:56 ` [Qemu-devel] " Avi Kivity
@ 2009-05-19 17:55 ` Mark McLoughlin
0 siblings, 0 replies; 3+ messages in thread
From: Mark McLoughlin @ 2009-05-19 17:55 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel, Avi Kivity
KVM_GET_SUPPORTED_CPUID has been known to fail to return -E2BIG
when it runs out of entries. Detect this by always trying again
with a bigger table if the ioctl() fills the table.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
target-i386/kvm.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index fe67eed..7cdcf31 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -45,6 +45,9 @@ static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
cpuid = (struct kvm_cpuid2 *)qemu_mallocz(size);
cpuid->nent = max;
r = kvm_ioctl(s, KVM_GET_SUPPORTED_CPUID, cpuid);
+ if (r == 0 && cpuid->nent >= max) {
+ r = -E2BIG;
+ }
if (r < 0) {
if (r == -E2BIG) {
qemu_free(cpuid);
--
1.6.0.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-19 17:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-12 11:40 [Qemu-devel] [PATCH] kvm: work around supported cpuid ioctl() brokenness Mark McLoughlin
2009-05-17 22:56 ` [Qemu-devel] " Avi Kivity
2009-05-19 17:55 ` [Qemu-devel] [PATCH v2] " Mark McLoughlin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).