|
|
0a7476 |
From 9a33b0d475699d322f3e881c397143eed2dc9b3f Mon Sep 17 00:00:00 2001
|
|
|
0a7476 |
Message-Id: <9a33b0d475699d322f3e881c397143eed2dc9b3f@dist-git>
|
|
|
0a7476 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
0a7476 |
Date: Thu, 11 Apr 2019 15:14:19 -0400
|
|
|
0a7476 |
Subject: [PATCH] qemu_hotplug: Detach guestfwd using netdev_del
|
|
|
0a7476 |
|
|
|
0a7476 |
https://bugzilla.redhat.com/show_bug.cgi?id=1624204
|
|
|
0a7476 |
|
|
|
0a7476 |
The guestfwd channels are -netdevs really. Hotunplug them as
|
|
|
0a7476 |
such. Also, DEVICE_DELETED event is not triggered (surprisingly,
|
|
|
0a7476 |
since we're not issuing device_del rather than netdev_del) and
|
|
|
0a7476 |
associated chardev is removed automagically too. This means that
|
|
|
0a7476 |
we need to do qemuDomainRemoveChrDevice() minus monitor call to
|
|
|
0a7476 |
remove the chardev.
|
|
|
0a7476 |
|
|
|
0a7476 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
0a7476 |
Reviewed-by: John Ferlan <jferlan@redhat.com>
|
|
|
0a7476 |
(cherry picked from commit 112f3a8d0f324c0705326957cca4508602b25eba)
|
|
|
0a7476 |
|
|
|
0a7476 |
Partially-Resolves: https://bugzilla.redhat.com/1658198
|
|
|
0a7476 |
Signed-off-by: Laine Stump <laine@redhat.com>
|
|
|
0a7476 |
Signed-off-by: Laine Stump <laine@laine.org>
|
|
|
0a7476 |
Message-Id: <20190411191453.24055-8-laine@redhat.com>
|
|
|
0a7476 |
Acked-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
0a7476 |
---
|
|
|
0a7476 |
src/qemu/qemu_hotplug.c | 48 ++++++++++++++++++++++++++++-------------
|
|
|
0a7476 |
1 file changed, 33 insertions(+), 15 deletions(-)
|
|
|
0a7476 |
|
|
|
0a7476 |
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
|
|
0a7476 |
index 680c06c1ed..43dec329b6 100644
|
|
|
0a7476 |
--- a/src/qemu/qemu_hotplug.c
|
|
|
0a7476 |
+++ b/src/qemu/qemu_hotplug.c
|
|
|
0a7476 |
@@ -4214,25 +4214,28 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
|
|
|
0a7476 |
static int
|
|
|
0a7476 |
qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
|
|
|
0a7476 |
virDomainObjPtr vm,
|
|
|
0a7476 |
- virDomainChrDefPtr chr)
|
|
|
0a7476 |
+ virDomainChrDefPtr chr,
|
|
|
0a7476 |
+ bool monitor)
|
|
|
0a7476 |
{
|
|
|
0a7476 |
virObjectEventPtr event;
|
|
|
0a7476 |
char *charAlias = NULL;
|
|
|
0a7476 |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
0a7476 |
int ret = -1;
|
|
|
0a7476 |
- int rc;
|
|
|
0a7476 |
+ int rc = 0;
|
|
|
0a7476 |
|
|
|
0a7476 |
VIR_DEBUG("Removing character device %s from domain %p %s",
|
|
|
0a7476 |
chr->info.alias, vm, vm->def->name);
|
|
|
0a7476 |
|
|
|
0a7476 |
- if (!(charAlias = qemuAliasChardevFromDevAlias(chr->info.alias)))
|
|
|
0a7476 |
- goto cleanup;
|
|
|
0a7476 |
+ if (monitor) {
|
|
|
0a7476 |
+ if (!(charAlias = qemuAliasChardevFromDevAlias(chr->info.alias)))
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
|
|
|
0a7476 |
- qemuDomainObjEnterMonitor(driver, vm);
|
|
|
0a7476 |
- rc = qemuMonitorDetachCharDev(priv->mon, charAlias);
|
|
|
0a7476 |
+ qemuDomainObjEnterMonitor(driver, vm);
|
|
|
0a7476 |
+ rc = qemuMonitorDetachCharDev(priv->mon, charAlias);
|
|
|
0a7476 |
|
|
|
0a7476 |
- if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
0a7476 |
- goto cleanup;
|
|
|
0a7476 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
+ }
|
|
|
0a7476 |
|
|
|
0a7476 |
if (rc == 0 &&
|
|
|
0a7476 |
qemuDomainDelChardevTLSObjects(driver, vm, chr->source, charAlias) < 0)
|
|
|
0a7476 |
@@ -4526,7 +4529,7 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver,
|
|
|
0a7476 |
break;
|
|
|
0a7476 |
|
|
|
0a7476 |
case VIR_DOMAIN_DEVICE_CHR:
|
|
|
0a7476 |
- ret = qemuDomainRemoveChrDevice(driver, vm, dev->data.chr);
|
|
|
0a7476 |
+ ret = qemuDomainRemoveChrDevice(driver, vm, dev->data.chr, true);
|
|
|
0a7476 |
break;
|
|
|
0a7476 |
case VIR_DOMAIN_DEVICE_RNG:
|
|
|
0a7476 |
ret = qemuDomainRemoveRNGDevice(driver, vm, dev->data.rng);
|
|
|
0a7476 |
@@ -5590,6 +5593,7 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
|
|
|
0a7476 |
virDomainDefPtr vmdef = vm->def;
|
|
|
0a7476 |
virDomainChrDefPtr tmpChr;
|
|
|
0a7476 |
char *devstr = NULL;
|
|
|
0a7476 |
+ bool guestfwd = false;
|
|
|
0a7476 |
|
|
|
0a7476 |
if (!(tmpChr = virDomainChrFind(vmdef, chr))) {
|
|
|
0a7476 |
virReportError(VIR_ERR_DEVICE_MISSING,
|
|
|
0a7476 |
@@ -5599,6 +5603,11 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
|
|
|
0a7476 |
goto cleanup;
|
|
|
0a7476 |
}
|
|
|
0a7476 |
|
|
|
0a7476 |
+ /* guestfwd channels are not really -device rather than
|
|
|
0a7476 |
+ * -netdev. We need to treat them slightly differently. */
|
|
|
0a7476 |
+ guestfwd = tmpChr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
|
|
|
0a7476 |
+ tmpChr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
if (!tmpChr->info.alias && qemuAssignDeviceChrAlias(vmdef, tmpChr, -1) < 0)
|
|
|
0a7476 |
goto cleanup;
|
|
|
0a7476 |
|
|
|
0a7476 |
@@ -5607,22 +5616,31 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
|
|
|
0a7476 |
if (qemuBuildChrDeviceStr(&devstr, vmdef, tmpChr, priv->qemuCaps) < 0)
|
|
|
0a7476 |
goto cleanup;
|
|
|
0a7476 |
|
|
|
0a7476 |
- if (!async)
|
|
|
0a7476 |
+ if (!async && !guestfwd)
|
|
|
0a7476 |
qemuDomainMarkDeviceForRemoval(vm, &tmpChr->info);
|
|
|
0a7476 |
|
|
|
0a7476 |
qemuDomainObjEnterMonitor(driver, vm);
|
|
|
0a7476 |
- if (devstr && qemuMonitorDelDevice(priv->mon, tmpChr->info.alias) < 0) {
|
|
|
0a7476 |
- ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
|
|
0a7476 |
- goto cleanup;
|
|
|
0a7476 |
+ if (guestfwd) {
|
|
|
0a7476 |
+ if (qemuMonitorRemoveNetdev(priv->mon, tmpChr->info.alias) < 0) {
|
|
|
0a7476 |
+ ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
+ }
|
|
|
0a7476 |
+ } else {
|
|
|
0a7476 |
+ if (devstr && qemuMonitorDelDevice(priv->mon, tmpChr->info.alias) < 0) {
|
|
|
0a7476 |
+ ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
+ }
|
|
|
0a7476 |
}
|
|
|
0a7476 |
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
0a7476 |
goto cleanup;
|
|
|
0a7476 |
|
|
|
0a7476 |
- if (async) {
|
|
|
0a7476 |
+ if (guestfwd) {
|
|
|
0a7476 |
+ ret = qemuDomainRemoveChrDevice(driver, vm, tmpChr, false);
|
|
|
0a7476 |
+ } else if (async) {
|
|
|
0a7476 |
ret = 0;
|
|
|
0a7476 |
} else {
|
|
|
0a7476 |
if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
|
|
|
0a7476 |
- ret = qemuDomainRemoveChrDevice(driver, vm, tmpChr);
|
|
|
0a7476 |
+ ret = qemuDomainRemoveChrDevice(driver, vm, tmpChr, true);
|
|
|
0a7476 |
}
|
|
|
0a7476 |
|
|
|
0a7476 |
cleanup:
|
|
|
0a7476 |
--
|
|
|
0a7476 |
2.21.0
|
|
|
0a7476 |
|