[libvirt] [PATCH 11/35] util: file: Add helper to determine whether a path is a CDROM

Peter Krempa pkrempa at redhat.com
Wed May 2 07:47:08 UTC 2018


On Tue, May 01, 2018 at 20:25:09 -0400, John Ferlan wrote:
> 
> 
> On 04/25/2018 11:15 AM, Peter Krempa wrote:
> > Add detection mechanism which will allow to check whether a path to a
> > block device is a physical CDROM drive. This will be useful once we will
> > need to pass it to hypervisors.
> > 
> > The linux implementation uses an ioctl to do the detection, while the
> > fallback uses a simple string prefix match.
> > 
> > Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> > ---
> >  src/libvirt_private.syms |  1 +
> >  src/util/virfile.c       | 56 +++++++++++++++++++++++++++++++++++++++++++++++-
> >  src/util/virfile.h       |  2 ++
> >  3 files changed, 58 insertions(+), 1 deletion(-)
> > 
> 
> Should this be a replacement for qemuDomainFilePathIsHostCDROM used for
> qemuDomainObjCheckDiskTaint?

Very good point. This code is actually "inspired" by the code that qemu
uses for CDROM detection, so I think we should actually use it instead
of the string checks.

> Not a problem with this code, but I think there should only be one place
> that we determine host CDROM and it doesn't matter to me the mechanism.
> Just trying to avoid multiple means to get the same answer.

I agree. If it is deemed that it's okay to do ioctl()s on the cdrom
device for libvirt I'll gladly replace the existing code. The advantage
of the ioctl based code is that it works regardless of the name of the
device.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180502/c21649f3/attachment-0001.sig>


More information about the libvir-list mailing list