[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v11 10/17] libxl: set correct nic type depending on the guest
Fix the use of nic type, which results in the following for each type of domain: * HVM: let the user choose, if none specified use VIF_IOEMU. * PV: use VIF is none provided, return error if VIF_IOEMU requested. Changes since v10: * Return an error if trying to create a guest with an IOEMU nic. Changes since v9: * Don't force nic type for HVM-stubdom guests. Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxx> --- tools/libxl/libxl.c | 22 ++++++++++++++++++---- tools/libxl/libxl_create.c | 2 +- tools/libxl/libxl_dm.c | 2 +- tools/libxl/libxl_internal.h | 3 ++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index e6c857e..c83d1de 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -2379,7 +2379,8 @@ out: /******************************************************************************/ -int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic) +int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic, + uint32_t domid) { if (!nic->mtu) nic->mtu = 1492; @@ -2409,8 +2410,21 @@ int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic) if ( !nic->script && asprintf(&nic->script, "%s/vif-bridge", libxl__xen_script_dir_path()) < 0 ) return ERROR_FAIL; - if (!nic->nictype) - nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU; + + switch (libxl__domain_type(gc, domid)) { + case LIBXL_DOMAIN_TYPE_HVM: + if (!nic->nictype) + nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU; + break; + case LIBXL_DOMAIN_TYPE_PV: + if (nic->nictype == LIBXL_NIC_TYPE_VIF_IOEMU) + return ERROR_INVAL; + nic->nictype = LIBXL_NIC_TYPE_VIF; + break; + default: + abort(); + } + return 0; } @@ -2438,7 +2452,7 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t domid, char *dompath, **l; unsigned int nb, rc; - rc = libxl__device_nic_setdefault(gc, nic); + rc = libxl__device_nic_setdefault(gc, nic, domid); if (rc) goto out; front = flexarray_make(16, 1); diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 9330012..fc112ce 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -941,7 +941,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__ao_devices *aodevs, * called libxl_device_nic_add at this point, but qemu needs * the nic information to be complete. */ - libxl__device_nic_setdefault(gc, &d_config->nics[i]); + libxl__device_nic_setdefault(gc, &d_config->nics[i], domid); } switch (d_config->c_info.type) { case LIBXL_DOMAIN_TYPE_HVM: diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index aaabf1b..4b0ea7e 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -904,7 +904,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. */ - libxl__device_nic_setdefault(gc, &dm_config->nics[i]); + libxl__device_nic_setdefault(gc, &dm_config->nics[i], dm_domid); } ret = libxl_device_vfb_add(ctx, dm_domid, &dm_config->vfbs[0]); if (ret) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 2add151..aca21ca 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -897,7 +897,8 @@ _hidden int libxl__domain_build_info_setdefault(libxl__gc *gc, libxl_domain_build_info *b_info); _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); +_hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic, + uint32_t domid); _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); _hidden int libxl__device_pci_setdefault(libxl__gc *gc, libxl_device_pci *pci); -- 1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |