On Thu, Mar 20, 2025 at 11:05:04AM +0100, Peter Krempa via Devel wrote:
> 
> Libvirt supports console also for unix-socket backed chardevs. I presume
> that would require the QMP command approach instead. That will likely
> reuqire more plumbing because on the first glance we don't seem to
> have the access to the VM object from the stream code. A callback could
> potentially solve that.

I thought we didn't support UNIX socket chardevs for the
console because in qemuDomainOpenConsole we have

    if (chr->source->type != VIR_DOMAIN_CHR_TYPE_PTY) {
        virReportError(VIR_ERR_INTERNAL_ERROR,
                       _("character device %1$s is not using a PTY"),
                       dev_name ? dev_name : NULLSTR(chr->info.alias));
        goto cleanup;
    }

and yet virChrdevOpen supports it since

  commit 66a0664974b6200b9184ea6b4ca9d816f6924f8c
  Author: John Eckersberg <jecke...@redhat.com>
  Date:   Wed Jan 2 10:38:53 2013 -0500

    conf: Add unix socket support to virChrdevOpen

so surely our check in qemuDomainOpenConsole has prevented
this ever being used.

> 
> > 
> > TLDR I have the following 2 questions:
> > - Should the resize handle be implemented in the virHypervisorDriver
> > directly or in the virStreamDriver?
> > - Is there a way to get the QMP alias of a chardev from a virStream?
> 
> I'd suggest to either implement it as another type of data transported
> via the stream or a standalone API.
> 
> The client application which uses the stream knows which console it
> opened so it does have enough data to issue the proper API call with
> parameters identical to how it opened the console.
> 
> The approach of adding stream APIs looks a bit cleaner on the first
> glance but as I've noted I'm not sure how complicated it will be to
> access the VM object if QMP command will be needed.

If we consider that resize is just one, of possibly many, control commands
you might want over a terminal, then we would want a general  callback
that can be registered with the stream impl

    virStreamControlCommand(virStreamPtr st,
                            virTypedParameter params,
                            unsigned int nparams);

and an internal method

   typedef int (*virFDStreamControlCommandCallback)(virFDStream *st,
                                                    virTypedParameter params,
                                                    unsigned int nparams,
                                                    void *opaque)
   virFDStreamSetInternalControlCommandCallback(virFDStream,
           virFDStreamControlCommandCallback cb,
           void *opaque,
           virFreeCallback freecb)

which could be used to pass the 'virDomainObjPt' as the 'opaque' param

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 :|

Reply via email to