}
-static int cons_free(struct vm_device * dev) {
- struct cons_state * state = (struct cons_state *)dev->private_data;
-
+static int cons_free(struct cons_state * state) {
v3_console_close(state->cons);
// remove host event
};
static struct v3_device_ops dev_ops = {
- .free = cons_free,
+ .free = (int (*)(void *))cons_free,
};
static int cons_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg)
}
/* allocate device */
- struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, state);
- V3_ASSERT(dev);
-
- /* attach device to virtual machine */
- if (v3_attach_device(vm, dev) == -1) {
+ struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, state);
+
+ if (dev == NULL) {
PrintError("Could not attach device %s\n", dev_id);
V3_Free(state);
return -1;