<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><br><div><br><blockquote type="cite"><div>2024年3月21日 17:57,Haoqian He <haoqian.he@smartx.com> 写道:</div><br class="Apple-interchange-newline"><div><div>We should cleanup vq resubmit info when set_inflight_fd<br>before set_vring_kick which will check if there is any<br>inflight io waiting for resubmission.<br><br>Otherwise, when the vm is rebooting immediately after<br>reconnecting to the vhost target (inflight io has not<br>been resubmitted yet), the vhost backend still use the<br>old resubmit info set when reconnection.<br><br>Signed-off-by: Haoqian He <haoqian.he@smartx.com><br>---<br> lib/vhost/vhost_user.c | 1 +<br> 1 file changed, 1 insertion(+)<br><br>diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c<br>index 414192500e..7c54afc5fb 100644<br>--- a/lib/vhost/vhost_user.c<br>+++ b/lib/vhost/vhost_user.c<br>@@ -1871,6 +1871,7 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev,<br> <span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">    </span>if (!vq)<br> <span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span>continue;<br><br>+<span class="Apple-tab-span" style="white-space:pre">      </span><span class="Apple-tab-span" style="white-space:pre">    </span>cleanup_vq_inflight(dev, vq);<br> <span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span>if (vq_is_packed(dev)) {<br> <span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span>vq->inflight_packed = addr;<br> <span class="Apple-tab-span" style="white-space:pre">   </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span>vq->inflight_packed->desc_num = queue_size;<br>-- <br>2.41.0<br><br></div></div></blockquote></div><br><div>Ping.</div><div><br></div><div>Hi, Maxime.</div><div><br></div><div>This patch fix the potential error when VM reboot after vhost live recovery which</div><div>could lead to the VM hang as missing resubmit info cleanup.</div><div><br></div><div>If inflight io that should be resubmitted during the latest vhost reconnection has</div><div>not been submitted yet, so GET_VRING_BASE would not wait these inflight io,</div><div>at this time the resubmit info has been set and restart the VM <span style="font-size: 13px; orphans: 2; white-space: pre-wrap; widows: 2;">immediately.</span></div><div><br></div><div>Currently, we do not cleanup the resubmit info before VM restart, so when VM</div><div>restarts, SET_VRING_KICK will resubmit these inflight io (If resubmit info is not</div><div>null, function set_vring_kick will return without updating resubmit info).</div><div><br></div><div>It’s an error, any stale inflight io should not be resubmitted after the VM restart.</div><div><br></div><div>Thanks,</div><div>Haoqian</div><div><br></div><div><br></div><div><br></div><div> </div><div><br></div><div><br></div></body></html>