block.c (636ea3708c253e9d2ddac6bd7d96854ba95fb7f5) | block.c (98522f63f40adaebc412481e1d2e9170160d4539) |
---|---|
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 --- 318 unchanged lines hidden (view full) --- 327 bdrv->bdrv_aio_writev = bdrv_aio_writev_em; 328 } 329 } 330 331 QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list); 332} 333 334/* create a new block device (by default it is empty) */ | 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 --- 318 unchanged lines hidden (view full) --- 327 bdrv->bdrv_aio_writev = bdrv_aio_writev_em; 328 } 329 } 330 331 QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list); 332} 333 334/* create a new block device (by default it is empty) */ |
335BlockDriverState *bdrv_new(const char *device_name) | 335BlockDriverState *bdrv_new(const char *device_name, Error **errp) |
336{ 337 BlockDriverState *bs; 338 339 bs = g_malloc0(sizeof(BlockDriverState)); 340 QLIST_INIT(&bs->dirty_bitmaps); 341 pstrcpy(bs->device_name, sizeof(bs->device_name), device_name); 342 if (device_name[0] != '\0') { 343 QTAILQ_INSERT_TAIL(&bdrv_states, bs, device_list); --- 871 unchanged lines hidden (view full) --- 1215 1216 /* Prepare a new options QDict for the temporary file */ 1217 snapshot_options = qdict_new(); 1218 qdict_put(snapshot_options, "file.driver", 1219 qstring_from_str("file")); 1220 qdict_put(snapshot_options, "file.filename", 1221 qstring_from_str(tmp_filename)); 1222 | 336{ 337 BlockDriverState *bs; 338 339 bs = g_malloc0(sizeof(BlockDriverState)); 340 QLIST_INIT(&bs->dirty_bitmaps); 341 pstrcpy(bs->device_name, sizeof(bs->device_name), device_name); 342 if (device_name[0] != '\0') { 343 QTAILQ_INSERT_TAIL(&bdrv_states, bs, device_list); --- 871 unchanged lines hidden (view full) --- 1215 1216 /* Prepare a new options QDict for the temporary file */ 1217 snapshot_options = qdict_new(); 1218 qdict_put(snapshot_options, "file.driver", 1219 qstring_from_str("file")); 1220 qdict_put(snapshot_options, "file.filename", 1221 qstring_from_str(tmp_filename)); 1222 |
1223 bs_snapshot = bdrv_new(""); | 1223 bs_snapshot = bdrv_new("", &error_abort); |
1224 bs_snapshot->is_temporary = 1; 1225 1226 ret = bdrv_open(&bs_snapshot, NULL, NULL, snapshot_options, 1227 bs->open_flags & ~BDRV_O_SNAPSHOT, bdrv_qcow2, &local_err); 1228 if (ret < 0) { 1229 error_propagate(errp, local_err); 1230 return; 1231 } --- 50 unchanged lines hidden (view full) --- 1282 bdrv_ref(bs); 1283 *pbs = bs; 1284 return 0; 1285 } 1286 1287 if (*pbs) { 1288 bs = *pbs; 1289 } else { | 1224 bs_snapshot->is_temporary = 1; 1225 1226 ret = bdrv_open(&bs_snapshot, NULL, NULL, snapshot_options, 1227 bs->open_flags & ~BDRV_O_SNAPSHOT, bdrv_qcow2, &local_err); 1228 if (ret < 0) { 1229 error_propagate(errp, local_err); 1230 return; 1231 } --- 50 unchanged lines hidden (view full) --- 1282 bdrv_ref(bs); 1283 *pbs = bs; 1284 return 0; 1285 } 1286 1287 if (*pbs) { 1288 bs = *pbs; 1289 } else { |
1290 bs = bdrv_new(""); | 1290 bs = bdrv_new("", &error_abort); |
1291 } 1292 1293 /* NULL means an empty set of options */ 1294 if (options == NULL) { 1295 options = qdict_new(); 1296 } 1297 1298 bs->options = options; --- 4218 unchanged lines hidden --- | 1291 } 1292 1293 /* NULL means an empty set of options */ 1294 if (options == NULL) { 1295 options = qdict_new(); 1296 } 1297 1298 bs->options = options; --- 4218 unchanged lines hidden --- |