Revision 5469a2a6
b/block.c | ||
---|---|---|
969 | 969 |
Error *local_err = NULL; |
970 | 970 |
int ret; |
971 | 971 |
|
972 |
/* NULL means an empty set of options */ |
|
973 |
if (options == NULL) { |
|
974 |
options = qdict_new(); |
|
975 |
} |
|
976 |
|
|
977 |
bs->options = options; |
|
978 |
options = qdict_clone_shallow(options); |
|
979 |
|
|
980 | 972 |
/* Fetch the file name from the options QDict if necessary */ |
981 | 973 |
if (!filename) { |
982 | 974 |
filename = qdict_get_try_str(options, "filename"); |
... | ... | |
1051 | 1043 |
|
1052 | 1044 |
fail: |
1053 | 1045 |
QDECREF(options); |
1054 |
if (!bs->drv) { |
|
1055 |
QDECREF(bs->options); |
|
1056 |
} |
|
1057 | 1046 |
return ret; |
1058 | 1047 |
} |
1059 | 1048 |
|
... | ... | |
1254 | 1243 |
bs = bdrv_new(""); |
1255 | 1244 |
} |
1256 | 1245 |
|
1257 |
if (flags & BDRV_O_PROTOCOL) { |
|
1258 |
assert(!drv); |
|
1259 |
ret = bdrv_file_open(bs, filename, options, flags & ~BDRV_O_PROTOCOL, |
|
1260 |
errp); |
|
1261 |
if (ret && !*pbs) { |
|
1262 |
bdrv_unref(bs); |
|
1263 |
} else if (!ret) { |
|
1264 |
*pbs = bs; |
|
1265 |
} |
|
1266 |
return ret; |
|
1267 |
} |
|
1268 |
|
|
1269 | 1246 |
/* NULL means an empty set of options */ |
1270 | 1247 |
if (options == NULL) { |
1271 | 1248 |
options = qdict_new(); |
... | ... | |
1274 | 1251 |
bs->options = options; |
1275 | 1252 |
options = qdict_clone_shallow(options); |
1276 | 1253 |
|
1254 |
if (flags & BDRV_O_PROTOCOL) { |
|
1255 |
assert(!drv); |
|
1256 |
ret = bdrv_file_open(bs, filename, options, flags & ~BDRV_O_PROTOCOL, |
|
1257 |
&local_err); |
|
1258 |
options = NULL; |
|
1259 |
if (!ret) { |
|
1260 |
*pbs = bs; |
|
1261 |
return 0; |
|
1262 |
} else if (bs->drv) { |
|
1263 |
goto close_and_fail; |
|
1264 |
} else { |
|
1265 |
goto fail; |
|
1266 |
} |
|
1267 |
} |
|
1268 |
|
|
1277 | 1269 |
/* For snapshot=on, create a temporary qcow2 overlay */ |
1278 | 1270 |
if (flags & BDRV_O_SNAPSHOT) { |
1279 | 1271 |
BlockDriverState *bs1; |
Also available in: Unified diff