提交 149fa591 编写于 作者: E Eric Blake

qemu: improve error for failed JSON commands

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.
上级 3bef4adf
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册