mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 03:21:19 +00:00
conf: virtiofs: validate that the target dir is unique even for hotplug
https://bugzilla.redhat.com/show_bug.cgi?id=2171384 Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
063e8b9d62
commit
a7ee9eac83
@ -1735,33 +1735,6 @@ virDomainDefIOMMUValidate(const virDomainDef *def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
virDomainDefFSValidate(const virDomainDef *def)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
g_autoptr(GHashTable) dsts = virHashNew(NULL);
|
|
||||||
|
|
||||||
for (i = 0; i < def->nfss; i++) {
|
|
||||||
const virDomainFSDef *fs = def->fss[i];
|
|
||||||
|
|
||||||
if (fs->fsdriver != VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (virHashHasEntry(dsts, fs->dst)) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("filesystem target '%1$s' specified twice"),
|
|
||||||
fs->dst);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virHashAddEntry(dsts, fs->dst, (void *) 0x1) < 0)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virDomainDefValidateIOThreadsThreadPool(int thread_pool_min,
|
virDomainDefValidateIOThreadsThreadPool(int thread_pool_min,
|
||||||
int thread_pool_max)
|
int thread_pool_max)
|
||||||
@ -1856,9 +1829,6 @@ virDomainDefValidateInternal(const virDomainDef *def,
|
|||||||
if (virDomainNumaDefValidate(def->numa) < 0)
|
if (virDomainNumaDefValidate(def->numa) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virDomainDefFSValidate(def) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (virDomainDefValidateIOThreads(def) < 0)
|
if (virDomainDefValidateIOThreads(def) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -2573,8 +2543,13 @@ virDomainShmemDefValidate(const virDomainShmemDef *shmem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virDomainFSDefValidate(const virDomainFSDef *fs)
|
virDomainFSDefValidate(const virDomainDef *def,
|
||||||
|
const virDomainFSDef *fs)
|
||||||
{
|
{
|
||||||
|
g_autoptr(GHashTable) dsts = virHashNew(NULL);
|
||||||
|
const virDomainFSDef *lookup;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
if (fs->dst == NULL) {
|
if (fs->dst == NULL) {
|
||||||
const char *source = fs->src->path;
|
const char *source = fs->src->path;
|
||||||
if (!source)
|
if (!source)
|
||||||
@ -2592,6 +2567,31 @@ virDomainFSDefValidate(const virDomainFSDef *fs)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < def->nfss; i++) {
|
||||||
|
const virDomainFSDef *iter = def->fss[i];
|
||||||
|
|
||||||
|
if (iter->fsdriver != VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (virHashHasEntry(dsts, iter->dst)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("filesystem target '%1$s' specified twice"),
|
||||||
|
iter->dst);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virHashAddEntry(dsts, iter->dst, (void *) iter) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
lookup = g_hash_table_lookup(dsts, fs->dst);
|
||||||
|
if (lookup && lookup != fs) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("filesystem target '%1$s' specified twice"),
|
||||||
|
fs->dst);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2885,7 +2885,7 @@ virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev,
|
|||||||
return virDomainShmemDefValidate(dev->data.shmem);
|
return virDomainShmemDefValidate(dev->data.shmem);
|
||||||
|
|
||||||
case VIR_DOMAIN_DEVICE_FS:
|
case VIR_DOMAIN_DEVICE_FS:
|
||||||
return virDomainFSDefValidate(dev->data.fs);
|
return virDomainFSDefValidate(def, dev->data.fs);
|
||||||
|
|
||||||
case VIR_DOMAIN_DEVICE_AUDIO:
|
case VIR_DOMAIN_DEVICE_AUDIO:
|
||||||
return virDomainAudioDefValidate(def, dev->data.audio);
|
return virDomainAudioDefValidate(def, dev->data.audio);
|
||||||
|
Loading…
Reference in New Issue
Block a user