[libvirt] [PATCH 29/34] conf: Parse <backingStore> in virDomainStorageSourceParseFull
Ján Tomko
jtomko at redhat.com
Tue Mar 19 14:39:17 UTC 2019
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 at redhat.com>
>---
> 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 at redhat.com>
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190319/08637ca4/attachment-0001.sig>
More information about the libvir-list
mailing list