kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Matlack <dmatlack@google.com>
To: Andrew Jones <drjones@redhat.com>
Cc: kvm list <kvm@vger.kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Aaron Lewis <aaronlewis@google.com>
Subject: Re: [PATCH] KVM: selftests: Print a message if /dev/kvm is missing
Date: Mon, 10 May 2021 10:23:19 -0700	[thread overview]
Message-ID: <CALzav=fptvvuY==LQ7pzA3y4aoEz4N+2TpiVvjTueZNyj8uwgw@mail.gmail.com> (raw)
In-Reply-To: <20210510063236.5ekmlulazelvl2s6@gator>

On Sun, May 9, 2021 at 11:32 PM Andrew Jones <drjones@redhat.com> wrote:
>
> On Fri, May 07, 2021 at 01:51:45PM -0700, David Matlack wrote:
> > > >  static void vm_open(struct kvm_vm *vm, int perm)
> > > >  {
> > > > -     vm->kvm_fd = open(KVM_DEV_PATH, perm);
> > >
> > > I don't think we should change this one, otherwise the user provided
> > > perms are ignored.
> >
> > Good catch. I don't see any reason to exclude this case, but we do need
> > to pass `perm` down to open_kvm_dev_path_or_exit().
> >
>
> I've reviewed v2 and gave it an r-b, since I don't have overly strong
> opinion about this, but I actually liked that open_kvm_dev_path_or_exit()
> didn't take any arguments. To handle this case I would have either left
> it open coded, like it was, or created something like
>
> int _open_kvm_dev_path_or_exit(int flags)
> {
>    int fd = open(KVM_DEV_PATH, flags);
>    if (fd < 0)
>      ...exit skip...
>    return fd;
> }
>
> int open_kvm_dev_path_or_exit(void)
> {
>   return _open_kvm_dev_path_or_exit(O_RDONLY);
> }

I agree so long as hiding O_RDONLY does not decrease code readability.
I could not find any place in KVM where the R/W permissions on
/dev/kvm played a role, so I'm inclined to agree it's better to hide
the permissions.

I'll send another version with this change along with the comment fix.

Thanks.

>
> Thanks,
> drew
>

      reply	other threads:[~2021-05-10 17:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07 19:05 [PATCH] KVM: selftests: Print a message if /dev/kvm is missing David Matlack
2021-05-07 20:14 ` Andrew Jones
2021-05-07 20:51   ` David Matlack
2021-05-10  6:32     ` Andrew Jones
2021-05-10 17:23       ` David Matlack [this message]

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='CALzav=fptvvuY==LQ7pzA3y4aoEz4N+2TpiVvjTueZNyj8uwgw@mail.gmail.com' \
    --to=dmatlack@google.com \
    --cc=aaronlewis@google.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).