block.c (4348355032c027d0029994fc62da395e68afb60d) | block.c (33f2663bd58696ab836731830f9fb6a878a5b944) |
---|---|
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 --- 2483 unchanged lines hidden (view full) --- 2492 } 2493 2494 /* bs->file always needs to be consistent because of the metadata. We 2495 * can never allow other users to resize or write to it. */ 2496 if (!(flags & BDRV_O_NO_IO)) { 2497 perm |= BLK_PERM_CONSISTENT_READ; 2498 } 2499 shared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); | 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 --- 2483 unchanged lines hidden (view full) --- 2492 } 2493 2494 /* bs->file always needs to be consistent because of the metadata. We 2495 * can never allow other users to resize or write to it. */ 2496 if (!(flags & BDRV_O_NO_IO)) { 2497 perm |= BLK_PERM_CONSISTENT_READ; 2498 } 2499 shared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); |
2500 2501 if (bs->open_flags & BDRV_O_INACTIVE) { 2502 shared |= BLK_PERM_WRITE | BLK_PERM_RESIZE; 2503 } 2504 2505 *nperm = perm; 2506 *nshared = shared; |
|
2500 } else { 2501 /* We want consistent read from backing files if the parent needs it. 2502 * No other operations are performed on backing files. */ 2503 perm &= BLK_PERM_CONSISTENT_READ; 2504 2505 /* If the parent can deal with changing data, we're okay with a 2506 * writable and resizable backing file. */ 2507 /* TODO Require !(perm & BLK_PERM_CONSISTENT_READ), too? */ 2508 if (shared & BLK_PERM_WRITE) { 2509 shared = BLK_PERM_WRITE | BLK_PERM_RESIZE; 2510 } else { 2511 shared = 0; 2512 } 2513 2514 shared |= BLK_PERM_CONSISTENT_READ | BLK_PERM_GRAPH_MOD | 2515 BLK_PERM_WRITE_UNCHANGED; | 2507 } else { 2508 /* We want consistent read from backing files if the parent needs it. 2509 * No other operations are performed on backing files. */ 2510 perm &= BLK_PERM_CONSISTENT_READ; 2511 2512 /* If the parent can deal with changing data, we're okay with a 2513 * writable and resizable backing file. */ 2514 /* TODO Require !(perm & BLK_PERM_CONSISTENT_READ), too? */ 2515 if (shared & BLK_PERM_WRITE) { 2516 shared = BLK_PERM_WRITE | BLK_PERM_RESIZE; 2517 } else { 2518 shared = 0; 2519 } 2520 2521 shared |= BLK_PERM_CONSISTENT_READ | BLK_PERM_GRAPH_MOD | 2522 BLK_PERM_WRITE_UNCHANGED; |
2516 } | |
2517 | 2523 |
2518 if (bs->open_flags & BDRV_O_INACTIVE) { 2519 shared |= BLK_PERM_WRITE | BLK_PERM_RESIZE; 2520 } | 2524 if (bs->open_flags & BDRV_O_INACTIVE) { 2525 shared |= BLK_PERM_WRITE | BLK_PERM_RESIZE; 2526 } |
2521 | 2527 |
2522 *nperm = perm; 2523 *nshared = shared; | 2528 *nperm = perm; 2529 *nshared = shared; 2530 } |
2524} 2525 2526uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm) 2527{ 2528 static const uint64_t permissions[] = { 2529 [BLOCK_PERMISSION_CONSISTENT_READ] = BLK_PERM_CONSISTENT_READ, 2530 [BLOCK_PERMISSION_WRITE] = BLK_PERM_WRITE, 2531 [BLOCK_PERMISSION_WRITE_UNCHANGED] = BLK_PERM_WRITE_UNCHANGED, --- 4392 unchanged lines hidden --- | 2531} 2532 2533uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm) 2534{ 2535 static const uint64_t permissions[] = { 2536 [BLOCK_PERMISSION_CONSISTENT_READ] = BLK_PERM_CONSISTENT_READ, 2537 [BLOCK_PERMISSION_WRITE] = BLK_PERM_WRITE, 2538 [BLOCK_PERMISSION_WRITE_UNCHANGED] = BLK_PERM_WRITE_UNCHANGED, --- 4392 unchanged lines hidden --- |