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

[libvirt] [PATCH v2 6/7] vz: check supported controllers



From: Mikhail Feoktistov <mfeoktistov virtuozzo com>

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>
---
 src/vz/vz_driver.c |  3 +++
 src/vz/vz_utils.c  | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/vz/vz_utils.h  |  5 +++++
 3 files changed, 56 insertions(+)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 4f52bc7..74e1f5d 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -180,6 +180,9 @@ vzDomainDefPostParse(virDomainDefPtr def ATTRIBUTE_UNUSED,
     if (vzCheckUnsupportedDisks(def, opaque) < 0)
         return -1;
 
+    if (vzCheckUnsupportedControllers(def, opaque) < 0)
+        return -1;
+
     return 0;
 }
 
diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c
index b616103..a0fdc6c 100644
--- a/src/vz/vz_utils.c
+++ b/src/vz/vz_utils.c
@@ -45,6 +45,15 @@ static virDomainDiskBus vz7DiskBuses[] = {VIR_DOMAIN_DISK_BUS_IDE,
                                           VIR_DOMAIN_DISK_BUS_SCSI,
                                           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:
  * @domain: Domain pointer that has to be looked up
@@ -196,10 +205,14 @@ vzInitCaps(unsigned long vzVersion, vzCapabilities *vzCaps)
         vzCaps->ctDiskFormat = VIR_STORAGE_FILE_PLOOP;
         vzCaps->vmDiskFormat = VIR_STORAGE_FILE_PLOOP;
         vzCaps->diskBuses = vz6DiskBuses;
+        vzCaps->controllerTypes = vz6ControllerTypes;
+        vzCaps->scsiControllerModel = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC;
     } else {
         vzCaps->ctDiskFormat = VIR_STORAGE_FILE_PLOOP;
         vzCaps->vmDiskFormat = VIR_STORAGE_FILE_QCOW2;
         vzCaps->diskBuses = vz7DiskBuses;
+        vzCaps->controllerTypes = vz7ControllerTypes;
+        vzCaps->scsiControllerModel = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI;
     }
 }
 
@@ -424,3 +437,38 @@ vzCheckUnsupportedDisks(virDomainDefPtr def, vzCapabilitiesPtr vzCaps)
     }
     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;
+}
diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h
index 851322f..88e74fc 100644
--- a/src/vz/vz_utils.h
+++ b/src/vz/vz_utils.h
@@ -54,6 +54,8 @@ struct _vzCapabilities {
     virStorageFileFormat vmDiskFormat;
     virStorageFileFormat ctDiskFormat;
     virDomainDiskBus *diskBuses;
+    virDomainControllerType *controllerTypes;
+    virDomainControllerModelSCSI scsiControllerModel;
 };
 typedef struct _vzCapabilities vzCapabilities;
 typedef struct _vzCapabilities *vzCapabilitiesPtr;
@@ -113,6 +115,9 @@ vzInitVersion(vzConnPtr privconn);
 int
 vzCheckUnsupportedDisks(virDomainDefPtr def,
                         vzCapabilitiesPtr vzCaps);
+int
+vzCheckUnsupportedControllers(virDomainDefPtr def,
+                              vzCapabilitiesPtr vzCaps);
 
 # define PARALLELS_BLOCK_STATS_FOREACH(OP)                              \
     OP(rd_req, VIR_DOMAIN_BLOCK_STATS_READ_REQ, "read_requests")        \
-- 
2.4.3


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