]> xenbits.xensource.com Git - libvirt.git/commitdiff
vz: move prlsdkCheckDiskUnsupportedParams to vz_utils.c
authorMaxim Nestratov <mnestratov@virtuozzo.com>
Wed, 16 Mar 2016 11:55:27 +0000 (14:55 +0300)
committerMaxim Nestratov <mnestratov@virtuozzo.com>
Wed, 16 Mar 2016 16:34:27 +0000 (19:34 +0300)
As long as we have another function checking disk parameters correctness,
let's have them in one place. Here we change prefix of the moved function and
start to call it from vzCheckUnsupportedDisks rather than add disk.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
src/vz/vz_sdk.c
src/vz/vz_utils.c

index bac8feb841c9d61f80056baadab59e5f8e062330..d11e29f8ba6d83c25ab454e10336ab8f0072fd49 100644 (file)
@@ -2410,126 +2410,6 @@ static int prlsdkCheckNetUnsupportedParams(virDomainNetDefPtr net)
     return 0;
 }
 
-static int prlsdkCheckDiskUnsupportedParams(virDomainDiskDefPtr disk)
-{
-    if (disk->device != VIR_DOMAIN_DISK_DEVICE_DISK &&
-        disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM) {
-
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Only hard disks and cdroms are supported "
-                         "by vz driver."));
-        return -1;
-    }
-
-    if (disk->blockio.logical_block_size ||
-        disk->blockio.physical_block_size) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Setting disk block sizes is not "
-                         "supported by vz driver."));
-        return -1;
-    }
-
-    if (disk->blkdeviotune.total_bytes_sec ||
-        disk->blkdeviotune.read_bytes_sec ||
-        disk->blkdeviotune.write_bytes_sec ||
-        disk->blkdeviotune.total_iops_sec ||
-        disk->blkdeviotune.read_iops_sec ||
-        disk->blkdeviotune.write_iops_sec) {
-
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Setting disk io limits is not "
-                         "supported by vz driver yet."));
-        return -1;
-    }
-
-    if (disk->serial) {
-        VIR_INFO("%s", _("Setting disk serial number is not "
-                         "supported by vz driver."));
-    }
-
-    if (disk->wwn) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Setting disk wwn id is not "
-                         "supported by vz driver."));
-        return -1;
-    }
-
-    if (disk->vendor) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Setting disk vendor is not "
-                         "supported by vz driver."));
-        return -1;
-    }
-
-    if (disk->product) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Setting disk product id is not "
-                         "supported by vz driver."));
-        return -1;
-    }
-
-    if (disk->error_policy != VIR_DOMAIN_DISK_ERROR_POLICY_DEFAULT) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Setting disk error policy is not "
-                         "supported by vz driver."));
-        return -1;
-    }
-
-    if (disk->iomode) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Setting disk io mode is not "
-                         "supported by vz driver."));
-        return -1;
-    }
-
-    if (disk->copy_on_read) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Disk copy_on_read is not "
-                         "supported by vz driver."));
-        return -1;
-    }
-
-    if (disk->startupPolicy != VIR_DOMAIN_STARTUP_POLICY_DEFAULT) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Setting up disk startup policy is not "
-                         "supported by vz driver."));
-        return -1;
-    }
-
-    if (disk->transient) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Transient disks are not "
-                         "supported by vz driver."));
-        return -1;
-    }
-
-    if (disk->discard) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Setting up disk discard parameter is not "
-                         "supported by vz driver."));
-        return -1;
-    }
-
-    if (disk->iothread) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Setting up disk io thread # is not "
-                         "supported by vz driver."));
-        return -1;
-    }
-
-    if (disk->src->type != VIR_STORAGE_TYPE_FILE &&
-        disk->src->type != VIR_STORAGE_TYPE_BLOCK) {
-
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Only disk and block storage types are "
-                         "supported by vz driver."));
-        return -1;
-
-    }
-
-    return 0;
-}
-
 static int prlsdkCheckFSUnsupportedParams(virDomainFSDefPtr fs)
 {
     if (fs->type != VIR_DOMAIN_FS_TYPE_FILE) {
@@ -3120,9 +3000,6 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom,
     PRL_DEVICE_TYPE devType;
     char *dst = NULL;
 
-    if (prlsdkCheckDiskUnsupportedParams(disk) < 0)
-        return -1;
-
     if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK)
         devType = PDE_HARD_DISK;
     else
index f9498879b6533fe817e35d4d90892bbc50ae60d9..601c5573ddc89c609af461e88334939ea68fad6e 100644 (file)
 #include "vz_sdk.h"
 #include "virstring.h"
 #include "datatypes.h"
+#include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_PARALLELS
 #define PRLSRVCTL "prlsrvctl"
 
+VIR_LOG_INIT("parallels.utils");
+
 static virDomainDiskBus vz6DiskBuses[] = {VIR_DOMAIN_DISK_BUS_IDE,
                                           VIR_DOMAIN_DISK_BUS_SCSI,
                                           VIR_DOMAIN_DISK_BUS_SATA,
@@ -250,6 +253,127 @@ vzInitVersion(vzConnPtr privconn)
     return ret;
 }
 
+static int
+vzCheckDiskUnsupportedParams(virDomainDiskDefPtr disk)
+{
+    if (disk->device != VIR_DOMAIN_DISK_DEVICE_DISK &&
+        disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM) {
+
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Only hard disks and cdroms are supported "
+                         "by vz driver."));
+        return -1;
+    }
+
+    if (disk->blockio.logical_block_size ||
+        disk->blockio.physical_block_size) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Setting disk block sizes is not "
+                         "supported by vz driver."));
+        return -1;
+    }
+
+    if (disk->blkdeviotune.total_bytes_sec ||
+        disk->blkdeviotune.read_bytes_sec ||
+        disk->blkdeviotune.write_bytes_sec ||
+        disk->blkdeviotune.total_iops_sec ||
+        disk->blkdeviotune.read_iops_sec ||
+        disk->blkdeviotune.write_iops_sec) {
+
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Setting disk io limits is not "
+                         "supported by vz driver yet."));
+        return -1;
+    }
+
+    if (disk->serial) {
+        VIR_INFO("%s", _("Setting disk serial number is not "
+                         "supported by vz driver."));
+    }
+
+    if (disk->wwn) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Setting disk wwn id is not "
+                         "supported by vz driver."));
+        return -1;
+    }
+
+    if (disk->vendor) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Setting disk vendor is not "
+                         "supported by vz driver."));
+        return -1;
+    }
+
+    if (disk->product) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Setting disk product id is not "
+                         "supported by vz driver."));
+        return -1;
+    }
+
+    if (disk->error_policy != VIR_DOMAIN_DISK_ERROR_POLICY_DEFAULT) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Setting disk error policy is not "
+                         "supported by vz driver."));
+        return -1;
+    }
+
+    if (disk->iomode) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Setting disk io mode is not "
+                         "supported by vz driver."));
+        return -1;
+    }
+
+    if (disk->copy_on_read) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Disk copy_on_read is not "
+                         "supported by vz driver."));
+        return -1;
+    }
+
+    if (disk->startupPolicy != VIR_DOMAIN_STARTUP_POLICY_DEFAULT) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Setting up disk startup policy is not "
+                         "supported by vz driver."));
+        return -1;
+    }
+
+    if (disk->transient) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Transient disks are not "
+                         "supported by vz driver."));
+        return -1;
+    }
+
+    if (disk->discard) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Setting up disk discard parameter is not "
+                         "supported by vz driver."));
+        return -1;
+    }
+
+    if (disk->iothread) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Setting up disk io thread # is not "
+                         "supported by vz driver."));
+        return -1;
+    }
+
+    if (disk->src->type != VIR_STORAGE_TYPE_FILE &&
+        disk->src->type != VIR_STORAGE_TYPE_BLOCK) {
+
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Only disk and block storage types are "
+                         "supported by vz driver."));
+        return -1;
+
+    }
+
+    return 0;
+}
+
 int
 vzCheckUnsupportedDisks(virDomainDefPtr def, vzCapabilitiesPtr vzCaps)
 {
@@ -260,6 +384,10 @@ vzCheckUnsupportedDisks(virDomainDefPtr def, vzCapabilitiesPtr vzCaps)
 
     for (i = 0; i < def->ndisks; i++) {
         disk = def->disks[i];
+
+        if (vzCheckDiskUnsupportedParams(disk) < 0)
+            return -1;
+
         diskFormat = virDomainDiskGetFormat(disk);
         supported = true;
         if (disk->src->type == VIR_STORAGE_TYPE_FILE) {