[libvirt] [PATCH 3/3] Wire up virDomainOpenGraphicsFD in QEMU driver

Eric Blake eblake at redhat.com
Tue Aug 26 22:33:11 UTC 2014


On 08/25/2014 12:22 PM, Ján Tomko wrote:
> Should fix https://bugzilla.redhat.com/show_bug.cgi?id=999926
> ---
>  src/qemu/qemu_driver.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 80 insertions(+)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index ad75bd9..932c638 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -15806,6 +15806,85 @@ qemuDomainOpenGraphics(virDomainPtr dom,
>  }
>  
>  static int
> +qemuDomainOpenGraphicsFD(virDomainPtr dom,
> +                         unsigned int idx,
> +                         int *fd,
> +                         unsigned int flags)
> +{
> +    virQEMUDriverPtr driver = dom->conn->privateData;
> +    virDomainObjPtr vm = NULL;
> +    int ret = -1;

-1 here...


> +    qemuDomainObjEnterMonitor(driver, vm);
> +    ret = qemuMonitorOpenGraphics(priv->mon, protocol, pair[1], "graphicsfd",
> +                                  (flags & VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH) != 0);

slammed into 0 or 1 here, but the contract of the API (prior to my
proposed change) is to return 0 on success, not 1.

> +    qemuDomainObjExitMonitor(driver, vm);
> +    if (!qemuDomainObjEndJob(driver, vm))
> +        vm = NULL;
> +
> +    *fd = pair[0];

And if qemuMonitorOpenGraphics failed, it means we are still assigning a
non-zero fd to *fd,...

> +
> + cleanup:
> +    if (ret < 0) {
> +        VIR_FORCE_CLOSE(pair[0]);
> +        VIR_FORCE_CLOSE(pair[1]);
> +    }

...but failing to close pair[1] (fd leak), and giving the user a useless
fd.  My proposed patch tries to fix that.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 539 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140826/d663401a/attachment-0001.sig>


More information about the libvir-list mailing list