<div dir="ltr">Hi Peter,<div><br></div><div>Thank you for pointing that out, I will track the issue on that bug instead.<br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><br></div><font color="#666666">Yalan</font></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 8, 2022 at 3:58 PM Peter Krempa <<a href="mailto:pkrempa@redhat.com">pkrempa@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, Sep 08, 2022 at 15:16:56 +0800, Yalan Zhang wrote:<br>
> Hi Laine,<br>
> <br>
> As for the hot-unplug behavior, I have one more question about it, could<br>
> you please help to confirm?<br>
> <br>
> unplugging a PCI device properly requires cooperation from the guest OS.<br>
> > If the guest OS isn't running yet, the unplug won't complete, so qemu<br>
> > (and libvirt) still show the device as plugged into the guest.<br>
> ><br>
> > virsh reports success on the unplug because unplugging a device is done<br>
> > asynchronously - the "success" means "libvirt successfully told qemu to<br>
> > unplug the device, qemu has told the virtual machine to unplug the<br>
> > device, and is waiting for acknowledgment from the virtual machine that<br>
> > the guest has completed removal". At some later time the guest OS may<br>
> > complete its part of the unplug; when that happens, qemu will get a<br>
> > notification and will send an event to libvirt - at that time the device<br>
> > will be removed from libvirt's list of devices.<br>
> ><br>
> > tl;dr - this is all expected.<br>
> ><br>
> <br>
> The question is that, when I unplug it during boot, the virsh cmd will<br>
> succeed but the interface still exists, which is expected.<br>
> After the vm boot successfully, the guest OS will *not* complete this<br>
> removal. When I tried to detach it again, it reported that the device was<br>
> in the process of unplugging.<br>
> Is this acceptable?<br>
> <br>
> # virsh detach-interface rhel_new network 52:54:00:36:a8:d4<br>
> Interface detached successfully<br>
> # virsh domiflist rhel_new<br>
>  Interface   Type      Source    Model    MAC<br>
> -------------------------------------------------------------<br>
>  vnet4       network   default   virtio   52:54:00:36:a8:d4<br>
> <br>
> # virsh detach-interface rhel_new network 52:54:00:36:a8:d4<br>
> error: Failed to detach interface<br>
> error: internal error: unable to execute QEMU command 'device_del': Device<br>
> net0 is already in the process of unplug<br>
<br>
The same problem was already reported for disks:<br>
<br>
<a href="https://bugzilla.redhat.com/show_bug.cgi?id=2087047" rel="noreferrer" target="_blank">https://bugzilla.redhat.com/show_bug.cgi?id=2087047</a><br>
<br>
<a href="https://gitlab.com/libvirt/libvirt/-/issues/309" rel="noreferrer" target="_blank">https://gitlab.com/libvirt/libvirt/-/issues/309</a><br>
<br>
The main problem is that qemu doesn't re-send the request to unplug the<br>
device and rather reprots an eroror. At the same time the guest OS<br>
doesn't notice it any more, so the unplug can't be finished until the VM<br>
is rebooted.<br>
<br>
</blockquote></div>