mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
qemu: Remove character device backend only after frontend is gone
In general, we should only remove a backend after seeing DEVICE_DELETED event for a corresponding frontend. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
0635785b6e
commit
55b21f9b23
@ -2742,22 +2742,40 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static int
|
||||||
qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
|
qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
virDomainChrDefPtr chr)
|
virDomainChrDefPtr chr)
|
||||||
{
|
{
|
||||||
virObjectEventPtr event;
|
virObjectEventPtr event;
|
||||||
|
char *charAlias = NULL;
|
||||||
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
VIR_DEBUG("Removing character device %s from domain %p %s",
|
VIR_DEBUG("Removing character device %s from domain %p %s",
|
||||||
chr->info.alias, vm, vm->def->name);
|
chr->info.alias, vm, vm->def->name);
|
||||||
|
|
||||||
|
if (virAsprintf(&charAlias, "char%s", chr->info.alias) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
|
if (qemuMonitorDetachCharDev(priv->mon, charAlias) < 0) {
|
||||||
|
qemuDomainObjExitMonitor(driver, vm);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
qemuDomainObjExitMonitor(driver, vm);
|
||||||
|
|
||||||
event = virDomainEventDeviceRemovedNewFromObj(vm, chr->info.alias);
|
event = virDomainEventDeviceRemovedNewFromObj(vm, chr->info.alias);
|
||||||
if (event)
|
if (event)
|
||||||
qemuDomainEventQueue(driver, event);
|
qemuDomainEventQueue(driver, event);
|
||||||
|
|
||||||
qemuDomainChrRemove(vm->def, chr);
|
qemuDomainChrRemove(vm->def, chr);
|
||||||
virDomainChrDefFree(chr);
|
virDomainChrDefFree(chr);
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(charAlias);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3596,7 +3614,6 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
|
|||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virDomainDefPtr vmdef = vm->def;
|
virDomainDefPtr vmdef = vm->def;
|
||||||
virDomainChrDefPtr tmpChr;
|
virDomainChrDefPtr tmpChr;
|
||||||
char *charAlias = NULL;
|
|
||||||
char *devstr = NULL;
|
char *devstr = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@ -3609,9 +3626,6 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
|
|||||||
if (qemuBuildChrDeviceStr(&devstr, vm->def, chr, priv->qemuCaps) < 0)
|
if (qemuBuildChrDeviceStr(&devstr, vm->def, chr, priv->qemuCaps) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (virAsprintf(&charAlias, "char%s", tmpChr->info.alias) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
qemuDomainMarkDeviceForRemoval(vm, &tmpChr->info);
|
qemuDomainMarkDeviceForRemoval(vm, &tmpChr->info);
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
@ -3619,21 +3633,16 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
|
|||||||
qemuDomainObjExitMonitor(driver, vm);
|
qemuDomainObjExitMonitor(driver, vm);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuMonitorDetachCharDev(priv->mon, charAlias) < 0) {
|
|
||||||
qemuDomainObjExitMonitor(driver, vm);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
qemuDomainObjExitMonitor(driver, vm);
|
qemuDomainObjExitMonitor(driver, vm);
|
||||||
|
|
||||||
rc = qemuDomainWaitForDeviceRemoval(vm);
|
rc = qemuDomainWaitForDeviceRemoval(vm);
|
||||||
if (rc == 0 || rc == 1)
|
if (rc == 0 || rc == 1)
|
||||||
qemuDomainRemoveChrDevice(driver, vm, tmpChr);
|
ret = qemuDomainRemoveChrDevice(driver, vm, tmpChr);
|
||||||
ret = 0;
|
else
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
qemuDomainResetDeviceRemoval(vm);
|
qemuDomainResetDeviceRemoval(vm);
|
||||||
VIR_FREE(devstr);
|
VIR_FREE(devstr);
|
||||||
VIR_FREE(charAlias);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user