Blame SOURCES/libvirt-storage-Allow-parsing-of-RBD-backing-strings-when-building-backing-chain.patch

9119d9
From 32637190ee1024b114635d1b9fd42a9367f7ad2d Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <32637190ee1024b114635d1b9fd42a9367f7ad2d@dist-git>
9119d9
From: Peter Krempa <pkrempa@redhat.com>
9119d9
Date: Fri, 21 Nov 2014 15:04:10 +0100
9119d9
Subject: [PATCH] storage: Allow parsing of RBD backing strings when building
9119d9
 backing chain
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1164528
9119d9
9119d9
As we now have a common function to parse backing store string for RBD
9119d9
backing store we can reuse it in the backing store walker so that we
9119d9
don't fail on files backed by RBD storage.
9119d9
9119d9
This patch also adds a few tests to verify that the parsing works as
9119d9
expected.
9119d9
9119d9
(cherry picked from commit 930b77598b4a8481ad98c786e77e372dc6b803cc)
9119d9
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/util/virstoragefile.c |  6 +++++-
9119d9
 tests/virstoragetest.c    | 43 +++++++++++++++++++++++++++++++++++++++++++
9119d9
 2 files changed, 48 insertions(+), 1 deletion(-)
9119d9
9119d9
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
9119d9
index 94fb3cd..ba4d830 100644
9119d9
--- a/src/util/virstoragefile.c
9119d9
+++ b/src/util/virstoragefile.c
9119d9
@@ -2437,8 +2437,12 @@ virStorageSourceParseBackingColon(virStorageSourcePtr src,
9119d9
             goto cleanup;
9119d9
         break;
9119d9
 
9119d9
-    case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG:
9119d9
     case VIR_STORAGE_NET_PROTOCOL_RBD:
9119d9
+        if (virStorageSourceParseRBDColonString(path, src) < 0)
9119d9
+            goto cleanup;
9119d9
+        break;
9119d9
+
9119d9
+    case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG:
9119d9
     case VIR_STORAGE_NET_PROTOCOL_LAST:
9119d9
     case VIR_STORAGE_NET_PROTOCOL_NONE:
9119d9
         virReportError(VIR_ERR_INTERNAL_ERROR,
9119d9
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
9119d9
index ee6f576..2601edc 100644
9119d9
--- a/tests/virstoragetest.c
9119d9
+++ b/tests/virstoragetest.c
9119d9
@@ -972,6 +972,49 @@ mymain(void)
9119d9
                (&wrap, &qcow2), EXP_WARN,
9119d9
                (&wrap, &qcow2), ALLOW_PROBE | EXP_WARN);
9119d9
 
9119d9
+    /* Rewrite qcow2 to use an rbd: protocol as backend */
9119d9
+    virCommandFree(cmd);
9119d9
+    cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
9119d9
+                               "-F", "raw", "-b", "rbd:testshare",
9119d9
+                               "qcow2", NULL);
9119d9
+    if (virCommandRun(cmd, NULL) < 0)
9119d9
+        ret = -1;
9119d9
+    qcow2.expBackingStoreRaw = "rbd:testshare";
9119d9
+
9119d9
+    /* Qcow2 file with backing protocol instead of file */
9119d9
+    testFileData rbd1 = {
9119d9
+        .path = "testshare",
9119d9
+        .type = VIR_STORAGE_TYPE_NETWORK,
9119d9
+        .format = VIR_STORAGE_FILE_RAW,
9119d9
+        .protocol = VIR_STORAGE_NET_PROTOCOL_RBD,
9119d9
+    };
9119d9
+    TEST_CHAIN(19, absqcow2, VIR_STORAGE_FILE_QCOW2,
9119d9
+               (&qcow2, &rbd1), EXP_PASS,
9119d9
+               (&qcow2, &rbd1), ALLOW_PROBE | EXP_PASS);
9119d9
+
9119d9
+    /* Rewrite qcow2 to use an rbd: protocol as backend */
9119d9
+    virCommandFree(cmd);
9119d9
+    cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
9119d9
+                               "-F", "raw", "-b", "rbd:testshare:id=asdf:mon_host=example.com",
9119d9
+                               "qcow2", NULL);
9119d9
+    if (virCommandRun(cmd, NULL) < 0)
9119d9
+        ret = -1;
9119d9
+    qcow2.expBackingStoreRaw = "rbd:testshare:id=asdf:mon_host=example.com";
9119d9
+
9119d9
+    /* Qcow2 file with backing protocol instead of file */
9119d9
+    testFileData rbd2 = {
9119d9
+        .path = "testshare",
9119d9
+        .type = VIR_STORAGE_TYPE_NETWORK,
9119d9
+        .format = VIR_STORAGE_FILE_RAW,
9119d9
+        .protocol = VIR_STORAGE_NET_PROTOCOL_RBD,
9119d9
+        .secret = "asdf",
9119d9
+        .hostname = "example.com",
9119d9
+    };
9119d9
+    TEST_CHAIN(20, absqcow2, VIR_STORAGE_FILE_QCOW2,
9119d9
+               (&qcow2, &rbd2), EXP_PASS,
9119d9
+               (&qcow2, &rbd2), ALLOW_PROBE | EXP_PASS);
9119d9
+
9119d9
+
9119d9
     /* Rewrite wrap and qcow2 back to 3-deep chain, absolute backing */
9119d9
     virCommandFree(cmd);
9119d9
     cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
9119d9
-- 
9119d9
2.1.3
9119d9