blockdev.c (fb5458cd10a199e55e622a906b24f8085d922c0f) | blockdev.c (aa398a5c3a4c0fc29baf02aee5283a7fa0f202a3) |
---|---|
1/* 2 * QEMU host block devices 3 * 4 * Copyright (c) 2003-2008 Fabrice Bellard 5 * 6 * This work is licensed under the terms of the GNU GPL, version 2 or 7 * later. See the COPYING file in the top-level directory. 8 */ --- 188 unchanged lines hidden (view full) --- 197 } 198} 199 200void drive_get_ref(DriveInfo *dinfo) 201{ 202 dinfo->refcount++; 203} 204 | 1/* 2 * QEMU host block devices 3 * 4 * Copyright (c) 2003-2008 Fabrice Bellard 5 * 6 * This work is licensed under the terms of the GNU GPL, version 2 or 7 * later. See the COPYING file in the top-level directory. 8 */ --- 188 unchanged lines hidden (view full) --- 197 } 198} 199 200void drive_get_ref(DriveInfo *dinfo) 201{ 202 dinfo->refcount++; 203} 204 |
205typedef struct { 206 QEMUBH *bh; 207 DriveInfo *dinfo; 208} DrivePutRefBH; 209 210static void drive_put_ref_bh(void *opaque) 211{ 212 DrivePutRefBH *s = opaque; 213 214 drive_put_ref(s->dinfo); 215 qemu_bh_delete(s->bh); 216 g_free(s); 217} 218 219/* 220 * Release a drive reference in a BH 221 * 222 * It is not possible to use drive_put_ref() from a callback function when the 223 * callers still need the drive. In such cases we schedule a BH to release the 224 * reference. 225 */ 226static void drive_put_ref_bh_schedule(DriveInfo *dinfo) 227{ 228 DrivePutRefBH *s; 229 230 s = g_new(DrivePutRefBH, 1); 231 s->bh = qemu_bh_new(drive_put_ref_bh, s); 232 s->dinfo = dinfo; 233 qemu_bh_schedule(s->bh); 234} 235 |
|
205static int parse_block_error_action(const char *buf, int is_read) 206{ 207 if (!strcmp(buf, "ignore")) { 208 return BLOCK_ERR_IGNORE; 209 } else if (!is_read && !strcmp(buf, "enospc")) { 210 return BLOCK_ERR_STOP_ENOSPC; 211 } else if (!strcmp(buf, "stop")) { 212 return BLOCK_ERR_STOP_ANY; --- 716 unchanged lines hidden (view full) --- 929 } 930 931 if (block_job_is_cancelled(bs->job)) { 932 monitor_protocol_event(QEVENT_BLOCK_JOB_CANCELLED, obj); 933 } else { 934 monitor_protocol_event(QEVENT_BLOCK_JOB_COMPLETED, obj); 935 } 936 qobject_decref(obj); | 236static int parse_block_error_action(const char *buf, int is_read) 237{ 238 if (!strcmp(buf, "ignore")) { 239 return BLOCK_ERR_IGNORE; 240 } else if (!is_read && !strcmp(buf, "enospc")) { 241 return BLOCK_ERR_STOP_ENOSPC; 242 } else if (!strcmp(buf, "stop")) { 243 return BLOCK_ERR_STOP_ANY; --- 716 unchanged lines hidden (view full) --- 960 } 961 962 if (block_job_is_cancelled(bs->job)) { 963 monitor_protocol_event(QEVENT_BLOCK_JOB_CANCELLED, obj); 964 } else { 965 monitor_protocol_event(QEVENT_BLOCK_JOB_COMPLETED, obj); 966 } 967 qobject_decref(obj); |
968 969 drive_put_ref_bh_schedule(drive_get_by_blockdev(bs)); |
|
937} 938 939void qmp_block_stream(const char *device, bool has_base, 940 const char *base, Error **errp) 941{ 942 BlockDriverState *bs; 943 int ret; 944 --- 16 unchanged lines hidden (view full) --- 961 error_set(errp, QERR_DEVICE_IN_USE, device); 962 return; 963 default: 964 error_set(errp, QERR_NOT_SUPPORTED); 965 return; 966 } 967 } 968 | 970} 971 972void qmp_block_stream(const char *device, bool has_base, 973 const char *base, Error **errp) 974{ 975 BlockDriverState *bs; 976 int ret; 977 --- 16 unchanged lines hidden (view full) --- 994 error_set(errp, QERR_DEVICE_IN_USE, device); 995 return; 996 default: 997 error_set(errp, QERR_NOT_SUPPORTED); 998 return; 999 } 1000 } 1001 |
1002 /* Grab a reference so hotplug does not delete the BlockDriverState from 1003 * underneath us. 1004 */ 1005 drive_get_ref(drive_get_by_blockdev(bs)); 1006 |
|
969 trace_qmp_block_stream(bs, bs->job); 970} 971 972static BlockJob *find_block_job(const char *device) 973{ 974 BlockDriverState *bs; 975 976 bs = bdrv_find(device); --- 65 unchanged lines hidden --- | 1007 trace_qmp_block_stream(bs, bs->job); 1008} 1009 1010static BlockJob *find_block_job(const char *device) 1011{ 1012 BlockDriverState *bs; 1013 1014 bs = bdrv_find(device); --- 65 unchanged lines hidden --- |