On 06/03/14 10:22, Jiri Denemark wrote: > In general, we should only remove a backend after seeing DEVICE_DELETED > event for a corresponding frontend. > > Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> > --- > > Notes: > Version 2: > - return int and propagate errors > > src/qemu/qemu_hotplug.c | 33 ++++++++++++++++++++------------- > 1 file changed, 20 insertions(+), 13 deletions(-) > > diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c > index 35099e4..fde46ad 100644 > --- a/src/qemu/qemu_hotplug.c > +++ b/src/qemu/qemu_hotplug.c > @@ -2742,22 +2742,38 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver, > } > > > -static void > +static int > qemuDomainRemoveChrDevice(virQEMUDriverPtr driver, > virDomainObjPtr vm, > virDomainChrDefPtr chr) > { > virObjectEventPtr event; > + char *charAlias = NULL; > + qemuDomainObjPrivatePtr priv = vm->privateData; > > VIR_DEBUG("Removing character device %s from domain %p %s", > chr->info.alias, vm, vm->def->name); > > + if (virAsprintf(&charAlias, "char%s", chr->info.alias) < 0) > + return -1; > + > + qemuDomainObjEnterMonitor(driver, vm); > + if (qemuMonitorDetachCharDev(priv->mon, charAlias) < 0) { > + qemuDomainObjExitMonitor(driver, vm); > + goto cleanup; You will return 0 even if qemuMonitorDetachCharDev fails which wouldn't happen before as qemuDomainDetachChrDevice initializes ret to -1. I think you need to add the "ret" variable to this function too. > + } > + qemuDomainObjExitMonitor(driver, vm); > + > event = virDomainEventDeviceRemovedNewFromObj(vm, chr->info.alias); > if (event) > qemuDomainEventQueue(driver, event); > > qemuDomainChrRemove(vm->def, chr); > virDomainChrDefFree(chr); > + > + cleanup: > + VIR_FREE(charAlias); > + return 0; > } ACK if you correctly propagate errors from qemuMonitorDetachCharDev. Peter
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list