block.c (c1a5f950cdeeaea6a835b2b33f040a0e62c18662) block.c (cddff5bae1c8e0e21a5e6da04eff1d0a4423e5f3)
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

--- 610 unchanged lines hidden (view full) ---

619 hint = DIV_ROUND_UP(length, BDRV_SECTOR_SIZE);
620 }
621
622 bs->total_sectors = hint;
623 return 0;
624}
625
626/**
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

--- 610 unchanged lines hidden (view full) ---

619 hint = DIV_ROUND_UP(length, BDRV_SECTOR_SIZE);
620 }
621
622 bs->total_sectors = hint;
623 return 0;
624}
625
626/**
627 * Combines a QDict of new block driver @options with any missing options taken
628 * from @old_options, so that leaving out an option defaults to its old value.
629 */
630static void bdrv_join_options(BlockDriverState *bs, QDict *options,
631 QDict *old_options)
632{
633 if (bs->drv && bs->drv->bdrv_join_options) {
634 bs->drv->bdrv_join_options(options, old_options);
635 } else {
636 qdict_join(options, old_options, false);
637 }
638}
639
640/**
627 * Set open flags for a given discard mode
628 *
629 * Return 0 on success, -1 if the discard mode was invalid.
630 */
631int bdrv_parse_discard_flags(const char *mode, int *flags)
632{
633 *flags &= ~BDRV_O_UNMAP;
634

--- 1023 unchanged lines hidden (view full) ---

1658 QSIMPLEQ_INIT(bs_queue);
1659 }
1660
1661 if (!options) {
1662 options = qdict_new();
1663 }
1664
1665 old_options = qdict_clone_shallow(bs->options);
641 * Set open flags for a given discard mode
642 *
643 * Return 0 on success, -1 if the discard mode was invalid.
644 */
645int bdrv_parse_discard_flags(const char *mode, int *flags)
646{
647 *flags &= ~BDRV_O_UNMAP;
648

--- 1023 unchanged lines hidden (view full) ---

1672 QSIMPLEQ_INIT(bs_queue);
1673 }
1674
1675 if (!options) {
1676 options = qdict_new();
1677 }
1678
1679 old_options = qdict_clone_shallow(bs->options);
1666 qdict_join(options, old_options, false);
1680 bdrv_join_options(bs, options, old_options);
1667 QDECREF(old_options);
1668
1669 /* bdrv_open() masks this flag out */
1670 flags &= ~BDRV_O_PROTOCOL;
1671
1672 QLIST_FOREACH(child, &bs->children, next) {
1673 int child_flags;
1674

--- 2381 unchanged lines hidden ---
1681 QDECREF(old_options);
1682
1683 /* bdrv_open() masks this flag out */
1684 flags &= ~BDRV_O_PROTOCOL;
1685
1686 QLIST_FOREACH(child, &bs->children, next) {
1687 int child_flags;
1688

--- 2381 unchanged lines hidden ---