qemu: hotplug: Check duplicate disk serial/wwn on hotplug too

We do the check on VM start, but the user could still hotplug a disk
with a conflicting serial or WWN. Reuse the checker function to fix the
issue.
This commit is contained in:
Peter Krempa 2016-02-04 13:39:15 +01:00
parent e76a848e3d
commit 4f1324aa48
4 changed files with 8 additions and 1 deletions

View File

@ -23988,7 +23988,7 @@ virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
}
static int
int
virDomainDiskDefCheckDuplicateInfo(virDomainDiskDefPtr a,
virDomainDiskDefPtr b)
{

View File

@ -3153,6 +3153,9 @@ virDomainParseMemory(const char *xpath,
bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
ATTRIBUTE_NONNULL(1);
int virDomainDiskDefCheckDuplicateInfo(virDomainDiskDefPtr a,
virDomainDiskDefPtr b)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int virDomainDefCheckDuplicateDiskInfo(virDomainDefPtr def)
ATTRIBUTE_NONNULL(1);

View File

@ -257,6 +257,7 @@ virDomainDiskByName;
virDomainDiskCacheTypeFromString;
virDomainDiskCacheTypeToString;
virDomainDiskDefAssignAddress;
virDomainDiskDefCheckDuplicateInfo;
virDomainDiskDefDstDuplicates;
virDomainDiskDefForeachPath;
virDomainDiskDefFree;

View File

@ -799,6 +799,9 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
_("target %s already exists"), disk->dst);
goto cleanup;
}
if (virDomainDiskDefCheckDuplicateInfo(vm->def->disks[i], disk) < 0)
goto cleanup;
}
switch ((virDomainDiskBus) disk->bus) {