block.c (f1faf2d59c91a8f1f59a0fc6339154efb749b55d) block.c (5fbfabd313b77e1cc7038ae8c4481c4b9f8b650a)
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

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

1919 BlockReopenQueue *reopen_queue,
1920 uint64_t perm, uint64_t shared,
1921 uint64_t *nperm, uint64_t *nshared)
1922{
1923 bool backing = (role == &child_backing);
1924 assert(role == &child_backing || role == &child_file);
1925
1926 if (!backing) {
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

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

1919 BlockReopenQueue *reopen_queue,
1920 uint64_t perm, uint64_t shared,
1921 uint64_t *nperm, uint64_t *nshared)
1922{
1923 bool backing = (role == &child_backing);
1924 assert(role == &child_backing || role == &child_file);
1925
1926 if (!backing) {
1927 int flags = bdrv_reopen_get_flags(reopen_queue, bs);
1928
1927 /* Apart from the modifications below, the same permissions are
1928 * forwarded and left alone as for filters */
1929 bdrv_filter_default_perms(bs, c, role, reopen_queue, perm, shared,
1930 &perm, &shared);
1931
1932 /* Format drivers may touch metadata even if the guest doesn't write */
1933 if (bdrv_is_writable(bs, reopen_queue)) {
1934 perm |= BLK_PERM_WRITE | BLK_PERM_RESIZE;
1935 }
1936
1937 /* bs->file always needs to be consistent because of the metadata. We
1938 * can never allow other users to resize or write to it. */
1929 /* Apart from the modifications below, the same permissions are
1930 * forwarded and left alone as for filters */
1931 bdrv_filter_default_perms(bs, c, role, reopen_queue, perm, shared,
1932 &perm, &shared);
1933
1934 /* Format drivers may touch metadata even if the guest doesn't write */
1935 if (bdrv_is_writable(bs, reopen_queue)) {
1936 perm |= BLK_PERM_WRITE | BLK_PERM_RESIZE;
1937 }
1938
1939 /* bs->file always needs to be consistent because of the metadata. We
1940 * can never allow other users to resize or write to it. */
1939 perm |= BLK_PERM_CONSISTENT_READ;
1941 if (!(flags & BDRV_O_NO_IO)) {
1942 perm |= BLK_PERM_CONSISTENT_READ;
1943 }
1940 shared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
1941 } else {
1942 /* We want consistent read from backing files if the parent needs it.
1943 * No other operations are performed on backing files. */
1944 perm &= BLK_PERM_CONSISTENT_READ;
1945
1946 /* If the parent can deal with changing data, we're okay with a
1947 * writable and resizable backing file. */

--- 3193 unchanged lines hidden ---
1944 shared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
1945 } else {
1946 /* We want consistent read from backing files if the parent needs it.
1947 * No other operations are performed on backing files. */
1948 perm &= BLK_PERM_CONSISTENT_READ;
1949
1950 /* If the parent can deal with changing data, we're okay with a
1951 * writable and resizable backing file. */

--- 3193 unchanged lines hidden ---