qemu: Improve check for local storage

Now that we have a simple function to check locality of storage, reuse
it in qemuDomainCheckDiskPresence().

Also reuse check for empty storage source.
This commit is contained in:
Peter Krempa 2014-09-11 19:28:10 +02:00
parent 7c7981eb79
commit 434dd55194
1 changed files with 3 additions and 5 deletions

View File

@ -2510,20 +2510,18 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
for (i = vm->def->ndisks; i > 0; i--) {
size_t idx = i - 1;
virDomainDiskDefPtr disk = vm->def->disks[idx];
const char *path = virDomainDiskGetSource(disk);
virStorageFileFormat format = virDomainDiskGetFormat(disk);
virStorageType type = virStorageSourceGetActualType(disk->src);
if (!path)
if (virStorageSourceIsEmpty(disk->src))
continue;
/* There is no need to check the backing chain for disks
* without backing support, the fact that the file exists is
* more than enough */
if (type != VIR_STORAGE_TYPE_NETWORK &&
if (virStorageSourceIsLocalStorage(disk->src) &&
format >= VIR_STORAGE_FILE_NONE &&
format < VIR_STORAGE_FILE_BACKING &&
virFileExists(path))
virFileExists(virDomainDiskGetSource(disk)))
continue;
if (qemuDomainDetermineDiskChain(driver, vm, disk, false) >= 0 &&