qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Programmingkid <programmingkidx@gmail.com>
Cc: Laurent Vivier <lvivier@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Qemu-block <qemu-block@nongnu.org>,
	Stefan Hajnoczi <stefanha@gmail.com>,
	qemu-devel qemu-devel <qemu-devel@nongnu.org>,
	Paolo Bonzini <pbonzini@redhat.com>, John Snow <jsnow@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] raw-posix.c: remove raw device access for cdrom
Date: Wed, 8 Jul 2015 15:11:15 +0200	[thread overview]
Message-ID: <20150708131115.GK4117@noname.redhat.com> (raw)
In-Reply-To: <EDC992B2-1866-4D42-9B36-39CD79D38223@gmail.com>

Am 08.07.2015 um 14:56 hat Programmingkid geschrieben:
> 
> On Jul 8, 2015, at 7:01 AM, Kevin Wolf wrote:
> 
> > Am 08.07.2015 um 12:47 hat Laurent Vivier geschrieben:
> >> 
> >> 
> >> On 08/07/2015 12:31, Kevin Wolf wrote:
> >>> Am 02.07.2015 um 16:18 hat Laurent Vivier geschrieben:
> >>>> 
> >>>> 
> >>>> On 02/07/2015 16:03, Paolo Bonzini wrote:
> >>>>> 
> >>>>> 
> >>>>> On 02/07/2015 15:58, Laurent Vivier wrote:
> >>>>>> Since any /dev entry can be treated as a raw disk image, it is worth
> >>>>>> noting which devices can be accessed when and how. /dev/rdisk nodes are
> >>>>>> character-special devices, but are "raw" in the BSD sense and force
> >>>>>> block-aligned I/O. They are closer to the physical disk than the buffer
> >>>>>> cache. /dev/disk nodes, on the other hand, are buffered block-special
> >>>>>> devices and are used primarily by the kernel's filesystem code.
> >>>>> 
> >>>>> So the right thing to do would not be just to set need_alignment, but to
> >>>>> probe it like we do on Linux for BDRV_O_NO_CACHE.
> >>>>> 
> >>>>> I'm okay with doing the simple thing, but it needs a comment for non-BSDers.
> >>>> 
> >>>> So, what we have to do, in our case, for MacOS X cdrom, is something like:
> >>>> 
> >>>> ... GetBSDPath ...
> >>>> ...
> >>>>    if (flags & BDRV_O_NOCACHE) {
> >>>>        strcat(bsdPath, "r");
> >>>>    }
> >>>> ...
> >>> 
> >>> I would avoid such magic. What we could do is rejecting /dev/rdisk nodes
> >>> without BDRV_O_NOCACHE.
> >> 
> >> It's not how it works...
> >> 
> >> Look in hdev_open().
> >> 
> >> If user provides /dev/cdrom on the command line, in the case of MacOS X,
> >> QEMU searches for a cdrom drive in the system and set filename to
> >> /dev/rdiskX according to the result.
> > 
> > Oh, we're already playing such games... I guess you're right then.
> > 
> > It even seems to be not only for '/dev/cdrom', but for everything
> > starting with this string. Does anyone know what's the reason for that?
> > 
> > Also, I guess before doing strcat() on bsdPath, we should check the
> > buffer length...
> 
> By buffer, do you mean the bsdPath variable?

Yes. In theory, bsdPath could be completely filled with the path
returned by GetBSDPath() because we pass sizeof(bsdPath) as maxPathSize.
Appending "s0" would then overflow the buffer.

I'll admit that this is rather unlikely to happen, but being careful
when dealing with strings can never hurt.

Kevin

  reply	other threads:[~2015-07-08 13:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01 22:13 [Qemu-devel] [PATCH] raw-posix.c: remove raw device access for cdrom Programmingkid
2015-07-01 22:32 ` M A
2015-07-02  7:18 ` Paolo Bonzini
2015-07-02  7:39   ` Laurent Vivier
2015-07-02  7:54     ` Paolo Bonzini
2015-07-02 11:14 ` Stefan Hajnoczi
2015-07-02 12:24   ` Laurent Vivier
2015-07-02 13:47     ` Paolo Bonzini
2015-07-02 13:58       ` Laurent Vivier
2015-07-02 14:03         ` Paolo Bonzini
2015-07-02 14:18           ` Laurent Vivier
2015-07-02 14:20             ` Paolo Bonzini
2015-07-02 14:33               ` Laurent Vivier
2015-07-02 23:19                 ` Programmingkid
2015-07-03  0:46                 ` [Qemu-devel] [PATCH v2] " Programmingkid
2015-07-08 10:31             ` [Qemu-devel] [PATCH] " Kevin Wolf
2015-07-08 10:47               ` Laurent Vivier
2015-07-08 11:01                 ` Kevin Wolf
2015-07-08 12:56                   ` Programmingkid
2015-07-08 13:11                     ` Kevin Wolf [this message]
2015-07-08 13:14                       ` Programmingkid
2015-07-08 12:59                   ` Laurent Vivier
     [not found]   ` <33C18758-309D-4A09-8276-31641B63B963@gmail.com>
     [not found]     ` <CAJSP0QWrh0qcX9u9iYVfCJrtgh9w0Aw4dW9jUTQRXhrBoseC2g@mail.gmail.com>
     [not found]       ` <6FE80FDC-996C-45B6-B5F8-F4F16A10F396@gmail.com>
     [not found]         ` <CAJSP0QW9SOLM2+UQW0bV4rr407XWmdNp6VFBaUabx14_iM5xPQ@mail.gmail.com>
     [not found]           ` <A36B6438-BC34-4C2A-B8CA-8EDFB9747AF3@gmail.com>
2015-07-07  8:05             ` Stefan Hajnoczi

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=20150708131115.GK4117@noname.redhat.com \
    --to=kwolf@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=programmingkidx@gmail.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.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).