block.c (15c7733bb231090e5ebd6d10060dccdb98bb4941) block.c (18846dee1a795b4345ac0bd10b70a3a46fd14287)
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

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

660
661 QTAILQ_FOREACH(bs, &bdrv_states, list) {
662 bdrv_close(bs);
663 }
664}
665
666void bdrv_delete(BlockDriverState *bs)
667{
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

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

660
661 QTAILQ_FOREACH(bs, &bdrv_states, list) {
662 bdrv_close(bs);
663 }
664}
665
666void bdrv_delete(BlockDriverState *bs)
667{
668 assert(!bs->peer);
669
668 /* remove from list, if necessary */
669 if (bs->device_name[0] != '\0') {
670 QTAILQ_REMOVE(&bdrv_states, bs, list);
671 }
672
673 bdrv_close(bs);
674 if (bs->file != NULL) {
675 bdrv_delete(bs->file);
676 }
677
678 qemu_free(bs);
679}
680
670 /* remove from list, if necessary */
671 if (bs->device_name[0] != '\0') {
672 QTAILQ_REMOVE(&bdrv_states, bs, list);
673 }
674
675 bdrv_close(bs);
676 if (bs->file != NULL) {
677 bdrv_delete(bs->file);
678 }
679
680 qemu_free(bs);
681}
682
683int bdrv_attach(BlockDriverState *bs, DeviceState *qdev)
684{
685 if (bs->peer) {
686 return -EBUSY;
687 }
688 bs->peer = qdev;
689 return 0;
690}
691
692void bdrv_detach(BlockDriverState *bs, DeviceState *qdev)
693{
694 assert(bs->peer == qdev);
695 bs->peer = NULL;
696}
697
698DeviceState *bdrv_get_attached(BlockDriverState *bs)
699{
700 return bs->peer;
701}
702
681/*
682 * Run consistency checks on an image
683 *
684 * Returns the number of errors or -errno when an internal error occurs
685 */
686int bdrv_check(BlockDriverState *bs)
687{
688 if (bs->drv->bdrv_check == NULL) {

--- 1876 unchanged lines hidden ---
703/*
704 * Run consistency checks on an image
705 *
706 * Returns the number of errors or -errno when an internal error occurs
707 */
708int bdrv_check(BlockDriverState *bs)
709{
710 if (bs->drv->bdrv_check == NULL) {

--- 1876 unchanged lines hidden ---