Re: [PATCH v6 1/3] ui/console: Introduce dpy_gl_qemu_dmabuf_get_..() helpers
Hi On Wed, Apr 17, 2024 at 9:06 PM Kim, Dongwon wrote: > > Hi Daniel, > > > -Original Message- > > From: Daniel P. Berrangé > > Sent: Wednesday, April 17, 2024 4:05 AM > > To: Kim, Dongwon > > Cc: qemu-devel@nongnu.org; marcandre.lur...@redhat.com > > Subject: Re: [PATCH v6 1/3] ui/console: Introduce > > dpy_gl_qemu_dmabuf_get_..() helpers > > > > On Tue, Apr 16, 2024 at 09:09:52PM -0700, dongwon@intel.com wrote: > > > From: Dongwon Kim > > > > > > This commit introduces dpy_gl_qemu_dmabuf_get_... helpers to extract > > > specific fields from the QemuDmaBuf struct. It also updates all > > > instances where fields within the QemuDmaBuf struct are directly > > > accessed, replacing them with calls to these new helper functions. > > > > > > v6: fix typos in helper names in ui/spice-display.c > > > > > > Suggested-by: Marc-André Lureau > > > Cc: Philippe Mathieu-Daudé > > > Cc: Vivek Kasireddy > > > Signed-off-by: Dongwon Kim > > > --- > > > include/ui/console.h| 17 + > > > hw/display/vhost-user-gpu.c | 6 +- > > > hw/display/virtio-gpu-udmabuf.c | 7 +- > > > hw/vfio/display.c | 15 +++-- > > > ui/console.c| 116 +++- > > > ui/dbus-console.c | 9 ++- > > > ui/dbus-listener.c | 43 +++- > > > ui/egl-headless.c | 23 +-- > > > ui/egl-helpers.c| 47 +++-- > > > ui/gtk-egl.c| 48 - > > > ui/gtk-gl-area.c| 37 ++ > > > ui/gtk.c| 6 +- > > > ui/spice-display.c | 50 -- > > > 13 files changed, 316 insertions(+), 108 deletions(-) > > > > > > diff --git a/include/ui/console.h b/include/ui/console.h index > > > 0bc7a00ac0..6292943a82 100644 > > > --- a/include/ui/console.h > > > +++ b/include/ui/console.h > > > @@ -358,6 +358,23 @@ void dpy_gl_cursor_dmabuf(QemuConsole *con, > > QemuDmaBuf *dmabuf, > > >bool have_hot, uint32_t hot_x, uint32_t > > > hot_y); void dpy_gl_cursor_position(QemuConsole *con, > > > uint32_t pos_x, uint32_t pos_y); > > > + > > > +int32_t dpy_gl_qemu_dmabuf_get_fd(QemuDmaBuf *dmabuf); uint32_t > > > +dpy_gl_qemu_dmabuf_get_width(QemuDmaBuf *dmabuf); uint32_t > > > +dpy_gl_qemu_dmabuf_get_height(QemuDmaBuf *dmabuf); uint32_t > > > +dpy_gl_qemu_dmabuf_get_stride(QemuDmaBuf *dmabuf); uint32_t > > > +dpy_gl_qemu_dmabuf_get_fourcc(QemuDmaBuf *dmabuf); uint64_t > > > +dpy_gl_qemu_dmabuf_get_modifier(QemuDmaBuf *dmabuf); uint32_t > > > +dpy_gl_qemu_dmabuf_get_texture(QemuDmaBuf *dmabuf); uint32_t > > > +dpy_gl_qemu_dmabuf_get_x(QemuDmaBuf *dmabuf); uint32_t > > > +dpy_gl_qemu_dmabuf_get_y(QemuDmaBuf *dmabuf); uint32_t > > > +dpy_gl_qemu_dmabuf_get_backing_width(QemuDmaBuf *dmabuf); > > uint32_t > > > +dpy_gl_qemu_dmabuf_get_backing_height(QemuDmaBuf *dmabuf); bool > > > +dpy_gl_qemu_dmabuf_get_y0_top(QemuDmaBuf *dmabuf); void > > > +*dpy_gl_qemu_dmabuf_get_sync(QemuDmaBuf *dmabuf); int32_t > > > +dpy_gl_qemu_dmabuf_get_fence_fd(QemuDmaBuf *dmabuf); bool > > > +dpy_gl_qemu_dmabuf_get_allow_fences(QemuDmaBuf *dmabuf); bool > > > +dpy_gl_qemu_dmabuf_get_draw_submitted(QemuDmaBuf *dmabuf); > > > > IMHO these method names don't need a "dpy_gl_" prefix on them. Since > > they're accessors for the "QemuDmaBuf" struct, I think its sufficient to > > just > > have "qemu_dmabuf_" as the name prefix, making names more compact. > > > > The console.{h,c} files are a bit of a dumping ground for UI code. While > > QemuDmaBuf was just a struct with direct field access that's OK. > > > > With turning this into a more of an object with accessors, I think it would > > also > > be desirable to move the struct definition and all its methods into separate > > ui/dmabuf.{c,h} files, so its fully self-contained. > > [Kim, Dongwon] I am ok with changing function names and create > separate c and h for dmabuf helpers as you suggested. But I would > like to hear Marc-André's opinion about this suggestion before I make > such changes. > > Marc-André, do you have any thought on Daniel's suggestion? Sure, I was about to ask the same. Anything we can do to slim ui/console.c helps :)
RE: [PATCH v6 1/3] ui/console: Introduce dpy_gl_qemu_dmabuf_get_..() helpers
Hi Daniel, > -Original Message- > From: Daniel P. Berrangé > Sent: Wednesday, April 17, 2024 4:05 AM > To: Kim, Dongwon > Cc: qemu-devel@nongnu.org; marcandre.lur...@redhat.com > Subject: Re: [PATCH v6 1/3] ui/console: Introduce > dpy_gl_qemu_dmabuf_get_..() helpers > > On Tue, Apr 16, 2024 at 09:09:52PM -0700, dongwon@intel.com wrote: > > From: Dongwon Kim > > > > This commit introduces dpy_gl_qemu_dmabuf_get_... helpers to extract > > specific fields from the QemuDmaBuf struct. It also updates all > > instances where fields within the QemuDmaBuf struct are directly > > accessed, replacing them with calls to these new helper functions. > > > > v6: fix typos in helper names in ui/spice-display.c > > > > Suggested-by: Marc-André Lureau > > Cc: Philippe Mathieu-Daudé > > Cc: Vivek Kasireddy > > Signed-off-by: Dongwon Kim > > --- > > include/ui/console.h| 17 + > > hw/display/vhost-user-gpu.c | 6 +- > > hw/display/virtio-gpu-udmabuf.c | 7 +- > > hw/vfio/display.c | 15 +++-- > > ui/console.c| 116 +++- > > ui/dbus-console.c | 9 ++- > > ui/dbus-listener.c | 43 +++- > > ui/egl-headless.c | 23 +-- > > ui/egl-helpers.c| 47 +++-- > > ui/gtk-egl.c| 48 - > > ui/gtk-gl-area.c| 37 ++ > > ui/gtk.c| 6 +- > > ui/spice-display.c | 50 -- > > 13 files changed, 316 insertions(+), 108 deletions(-) > > > > diff --git a/include/ui/console.h b/include/ui/console.h index > > 0bc7a00ac0..6292943a82 100644 > > --- a/include/ui/console.h > > +++ b/include/ui/console.h > > @@ -358,6 +358,23 @@ void dpy_gl_cursor_dmabuf(QemuConsole *con, > QemuDmaBuf *dmabuf, > >bool have_hot, uint32_t hot_x, uint32_t > > hot_y); void dpy_gl_cursor_position(QemuConsole *con, > > uint32_t pos_x, uint32_t pos_y); > > + > > +int32_t dpy_gl_qemu_dmabuf_get_fd(QemuDmaBuf *dmabuf); uint32_t > > +dpy_gl_qemu_dmabuf_get_width(QemuDmaBuf *dmabuf); uint32_t > > +dpy_gl_qemu_dmabuf_get_height(QemuDmaBuf *dmabuf); uint32_t > > +dpy_gl_qemu_dmabuf_get_stride(QemuDmaBuf *dmabuf); uint32_t > > +dpy_gl_qemu_dmabuf_get_fourcc(QemuDmaBuf *dmabuf); uint64_t > > +dpy_gl_qemu_dmabuf_get_modifier(QemuDmaBuf *dmabuf); uint32_t > > +dpy_gl_qemu_dmabuf_get_texture(QemuDmaBuf *dmabuf); uint32_t > > +dpy_gl_qemu_dmabuf_get_x(QemuDmaBuf *dmabuf); uint32_t > > +dpy_gl_qemu_dmabuf_get_y(QemuDmaBuf *dmabuf); uint32_t > > +dpy_gl_qemu_dmabuf_get_backing_width(QemuDmaBuf *dmabuf); > uint32_t > > +dpy_gl_qemu_dmabuf_get_backing_height(QemuDmaBuf *dmabuf); bool > > +dpy_gl_qemu_dmabuf_get_y0_top(QemuDmaBuf *dmabuf); void > > +*dpy_gl_qemu_dmabuf_get_sync(QemuDmaBuf *dmabuf); int32_t > > +dpy_gl_qemu_dmabuf_get_fence_fd(QemuDmaBuf *dmabuf); bool > > +dpy_gl_qemu_dmabuf_get_allow_fences(QemuDmaBuf *dmabuf); bool > > +dpy_gl_qemu_dmabuf_get_draw_submitted(QemuDmaBuf *dmabuf); > > IMHO these method names don't need a "dpy_gl_" prefix on them. Since > they're accessors for the "QemuDmaBuf" struct, I think its sufficient to just > have "qemu_dmabuf_" as the name prefix, making names more compact. > > The console.{h,c} files are a bit of a dumping ground for UI code. While > QemuDmaBuf was just a struct with direct field access that's OK. > > With turning this into a more of an object with accessors, I think it would > also > be desirable to move the struct definition and all its methods into separate > ui/dmabuf.{c,h} files, so its fully self-contained. [Kim, Dongwon] I am ok with changing function names and create separate c and h for dmabuf helpers as you suggested. But I would like to hear Marc-André's opinion about this suggestion before I make such changes. Marc-André, do you have any thought on Daniel's suggestion? > > With regards, > Daniel > -- > |: https://berrange.com -o-https://www.flickr.com/photos/dberrange :| > |: https://libvirt.org -o-https://fstop138.berrange.com :| > |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
Re: [PATCH v6 1/3] ui/console: Introduce dpy_gl_qemu_dmabuf_get_..() helpers
On Tue, Apr 16, 2024 at 09:09:52PM -0700, dongwon@intel.com wrote: > From: Dongwon Kim > > This commit introduces dpy_gl_qemu_dmabuf_get_... helpers to extract > specific fields from the QemuDmaBuf struct. It also updates all instances > where fields within the QemuDmaBuf struct are directly accessed, replacing > them with calls to these new helper functions. > > v6: fix typos in helper names in ui/spice-display.c > > Suggested-by: Marc-André Lureau > Cc: Philippe Mathieu-Daudé > Cc: Vivek Kasireddy > Signed-off-by: Dongwon Kim > --- > include/ui/console.h| 17 + > hw/display/vhost-user-gpu.c | 6 +- > hw/display/virtio-gpu-udmabuf.c | 7 +- > hw/vfio/display.c | 15 +++-- > ui/console.c| 116 +++- > ui/dbus-console.c | 9 ++- > ui/dbus-listener.c | 43 +++- > ui/egl-headless.c | 23 +-- > ui/egl-helpers.c| 47 +++-- > ui/gtk-egl.c| 48 - > ui/gtk-gl-area.c| 37 ++ > ui/gtk.c| 6 +- > ui/spice-display.c | 50 -- > 13 files changed, 316 insertions(+), 108 deletions(-) > > diff --git a/include/ui/console.h b/include/ui/console.h > index 0bc7a00ac0..6292943a82 100644 > --- a/include/ui/console.h > +++ b/include/ui/console.h > @@ -358,6 +358,23 @@ void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf > *dmabuf, >bool have_hot, uint32_t hot_x, uint32_t hot_y); > void dpy_gl_cursor_position(QemuConsole *con, > uint32_t pos_x, uint32_t pos_y); > + > +int32_t dpy_gl_qemu_dmabuf_get_fd(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_width(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_height(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_stride(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_fourcc(QemuDmaBuf *dmabuf); > +uint64_t dpy_gl_qemu_dmabuf_get_modifier(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_texture(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_x(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_y(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_backing_width(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_backing_height(QemuDmaBuf *dmabuf); > +bool dpy_gl_qemu_dmabuf_get_y0_top(QemuDmaBuf *dmabuf); > +void *dpy_gl_qemu_dmabuf_get_sync(QemuDmaBuf *dmabuf); > +int32_t dpy_gl_qemu_dmabuf_get_fence_fd(QemuDmaBuf *dmabuf); > +bool dpy_gl_qemu_dmabuf_get_allow_fences(QemuDmaBuf *dmabuf); > +bool dpy_gl_qemu_dmabuf_get_draw_submitted(QemuDmaBuf *dmabuf); IMHO these method names don't need a "dpy_gl_" prefix on them. Since they're accessors for the "QemuDmaBuf" struct, I think its sufficient to just have "qemu_dmabuf_" as the name prefix, making names more compact. The console.{h,c} files are a bit of a dumping ground for UI code. While QemuDmaBuf was just a struct with direct field access that's OK. With turning this into a more of an object with accessors, I think it would also be desirable to move the struct definition and all its methods into separate ui/dmabuf.{c,h} files, so its fully self-contained. With regards, Daniel -- |: https://berrange.com -o-https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o-https://fstop138.berrange.com :| |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
Re: [PATCH v6 1/3] ui/console: Introduce dpy_gl_qemu_dmabuf_get_..() helpers
Hi On Wed, Apr 17, 2024 at 8:14 AM wrote: > > From: Dongwon Kim > > This commit introduces dpy_gl_qemu_dmabuf_get_... helpers to extract > specific fields from the QemuDmaBuf struct. It also updates all instances > where fields within the QemuDmaBuf struct are directly accessed, replacing > them with calls to these new helper functions. > > v6: fix typos in helper names in ui/spice-display.c > > Suggested-by: Marc-André Lureau > Cc: Philippe Mathieu-Daudé > Cc: Vivek Kasireddy > Signed-off-by: Dongwon Kim > --- > include/ui/console.h| 17 + > hw/display/vhost-user-gpu.c | 6 +- > hw/display/virtio-gpu-udmabuf.c | 7 +- > hw/vfio/display.c | 15 +++-- > ui/console.c| 116 +++- > ui/dbus-console.c | 9 ++- > ui/dbus-listener.c | 43 +++- > ui/egl-headless.c | 23 +-- > ui/egl-helpers.c| 47 +++-- > ui/gtk-egl.c| 48 - > ui/gtk-gl-area.c| 37 ++ > ui/gtk.c| 6 +- > ui/spice-display.c | 50 -- > 13 files changed, 316 insertions(+), 108 deletions(-) > > diff --git a/include/ui/console.h b/include/ui/console.h > index 0bc7a00ac0..6292943a82 100644 > --- a/include/ui/console.h > +++ b/include/ui/console.h > @@ -358,6 +358,23 @@ void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf > *dmabuf, >bool have_hot, uint32_t hot_x, uint32_t hot_y); > void dpy_gl_cursor_position(QemuConsole *con, > uint32_t pos_x, uint32_t pos_y); > + > +int32_t dpy_gl_qemu_dmabuf_get_fd(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_width(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_height(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_stride(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_fourcc(QemuDmaBuf *dmabuf); > +uint64_t dpy_gl_qemu_dmabuf_get_modifier(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_texture(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_x(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_y(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_backing_width(QemuDmaBuf *dmabuf); > +uint32_t dpy_gl_qemu_dmabuf_get_backing_height(QemuDmaBuf *dmabuf); > +bool dpy_gl_qemu_dmabuf_get_y0_top(QemuDmaBuf *dmabuf); > +void *dpy_gl_qemu_dmabuf_get_sync(QemuDmaBuf *dmabuf); > +int32_t dpy_gl_qemu_dmabuf_get_fence_fd(QemuDmaBuf *dmabuf); > +bool dpy_gl_qemu_dmabuf_get_allow_fences(QemuDmaBuf *dmabuf); > +bool dpy_gl_qemu_dmabuf_get_draw_submitted(QemuDmaBuf *dmabuf); > void dpy_gl_release_dmabuf(QemuConsole *con, > QemuDmaBuf *dmabuf); > void dpy_gl_update(QemuConsole *con, > diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c > index 709c8a02a1..87dcfbca10 100644 > --- a/hw/display/vhost-user-gpu.c > +++ b/hw/display/vhost-user-gpu.c > @@ -249,6 +249,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, > VhostUserGpuMsg *msg) > case VHOST_USER_GPU_DMABUF_SCANOUT: { > VhostUserGpuDMABUFScanout *m = >payload.dmabuf_scanout; > int fd = qemu_chr_fe_get_msgfd(>vhost_chr); > +int old_fd; > QemuDmaBuf *dmabuf; > > if (m->scanout_id >= g->parent_obj.conf.max_outputs) { > @@ -262,8 +263,9 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, > VhostUserGpuMsg *msg) > g->parent_obj.enable = 1; > con = g->parent_obj.scanout[m->scanout_id].con; > dmabuf = >dmabuf[m->scanout_id]; > -if (dmabuf->fd >= 0) { > -close(dmabuf->fd); > +old_fd = dpy_gl_qemu_dmabuf_get_fd(dmabuf); > +if (old_fd >= 0) { > +close(old_fd); > dmabuf->fd = -1; > } > dpy_gl_release_dmabuf(con, dmabuf); > diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabuf.c > index d51184d658..e3f358b575 100644 > --- a/hw/display/virtio-gpu-udmabuf.c > +++ b/hw/display/virtio-gpu-udmabuf.c > @@ -206,6 +206,7 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g, > { > struct virtio_gpu_scanout *scanout = >parent_obj.scanout[scanout_id]; > VGPUDMABuf *new_primary, *old_primary = NULL; > +uint32_t width, height; > > new_primary = virtio_gpu_create_dmabuf(g, scanout_id, res, fb, r); > if (!new_primary) { > @@ -216,10 +217,10 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g, > old_primary = g->dmabuf.primary[scanout_id]; > } > > +width = dpy_gl_qemu_dmabuf_get_width(_primary->buf); > +height = dpy_gl_qemu_dmabuf_get_height(_primary->buf); > g->dmabuf.primary[scanout_id] = new_primary; > -qemu_console_resize(scanout->con, > -new_primary->buf.width, > -new_primary->buf.height); > +qemu_console_resize(scanout->con, width, height); > dpy_gl_scanout_dmabuf(scanout->con,
[PATCH v6 1/3] ui/console: Introduce dpy_gl_qemu_dmabuf_get_..() helpers
From: Dongwon Kim This commit introduces dpy_gl_qemu_dmabuf_get_... helpers to extract specific fields from the QemuDmaBuf struct. It also updates all instances where fields within the QemuDmaBuf struct are directly accessed, replacing them with calls to these new helper functions. v6: fix typos in helper names in ui/spice-display.c Suggested-by: Marc-André Lureau Cc: Philippe Mathieu-Daudé Cc: Vivek Kasireddy Signed-off-by: Dongwon Kim --- include/ui/console.h| 17 + hw/display/vhost-user-gpu.c | 6 +- hw/display/virtio-gpu-udmabuf.c | 7 +- hw/vfio/display.c | 15 +++-- ui/console.c| 116 +++- ui/dbus-console.c | 9 ++- ui/dbus-listener.c | 43 +++- ui/egl-headless.c | 23 +-- ui/egl-helpers.c| 47 +++-- ui/gtk-egl.c| 48 - ui/gtk-gl-area.c| 37 ++ ui/gtk.c| 6 +- ui/spice-display.c | 50 -- 13 files changed, 316 insertions(+), 108 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 0bc7a00ac0..6292943a82 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -358,6 +358,23 @@ void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf, bool have_hot, uint32_t hot_x, uint32_t hot_y); void dpy_gl_cursor_position(QemuConsole *con, uint32_t pos_x, uint32_t pos_y); + +int32_t dpy_gl_qemu_dmabuf_get_fd(QemuDmaBuf *dmabuf); +uint32_t dpy_gl_qemu_dmabuf_get_width(QemuDmaBuf *dmabuf); +uint32_t dpy_gl_qemu_dmabuf_get_height(QemuDmaBuf *dmabuf); +uint32_t dpy_gl_qemu_dmabuf_get_stride(QemuDmaBuf *dmabuf); +uint32_t dpy_gl_qemu_dmabuf_get_fourcc(QemuDmaBuf *dmabuf); +uint64_t dpy_gl_qemu_dmabuf_get_modifier(QemuDmaBuf *dmabuf); +uint32_t dpy_gl_qemu_dmabuf_get_texture(QemuDmaBuf *dmabuf); +uint32_t dpy_gl_qemu_dmabuf_get_x(QemuDmaBuf *dmabuf); +uint32_t dpy_gl_qemu_dmabuf_get_y(QemuDmaBuf *dmabuf); +uint32_t dpy_gl_qemu_dmabuf_get_backing_width(QemuDmaBuf *dmabuf); +uint32_t dpy_gl_qemu_dmabuf_get_backing_height(QemuDmaBuf *dmabuf); +bool dpy_gl_qemu_dmabuf_get_y0_top(QemuDmaBuf *dmabuf); +void *dpy_gl_qemu_dmabuf_get_sync(QemuDmaBuf *dmabuf); +int32_t dpy_gl_qemu_dmabuf_get_fence_fd(QemuDmaBuf *dmabuf); +bool dpy_gl_qemu_dmabuf_get_allow_fences(QemuDmaBuf *dmabuf); +bool dpy_gl_qemu_dmabuf_get_draw_submitted(QemuDmaBuf *dmabuf); void dpy_gl_release_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf); void dpy_gl_update(QemuConsole *con, diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 709c8a02a1..87dcfbca10 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -249,6 +249,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg) case VHOST_USER_GPU_DMABUF_SCANOUT: { VhostUserGpuDMABUFScanout *m = >payload.dmabuf_scanout; int fd = qemu_chr_fe_get_msgfd(>vhost_chr); +int old_fd; QemuDmaBuf *dmabuf; if (m->scanout_id >= g->parent_obj.conf.max_outputs) { @@ -262,8 +263,9 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg) g->parent_obj.enable = 1; con = g->parent_obj.scanout[m->scanout_id].con; dmabuf = >dmabuf[m->scanout_id]; -if (dmabuf->fd >= 0) { -close(dmabuf->fd); +old_fd = dpy_gl_qemu_dmabuf_get_fd(dmabuf); +if (old_fd >= 0) { +close(old_fd); dmabuf->fd = -1; } dpy_gl_release_dmabuf(con, dmabuf); diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabuf.c index d51184d658..e3f358b575 100644 --- a/hw/display/virtio-gpu-udmabuf.c +++ b/hw/display/virtio-gpu-udmabuf.c @@ -206,6 +206,7 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g, { struct virtio_gpu_scanout *scanout = >parent_obj.scanout[scanout_id]; VGPUDMABuf *new_primary, *old_primary = NULL; +uint32_t width, height; new_primary = virtio_gpu_create_dmabuf(g, scanout_id, res, fb, r); if (!new_primary) { @@ -216,10 +217,10 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g, old_primary = g->dmabuf.primary[scanout_id]; } +width = dpy_gl_qemu_dmabuf_get_width(_primary->buf); +height = dpy_gl_qemu_dmabuf_get_height(_primary->buf); g->dmabuf.primary[scanout_id] = new_primary; -qemu_console_resize(scanout->con, -new_primary->buf.width, -new_primary->buf.height); +qemu_console_resize(scanout->con, width, height); dpy_gl_scanout_dmabuf(scanout->con, _primary->buf); if (old_primary) { diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 1aa440c663..f9c39cbd51 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -259,9 +259,13 @@ static VFIODMABuf *vfio_display_get_dmabuf(VFIOPCIDevice