/* * This routine does all the creation and setup of a new device, including * calling new_dev_desc() to allocate the descriptor and device memory. We * don't actually start the service threads until later. * * See what I mean about userspace being boring? */ static struct device *new_device(const char *name, u16 type) { struct device *dev = malloc(sizeof(*dev)); /* Now we populate the fields one at a time. */ dev->desc = new_dev_desc(type); dev->name = name; dev->vq = NULL; dev->feature_len = 0; dev->num_vq = 0; dev->running = false; /* * Append to device list. Prepending to a single-linked list is * easier, but the user expects the devices to be arranged on the bus * in command-line order. The first network device on the command line * is eth0, the first block device /dev/vda, etc. */ if (devices.lastdev) devices.lastdev->next = dev; else devices.dev = dev; devices.lastdev = dev; return dev; }
static struct device *new_device(const char *name, u16 type) { struct device *dev = malloc(sizeof(*dev)); dev->desc = new_dev_desc(type); dev->name = name; dev->vq = NULL; dev->feature_len = 0; dev->num_vq = 0; dev->running = false; dev->next = NULL; if (devices.lastdev) devices.lastdev->next = dev; else devices.dev = dev; devices.lastdev = dev; return dev; }