block.c (aa269ff888d70158fe0c26ed17814046bdc19bd5) | block.c (8dc8a60c9e52fa446a5135180592c0cd4213acfb) |
---|---|
1/* 2 * QEMU System Emulator block driver 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * Copyright (c) 2020 Virtuozzo International GmbH. 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal --- 1599 unchanged lines hidden (view full) --- 1608 * The caller must always hold @bs AioContext lock, because this function calls 1609 * bdrv_refresh_total_sectors() which polls when called from non-coroutine 1610 * context. 1611 */ 1612static int no_coroutine_fn GRAPH_UNLOCKED 1613bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv, const char *node_name, 1614 QDict *options, int open_flags, Error **errp) 1615{ | 1/* 2 * QEMU System Emulator block driver 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * Copyright (c) 2020 Virtuozzo International GmbH. 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal --- 1599 unchanged lines hidden (view full) --- 1608 * The caller must always hold @bs AioContext lock, because this function calls 1609 * bdrv_refresh_total_sectors() which polls when called from non-coroutine 1610 * context. 1611 */ 1612static int no_coroutine_fn GRAPH_UNLOCKED 1613bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv, const char *node_name, 1614 QDict *options, int open_flags, Error **errp) 1615{ |
1616 AioContext *ctx; |
|
1616 Error *local_err = NULL; 1617 int i, ret; 1618 GLOBAL_STATE_CODE(); 1619 1620 bdrv_assign_node_name(bs, node_name, &local_err); 1621 if (local_err) { 1622 error_propagate(errp, local_err); 1623 return -EINVAL; --- 31 unchanged lines hidden (view full) --- 1655 * declaring support explicitly. 1656 * 1657 * Drivers must not propagate this flag accidentally when they initiate I/O 1658 * to a bounce buffer. That case should be rare though. 1659 */ 1660 bs->supported_read_flags |= BDRV_REQ_REGISTERED_BUF; 1661 bs->supported_write_flags |= BDRV_REQ_REGISTERED_BUF; 1662 | 1617 Error *local_err = NULL; 1618 int i, ret; 1619 GLOBAL_STATE_CODE(); 1620 1621 bdrv_assign_node_name(bs, node_name, &local_err); 1622 if (local_err) { 1623 error_propagate(errp, local_err); 1624 return -EINVAL; --- 31 unchanged lines hidden (view full) --- 1656 * declaring support explicitly. 1657 * 1658 * Drivers must not propagate this flag accidentally when they initiate I/O 1659 * to a bounce buffer. That case should be rare though. 1660 */ 1661 bs->supported_read_flags |= BDRV_REQ_REGISTERED_BUF; 1662 bs->supported_write_flags |= BDRV_REQ_REGISTERED_BUF; 1663 |
1664 /* Get the context after .bdrv_open, it can change the context */ 1665 ctx = bdrv_get_aio_context(bs); 1666 aio_context_acquire(ctx); 1667 |
|
1663 ret = bdrv_refresh_total_sectors(bs, bs->total_sectors); 1664 if (ret < 0) { 1665 error_setg_errno(errp, -ret, "Could not refresh total sector count"); | 1668 ret = bdrv_refresh_total_sectors(bs, bs->total_sectors); 1669 if (ret < 0) { 1670 error_setg_errno(errp, -ret, "Could not refresh total sector count"); |
1671 aio_context_release(ctx); |
|
1666 return ret; 1667 } 1668 1669 bdrv_graph_rdlock_main_loop(); 1670 bdrv_refresh_limits(bs, NULL, &local_err); 1671 bdrv_graph_rdunlock_main_loop(); | 1672 return ret; 1673 } 1674 1675 bdrv_graph_rdlock_main_loop(); 1676 bdrv_refresh_limits(bs, NULL, &local_err); 1677 bdrv_graph_rdunlock_main_loop(); |
1678 aio_context_release(ctx); |
|
1672 1673 if (local_err) { 1674 error_propagate(errp, local_err); 1675 return -EINVAL; 1676 } 1677 1678 assert(bdrv_opt_mem_align(bs) != 0); 1679 assert(bdrv_min_mem_align(bs) != 0); --- 6623 unchanged lines hidden --- | 1679 1680 if (local_err) { 1681 error_propagate(errp, local_err); 1682 return -EINVAL; 1683 } 1684 1685 assert(bdrv_opt_mem_align(bs) != 0); 1686 assert(bdrv_min_mem_align(bs) != 0); --- 6623 unchanged lines hidden --- |