qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	Programmingkid <programmingkidx@gmail.com>,
	Markus Armbruster <armbru@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	qemu-devel qemu-devel <qemu-devel@nongnu.org>,
	Qemu-block <qemu-block@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] block.c: fix real cdrom detection
Date: Thu, 25 Jun 2015 19:19:14 +0200	[thread overview]
Message-ID: <558C3812.7060202@redhat.com> (raw)
In-Reply-To: <558C295C.2030108@redhat.com>



On 25/06/2015 18:16, Paolo Bonzini wrote:
> 
> 
> On 25/06/2015 18:12, Laurent Vivier wrote:
>>
>>
>> On 25/06/2015 17:48, Paolo Bonzini wrote:
>>>
>>> On 25/06/2015 17:32, Programmingkid wrote:
>>>>> I think we are going to have to agree to disagree. I have never
>>>>> used the /dev/sr(0 | 1) devices and don't see how they would be
>>>>> effected by this patch. Are you trying to say the /dev/sr(0 | 1)
>>>>> devices *should* be handled by this patch?
>>>>
>>>> Thinking about your question some more, I see what you mean. On Linux
>>>> /dev/sr0 refers to the cdrom drive. Also on Linux, the /dev/cdrom
>>>> link refers to the /dev/sr0 device file. So if you just use
>>>> /dev/cdrom, you are good.
>>>
>>> Well, that's not how things work.
>>>
>>> If you do things like that, you end up with a bunch of hacks, not with a
>>> decent piece of software.
>>>
>>> There is support for CD-ROM passthrough on Linux and FreeBSD in
>>> block/raw-posix.c.  Perhaps the FreeBSD support can be extended to OS X
>>> as well.
>>>
>>
>> In fact, programmingkid, you should fix it in hdev_open() where there is
>> already a #if __APPLE__ .
>>
>> Paolo, I agree with you but :
>>
>> hdev_open()
>>
>> #if defined(__linux__)
>>     {
>>         char resolved_path[ MAXPATHLEN ], *temp;
>>
>>         temp = realpath(filename, resolved_path);
>>         if (temp && strstart(temp, "/dev/sg", NULL)) {
>>             bs->sg = 1;
>>         }
>> #endif
>>
>> I'm wondering who had this strange idea... :)
> 
> I was very scared to type "git blame" here. :)  But the question is also

http://geek-and-poke.com/2013/11/24/simply-explained

BTW, it is a legacy from 2006:

19cb373 better support of host drives

coming from MacOS X (again!):

3b0d4f6 OS X: support for the built in CD-ROM drive (Mike Kronenberg)

> where to put the checks.  Putting it at a random place in block.c is not
> a good idea.
> 
> But yes, this is also bad.  It should use stat and check the major/minor
> numbers.

Yes, we should check if major is SCSI_GENERIC_MAJOR (21) (on linux).

We can also try to send an SG command like in cdrom_probe_device().
Something like in scsi_generic_realize():

    rc = blk_ioctl(s->conf.blk, SG_GET_VERSION_NUM, &sg_version);
    if (rc < 0) {
        error_setg(errp, "cannot get SG_IO version number: %s.  "
                         "Is this a SCSI device?",
                         strerror(-rc));
        return;
    }

Laurent

  reply	other threads:[~2015-06-25 17:19 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-23 17:56 [Qemu-devel] [PATCH] block.c: fix real cdrom detection Programmingkid
2015-06-23 18:06 ` John Snow
2015-06-23 18:26   ` Programmingkid
2015-06-25  6:53     ` Markus Armbruster
2015-06-25 15:14       ` Programmingkid
2015-06-25 15:32         ` Programmingkid
2015-06-25 15:47           ` Programmingkid
2015-06-25 15:48           ` Paolo Bonzini
2015-06-25 16:12             ` Laurent Vivier
2015-06-25 16:16               ` Paolo Bonzini
2015-06-25 17:19                 ` Laurent Vivier [this message]
2015-06-26  9:14                   ` Laurent Vivier
2015-06-26  9:20                   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-06-25 18:07                 ` [Qemu-devel] " Programmingkid
2015-06-25 20:51                   ` Paolo Bonzini
2015-06-25 17:56               ` Programmingkid
2015-06-25 18:01                 ` Paolo Bonzini
2015-06-25 18:01                 ` Peter Maydell
2015-06-28 23:43                   ` Programmingkid
2015-06-29  0:29                     ` Laurent Vivier
2015-06-29  0:56                       ` Programmingkid
2015-06-29  3:01                       ` Programmingkid
2015-06-29 10:36                         ` Laurent Vivier
2015-06-25 17:57             ` Programmingkid
2015-06-25 13:31     ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-06-25 15:11       ` Programmingkid
2015-06-26  9:34         ` Stefan Hajnoczi
2015-06-26 15:50           ` Programmingkid
2015-06-26 20:01             ` 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=558C3812.7060202@redhat.com \
    --to=lvivier@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@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 \
    /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).