mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
block: Attach non-qdev devices as well
For now, this just protects against programming errors like having the same drive back multiple non-qdev devices, or untimely bdrv_delete(). Later commits will add other interesting uses. While there, rename BlockDriverState member peer to dev, bdrv_attach() to bdrv_attach_dev(), bdrv_detach() to bdrv_detach_dev(), and bdrv_get_attached() to bdrv_get_attached_dev(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
648fb0ea5e
commit
fa879d62eb
12 changed files with 39 additions and 22 deletions
|
@ -14,7 +14,6 @@
|
|||
#include "qemu-option.h"
|
||||
#include "qemu-config.h"
|
||||
#include "sysemu.h"
|
||||
#include "hw/qdev.h"
|
||||
#include "block_int.h"
|
||||
|
||||
static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives);
|
||||
|
@ -738,12 +737,12 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
|||
bdrv_flush(bs);
|
||||
bdrv_close(bs);
|
||||
|
||||
/* if we have a device associated with this BlockDriverState (bs->peer)
|
||||
/* if we have a device attached to this BlockDriverState
|
||||
* then we need to make the drive anonymous until the device
|
||||
* can be removed. If this is a drive with no device backing
|
||||
* then we can just get rid of the block driver state right here.
|
||||
*/
|
||||
if (bs->peer) {
|
||||
if (bdrv_get_attached_dev(bs)) {
|
||||
bdrv_make_anon(bs);
|
||||
} else {
|
||||
drive_uninit(drive_get_by_blockdev(bs));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue