vz: check supported controllers

Because Vz6 supports SCSI(BUSLOGIC), IDE and SATA controllers only and
Vz7 supports SCSI(VIRTIO_SCSI) and IDE only we add list of supported
controllers and scsi models to vzCapabilities structure.
When a new  connection opens, we select proper capabilities values according
to Virtuozzo version and check them in XMLPostParse.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
This commit is contained in:
Mikhail Feoktistov 2016-03-15 10:47:50 +03:00 committed by Maxim Nestratov
parent 1de787b065
commit 97841dd9e6
3 changed files with 56 additions and 0 deletions

View File

@ -180,6 +180,9 @@ vzDomainDefPostParse(virDomainDefPtr def ATTRIBUTE_UNUSED,
if (vzCheckUnsupportedDisks(def, opaque) < 0) if (vzCheckUnsupportedDisks(def, opaque) < 0)
return -1; return -1;
if (vzCheckUnsupportedControllers(def, opaque) < 0)
return -1;
return 0; return 0;
} }

View File

@ -48,6 +48,15 @@ static virDomainDiskBus vz7DiskBuses[] = {VIR_DOMAIN_DISK_BUS_IDE,
VIR_DOMAIN_DISK_BUS_SCSI, VIR_DOMAIN_DISK_BUS_SCSI,
VIR_DOMAIN_DISK_BUS_LAST}; VIR_DOMAIN_DISK_BUS_LAST};
static virDomainControllerType vz6ControllerTypes[] = {VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
VIR_DOMAIN_CONTROLLER_TYPE_IDE,
VIR_DOMAIN_CONTROLLER_TYPE_SATA,
VIR_DOMAIN_CONTROLLER_TYPE_LAST};
static virDomainControllerType vz7ControllerTypes[] = {VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
VIR_DOMAIN_CONTROLLER_TYPE_IDE,
VIR_DOMAIN_CONTROLLER_TYPE_LAST};
/** /**
* vzDomObjFromDomain: * vzDomObjFromDomain:
* @domain: Domain pointer that has to be looked up * @domain: Domain pointer that has to be looked up
@ -199,10 +208,14 @@ vzInitCaps(unsigned long vzVersion, vzCapabilities *vzCaps)
vzCaps->ctDiskFormat = VIR_STORAGE_FILE_PLOOP; vzCaps->ctDiskFormat = VIR_STORAGE_FILE_PLOOP;
vzCaps->vmDiskFormat = VIR_STORAGE_FILE_PLOOP; vzCaps->vmDiskFormat = VIR_STORAGE_FILE_PLOOP;
vzCaps->diskBuses = vz6DiskBuses; vzCaps->diskBuses = vz6DiskBuses;
vzCaps->controllerTypes = vz6ControllerTypes;
vzCaps->scsiControllerModel = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC;
} else { } else {
vzCaps->ctDiskFormat = VIR_STORAGE_FILE_PLOOP; vzCaps->ctDiskFormat = VIR_STORAGE_FILE_PLOOP;
vzCaps->vmDiskFormat = VIR_STORAGE_FILE_QCOW2; vzCaps->vmDiskFormat = VIR_STORAGE_FILE_QCOW2;
vzCaps->diskBuses = vz7DiskBuses; vzCaps->diskBuses = vz7DiskBuses;
vzCaps->controllerTypes = vz7ControllerTypes;
vzCaps->scsiControllerModel = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI;
} }
} }
@ -427,3 +440,38 @@ vzCheckUnsupportedDisks(virDomainDefPtr def, vzCapabilitiesPtr vzCaps)
} }
return 0; return 0;
} }
int
vzCheckUnsupportedControllers(virDomainDefPtr def, vzCapabilitiesPtr vzCaps)
{
size_t i, j;
virDomainControllerDefPtr controller;
for (i = 0; i < def->ncontrollers; i++) {
controller = def->controllers[i];
for (j = 0; vzCaps->controllerTypes[j] != VIR_DOMAIN_CONTROLLER_TYPE_LAST; j++) {
if (controller->type == vzCaps->controllerTypes[j])
break;
}
if (vzCaps->controllerTypes[j] == VIR_DOMAIN_CONTROLLER_TYPE_LAST) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported controller type %s"),
virDomainControllerTypeToString(controller->type));
return -1;
}
if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
controller->model != -1 &&
controller->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO &&
controller->model != vzCaps->scsiControllerModel) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported SCSI controller model %s"),
virDomainControllerModelSCSITypeToString(controller->model));
return -1;
}
}
return 0;
}

View File

@ -54,6 +54,8 @@ struct _vzCapabilities {
virStorageFileFormat vmDiskFormat; virStorageFileFormat vmDiskFormat;
virStorageFileFormat ctDiskFormat; virStorageFileFormat ctDiskFormat;
virDomainDiskBus *diskBuses; virDomainDiskBus *diskBuses;
virDomainControllerType *controllerTypes;
virDomainControllerModelSCSI scsiControllerModel;
}; };
typedef struct _vzCapabilities vzCapabilities; typedef struct _vzCapabilities vzCapabilities;
typedef struct _vzCapabilities *vzCapabilitiesPtr; typedef struct _vzCapabilities *vzCapabilitiesPtr;
@ -113,6 +115,9 @@ vzInitVersion(vzConnPtr privconn);
int int
vzCheckUnsupportedDisks(virDomainDefPtr def, vzCheckUnsupportedDisks(virDomainDefPtr def,
vzCapabilitiesPtr vzCaps); vzCapabilitiesPtr vzCaps);
int
vzCheckUnsupportedControllers(virDomainDefPtr def,
vzCapabilitiesPtr vzCaps);
# define PARALLELS_BLOCK_STATS_FOREACH(OP) \ # define PARALLELS_BLOCK_STATS_FOREACH(OP) \
OP(rd_req, VIR_DOMAIN_BLOCK_STATS_READ_REQ, "read_requests") \ OP(rd_req, VIR_DOMAIN_BLOCK_STATS_READ_REQ, "read_requests") \