mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +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++) {
|
for (i = 0; i < def->ndisks; i++) {
|
||||||
virDomainDiskDef *disk = def->disks[i];
|
virDomainDiskDef *disk = def->disks[i];
|
||||||
if (qemuNbdkitStartStorageSource(driver, vm, disk->src) < 0)
|
if (qemuNbdkitStartStorageSource(driver, vm, disk->src, true) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->os.loader && def->os.loader->nvram) {
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,11 +297,11 @@ qemuExtDevicesStop(virQEMUDriver *driver,
|
|||||||
|
|
||||||
for (i = 0; i < def->ndisks; i++) {
|
for (i = 0; i < def->ndisks; i++) {
|
||||||
virDomainDiskDef *disk = def->disks[i];
|
virDomainDiskDef *disk = def->disks[i];
|
||||||
qemuNbdkitStopStorageSource(disk->src, vm);
|
qemuNbdkitStopStorageSource(disk->src, vm, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->os.loader && def->os.loader->nvram)
|
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)
|
if (qemuHotplugAttachManagedPR(vm, disk->src, VIR_ASYNC_JOB_NONE) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuNbdkitStartStorageSource(driver, vm, disk->src) < 0)
|
if (qemuNbdkitStartStorageSource(driver, vm, disk->src, true) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1051,7 +1051,7 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
|||||||
if (virStorageSourceChainHasManagedPR(disk->src))
|
if (virStorageSourceChainHasManagedPR(disk->src))
|
||||||
ignore_value(qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE));
|
ignore_value(qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE));
|
||||||
|
|
||||||
qemuNbdkitStopStorageSource(disk->src, vm);
|
qemuNbdkitStopStorageSource(disk->src, vm, true);
|
||||||
}
|
}
|
||||||
qemuDomainSecretDiskDestroy(disk);
|
qemuDomainSecretDiskDestroy(disk);
|
||||||
qemuDomainCleanupStorageSourceFD(disk->src);
|
qemuDomainCleanupStorageSourceFD(disk->src);
|
||||||
@ -4568,7 +4568,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver,
|
|||||||
qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE) < 0)
|
qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
qemuNbdkitStopStorageSource(disk->src, vm);
|
qemuNbdkitStopStorageSource(disk->src, vm, true);
|
||||||
|
|
||||||
if (disk->transient) {
|
if (disk->transient) {
|
||||||
VIR_DEBUG("Removing transient overlay '%s' of disk '%s'",
|
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
|
int
|
||||||
qemuNbdkitStartStorageSource(virQEMUDriver *driver,
|
qemuNbdkitStartStorageSource(virQEMUDriver *driver,
|
||||||
virDomainObj *vm,
|
virDomainObj *vm,
|
||||||
virStorageSource *src)
|
virStorageSource *src,
|
||||||
|
bool chain)
|
||||||
{
|
{
|
||||||
virStorageSource *backing;
|
virStorageSource *backing;
|
||||||
|
|
||||||
for (backing = src; backing != NULL; backing = backing->backingStore) {
|
for (backing = src; backing != NULL; backing = backing->backingStore) {
|
||||||
qemuDomainStorageSourcePrivate *priv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(backing);
|
if (qemuNbdkitStartStorageSourceOne(driver, vm, backing) < 0)
|
||||||
|
|
||||||
if (priv && priv->nbdkitProcess &&
|
|
||||||
qemuNbdkitProcessStart(priv->nbdkitProcess, vm, driver) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
if (!chain)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
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
|
void
|
||||||
qemuNbdkitStopStorageSource(virStorageSource *src,
|
qemuNbdkitStopStorageSource(virStorageSource *src,
|
||||||
virDomainObj *vm)
|
virDomainObj *vm,
|
||||||
|
bool chain)
|
||||||
{
|
{
|
||||||
virStorageSource *backing;
|
virStorageSource *backing;
|
||||||
|
|
||||||
for (backing = src; backing != NULL; backing = backing->backingStore) {
|
for (backing = src; backing != NULL; backing = backing->backingStore) {
|
||||||
qemuDomainStorageSourcePrivate *priv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(backing);
|
qemuNbdkitStopStorageSourceOne(backing, vm);
|
||||||
|
if (!chain)
|
||||||
if (priv && priv->nbdkitProcess &&
|
break;
|
||||||
qemuNbdkitProcessStop(priv->nbdkitProcess, vm) < 0)
|
|
||||||
VIR_WARN("Unable to stop nbdkit for storage source '%s'", qemuBlockStorageSourceGetStorageNodename(src));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,11 +63,13 @@ qemuNbdkitReconnectStorageSource(virStorageSource *source,
|
|||||||
int
|
int
|
||||||
qemuNbdkitStartStorageSource(virQEMUDriver *driver,
|
qemuNbdkitStartStorageSource(virQEMUDriver *driver,
|
||||||
virDomainObj *vm,
|
virDomainObj *vm,
|
||||||
virStorageSource *src);
|
virStorageSource *src,
|
||||||
|
bool chain);
|
||||||
|
|
||||||
void
|
void
|
||||||
qemuNbdkitStopStorageSource(virStorageSource *src,
|
qemuNbdkitStopStorageSource(virStorageSource *src,
|
||||||
virDomainObj *vm);
|
virDomainObj *vm,
|
||||||
|
bool chain);
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuNbdkitStorageSourceManageProcess(virStorageSource *src,
|
qemuNbdkitStorageSourceManageProcess(virStorageSource *src,
|
||||||
|
Loading…
Reference in New Issue
Block a user