Skip to content

Commit b9fe8a7

Browse files
Markus Armbrusterkevmw
Markus Armbruster
authored andcommitted
blockdev: Eliminate drive_del()
drive_del() has become a trivial wrapper around blk_unref(). Get rid of it. Signed-off-by: Markus Armbruster <[email protected]> Reviewed-by: Max Reitz <[email protected]> Signed-off-by: Kevin Wolf <[email protected]>
1 parent 9ba10c9 commit b9fe8a7

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

blockdev.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void blockdev_auto_del(BlockDriverState *bs)
134134
DriveInfo *dinfo = blk_legacy_dinfo(blk);
135135

136136
if (dinfo && dinfo->auto_del) {
137-
drive_del(dinfo);
137+
blk_unref(blk);
138138
}
139139
}
140140

@@ -276,11 +276,6 @@ static void bdrv_format_print(void *opaque, const char *name)
276276
error_printf(" %s", name);
277277
}
278278

279-
void drive_del(DriveInfo *dinfo)
280-
{
281-
blk_unref(dinfo->bdrv->blk);
282-
}
283-
284279
typedef struct {
285280
QEMUBH *bh;
286281
BlockDriverState *bs;
@@ -1867,7 +1862,7 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
18671862
bdrv_set_on_error(bs, BLOCKDEV_ON_ERROR_REPORT,
18681863
BLOCKDEV_ON_ERROR_REPORT);
18691864
} else {
1870-
drive_del(dinfo);
1865+
blk_unref(blk);
18711866
}
18721867

18731868
aio_context_release(aio_context);

device-hotplug.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "hw/hw.h"
2626
#include "hw/boards.h"
27+
#include "sysemu/block-backend.h"
2728
#include "sysemu/blockdev.h"
2829
#include "qemu/config-file.h"
2930
#include "sysemu/sysemu.h"
@@ -76,6 +77,6 @@ void drive_hot_add(Monitor *mon, const QDict *qdict)
7677

7778
err:
7879
if (dinfo) {
79-
drive_del(dinfo);
80+
blk_unref(blk_by_legacy_dinfo(dinfo));
8081
}
8182
}

hw/ide/piix.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <hw/i386/pc.h>
2828
#include <hw/pci/pci.h>
2929
#include <hw/isa/isa.h>
30+
#include "sysemu/block-backend.h"
3031
#include "sysemu/blockdev.h"
3132
#include "sysemu/sysemu.h"
3233
#include "sysemu/dma.h"
@@ -178,12 +179,13 @@ int pci_piix3_xen_ide_unplug(DeviceState *dev)
178179
for (; i < 3; i++) {
179180
di = drive_get_by_index(IF_IDE, i);
180181
if (di != NULL && !di->media_cd) {
182+
BlockBackend *blk = blk_by_legacy_dinfo(di);
181183
DeviceState *ds = bdrv_get_attached_dev(di->bdrv);
182184
if (ds) {
183185
bdrv_detach_dev(di->bdrv, ds);
184186
}
185187
pci_ide->bus[di->bus].ifs[di->unit].bs = NULL;
186-
drive_del(di);
188+
blk_unref(blk);
187189
}
188190
}
189191
qdev_reset_all(DEVICE(dev));

include/sysemu/blockdev.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ QemuOpts *drive_def(const char *optstr);
6464
QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file,
6565
const char *optstr);
6666
DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type);
67-
void drive_del(DriveInfo *dinfo);
6867

6968
/* device-hotplug */
7069

0 commit comments

Comments
 (0)