All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Schmitt" <scdbackup@gmx.net>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, stefanha@gmail.com, armbru@redhat.com,
	pbonzini@redhat.com
Subject: Re: [Qemu-devel] Summary of CD, DVD, BD passthrough tests with -drive if=none -device virtio-blk
Date: Tue, 08 Nov 2011 20:13:42 +0100	[thread overview]
Message-ID: <9749351301123@192.168.2.69> (raw)
In-Reply-To: <97494408320282@192.168.2.69>

Hi,

i am now testing a hack that adds O_EXCL to the call of qemu_open()
in block/raw-posix.c. Just as proof-of-concept.

This is Linux-host-specific, of course.

-----------------------------------------------------------------------

As first i learned to distinguish between octal and hex. :))
So my question "(What flag is 0x800, btw ?)" is obsolete.

-----------------------------------------------------------------------

During the O_EXCL test i was bitten by a little pitfall of
the proposed virtual device setup. It happens with the well
tested version of my git clone, too.

If there is no medium inside, then qemu start-up fails with

  qemu-system-x86_64: -device virtio-blk-pci,drive=scsicd,logical_block_size=2048,physical_block_size=2048: Device needs media, but drive is empty
  qemu-system-x86_64: -device virtio-blk-pci,drive=scsicd,logical_block_size=2048,physical_block_size=2048: Device 'virtio-blk-pci' could not be initialized

If there is a blank DVD-RW medium loaded. i get:

  qemu-system-x86_64: -drive file=/dev/sr2,if=none,id=scsicd: could not open disk image /dev/sr2: Input/output error

Would it be possible to make qemu more tolerant here ?

(For a better error message, one would would have to inquire the medium.
 READ DISC INFORMATION, Disc Status 00b "Empty" means blank medium,
 MMC-1 table 131, MMC-3 table 163.
 No medium would be indicated by sense code 2 3A xx MEDIUM NOT PRESENT.)

-----------------------------------------------------------------------

I am worrying now about my happy ejecting and changing of media, while
qemu has open the same device descriptor all the time.

Is this sane for the host system resp. for qemu ?
If above initialization of 'virtio-blk-pci' is needed, then wouldn't
it be needed after each media change ?

There are no visible bad effects, though.

-----------------------------------------------------------------------
For O_EXCL tests:

The start terminal now says

  block/raw-posix.c: raw_open_common("/dev/sr2", 0x1800)
  block/raw-posix.c: raw_open_common("/dev/sr2", 0x1802)
  block/raw-posix.c: /dev/sr O_EXCL test : s->open_flags is now 0x1882

I added O_EXCL only to the open call with O_RDWR, because this combination
is known to work on older Linux kernels, where O_RDONLY sometimes ignores
the extra meaning of O_EXCL. (Which is not described in man 2 open.)

In any case one has to avoid to use O_EXCLi on that device, while there
is still another own open O_EXCL file descriptor for the device.
Else self-denial.

One could re-try without O_EXCL after a failure. That would still be
more protection than there is now. libburn and wodim wait a second and
retry with O_EXCL, because there is sometimes a delay with unlocking.

-----------------------------------------------------------------------

On the host system, xorriso now reports as i wish

  libburn : SORRY : Cannot open busy device '/dev/sr2' : Device or resource busy
  0  -dev '/dev/sr0' rwrw-- :  'TSSTcorp' 'DVD-ROM SH-D162C' 
  1  -dev '/dev/sr1' rwrw-- :  'TSSTcorp' 'CDDVDW SH-S223B' 

 
I made a quick tour through my emerging qemu test wiki page with DVD-RW.
It all looks as good as before.


If there is a further opening call with O_RDWR, then it does not happen
with my setup, my use cases, and my hack in raw_open_common():

  + if (strncmp(filename, "/dev/sr", 7) == 0 && (s->open_flags & O_RDWR)) {
  +     s->open_flags |= O_EXCL;
  +     printf("block/raw-posix.c: /dev/sr O_EXCL test : s->open_flags is now 0x%x\n", s->open_flags);
  + }
  +
    s->fd = -1;
    fd = qemu_open(filename, s->open_flags, 0644);

-----------------------------------------------------------------------


Have a nice day :)

Thomas

      reply	other threads:[~2011-11-08 19:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-08 16:44 [Qemu-devel] Summary of CD, DVD, BD passthrough tests with -drive if=none -device virtio-blk Thomas Schmitt
2011-11-08 19:13 ` Thomas Schmitt [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=9749351301123@192.168.2.69 \
    --to=scdbackup@gmx.net \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --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 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.