mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
file-posix: Include filename in locking error message
Image locking errors happening at device initialization time doesn't say which file cannot be locked, for instance, -device scsi-disk,drive=drive-1: Failed to get shared "write" lock Is another process using the image? could refer to either the overlay image or its backing image. Hoist the error_append_hint to the caller of raw_check_lock_bytes where file name is known, and include it in the error hint. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
07f426c35e
commit
b857431d2a
3 changed files with 45 additions and 43 deletions
|
@ -741,8 +741,6 @@ static int raw_check_lock_bytes(int fd, uint64_t perm, uint64_t shared_perm,
|
|||
"Failed to get \"%s\" lock",
|
||||
perm_name);
|
||||
g_free(perm_name);
|
||||
error_append_hint(errp,
|
||||
"Is another process using the image?\n");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -758,8 +756,6 @@ static int raw_check_lock_bytes(int fd, uint64_t perm, uint64_t shared_perm,
|
|||
"Failed to get shared \"%s\" lock",
|
||||
perm_name);
|
||||
g_free(perm_name);
|
||||
error_append_hint(errp,
|
||||
"Is another process using the image?\n");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -796,6 +792,9 @@ static int raw_handle_perm_lock(BlockDriverState *bs,
|
|||
if (!ret) {
|
||||
return 0;
|
||||
}
|
||||
error_append_hint(errp,
|
||||
"Is another process using the image [%s]?\n",
|
||||
bs->filename);
|
||||
}
|
||||
op = RAW_PL_ABORT;
|
||||
/* fall through to unlock bytes. */
|
||||
|
@ -2217,6 +2216,9 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
|||
/* Step two: Check that nobody else has taken conflicting locks */
|
||||
result = raw_check_lock_bytes(fd, perm, shared, errp);
|
||||
if (result < 0) {
|
||||
error_append_hint(errp,
|
||||
"Is another process using the image [%s]?\n",
|
||||
file_opts->filename);
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue