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
|
@ -312,7 +312,7 @@ static int parse_drive(DeviceState *dev, Property *prop, const char *str)
|
|||
bs = bdrv_find(str);
|
||||
if (bs == NULL)
|
||||
return -ENOENT;
|
||||
if (bdrv_attach(bs, dev) < 0)
|
||||
if (bdrv_attach_dev(bs, dev) < 0)
|
||||
return -EEXIST;
|
||||
*ptr = bs;
|
||||
return 0;
|
||||
|
@ -323,7 +323,7 @@ static void free_drive(DeviceState *dev, Property *prop)
|
|||
BlockDriverState **ptr = qdev_get_prop_ptr(dev, prop);
|
||||
|
||||
if (*ptr) {
|
||||
bdrv_detach(*ptr, dev);
|
||||
bdrv_detach_dev(*ptr, dev);
|
||||
blockdev_auto_del(*ptr);
|
||||
}
|
||||
}
|
||||
|
@ -678,7 +678,7 @@ int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *va
|
|||
{
|
||||
int res;
|
||||
|
||||
res = bdrv_attach(value, dev);
|
||||
res = bdrv_attach_dev(value, dev);
|
||||
if (res < 0) {
|
||||
error_report("Can't attach drive %s to %s.%s: %s",
|
||||
bdrv_get_device_name(value),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue