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

[libvirt] [PATCH v4 10/13] parallels: add function parallelsGetDiskBusName



Add function for convertion bus from libvirt's numeric constant
to a name, used in a parallels command-line tools.

Signed-off-by: Dmitry Guryanov <dguryanov parallels com>
---
 src/parallels/parallels_driver.c |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index fe91968..967f545 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -76,6 +76,19 @@
 
 static int parallelsClose(virConnectPtr conn);
 
+const char * parallelsGetDiskBusName(int bus) {
+    switch (bus) {
+    case VIR_DOMAIN_DISK_BUS_IDE:
+        return "ide";
+    case VIR_DOMAIN_DISK_BUS_SATA:
+        return "sata";
+    case VIR_DOMAIN_DISK_BUS_SCSI:
+        return "scsi";
+    default:
+        return NULL;
+    }
+}
+
 void
 parallelsDriverLock(parallelsConnPtr driver)
 {
@@ -1529,17 +1542,12 @@ parallelsApplyDisksParams(parallelsDomObjPtr pdom,
             strpos[15] = '\0';
             snprintf(strpos, 15, "%d", newdisk->info.addr.drive.target);
 
-            switch (newdisk->bus) {
-            case VIR_DOMAIN_DISK_BUS_IDE:
-                strbus = "ide";
-                break;
-            case VIR_DOMAIN_DISK_BUS_SATA:
-                strbus = "sata";
-                break;
-            case VIR_DOMAIN_DISK_BUS_SCSI:
-                strbus = "scsi";
-                break;
+            if (!(strbus = parallelsGetDiskBusName(newdisk->bus))) {
+                virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
+                               _("Unsupported disk bus: %d", newdisk->bus));
+                return -1;
             }
+
             if (parallelsCmdRun(PRLCTL, "set", pdom->uuid,
                                 "--device-set", prlname,
                                 "--iface", strbus,
-- 
1.7.7.6


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