[PATCH 02/14] conf: Pass virStorageSource into virDomainDiskSourceIsBlockType

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

 



All checks are based on the storage source, thus there's no need to pass
the complete disk def.
---
 src/conf/domain_conf.c  | 19 ++++++++-----------
 src/conf/domain_conf.h  |  2 +-
 src/lxc/lxc_cgroup.c    |  2 +-
 src/lxc/lxc_driver.c    |  2 +-
 src/qemu/qemu_command.c |  2 +-
 src/qemu/qemu_conf.c    |  6 +++---
 6 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c7016f3..34c1a8c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -20011,29 +20011,26 @@ virDomainDefFindDevice(virDomainDefPtr def,
  * Return true if its source is block type, or false otherwise.
  */
 bool
-virDomainDiskSourceIsBlockType(virDomainDiskDefPtr def)
+virDomainDiskSourceIsBlockType(virStorageSourcePtr src)
 {
-    /* No reason to think the disk source is block type if
-     * the source is empty
-     */
-    if (!virDomainDiskGetSource(def))
+    if (!src->path)
         return false;

-    if (virDomainDiskGetType(def) == VIR_STORAGE_TYPE_BLOCK)
+    if (src->type == VIR_STORAGE_TYPE_BLOCK)
         return true;

     /* For volume types, check the srcpool.
      * If it's a block type source pool, then it's possible
      */
-    if (virDomainDiskGetType(def) == VIR_STORAGE_TYPE_VOLUME &&
-        def->src->srcpool &&
-        def->src->srcpool->voltype == VIR_STORAGE_VOL_BLOCK) {
+    if (src->type == VIR_STORAGE_TYPE_VOLUME &&
+        src->srcpool &&
+        src->srcpool->voltype == VIR_STORAGE_VOL_BLOCK) {
         /* We don't think the volume accessed by remote URI is
          * block type source, since we can't/shouldn't manage it
          * (e.g. set sgio=filtered|unfiltered for it) in libvirt.
          */
-         if (def->src->srcpool->pooltype == VIR_STORAGE_POOL_ISCSI &&
-             def->src->srcpool->mode == VIR_STORAGE_SOURCE_POOL_MODE_DIRECT)
+         if (src->srcpool->pooltype == VIR_STORAGE_POOL_ISCSI &&
+             src->srcpool->mode == VIR_STORAGE_SOURCE_POOL_MODE_DIRECT)
              return false;

         return true;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ff7d640..21cfba2 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2713,7 +2713,7 @@ int virDomainDefFindDevice(virDomainDefPtr def,
                            virDomainDeviceDefPtr dev,
                            bool reportError);

-bool virDomainDiskSourceIsBlockType(virDomainDiskDefPtr def)
+bool virDomainDiskSourceIsBlockType(virStorageSourcePtr src)
     ATTRIBUTE_NONNULL(1);

 void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);
diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
index ff88e4f..f9af31c 100644
--- a/src/lxc/lxc_cgroup.c
+++ b/src/lxc/lxc_cgroup.c
@@ -373,7 +373,7 @@ static int virLXCCgroupSetupDeviceACL(virDomainDefPtr def,

     VIR_DEBUG("Allowing any disk block devs");
     for (i = 0; i < def->ndisks; i++) {
-        if (!virDomainDiskSourceIsBlockType(def->disks[i]))
+        if (!virDomainDiskSourceIsBlockType(def->disks[i]->src))
             continue;

         if (virCgroupAllowDevicePath(cgroup,
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 9e12ecc..6eff8b3 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -4047,7 +4047,7 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver,
         goto cleanup;
     }

-    if (!virDomainDiskSourceIsBlockType(def)) {
+    if (!virDomainDiskSourceIsBlockType(def->src)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("Can't setup disk for non-block device"));
         goto cleanup;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8a69976..b8af9e0 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3660,7 +3660,7 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
                                virStorageNetProtocolTypeToString(disk->src->protocol));
                 goto error;
             }
-        } else if (!virDomainDiskSourceIsBlockType(disk)) {
+        } else if (!virDomainDiskSourceIsBlockType(disk->src)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("disk device='lun' is only valid for block type disk source"));
             goto error;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 6bfa48e..ec665d6 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -979,7 +979,7 @@ qemuAddSharedDevice(virQEMUDriverPtr driver,
     if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
         disk = dev->data.disk;

-        if (!disk->src->shared || !virDomainDiskSourceIsBlockType(disk))
+        if (!disk->src->shared || !virDomainDiskSourceIsBlockType(disk->src))
             return 0;
     } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
         hostdev = dev->data.hostdev;
@@ -1088,7 +1088,7 @@ qemuRemoveSharedDevice(virQEMUDriverPtr driver,
     if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
         disk = dev->data.disk;

-        if (!disk->src->shared || !virDomainDiskSourceIsBlockType(disk))
+        if (!disk->src->shared || !virDomainDiskSourceIsBlockType(disk->src))
             return 0;
     } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
         hostdev = dev->data.hostdev;
@@ -1174,7 +1174,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
         disk = dev->data.disk;

         if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN ||
-            !virDomainDiskSourceIsBlockType(disk))
+            !virDomainDiskSourceIsBlockType(disk->src))
             return 0;

         path = virDomainDiskGetSource(disk);
-- 
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]