block.c (16121fa39e1ec17308162af4de5c5f6c01c1cce1) block.c (dbecebddfa4932d1c83915bcb9b5ba5984eb91be)
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

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

973 }
974
975 bs->open_flags &= ~BDRV_O_NO_BACKING;
976 if (qdict_haskey(options, "file.filename")) {
977 backing_filename[0] = '\0';
978 } else if (bs->backing_file[0] == '\0' && qdict_size(options) == 0) {
979 QDECREF(options);
980 return 0;
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

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

973 }
974
975 bs->open_flags &= ~BDRV_O_NO_BACKING;
976 if (qdict_haskey(options, "file.filename")) {
977 backing_filename[0] = '\0';
978 } else if (bs->backing_file[0] == '\0' && qdict_size(options) == 0) {
979 QDECREF(options);
980 return 0;
981 } else {
982 bdrv_get_full_backing_filename(bs, backing_filename,
983 sizeof(backing_filename));
981 }
982
983 bs->backing_hd = bdrv_new("");
984 }
985
986 bs->backing_hd = bdrv_new("");
984 bdrv_get_full_backing_filename(bs, backing_filename,
985 sizeof(backing_filename));
986
987 if (bs->backing_format[0] != '\0') {
988 back_drv = bdrv_find_format(bs->backing_format);
989 }
990
991 /* backing files always opened read-only */
992 back_flags = bs->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT);
993
994 ret = bdrv_open(bs->backing_hd,
995 *backing_filename ? backing_filename : NULL, options,
996 back_flags, back_drv, &local_err);
987
988 if (bs->backing_format[0] != '\0') {
989 back_drv = bdrv_find_format(bs->backing_format);
990 }
991
992 /* backing files always opened read-only */
993 back_flags = bs->open_flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT);
994
995 ret = bdrv_open(bs->backing_hd,
996 *backing_filename ? backing_filename : NULL, options,
997 back_flags, back_drv, &local_err);
998 pstrcpy(bs->backing_file, sizeof(bs->backing_file),
999 bs->backing_hd->file->filename);
997 if (ret < 0) {
998 bdrv_unref(bs->backing_hd);
999 bs->backing_hd = NULL;
1000 bs->open_flags |= BDRV_O_NO_BACKING;
1001 error_propagate(errp, local_err);
1002 return ret;
1003 }
1004 return 0;

--- 3645 unchanged lines hidden ---
1000 if (ret < 0) {
1001 bdrv_unref(bs->backing_hd);
1002 bs->backing_hd = NULL;
1003 bs->open_flags |= BDRV_O_NO_BACKING;
1004 error_propagate(errp, local_err);
1005 return ret;
1006 }
1007 return 0;

--- 3645 unchanged lines hidden ---