qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Chardev: delete the QemuOpts reserved in vm_config_groups
@ 2021-11-06 10:23 =?gb18030?B?pNe357n9zt662z8/?=
  2021-11-08  8:46 ` Marc-André Lureau
  0 siblings, 1 reply; 6+ messages in thread
From: =?gb18030?B?pNe357n9zt662z8/?= @ 2021-11-06 10:23 UTC (permalink / raw)
  To: =?gb18030?B?bWFyY2FuZHJlLmx1cmVhdQ==?=, =?gb18030?B?cGJvbnppbmk=?=
  Cc: =?gb18030?B?cWVtdS1kZXZlbA==?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 3037 bytes --]

We have found that qemu cannot plug in the previously unplugged device.
        start qemu with the following command:
./qemu-system-x86_64 -enable-kvm -m 8192 -smp 16 \
   -object memory-backend-file,id=mem,size=8192M,mem-path=/dev/hugepages,share=on \
   -numa node,memdev=mem -mem-prealloc \
   ...
   -chardev socket,id=drive-virtio-disk1,path=/var/run/spdk/vhost_blk_socket-30dcf467-486a-45cf-b754-093bf5cf24d1,reconnect=10 \
   -device vhost-user-blk-pci,chardev=drive-virtio-disk1,num-queues=1,bus=pci.0,addr=0x5,id=virtio-disk1 \
   ...


(qemu) info chardev
serial0: filename=pty:/dev/pts/0
drive-virtio-disk1: filename=unix:
charmonitor:
filename=unix:/usr/local/var/lib/libvirt/qemu/domain-55-e59039db-d576-40db-a/monitor.sock,server
(qemu) device_del virtio-disk1
(qemu) chardev-remove drive-virtio-disk1
(qemu) info chardev
serial0: filename=pty:/dev/pts/0
charmonitor:
filename=unix:/usr/local/var/lib/libvirt/qemu/domain-55-e59039db-d576-40db-a/monitor.sock,server
(qemu) chardev-add socket,id=drive-virtio-disk1,path=/var/run/spdk/vhost_blk_socket-30dcf467-486a-45cf-b754-093bf5cf24d1,reconnect=10
device failed: Duplicate ID 'drive-virtio-disk1' for chardev Error: Parsing chardev args failed


The root cause of this issue is that the QemuOpts is still reserved in vm_config_groups list,
so qemu_opts_create will fail with the error above. So the QemuOpts should be removed when
invoking qmp_chardev_remove.




Signed-off-by: Zhoujian Yu <windyu@tencent.com&gt;
Reviewed-by: Lei Wang <kaierwang@tencent.com&gt;
Reviewed-by: Xun Ni <richardni@tencent.com&gt;
Reviewed-by: Zhigang Lu <tonnylu@tencent.com&gt;
---
&nbsp;chardev/char.c | 6 ++++++
&nbsp;1 file changed, 6 insertions(+)


diff --git a/chardev/char.c b/chardev/char.c
index 398f09d..d2087bd 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -37,6 +37,7 @@
&nbsp;#include "qemu/help_option.h"
&nbsp;#include "qemu/module.h"
&nbsp;#include "qemu/option.h"
+#include "qemu/option_int.h"
&nbsp;#include "qemu/id.h"
&nbsp;#include "qemu/coroutine.h"
&nbsp;#include "qemu/yank.h"
@@ -1159,6 +1160,7 @@ ChardevReturn *qmp_chardev_change(const char *id, ChardevBackend *backend,
&nbsp;void qmp_chardev_remove(const char *id, Error **errp)
&nbsp;{
&nbsp; &nbsp; &nbsp;Chardev *chr;
+&nbsp; &nbsp;QemuOpts *opts;
&nbsp;
&nbsp; &nbsp; &nbsp;chr = qemu_chr_find(id);
&nbsp; &nbsp; &nbsp;if (chr == NULL) {
@@ -1175,6 +1177,10 @@ void qmp_chardev_remove(const char *id, Error **errp)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
&nbsp; &nbsp; &nbsp;}
&nbsp; &nbsp; &nbsp;object_unparent(OBJECT(chr));
+&nbsp; &nbsp; /* delete the opts reserved in vm_config_groups list.&nbsp; */
+&nbsp; &nbsp; opts = qemu_opts_find(qemu_find_opts("chardev"), id);
+&nbsp; &nbsp; if (opts)
+&nbsp; &nbsp; &nbsp; &nbsp; qemu_opts_del(opts);
&nbsp;}
&nbsp;
&nbsp;void qmp_chardev_send_break(const char *id, Error **errp)
--&nbsp;
1.8.3.1

[-- Attachment #2: Type: text/html, Size: 3771 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-19  9:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-06 10:23 Chardev: delete the QemuOpts reserved in vm_config_groups =?gb18030?B?pNe357n9zt662z8/?=
2021-11-08  8:46 ` Marc-André Lureau
2021-11-09  2:55   ` =?gb18030?B?u9i4tKO6IENoYXJkZXY6IGRlbGV0ZSB0aGUgUWVtdU9wdHMgcmVzZXJ2ZWQgaW4gdm1fY29uZmlnX2dyb3Vwcw==?= =?gb18030?B?pNe357n9zt662z8/?=
2021-11-15  8:14     ` Chardev: delete the QemuOpts reserved in vm_config_groups =?gb18030?B?pNe357n9zt662z8/?=
2021-11-19  9:27   ` Paolo Bonzini
2021-11-19  9:55     ` =?gb18030?B?u9i4tKO6IENoYXJkZXY6IGRlbGV0ZSB0aGUgUWVtdU9wdHMgcmVzZXJ2ZWQgaW4gdm1fY29uZmlnX2dyb3Vwcw==?= =?gb18030?B?pNe357n9zt662z8/?=

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).