All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Wen, Jianxian" <Jianxian.Wen@verisilicon.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"Gao, Lu" <Lu.Gao@verisilicon.com>
Subject: [PATCH] ui/console: allow display device to be labeled with given id
Date: Thu, 26 May 2022 07:08:14 +0000	[thread overview]
Message-ID: <4C23C17B8E87E74E906A25A3254A03F4018FC0021E@SHASXM06.verisilicon.com> (raw)

The update makes it easier to find and specify devices.
They can only be found by device type name without the id field,
for example, devices of the same type have the same label.
The update also adds a head field,
which is useful for devices that support multiple heads,
such as virtio-gpu.

Signed-off-by: Jianxian Wen <jianxian.wen@verisilicon.com>
Signed-off-by: Lu Gao <lu.gao@verisilicon.com>
---
How to reproduce it:
    -display gtk \
    -device bochs-display,id=bochs0 \
    -device bochs-display,id=bochs1 \
    -device virtio-gpu,max_outputs=2 \
    -device virtio-gpu,max_outputs=2,id=vgpu1

 ui/console.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/ui/console.c b/ui/console.c
index 36c80cd1de..d0226c765e 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -2323,7 +2323,16 @@ char *qemu_console_get_label(QemuConsole *con)
 {
     if (con->console_type == GRAPHIC_CONSOLE) {
         if (con->device) {
-            return g_strdup(object_get_typename(con->device));
+            DeviceState *dev;
+
+            dev = DEVICE(con->device);
+            if (dev->id) {
+                return g_strdup_printf("%s.%d", dev->id, con->head);
+            } else {
+                return g_strdup_printf("%s.%d",
+                                       object_get_typename(con->device),
+                                       con->head);
+            }
         }
         return g_strdup("VGA");
     } else {
-- 
2.33.0


             reply	other threads:[~2022-05-26  7:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-26  7:08 Wen, Jianxian [this message]
2022-06-09  9:33 ` [PATCH] ui/console: allow display device to be labeled with given id Gerd Hoffmann

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=4C23C17B8E87E74E906A25A3254A03F4018FC0021E@SHASXM06.verisilicon.com \
    --to=jianxian.wen@verisilicon.com \
    --cc=Lu.Gao@verisilicon.com \
    --cc=kraxel@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.