提交 f8699311 编写于 作者: P Peter Krempa

qemu: hotplug: Be explicit about old/new sources when changing media

Some functions require us to replace disk->src with the new source for
them to work properly. To avoid confusion all places which allow
explicit virStorageSource should get the appropriate definition.

The legacy code fortunately does not need anything from the old source
so that does not require modifications.

Blockdev does require the old definition so we'll pass it explicitly.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
上级 50cb91db
......@@ -625,6 +625,7 @@ qemuHotplugDiskSourceRemove(qemuMonitorPtr mon,
* @driver: qemu driver structure
* @vm: domain definition
* @disk: disk definition to change the source of
* @oldsrc: old source definition
* @newsrc: new disk source to change to
* @force: force the change of media
*
......@@ -639,6 +640,7 @@ static int
qemuDomainChangeMediaBlockdev(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainDiskDefPtr disk,
virStorageSourcePtr oldsrc,
virStorageSourcePtr newsrc,
bool force)
{
......@@ -646,19 +648,17 @@ qemuDomainChangeMediaBlockdev(virQEMUDriverPtr driver,
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
qemuHotplugDiskSourceDataPtr newbackend = NULL;
qemuHotplugDiskSourceDataPtr oldbackend = NULL;
virStorageSourcePtr oldsrc = disk->src;
char *nodename = NULL;
int rc;
int ret = -1;
if (!virStorageSourceIsEmpty(disk->src) &&
!(oldbackend = qemuHotplugDiskSourceRemovePrepare(disk, disk->src,
if (!virStorageSourceIsEmpty(oldsrc) &&
!(oldbackend = qemuHotplugDiskSourceRemovePrepare(disk, oldsrc,
priv->qemuCaps)))
goto cleanup;
disk->src = newsrc;
if (!virStorageSourceIsEmpty(disk->src)) {
if (!(newbackend = qemuHotplugDiskSourceAttachPrepare(disk, disk->src,
if (!virStorageSourceIsEmpty(newsrc)) {
if (!(newbackend = qemuHotplugDiskSourceAttachPrepare(disk, newsrc,
priv->qemuCaps)))
goto cleanup;
......@@ -704,8 +704,6 @@ qemuDomainChangeMediaBlockdev(virQEMUDriverPtr driver,
qemuHotplugDiskSourceDataFree(newbackend);
qemuHotplugDiskSourceDataFree(oldbackend);
VIR_FREE(nodename);
/* caller handles correct exchange of sources */
disk->src = oldsrc;
return ret;
}
......@@ -743,7 +741,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
goto cleanup;
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV))
rc = qemuDomainChangeMediaBlockdev(driver, vm, disk, newsrc, force);
rc = qemuDomainChangeMediaBlockdev(driver, vm, disk, disk->src, newsrc, force);
else
rc = qemuDomainChangeMediaLegacy(driver, vm, disk, newsrc, force);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册