
On 12/14/2017 06:16 AM, Chen Hanxiao wrote:
From: Chen Hanxiao <chenhanxiao@gmail.com>
Some services, such as Nova, check whether device was not found by errror messages "not found". [1]
error
This patch unify logs of qemuDomainDetachDeviceLive, which will be helpful.
[1] https://github.com/openstack/nova/blob/master/nova/virt/libvirt/guest.py#L40...
Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com> --- src/qemu/qemu_hotplug.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
Something about a tool that parses the error message(s) looking for a specific message string in English and needing to alter libvirt sources to match that tools' needs strikes me as incorrect and a "slippery slope" to follow. I'm not in favor of this because we'll be constantly chasing these types of bugs to match some other tools' (what I think is) incorrect means to handle errors. John
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d97aa6051..925574b92 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5093,7 +5093,7 @@ qemuDomainDetachShmemDevice(virQEMUDriverPtr driver,
if ((idx = virDomainShmemDefFind(vm->def, dev)) < 0) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("device not present in domain configuration")); + _("device not found in domain configuration")); return -1; }
@@ -5150,7 +5150,7 @@ qemuDomainDetachWatchdog(virQEMUDriverPtr driver, watchdog->action == dev->action && virDomainDeviceInfoAddressIsEqual(&dev->info, &watchdog->info))) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("watchdog device not present in domain configuration")); + _("watchdog device not found in domain configuration")); return -1; }
@@ -5233,8 +5233,11 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver, virDomainNetDefPtr detach = NULL; qemuDomainObjPrivatePtr priv = vm->privateData;
- if ((detachidx = virDomainNetFindIdx(vm->def, dev->data.net)) < 0) + if ((detachidx = virDomainNetFindIdx(vm->def, dev->data.net)) < 0) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("netdev %s not found"), dev->data.net->mac.addr); goto cleanup; + }
detach = vm->def->nets[detachidx];
@@ -5420,8 +5423,9 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver, char *devstr = NULL;
if (!(tmpChr = virDomainChrFind(vmdef, chr))) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("device not present in domain configuration")); + virReportError(VIR_ERR_OPERATION_INVALID, + _("device %s not found in domain configuration"), + chr->target.name); goto cleanup; }
@@ -5468,7 +5472,7 @@ qemuDomainDetachRNGDevice(virQEMUDriverPtr driver,
if ((idx = virDomainRNGFind(vm->def, rng)) < 0) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("device not present in domain configuration")); + _("device not found in domain configuration")); return -1; }
@@ -5511,7 +5515,7 @@ qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver,
if ((idx = virDomainMemoryFindByDef(vm->def, memdef)) < 0) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("device not present in domain configuration")); + _("device not found in domain configuration")); return -1; }