On 7/28/20 8:15 AM, Vladimir Sementsov-Ogievskiy wrote:
28.07.2020 00:58, Nir Soffer wrote:
When converting to qcow2 compressed format, the last step is a special
zero length compressed write, ending in call to bdrv_co_truncate(). This
call always fails for the nbd driver since it does not implement
bdrv_co_truncate().
+static int coroutine_fn nbd_co_truncate(BlockDriverState *bs, int64_t
offset,
+ bool exact, PreallocMode
prealloc,
+ BdrvRequestFlags flags, Error
**errp)
+{
+ BDRVNBDState *s = bs->opaque;
+
+ if (offset != s->info.size && exact) {
+ error_setg(errp, "Cannot resize NBD nodes");
+ return -ENOTSUP;
+ }
+
+ if (offset > s->info.size) {
+ error_setg(errp, "Cannot grow NBD nodes");
+ return -EINVAL;
+ }
I think that ENOTSUP actually is valid error code for both cases.. NBD
protocol has experimental extension NBD_CMD_RESIZE, so one day we'll
implement this. So, I think, it's not invalid, but just not supported
yet. Still, not a big deal, so with ENOTSUP or EINVAL:
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com>
Indeed, if we ever get around to fully specifying how NBD_CMD_RESIZE
should even work, we'll be revisiting this code to implement that.
Also, may be better to manage it in generic layer:
If driver doesn't implement bdrv_co_truncate handler (or return
ENOTSUP), and we are truncating to the same size, or to smaller size
with exact=false, we just report success? Then we'll drop same code from
file-posix.c
That was also my question on v1; but given the closeness to the release,
this is a minimal change appropriate for -rc2, while changing the
generic layer may have unintended consequences.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org