static int pit_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct pit * pit_state = NULL;
struct vm_device * dev = NULL;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
// PIT is only usable in non-multicore environments
// just hardcode the core context
pit_state = (struct pit *)V3_Malloc(sizeof(struct pit));
V3_ASSERT(pit_state != NULL);
- dev = v3_allocate_device(name, &dev_ops, pit_state);
+ dev = v3_allocate_device(dev_id, &dev_ops, pit_state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
static int pic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct pic_internal * state = NULL;
state = (struct pic_internal *)V3_Malloc(sizeof(struct pic_internal));
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
// PIC is only usable in non-multicore environments
// just hardcode the core context
V3_ASSERT(state != NULL);
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
static int apic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
PrintDebug("apic: creating an APIC for each core\n");
- char * name = v3_cfg_val(cfg, "name");
- char * icc_name = v3_cfg_val(cfg,"bus");
- struct vm_device * icc = v3_find_dev(vm, icc_name);
+ char * dev_id = v3_cfg_val(cfg, "ID");
+ char * icc_bus_id = v3_cfg_val(cfg,"bus");
+ struct vm_device * icc = v3_find_dev(vm, icc_bus_id);
int i;
if (!icc) {
- PrintError("apic: Cannot find ICC Bus (%s)\n", icc_name);
+ PrintError("apic: Cannot find ICC Bus (%s)\n", icc_bus_id);
return -1;
}
// 0..num_cores-1 at num_cores is the ioapic (one only)
struct apic_state * apic = (struct apic_state *)V3_Malloc(sizeof(struct apic_state) * vm->num_cores);
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, apic);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, apic);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("apic: Could not attach device %s\n", name);
+ PrintError("apic: Could not attach device %s\n", dev_id);
return -1;
}
static int debug_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct debug_state * state = NULL;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
state = (struct debug_state *)V3_Malloc(sizeof(struct debug_state));
V3_ASSERT(state != NULL);
PrintDebug("Creating Bochs Debug Device\n");
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
}
}
-static int video_write_mem(addr_t guest_addr, void * dest, uint_t length, void * priv_data) {
+static int video_write_mem(struct guest_info * core, addr_t guest_addr, void * dest, uint_t length, void * priv_data) {
struct vm_device * dev = (struct vm_device *)priv_data;
struct video_internal * state = (struct video_internal *)dev->private_data;
uint_t fb_offset = guest_addr - START_ADDR;
return length;
}
-static int video_read_port(uint16_t port, void * dest, uint_t length, struct vm_device * dev) {
+static int video_read_port(struct guest_info * core, uint16_t port, void * dest, uint_t length, struct vm_device * dev) {
struct video_internal * video_state = (struct video_internal *)dev->private_data;
-static int video_write_port(uint16_t port, void * src, uint_t length, struct vm_device * dev) {
+static int video_write_port(struct guest_info * core, uint16_t port, void * src, uint_t length, struct vm_device * dev) {
struct video_internal * video_state = (struct video_internal *)dev->private_data;
-static int crtc_data_write(uint16_t port, void * src, uint_t length, struct vm_device * dev) {
+static int crtc_data_write(struct guest_info * core, uint16_t port, void * src, uint_t length, struct vm_device * dev) {
struct video_internal * video_state = (struct video_internal *)dev->private_data;
uint8_t val = *(uint8_t *)src;
uint_t index = video_state->crtc_index_reg;
}
-static int crtc_index_write(uint16_t port, void * src, uint_t length, struct vm_device * dev) {
+static int crtc_index_write(struct guest_info * core, uint16_t port, void * src, uint_t length, struct vm_device * dev) {
struct video_internal * video_state = (struct video_internal *)dev->private_data;
if (length > 2) {
}
if (length == 2) {
- if (crtc_data_write(port + 1, src + 1, length - 1, dev) != (length - 1)) {
+ if (crtc_data_write(core, port + 1, src + 1, length - 1, dev) != (length - 1)) {
PrintError("could not handle implicit crtc data write\n");
return -1;
}
static int free_device(struct vm_device * dev) {
- v3_unhook_mem(dev->vm, START_ADDR);
+ v3_unhook_mem(dev->vm, V3_MEM_CORE_ANY, START_ADDR);
return 0;
}
.stop = NULL,
};
-static int cga_init(struct guest_info * vm, v3_cfg_tree_t * cfg) {
+static int cga_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct video_internal * video_state = (struct video_internal *)V3_Malloc(sizeof(struct video_internal));
addr_t frame_buf_pa = 0;
int enable_passthrough = 0;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
enable_passthrough = (strcasecmp(v3_cfg_val(cfg, "passthrough"), "enable") == 0) ? 1 : 0;
PrintDebug("video: init_device\n");
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, video_state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, video_state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
if (enable_passthrough) {
PrintDebug("Enabling CGA Passthrough\n");
- if (v3_hook_write_mem(vm, START_ADDR, END_ADDR, START_ADDR, &video_write_mem, dev) == -1) {
+ if (v3_hook_write_mem(vm, V3_MEM_CORE_ANY, START_ADDR, END_ADDR, START_ADDR, &video_write_mem, dev) == -1) {
PrintDebug("\n\nVideo Hook failed.\n\n");
}
} else {
- if (v3_hook_write_mem(vm, START_ADDR, END_ADDR, frame_buf_pa, &video_write_mem, dev) == -1) {
+ if (v3_hook_write_mem(vm, V3_MEM_CORE_ANY, START_ADDR, END_ADDR, frame_buf_pa, &video_write_mem, dev) == -1) {
PrintDebug("\n\nVideo Hook failed.\n\n");
}
}
static int cirrus_gfx_card_init(struct guest_info * vm, v3_cfg_tree_t * cfg){
struct video_internal * video_state = (struct video_internal *)V3_Malloc(sizeof(struct video_internal));
struct vm_device * pci_bus = v3_find_dev(vm, (char *)cfg_data);
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
- struct vm_device * dev = v3_allocate_device("TEXT_GFX_CARD", &dev_ops, video_state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, video_state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", "TEXT_GFX_CARD");
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
.stop = NULL,
};
-static int cons_init(struct guest_info * vm, v3_cfg_tree_t * cfg)
+static int cons_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg)
{
- struct cons_state * state;
- v3_cfg_tree_t * frontend_cfg;
- const char *frontend_tag;
- struct vm_device * frontend;
- char *name, *ttypath;
+ struct cons_state * state = NULL;
+ v3_cfg_tree_t * frontend_cfg = v3_cfg_subtree(cfg, "frontend");
+ const char * frontend_tag = v3_cfg_val(frontend_cfg, "tag");
+ struct vm_device * frontend = v3_find_dev(vm, frontend_tag);
+ char * dev_id = v3_cfg_val(cfg, "ID");
+ char * ttypath = v3_cfg_val(cfg, "tty");
/* read configuration */
- frontend_cfg = v3_cfg_subtree(cfg, "frontend");
V3_ASSERT(frontend_cfg);
- frontend_tag = v3_cfg_val(frontend_cfg, "tag");
V3_ASSERT(frontend_tag);
- frontend = v3_find_dev(vm, frontend_tag);
V3_ASSERT(frontend);
- name = v3_cfg_val(cfg, "name");
+
/* allocate state */
- state = (struct cons_state *) V3_Malloc(sizeof(struct cons_state));
+ state = (struct cons_state *)V3_Malloc(sizeof(struct cons_state));
V3_ASSERT(state);
state->frontend_dev = frontend;
- ttypath = v3_cfg_val(cfg, "tty");
V3_ASSERT(ttypath);
/* open tty for screen display */
}
/* allocate device */
- struct vm_device *dev = v3_allocate_device(name, &dev_ops, state);
+ 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) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
V3_Free(state);
return -1;
}
static int model_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, NULL);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, NULL);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
- if (v3_dev_add_blk_frontend(vm, name, connect_fn, NULL) == -1) {
- PrintError("Could not register %s as block frontend\n", name);
+ if (v3_dev_add_blk_frontend(vm, dev_id, connect_fn, NULL) == -1) {
+ PrintError("Could not register %s as block frontend\n", dev_id);
return -1;
}
static int disk_init(struct guest_info * vm, v3_cfg_tree_t * cfg) {
struct disk_state * disk = NULL;
- char * name = v3_cfg_val(cfg, "filename");
+ char * path = v3_cfg_val(cfg, "path");
+ char * dev_id = v3_cfg_val(cfg, "ID");
char * filename = v3_cfg_val(cfg, "file");
+
v3_cfg_tree_t * frontend_cfg = v3_cfg_subtree(cfg, "frontend");
disk = (struct disk_state *)V3_Malloc(sizeof(struct disk_state));
memset(disk, 0, sizeof(struct disk_state));
- if (!filename) {
- PrintError("Missing filename (%s) for %s\n", filename, name);
+ if (!path) {
+ PrintError("Missing path (%s) for %s\n", path, dev_id);
return -1;
}
- disk->fd = V3_FileOpen(filename, 0);
+ disk->fd = V3_FileOpen(path, 0);
disk->capacity = V3_FileSize(disk->fd);
PrintDebug("Registering RAMDISK at %p (size=%d)\n",
(void *)file->data, (uint32_t)file->size);
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, disk);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, disk);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
if (v3_dev_connect_blk(vm, v3_cfg_val(frontend_cfg, "tag"),
&blk_ops, frontend_cfg, disk) == -1) {
PrintError("Could not connect %s to frontend %s\n",
- name, v3_cfg_val(frontend_cfg, "tag"));
+ dev_id, v3_cfg_val(frontend_cfg, "tag"));
return -1;
}
static int generic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct generic_internal * state = (struct generic_internal *)V3_Malloc(sizeof(struct generic_internal));
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
v3_cfg_tree_t * port_cfg = v3_cfg_subtree(cfg, "ports");
state->num_port_ranges = 0;
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
int i;
struct i440_state * state = NULL;
struct vm_device * pci = v3_find_dev(vm, v3_cfg_val(cfg, "bus"));
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
if (!pci) {
PrintError("could not find PCI Device\n");
state->pci = pci;
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
static int icc_bus_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
PrintDebug("icc_bus: Creating ICC_BUS\n");
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
struct icc_bus_state * icc_bus = (struct icc_bus_state *)V3_Malloc(sizeof(struct icc_bus_state));
memset(icc_bus, 0, sizeof(struct icc_bus_state));
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, icc_bus);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, icc_bus);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("icc_bus: Could not attach device %s\n", name);
+ PrintError("icc_bus: Could not attach device %s\n", dev_id);
return -1;
}
static int ide_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct ide_internal * ide = (struct ide_internal *)V3_Malloc(sizeof(struct ide_internal));
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
PrintDebug("IDE: Initializing IDE\n");
memset(ide, 0, sizeof(struct ide_internal));
PrintDebug("IDE: Creating IDE bus x 2\n");
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, ide);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, ide);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
}
- if (v3_dev_add_blk_frontend(vm, name, connect_fn, (void *)ide) == -1) {
- PrintError("Could not register %s as frontend\n", name);
+ if (v3_dev_add_blk_frontend(vm, dev_id, connect_fn, (void *)ide) == -1) {
+ PrintError("Could not register %s as frontend\n", dev_id);
return -1;
}
return 0;
}
-
-
-
static int ioapic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct vm_device * icc_bus = v3_find_dev(vm, v3_cfg_val(cfg, "bus"));
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
if (!icc_bus) {
PrintError("ioapic: Could not locate ICC BUS device (%s)\n", v3_cfg_val(cfg, "bus"));
ioapic->icc_bus = icc_bus;
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, ioapic);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, ioapic);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("ioapic: Could not attach device %s\n", name);
+ PrintError("ioapic: Could not attach device %s\n", dev_id);
return -1;
}
static int keyboard_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct keyboard_internal * keyboard_state = NULL;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
PrintDebug("keyboard: init_device\n");
keyboard_state->mouse_enabled = 0;
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, keyboard_state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, keyboard_state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
struct vm_device * pci_bus = v3_find_dev(vm, v3_cfg_val(cfg, "bus"));
struct virtio_balloon_state * virtio_state = NULL;
struct pci_device * pci_dev = NULL;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
PrintDebug("Initializing VIRTIO Balloon device\n");
memset(virtio_state, 0, sizeof(struct virtio_balloon_state));
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, virtio_state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, virtio_state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct vm_device * pci_bus = v3_find_dev(vm, v3_cfg_val(cfg, "bus"));
struct virtio_dev_state * virtio_state = NULL;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
PrintDebug("Initializing VIRTIO Block device\n");
virtio_state->pci_bus = pci_bus;
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, virtio_state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, virtio_state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
- if (v3_dev_add_blk_frontend(vm, name, connect_fn, (void *)virtio_state) == -1) {
- PrintError("Could not register %s as block frontend\n", name);
+ if (v3_dev_add_blk_frontend(vm, dev_id, connect_fn, (void *)virtio_state) == -1) {
+ PrintError("Could not register %s as block frontend\n", dev_id);
return -1;
}
static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct vm_device * pci_bus = v3_find_dev(vm, v3_cfg_val(cfg, "bus"));
struct virtio_dev_state * virtio_state = NULL;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
- PrintDebug("Virtio NIC: Initializing VIRTIO Network device: %s\n", name);
+ PrintDebug("Virtio NIC: Initializing VIRTIO Network device: %s\n", dev_id);
if (pci_bus == NULL) {
PrintError("Virtio NIC: VirtIO devices require a PCI Bus");
virtio_state->pci_bus = pci_bus;
virtio_state->vm = vm;
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, virtio_state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, virtio_state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Virtio NIC: Could not attach device %s\n", name);
+ PrintError("Virtio NIC: Could not attach device %s\n", dev_id);
return -1;
}
- if (v3_dev_add_net_frontend(vm, name, connect_fn, (void *)virtio_state) == -1) {
- PrintError("Virtio NIC: Could not register %s as net frontend\n", name);
+ if (v3_dev_add_net_frontend(vm, dev_id, connect_fn, (void *)virtio_state) == -1) {
+ PrintError("Virtio NIC: Could not register %s as net frontend\n", dev_id);
return -1;
}
struct vm_device * pci_bus = v3_find_dev(vm, v3_cfg_val(cfg, "bus"));
struct virtio_sym_state * virtio_state = NULL;
struct pci_device * pci_dev = NULL;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
PrintDebug("Initializing VIRTIO Symbiotic device\n");
memset(virtio_state, 0, sizeof(struct virtio_sym_state));
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, virtio_state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, virtio_state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
struct virtio_sym_state * virtio_state = NULL;
struct v3_symmod_state * symmod_state = &(vm->sym_vm_state.symmod_state);
struct pci_device * pci_dev = NULL;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
PrintDebug("SYMMOD: Initializing VIRTIO Symbiotic Module device\n");
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, virtio_state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, virtio_state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
struct vm_device * pci_bus = v3_find_dev(vm, v3_cfg_val(cfg, "bus"));
struct virtio_vnet_state * vnet_state = NULL;
struct pci_device * pci_dev = NULL;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
- PrintDebug("VNET Bridge: Initializing VNET Bridge Control device: %s\n", name);
+ PrintDebug("VNET Bridge: Initializing VNET Bridge Control device: %s\n", dev_id);
if (pci_bus == NULL) {
PrintError("VNET Bridge device require a PCI Bus");
vnet_state->vm = vm;
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, vnet_state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, vnet_state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
char * ip_str = v3_cfg_val(cfg, "IP");
char * port_str = v3_cfg_val(cfg, "port");
char * disk_tag = v3_cfg_val(cfg, "tag");
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
v3_cfg_tree_t * frontend_cfg = v3_cfg_subtree(cfg, "frontend");
disk->ip_addr = v3_inet_addr(ip_str);
disk->port = atoi(port_str);
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, disk);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, disk);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
if (v3_dev_connect_blk(vm, v3_cfg_val(frontend_cfg, "tag"),
&blk_ops, frontend_cfg, disk) == -1) {
- PrintError("Could not connect %s to frontend\n", name);
+ PrintError("Could not connect %s to frontend\n", dev_id);
return -1;
}
static int nvram_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct nvram_internal * nvram_state = NULL;
struct vm_device * ide = v3_find_dev(vm, v3_cfg_val(cfg, "storage"));
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
if (!ide) {
PrintError("Could not find IDE device\n");
nvram_state->ide = ide;
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, nvram_state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, nvram_state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
static int debug_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct debug_state * state = NULL;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
state = (struct debug_state *)V3_Malloc(sizeof(struct debug_state));
PrintDebug("Creating OS Debug Device\n");
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
static int net_init(struct guest_info * vm, v3_cfg_tree_t * cfg) {
struct nic_state * state = NULL;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
state = (struct nic_state *)V3_Malloc(sizeof(struct nic_state));
PrintDebug("Creating VMNet Device\n");
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
static int pci_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct pci_internal * pci_state = V3_Malloc(sizeof(struct pci_internal));
int i = 0;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
PrintDebug("PCI internal at %p\n",(void *)pci_state);
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, pci_state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, pci_state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
struct pt_dev_state * state = V3_Malloc(sizeof(struct pt_dev_state));
struct vm_device * dev = NULL;
struct vm_device * pci = v3_find_dev(vm, v3_cfg_val(cfg, "bus"));
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
memset(state, 0, sizeof(struct pt_dev_state));
}
state->pci_bus = pci;
- strncpy(state->name, name, 32);
+ strncpy(state->name, dev_id, 32);
- dev = v3_allocate_device(name, &dev_ops, state);
+ dev = v3_allocate_device(dev_id, &dev_ops, state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
struct v3_southbridge * piix3 = (struct v3_southbridge *)V3_Malloc(sizeof(struct v3_southbridge));
struct vm_device * dev = NULL;
struct vm_device * pci = v3_find_dev(vm, v3_cfg_val(cfg, "bus"));
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
if (!pci) {
PrintError("Could not find PCI device\n");
piix3->pci_bus = pci;
piix3->type = V3_SB_PIIX3;
- dev = v3_allocate_device(name, &dev_ops, piix3);
+ dev = v3_allocate_device(dev_id, &dev_ops, piix3);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
static int disk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct disk_state * disk = NULL;
struct v3_cfg_file * file = NULL;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
char * filename = v3_cfg_val(cfg, "file");
v3_cfg_tree_t * frontend_cfg = v3_cfg_subtree(cfg, "frontend");
if (!filename) {
- PrintError("Missing filename (%s) for %s\n", filename, name);
+ PrintError("Missing filename (%s) for %s\n", filename, dev_id);
return -1;
}
PrintDebug("Registering RAMDISK at %p (size=%d)\n",
(void *)file->data, (uint32_t)file->size);
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, disk);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, disk);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
if (v3_dev_connect_blk(vm, v3_cfg_val(frontend_cfg, "tag"),
&blk_ops, frontend_cfg, disk) == -1) {
PrintError("Could not connect %s to frontend %s\n",
- name, v3_cfg_val(frontend_cfg, "tag"));
+ dev_id, v3_cfg_val(frontend_cfg, "tag"));
return -1;
}
static int serial_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct serial_state * state = (struct serial_state *)V3_Malloc(sizeof(struct serial_state));
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
PrintDebug("UART: init_device\n");
init_serial_port(&(state->com1));
state->com4.irq_number = COM4_IRQ;
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
struct swap_state * swap = NULL;
v3_cfg_tree_t * frontend_cfg = v3_cfg_subtree(cfg, "frontend");
uint32_t capacity = atoi(v3_cfg_val(cfg, "size")) * 1024 * 1024;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
if (!frontend_cfg) {
PrintError("Initializing sym swap without a frontend device\n");
memset(swap->usage_map, 0, ((swap->capacity / 4096) / 8));
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, swap);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, swap);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
if (v3_dev_connect_blk(vm, v3_cfg_val(frontend_cfg, "tag"),
&blk_ops, frontend_cfg, swap) == -1) {
PrintError("Could not connect %s to frontend %s\n",
- name, v3_cfg_val(frontend_cfg, "tag"));
+ dev_id, v3_cfg_val(frontend_cfg, "tag"));
return -1;
}
static int swap_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, NULL);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, NULL);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
- if (v3_dev_add_blk_frontend(vm, name, connect_fn, NULL) == -1) {
- PrintError("Could not register %s as block frontend\n", name);
+ if (v3_dev_add_blk_frontend(vm, dev_id, connect_fn, NULL) == -1) {
+ PrintError("Could not register %s as block frontend\n", dev_id);
return -1;
}
}
-static int cons_init(struct guest_info * vm, v3_cfg_tree_t * cfg) {
+static int cons_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct cons_state * state = (struct cons_state *)V3_Malloc(sizeof(struct cons_state));
v3_cfg_tree_t * frontend_cfg = v3_cfg_subtree(cfg, "frontend");
- struct vm_device * frontend = v3_find_dev(vm, v3_cfg_val(frontend_cfg, "id"));
- char * name = v3_cfg_val(cfg, "name");
+ struct vm_device * frontend = v3_find_dev(vm, v3_cfg_val(frontend_cfg, "tag"));
+ char * dev_id = v3_cfg_val(cfg, "ID");
state->server_fd = 0;
v3_lock_init(&(state->cons_lock));
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
static int blk_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct blk_state * blk = NULL;
v3_cfg_tree_t * frontend_cfg = v3_cfg_subtree(cfg, "frontend");
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
uint64_t capacity = atoi(v3_cfg_val(cfg, "size")) * 1024 * 1024;
if (!frontend_cfg) {
memset(blk->blk_space, 0, capacity);
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, blk);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, blk);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
if (v3_dev_connect_blk(vm, v3_cfg_val(frontend_cfg, "tag"),
&blk_ops, frontend_cfg, blk) == -1) {
PrintError("Could not connect %s to frontend %s\n",
- name, v3_cfg_val(frontend_cfg, "tag"));
+ dev_id, v3_cfg_val(frontend_cfg, "tag"));
return -1;
}
static int vnet_nic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
struct vnet_nic_state * vnetnic = NULL;
- char * name = v3_cfg_val(cfg, "name");
+ char * dev_id = v3_cfg_val(cfg, "ID");
char * macstr = NULL;
char mac[6];
- int vnet_dev_id;
+ int vnet_dev_id = 0;
v3_cfg_tree_t * frontend_cfg = v3_cfg_subtree(cfg, "frontend");
macstr = v3_cfg_val(frontend_cfg, "mac");
vnetnic = (struct vnet_nic_state *)V3_Malloc(sizeof(struct vnet_nic_state));
memset(vnetnic, 0, sizeof(struct vnet_nic_state));
- struct vm_device * dev = v3_allocate_device(name, &dev_ops, vnetnic);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, vnetnic);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", name);
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
if (v3_dev_connect_net(vm, v3_cfg_val(frontend_cfg, "tag"),
&(vnetnic->net_ops), frontend_cfg, vnetnic) == -1) {
PrintError("Could not connect %s to frontend %s\n",
- name, v3_cfg_val(frontend_cfg, "tag"));
+ dev_id, v3_cfg_val(frontend_cfg, "tag"));
return -1;
}
PrintDebug("Vnet-nic: Connect %s to frontend %s\n",
- name, v3_cfg_val(frontend_cfg, "tag"));
+ dev_id, v3_cfg_val(frontend_cfg, "tag"));
- if ((vnet_dev_id = register_to_vnet(vm, vnetnic, name, vnetnic->mac)) == -1) {
- PrintError("Vnet-nic device %s (mac: %s) fails to registered to VNET\n", name, macstr);
+ if ((vnet_dev_id = register_to_vnet(vm, vnetnic, dev_id, vnetnic->mac)) == -1) {
+ PrintError("Vnet-nic device %s (mac: %s) fails to registered to VNET\n", dev_id, macstr);
}
vnetnic->vnet_dev_id = vnet_dev_id;
- PrintDebug("Vnet-nic device %s (mac: %s, %ld) registered to VNET\n", name, macstr, *((ulong_t *)vnetnic->mac));
+ PrintDebug("Vnet-nic device %s (mac: %s, %ld) registered to VNET\n", dev_id, macstr, *((ulong_t *)vnetnic->mac));
//for temporary hack for vnet bridge test
{
uchar_t zeromac[6] = {0,0,0,0,0,0};
- if(!strcmp(name, "vnet_nic")){
+ if(!strcmp(dev_id, "vnet_nic")){
struct v3_vnet_route route;
route.dst_id = vnet_dev_id;
static int vnet_nic_dom0 = -1;
uchar_t zeromac[6] = {0,0,0,0,0,0};
- if(!strcmp(name, "vnet_nic")){ //domu
+ if(!strcmp(dev_id, "vnet_nic")){ //domu
vnet_nic_guestid = vnet_dev_id;
}
- if (!strcmp(name, "vnet_nic_dom0")){
+ if (!strcmp(dev_id, "vnet_nic_dom0")){
vnet_nic_dom0 = vnet_dev_id;
}\r
while (device) {
- char * id = v3_cfg_val(device, "id");
+ char * dev_class = v3_cfg_val(device, "class");
- V3_Print("configuring device %s\n", id);
+ V3_Print("configuring device %s\n", dev_class);
- if (v3_create_device(vm, id, device) == -1) {
- PrintError("Error creating device %s\n", id);
+ if (v3_create_device(vm, dev_class, device) == -1) {
+ PrintError("Error creating device %s\n", dev_class);
return -1;
}
<!-- List of devices attached to guest -->
- <!-- The device 'ID' is the device name in the global device registry -->
- <!-- The device 'name' is the reference to the device instance associated with a VM -->
+ <!-- The device 'class' is the device name in the global device registry -->
+ <!-- The device 'id' is the reference to the device instance associated with a VM -->
<!-- The name can be used as a reference by other devices -->
<devices>
- <device id="8259A" name="PIC"/>
- <device id="KEYBOARD" name="keyboard"/>
- <device id="8254_PIT" name="PIT" />
- <device id="BOCHS_DEBUG" name="bochs debug"/>
- <device id="OS_DEBUG" name="os debug" />
- <device id="ICC_BUS" name="icc"/>
- <device id="LAPIC" name="apic">
+ <device class="8259A" id="PIC"/>
+ <device class="KEYBOARD" id="keyboard"/>
+ <device class="8254_PIT" id="PIT" />
+ <device class="BOCHS_DEBUG" id="bochs debug"/>
+ <device class="OS_DEBUG" id="os debug" />
+ <device class="ICC_BUS" id="icc"/>
+ <device class="LAPIC" id="apic">
<bus>icc</bus>
</device>
- <device id="IOAPIC" name="ioapic">
+ <device class="IOAPIC" id="ioapic">
<bus>icc</bus>
</device>
<!--
- <device id="CGA_VIDEO" name="cga" passthrough="enable" />
- <device id="TELNET_CONSOLE" name="telnet console">
+ <device class="CGA_VIDEO" id="cga" passthrough="enable" />
+ <device class="TELNET_CONSOLE" id="telnet console">
<frontend tag="CGA_VIDEO" />
<port>19997</port>
</device>
-->
- <device id="PCI" name="pci0" />
+ <device class="PCI" id="pci0" />
- <device id="i440FX" name="northbridge">
+ <device class="i440FX" id="northbridge">
<bus>pci0</bus>
</device>
- <device id="PIIX3" name="southbridge">
+ <device class="PIIX3" id="southbridge">
<bus>pci0</bus>
</device>
- <device id="IDE" name="ide">
+ <device class="IDE" id="ide">
<bus>pci0</bus>
<controller>southbridge</controller>
</device>
<!--
- <device id="LNX_VIRTIO_SYM" name="sym_pci">
+ <device class="LNX_VIRTIO_SYM" id="sym_pci">
<bus>pci0</bus>
</device>
- <device id="LNX_VIRTIO_BLK" name="blk_virtio">
+ <device class="LNX_VIRTIO_BLK" id="blk_virtio">
<bus>pci0</bus>
</device>
- <device id="LNX_VIRTIO_BALLOON" name="balloon">
+ <device class="LNX_VIRTIO_BALLOON" id="balloon">
<bus>pci0</bus>
</device>
- <device id="PCI_PASSTHROUGH" name="e1000">
+ <device class="PCI_PASSTHROUGH" id="e1000">
<bus>pci0</bus>
<vendor_id>0x8086</vendor_id>
<device_id>0x100e</device_id>
<irq>59</irq>
</device>
- <device id="PCI_PASSTHROUGH" name="e1000-hw">
+ <device class="PCI_PASSTHROUGH" id="e1000-hw">
<bus>pci0</bus>
<vendor_id>0x8086</vendor_id>
<device_id>0x107c</device_id>
<!-- This is a Storage Backend that connects to a frontend -->
<!-- The frontend section is passed to the frontend when the backend connects -->
<!-- The file tag refers to an 'id' already listed in the file list section above -->
- <device id="RAMDISK" name="CD0">
+ <device class="RAMDISK" id="CD0">
<file>boot-cd</file>
<frontend tag="ide">
<model>V3Vee CDROM</model>
<!---
- <device id="SYM_SWAP" name="sym swap">
+ <device class="SYM_SWAP" id="sym swap">
<frontend tag="blk_virtio" />
<size>150</size>
</device>
- <device id="RAMDISK" name="HD0">
+ <device class="RAMDISK" id="HD0">
<file>harddisk</file>
<frontend tag="blk_virtio" />
</device>
-->
- <device id="NVRAM" name="nvram">
+ <device class="NVRAM" id="nvram">
<storage>ide</storage>
</device>
- <device id="GENERIC" name="generic">
+ <device class="GENERIC" id="generic">
<ports>
<start>0x00</start>
<end>0x07</end>