xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: xen-devel@lists.xenproject.org, Wei Liu <wei.liu2@citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	Alex Braunegg <alex.braunegg@gmail.com>
Subject: Re: [PATCH v4 4/4] libxl: fix cd-eject
Date: Wed, 17 Feb 2016 12:20:37 +0100	[thread overview]
Message-ID: <56C45785.7020704@citrix.com> (raw)
In-Reply-To: <22211.25400.584104.350999@mariner.uk.xensource.com>

El 16/2/16 a les 18:58, Ian Jackson ha escrit:
> Roger Pau Monne writes ("[PATCH v4 4/4] libxl: fix cd-eject"):
>> Current libxl__device_disk_set_backend implementation tried to guess the
>> backend of devices with format LIBXL_DISK_FORMAT_EMPTY, which is of course
>> doomed to fail since the disk is empty. Instead just return early from the
>> function if an empty disk is detected.
>>
>> This fixes cd ejection.
> 
> DYK when this was broken ?  Or, to put it another way, how did this
> ever work ?
> 
> ...looking at the code...
> 
> AFAICT disk_try_backend should succeed for both LIBXL_DISK_BACKEND_PHY
> and LIBXL_DISK_BACKEND_QDISK.  So even before your patch:
>
>>          }
>> -        memset(&a.stab, 0, sizeof(a.stab));
>> +        /* Disk is empty, so it's useless to try to guess the backend type. */
>> +        return 0;
>>      } else if ((disk->backend == LIBXL_DISK_BACKEND_UNKNOWN ||
> 
> libxl__device_disk_set_backend should work.

I've been looking at the code and I cannot really understand how this is
supposed to work before, none of the recent changes seem to have broken
it AFAICT, and the issue has been there for a long time (~1year), which
IMHO makes no sense, so I'm quite sure I'm missing something.

The problem is that in libxl_cdrom_insert the backend of the input
"disk" struct is set based on the backend that the disk with the same
vdev is using (see libxl.c:~2910). So if you have a CD plugged in with a
PHY backend, the backend of the input disk will also be set to PHY. Then
when you try to unplug it, the backend of the empty disk will also be
set to PHY, and disk_try_backend will fail miserably. In this case since
the backend is set _before_ calling libxl__device_disk_set_backend no
other backend is tested, and an error is returned.

I guess that all this steams from when we switched from handling RAW
files from QDISK to blkback (PHY). That was quite some time ago IIRC,
and I found it weird that nobody noticed this before. Prior to this
change the backend used for CDROM would be QDISK, which should make
everything work as expected (I've locally reverted a0a2dc and it solves
the issue).

Should I just force all devices of type CDROM to use QDISK as the
backend? Should we allow the PHY backend to handle empty files?
(pdev_path == NULL || pdev_path == "").

Roger.

  reply	other threads:[~2016-02-17 11:20 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16 17:37 [PATCH v4 0/4] Assorted fixes and improvements Roger Pau Monne
2016-02-16 17:37 ` [PATCH v4 1/4] x86/HVM: update the start info structure layout Roger Pau Monne
2016-02-16 19:13   ` Andrew Cooper
2016-02-16 20:06   ` Konrad Rzeszutek Wilk
2016-02-17 10:01     ` Roger Pau Monné
2016-02-16 21:26   ` Boris Ostrovsky
2016-02-17  9:58     ` Jan Beulich
2016-02-17 10:05       ` Roger Pau Monné
2016-02-17 14:39         ` Boris Ostrovsky
2016-02-17 14:54           ` Jan Beulich
2016-02-17 10:45   ` Samuel Thibault
2016-02-17 13:00   ` Jan Beulich
2016-02-16 17:37 ` [PATCH v4 2/4] libxl: introduce LIBXL_VGA_INTERFACE_TYPE_UNKNOWN Roger Pau Monne
2016-02-24 12:08   ` Wei Liu
2016-03-01 16:06     ` Ian Jackson
2016-02-16 17:37 ` [PATCH v4 3/4] libelf: rewrite symtab/strtab loading Roger Pau Monne
2016-02-26 13:15   ` Jan Beulich
2016-02-26 17:02     ` Roger Pau Monné
2016-02-29  9:31       ` Jan Beulich
2016-02-29 10:57         ` Roger Pau Monné
2016-02-29 12:14           ` Jan Beulich
2016-02-29 16:20             ` Roger Pau Monné
2016-02-29 16:41               ` Jan Beulich
2016-02-16 17:37 ` [PATCH v4 4/4] libxl: fix cd-eject Roger Pau Monne
2016-02-16 17:58   ` Ian Jackson
2016-02-17 11:20     ` Roger Pau Monné [this message]
2016-02-17 11:42       ` Ian Campbell
2016-02-17 12:15       ` Ian Jackson
2016-02-17 17:20         ` [PATCH v6] libxl: allow 'phy' backend to use empty files Roger Pau Monne
2016-02-18 10:27           ` Alex Braunegg
2016-02-19 17:30           ` Ian Jackson
2016-02-19 17:41             ` Roger Pau Monné
2016-02-19 18:01               ` [PATCH v7] " Roger Pau Monne
2016-03-01  9:51                 ` Roger Pau Monné
2016-03-03 15:41                 ` Ian Jackson
2016-03-31 16:20                   ` Roger Pau Monné
2016-04-01 14:06                     ` Ian Jackson
2016-04-05 16:48           ` [PATCH v6] " George Dunlap
2016-04-05 21:45             ` Alex Braunegg

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=56C45785.7020704@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=alex.braunegg@gmail.com \
    --cc=ian.campbell@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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).