mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-31 22:17:17 +00:00
qemu_hotplug: Detach guestfwd using netdev_del
https://bugzilla.redhat.com/show_bug.cgi?id=1624204 The guestfwd channels are -netdevs really. Hotunplug them as such. Also, DEVICE_DELETED event is not triggered (surprisingly, since we're not issuing device_del rather than netdev_del) and associated chardev is removed automagically too. This means that we need to do qemuDomainRemoveChrDevice() minus monitor call to remove the chardev. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
903315dc8f
commit
112f3a8d0f
@ -4742,17 +4742,19 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
|
|||||||
static int
|
static int
|
||||||
qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
|
qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
virDomainChrDefPtr chr)
|
virDomainChrDefPtr chr,
|
||||||
|
bool monitor)
|
||||||
{
|
{
|
||||||
virObjectEventPtr event;
|
virObjectEventPtr event;
|
||||||
char *charAlias = NULL;
|
char *charAlias = NULL;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int rc;
|
int rc = 0;
|
||||||
|
|
||||||
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 (monitor) {
|
||||||
if (!(charAlias = qemuAliasChardevFromDevAlias(chr->info.alias)))
|
if (!(charAlias = qemuAliasChardevFromDevAlias(chr->info.alias)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -4761,6 +4763,7 @@ qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (rc == 0 &&
|
if (rc == 0 &&
|
||||||
qemuDomainDelChardevTLSObjects(driver, vm, chr->source, charAlias) < 0)
|
qemuDomainDelChardevTLSObjects(driver, vm, chr->source, charAlias) < 0)
|
||||||
@ -5064,7 +5067,7 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DEVICE_CHR:
|
case VIR_DOMAIN_DEVICE_CHR:
|
||||||
ret = qemuDomainRemoveChrDevice(driver, vm, dev->data.chr);
|
ret = qemuDomainRemoveChrDevice(driver, vm, dev->data.chr, true);
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_DEVICE_RNG:
|
case VIR_DOMAIN_DEVICE_RNG:
|
||||||
ret = qemuDomainRemoveRNGDevice(driver, vm, dev->data.rng);
|
ret = qemuDomainRemoveRNGDevice(driver, vm, dev->data.rng);
|
||||||
@ -6127,6 +6130,7 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainDefPtr vmdef = vm->def;
|
virDomainDefPtr vmdef = vm->def;
|
||||||
virDomainChrDefPtr tmpChr;
|
virDomainChrDefPtr tmpChr;
|
||||||
char *devstr = NULL;
|
char *devstr = NULL;
|
||||||
|
bool guestfwd = false;
|
||||||
|
|
||||||
if (!(tmpChr = virDomainChrFind(vmdef, chr))) {
|
if (!(tmpChr = virDomainChrFind(vmdef, chr))) {
|
||||||
virReportError(VIR_ERR_DEVICE_MISSING,
|
virReportError(VIR_ERR_DEVICE_MISSING,
|
||||||
@ -6136,6 +6140,11 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* guestfwd channels are not really -device rather than
|
||||||
|
* -netdev. We need to treat them slightly differently. */
|
||||||
|
guestfwd = tmpChr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
|
||||||
|
tmpChr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD;
|
||||||
|
|
||||||
if (!tmpChr->info.alias && qemuAssignDeviceChrAlias(vmdef, tmpChr, -1) < 0)
|
if (!tmpChr->info.alias && qemuAssignDeviceChrAlias(vmdef, tmpChr, -1) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -6144,22 +6153,31 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
|
|||||||
if (qemuBuildChrDeviceStr(&devstr, vmdef, tmpChr, priv->qemuCaps) < 0)
|
if (qemuBuildChrDeviceStr(&devstr, vmdef, tmpChr, priv->qemuCaps) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!async)
|
if (!async && !guestfwd)
|
||||||
qemuDomainMarkDeviceForRemoval(vm, &tmpChr->info);
|
qemuDomainMarkDeviceForRemoval(vm, &tmpChr->info);
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
|
if (guestfwd) {
|
||||||
|
if (qemuMonitorRemoveNetdev(priv->mon, tmpChr->info.alias) < 0) {
|
||||||
|
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (devstr && qemuMonitorDelDevice(priv->mon, tmpChr->info.alias) < 0) {
|
if (devstr && qemuMonitorDelDevice(priv->mon, tmpChr->info.alias) < 0) {
|
||||||
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (async) {
|
if (guestfwd) {
|
||||||
|
ret = qemuDomainRemoveChrDevice(driver, vm, tmpChr, false);
|
||||||
|
} else if (async) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
|
if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
|
||||||
ret = qemuDomainRemoveChrDevice(driver, vm, tmpChr);
|
ret = qemuDomainRemoveChrDevice(driver, vm, tmpChr, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
Loading…
Reference in New Issue
Block a user