All of lore.kernel.org
 help / color / mirror / Atom feed
From: =?gb18030?B?pNe357n9zt662z8/?= <787738581@qq.com>
To: =?gb18030?B?bWFyY2FuZHJlLmx1cmVhdQ==?=
	<marcandre.lureau@redhat.com>,
	=?gb18030?B?cGJvbnppbmk=?= <pbonzini@redhat.com>
Cc: =?gb18030?B?cWVtdS1kZXZlbA==?= <qemu-devel@nongnu.org>
Subject: Chardev: delete the QemuOpts reserved in vm_config_groups
Date: Sat, 6 Nov 2021 18:23:38 +0800	[thread overview]
Message-ID: <tencent_C7CEA36B3AB3971A278DFD71F2BBCFF88906@qq.com> (raw)

[-- 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.
&nbsp; &nbsp; &nbsp; &nbsp; start qemu with the following command:
./qemu-system-x86_64 -enable-kvm -m 8192 -smp 16 \
&nbsp; &nbsp;-object memory-backend-file,id=mem,size=8192M,mem-path=/dev/hugepages,share=on \
&nbsp; &nbsp;-numa node,memdev=mem -mem-prealloc \
&nbsp; &nbsp;...
&nbsp; &nbsp;-chardev socket,id=drive-virtio-disk1,path=/var/run/spdk/vhost_blk_socket-30dcf467-486a-45cf-b754-093bf5cf24d1,reconnect=10 \
&nbsp; &nbsp;-device vhost-user-blk-pci,chardev=drive-virtio-disk1,num-queues=1,bus=pci.0,addr=0x5,id=virtio-disk1 \
&nbsp; &nbsp;...


(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 --]

             reply	other threads:[~2021-11-06 14:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-06 10:23 =?gb18030?B?pNe357n9zt662z8/?= [this message]
2021-11-08  8:46 ` Chardev: delete the QemuOpts reserved in vm_config_groups 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/?=

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_C7CEA36B3AB3971A278DFD71F2BBCFF88906@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.