[PATCH] qemu: improve error for failed JSON commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Only one error in qemu_monitor was already using the relatively
new OPERATION_UNSUPPORTED error, even though it is a better fit
for all of the messages related to options that are unsupported
due to the version of qemu in use rather than due to a user's
XML or .conf file choice.  Suggested by Osier Yang.

* src/qemu/qemu_monitor.c (qemuMonitorSendFileHandle)
(qemuMonitorAddHostNetwork, qemuMonitorRemoveHostNetwork)
(qemuMonitorAttachDrive, qemuMonitorDiskSnapshot)
(qemuMonitorDriveMirror, qemuMonitorTransaction)
(qemuMonitorBlockCommit, qemuMonitorDrivePivot)
(qemuMonitorBlockJob, qemuMonitorSystemWakeup)
(qemuMonitorGetVersion, qemuMonitorGetMachines)
(qemuMonitorGetCPUDefinitions, qemuMonitorGetCommands)
(qemuMonitorGetEvents, qemuMonitorGetKVMState)
(qemuMonitorGetObjectTypes, qemuMonitorGetObjectProps)
(qemuMonitorGetTargetArch): Use better error category.
---
 src/qemu/qemu_monitor.c |   40 ++++++++++++++++++++--------------------
 1 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 066e420..5ad6c15 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2316,7 +2316,7 @@ int qemuMonitorSendFileHandle(qemuMonitorPtr mon,
     }

     if (!mon->hasSendFD) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
                        _("qemu is not using a unix socket monitor, "
                          "cannot send fd %s"), fdname);
         return -1;
@@ -2387,7 +2387,7 @@ int qemuMonitorAddHostNetwork(qemuMonitorPtr mon,
     }

     if (mon->json)
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("JSON monitor should be using AddNetdev"));
     else
         ret = qemuMonitorTextAddHostNetwork(mon, netstr);
@@ -2419,7 +2419,7 @@ int qemuMonitorRemoveHostNetwork(qemuMonitorPtr mon,
     }

     if (mon->json)
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("JSON monitor should be using RemoveNetdev"));
     else
         ret = qemuMonitorTextRemoveHostNetwork(mon, vlan, netname);
@@ -2550,7 +2550,7 @@ int qemuMonitorAttachDrive(qemuMonitorPtr mon,
     }

     if (mon->json)
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("JSON monitor should be using AddDrive"));
     else
         ret = qemuMonitorTextAttachDrive(mon, drivestr, controllerAddr, driveAddr);
@@ -2773,7 +2773,7 @@ qemuMonitorDiskSnapshot(qemuMonitorPtr mon, virJSONValuePtr actions,
         ret = qemuMonitorJSONDiskSnapshot(mon, actions, device, file, format,
                                           reuse);
     else
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("disk snapshot requires JSON monitor"));
     return ret;
 }
@@ -2806,7 +2806,7 @@ qemuMonitorDriveMirror(qemuMonitorPtr mon,
         ret = qemuMonitorJSONDriveMirror(mon, device, file, format, speed,
                                          flags);
     else
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("drive-mirror requires JSON monitor"));
     return ret;
 }
@@ -2822,7 +2822,7 @@ qemuMonitorTransaction(qemuMonitorPtr mon, virJSONValuePtr actions)
     if (mon->json)
         ret = qemuMonitorJSONTransaction(mon, actions);
     else
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("transaction requires JSON monitor"));
     return ret;
 }
@@ -2852,7 +2852,7 @@ qemuMonitorBlockCommit(qemuMonitorPtr mon, const char *device,
     if (mon->json)
         ret = qemuMonitorJSONBlockCommit(mon, device, top, base, speed);
     else
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("block-commit requires JSON monitor"));
     return ret;
 }
@@ -2871,7 +2871,7 @@ qemuMonitorDrivePivot(qemuMonitorPtr mon, const char *device,
     if (mon->json)
         ret = qemuMonitorJSONDrivePivot(mon, device, file, format);
     else
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("drive pivot requires JSON monitor"));
     return ret;
 }
@@ -2973,7 +2973,7 @@ int qemuMonitorBlockJob(qemuMonitorPtr mon,
         ret = qemuMonitorJSONBlockJob(mon, device, base, speed, info, mode,
                                       modern);
     else
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("block jobs require JSON monitor"));
     return ret;
 }
@@ -3105,7 +3105,7 @@ int qemuMonitorSystemWakeup(qemuMonitorPtr mon)
     }

     if (!mon->json) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("JSON monitor is required"));
         return -1;
     }
@@ -3129,7 +3129,7 @@ int qemuMonitorGetVersion(qemuMonitorPtr mon,
     }

     if (!mon->json) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("JSON monitor is required"));
         return -1;
     }
@@ -3150,7 +3150,7 @@ int qemuMonitorGetMachines(qemuMonitorPtr mon,
     }

     if (!mon->json) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("JSON monitor is required"));
         return -1;
     }
@@ -3180,7 +3180,7 @@ int qemuMonitorGetCPUDefinitions(qemuMonitorPtr mon,
     }

     if (!mon->json) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("JSON monitor is required"));
         return -1;
     }
@@ -3202,7 +3202,7 @@ int qemuMonitorGetCommands(qemuMonitorPtr mon,
     }

     if (!mon->json) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("JSON monitor is required"));
         return -1;
     }
@@ -3224,7 +3224,7 @@ int qemuMonitorGetEvents(qemuMonitorPtr mon,
     }

     if (!mon->json) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("JSON monitor is required"));
         return -1;
     }
@@ -3247,7 +3247,7 @@ int qemuMonitorGetKVMState(qemuMonitorPtr mon,
     }

     if (!mon->json) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("JSON monitor is required"));
         return -1;
     }
@@ -3269,7 +3269,7 @@ int qemuMonitorGetObjectTypes(qemuMonitorPtr mon,
     }

     if (!mon->json) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("JSON monitor is required"));
         return -1;
     }
@@ -3292,7 +3292,7 @@ int qemuMonitorGetObjectProps(qemuMonitorPtr mon,
     }

     if (!mon->json) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("JSON monitor is required"));
         return -1;
     }
@@ -3313,7 +3313,7 @@ char *qemuMonitorGetTargetArch(qemuMonitorPtr mon)
     }

     if (!mon->json) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                        _("JSON monitor is required"));
         return NULL;
     }
-- 
1.7.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]