|
|
d76c62 |
From 6d5174acd7530d554ac2651f3e6a5da9f69fe6e4 Mon Sep 17 00:00:00 2001
|
|
|
d76c62 |
Message-Id: <6d5174acd7530d554ac2651f3e6a5da9f69fe6e4@dist-git>
|
|
|
d76c62 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
d76c62 |
Date: Wed, 19 Feb 2020 15:10:20 +0100
|
|
|
d76c62 |
Subject: [PATCH] conf: Implement support for <slices> of disk source
|
|
|
d76c62 |
MIME-Version: 1.0
|
|
|
d76c62 |
Content-Type: text/plain; charset=UTF-8
|
|
|
d76c62 |
Content-Transfer-Encoding: 8bit
|
|
|
d76c62 |
|
|
|
d76c62 |
Implement parsing and formatting of the 'storage' slice.
|
|
|
d76c62 |
|
|
|
d76c62 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
d76c62 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
d76c62 |
(cherry picked from commit bbf5d05cfd003e33600009cac7ea98ef1539dd7c)
|
|
|
d76c62 |
|
|
|
d76c62 |
https://bugzilla.redhat.com/show_bug.cgi?id=1791788
|
|
|
d76c62 |
Message-Id: <d31bb27ae30140c9deb696972ee76a90d7bcc610.1582120424.git.pkrempa@redhat.com>
|
|
|
d76c62 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
d76c62 |
---
|
|
|
d76c62 |
src/conf/domain_conf.c | 86 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
d76c62 |
1 file changed, 86 insertions(+)
|
|
|
d76c62 |
|
|
|
d76c62 |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
d76c62 |
index b46b92aecf..5c11f49463 100644
|
|
|
d76c62 |
--- a/src/conf/domain_conf.c
|
|
|
d76c62 |
+++ b/src/conf/domain_conf.c
|
|
|
d76c62 |
@@ -9441,6 +9441,57 @@ virDomainStorageSourceParseBase(const char *type,
|
|
|
d76c62 |
}
|
|
|
d76c62 |
|
|
|
d76c62 |
|
|
|
d76c62 |
+static virStorageSourceSlicePtr
|
|
|
d76c62 |
+virDomainStorageSourceParseSlice(xmlNodePtr node,
|
|
|
d76c62 |
+ xmlXPathContextPtr ctxt)
|
|
|
d76c62 |
+{
|
|
|
d76c62 |
+ VIR_XPATH_NODE_AUTORESTORE(ctxt);
|
|
|
d76c62 |
+ g_autofree char *offset = NULL;
|
|
|
d76c62 |
+ g_autofree char *size = NULL;
|
|
|
d76c62 |
+ g_autofree virStorageSourceSlicePtr ret = g_new0(virStorageSourceSlice, 1);
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ ctxt->node = node;
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ if (!(offset = virXPathString("string(./@offset)", ctxt)) ||
|
|
|
d76c62 |
+ !(size = virXPathString("string(./@size)", ctxt))) {
|
|
|
d76c62 |
+ virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
d76c62 |
+ _("missing offset or size attribute of slice"));
|
|
|
d76c62 |
+ return NULL;
|
|
|
d76c62 |
+ }
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ if (virStrToLong_ullp(offset, NULL, 10, &ret->offset) < 0) {
|
|
|
d76c62 |
+ virReportError(VIR_ERR_XML_ERROR,
|
|
|
d76c62 |
+ _("malformed value '%s' of 'offset' attribute of slice"),
|
|
|
d76c62 |
+ offset);
|
|
|
d76c62 |
+ return NULL;
|
|
|
d76c62 |
+ }
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ if (virStrToLong_ullp(size, NULL, 10, &ret->size) < 0) {
|
|
|
d76c62 |
+ virReportError(VIR_ERR_XML_ERROR,
|
|
|
d76c62 |
+ _("malformed value '%s' of 'size' attribute of slice"),
|
|
|
d76c62 |
+ size);
|
|
|
d76c62 |
+ return NULL;
|
|
|
d76c62 |
+ }
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ return g_steal_pointer(&ret;;
|
|
|
d76c62 |
+}
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+static int
|
|
|
d76c62 |
+virDomainStorageSourceParseSlices(virStorageSourcePtr src,
|
|
|
d76c62 |
+ xmlXPathContextPtr ctxt)
|
|
|
d76c62 |
+{
|
|
|
d76c62 |
+ xmlNodePtr node;
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ if ((node = virXPathNode("./slices/slice[@type='storage']", ctxt))) {
|
|
|
d76c62 |
+ if (!(src->sliceStorage = virDomainStorageSourceParseSlice(node, ctxt)))
|
|
|
d76c62 |
+ return -1;
|
|
|
d76c62 |
+ }
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ return 0;
|
|
|
d76c62 |
+}
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+
|
|
|
d76c62 |
/**
|
|
|
d76c62 |
* virDomainStorageSourceParse:
|
|
|
d76c62 |
* @node: XML node pointing to the source element to parse
|
|
|
d76c62 |
@@ -9506,6 +9557,9 @@ virDomainStorageSourceParse(xmlNodePtr node,
|
|
|
d76c62 |
if (virDomainDiskSourcePRParse(node, ctxt, &src->pr) < 0)
|
|
|
d76c62 |
return -1;
|
|
|
d76c62 |
|
|
|
d76c62 |
+ if (virDomainStorageSourceParseSlices(src, ctxt) < 0)
|
|
|
d76c62 |
+ return -1;
|
|
|
d76c62 |
+
|
|
|
d76c62 |
if (virSecurityDeviceLabelDefParseXML(&src->seclabels, &src->nseclabels,
|
|
|
d76c62 |
ctxt, flags) < 0)
|
|
|
d76c62 |
return -1;
|
|
|
d76c62 |
@@ -24226,6 +24280,36 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr buf,
|
|
|
d76c62 |
}
|
|
|
d76c62 |
|
|
|
d76c62 |
|
|
|
d76c62 |
+static void
|
|
|
d76c62 |
+virDomainDiskSourceFormatSlice(virBufferPtr buf,
|
|
|
d76c62 |
+ const char *slicetype,
|
|
|
d76c62 |
+ virStorageSourceSlicePtr slice)
|
|
|
d76c62 |
+{
|
|
|
d76c62 |
+ g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ if (!slice)
|
|
|
d76c62 |
+ return;
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ virBufferAsprintf(&attrBuf, " type='%s'", slicetype);
|
|
|
d76c62 |
+ virBufferAsprintf(&attrBuf, " offset='%llu'", slice->offset);
|
|
|
d76c62 |
+ virBufferAsprintf(&attrBuf, " size='%llu'", slice->size);
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ virXMLFormatElement(buf, "slice", &attrBuf, NULL);
|
|
|
d76c62 |
+}
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+static void
|
|
|
d76c62 |
+virDomainDiskSourceFormatSlices(virBufferPtr buf,
|
|
|
d76c62 |
+ virStorageSourcePtr src)
|
|
|
d76c62 |
+{
|
|
|
d76c62 |
+ g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ virDomainDiskSourceFormatSlice(&childBuf, "storage", src->sliceStorage);
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ virXMLFormatElement(buf, "slices", NULL, &childBuf);
|
|
|
d76c62 |
+}
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+
|
|
|
d76c62 |
/**
|
|
|
d76c62 |
* virDomainDiskSourceFormat:
|
|
|
d76c62 |
* @buf: output buffer
|
|
|
d76c62 |
@@ -24296,6 +24380,8 @@ virDomainDiskSourceFormat(virBufferPtr buf,
|
|
|
d76c62 |
return -1;
|
|
|
d76c62 |
}
|
|
|
d76c62 |
|
|
|
d76c62 |
+ virDomainDiskSourceFormatSlices(&childBuf, src);
|
|
|
d76c62 |
+
|
|
|
d76c62 |
if (src->type != VIR_STORAGE_TYPE_NETWORK)
|
|
|
d76c62 |
virDomainSourceDefFormatSeclabel(&childBuf, src->nseclabels,
|
|
|
d76c62 |
src->seclabels, flags);
|
|
|
d76c62 |
--
|
|
|
d76c62 |
2.25.0
|
|
|
d76c62 |
|