qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: =?gb18030?B?pNe357n9zt662z8/?= <787738581@qq.com>
To: =?gb18030?B?TWFyYy1BbmRyqKYgTHVyZWF1?= <marcandre.lureau@redhat.com>
Cc: =?gb18030?B?cGJvbnppbmk=?= <pbonzini@redhat.com>,
	=?gb18030?B?cWVtdS1kZXZlbA==?= <qemu-devel@nongnu.org>
Subject: Chardev: delete the QemuOpts reserved in vm_config_groups
Date: Mon, 15 Nov 2021 16:14:16 +0800	[thread overview]
Message-ID: <tencent_ED9A108DF3F1FE3BFF38884E9FAB28339906@qq.com> (raw)
In-Reply-To: <tencent_7080EF93E3263A6DAE07CC946AC9344CC708@qq.com>

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

PING
&nbsp;
thanks, Wind Yu


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


&gt;Hi

On Sat, Nov 6, 2021 at 10:41 PM ¤×·ç¹ýÎÞºÛ?? <787738581@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; start qemu with the following command:
&gt; ./qemu-system-x86_64 -enable-kvm -m 8192 -smp 16 \
&gt;&nbsp; &nbsp; -object memory-backend-file,id=mem,size=8192M,mem-path=/dev/hugepages,share=on \
&gt;&nbsp; &nbsp; -numa node,memdev=mem -mem-prealloc \
&gt;&nbsp; &nbsp; ...
&gt;&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; -device vhost-user-blk-pci,chardev=drive-virtio-disk1,num-queues=1,bus=pci.0,addr=0x5,id=virtio-disk1 \
&gt;&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 <windyu@tencent.com&gt;
&gt; Reviewed-by: Lei Wang <kaierwang@tencent.com&gt;
&gt; Reviewed-by: Xun Ni <richardni@tencent.com&gt;
&gt; Reviewed-by: Zhigang Lu <tonnylu@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; Chardev *chr;
&gt; + &nbsp; QemuOpts *opts;
&gt;
&gt;&nbsp;&nbsp;&nbsp; &nbsp; chr = qemu_chr_find(id);
&gt;&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; return;
&gt;&nbsp;&nbsp;&nbsp; &nbsp; }
&gt;&nbsp;&nbsp;&nbsp; &nbsp; object_unparent(OBJECT(chr));
&gt; +&nbsp; &nbsp; /* delete the opts reserved in vm_config_groups list.&nbsp; */
&gt; +&nbsp; &nbsp; opts = qemu_opts_find(qemu_find_opts("chardev"), id);
&gt; +&nbsp; &nbsp; if (opts)
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; qemu_opts_del(opts);

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

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

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

  reply	other threads:[~2021-11-15  8:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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     ` =?gb18030?B?pNe357n9zt662z8/?= [this message]
2021-11-19  9:27   ` Chardev: delete the QemuOpts reserved in vm_config_groups Paolo Bonzini
2021-11-19  9:55     ` =?gb18030?B?u9i4tKO6IENoYXJkZXY6IGRlbGV0ZSB0aGUgUWVtdU9wdHMgcmVzZXJ2ZWQgaW4gdm1fY29uZmlnX2dyb3Vwcw==?= =?gb18030?B?pNe357n9zt662z8/?=

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_ED9A108DF3F1FE3BFF38884E9FAB28339906@qq.com \
    --to=787738581@qq.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).