Re: [PATCH 29/34] conf: Parse <backingStore> in virDomainStorageSourceParseFull

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

 



On Mon, Mar 18, 2019 at 04:55:18PM +0100, Peter Krempa wrote:
Move parsing of <backingStore> into virDomainStorageSourceParseFull so
that it can be reused easily.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
src/conf/domain_conf.c   | 100 +++++++++++++++++++++------------------
src/conf/domain_conf.h   |   3 +-
src/conf/snapshot_conf.c |   2 +-
src/qemu/qemu_domain.c   |   2 +-
tests/qemublocktest.c    |   2 +-
5 files changed, 59 insertions(+), 50 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5790b19315..5b13402154 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9111,6 +9111,43 @@ virDomainStorageSourceParse(xmlNodePtr node,
}


+static int
+virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
+                               virStorageSourcePtr src,
+                               unsigned int flags,
+                               virDomainXMLOptionPtr xmlopt)
+{
+    VIR_XPATH_NODE_AUTORESTORE(ctxt);
+    VIR_AUTOUNREF(virStorageSourcePtr) backingStore = NULL;
+    VIR_AUTOFREE(char *) type = NULL;
+
+    if (!(ctxt->node = virXPathNode("./backingStore", ctxt)))
+        return 0;
+
+    /* terminator does not have a type */
+    if (!(type = virXMLPropString(ctxt->node, "type"))) {
+        if (!(src->backingStore = virStorageSourceNew()))
+            return -1;
+
+        return 0;
+    }
+
+    if (!(backingStore = virDomainStorageSourceParseFull("string(@type)",
+                                                         "string(./format/@type)",
+                                                         "./source",
+                                                         "string(@index)",
+                                                         false, true, ctxt, flags, xmlopt)))
+        return -1;
+
+    /* backing store is always read-only */
+    backingStore->readonly = true;
+
+    VIR_STEAL_PTR(src->backingStore, backingStore);
+
+    return 0;
+}
+
+

The movement of this function should be in a separate commit.
This one would only remove the virDomainDiskBackingStoreParse call and
add the 'true' argument.

/**
 * virDomainStorageSourceParseFull
 * @typeXPath: XPath query string for the 'type' of virStorageSource
@@ -9774,6 +9783,9 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
    /* defaults */
    def->device = VIR_DOMAIN_DISK_DEVICE_DISK;

+    if ((flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE))

Too many parentheses.

+        backingStore = false;
+
    if ((tmp = virXMLPropString(node, "device")) &&
        (def->device = virDomainDiskDeviceTypeFromString(tmp)) < 0) {
        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,

Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>

Jano

Attachment: signature.asc
Description: Digital signature

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

  Powered by Linux