kdevops.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: fan.ni@gmx.us
To: mcgrof@kernel.org
Cc: nmtadam.samsung@gmail.com, fan.ni@samsung.com,
	kdevops@lists.linux.dev, jlayton@kernel.org,
	Fan Ni <fan.ni@gmx.us>
Subject: [PATCH 2/3] qemu: Add QMP connection option for QMP interface access
Date: Tue, 29 Aug 2023 13:36:33 -0700	[thread overview]
Message-ID: <20230829203634.29635-3-fan.ni@gmx.us> (raw)
In-Reply-To: <20230829203634.29635-1-fan.ni@gmx.us>

From: Fan Ni <fan.ni@gmx.us>

In Qemu, QMP interface allows applications to control a QEMU instance.
For CXL emulation, QMP interface has been used to inject poison,
add/release dynamic capacity extents, etc.

With the change, we add a Qemu configuration option to allow user to use
the QMP interface. By default, we start QMP on a TCP socket and let Qemu
instance go through without waiting for QMP connection.

Signed-off-by: Fan Ni <fan.ni@samsung.com>
---
 playbooks/roles/gen_nodes/defaults/main.yml       |  3 +++
 .../roles/gen_nodes/templates/Vagrantfile.j2      |  8 ++++++++
 scripts/gen-nodes.Makefile                        |  9 +++++++++
 vagrant/Kconfig                                   | 15 +++++++++++++++
 4 files changed, 35 insertions(+)

diff --git a/playbooks/roles/gen_nodes/defaults/main.yml b/playbooks/roles/gen_nodes/defaults/main.yml
index 55827e5b..ef5e0c26 100644
--- a/playbooks/roles/gen_nodes/defaults/main.yml
+++ b/playbooks/roles/gen_nodes/defaults/main.yml
@@ -48,6 +48,9 @@ libvirt_qemu_group: libvirt-qemu
 libvirt_machine_type: 'pc'
 libvirt_host_passthrough: False
 libvirt_enable_cxl: False
+libvirt_enable_qmp: False
+libvirt_qemu_qmp_string: ""
+libvirt_qemu_qmp_wait: False
 libvirt_enable_cxl_demo_topo1: False
 libvirt_enable_cxl_demo_topo2: False
 libvirt_enable_cxl_switch_topo1: False
diff --git a/playbooks/roles/gen_nodes/templates/Vagrantfile.j2 b/playbooks/roles/gen_nodes/templates/Vagrantfile.j2
index 124cabd6..20cdd592 100644
--- a/playbooks/roles/gen_nodes/templates/Vagrantfile.j2
+++ b/playbooks/roles/gen_nodes/templates/Vagrantfile.j2
@@ -330,6 +330,14 @@ Vagrant.configure("2") do |config|
 {% endif %} # !switch topo1
         libvirt.qemuargs :value => "-M"
         libvirt.qemuargs :value => "cxl-fmw.0.targets.0=cxl.0,cxl-fmw.0.size=8G"
+{% if libvirt_enable_qmp %}
+        libvirt.qemuargs :value => "-qmp"
+{% if libvirt_qemu_qmp_wait %}
+        libvirt.qemuargs :value => "{{ libvirt_qemu_qmp_string }},wait=on"
+{% else %} # !qmp_wait
+        libvirt.qemuargs :value => "{{ libvirt_qemu_qmp_string }},wait=off"
+{% endif %} # libvirt_qemu_qmp_wait
+{% endif %} # libvirt_enable_qmp
 {% endif %} # CXL
 {% endif %}

diff --git a/scripts/gen-nodes.Makefile b/scripts/gen-nodes.Makefile
index eebd0b2b..8906b49f 100644
--- a/scripts/gen-nodes.Makefile
+++ b/scripts/gen-nodes.Makefile
@@ -190,6 +190,15 @@ GEN_NODES_EXTRA_ARGS += libvirt_machine_type='q35'

 ifeq (y,$(CONFIG_QEMU_ENABLE_CXL))
 GEN_NODES_EXTRA_ARGS += libvirt_enable_cxl='True'
+ifeq (y,$(CONFIG_QEMU_START_QMP_ON_TCP_SOCKET))
+GEN_NODES_EXTRA_ARGS += libvirt_enable_qmp='True'
+GEN_NODES_EXTRA_ARGS += libvirt_qemu_qmp_string='$(subst ",,$(CONFIG_QEMU_QMP_COMMAND_LINE_STRING))'
+ifeq (y,$(CONFIG_QEMU_QMP_WAIT_ON))
+GEN_NODES_EXTRA_ARGS += libvirt_qemu_qmp_wait='True'
+else
+GEN_NODES_EXTRA_ARGS += libvirt_qemu_qmp_wait='False'
+endif # CONFIG_QEMU_QMP_WAIT_ON
+endif # CONFIG_QEMU_START_QMP_ON_TCP_SOCKET
 ifeq (y,$(CONFIG_QEMU_ENABLE_CXL_DEMO_TOPOLOGY_1))
 GEN_NODES_EXTRA_ARGS += libvirt_enable_cxl_demo_topo1='True'
 endif # QEMU_ENABLE_CXL_DEMO_TOPOLOGY_1
diff --git a/vagrant/Kconfig b/vagrant/Kconfig
index 4e382264..c2783935 100644
--- a/vagrant/Kconfig
+++ b/vagrant/Kconfig
@@ -1635,6 +1635,21 @@ config QEMU_ENABLE_CXL

 if QEMU_ENABLE_CXL

+config QEMU_START_QMP_ON_TCP_SOCKET
+	bool "Start QMP on a TCP socket"
+	default n
+	if QEMU_START_QMP_ON_TCP_SOCKET
+	config QEMU_QMP_COMMAND_LINE_STRING
+	string "Qemu command line string for qmp"
+	default "tcp:localhost:4444,server"
+	help
+	  Option for qmp interface (from https://wiki.qemu.org/Documentation/QMP).
+
+	config QEMU_QMP_WAIT_ON
+	bool "Let Qemu instance wait for qmp connection"
+	default n
+	endif # QEMU_START_QMP_ON_TCP_SOCKET
+
 choice
 	prompt "CXL topology to enable"
 	default QEMU_ENABLE_CXL_DEMO_TOPOLOGY_1
--
2.40.1


  parent reply	other threads:[~2023-08-29 20:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29 20:36 [PATCH 0/3] CXL: Add dynamic capacity device test support in kdevops fan.ni
2023-08-29 20:36 ` [PATCH 1/3] CXL: Add a new topology to support DCD emulation fan.ni
2023-08-29 20:36 ` fan.ni [this message]
2023-08-29 20:36 ` [PATCH 3/3] CXL: Add support to create a DC region for DCD fan.ni
2023-08-29 20:48 ` [PATCH 0/3] CXL: Add dynamic capacity device test support in kdevops Fan Ni

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=20230829203634.29635-3-fan.ni@gmx.us \
    --to=fan.ni@gmx.us \
    --cc=fan.ni@samsung.com \
    --cc=jlayton@kernel.org \
    --cc=kdevops@lists.linux.dev \
    --cc=mcgrof@kernel.org \
    --cc=nmtadam.samsung@gmail.com \
    /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).