block.c (add8200dd14041d059cc376eff91461fadd93ec5) block.c (e54ee1b385a9d084b4052b6db7391ea2fd799fa8)
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 1192 unchanged lines hidden (view full) ---

1201 if (read_only) {
1202 ret = bdrv_reopen_set_read_only(parent, false, errp);
1203 if (ret < 0) {
1204 return ret;
1205 }
1206 }
1207
1208 ret = bdrv_change_backing_file(parent, filename,
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 1192 unchanged lines hidden (view full) ---

1201 if (read_only) {
1202 ret = bdrv_reopen_set_read_only(parent, false, errp);
1203 if (ret < 0) {
1204 return ret;
1205 }
1206 }
1207
1208 ret = bdrv_change_backing_file(parent, filename,
1209 base->drv ? base->drv->format_name : "");
1209 base->drv ? base->drv->format_name : "",
1210 false);
1210 if (ret < 0) {
1211 error_setg_errno(errp, -ret, "Could not update backing file link");
1212 }
1213
1214 if (read_only) {
1215 bdrv_reopen_set_read_only(parent, true, NULL);
1216 }
1217

--- 3457 unchanged lines hidden (view full) ---

4675/*
4676 * Return values:
4677 * 0 - success
4678 * -EINVAL - backing format specified, but no file
4679 * -ENOSPC - can't update the backing file because no space is left in the
4680 * image file header
4681 * -ENOTSUP - format driver doesn't support changing the backing file
4682 */
1211 if (ret < 0) {
1212 error_setg_errno(errp, -ret, "Could not update backing file link");
1213 }
1214
1215 if (read_only) {
1216 bdrv_reopen_set_read_only(parent, true, NULL);
1217 }
1218

--- 3457 unchanged lines hidden (view full) ---

4676/*
4677 * Return values:
4678 * 0 - success
4679 * -EINVAL - backing format specified, but no file
4680 * -ENOSPC - can't update the backing file because no space is left in the
4681 * image file header
4682 * -ENOTSUP - format driver doesn't support changing the backing file
4683 */
4683int bdrv_change_backing_file(BlockDriverState *bs,
4684 const char *backing_file, const char *backing_fmt)
4684int bdrv_change_backing_file(BlockDriverState *bs, const char *backing_file,
4685 const char *backing_fmt, bool warn)
4685{
4686 BlockDriver *drv = bs->drv;
4687 int ret;
4688
4689 if (!drv) {
4690 return -ENOMEDIUM;
4691 }
4692
4693 /* Backing file format doesn't make sense without a backing file */
4694 if (backing_fmt && !backing_file) {
4695 return -EINVAL;
4696 }
4697
4686{
4687 BlockDriver *drv = bs->drv;
4688 int ret;
4689
4690 if (!drv) {
4691 return -ENOMEDIUM;
4692 }
4693
4694 /* Backing file format doesn't make sense without a backing file */
4695 if (backing_fmt && !backing_file) {
4696 return -EINVAL;
4697 }
4698
4699 if (warn && backing_file && !backing_fmt) {
4700 warn_report("Deprecated use of backing file without explicit "
4701 "backing format, use of this image requires "
4702 "potentially unsafe format probing");
4703 }
4704
4698 if (drv->bdrv_change_backing_file != NULL) {
4699 ret = drv->bdrv_change_backing_file(bs, backing_file, backing_fmt);
4700 } else {
4701 ret = -ENOTSUP;
4702 }
4703
4704 if (ret == 0) {
4705 pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_file ?: "");

--- 2186 unchanged lines hidden ---
4705 if (drv->bdrv_change_backing_file != NULL) {
4706 ret = drv->bdrv_change_backing_file(bs, backing_file, backing_fmt);
4707 } else {
4708 ret = -ENOTSUP;
4709 }
4710
4711 if (ret == 0) {
4712 pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_file ?: "");

--- 2186 unchanged lines hidden ---