Re: [v2 02/13] Split virDomainControllerModel to virDomainControllerModelSCSI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 26, 2011 at 01:44:18AM +0300, Marc-André Lureau wrote:
> ---
>  src/conf/domain_conf.c   |   26 +++++++++++++++++++++++---
>  src/conf/domain_conf.h   |   18 ++++++++++--------
>  src/esx/esx_driver.c     |    8 ++++----
>  src/libvirt_private.syms |    4 ++--
>  src/vmx/vmx.c            |   32 ++++++++++++++++----------------
>  tests/xml2vmxtest.c      |    2 +-
>  6 files changed, 56 insertions(+), 34 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index ce1f3c5..5e91d54 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -195,7 +195,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",
> @@ -2455,6 +2455,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
>   */
> @@ -2492,7 +2502,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;
> @@ -8733,6 +8743,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,
> @@ -8748,7 +8768,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 2cc9b06..8a4cd11 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -257,14 +257,16 @@ 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_SCSI_LAST
> +};
>  
> -    VIR_DOMAIN_CONTROLLER_MODEL_LAST
>  };
>  
>  typedef struct _virDomainVirtioSerialOpts virDomainVirtioSerialOpts;
> @@ -1673,7 +1675,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 c097651..e603399 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 acae122..91ecd7b 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 08c2716..dff3599 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 439ddc8..77b1611 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;
>  }

ACK


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]