[PATCH 1/5] libvirt: introduce domainCreateWithFlags API

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

 



Persistent domain creation needs the same features as transient
domains, but virDomainCreate lacks the flags argument present in
virDomainCreateXML.  virDomainCreateFlags is already claimed as
a public enum, so we have to break convention and expose
virDomainCreateWithFlags.

* include/libvirt/libvirt.h.in (virDomainCreateWithFlags): Add.
* src/driver.h (virDrvDomainCreateWithFlags): Internal API.
* src/libvirt.c (virDomainCreateWithFlags): Glue public API to
driver API.
* src/libvirt_public.syms (LIBVIRT_0.8.2): Expose public API.
* src/esx/esx_driver.c (esxDriver): Add stub for driver.
* src/lxc/lxc_driver.c (lxcDriver): Likewise.
* src/opennebula/one_driver.c (oneDriver): Likewise.
* src/openvz/openvz_driver.c (openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemuDriver): Likewise.
* src/remote/remote_driver.c (remote_driver): Likewise.
* src/test/test_driver.c (testDriver): Likewise.
* src/uml/uml_driver.c (umlDriver): Likewise.
* src/vbox/vbox_tmpl.c (Driver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDriver): Likewise.
---
 include/libvirt/libvirt.h.in |    2 +
 src/driver.h                 |    6 ++++-
 src/esx/esx_driver.c         |    1 +
 src/libvirt.c                |   45 +++++++++++++++++++++++++++++++++++++++++-
 src/libvirt_public.syms      |    6 +++++
 src/lxc/lxc_driver.c         |    1 +
 src/opennebula/one_driver.c  |    1 +
 src/openvz/openvz_driver.c   |    1 +
 src/phyp/phyp_driver.c       |    1 +
 src/qemu/qemu_driver.c       |    1 +
 src/remote/remote_driver.c   |    1 +
 src/test/test_driver.c       |    1 +
 src/uml/uml_driver.c         |    1 +
 src/vbox/vbox_tmpl.c         |    1 +
 src/xen/xen_driver.c         |    1 +
 src/xenapi/xenapi_driver.c   |    1 +
 16 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 81bfa1a..b45f7ec 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -799,6 +799,8 @@ int                     virConnectListDefinedDomains (virConnectPtr conn,
                                                  char **const names,
                                                  int maxnames);
 int                     virDomainCreate         (virDomainPtr domain);
+int                     virDomainCreateWithFlags (virDomainPtr domain,
+                                                 unsigned int flags);

 int                     virDomainGetAutostart   (virDomainPtr domain,
                                                  int *autostart);
diff --git a/src/driver.h b/src/driver.h
index 0975b59..22e3db6 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -161,6 +161,9 @@ typedef int
         (*virDrvNumOfDefinedDomains)	(virConnectPtr conn);
 typedef int
         (*virDrvDomainCreate)		(virDomainPtr dom);
+typedef int
+        (*virDrvDomainCreateWithFlags)	(virDomainPtr dom,
+                                         unsigned int flags);
 typedef virDomainPtr
         (*virDrvDomainDefineXML)	(virConnectPtr conn,
                                          const char *xml);
@@ -468,7 +471,7 @@ typedef int
  *  - close
  */
 struct _virDriver {
-    int	       no;	/* the number virDrvNo */
+    int        no;	/* the number virDrvNo */
     const char * name;	/* the name of the driver */
     virDrvOpen			open;
     virDrvClose			close;
@@ -511,6 +514,7 @@ struct _virDriver {
     virDrvListDefinedDomains	listDefinedDomains;
     virDrvNumOfDefinedDomains	numOfDefinedDomains;
     virDrvDomainCreate		domainCreate;
+    virDrvDomainCreateWithFlags	domainCreateWithFlags;
     virDrvDomainDefineXML           domainDefineXML;
     virDrvDomainUndefine            domainUndefine;
     virDrvDomainAttachDevice	domainAttachDevice;
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index c5cf2e8..0b2a3b6 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -3694,6 +3694,7 @@ static virDriver esxDriver = {
     esxListDefinedDomains,           /* listDefinedDomains */
     esxNumberOfDefinedDomains,       /* numOfDefinedDomains */
     esxDomainCreate,                 /* domainCreate */
+    NULL,                            /* domainCreateWithFlags */
     esxDomainDefineXML,              /* domainDefineXML */
     esxDomainUndefine,               /* domainUndefine */
     NULL,                            /* domainAttachDevice */
diff --git a/src/libvirt.c b/src/libvirt.c
index 2754fd0..6332ac7 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -4850,7 +4850,7 @@ error:
  * virDomainCreate:
  * @domain: pointer to a defined domain
  *
- * launch a defined domain. If the call succeed the domain moves from the
+ * Launch a defined domain. If the call succeeds the domain moves from the
  * defined to the running domains pools.
  *
  * Returns 0 in case of success, -1 in case of error
@@ -4889,6 +4889,49 @@ error:
 }

 /**
+ * virDomainCreateWithFlags:
+ * @domain: pointer to a defined domain
+ * @flags: bitwise-or of supported virDomainCreateFlags
+ *
+ * Launch a defined domain. If the call succeeds the domain moves from the
+ * defined to the running domains pools.
+ *
+ * Returns 0 in case of success, -1 in case of error
+ */
+int
+virDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) {
+    virConnectPtr conn;
+    DEBUG("domain=%p, flags=%d", domain, flags);
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+        virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+        virDispatchError(NULL);
+        return (-1);
+    }
+    conn = domain->conn;
+    if (conn->flags & VIR_CONNECT_RO) {
+        virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+        goto error;
+    }
+
+    if (conn->driver->domainCreateWithFlags) {
+        int ret;
+        ret = conn->driver->domainCreateWithFlags (domain, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    virDispatchError(domain->conn);
+    return -1;
+}
+
+/**
  * virDomainGetAutostart:
  * @domain: a domain object
  * @autostart: the value returned
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 81465d3..849c163 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -399,4 +399,10 @@ LIBVIRT_0.8.1 {
         virDomainGetBlockInfo;
 } LIBVIRT_0.8.0;

+
+LIBVIRT_0.8.2 {
+    global:
+        virDomainCreateWithFlags;
+} LIBVIRT_0.8.1;
+
 # .... define new API here using predicted next version number ....
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index c3f65cb..2027abf 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2557,6 +2557,7 @@ static virDriver lxcDriver = {
     lxcListDefinedDomains, /* listDefinedDomains */
     lxcNumDefinedDomains, /* numOfDefinedDomains */
     lxcDomainStart, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     lxcDomainDefine, /* domainDefineXML */
     lxcDomainUndefine, /* domainUndefine */
     NULL, /* domainAttachDevice */
diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c
index fd99f0b..caa0d67 100644
--- a/src/opennebula/one_driver.c
+++ b/src/opennebula/one_driver.c
@@ -755,6 +755,7 @@ static virDriver oneDriver = {
     oneListDefinedDomains, /* listDefinedDomains */
     oneNumDefinedDomains, /* numOfDefinedDomains */
     oneDomainStart, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     oneDomainDefine, /* domainDefineXML */
     oneDomainUndefine, /* domainUndefine */
     NULL, /* domainAttachDevice */
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 2dd27d9..8ee9ad5 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1507,6 +1507,7 @@ static virDriver openvzDriver = {
     openvzListDefinedDomains, /* listDefinedDomains */
     openvzNumDefinedDomains, /* numOfDefinedDomains */
     openvzDomainCreate, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     openvzDomainDefineXML, /* domainDefineXML */
     openvzDomainUndefine, /* domainUndefine */
     NULL, /* domainAttachDevice */
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 0f4bc20..c04a487 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1609,6 +1609,7 @@ virDriver phypDriver = {
     phypListDefinedDomains,     /* listDefinedDomains */
     phypNumDefinedDomains,      /* numOfDefinedDomains */
     NULL,                       /* domainCreate */
+    NULL,                       /* domainCreateWithFlags */
     NULL,                       /* domainDefineXML */
     NULL,                       /* domainUndefine */
     NULL,                       /* domainAttachDevice */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index bc8dcfa..760a27a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12195,6 +12195,7 @@ static virDriver qemuDriver = {
     qemudListDefinedDomains, /* listDefinedDomains */
     qemudNumDefinedDomains, /* numOfDefinedDomains */
     qemudDomainStart, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     qemudDomainDefine, /* domainDefineXML */
     qemudDomainUndefine, /* domainUndefine */
     qemudDomainAttachDevice, /* domainAttachDevice */
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 80977a3..3f37cc8 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -10215,6 +10215,7 @@ static virDriver remote_driver = {
     remoteListDefinedDomains, /* listDefinedDomains */
     remoteNumOfDefinedDomains, /* numOfDefinedDomains */
     remoteDomainCreate, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     remoteDomainDefineXML, /* domainDefineXML */
     remoteDomainUndefine, /* domainUndefine */
     remoteDomainAttachDevice, /* domainAttachDevice */
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 5b8105d..13eb5e0 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -5261,6 +5261,7 @@ static virDriver testDriver = {
     testListDefinedDomains, /* listDefinedDomains */
     testNumOfDefinedDomains, /* numOfDefinedDomains */
     testDomainCreate, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     testDomainDefineXML, /* domainDefineXML */
     testDomainUndefine, /* domainUndefine */
     NULL, /* domainAttachDevice */
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 3111211..4978e48 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1892,6 +1892,7 @@ static virDriver umlDriver = {
     umlListDefinedDomains, /* listDefinedDomains */
     umlNumDefinedDomains, /* numOfDefinedDomains */
     umlDomainStart, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     umlDomainDefine, /* domainDefineXML */
     umlDomainUndefine, /* domainUndefine */
     NULL, /* domainAttachDevice */
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 1372f96..3d94ce9 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -8173,6 +8173,7 @@ virDriver NAME(Driver) = {
     vboxListDefinedDomains, /* listDefinedDomains */
     vboxNumOfDefinedDomains, /* numOfDefinedDomains */
     vboxDomainCreate, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     vboxDomainDefineXML, /* domainDefineXML */
     vboxDomainUndefine, /* domainUndefine */
     vboxDomainAttachDevice, /* domainAttachDevice */
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 91f0acd..ca6b246 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1941,6 +1941,7 @@ static virDriver xenUnifiedDriver = {
     xenUnifiedListDefinedDomains, /* listDefinedDomains */
     xenUnifiedNumOfDefinedDomains, /* numOfDefinedDomains */
     xenUnifiedDomainCreate, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     xenUnifiedDomainDefineXML, /* domainDefineXML */
     xenUnifiedDomainUndefine, /* domainUndefine */
     xenUnifiedDomainAttachDevice, /* domainAttachDevice */
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index e3bcb63..518c4a7 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -1744,6 +1744,7 @@ static virDriver xenapiDriver = {
     xenapiListDefinedDomains, /* listDefinedDomains */
     xenapiNumOfDefinedDomains, /* numOfDefinedDomains */
     xenapiDomainCreate, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     xenapiDomainDefineXML, /* domainDefineXML */
     xenapiDomainUndefine, /* domainUndefine */
     NULL, /* domainAttachDevice */
-- 
1.7.0.1

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