Add function for conversion bus from libvirt's numeric constant
to a name, used in a parallels command-line tools.
Signed-off-by: Dmitry Guryanov <dguryanov(a)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 21850d3..e2ffb48 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)
{
@@ -1526,17 +1539,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.1