提交 64ed4d00 编写于 作者: P Peter Krempa

qemu: Suppress error reporting from qemuMonitorDelObject in cleanup paths

Many calls of qemuMonitorDelObject don't actually check the return value
or report the error from the object deletion itself since they are on
cleanup paths. In some cases this can lead to reporting of spurious
errors e.g. when qemuMonitorDelObject is used to clean up a possibly
pre-existing objects.

Add a new argument for qemuMonitorDelObject which controls whether
the internals report errors from qemu and fix all callers accordingly.

Note that some of the cases on device unplug which check the error code
don't in fact propagate the error to the user, but in this case it is
important to add the log entry anyways for tracing that the device
deletion failed.

https://bugzilla.redhat.com/show_bug.cgi?id=1784040Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 103bfbfd
...@@ -1732,19 +1732,19 @@ qemuBlockStorageSourceAttachRollback(qemuMonitorPtr mon, ...@@ -1732,19 +1732,19 @@ qemuBlockStorageSourceAttachRollback(qemuMonitorPtr mon,
ignore_value(qemuMonitorBlockdevDel(mon, data->storageNodeName)); ignore_value(qemuMonitorBlockdevDel(mon, data->storageNodeName));
if (data->prmgrAlias) if (data->prmgrAlias)
ignore_value(qemuMonitorDelObject(mon, data->prmgrAlias)); ignore_value(qemuMonitorDelObject(mon, data->prmgrAlias, false));
if (data->authsecretAlias) if (data->authsecretAlias)
ignore_value(qemuMonitorDelObject(mon, data->authsecretAlias)); ignore_value(qemuMonitorDelObject(mon, data->authsecretAlias, false));
if (data->encryptsecretAlias) if (data->encryptsecretAlias)
ignore_value(qemuMonitorDelObject(mon, data->encryptsecretAlias)); ignore_value(qemuMonitorDelObject(mon, data->encryptsecretAlias, false));
if (data->httpcookiesecretAlias) if (data->httpcookiesecretAlias)
ignore_value(qemuMonitorDelObject(mon, data->httpcookiesecretAlias)); ignore_value(qemuMonitorDelObject(mon, data->httpcookiesecretAlias, false));
if (data->tlsAlias) if (data->tlsAlias)
ignore_value(qemuMonitorDelObject(mon, data->tlsAlias)); ignore_value(qemuMonitorDelObject(mon, data->tlsAlias, false));
virErrorRestore(&orig_err); virErrorRestore(&orig_err);
......
...@@ -6047,7 +6047,7 @@ qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver, ...@@ -6047,7 +6047,7 @@ qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver,
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
rc = qemuMonitorDelObject(priv->mon, alias); rc = qemuMonitorDelObject(priv->mon, alias, true);
exp_niothreads--; exp_niothreads--;
if (rc < 0) if (rc < 0)
goto exit_monitor; goto exit_monitor;
......
...@@ -390,7 +390,8 @@ qemuHotplugRemoveManagedPR(virQEMUDriverPtr driver, ...@@ -390,7 +390,8 @@ qemuHotplugRemoveManagedPR(virQEMUDriverPtr driver,
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
goto cleanup; goto cleanup;
ignore_value(qemuMonitorDelObject(priv->mon, qemuDomainGetManagedPRAlias())); ignore_value(qemuMonitorDelObject(priv->mon, qemuDomainGetManagedPRAlias(),
false));
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto cleanup; goto cleanup;
...@@ -471,7 +472,7 @@ qemuDomainDetachDBusVMState(virQEMUDriverPtr driver, ...@@ -471,7 +472,7 @@ qemuDomainDetachDBusVMState(virQEMUDriverPtr driver,
qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
return -1; return -1;
ret = qemuMonitorDelObject(priv->mon, alias); ret = qemuMonitorDelObject(priv->mon, alias, true);
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)
return -1; return -1;
...@@ -1685,10 +1686,10 @@ qemuDomainDelTLSObjects(virQEMUDriverPtr driver, ...@@ -1685,10 +1686,10 @@ qemuDomainDelTLSObjects(virQEMUDriverPtr driver,
goto cleanup; goto cleanup;
if (tlsAlias) if (tlsAlias)
ignore_value(qemuMonitorDelObject(priv->mon, tlsAlias)); ignore_value(qemuMonitorDelObject(priv->mon, tlsAlias, false));
if (secAlias) if (secAlias)
ignore_value(qemuMonitorDelObject(priv->mon, secAlias)); ignore_value(qemuMonitorDelObject(priv->mon, secAlias, false));
ignore_value(qemuDomainObjExitMonitor(driver, vm)); ignore_value(qemuDomainObjExitMonitor(driver, vm));
...@@ -1850,9 +1851,9 @@ qemuDomainDelChardevTLSObjects(virQEMUDriverPtr driver, ...@@ -1850,9 +1851,9 @@ qemuDomainDelChardevTLSObjects(virQEMUDriverPtr driver,
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
ignore_value(qemuMonitorDelObject(priv->mon, tlsAlias)); ignore_value(qemuMonitorDelObject(priv->mon, tlsAlias, false));
if (secAlias) if (secAlias)
ignore_value(qemuMonitorDelObject(priv->mon, secAlias)); ignore_value(qemuMonitorDelObject(priv->mon, secAlias, false));
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)
return -1; return -1;
...@@ -2307,7 +2308,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver, ...@@ -2307,7 +2308,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
exit_monitor: exit_monitor:
virErrorPreserveLast(&orig_err); virErrorPreserveLast(&orig_err);
if (objAlias) if (objAlias)
ignore_value(qemuMonitorDelObject(priv->mon, objAlias)); ignore_value(qemuMonitorDelObject(priv->mon, objAlias, false));
if (rng->backend == VIR_DOMAIN_RNG_BACKEND_EGD && chardevAdded) if (rng->backend == VIR_DOMAIN_RNG_BACKEND_EGD && chardevAdded)
ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias)); ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias));
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)
...@@ -2443,7 +2444,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, ...@@ -2443,7 +2444,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
exit_monitor: exit_monitor:
virErrorPreserveLast(&orig_err); virErrorPreserveLast(&orig_err);
if (objAdded) if (objAdded)
ignore_value(qemuMonitorDelObject(priv->mon, objalias)); ignore_value(qemuMonitorDelObject(priv->mon, objalias, false));
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)
mem = NULL; mem = NULL;
...@@ -2665,7 +2666,7 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver, ...@@ -2665,7 +2666,7 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver,
drvstr, devstr); drvstr, devstr);
} }
if (secobjAlias) if (secobjAlias)
ignore_value(qemuMonitorDelObject(priv->mon, secobjAlias)); ignore_value(qemuMonitorDelObject(priv->mon, secobjAlias, false));
ignore_value(qemuDomainObjExitMonitor(driver, vm)); ignore_value(qemuDomainObjExitMonitor(driver, vm));
virErrorRestore(&orig_err); virErrorRestore(&orig_err);
...@@ -3041,7 +3042,7 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver, ...@@ -3041,7 +3042,7 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver,
if (shmem->server.enabled) if (shmem->server.enabled)
ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias)); ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias));
else else
ignore_value(qemuMonitorDelObject(priv->mon, memAlias)); ignore_value(qemuMonitorDelObject(priv->mon, memAlias, false));
} }
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)
...@@ -4367,7 +4368,7 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver, ...@@ -4367,7 +4368,7 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
backendAlias = g_strdup_printf("mem%s", mem->info.alias); backendAlias = g_strdup_printf("mem%s", mem->info.alias);
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
rc = qemuMonitorDelObject(priv->mon, backendAlias); rc = qemuMonitorDelObject(priv->mon, backendAlias, true);
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)
rc = -1; rc = -1;
...@@ -4483,7 +4484,7 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver, ...@@ -4483,7 +4484,7 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
/* If it fails, then so be it - it was a best shot */ /* If it fails, then so be it - it was a best shot */
if (objAlias) if (objAlias)
ignore_value(qemuMonitorDelObject(priv->mon, objAlias)); ignore_value(qemuMonitorDelObject(priv->mon, objAlias, false));
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)
return -1; return -1;
...@@ -4741,7 +4742,7 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver, ...@@ -4741,7 +4742,7 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver,
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
if (rc == 0 && if (rc == 0 &&
qemuMonitorDelObject(priv->mon, objAlias) < 0) qemuMonitorDelObject(priv->mon, objAlias, true) < 0)
rc = -1; rc = -1;
if (rng->backend == VIR_DOMAIN_RNG_BACKEND_EGD && if (rng->backend == VIR_DOMAIN_RNG_BACKEND_EGD &&
...@@ -4802,7 +4803,7 @@ qemuDomainRemoveShmemDevice(virQEMUDriverPtr driver, ...@@ -4802,7 +4803,7 @@ qemuDomainRemoveShmemDevice(virQEMUDriverPtr driver,
if (shmem->server.enabled) if (shmem->server.enabled)
rc = qemuMonitorDetachCharDev(priv->mon, charAlias); rc = qemuMonitorDetachCharDev(priv->mon, charAlias);
else else
rc = qemuMonitorDelObject(priv->mon, memAlias); rc = qemuMonitorDelObject(priv->mon, memAlias, true);
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)
return -1; return -1;
......
...@@ -2966,13 +2966,14 @@ qemuMonitorAddObject(qemuMonitorPtr mon, ...@@ -2966,13 +2966,14 @@ qemuMonitorAddObject(qemuMonitorPtr mon,
int int
qemuMonitorDelObject(qemuMonitorPtr mon, qemuMonitorDelObject(qemuMonitorPtr mon,
const char *objalias) const char *objalias,
bool report_error)
{ {
VIR_DEBUG("objalias=%s", objalias); VIR_DEBUG("objalias=%s", objalias);
QEMU_CHECK_MONITOR(mon); QEMU_CHECK_MONITOR(mon);
return qemuMonitorJSONDelObject(mon, objalias); return qemuMonitorJSONDelObject(mon, objalias, report_error);
} }
......
...@@ -931,7 +931,8 @@ int qemuMonitorAddObject(qemuMonitorPtr mon, ...@@ -931,7 +931,8 @@ int qemuMonitorAddObject(qemuMonitorPtr mon,
ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(2);
int qemuMonitorDelObject(qemuMonitorPtr mon, int qemuMonitorDelObject(qemuMonitorPtr mon,
const char *objalias); const char *objalias,
bool report_error);
int qemuMonitorAddDrive(qemuMonitorPtr mon, int qemuMonitorAddDrive(qemuMonitorPtr mon,
const char *drivestr); const char *drivestr);
......
...@@ -4448,7 +4448,8 @@ qemuMonitorJSONAddObject(qemuMonitorPtr mon, ...@@ -4448,7 +4448,8 @@ qemuMonitorJSONAddObject(qemuMonitorPtr mon,
int int
qemuMonitorJSONDelObject(qemuMonitorPtr mon, qemuMonitorJSONDelObject(qemuMonitorPtr mon,
const char *objalias) const char *objalias,
bool report_error)
{ {
g_autoptr(virJSONValue) cmd = NULL; g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL; g_autoptr(virJSONValue) reply = NULL;
...@@ -4459,7 +4460,7 @@ qemuMonitorJSONDelObject(qemuMonitorPtr mon, ...@@ -4459,7 +4460,7 @@ qemuMonitorJSONDelObject(qemuMonitorPtr mon,
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
return -1; return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0) if (qemuMonitorJSONCheckErrorFull(cmd, reply, report_error) < 0)
return -1; return -1;
return 0; return 0;
......
...@@ -237,7 +237,8 @@ int qemuMonitorJSONAddObject(qemuMonitorPtr mon, ...@@ -237,7 +237,8 @@ int qemuMonitorJSONAddObject(qemuMonitorPtr mon,
virJSONValuePtr props); virJSONValuePtr props);
int qemuMonitorJSONDelObject(qemuMonitorPtr mon, int qemuMonitorJSONDelObject(qemuMonitorPtr mon,
const char *objalias); const char *objalias,
bool report_error);
int qemuMonitorJSONTransaction(qemuMonitorPtr mon, virJSONValuePtr *actions) int qemuMonitorJSONTransaction(qemuMonitorPtr mon, virJSONValuePtr *actions)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册