[libvirt] [PATCH] vhost-user: no need to remove chardev when remove netdev

linzhecheng linzhecheng at huawei.com
Mon Dec 18 09:43:00 UTC 2017


We use virsh detach-device to hot-unplug a vhost-user net card,
and libvirtd will issue qmp_netdev_del, qmp_chardev_remove and
qmp_netdev_del. However, in qmp_netdev_del, qemu will remove
the chardev when cleanup the netdev. So libvirtd has no need to issue
qmp_chardev_remove to qemu any more.

Change-Id: I4883c17bbb8dce088406f6a8a9ca4e02612d21f4

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 7de04c85a..c4787dd60 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -4014,7 +4014,6 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
     qemuDomainObjPrivatePtr priv = vm->privateData;
     virObjectEventPtr event;
     char *hostnet_name = NULL;
-    char *charDevAlias = NULL;
     size_t i;
     int ret = -1;
     int actualType = virDomainNetGetActualType(net);
@@ -4029,8 +4028,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
     VIR_DEBUG("Removing network interface %s from domain %p %s",
               net->info.alias, vm, vm->def->name);
 
-    if (virAsprintf(&hostnet_name, "host%s", net->info.alias) < 0 ||
-        !(charDevAlias = qemuAliasChardevFromDevAlias(net->info.alias)))
+    if (virAsprintf(&hostnet_name, "host%s", net->info.alias) < 0)
         goto cleanup;
 
 
@@ -4057,15 +4055,6 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
         }
     }
 
-    if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
-        /* vhostuser has a chardev too */
-        if (qemuMonitorDetachCharDev(priv->mon, charDevAlias) < 0) {
-            /* well, this is a messy situation. Guest visible PCI device has
-             * been removed, netdev too but chardev not. The best seems to be
-             * to just ignore the error and carry on.
-             */
-        }
-    }
 
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         goto cleanup;
@@ -4108,7 +4097,6 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
 
  cleanup:
     virObjectUnref(cfg);
-    VIR_FREE(charDevAlias);
     VIR_FREE(hostnet_name);
     return ret;
 }
-- 
2.12.2.windows.2





More information about the libvir-list mailing list