[PATCH 1/3] Introduce virDomainOpenGraphicsFD API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Define the public API implementation and declare internal
driver prototype.
---
 include/libvirt/libvirt.h.in |  5 ++++
 src/driver.h                 |  7 ++++++
 src/libvirt.c                | 58 ++++++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms      |  5 ++++
 4 files changed, 75 insertions(+)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 47ea695..153b386 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -5321,6 +5321,11 @@ int virDomainOpenGraphics(virDomainPtr dom,
                           int fd,
                           unsigned int flags);
 
+int virDomainOpenGraphicsFD(virDomainPtr dom,
+                            unsigned int idx,
+                            int *fd,
+                            unsigned int flags);
+
 int virDomainInjectNMI(virDomainPtr domain, unsigned int flags);
 
 int virDomainFSTrim(virDomainPtr dom,
diff --git a/src/driver.h b/src/driver.h
index ba7c1fc..39bf219 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -888,6 +888,12 @@ typedef int
                             unsigned int flags);
 
 typedef int
+(*virDrvDomainOpenGraphicsFD)(virDomainPtr dom,
+                              unsigned int idx,
+                              int *fd,
+                              unsigned int flags);
+
+typedef int
 (*virDrvDomainInjectNMI)(virDomainPtr dom,
                          unsigned int flags);
 
@@ -1369,6 +1375,7 @@ struct _virDriver {
     virDrvDomainOpenConsole domainOpenConsole;
     virDrvDomainOpenChannel domainOpenChannel;
     virDrvDomainOpenGraphics domainOpenGraphics;
+    virDrvDomainOpenGraphicsFD domainOpenGraphicsFD;
     virDrvDomainInjectNMI domainInjectNMI;
     virDrvDomainMigrateBegin3 domainMigrateBegin3;
     virDrvDomainMigratePrepare3 domainMigratePrepare3;
diff --git a/src/libvirt.c b/src/libvirt.c
index 8349261..9de1e44 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -20182,6 +20182,64 @@ virDomainOpenGraphics(virDomainPtr dom,
 
 
 /**
+ * virDomainOpenGraphicsFD:
+ * @dom: pointer to domain object
+ * @idx: index of graphics config to open
+ * @fd: returned file descriptor
+ * @flags: bitwise-OR of virDomainOpenGraphicsFlags
+ *
+ * This will create a socket pair connected to the graphics backend of @dom.
+ * One pair will be returned as @fd.
+ * If @dom has multiple graphics backends configured, then @idx will determine
+ * which one is opened, starting from @idx 0.
+ *
+ * To disable any authentication, pass the VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH
+ * constant for @flags.
+ *
+ * This method can only be used when connected to a local
+ * libvirt hypervisor, over a UNIX domain socket. Attempts
+ * to use this method over a TCP connection will always fail
+ *
+ * Returns 0 on success, -1 on failure
+ */
+int
+virDomainOpenGraphicsFD(virDomainPtr dom,
+                        unsigned int idx,
+                        int *fd,
+                        unsigned int flags)
+{
+    VIR_DOMAIN_DEBUG(dom, "idx=%u, fd=%p, flags=%x",
+                     idx, fd, flags);
+
+    virResetLastError();
+
+    virCheckDomainReturn(dom, -1);
+    virCheckNonNullArgGoto(fd, error);
+
+    virCheckReadOnlyGoto(dom->conn->flags, error);
+
+    if (!VIR_DRV_SUPPORTS_FEATURE(dom->conn->driver, dom->conn,
+                                  VIR_DRV_FEATURE_FD_PASSING)) {
+        virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
+                       _("fd passing is not supported by this connection"));
+        goto error;
+    }
+
+    if (dom->conn->driver->domainOpenGraphicsFD) {
+        int ret;
+        ret = dom->conn->driver->domainOpenGraphicsFD(dom, idx, fd, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(dom->conn);
+    return -1;
+}
+/**
  * virConnectSetKeepAlive:
  * @conn: pointer to a hypervisor connection
  * @interval: number of seconds of inactivity before a keepalive message is sent
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 9f4016a..ce5aeeb 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -670,4 +670,9 @@ LIBVIRT_1.2.7 {
         virConnectGetDomainCapabilities;
 } LIBVIRT_1.2.6;
 
+LIBVIRT_1.2.8 {
+     global:
+         virDomainOpenGraphicsFD;
+} LIBVIRT_1.2.7;
+
 # .... define new API here using predicted next version number ....
-- 
1.8.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]