|
|
fbe740 |
From 5322d68b1c1ce4b8db415e691b666e1aae14ce8b Mon Sep 17 00:00:00 2001
|
|
|
fbe740 |
Message-Id: <5322d68b1c1ce4b8db415e691b666e1aae14ce8b@dist-git>
|
|
|
fbe740 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
fbe740 |
Date: Wed, 19 Feb 2020 15:10:06 +0100
|
|
|
fbe740 |
Subject: [PATCH] virStorageSourceParseBackingJSON: Pass around original
|
|
|
fbe740 |
backing file string
|
|
|
fbe740 |
MIME-Version: 1.0
|
|
|
fbe740 |
Content-Type: text/plain; charset=UTF-8
|
|
|
fbe740 |
Content-Transfer-Encoding: 8bit
|
|
|
fbe740 |
|
|
|
fbe740 |
There are a few error messages which might want to report the original
|
|
|
fbe740 |
backing store string. Pass it around rather than trying to re-generate
|
|
|
fbe740 |
it.
|
|
|
fbe740 |
|
|
|
fbe740 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
(cherry picked from commit 4a6bc568cd485f8f252a4750c5a67735f15ff82d)
|
|
|
fbe740 |
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1791788
|
|
|
fbe740 |
Message-Id: <09648d6aeb27261a420b144c53360158b1e367d0.1582120424.git.pkrempa@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
---
|
|
|
fbe740 |
src/util/virstoragefile.c | 31 ++++++++++++++++++++-----------
|
|
|
fbe740 |
1 file changed, 20 insertions(+), 11 deletions(-)
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
|
|
|
fbe740 |
index 7a2af0ad94..05f17224f4 100644
|
|
|
fbe740 |
--- a/src/util/virstoragefile.c
|
|
|
fbe740 |
+++ b/src/util/virstoragefile.c
|
|
|
fbe740 |
@@ -3051,12 +3051,14 @@ virStorageSourceParseBackingColon(virStorageSourcePtr src,
|
|
|
fbe740 |
|
|
|
fbe740 |
static int
|
|
|
fbe740 |
virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src,
|
|
|
fbe740 |
- virJSONValuePtr json);
|
|
|
fbe740 |
+ virJSONValuePtr json,
|
|
|
fbe740 |
+ const char *jsonstr);
|
|
|
fbe740 |
|
|
|
fbe740 |
|
|
|
fbe740 |
static int
|
|
|
fbe740 |
virStorageSourceParseBackingJSONPath(virStorageSourcePtr src,
|
|
|
fbe740 |
virJSONValuePtr json,
|
|
|
fbe740 |
+ const char *jsonstr G_GNUC_UNUSED,
|
|
|
fbe740 |
int type)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
const char *path;
|
|
|
fbe740 |
@@ -3101,6 +3103,7 @@ virStorageSourceParseBackingJSONUriStr(virStorageSourcePtr src,
|
|
|
fbe740 |
static int
|
|
|
fbe740 |
virStorageSourceParseBackingJSONUri(virStorageSourcePtr src,
|
|
|
fbe740 |
virJSONValuePtr json,
|
|
|
fbe740 |
+ const char *jsonstr G_GNUC_UNUSED,
|
|
|
fbe740 |
int protocol)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
const char *uri;
|
|
|
fbe740 |
@@ -3204,6 +3207,7 @@ virStorageSourceParseBackingJSONSocketAddress(virStorageNetHostDefPtr host,
|
|
|
fbe740 |
static int
|
|
|
fbe740 |
virStorageSourceParseBackingJSONGluster(virStorageSourcePtr src,
|
|
|
fbe740 |
virJSONValuePtr json,
|
|
|
fbe740 |
+ const char *jsonstr G_GNUC_UNUSED,
|
|
|
fbe740 |
int opaque G_GNUC_UNUSED)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
const char *uri = virJSONValueObjectGetString(json, "filename");
|
|
|
fbe740 |
@@ -3257,6 +3261,7 @@ virStorageSourceParseBackingJSONGluster(virStorageSourcePtr src,
|
|
|
fbe740 |
static int
|
|
|
fbe740 |
virStorageSourceParseBackingJSONiSCSI(virStorageSourcePtr src,
|
|
|
fbe740 |
virJSONValuePtr json,
|
|
|
fbe740 |
+ const char *jsonstr G_GNUC_UNUSED,
|
|
|
fbe740 |
int opaque G_GNUC_UNUSED)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
const char *transport = virJSONValueObjectGetString(json, "transport");
|
|
|
fbe740 |
@@ -3326,6 +3331,7 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSourcePtr src,
|
|
|
fbe740 |
static int
|
|
|
fbe740 |
virStorageSourceParseBackingJSONNbd(virStorageSourcePtr src,
|
|
|
fbe740 |
virJSONValuePtr json,
|
|
|
fbe740 |
+ const char *jsonstr G_GNUC_UNUSED,
|
|
|
fbe740 |
int opaque G_GNUC_UNUSED)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
const char *path = virJSONValueObjectGetString(json, "path");
|
|
|
fbe740 |
@@ -3373,6 +3379,7 @@ virStorageSourceParseBackingJSONNbd(virStorageSourcePtr src,
|
|
|
fbe740 |
static int
|
|
|
fbe740 |
virStorageSourceParseBackingJSONSheepdog(virStorageSourcePtr src,
|
|
|
fbe740 |
virJSONValuePtr json,
|
|
|
fbe740 |
+ const char *jsonstr G_GNUC_UNUSED,
|
|
|
fbe740 |
int opaque G_GNUC_UNUSED)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
const char *filename;
|
|
|
fbe740 |
@@ -3416,6 +3423,7 @@ virStorageSourceParseBackingJSONSheepdog(virStorageSourcePtr src,
|
|
|
fbe740 |
static int
|
|
|
fbe740 |
virStorageSourceParseBackingJSONSSH(virStorageSourcePtr src,
|
|
|
fbe740 |
virJSONValuePtr json,
|
|
|
fbe740 |
+ const char *jsonstr G_GNUC_UNUSED,
|
|
|
fbe740 |
int opaque G_GNUC_UNUSED)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
const char *path = virJSONValueObjectGetString(json, "path");
|
|
|
fbe740 |
@@ -3458,6 +3466,7 @@ virStorageSourceParseBackingJSONSSH(virStorageSourcePtr src,
|
|
|
fbe740 |
static int
|
|
|
fbe740 |
virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src,
|
|
|
fbe740 |
virJSONValuePtr json,
|
|
|
fbe740 |
+ const char *jsonstr G_GNUC_UNUSED,
|
|
|
fbe740 |
int opaque G_GNUC_UNUSED)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
const char *filename;
|
|
|
fbe740 |
@@ -3509,18 +3518,20 @@ virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src,
|
|
|
fbe740 |
static int
|
|
|
fbe740 |
virStorageSourceParseBackingJSONRaw(virStorageSourcePtr src,
|
|
|
fbe740 |
virJSONValuePtr json,
|
|
|
fbe740 |
+ const char *jsonstr,
|
|
|
fbe740 |
int opaque G_GNUC_UNUSED)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
/* There are no interesting attributes in raw driver.
|
|
|
fbe740 |
* Treat it as pass-through.
|
|
|
fbe740 |
*/
|
|
|
fbe740 |
- return virStorageSourceParseBackingJSONInternal(src, json);
|
|
|
fbe740 |
+ return virStorageSourceParseBackingJSONInternal(src, json, jsonstr);
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
|
|
|
fbe740 |
static int
|
|
|
fbe740 |
virStorageSourceParseBackingJSONVxHS(virStorageSourcePtr src,
|
|
|
fbe740 |
virJSONValuePtr json,
|
|
|
fbe740 |
+ const char *jsonstr G_GNUC_UNUSED,
|
|
|
fbe740 |
int opaque G_GNUC_UNUSED)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
const char *vdisk_id = virJSONValueObjectGetString(json, "vdisk-id");
|
|
|
fbe740 |
@@ -3559,7 +3570,7 @@ struct virStorageSourceJSONDriverParser {
|
|
|
fbe740 |
* can't be converted to libvirt's configuration (e.g. inline authentication
|
|
|
fbe740 |
* credentials are present).
|
|
|
fbe740 |
*/
|
|
|
fbe740 |
- int (*func)(virStorageSourcePtr src, virJSONValuePtr json, int opaque);
|
|
|
fbe740 |
+ int (*func)(virStorageSourcePtr src, virJSONValuePtr json, const char *jsonstr, int opaque);
|
|
|
fbe740 |
int opaque;
|
|
|
fbe740 |
};
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -3586,36 +3597,34 @@ static const struct virStorageSourceJSONDriverParser jsonParsers[] = {
|
|
|
fbe740 |
|
|
|
fbe740 |
static int
|
|
|
fbe740 |
virStorageSourceParseBackingJSONInternal(virStorageSourcePtr src,
|
|
|
fbe740 |
- virJSONValuePtr json)
|
|
|
fbe740 |
+ virJSONValuePtr json,
|
|
|
fbe740 |
+ const char *jsonstr)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
g_autoptr(virJSONValue) deflattened = NULL;
|
|
|
fbe740 |
virJSONValuePtr file;
|
|
|
fbe740 |
const char *drvname;
|
|
|
fbe740 |
size_t i;
|
|
|
fbe740 |
- g_autofree char *str = NULL;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (!(deflattened = virJSONValueObjectDeflatten(json)))
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (!(file = virJSONValueObjectGetObject(deflattened, "file"))) {
|
|
|
fbe740 |
- str = virJSONValueToString(json, false);
|
|
|
fbe740 |
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
fbe740 |
_("JSON backing volume definition '%s' lacks 'file' object"),
|
|
|
fbe740 |
- NULLSTR(str));
|
|
|
fbe740 |
+ jsonstr);
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
if (!(drvname = virJSONValueObjectGetString(file, "driver"))) {
|
|
|
fbe740 |
- str = virJSONValueToString(json, false);
|
|
|
fbe740 |
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
fbe740 |
_("JSON backing volume definition '%s' lacks driver name"),
|
|
|
fbe740 |
- NULLSTR(str));
|
|
|
fbe740 |
+ jsonstr);
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
for (i = 0; i < G_N_ELEMENTS(jsonParsers); i++) {
|
|
|
fbe740 |
if (STREQ(drvname, jsonParsers[i].drvname))
|
|
|
fbe740 |
- return jsonParsers[i].func(src, file, jsonParsers[i].opaque);
|
|
|
fbe740 |
+ return jsonParsers[i].func(src, file, jsonstr, jsonParsers[i].opaque);
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
fbe740 |
@@ -3634,7 +3643,7 @@ virStorageSourceParseBackingJSON(virStorageSourcePtr src,
|
|
|
fbe740 |
if (!(root = virJSONValueFromString(json)))
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
- return virStorageSourceParseBackingJSONInternal(src, root);
|
|
|
fbe740 |
+ return virStorageSourceParseBackingJSONInternal(src, root, json);
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
|
|
|
fbe740 |
--
|
|
|
fbe740 |
2.25.0
|
|
|
fbe740 |
|