block.c (9f07429e8873124c588847b0d499cb32b9410bdd) | block.c (291680186f7f8856d943793414d1b8df6c562fc4) |
---|---|
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 --- 5645 unchanged lines hidden (view full) --- 5654 } 5655 5656 // The size for the image must always be specified, with one exception: 5657 // If we are using a backing file, we can obtain the size from there 5658 size = qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0); 5659 if (size == -1) { 5660 if (backing_file) { 5661 BlockDriverState *bs; | 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 --- 5645 unchanged lines hidden (view full) --- 5654 } 5655 5656 // The size for the image must always be specified, with one exception: 5657 // If we are using a backing file, we can obtain the size from there 5658 size = qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0); 5659 if (size == -1) { 5660 if (backing_file) { 5661 BlockDriverState *bs; |
5662 char *full_backing = g_new0(char, PATH_MAX); |
|
5662 int64_t size; 5663 int back_flags; 5664 | 5663 int64_t size; 5664 int back_flags; 5665 |
5666 bdrv_get_full_backing_filename_from_filename(filename, backing_file, 5667 full_backing, PATH_MAX, 5668 &local_err); 5669 if (local_err) { 5670 g_free(full_backing); 5671 goto out; 5672 } 5673 |
|
5665 /* backing files always opened read-only */ 5666 back_flags = 5667 flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING); 5668 5669 bs = NULL; | 5674 /* backing files always opened read-only */ 5675 back_flags = 5676 flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING); 5677 5678 bs = NULL; |
5670 ret = bdrv_open(&bs, backing_file, NULL, NULL, back_flags, | 5679 ret = bdrv_open(&bs, full_backing, NULL, NULL, back_flags, |
5671 backing_drv, &local_err); | 5680 backing_drv, &local_err); |
5681 g_free(full_backing); |
|
5672 if (ret < 0) { 5673 goto out; 5674 } 5675 size = bdrv_getlength(bs); 5676 if (size < 0) { 5677 error_setg_errno(errp, -size, "Could not get size of '%s'", 5678 backing_file); 5679 bdrv_unref(bs); --- 431 unchanged lines hidden --- | 5682 if (ret < 0) { 5683 goto out; 5684 } 5685 size = bdrv_getlength(bs); 5686 if (size < 0) { 5687 error_setg_errno(errp, -size, "Could not get size of '%s'", 5688 backing_file); 5689 bdrv_unref(bs); --- 431 unchanged lines hidden --- |