[PATCH 2/5] conf: Introduce raw disk string passthrough

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds a new disk type "raw" that can be used twofold:

1) To pass arbitrary strings as disk sources to the hypervisor of
choice. This allows to use not-yet-supported storage specification
formats.

2) To return backing chain element names that libvirt doesn't yet know
how to parse. Backing chain elements may specify names that libvirt
isn't able to parse. To allow us reporting it back to the user,
unparsable strings will be reported as disk type="raw".

To avoid attempts to label or do other operations on "raw" disks mark
them as remote and unsupported by the storage driver explicitly.

Tests for the new format are being added separately.
---
 docs/schemas/domaincommon.rng | 14 ++++++++++++++
 src/conf/domain_conf.c        |  7 +++++++
 src/qemu/qemu_command.c       |  1 +
 src/qemu/qemu_driver.c        |  4 ++++
 src/storage/storage_driver.c  |  8 ++++++++
 src/util/virstoragefile.c     |  4 +++-
 src/util/virstoragefile.h     |  1 +
 7 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index cedceae..b7246c5 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1296,6 +1296,7 @@
       <ref name="diskSourceDir"/>
       <ref name="diskSourceNetwork"/>
       <ref name="diskSourceVolume"/>
+      <ref name="diskSourceRaw"/>
     </choice>
   </define>

@@ -1461,6 +1462,19 @@
     </interleave>
   </define>

+  <define name="diskSourceRaw">
+    <attribute name="type">
+      <value>raw</value>
+    </attribute>
+    <optional>
+      <element name="source">
+        <attribute name="raw">
+          <data type="string"/>
+        </attribute>
+      </element>
+    </optional>
+  </define>
+
   <define name="diskTarget">
     <data type="string">
       <param name="pattern">(ioemu:)?(fd|hd|sd|vd|xvd|ubd)[a-zA-Z0-9_]+</param>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index aac78a6..189a4e8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5305,6 +5305,9 @@ virDomainDiskSourceParse(xmlNodePtr node,
         if (virDomainDiskSourcePoolDefParse(node, &src->srcpool) < 0)
             goto cleanup;
         break;
+    case VIR_STORAGE_TYPE_RAW:
+        src->path = virXMLPropString(node, "raw");
+         break;
     case VIR_STORAGE_TYPE_NONE:
     case VIR_STORAGE_TYPE_LAST:
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -15557,6 +15560,10 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf,
                                                  skipSeclabels);
             break;

+        case VIR_STORAGE_TYPE_RAW:
+            virBufferEscapeString(buf, "<source raw='%s'/>\n", src->path);
+            break;
+
         case VIR_STORAGE_TYPE_NONE:
         case VIR_STORAGE_TYPE_LAST:
             virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7b87a31..82111ca 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3184,6 +3184,7 @@ qemuGetDriveSourceString(virStorageSourcePtr src,
     case VIR_STORAGE_TYPE_BLOCK:
     case VIR_STORAGE_TYPE_FILE:
     case VIR_STORAGE_TYPE_DIR:
+    case VIR_STORAGE_TYPE_RAW:
         if (!src->path) {
             ret = 1;
             goto cleanup;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d724eeb..c4af401 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12460,6 +12460,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
     case VIR_STORAGE_TYPE_VOLUME:
     case VIR_STORAGE_TYPE_NONE:
     case VIR_STORAGE_TYPE_LAST:
+    case VIR_STORAGE_TYPE_RAW:
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("external inactive snapshots are not supported on "
                          "'%s' disks"), virStorageTypeToString(actualType));
@@ -12523,6 +12524,7 @@ qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDefPtr d
     case VIR_STORAGE_TYPE_VOLUME:
     case VIR_STORAGE_TYPE_NONE:
     case VIR_STORAGE_TYPE_LAST:
+    case VIR_STORAGE_TYPE_RAW:
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("external active snapshots are not supported on "
                          "'%s' disks"), virStorageTypeToString(actualType));
@@ -12547,6 +12549,7 @@ qemuDomainSnapshotPrepareDiskExternalOverlayInactive(virDomainSnapshotDiskDefPtr
     case VIR_STORAGE_TYPE_DIR:
     case VIR_STORAGE_TYPE_VOLUME:
     case VIR_STORAGE_TYPE_NONE:
+    case VIR_STORAGE_TYPE_RAW:
     case VIR_STORAGE_TYPE_LAST:
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("external inactive snapshots are not supported on "
@@ -12665,6 +12668,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
     case VIR_STORAGE_TYPE_DIR:
     case VIR_STORAGE_TYPE_VOLUME:
     case VIR_STORAGE_TYPE_NONE:
+    case VIR_STORAGE_TYPE_RAW:
     case VIR_STORAGE_TYPE_LAST:
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("internal inactive snapshots are not supported on "
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 433d7b7..25ce748 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -2448,6 +2448,10 @@ virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src)
         return false;
     actualType = virStorageSourceGetActualType(src);

+    /* explicitly reject raw disk strings */
+    if (actualType == VIR_STORAGE_TYPE_RAW)
+        return false;
+
     if (src->drv) {
         backend = src->drv->backend;
     } else {
@@ -2481,6 +2485,10 @@ virStorageFileSupportsSecurityDriver(virStorageSourcePtr src)
         return false;
     actualType = virStorageSourceGetActualType(src);

+    /* explicitly reject raw disk strings */
+    if (actualType == VIR_STORAGE_TYPE_RAW)
+        return false;
+
     if (src->drv) {
         backend = src->drv->backend;
     } else {
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 299edcd..a17ced1 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -57,7 +57,8 @@ VIR_ENUM_IMPL(virStorage, VIR_STORAGE_TYPE_LAST,
               "block",
               "dir",
               "network",
-              "volume")
+              "volume",
+              "raw")

 VIR_ENUM_IMPL(virStorageFileFormat,
               VIR_STORAGE_FILE_LAST,
@@ -1968,6 +1969,7 @@ virStorageSourceIsLocalStorage(virStorageSourcePtr src)
     case VIR_STORAGE_TYPE_VOLUME:
     case VIR_STORAGE_TYPE_LAST:
     case VIR_STORAGE_TYPE_NONE:
+    case VIR_STORAGE_TYPE_RAW:
         return false;
     }

diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index eccbf4e..e643095 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -49,6 +49,7 @@ typedef enum {
     VIR_STORAGE_TYPE_DIR,
     VIR_STORAGE_TYPE_NETWORK,
     VIR_STORAGE_TYPE_VOLUME,
+    VIR_STORAGE_TYPE_RAW,

     VIR_STORAGE_TYPE_LAST
 } virStorageType;
-- 
2.0.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]