mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
qemu: add a 'chain' parameter to nbdkit start/stop
This will allow us to start or stop nbdkit for just a single disk source or for every source in the backing chain. This will be used in following patches. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
20a5f77156
commit
7a03785d88
@ -234,12 +234,12 @@ qemuExtDevicesStart(virQEMUDriver *driver,
|
||||
|
||||
for (i = 0; i < def->ndisks; i++) {
|
||||
virDomainDiskDef *disk = def->disks[i];
|
||||
if (qemuNbdkitStartStorageSource(driver, vm, disk->src) < 0)
|
||||
if (qemuNbdkitStartStorageSource(driver, vm, disk->src, true) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (def->os.loader && def->os.loader->nvram) {
|
||||
if (qemuNbdkitStartStorageSource(driver, vm, def->os.loader->nvram) < 0)
|
||||
if (qemuNbdkitStartStorageSource(driver, vm, def->os.loader->nvram, true) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -297,11 +297,11 @@ qemuExtDevicesStop(virQEMUDriver *driver,
|
||||
|
||||
for (i = 0; i < def->ndisks; i++) {
|
||||
virDomainDiskDef *disk = def->disks[i];
|
||||
qemuNbdkitStopStorageSource(disk->src, vm);
|
||||
qemuNbdkitStopStorageSource(disk->src, vm, true);
|
||||
}
|
||||
|
||||
if (def->os.loader && def->os.loader->nvram)
|
||||
qemuNbdkitStopStorageSource(def->os.loader->nvram, vm);
|
||||
qemuNbdkitStopStorageSource(def->os.loader->nvram, vm, true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1024,7 +1024,7 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
||||
if (qemuHotplugAttachManagedPR(vm, disk->src, VIR_ASYNC_JOB_NONE) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuNbdkitStartStorageSource(driver, vm, disk->src) < 0)
|
||||
if (qemuNbdkitStartStorageSource(driver, vm, disk->src, true) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -1051,7 +1051,7 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
||||
if (virStorageSourceChainHasManagedPR(disk->src))
|
||||
ignore_value(qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE));
|
||||
|
||||
qemuNbdkitStopStorageSource(disk->src, vm);
|
||||
qemuNbdkitStopStorageSource(disk->src, vm, true);
|
||||
}
|
||||
qemuDomainSecretDiskDestroy(disk);
|
||||
qemuDomainCleanupStorageSourceFD(disk->src);
|
||||
@ -4568,7 +4568,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver,
|
||||
qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE) < 0)
|
||||
goto cleanup;
|
||||
|
||||
qemuNbdkitStopStorageSource(disk->src, vm);
|
||||
qemuNbdkitStopStorageSource(disk->src, vm, true);
|
||||
|
||||
if (disk->transient) {
|
||||
VIR_DEBUG("Removing transient overlay '%s' of disk '%s'",
|
||||
|
@ -890,37 +890,64 @@ qemuNbdkitInitStorageSource(qemuNbdkitCaps *caps WITHOUT_NBDKIT_UNUSED,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuNbdkitStartStorageSourceOne(virQEMUDriver *driver,
|
||||
virDomainObj *vm,
|
||||
virStorageSource *src)
|
||||
{
|
||||
qemuDomainStorageSourcePrivate *priv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
|
||||
|
||||
if (priv && priv->nbdkitProcess &&
|
||||
qemuNbdkitProcessStart(priv->nbdkitProcess, vm, driver) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuNbdkitStartStorageSource(virQEMUDriver *driver,
|
||||
virDomainObj *vm,
|
||||
virStorageSource *src)
|
||||
virStorageSource *src,
|
||||
bool chain)
|
||||
{
|
||||
virStorageSource *backing;
|
||||
|
||||
for (backing = src; backing != NULL; backing = backing->backingStore) {
|
||||
qemuDomainStorageSourcePrivate *priv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(backing);
|
||||
|
||||
if (priv && priv->nbdkitProcess &&
|
||||
qemuNbdkitProcessStart(priv->nbdkitProcess, vm, driver) < 0)
|
||||
if (qemuNbdkitStartStorageSourceOne(driver, vm, backing) < 0)
|
||||
return -1;
|
||||
if (!chain)
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
qemuNbdkitStopStorageSourceOne(virStorageSource *src,
|
||||
virDomainObj *vm)
|
||||
{
|
||||
qemuDomainStorageSourcePrivate *priv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
|
||||
|
||||
if (priv && priv->nbdkitProcess &&
|
||||
qemuNbdkitProcessStop(priv->nbdkitProcess, vm) < 0)
|
||||
VIR_WARN("Unable to stop nbdkit for storage source '%s'",
|
||||
qemuBlockStorageSourceGetStorageNodename(src));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
qemuNbdkitStopStorageSource(virStorageSource *src,
|
||||
virDomainObj *vm)
|
||||
virDomainObj *vm,
|
||||
bool chain)
|
||||
{
|
||||
virStorageSource *backing;
|
||||
|
||||
for (backing = src; backing != NULL; backing = backing->backingStore) {
|
||||
qemuDomainStorageSourcePrivate *priv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(backing);
|
||||
|
||||
if (priv && priv->nbdkitProcess &&
|
||||
qemuNbdkitProcessStop(priv->nbdkitProcess, vm) < 0)
|
||||
VIR_WARN("Unable to stop nbdkit for storage source '%s'", qemuBlockStorageSourceGetStorageNodename(src));
|
||||
qemuNbdkitStopStorageSourceOne(backing, vm);
|
||||
if (!chain)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,11 +63,13 @@ qemuNbdkitReconnectStorageSource(virStorageSource *source,
|
||||
int
|
||||
qemuNbdkitStartStorageSource(virQEMUDriver *driver,
|
||||
virDomainObj *vm,
|
||||
virStorageSource *src);
|
||||
virStorageSource *src,
|
||||
bool chain);
|
||||
|
||||
void
|
||||
qemuNbdkitStopStorageSource(virStorageSource *src,
|
||||
virDomainObj *vm);
|
||||
virDomainObj *vm,
|
||||
bool chain);
|
||||
|
||||
int
|
||||
qemuNbdkitStorageSourceManageProcess(virStorageSource *src,
|
||||
|
Loading…
Reference in New Issue
Block a user