All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ui/console: allow display device to be labeled with given id
@ 2022-05-26  7:08 Wen, Jianxian
  2022-06-09  9:33 ` Gerd Hoffmann
  0 siblings, 1 reply; 2+ messages in thread
From: Wen, Jianxian @ 2022-05-26  7:08 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, Gao, Lu

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


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

* Re: [PATCH] ui/console: allow display device to be labeled with given id
  2022-05-26  7:08 [PATCH] ui/console: allow display device to be labeled with given id Wen, Jianxian
@ 2022-06-09  9:33 ` Gerd Hoffmann
  0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2022-06-09  9:33 UTC (permalink / raw)
  To: Wen, Jianxian; +Cc: qemu-devel, Gao, Lu

On Thu, May 26, 2022 at 07:08:14AM +0000, Wen, Jianxian wrote:
> 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.

Can we make the head field conditional, so it's only done in case there
are actually multiple heads?  Both qxl and virtio-gpu have a max_outputs
property, so checking if that exists and is greater than 1 should work
for that.

take care,
  Gerd



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

end of thread, other threads:[~2022-06-09 12:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26  7:08 [PATCH] ui/console: allow display device to be labeled with given id Wen, Jianxian
2022-06-09  9:33 ` Gerd Hoffmann

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.