block.c (65b31cc207b8ab949033870acf55bb124d12848e) block.c (329c0a48a92664eb48b70993c0f2473b37aa7429)
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

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

938{
939 bs->dev_ops = ops;
940 bs->dev_opaque = opaque;
941 if (bdrv_dev_has_removable_media(bs) && bs == bs_snapshots) {
942 bs_snapshots = NULL;
943 }
944}
945
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

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

938{
939 bs->dev_ops = ops;
940 bs->dev_opaque = opaque;
941 if (bdrv_dev_has_removable_media(bs) && bs == bs_snapshots) {
942 bs_snapshots = NULL;
943 }
944}
945
946void bdrv_emit_qmp_error_event(const BlockDriverState *bdrv,
947 BlockQMPEventAction action, int is_read)
948{
949 QObject *data;
950 const char *action_str;
951
952 switch (action) {
953 case BDRV_ACTION_REPORT:
954 action_str = "report";
955 break;
956 case BDRV_ACTION_IGNORE:
957 action_str = "ignore";
958 break;
959 case BDRV_ACTION_STOP:
960 action_str = "stop";
961 break;
962 default:
963 abort();
964 }
965
966 data = qobject_from_jsonf("{ 'device': %s, 'action': %s, 'operation': %s }",
967 bdrv->device_name,
968 action_str,
969 is_read ? "read" : "write");
970 monitor_protocol_event(QEVENT_BLOCK_IO_ERROR, data);
971
972 qobject_decref(data);
973}
974
946static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load)
947{
948 if (bs->dev_ops && bs->dev_ops->change_media_cb) {
949 bs->dev_ops->change_media_cb(bs->dev_opaque, load);
950 }
951}
952
953bool bdrv_dev_has_removable_media(BlockDriverState *bs)

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

2288 co = qemu_coroutine_create(bdrv_is_allocated_co_entry);
2289 qemu_coroutine_enter(co, &data);
2290 while (!data.done) {
2291 qemu_aio_wait();
2292 }
2293 return data.ret;
2294}
2295
975static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load)
976{
977 if (bs->dev_ops && bs->dev_ops->change_media_cb) {
978 bs->dev_ops->change_media_cb(bs->dev_opaque, load);
979 }
980}
981
982bool bdrv_dev_has_removable_media(BlockDriverState *bs)

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

2317 co = qemu_coroutine_create(bdrv_is_allocated_co_entry);
2318 qemu_coroutine_enter(co, &data);
2319 while (!data.done) {
2320 qemu_aio_wait();
2321 }
2322 return data.ret;
2323}
2324
2296void bdrv_mon_event(const BlockDriverState *bdrv,
2297 BlockMonEventAction action, int is_read)
2298{
2299 QObject *data;
2300 const char *action_str;
2301
2302 switch (action) {
2303 case BDRV_ACTION_REPORT:
2304 action_str = "report";
2305 break;
2306 case BDRV_ACTION_IGNORE:
2307 action_str = "ignore";
2308 break;
2309 case BDRV_ACTION_STOP:
2310 action_str = "stop";
2311 break;
2312 default:
2313 abort();
2314 }
2315
2316 data = qobject_from_jsonf("{ 'device': %s, 'action': %s, 'operation': %s }",
2317 bdrv->device_name,
2318 action_str,
2319 is_read ? "read" : "write");
2320 monitor_protocol_event(QEVENT_BLOCK_IO_ERROR, data);
2321
2322 qobject_decref(data);
2323}
2324
2325BlockInfoList *qmp_query_block(Error **errp)
2326{
2327 BlockInfoList *head = NULL, *cur_item = NULL;
2328 BlockDriverState *bs;
2329
2330 QTAILQ_FOREACH(bs, &bdrv_states, list) {
2331 BlockInfoList *info = g_malloc0(sizeof(*info));
2332

--- 1643 unchanged lines hidden ---
2325BlockInfoList *qmp_query_block(Error **errp)
2326{
2327 BlockInfoList *head = NULL, *cur_item = NULL;
2328 BlockDriverState *bs;
2329
2330 QTAILQ_FOREACH(bs, &bdrv_states, list) {
2331 BlockInfoList *info = g_malloc0(sizeof(*info));
2332

--- 1643 unchanged lines hidden ---