[libvirt] [PATCH 2/2] storage: Improve error handling on cdrom backend
Peter Krempa
pkrempa at redhat.com
Wed Jul 11 07:08:52 UTC 2018
On Wed, Jul 11, 2018 at 11:07:53 +0800, Han Han wrote:
> Implement virFileCheckCDROM in virStorageBackendVolOpen to check if
> cdrom backend is ready. Skip the error of cdrom not ready.
>
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1596096
>
> Signed-off-by: Han Han <hhan at redhat.com>
> ---
> src/storage/storage_util.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
> index da99043e0a..38a91541fd 100644
> --- a/src/storage/storage_util.c
> +++ b/src/storage/storage_util.c
> @@ -1506,7 +1506,7 @@ int
> virStorageBackendVolOpen(const char *path, struct stat *sb,
> unsigned int flags)
> {
> - int fd, mode = 0;
> + int fd, cd_status, mode = 0;
One variable per line please.
> char *base = last_component(path);
> bool noerror = (flags & VIR_STORAGE_VOL_OPEN_NOERROR);
>
> @@ -1545,6 +1545,19 @@ virStorageBackendVolOpen(const char *path, struct stat *sb,
> return -1;
> }
>
> + if (virFileCheckCDROM(path, &cd_status)) {
> + if (cd_status != VIR_FILE_CDROM_DISC_OK) {
> + if (noerror) {
> + VIR_WARN("ignoring CDROM %s is not ready", path);
This is pointless. It only adds an entry in the log which will be
ignored.
> + return -2;
> + }
> + virReportError(VIR_ERR_INTERNAL_ERROR,
> + _("CDROM %s is not ready", path);
> + return -1;
> + }
> + VIR_INFO("CDROM backend %s is ok", path);
Also this is pointless.
> + }
> +
> /* O_NONBLOCK should only matter during open() for fifos and
> * sockets, which we already filtered; but using it prevents a
> * TOCTTOU race. However, later on we will want to read() the
> --
> 2.17.1
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
-------------- 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/20180711/74593e80/attachment-0001.sig>
More information about the libvir-list
mailing list