Revision 77a5a000 block/qed.c

b/block/qed.c
1333 1333

  
1334 1334
static int bdrv_qed_truncate(BlockDriverState *bs, int64_t offset)
1335 1335
{
1336
    return -ENOTSUP;
1336
    BDRVQEDState *s = bs->opaque;
1337
    uint64_t old_image_size;
1338
    int ret;
1339

  
1340
    if (!qed_is_image_size_valid(offset, s->header.cluster_size,
1341
                                 s->header.table_size)) {
1342
        return -EINVAL;
1343
    }
1344

  
1345
    /* Shrinking is currently not supported */
1346
    if ((uint64_t)offset < s->header.image_size) {
1347
        return -ENOTSUP;
1348
    }
1349

  
1350
    old_image_size = s->header.image_size;
1351
    s->header.image_size = offset;
1352
    ret = qed_write_header_sync(s);
1353
    if (ret < 0) {
1354
        s->header.image_size = old_image_size;
1355
    }
1356
    return ret;
1337 1357
}
1338 1358

  
1339 1359
static int64_t bdrv_qed_getlength(BlockDriverState *bs)

Also available in: Unified diff