]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: block: Add accessors for protocol/storage node names
authorPeter Krempa <pkrempa@redhat.com>
Mon, 21 Jun 2021 15:01:12 +0000 (17:01 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 17 Oct 2023 12:16:15 +0000 (14:16 +0200)
Introduce a set of accessors, which return node names based on
semantics. This will allow to us to modify how we setup the backing
chain in cases when e.g. the format driver can be omitted, without
breaking all the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_block.c
src/qemu/qemu_block.h

index 07bc8ede76e9730f96319c3b84dfb732dc119855..0c9460f67888bf341f4e7abb298eb5a4f900ebf3 100644 (file)
@@ -52,6 +52,54 @@ qemuBlockNodeNameValidate(const char *nn)
 }
 
 
+/**
+ * qemuBlockStorageSourceSetStorageNodename:
+ * @src: virStorageSource to set the storage nodename
+ * @nodename: The node name to set (stolen)
+ *
+ * Sets @nodename as the storage node name of @src. Using NULL @nodename clears
+ * the nodename. @src takes ownership of @nodename.
+ */
+void
+qemuBlockStorageSourceSetStorageNodename(virStorageSource *src,
+                                         char *nodename)
+{
+    g_free(src->nodestorage);
+    src->nodestorage = nodename;
+}
+
+
+/**
+ * qemuBlockStorageSourceGetEffectiveStorageNodename:
+ * @src: virStorageSource to get the effective nodename of
+ *
+ * Gets the nodename that exposes the storage corresponding to @src, without
+ * the format driver applied. This function always returns a name.
+ */
+const char *
+qemuBlockStorageSourceGetEffectiveStorageNodename(virStorageSource *src)
+{
+    if (src->sliceStorage &&
+        src->sliceStorage->nodename)
+        return src->sliceStorage->nodename;
+
+    return src->nodestorage;
+}
+
+
+/**
+ * qemuBlockStorageSourceGetStorageNodename:
+ * @src: virStorageSource to get the effective nodename of
+ *
+ * Gets the nodename corresponding to the real backing storage format layer.
+ */
+const char *
+qemuBlockStorageSourceGetStorageNodename(virStorageSource *src)
+{
+    return src->nodestorage;
+}
+
+
 /**
  * qemuBlockStorageSourceSupportsConcurrentAccess:
  * @src: disk storage source
index cf5eaf87f3fadad88d2fa194e40ebd7aa3933c09..ecc5711dcdb7966d1ba4e25084bdbbeb1afedfee 100644 (file)
 #include "virjson.h"
 #include "viruri.h"
 
+void
+qemuBlockStorageSourceSetStorageNodename(virStorageSource *src,
+                                         char *nodename);
+
+const char *
+qemuBlockStorageSourceGetEffectiveStorageNodename(virStorageSource *src);
+
+const char *
+qemuBlockStorageSourceGetStorageNodename(virStorageSource *src);
+
+
 typedef struct qemuBlockNodeNameBackingChainData qemuBlockNodeNameBackingChainData;
 struct qemuBlockNodeNameBackingChainData {
     char *qemufilename; /* name of the image from qemu */