]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add new virDomainDefineXMLFlags public API
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 18 Nov 2014 13:56:20 +0000 (13:56 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 13 Jan 2015 10:35:09 +0000 (10:35 +0000)
The virDomainDefineXML method is one of the few that still lacks
an 'unsigned int flags' parameter. This will be needed for adding
XML validation to this API. virDomainCreateXML fortunately already
has flags.

include/libvirt/libvirt-domain.h
src/driver-hypervisor.h
src/libvirt-domain.c
src/libvirt_public.syms
src/remote/remote_driver.c
src/remote/remote_protocol.x
src/remote_protocol-structs

index 0b1a2d6dd4d95a7436258881cd59da46ecbcc83d..3a835717ed1b0c65e548205bfec94aee48366600 100644 (file)
@@ -1422,6 +1422,10 @@ int                     virDomainMemoryPeek (virDomainPtr dom,
  */
 virDomainPtr            virDomainDefineXML      (virConnectPtr conn,
                                                  const char *xml);
+
+virDomainPtr            virDomainDefineXMLFlags (virConnectPtr conn,
+                                                 const char *xml,
+                                                 unsigned int flags);
 int                     virDomainUndefine       (virDomainPtr domain);
 
 typedef enum {
index 9f26b13c5ae9461e7027ff88e0fe0d4f7517ebaf..a1d2a0aec28cb75ec71ae805d108a8d17c7e5b28 100644 (file)
@@ -314,6 +314,10 @@ typedef int
 typedef virDomainPtr
 (*virDrvDomainDefineXML)(virConnectPtr conn,
                          const char *xml);
+typedef virDomainPtr
+(*virDrvDomainDefineXMLFlags)(virConnectPtr conn,
+                              const char *xml,
+                              unsigned int flags);
 
 typedef int
 (*virDrvDomainUndefine)(virDomainPtr dom);
@@ -1265,6 +1269,7 @@ struct _virHypervisorDriver {
     virDrvDomainCreateWithFlags domainCreateWithFlags;
     virDrvDomainCreateWithFiles domainCreateWithFiles;
     virDrvDomainDefineXML domainDefineXML;
+    virDrvDomainDefineXMLFlags domainDefineXMLFlags;
     virDrvDomainUndefine domainUndefine;
     virDrvDomainUndefineFlags domainUndefineFlags;
     virDrvDomainAttachDevice domainAttachDevice;
index 6ec68aa71770c72d7ebe72d78dd5069189f94d1d..0b4c09722b9c07648c73d96e6d1d505468c5b1c2 100644 (file)
@@ -6475,6 +6475,54 @@ virDomainDefineXML(virConnectPtr conn, const char *xml)
 }
 
 
+/**
+ * virDomainDefineXMLFlags:
+ * @conn: pointer to the hypervisor connection
+ * @xml: the XML description for the domain, preferably in UTF-8
+ * @flags: currently unused, pass 0
+ *
+ * Defines a domain, but does not start it.
+ * This definition is persistent, until explicitly undefined with
+ * virDomainUndefine(). A previous definition for this domain would be
+ * overridden if it already exists.
+ *
+ * Some hypervisors may prevent this operation if there is a current
+ * block copy operation on a transient domain with the same id as the
+ * domain being defined; in that case, use virDomainBlockJobAbort() to
+ * stop the block copy first.
+ *
+ * virDomainFree should be used to free the resources after the
+ * domain object is no longer needed.
+ *
+ * Returns NULL in case of error, a pointer to the domain otherwise
+ */
+virDomainPtr
+virDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
+{
+    VIR_DEBUG("conn=%p, xml=%s flags=%x", conn, xml, flags);
+
+    virResetLastError();
+
+    virCheckConnectReturn(conn, NULL);
+    virCheckReadOnlyGoto(conn->flags, error);
+    virCheckNonNullArgGoto(xml, error);
+
+    if (conn->driver->domainDefineXMLFlags) {
+        virDomainPtr ret;
+        ret = conn->driver->domainDefineXMLFlags(conn, xml, flags);
+        if (!ret)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(conn);
+    return NULL;
+}
+
+
 /**
  * virDomainUndefine:
  * @domain: pointer to a defined domain
index e4c2df198fd96ebef6d9d9a3b9cfea1c74f10893..4ea5cff6558b43aff3c0ad7a2f2be8b35591a8d7 100644 (file)
@@ -690,4 +690,9 @@ LIBVIRT_1.2.11 {
         virDomainGetFSInfo;
 } LIBVIRT_1.2.9;
 
+LIBVIRT_1.2.12 {
+    global:
+        virDomainDefineXMLFlags;
+} LIBVIRT_1.2.11;
+
 # .... define new API here using predicted next version number ....
index 999f16d0e1b4851fdfcd0ba40173bfa2a00e1944..3cc603f973dac7c809faff4321534ccd4e7c28db 100644 (file)
@@ -8151,6 +8151,7 @@ static virHypervisorDriver hypervisor_driver = {
     .domainCreateWithFlags = remoteDomainCreateWithFlags, /* 0.8.2 */
     .domainCreateWithFiles = remoteDomainCreateWithFiles, /* 1.1.1 */
     .domainDefineXML = remoteDomainDefineXML, /* 0.3.0 */
+    .domainDefineXMLFlags = remoteDomainDefineXMLFlags, /* 1.2.12 */
     .domainUndefine = remoteDomainUndefine, /* 0.3.0 */
     .domainUndefineFlags = remoteDomainUndefineFlags, /* 0.9.4 */
     .domainAttachDevice = remoteDomainAttachDevice, /* 0.3.0 */
index cbd3ec733ed98de56944210a27362ae2e68108d1..d91fbe0ee4a3a225870de31e97571b68edda221b 100644 (file)
@@ -1062,6 +1062,15 @@ struct remote_domain_define_xml_ret {
     remote_nonnull_domain dom;
 };
 
+struct remote_domain_define_xml_flags_args {
+    remote_nonnull_string xml;
+    unsigned int flags;
+};
+
+struct remote_domain_define_xml_flags_ret {
+    remote_nonnull_domain dom;
+};
+
 struct remote_domain_undefine_args {
     remote_nonnull_domain dom;
 };
@@ -5550,5 +5559,13 @@ enum remote_procedure {
      * @generate: none
      * @acl: domain:fs_freeze
      */
-    REMOTE_PROC_DOMAIN_GET_FSINFO = 349
+    REMOTE_PROC_DOMAIN_GET_FSINFO = 349,
+
+    /**
+     * @priority: high
+     * @generate: both
+     * @acl: domain:write
+     * @acl: domain:save
+     */
+    REMOTE_PROC_DOMAIN_DEFINE_XML_FLAGS = 350
 };
index 2907fd53bd28908a41395f171dffeff11938011e..df6eaf3755d8bc9afb24b542fe10d41bf71b449f 100644 (file)
@@ -686,6 +686,13 @@ struct remote_domain_define_xml_args {
 struct remote_domain_define_xml_ret {
         remote_nonnull_domain      dom;
 };
+struct remote_domain_define_xml_flags_args {
+        remote_nonnull_string      xml;
+        u_int                      flags;
+};
+struct remote_domain_define_xml_flags_ret {
+        remote_nonnull_domain      dom;
+};
 struct remote_domain_undefine_args {
         remote_nonnull_domain      dom;
 };
@@ -2955,4 +2962,5 @@ enum remote_procedure {
         REMOTE_PROC_NODE_ALLOC_PAGES = 347,
         REMOTE_PROC_DOMAIN_EVENT_CALLBACK_AGENT_LIFECYCLE = 348,
         REMOTE_PROC_DOMAIN_GET_FSINFO = 349,
+        REMOTE_PROC_DOMAIN_DEFINE_XML_FLAGS = 350,
 };