From 8631bdc0c82e1182a51a6877c0dbf3926431aa44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Fri, 2 Sep 2011 21:06:15 +0800 Subject: [PATCH] Rename virDomainControllerModel to virDomainControllerModelSCSI Since we are about to add USB controller support let's remove the ambiguity --- src/conf/domain_conf.c | 26 +++++++++++++++++++++++--- src/conf/domain_conf.h | 16 ++++++++-------- src/esx/esx_driver.c | 8 ++++---- src/libvirt_private.syms | 4 ++-- src/vmx/vmx.c | 32 ++++++++++++++++---------------- tests/xml2vmxtest.c | 2 +- 6 files changed, 54 insertions(+), 34 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a2de8df18a..a8b7d8392f 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 0abb75e3d1..39bb999cc6 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 c097651a0b..e6033994e5 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 9f03e30d86..c2ce32f022 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 08c2716c6b..dff3599403 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 439ddc8105..77b1611b9b 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; } -- GitLab