From 552bf13f45a646a38aeb243871930cb0c9d29dfb Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 10 Mar 2016 15:34:37 +0100 Subject: [PATCH] qemu: monitor: Drop qemuMonitorAttachDrive and leaves in call tree Functions no longer required for attaching SCSI disks since QEMU_CAPS_DEVICE is expected. --- src/qemu/qemu_monitor.c | 16 ------ src/qemu/qemu_monitor.h | 6 --- src/qemu/qemu_monitor_text.c | 98 ------------------------------------ src/qemu/qemu_monitor_text.h | 5 -- 4 files changed, 125 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 96bb9cfbed..ffc792007c 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2782,22 +2782,6 @@ qemuMonitorAttachPCIDiskController(qemuMonitorPtr mon, } -int -qemuMonitorAttachDrive(qemuMonitorPtr mon, - const char *drivestr, - virDevicePCIAddress *controllerAddr, - virDomainDeviceDriveAddress *driveAddr) -{ - VIR_DEBUG("drivestr=%s domain=%d bus=%d slot=%d function=%d", - drivestr, controllerAddr->domain, controllerAddr->bus, - controllerAddr->slot, controllerAddr->function); - - QEMU_CHECK_MONITOR_JSON(mon); - - return qemuMonitorTextAttachDrive(mon, drivestr, controllerAddr, driveAddr); -} - - int qemuMonitorGetAllPCIAddresses(qemuMonitorPtr mon, qemuMonitorPCIAddress **addrs) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index c6e391cf7b..79063619e7 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -674,12 +674,6 @@ int qemuMonitorAttachPCIDiskController(qemuMonitorPtr mon, const char *bus, virDevicePCIAddress *guestAddr); -int qemuMonitorAttachDrive(qemuMonitorPtr mon, - const char *drivestr, - virDevicePCIAddress *controllerAddr, - virDomainDeviceDriveAddress *driveAddr); - - typedef struct _qemuMonitorPCIAddress qemuMonitorPCIAddress; struct _qemuMonitorPCIAddress { unsigned int vendor; diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 3129427f48..ea3cbf0233 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -2210,104 +2210,6 @@ int qemuMonitorTextAttachPCIDiskController(qemuMonitorPtr mon, } -static int -qemuParseDriveAddReply(const char *reply, - virDomainDeviceDriveAddressPtr addr) -{ - char *s, *e; - - /* If the command succeeds qemu prints: - * OK bus X, unit Y - */ - - if (!(s = strstr(reply, "OK "))) - return -1; - - s += 3; - - if (STRPREFIX(s, "bus ")) { - s += strlen("bus "); - - if (virStrToLong_ui(s, &e, 10, &addr->bus) == -1) { - VIR_WARN("Unable to parse bus '%s'", s); - return -1; - } - - if (!STRPREFIX(e, ", ")) { - VIR_WARN("Expected ', ' parsing drive_add reply '%s'", s); - return -1; - } - s = e + 2; - } - - if (!STRPREFIX(s, "unit ")) { - VIR_WARN("Expected 'unit ' parsing drive_add reply '%s'", s); - return -1; - } - s += strlen("bus "); - - if (virStrToLong_ui(s, &e, 10, &addr->unit) == -1) { - VIR_WARN("Unable to parse unit number '%s'", s); - return -1; - } - - return 0; -} - - -int qemuMonitorTextAttachDrive(qemuMonitorPtr mon, - const char *drivestr, - virDevicePCIAddress *controllerAddr, - virDomainDeviceDriveAddress *driveAddr) -{ - char *cmd = NULL; - char *reply = NULL; - int ret = -1; - char *safe_str; - bool tryOldSyntax = false; - - safe_str = qemuMonitorEscapeArg(drivestr); - if (!safe_str) - return -1; - - try_command: - if (virAsprintf(&cmd, "drive_add %s%.2x:%.2x:%.2x %s", - (tryOldSyntax ? "" : "pci_addr="), - controllerAddr->domain, controllerAddr->bus, - controllerAddr->slot, safe_str) < 0) - goto cleanup; - - if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) - goto cleanup; - - if (strstr(reply, "unknown command:")) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("drive hotplug is not supported")); - goto cleanup; - } - - if (qemuParseDriveAddReply(reply, driveAddr) < 0) { - if (!tryOldSyntax && strstr(reply, "invalid char in expression")) { - VIR_FREE(reply); - VIR_FREE(cmd); - tryOldSyntax = true; - goto try_command; - } - virReportError(VIR_ERR_OPERATION_FAILED, - _("adding %s disk failed: %s"), drivestr, reply); - goto cleanup; - } - - ret = 0; - - cleanup: - VIR_FREE(cmd); - VIR_FREE(reply); - VIR_FREE(safe_str); - return ret; -} - - /* * The format we're after looks like this * diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h index 44a53308ac..287a8518b9 100644 --- a/src/qemu/qemu_monitor_text.h +++ b/src/qemu/qemu_monitor_text.h @@ -173,11 +173,6 @@ int qemuMonitorTextAttachPCIDiskController(qemuMonitorPtr mon, const char *bus, virDevicePCIAddress *guestAddr); -int qemuMonitorTextAttachDrive(qemuMonitorPtr mon, - const char *drivestr, - virDevicePCIAddress *controllerAddr, - virDomainDeviceDriveAddress *driveAddr); - int qemuMonitorTextGetAllPCIAddresses(qemuMonitorPtr mon, qemuMonitorPCIAddress **addrs); -- GitLab