block: Generalize change_cb() to BlockDevOps

So we can more easily add device model callbacks.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Markus Armbruster 2011-08-03 15:07:41 +02:00 committed by Kevin Wolf
parent fa879d62eb
commit 0e49de5232
6 changed files with 44 additions and 31 deletions

View file

@ -552,6 +552,10 @@ static void virtio_blk_change_cb(void *opaque, int reason)
}
}
static const BlockDevOps virtio_block_ops = {
.change_cb = virtio_blk_change_cb,
};
VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
char **serial)
{
@ -598,7 +602,7 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
register_savevm(dev, "virtio-blk", virtio_blk_id++, 2,
virtio_blk_save, virtio_blk_load, s);
bdrv_set_removable(s->bs, 0);
bdrv_set_change_cb(s->bs, virtio_blk_change_cb, s);
bdrv_set_dev_ops(s->bs, &virtio_block_ops, s);
s->bs->buffer_alignment = conf->logical_block_size;
add_boot_device_path(conf->bootindex, dev, "/disk@0,0");