mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemu: Prepare disks when starting a domain
When starting a domain and separate mount namespace is used, we have to create all the /dev entries that are configured for the domain. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
bb4e529664
commit
054202d020
@ -6909,6 +6909,53 @@ qemuDomainSetupDev(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainSetupDisk(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
||||||
|
virDomainDiskDefPtr disk,
|
||||||
|
const char *devPath)
|
||||||
|
{
|
||||||
|
virStorageSourcePtr next;
|
||||||
|
char *dst = NULL;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
for (next = disk->src; next; next = next->backingStore) {
|
||||||
|
if (!next->path || !virStorageSourceIsLocalStorage(next) ||
|
||||||
|
!STRPREFIX(next->path, "/dev")) {
|
||||||
|
/* Not creating device. Just continue. */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qemuDomainCreateDevice(next->path, devPath, false) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(dst);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainSetupAllDisks(virQEMUDriverPtr driver,
|
||||||
|
virDomainObjPtr vm,
|
||||||
|
const char *devPath)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
VIR_DEBUG("Setting up disks");
|
||||||
|
|
||||||
|
for (i = 0; i < vm->def->ndisks; i++) {
|
||||||
|
if (qemuDomainSetupDisk(driver,
|
||||||
|
vm->def->disks[i],
|
||||||
|
devPath) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
VIR_DEBUG("Setup all disks");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuDomainBuildNamespace(virQEMUDriverPtr driver,
|
qemuDomainBuildNamespace(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm)
|
virDomainObjPtr vm)
|
||||||
@ -6947,6 +6994,9 @@ qemuDomainBuildNamespace(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qemuDomainSetupAllDisks(driver, vm, devPath) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (mount(devPath, "/dev", NULL, mount_flags, NULL) < 0) {
|
if (mount(devPath, "/dev", NULL, mount_flags, NULL) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Failed to mount %s on /dev"),
|
_("Failed to mount %s on /dev"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user