virtio: cleanup: init and exit function.
This clean the init and the exit functions and rename virtio_common_cleanup to virtio_cleanup. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Message-id: 1366791683-5350-7-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
1c81944983
commit
6a1a8cc7af
@ -661,7 +661,7 @@ static int virtio_blk_device_init(VirtIODevice *vdev)
|
|||||||
s->vq = virtio_add_queue(vdev, 128, virtio_blk_handle_output);
|
s->vq = virtio_add_queue(vdev, 128, virtio_blk_handle_output);
|
||||||
#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
|
#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
|
||||||
if (!virtio_blk_data_plane_create(vdev, blk, &s->dataplane)) {
|
if (!virtio_blk_data_plane_create(vdev, blk, &s->dataplane)) {
|
||||||
virtio_common_cleanup(vdev);
|
virtio_cleanup(vdev);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -689,7 +689,7 @@ static int virtio_blk_device_exit(DeviceState *dev)
|
|||||||
qemu_del_vm_change_state_handler(s->change);
|
qemu_del_vm_change_state_handler(s->change);
|
||||||
unregister_savevm(dev, "virtio-blk", s);
|
unregister_savevm(dev, "virtio-blk", s);
|
||||||
blockdev_mark_auto_del(s->bs);
|
blockdev_mark_auto_del(s->bs);
|
||||||
virtio_common_cleanup(vdev);
|
virtio_cleanup(vdev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1001,7 +1001,7 @@ static int virtio_serial_device_exit(DeviceState *dev)
|
|||||||
qemu_free_timer(vser->post_load->timer);
|
qemu_free_timer(vser->post_load->timer);
|
||||||
g_free(vser->post_load);
|
g_free(vser->post_load);
|
||||||
}
|
}
|
||||||
virtio_common_cleanup(vdev);
|
virtio_cleanup(vdev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1374,7 +1374,7 @@ static int virtio_net_device_exit(DeviceState *qdev)
|
|||||||
|
|
||||||
g_free(n->vqs);
|
g_free(n->vqs);
|
||||||
qemu_del_nic(n->nic);
|
qemu_del_nic(n->nic);
|
||||||
virtio_common_cleanup(vdev);
|
virtio_cleanup(vdev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -640,7 +640,7 @@ int virtio_scsi_common_exit(VirtIOSCSICommon *vs)
|
|||||||
VirtIODevice *vdev = VIRTIO_DEVICE(vs);
|
VirtIODevice *vdev = VIRTIO_DEVICE(vs);
|
||||||
|
|
||||||
g_free(vs->cmd_vqs);
|
g_free(vs->cmd_vqs);
|
||||||
virtio_common_cleanup(vdev);
|
virtio_cleanup(vdev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ static int virtio_balloon_device_init(VirtIODevice *vdev)
|
|||||||
virtio_balloon_stat, s);
|
virtio_balloon_stat, s);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
virtio_common_cleanup(VIRTIO_DEVICE(s));
|
virtio_cleanup(VIRTIO_DEVICE(s));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,7 +377,7 @@ static int virtio_balloon_device_exit(DeviceState *qdev)
|
|||||||
balloon_stats_destroy_timer(s);
|
balloon_stats_destroy_timer(s);
|
||||||
qemu_remove_balloon_handler(s);
|
qemu_remove_balloon_handler(s);
|
||||||
unregister_savevm(qdev, "virtio-balloon", s);
|
unregister_savevm(qdev, "virtio-balloon", s);
|
||||||
virtio_common_cleanup(vdev);
|
virtio_cleanup(vdev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ static int virtio_rng_device_exit(DeviceState *qdev)
|
|||||||
qemu_del_timer(vrng->rate_limit_timer);
|
qemu_del_timer(vrng->rate_limit_timer);
|
||||||
qemu_free_timer(vrng->rate_limit_timer);
|
qemu_free_timer(vrng->rate_limit_timer);
|
||||||
unregister_savevm(qdev, "virtio-rng", vrng);
|
unregister_savevm(qdev, "virtio-rng", vrng);
|
||||||
virtio_common_cleanup(vdev);
|
virtio_cleanup(vdev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,19 +910,13 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void virtio_common_cleanup(VirtIODevice *vdev)
|
void virtio_cleanup(VirtIODevice *vdev)
|
||||||
{
|
{
|
||||||
qemu_del_vm_change_state_handler(vdev->vmstate);
|
qemu_del_vm_change_state_handler(vdev->vmstate);
|
||||||
g_free(vdev->config);
|
g_free(vdev->config);
|
||||||
g_free(vdev->vq);
|
g_free(vdev->vq);
|
||||||
}
|
}
|
||||||
|
|
||||||
void virtio_cleanup(VirtIODevice *vdev)
|
|
||||||
{
|
|
||||||
virtio_common_cleanup(vdev);
|
|
||||||
g_free(vdev);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void virtio_vmstate_change(void *opaque, int running, RunState state)
|
static void virtio_vmstate_change(void *opaque, int running, RunState state)
|
||||||
{
|
{
|
||||||
VirtIODevice *vdev = opaque;
|
VirtIODevice *vdev = opaque;
|
||||||
@ -972,15 +966,6 @@ void virtio_init(VirtIODevice *vdev, const char *name,
|
|||||||
vdev);
|
vdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtIODevice *virtio_common_init(const char *name, uint16_t device_id,
|
|
||||||
size_t config_size, size_t struct_size)
|
|
||||||
{
|
|
||||||
VirtIODevice *vdev;
|
|
||||||
vdev = g_malloc0(struct_size);
|
|
||||||
virtio_init(vdev, name, device_id, config_size);
|
|
||||||
return vdev;
|
|
||||||
}
|
|
||||||
|
|
||||||
hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n)
|
hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n)
|
||||||
{
|
{
|
||||||
return vdev->vq[n].vring.desc;
|
return vdev->vq[n].vring.desc;
|
||||||
|
@ -147,7 +147,7 @@ typedef struct VirtioDeviceClass {
|
|||||||
|
|
||||||
void virtio_init(VirtIODevice *vdev, const char *name,
|
void virtio_init(VirtIODevice *vdev, const char *name,
|
||||||
uint16_t device_id, size_t config_size);
|
uint16_t device_id, size_t config_size);
|
||||||
void virtio_common_cleanup(VirtIODevice *vdev);
|
void virtio_cleanup(VirtIODevice *vdev);
|
||||||
|
|
||||||
VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
|
VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
|
||||||
void (*handle_output)(VirtIODevice *,
|
void (*handle_output)(VirtIODevice *,
|
||||||
@ -176,8 +176,6 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f);
|
|||||||
|
|
||||||
int virtio_load(VirtIODevice *vdev, QEMUFile *f);
|
int virtio_load(VirtIODevice *vdev, QEMUFile *f);
|
||||||
|
|
||||||
void virtio_cleanup(VirtIODevice *vdev);
|
|
||||||
|
|
||||||
void virtio_notify_config(VirtIODevice *vdev);
|
void virtio_notify_config(VirtIODevice *vdev);
|
||||||
|
|
||||||
void virtio_queue_set_notification(VirtQueue *vq, int enable);
|
void virtio_queue_set_notification(VirtQueue *vq, int enable);
|
||||||
@ -188,8 +186,6 @@ int virtio_queue_empty(VirtQueue *vq);
|
|||||||
|
|
||||||
/* Host binding interface. */
|
/* Host binding interface. */
|
||||||
|
|
||||||
VirtIODevice *virtio_common_init(const char *name, uint16_t device_id,
|
|
||||||
size_t config_size, size_t struct_size);
|
|
||||||
uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr);
|
uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr);
|
||||||
uint32_t virtio_config_readw(VirtIODevice *vdev, uint32_t addr);
|
uint32_t virtio_config_readw(VirtIODevice *vdev, uint32_t addr);
|
||||||
uint32_t virtio_config_readl(VirtIODevice *vdev, uint32_t addr);
|
uint32_t virtio_config_readl(VirtIODevice *vdev, uint32_t addr);
|
||||||
|
Loading…
Reference in New Issue
Block a user