]> xenbits.xensource.com Git - libvirt.git/commitdiff
libvirt: introduce domainCreateWithFlags API
authorEric Blake <eblake@redhat.com>
Thu, 10 Jun 2010 13:28:05 +0000 (07:28 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 15 Jun 2010 13:32:41 +0000 (07:32 -0600)
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.

16 files changed:
include/libvirt/libvirt.h.in
src/driver.h
src/esx/esx_driver.c
src/libvirt.c
src/libvirt_public.syms
src/lxc/lxc_driver.c
src/opennebula/one_driver.c
src/openvz/openvz_driver.c
src/phyp/phyp_driver.c
src/qemu/qemu_driver.c
src/remote/remote_driver.c
src/test/test_driver.c
src/uml/uml_driver.c
src/vbox/vbox_tmpl.c
src/xen/xen_driver.c
src/xenapi/xenapi_driver.c

index 81bfa1a8796fb00f573be72ce52bf7279c8ffd23..b45f7ecaf5edeabfc2961b9856d38aada774ff9c 100644 (file)
@@ -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);
index 0975b590d85a8c36d3b32a786852fe7c1f323fad..22e3db60e6cbb86fb92183d27cb4d80513b1029c 100644 (file)
@@ -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;
index c5cf2e8485d6e3a5afa44a4408b857d17df87ab7..0b2a3b6a5cc71d3c6fad8755c58fa20829c697cf 100644 (file)
@@ -3694,6 +3694,7 @@ static virDriver esxDriver = {
     esxListDefinedDomains,           /* listDefinedDomains */
     esxNumberOfDefinedDomains,       /* numOfDefinedDomains */
     esxDomainCreate,                 /* domainCreate */
+    NULL,                            /* domainCreateWithFlags */
     esxDomainDefineXML,              /* domainDefineXML */
     esxDomainUndefine,               /* domainUndefine */
     NULL,                            /* domainAttachDevice */
index fd3587f3bf4be5cfc99384307ffcb40ad9778da3..d1b210d08213b01aad87008ec61352bfed296dfc 100644 (file)
@@ -4878,7 +4878,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
@@ -4916,6 +4916,49 @@ error:
     return -1;
 }
 
+/**
+ * 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
index 81465d3e1d35861b9a23afcefc0bf481fbc5b6a2..849c1631c75f4f2937844e0748d71c25d0ce462e 100644 (file)
@@ -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 ....
index c3f65cb9b21510361d14f57b9a4e61fedeb45521..2027abfea52c77bc91951f0a881d3df189f45766 100644 (file)
@@ -2557,6 +2557,7 @@ static virDriver lxcDriver = {
     lxcListDefinedDomains, /* listDefinedDomains */
     lxcNumDefinedDomains, /* numOfDefinedDomains */
     lxcDomainStart, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     lxcDomainDefine, /* domainDefineXML */
     lxcDomainUndefine, /* domainUndefine */
     NULL, /* domainAttachDevice */
index fd99f0b2e51c13f07164c63df2dcf0b6c5331a8e..caa0d67b36561e48269053a8759f2e89ef2c4123 100644 (file)
@@ -755,6 +755,7 @@ static virDriver oneDriver = {
     oneListDefinedDomains, /* listDefinedDomains */
     oneNumDefinedDomains, /* numOfDefinedDomains */
     oneDomainStart, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     oneDomainDefine, /* domainDefineXML */
     oneDomainUndefine, /* domainUndefine */
     NULL, /* domainAttachDevice */
index 2dd27d9af796dfd0eecf1514f08309cb9d084793..8ee9ad53724e9873c2f05235e3609a0bfe72bb77 100644 (file)
@@ -1507,6 +1507,7 @@ static virDriver openvzDriver = {
     openvzListDefinedDomains, /* listDefinedDomains */
     openvzNumDefinedDomains, /* numOfDefinedDomains */
     openvzDomainCreate, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     openvzDomainDefineXML, /* domainDefineXML */
     openvzDomainUndefine, /* domainUndefine */
     NULL, /* domainAttachDevice */
index 0f4bc20028eadc066fc23e24c36fdb4200034195..c04a48721e0af0188659c77c72470e6dfd926d78 100644 (file)
@@ -1609,6 +1609,7 @@ virDriver phypDriver = {
     phypListDefinedDomains,     /* listDefinedDomains */
     phypNumDefinedDomains,      /* numOfDefinedDomains */
     NULL,                       /* domainCreate */
+    NULL,                       /* domainCreateWithFlags */
     NULL,                       /* domainDefineXML */
     NULL,                       /* domainUndefine */
     NULL,                       /* domainAttachDevice */
index bc8dcfaf02aa6043231696d144716171962b36b1..760a27a92badc4bef74e2faa7962a948466f6820 100644 (file)
@@ -12195,6 +12195,7 @@ static virDriver qemuDriver = {
     qemudListDefinedDomains, /* listDefinedDomains */
     qemudNumDefinedDomains, /* numOfDefinedDomains */
     qemudDomainStart, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     qemudDomainDefine, /* domainDefineXML */
     qemudDomainUndefine, /* domainUndefine */
     qemudDomainAttachDevice, /* domainAttachDevice */
index 80977a33bfe70b10988a9d62c49a47876b21268f..3f37cc8334cbf904a3d4929550026c83dafa7044 100644 (file)
@@ -10215,6 +10215,7 @@ static virDriver remote_driver = {
     remoteListDefinedDomains, /* listDefinedDomains */
     remoteNumOfDefinedDomains, /* numOfDefinedDomains */
     remoteDomainCreate, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     remoteDomainDefineXML, /* domainDefineXML */
     remoteDomainUndefine, /* domainUndefine */
     remoteDomainAttachDevice, /* domainAttachDevice */
index 5b8105df1e16d941323d9ee0e3eb1291180122bd..13eb5e076d8b4124ac5c3fce202819545922d414 100644 (file)
@@ -5261,6 +5261,7 @@ static virDriver testDriver = {
     testListDefinedDomains, /* listDefinedDomains */
     testNumOfDefinedDomains, /* numOfDefinedDomains */
     testDomainCreate, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     testDomainDefineXML, /* domainDefineXML */
     testDomainUndefine, /* domainUndefine */
     NULL, /* domainAttachDevice */
index 1cbd0bd81c8234f7069808fc3794913229b2ad88..72b09cd2af32bffd6f08c953585ddc9cea9f7ea2 100644 (file)
@@ -1892,6 +1892,7 @@ static virDriver umlDriver = {
     umlListDefinedDomains, /* listDefinedDomains */
     umlNumDefinedDomains, /* numOfDefinedDomains */
     umlDomainStart, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     umlDomainDefine, /* domainDefineXML */
     umlDomainUndefine, /* domainUndefine */
     NULL, /* domainAttachDevice */
index dfa76a67050aca0f1222c0ef995cba5d4da82b8c..6b4eb40de0b5aa05e781c89fa23b0754b9e2a876 100644 (file)
@@ -8177,6 +8177,7 @@ virDriver NAME(Driver) = {
     vboxListDefinedDomains, /* listDefinedDomains */
     vboxNumOfDefinedDomains, /* numOfDefinedDomains */
     vboxDomainCreate, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     vboxDomainDefineXML, /* domainDefineXML */
     vboxDomainUndefine, /* domainUndefine */
     vboxDomainAttachDevice, /* domainAttachDevice */
index 91f0acd2c9a61ed82a343f8c00d6121fac1557fe..ca6b246f5838b65e36666190ca0dd83cef41bc6c 100644 (file)
@@ -1941,6 +1941,7 @@ static virDriver xenUnifiedDriver = {
     xenUnifiedListDefinedDomains, /* listDefinedDomains */
     xenUnifiedNumOfDefinedDomains, /* numOfDefinedDomains */
     xenUnifiedDomainCreate, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     xenUnifiedDomainDefineXML, /* domainDefineXML */
     xenUnifiedDomainUndefine, /* domainUndefine */
     xenUnifiedDomainAttachDevice, /* domainAttachDevice */
index e3bcb63465ef0cc98e2324688ab382e8a2c1f9d0..518c4a7438a1c2dbe6354f4ea4df4610f00c55af 100644 (file)
@@ -1744,6 +1744,7 @@ static virDriver xenapiDriver = {
     xenapiListDefinedDomains, /* listDefinedDomains */
     xenapiNumOfDefinedDomains, /* numOfDefinedDomains */
     xenapiDomainCreate, /* domainCreate */
+    NULL, /* domainCreateWithFlags */
     xenapiDomainDefineXML, /* domainDefineXML */
     xenapiDomainUndefine, /* domainUndefine */
     NULL, /* domainAttachDevice */