From c01f4e9e5541ee3ce32f4c41612a794e6819796f Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 26 Apr 2016 13:45:15 +0200 Subject: [PATCH] qemu: monitor: Kill legacy USB monitor code Code was obsoleted by using -device. --- src/qemu/qemu_monitor.c | 47 ----------------- src/qemu/qemu_monitor.h | 14 ----- src/qemu/qemu_monitor_json.c | 29 ----------- src/qemu/qemu_monitor_json.h | 11 ---- src/qemu/qemu_monitor_text.c | 99 ------------------------------------ src/qemu/qemu_monitor_text.h | 11 ---- 6 files changed, 211 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index fe8e89f45e..2ec4222946 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2404,53 +2404,6 @@ qemuMonitorGraphicsRelocate(qemuMonitorPtr mon, } -int -qemuMonitorAddUSBDisk(qemuMonitorPtr mon, - const char *path) -{ - VIR_DEBUG("path=%s", path); - - QEMU_CHECK_MONITOR(mon); - - if (mon->json) - return qemuMonitorJSONAddUSBDisk(mon, path); - else - return qemuMonitorTextAddUSBDisk(mon, path); -} - - -int -qemuMonitorAddUSBDeviceExact(qemuMonitorPtr mon, - int bus, - int dev) -{ - VIR_DEBUG("bus=%d dev=%d", bus, dev); - - QEMU_CHECK_MONITOR(mon); - - if (mon->json) - return qemuMonitorJSONAddUSBDeviceExact(mon, bus, dev); - else - return qemuMonitorTextAddUSBDeviceExact(mon, bus, dev); -} - - -int -qemuMonitorAddUSBDeviceMatch(qemuMonitorPtr mon, - int vendor, - int product) -{ - VIR_DEBUG("vendor=%d product=%d", vendor, product); - - QEMU_CHECK_MONITOR(mon); - - if (mon->json) - return qemuMonitorJSONAddUSBDeviceMatch(mon, vendor, product); - else - return qemuMonitorTextAddUSBDeviceMatch(mon, vendor, product); -} - - int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon, virDevicePCIAddress *hostAddr, diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 470c7292b3..7825781891 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -628,20 +628,6 @@ int qemuMonitorGraphicsRelocate(qemuMonitorPtr mon, int tlsPort, const char *tlsSubject); -/* XXX disk driver type eg, qcow/etc. - * XXX cache mode - */ -int qemuMonitorAddUSBDisk(qemuMonitorPtr mon, - const char *path); - -int qemuMonitorAddUSBDeviceExact(qemuMonitorPtr mon, - int bus, - int dev); -int qemuMonitorAddUSBDeviceMatch(qemuMonitorPtr mon, - int vendor, - int product); - - int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon, virDevicePCIAddress *hostAddr, virDevicePCIAddress *guestAddr); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 7bb99767c9..509254844c 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3032,35 +3032,6 @@ int qemuMonitorJSONGraphicsRelocate(qemuMonitorPtr mon, } -int qemuMonitorJSONAddUSBDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED, - const char *path ATTRIBUTE_UNUSED) -{ - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("usb_add not supported in JSON mode")); - return -1; -} - - -int qemuMonitorJSONAddUSBDeviceExact(qemuMonitorPtr mon ATTRIBUTE_UNUSED, - int bus ATTRIBUTE_UNUSED, - int dev ATTRIBUTE_UNUSED) -{ - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("usb_add not supported in JSON mode")); - return -1; -} - - -int qemuMonitorJSONAddUSBDeviceMatch(qemuMonitorPtr mon ATTRIBUTE_UNUSED, - int vendor ATTRIBUTE_UNUSED, - int product ATTRIBUTE_UNUSED) -{ - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("usb_add not supported in JSON mode")); - return -1; -} - - int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon ATTRIBUTE_UNUSED, virDevicePCIAddress *hostAddr ATTRIBUTE_UNUSED, virDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 8b5d4220d0..81247f4cf9 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -169,17 +169,6 @@ int qemuMonitorJSONGraphicsRelocate(qemuMonitorPtr mon, int tlsPort, const char *tlsSubject); -int qemuMonitorJSONAddUSBDisk(qemuMonitorPtr mon, - const char *path); - -int qemuMonitorJSONAddUSBDeviceExact(qemuMonitorPtr mon, - int bus, - int dev); -int qemuMonitorJSONAddUSBDeviceMatch(qemuMonitorPtr mon, - int vendor, - int product); - - int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon, virDevicePCIAddress *hostAddr, virDevicePCIAddress *guestAddr); diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index ccae02f99c..707addcdfd 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -1572,105 +1572,6 @@ int qemuMonitorTextGraphicsRelocate(qemuMonitorPtr mon, } -int qemuMonitorTextAddUSBDisk(qemuMonitorPtr mon, - const char *path) -{ - char *cmd = NULL; - char *safepath; - int ret = -1; - char *info = NULL; - - safepath = qemuMonitorEscapeArg(path); - if (!safepath) - return -1; - - if (virAsprintf(&cmd, "usb_add disk:%s", safepath) < 0) - goto cleanup; - - if (qemuMonitorHMPCommand(mon, cmd, &info) < 0) - goto cleanup; - - /* If the command failed qemu prints: - * Could not add ... */ - if (strstr(info, "Could not add ")) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("unable to add USB disk %s: %s"), path, info); - goto cleanup; - } - - ret = 0; - - cleanup: - VIR_FREE(cmd); - VIR_FREE(safepath); - VIR_FREE(info); - return ret; -} - - -static int qemuMonitorTextAddUSBDevice(qemuMonitorPtr mon, - const char *addr) -{ - char *cmd; - char *reply = NULL; - int ret = -1; - - if (virAsprintf(&cmd, "usb_add %s", addr) < 0) - return -1; - - if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) - goto cleanup; - - /* If the command failed qemu prints: - * Could not add ... */ - if (strstr(reply, "Could not add ")) { - virReportError(VIR_ERR_OPERATION_FAILED, - "%s", _("adding usb device failed")); - goto cleanup; - } - - ret = 0; - - cleanup: - VIR_FREE(cmd); - VIR_FREE(reply); - return ret; -} - - -int qemuMonitorTextAddUSBDeviceExact(qemuMonitorPtr mon, - int bus, - int dev) -{ - int ret; - char *addr; - - if (virAsprintf(&addr, "host:%.3d.%.3d", bus, dev) < 0) - return -1; - - ret = qemuMonitorTextAddUSBDevice(mon, addr); - - VIR_FREE(addr); - return ret; -} - -int qemuMonitorTextAddUSBDeviceMatch(qemuMonitorPtr mon, - int vendor, - int product) -{ - int ret; - char *addr; - - if (virAsprintf(&addr, "host:%.4x:%.4x", vendor, product) < 0) - return -1; - - ret = qemuMonitorTextAddUSBDevice(mon, addr); - - VIR_FREE(addr); - return ret; -} - - static int qemuMonitorTextParsePCIAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED, const char *reply, diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h index 287a8518b9..d62e66815e 100644 --- a/src/qemu/qemu_monitor_text.h +++ b/src/qemu/qemu_monitor_text.h @@ -119,17 +119,6 @@ int qemuMonitorTextGraphicsRelocate(qemuMonitorPtr mon, int tlsPort, const char *tlsSubject); -int qemuMonitorTextAddUSBDisk(qemuMonitorPtr mon, - const char *path); - -int qemuMonitorTextAddUSBDeviceExact(qemuMonitorPtr mon, - int bus, - int dev); -int qemuMonitorTextAddUSBDeviceMatch(qemuMonitorPtr mon, - int vendor, - int product); - - int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon, virDevicePCIAddress *hostAddr, virDevicePCIAddress *guestAddr); -- GitLab