Hi, The following is the current code to release connection in libvirt. int virConnectClose(virConnectPtr
conn) { …
if (!VIR_IS_CONNECT(conn)) { virLibConnError(VIR_ERR_INVALID_CONN,
__FUNCTION__);
goto error; } … error: virDispatchError(NULL);
return ret; } Now if the cable is unplugged and the application call virConnectClose to release connection, the code will enter into the error procedure, the connection Can’t be released. I have changed the following two parts to fix this issue. Please give your comments: Changed Code1: int virConnectClose(virConnectPtr conn) { … + if(NULL == conn) { + return 0; + } … - if (!VIR_IS_CONNECT(conn)) { - virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__); - goto error; - } … error: virDispatchError(NULL); return ret; } Changed Code2: int virUnrefConnect(virConnectPtr conn) { … + if(NULL == conn) { + return 0; + } - if ((!VIR_IS_CONNECT(conn))) { - virLibConnError(VIR_ERR_INVALID_ARG, _("no connection")); - return -1; - } … } For libvirt java, there are similar issue. I have changed code as following in Collect.java. Please also give your comments. public int close() throws LibvirtException { int success = 0; if (VCP != null) { + try { success = libvirt.virConnectClose(VCP); processError(); + } + finally { // If leave an invalid pointer dangling around JVM crashes and burns // if someone tries to call a method on us // We rely on the underlying libvirt error handling to detect that // it's called with a null virConnectPointer VCP = null;
+ } } return success; } B.R. Benjamin Wang |
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list