From: Avi Kivity <avi@redhat.com>
To: Juan Quintela <quintela@trasno.org>
Cc: Anthony Liguori <anthony@codemonkey.ws>,
qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH] kvm: Add helpers for checking and requiring kvm extensions
Date: Mon, 04 May 2009 09:57:55 +0300 [thread overview]
Message-ID: <49FE91F3.8070806@redhat.com> (raw)
In-Reply-To: <m38wldmkgu.fsf@neno.mitica>
Juan Quintela wrote:
> Avi Kivity <avi@redhat.com> wrote:
>
> Hi
>
>
>> diff --git a/kvm-all.c b/kvm-all.c
>> index 36659a9..1642a2a 100644
>> --- a/kvm-all.c
>> +++ b/kvm-all.c
>> @@ -64,6 +64,30 @@ struct KVMState
>>
>> static KVMState *kvm_state;
>>
>> +int kvm_check_extension(int extension)
>> +{
>> + int ret;
>> +
>> + ret = kvm_ioctl(kvm_state, KVM_CHECK_EXTENSION, extension);
>> + if (ret < 0) {
>> + fprintf(stderr, "KVM_CHECK_EXTENSION failed: %s\n", strerror(errno));
>> + exit(1);
>> + }
>> + return ret;
>> +}
>>
>>
> Are you sure you want the exit(1) in this case?
>
A negative result of kvm_ioctl() means the ioctl itself failed. This
shouldn't happen, so we exit.
If the extension is not present, it returns 0.
> With the exit() call, you are unable to check if one extension is
> present at all. And you check the return of the following code.
>
>> s->coalesced_mmio = 0;
>> #ifdef KVM_CAP_COALESCED_MMIO
>> - ret = kvm_ioctl(s, KVM_CHECK_EXTENSION, KVM_CAP_COALESCED_MMIO);
>> - if (ret > 0)
>> - s->coalesced_mmio = ret;
>> + s->coalesced_mmio = kvm_check_extension(KVM_CAP_COALESCED_MMIO);
>> #endif
>>
>
>
Here we use the return value (0 or 1).
> You can remove the ifdef at this point.
>
It won't compile if KVM_CAP_COLAESCED_MMIO is not defined.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
WARNING: multiple messages have this Message-ID (diff)
From: Avi Kivity <avi@redhat.com>
To: Juan Quintela <quintela@trasno.org>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH] kvm: Add helpers for checking and requiring kvm extensions
Date: Mon, 04 May 2009 09:57:55 +0300 [thread overview]
Message-ID: <49FE91F3.8070806@redhat.com> (raw)
In-Reply-To: <m38wldmkgu.fsf@neno.mitica>
Juan Quintela wrote:
> Avi Kivity <avi@redhat.com> wrote:
>
> Hi
>
>
>> diff --git a/kvm-all.c b/kvm-all.c
>> index 36659a9..1642a2a 100644
>> --- a/kvm-all.c
>> +++ b/kvm-all.c
>> @@ -64,6 +64,30 @@ struct KVMState
>>
>> static KVMState *kvm_state;
>>
>> +int kvm_check_extension(int extension)
>> +{
>> + int ret;
>> +
>> + ret = kvm_ioctl(kvm_state, KVM_CHECK_EXTENSION, extension);
>> + if (ret < 0) {
>> + fprintf(stderr, "KVM_CHECK_EXTENSION failed: %s\n", strerror(errno));
>> + exit(1);
>> + }
>> + return ret;
>> +}
>>
>>
> Are you sure you want the exit(1) in this case?
>
A negative result of kvm_ioctl() means the ioctl itself failed. This
shouldn't happen, so we exit.
If the extension is not present, it returns 0.
> With the exit() call, you are unable to check if one extension is
> present at all. And you check the return of the following code.
>
>> s->coalesced_mmio = 0;
>> #ifdef KVM_CAP_COALESCED_MMIO
>> - ret = kvm_ioctl(s, KVM_CHECK_EXTENSION, KVM_CAP_COALESCED_MMIO);
>> - if (ret > 0)
>> - s->coalesced_mmio = ret;
>> + s->coalesced_mmio = kvm_check_extension(KVM_CAP_COALESCED_MMIO);
>> #endif
>>
>
>
Here we use the return value (0 or 1).
> You can remove the ifdef at this point.
>
It won't compile if KVM_CAP_COLAESCED_MMIO is not defined.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
next prev parent reply other threads:[~2009-05-04 6:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-03 11:34 [PATCH] kvm: Add helpers for checking and requiring kvm extensions Avi Kivity
2009-05-03 11:34 ` [Qemu-devel] " Avi Kivity
2009-05-04 6:49 ` Juan Quintela
2009-05-04 6:49 ` [Qemu-devel] " Juan Quintela
2009-05-04 6:57 ` Avi Kivity [this message]
2009-05-04 6:57 ` Avi Kivity
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=49FE91F3.8070806@redhat.com \
--to=avi@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@trasno.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.