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@xxxxxxxxxxxxx> --- 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 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list