From 9f7d9891f0ae2c04970bba39fae59e3418bb0a5c Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 11 Mar 2016 16:33:03 +0100 Subject: [PATCH] qemu: monitor: Remove JSON impls of drive_add and drive_del qemu won't ever add those functions directly to QMP. They will be replaced with 'blockdev-add' and 'blockdev-del' eventually. At this time there's no need to keep the stubs around. Additionally the drive_del stub in JSON contained dead code in the attempt to report errors. (VIR_ERR_OPERATION_UNSUPPORTED was never reported). Since the text impl does have the same message it is reported anyways. --- src/qemu/qemu_monitor.c | 19 +++++++++++-------- src/qemu/qemu_monitor_json.c | 29 ----------------------------- src/qemu/qemu_monitor_json.h | 6 ------ src/qemu/qemu_monitor_text.c | 4 +--- 4 files changed, 12 insertions(+), 46 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index ffc792007c..10a6713c06 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2797,6 +2797,13 @@ qemuMonitorGetAllPCIAddresses(qemuMonitorPtr mon, } +/** + * qemuMonitorDriveDel: + * @mon: monitor object + * @drivestr: identifier of drive to delete. + * + * Attempts to remove a host drive. + * Returns 1 if unsupported, 0 if ok, and -1 on other failure */ int qemuMonitorDriveDel(qemuMonitorPtr mon, const char *drivestr) @@ -2805,10 +2812,8 @@ qemuMonitorDriveDel(qemuMonitorPtr mon, QEMU_CHECK_MONITOR(mon); - if (mon->json) - return qemuMonitorJSONDriveDel(mon, drivestr); - else - return qemuMonitorTextDriveDel(mon, drivestr); + /* there won't be a direct replacement for drive_del in QMP */ + return qemuMonitorTextDriveDel(mon, drivestr); } @@ -2911,10 +2916,8 @@ qemuMonitorAddDrive(qemuMonitorPtr mon, QEMU_CHECK_MONITOR(mon); - if (mon->json) - return qemuMonitorJSONAddDrive(mon, drivestr); - else - return qemuMonitorTextAddDrive(mon, drivestr); + /* there won't ever be a direct QMP replacement for this function */ + return qemuMonitorTextAddDrive(mon, drivestr); } diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 57c34f0b16..e140d0eeb0 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3583,35 +3583,6 @@ int qemuMonitorJSONDelObject(qemuMonitorPtr mon, } -int qemuMonitorJSONAddDrive(qemuMonitorPtr mon, - const char *drivestr) -{ - /* XXX Update to use QMP, if QMP ever adds support for drive_add */ - VIR_DEBUG("drive_add command not found, trying HMP"); - return qemuMonitorTextAddDrive(mon, drivestr); -} - - -int qemuMonitorJSONDriveDel(qemuMonitorPtr mon, - const char *drivestr) -{ - int ret; - - /* XXX Update to use QMP, if QMP ever adds support for drive_del */ - VIR_DEBUG("drive_del command not found, trying HMP"); - if ((ret = qemuMonitorTextDriveDel(mon, drivestr)) < 0) { - virErrorPtr err = virGetLastError(); - if (err && err->code == VIR_ERR_OPERATION_UNSUPPORTED) { - VIR_ERROR("%s", - _("deleting disk is not supported. " - "This may leak data if disk is reassigned")); - ret = 1; - virResetLastError(); - } - } - return ret; -} - int qemuMonitorJSONSetDrivePassphrase(qemuMonitorPtr mon, const char *alias, const char *passphrase) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 486e660a7a..d155f52e5a 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -230,12 +230,6 @@ int qemuMonitorJSONAddObject(qemuMonitorPtr mon, int qemuMonitorJSONDelObject(qemuMonitorPtr mon, const char *objalias); -int qemuMonitorJSONAddDrive(qemuMonitorPtr mon, - const char *drivestr); - -int qemuMonitorJSONDriveDel(qemuMonitorPtr mon, - const char *drivestr); - int qemuMonitorJSONSetDrivePassphrase(qemuMonitorPtr mon, const char *alias, const char *passphrase); diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index ea3cbf0233..ccae02f99c 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -2454,8 +2454,7 @@ int qemuMonitorTextAddDrive(qemuMonitorPtr mon, return ret; } -/* Attempts to remove a host drive. - * Returns 1 if unsupported, 0 if ok, and -1 on other failure */ + int qemuMonitorTextDriveDel(qemuMonitorPtr mon, const char *drivestr) { @@ -2463,7 +2462,6 @@ int qemuMonitorTextDriveDel(qemuMonitorPtr mon, char *reply = NULL; char *safedev; int ret = -1; - VIR_DEBUG("TextDriveDel drivestr=%s", drivestr); if (!(safedev = qemuMonitorEscapeArg(drivestr))) goto cleanup; -- GitLab