]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Validate disk lun using correct types
authorJohn Ferlan <jferlan@redhat.com>
Fri, 26 Jun 2015 17:48:06 +0000 (13:48 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 30 Jun 2015 12:39:32 +0000 (08:39 -0400)
https://bugzilla.redhat.com/show_bug.cgi?id=1201143

The formatdomain.html description for <disk> device 'lun' indicates that
it must be either a type 'block' or type 'network' with protocol 'iscsi';
however, we did not make that check until domain startup.

This caused issues for virt-manager which had an unexpected failure at
run time rather config time.

This patch adds a check in post part disk device checking for the specific
and supported lun types as well as adjusting the test failure to be for
parse config rather than run time.

src/conf/domain_conf.c
tests/qemuxml2argvtest.c

index 2c3b96b0e5785e6a4b0d7685951e69b08d7f3944..ad641ed67bc188ee3a5253249305e906471bda52 100644 (file)
@@ -3893,6 +3893,28 @@ virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
                 return -1;
             }
         }
+
+        /* Validate LUN configuration
+         * NOTE: virStorageTranslateDiskSourcePool is not run yet, so for
+         *       disk "volume"'s, the closest we can get at config time is
+         *       to ensure mode isn't direct since host/default will allow
+         *       lun/block usage. At run time if it's determined the wrong
+         *       voltype and pooltype values are set, then failure occurs
+         */
+        if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN &&
+            !(disk->src->type == VIR_STORAGE_TYPE_BLOCK ||
+              (disk->src->type == VIR_STORAGE_TYPE_NETWORK &&
+               disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI) ||
+              (disk->src->type == VIR_STORAGE_TYPE_VOLUME &&
+               disk->src->srcpool &&
+               disk->src->srcpool->mode !=
+               VIR_STORAGE_SOURCE_POOL_MODE_DIRECT))) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("disk '%s' improperly configured for a "
+                             "device='lun'"),
+                           disk->dst);
+            return -1;
+        }
     }
 
     if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
index 4154601d82d2abbf27cf5bf5fa570c620f1b6668..f85f63b3331b5125ebbe0fe404bb054cf48c9afd 100644 (file)
@@ -818,7 +818,7 @@ mymain(void)
                     QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
     DO_TEST("disk-drive-no-boot",
             QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_BOOTINDEX);
-    DO_TEST_FAILURE("disk-device-lun-type-invalid",
+    DO_TEST_PARSE_ERROR("disk-device-lun-type-invalid",
                     QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_SCSI);
     DO_TEST("disk-usb",  NONE);
     DO_TEST("disk-usb-device",