* THE SOFTWARE.
*/
#include "qemu/osdep.h"
-#include "trace.h"
+#include "block/trace.h"
#include "block/block_int.h"
#include "block/blockjob.h"
#include "block/nbd.h"
bdrv_refresh_filename(bs);
/* Check if any unknown options were used */
- if (options && (qdict_size(options) != 0)) {
+ if (qdict_size(options) != 0) {
const QDictEntry *entry = qdict_first(options);
if (flags & BDRV_O_PROTOCOL) {
error_setg(errp, "Block protocol '%s' doesn't support the option "
static int qsort_strcmp(const void *a, const void *b)
{
- return strcmp(a, b);
+ return strcmp(*(char *const *)a, *(char *const *)b);
}
void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
}
}
+ for (i = 0; i < (int)ARRAY_SIZE(block_driver_modules); i++) {
+ const char *format_name = block_driver_modules[i].format_name;
+
+ if (format_name) {
+ bool found = false;
+ int j = count;
+
+ while (formats && j && !found) {
+ found = !strcmp(formats[--j], format_name);
+ }
+
+ if (!found) {
+ formats = g_renew(const char *, formats, count + 1);
+ formats[count++] = format_name;
+ }
+ }
+ }
+
qsort(formats, count, sizeof(formats[0]), qsort_strcmp);
for (i = 0; i < count; i++) {
int is_protocol = 0;
BlockDriverState *curr_bs = NULL;
BlockDriverState *retval = NULL;
+ Error *local_error = NULL;
if (!bs || !bs->drv || !backing_file) {
return NULL;
retval = curr_bs->backing->bs;
break;
}
+ /* Also check against the full backing filename for the image */
+ bdrv_get_full_backing_filename(curr_bs, backing_file_full, PATH_MAX,
+ &local_error);
+ if (local_error == NULL) {
+ if (strcmp(backing_file, backing_file_full) == 0) {
+ retval = curr_bs->backing->bs;
+ break;
+ }
+ } else {
+ error_free(local_error);
+ local_error = NULL;
+ }
} else {
/* If not an absolute filename path, make it relative to the current
* image's filename path */
if (!(bs->open_flags & BDRV_O_INACTIVE)) {
return;
}
- bs->open_flags &= ~BDRV_O_INACTIVE;
- if (bs->drv->bdrv_invalidate_cache) {
- bs->drv->bdrv_invalidate_cache(bs, &local_err);
+ QLIST_FOREACH(child, &bs->children, next) {
+ bdrv_invalidate_cache(child->bs, &local_err);
if (local_err) {
- bs->open_flags |= BDRV_O_INACTIVE;
error_propagate(errp, local_err);
return;
}
}
- QLIST_FOREACH(child, &bs->children, next) {
- bdrv_invalidate_cache(child->bs, &local_err);
+ bs->open_flags &= ~BDRV_O_INACTIVE;
+ if (bs->drv->bdrv_invalidate_cache) {
+ bs->drv->bdrv_invalidate_cache(bs, &local_err);
if (local_err) {
bs->open_flags |= BDRV_O_INACTIVE;
error_propagate(errp, local_err);