From: Michal Privoznik <mprivozn@redhat.com>
Assigning device should happen from ch_hotplug.c (just like it's
done for disks currently) not in ch_process.c. Move alias
assignment out of chProcessAddNetworkDevice(). And while at it,
mimic what's done with disks and have net hotplug handling done
from a function.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
src/ch/ch_hotplug.c | 23 ++++++++++++++++++++---
src/ch/ch_process.c | 1 -
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/ch/ch_hotplug.c b/src/ch/ch_hotplug.c
index fabca2a73a..b296fd11b1 100644
--- a/src/ch/ch_hotplug.c
+++ b/src/ch/ch_hotplug.c
@@ -53,6 +53,25 @@ chDomainAddDisk(virCHMonitor *mon,
return 0;
}
+
+static int
+chDomainAddNet(virCHDriver *driver,
+ virCHMonitor *mon,
+ virDomainObj *vm,
+ virDomainNetDef *net)
+{
+ chAssignDeviceNetAlias(vm->def, net);
+
+ if (chProcessAddNetworkDevice(driver, mon, vm->def, net, NULL, NULL) < 0) {
+ return -1;
+ }
+
+ virDomainNetInsert(vm->def, net);
+
+ return 0;
+}
+
+
static int
chDomainAttachDeviceLive(virCHDriver *driver,
virDomainObj *vm,
@@ -75,12 +94,10 @@ chDomainAttachDeviceLive(virCHDriver *driver,
break;
case VIR_DOMAIN_DEVICE_NET:
- if (chProcessAddNetworkDevice(driver, mon, vm->def, dev->data.net,
- NULL, NULL) < 0) {
+ if (chDomainAddNet(driver, mon, vm, dev->data.net) < 0) {
break;
}
- virDomainNetInsert(vm->def, dev->data.net);
alias = dev->data.net->info.alias;
dev->data.net = NULL;
ret = 0;
diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c
index f16f2b3916..29db853a7f 100644
--- a/src/ch/ch_process.c
+++ b/src/ch/ch_process.c
@@ -685,7 +685,6 @@ chProcessAddNetworkDevice(virCHDriver *driver,
return -1;
}
- chAssignDeviceNetAlias(vmdef, net);
if (virCHMonitorBuildNetJson(net, &netJSONPayload) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to build net json"));
--
2.51.0