diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a2de8df18ae3cb3ae3a252f2570544581a8d2815..a8b7d8392f724e7b780c42e6d5bc73f48b798e29 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -196,7 +196,7 @@ VIR_ENUM_IMPL(virDomainController, VIR_DOMAIN_CONTROLLER_TYPE_LAST, "virtio-serial", "ccid") -VIR_ENUM_IMPL(virDomainControllerModel, VIR_DOMAIN_CONTROLLER_MODEL_LAST, +VIR_ENUM_IMPL(virDomainControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST, "auto", "buslogic", "lsilogic", @@ -2456,6 +2456,16 @@ no_memory: } +static int +virDomainControllerModelTypeFromString(const virDomainControllerDefPtr def, + const char *model) +{ + if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) + return virDomainControllerModelSCSITypeFromString(model); + + return -1; +} + /* Parse the XML definition for a controller * @param node XML nodeset to parse for controller definition */ @@ -2493,7 +2503,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, model = virXMLPropString(node, "model"); if (model) { - if ((def->model = virDomainControllerModelTypeFromString(model)) < 0) { + if ((def->model = virDomainControllerModelTypeFromString(def, model)) < 0) { virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown model type '%s'"), model); goto error; @@ -8729,6 +8739,16 @@ virDomainDiskDefFormat(virBufferPtr buf, return 0; } +static const char * +virDomainControllerModelTypeToString(virDomainControllerDefPtr def, + int model) +{ + if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) + return virDomainControllerModelSCSITypeToString(model); + + return NULL; +} + static int virDomainControllerDefFormat(virBufferPtr buf, virDomainControllerDefPtr def, @@ -8744,7 +8764,7 @@ virDomainControllerDefFormat(virBufferPtr buf, } if (def->model != -1) { - model = virDomainControllerModelTypeToString(def->model); + model = virDomainControllerModelTypeToString(def, def->model); if (!model) { virDomainReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 0abb75e3d1e52bb7e6bbfaa5dc16708b29cec1bb..39bb999cc6dbc6922edf22a0c8d4e6cb4f2e3d59 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -258,14 +258,14 @@ enum virDomainControllerType { }; -enum virDomainControllerModel { - VIR_DOMAIN_CONTROLLER_MODEL_AUTO, - VIR_DOMAIN_CONTROLLER_MODEL_BUSLOGIC, - VIR_DOMAIN_CONTROLLER_MODEL_LSILOGIC, - VIR_DOMAIN_CONTROLLER_MODEL_LSISAS1068, - VIR_DOMAIN_CONTROLLER_MODEL_VMPVSCSI, +enum virDomainControllerModelSCSI { + VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO, + VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC, + VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC, + VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068, + VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI, - VIR_DOMAIN_CONTROLLER_MODEL_LAST + VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST }; typedef struct _virDomainVirtioSerialOpts virDomainVirtioSerialOpts; @@ -1676,7 +1676,7 @@ VIR_ENUM_DECL(virDomainDiskIo) VIR_ENUM_DECL(virDomainIoEventFd) VIR_ENUM_DECL(virDomainVirtioEventIdx) VIR_ENUM_DECL(virDomainController) -VIR_ENUM_DECL(virDomainControllerModel) +VIR_ENUM_DECL(virDomainControllerModelSCSI) VIR_ENUM_DECL(virDomainFS) VIR_ENUM_DECL(virDomainFSAccessMode) VIR_ENUM_DECL(virDomainNet) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index c097651a0b0fed135dccdec4ae0f01c00f978ab0..e6033994e534b5849fcba6d126d5b7a67b53ec70 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -412,16 +412,16 @@ esxAutodetectSCSIControllerModel(virDomainDiskDefPtr def, int *model, if (STRCASEEQ(vmDiskFileInfo->controllerType, "VirtualBusLogicController")) { - *model = VIR_DOMAIN_CONTROLLER_MODEL_BUSLOGIC; + *model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC; } else if (STRCASEEQ(vmDiskFileInfo->controllerType, "VirtualLsiLogicController")) { - *model = VIR_DOMAIN_CONTROLLER_MODEL_LSILOGIC; + *model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC; } else if (STRCASEEQ(vmDiskFileInfo->controllerType, "VirtualLsiLogicSASController")) { - *model = VIR_DOMAIN_CONTROLLER_MODEL_LSISAS1068; + *model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068; } else if (STRCASEEQ(vmDiskFileInfo->controllerType, "ParaVirtualSCSIController")) { - *model = VIR_DOMAIN_CONTROLLER_MODEL_VMPVSCSI; + *model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI; } else { ESX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Found unexpected controller model '%s' for disk '%s'"), diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9f03e30d86acba91c28ac0ac793a8c12d8d6b120..c2ce32f022a94ed03ff807c09e73ba80cc86f465 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -248,8 +248,8 @@ virDomainConfigFile; virDomainControllerDefFree; virDomainControllerInsert; virDomainControllerInsertPreAlloced; -virDomainControllerModelTypeFromString; -virDomainControllerModelTypeToString; +virDomainControllerModelSCSITypeFromString; +virDomainControllerModelSCSITypeToString; virDomainControllerTypeToString; virDomainCpuSetFormat; virDomainCpuSetParse; diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 08c2716c6bcf7197cef1da9a9eb6093fd2cb602e..dff3599403b664b4a39c24d2d5eac8e2c6137429 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -483,8 +483,8 @@ def->parallels[0]... /* directly map the virDomainControllerModel to virVMXSCSIControllerModel, * this is good enough for now because all virDomainControllerModel values * are actually SCSI controller models in the ESX case */ -VIR_ENUM_DECL(virVMXSCSIControllerModel) -VIR_ENUM_IMPL(virVMXSCSIControllerModel, VIR_DOMAIN_CONTROLLER_MODEL_LAST, +VIR_ENUM_DECL(virVMXControllerModelSCSI) +VIR_ENUM_IMPL(virVMXControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST, "auto", /* just to match virDomainControllerModel, will never be used */ "buslogic", "lsilogic", @@ -1040,7 +1040,7 @@ virVMXHandleLegacySCSIDiskDriverName(virDomainDefPtr def, *tmp = c_tolower(*tmp); } - model = virDomainControllerModelTypeFromString(disk->driverName); + model = virDomainControllerModelSCSITypeFromString(disk->driverName); if (model < 0) { VMX_ERROR(VIR_ERR_INTERNAL_ERROR, @@ -1068,7 +1068,7 @@ virVMXHandleLegacySCSIDiskDriverName(virDomainDefPtr def, VMX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Inconsistent SCSI controller model ('%s' is not '%s') " "for SCSI controller index %d"), disk->driverName, - virDomainControllerModelTypeToString(controller->model), + virDomainControllerModelSCSITypeToString(controller->model), controller->idx); return -1; } @@ -1120,7 +1120,7 @@ virVMXGatherSCSIControllers(virVMXContext *ctx, virDomainDefPtr def, continue; } - if (controller->model == VIR_DOMAIN_CONTROLLER_MODEL_AUTO && + if (controller->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO && ctx->autodetectSCSIControllerModel != NULL) { count = 0; @@ -1157,15 +1157,15 @@ virVMXGatherSCSIControllers(virVMXContext *ctx, virDomainDefPtr def, } if (controller->model != -1 && - controller->model != VIR_DOMAIN_CONTROLLER_MODEL_BUSLOGIC && - controller->model != VIR_DOMAIN_CONTROLLER_MODEL_LSILOGIC && - controller->model != VIR_DOMAIN_CONTROLLER_MODEL_LSISAS1068 && - controller->model != VIR_DOMAIN_CONTROLLER_MODEL_VMPVSCSI) { + controller->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC && + controller->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC && + controller->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068 && + controller->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI) { VMX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Expecting domain XML attribute 'model' of entry " "'controller' to be 'buslogic' or 'lsilogic' or " "'lsisas1068' or 'vmpvscsi' but found '%s'"), - virDomainControllerModelTypeToString(controller->model)); + virDomainControllerModelSCSITypeToString(controller->model)); goto cleanup; } @@ -1869,13 +1869,13 @@ virVMXParseSCSIController(virConfPtr conf, int controller, bool *present, *tmp = c_tolower(*tmp); } - *virtualDev = virVMXSCSIControllerModelTypeFromString(virtualDev_string); + *virtualDev = virVMXControllerModelSCSITypeFromString(virtualDev_string); if (*virtualDev == -1 || - (*virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_BUSLOGIC && - *virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_LSILOGIC && - *virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_LSISAS1068 && - *virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_VMPVSCSI)) { + (*virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC && + *virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC && + *virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068 && + *virtualDev != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI)) { VMX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Expecting VMX entry '%s' to be 'buslogic' or 'lsilogic' " "or 'lsisas1068' or 'pvscsi' but found '%s'"), @@ -3088,7 +3088,7 @@ virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps, virDomainDefPtr def, if (scsi_virtualDev[i] != -1) { virBufferAsprintf(&buffer, "scsi%d.virtualDev = \"%s\"\n", i, - virVMXSCSIControllerModelTypeToString + virVMXControllerModelSCSITypeToString (scsi_virtualDev[i])); } } diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 439ddc81059f346509525fc40ea0d6a18180700b..77b1611b9b4fb39beaf56540c589be31e2d64760 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -143,7 +143,7 @@ static int testAutodetectSCSIControllerModel(virDomainDiskDefPtr def ATTRIBUTE_UNUSED, int *model, void *opaque ATTRIBUTE_UNUSED) { - *model = VIR_DOMAIN_CONTROLLER_MODEL_LSILOGIC; + *model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC; return 0; }