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

Re: [libvirt] [PATCH 5/6] vz: check supported controllers



15.03.2016 10:47, Mikhail Feoktistov пишет:
Virtuozzo6 supports only SCSI(BUSLOGIC) IDE and SATA controllers.
Virtuozzo7 supports only SCSI(VIRTIO_SCSI) and IDE.
In this patch we add list of supported controllers and scsi models to vzCapabilities structure.
In openConnection() callback we get virtuozzo version and select proper capabilities values.
In XMLPostParse phase we check controller type and SCSI model.
---
  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 bf62538..58014ec 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;
      }
  }
@@ -301,3 +314,38 @@ int vzCheckUnsupportedDisks(virDomainDefPtr def,
      }
      return 0;
  }
+
+int vzCheckUnsupportedControllers(virDomainDefPtr def,
+                                 vzCapabilitiesPtr vzCaps)

int
vzCheckUnsupportedControllers(virDomainDefPtr def, vzCapabilitiesPtr vzCaps)

declaration would comply with both line lenght and other function declaration style

+{
+    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")        \


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