Hi Lureau,
You say that hot-add failare is reasonable after hot-remove? I think it is a 
clear issue.


>Hi

On Sat, Nov 6, 2021 at 10:41 PM ???????????? <787738...@qq.com&gt; wrote:
&gt;
&gt; We have found that qemu cannot plug in the previously unplugged device.
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; start qemu with the 
following command:
&gt; ./qemu-system-x86_64 -enable-kvm -m 8192 -smp 16 \
&gt;&nbsp;&nbsp;&nbsp; -object 
memory-backend-file,id=mem,size=8192M,mem-path=/dev/hugepages,share=on \
&gt;&nbsp;&nbsp;&nbsp; -numa node,memdev=mem -mem-prealloc \
&gt;&nbsp;&nbsp;&nbsp; ...
&gt;&nbsp;&nbsp;&nbsp; -chardev 
socket,id=drive-virtio-disk1,path=/var/run/spdk/vhost_blk_socket-30dcf467-486a-45cf-b754-093bf5cf24d1,reconnect=10
 \
&gt;&nbsp;&nbsp;&nbsp; -device 
vhost-user-blk-pci,chardev=drive-virtio-disk1,num-queues=1,bus=pci.0,addr=0x5,id=virtio-disk1
 \
&gt;&nbsp;&nbsp;&nbsp; ...
&gt;
&gt; (qemu) info chardev
&gt; serial0: filename=pty:/dev/pts/0
&gt; drive-virtio-disk1: filename=unix:
&gt; charmonitor:
&gt; 
filename=unix:/usr/local/var/lib/libvirt/qemu/domain-55-e59039db-d576-40db-a/monitor.sock,server
&gt; (qemu) device_del virtio-disk1
&gt; (qemu) chardev-remove drive-virtio-disk1
&gt; (qemu) info chardev
&gt; serial0: filename=pty:/dev/pts/0
&gt; charmonitor:
&gt; 
filename=unix:/usr/local/var/lib/libvirt/qemu/domain-55-e59039db-d576-40db-a/monitor.sock,server
&gt; (qemu) chardev-add 
socket,id=drive-virtio-disk1,path=/var/run/spdk/vhost_blk_socket-30dcf467-486a-45cf-b754-093bf5cf24d1,reconnect=10
&gt; device failed: Duplicate ID 'drive-virtio-disk1' for chardev Error: 
Parsing chardev args failed
&gt;
&gt; The root cause of this issue is that the QemuOpts is still reserved in 
vm_config_groups list,
&gt; so qemu_opts_create will fail with the error above. So the QemuOpts should 
be removed when
&gt; invoking qmp_chardev_remove.
&gt;
&gt;
&gt; Signed-off-by: Zhoujian Yu <win...@tencent.com&gt;
&gt; Reviewed-by: Lei Wang <kaierw...@tencent.com&gt;
&gt; Reviewed-by: Xun Ni <richar...@tencent.com&gt;
&gt; Reviewed-by: Zhigang Lu <tonn...@tencent.com&gt;
&gt; ---
&gt;&nbsp; chardev/char.c | 6 ++++++
&gt;&nbsp; 1 file changed, 6 insertions(+)
&gt;
&gt; diff --git a/chardev/char.c b/chardev/char.c
&gt; index 398f09d..d2087bd 100644
&gt; --- a/chardev/char.c
&gt; +++ b/chardev/char.c
&gt; @@ -37,6 +37,7 @@
&gt;&nbsp; #include "qemu/help_option.h"
&gt;&nbsp; #include "qemu/module.h"
&gt;&nbsp; #include "qemu/option.h"
&gt; +#include "qemu/option_int.h"
&gt;&nbsp; #include "qemu/id.h"
&gt;&nbsp; #include "qemu/coroutine.h"
&gt;&nbsp; #include "qemu/yank.h"
&gt; @@ -1159,6 +1160,7 @@ ChardevReturn *qmp_chardev_change(const char *id, 
ChardevBackend *backend,
&gt;&nbsp; void qmp_chardev_remove(const char *id, Error **errp)
&gt;&nbsp; {
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Chardev *chr;
&gt; +&nbsp;&nbsp; QemuOpts *opts;
&gt;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chr = qemu_chr_find(id);
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (chr == NULL) {
&gt; @@ -1175,6 +1177,10 @@ void qmp_chardev_remove(const char *id, Error 
**errp)
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object_unparent(OBJECT(chr));
&gt; +&nbsp;&nbsp;&nbsp; /* delete the opts reserved in vm_config_groups 
list.&nbsp; */
&gt; +&nbsp;&nbsp;&nbsp; opts = qemu_opts_find(qemu_find_opts("chardev"), id);
&gt; +&nbsp;&nbsp;&nbsp; if (opts)
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; qemu_opts_del(opts);

That seems reasonable to me,
Reviewed-by: Marc-Andr?? Lureau <marcandre.lur...@redhat.com&gt;

&gt;&nbsp; }
&gt;
&gt;&nbsp; void qmp_chardev_send_break(const char *id, Error **errp)
&gt; --
&gt; 1.8.3.1

Reply via email to