@@ -3292,7 +3292,7 @@ out:
/******************************************************************************/
int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic,
- uint32_t domid, libxl_domain_build_info *info)
+ uint32_t domid)
{
int rc;
@@ -3330,21 +3330,11 @@ int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic,
switch (libxl__domain_type(gc, domid)) {
case LIBXL_DOMAIN_TYPE_HVM:
if (!nic->nictype) {
- if (info != NULL) {
- /* Path taken at creation time. */
- if (info->device_model_version ==
- LIBXL_DEVICE_MODEL_VERSION_NONE)
- nic->nictype = LIBXL_NIC_TYPE_VIF;
- else
- nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU;
- } else {
- /* Path taken when hot-adding a nic. */
- if (libxl__device_model_version_running(gc, domid) ==
- LIBXL_DEVICE_MODEL_VERSION_NONE)
- nic->nictype = LIBXL_NIC_TYPE_VIF;
- else
- nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU;
- }
+ if (libxl__device_model_version_running(gc, domid) ==
+ LIBXL_DEVICE_MODEL_VERSION_NONE)
+ nic->nictype = LIBXL_NIC_TYPE_VIF;
+ else
+ nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU;
}
break;
case LIBXL_DOMAIN_TYPE_PV:
@@ -3394,7 +3384,7 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t domid,
libxl_device_nic_init(&nic_saved);
libxl_device_nic_copy(CTX, &nic_saved, nic);
- rc = libxl__device_nic_setdefault(gc, nic, domid, NULL);
+ rc = libxl__device_nic_setdefault(gc, nic, domid);
if (rc) goto out;
front = flexarray_make(gc, 16, 1);
@@ -916,6 +916,12 @@ static void initiate_domain_create(libxl__egc *egc,
goto error_out;
}
+ /*
+ * Set the dm version quite early so that libxl doesn't have to pass the
+ * build info around just to know if the domain has a device model or not.
+ */
+ store_libxl_entry(gc, domid, &d_config->b_info);
+
for (i = 0; i < d_config->num_disks; i++) {
ret = libxl__device_disk_setdefault(gc, &d_config->disks[i]);
if (ret) {
@@ -940,8 +946,7 @@ static void initiate_domain_create(libxl__egc *egc,
* called libxl_device_nic_add when domcreate_launch_dm gets called,
* but qemu needs the nic information to be complete.
*/
- ret = libxl__device_nic_setdefault(gc, &d_config->nics[i], domid,
- &d_config->b_info);
+ ret = libxl__device_nic_setdefault(gc, &d_config->nics[i], domid);
if (ret) {
LOG(ERROR, "Unable to set nic defaults for nic %d", i);
goto error_out;
@@ -1810,8 +1810,7 @@ static void spawn_stub_launch_dm(libxl__egc *egc,
* called libxl_device_nic_add at this point, but qemu needs
* the nic information to be complete.
*/
- ret = libxl__device_nic_setdefault(gc, &dm_config->nics[i], dm_domid,
- &dm_config->b_info);
+ ret = libxl__device_nic_setdefault(gc, &dm_config->nics[i], dm_domid);
if (ret)
goto out;
}
@@ -1206,8 +1206,7 @@ _hidden int libxl__domain_build_info_setdefault(libxl__gc *gc,
_hidden int libxl__device_disk_setdefault(libxl__gc *gc,
libxl_device_disk *disk);
_hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic,
- uint32_t domid,
- libxl_domain_build_info *info);
+ uint32_t domid);
_hidden int libxl__device_vtpm_setdefault(libxl__gc *gc, libxl_device_vtpm *vtpm);
_hidden int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb);
_hidden int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb);