qemuDomainChangeDiskLive: Allow startupPolicy change

https://bugzilla.redhat.com/show_bug.cgi?id=1159219

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2015-09-15 17:13:01 +02:00
parent 08573b632d
commit 0751786d3c
2 changed files with 21 additions and 10 deletions

View File

@ -3157,7 +3157,7 @@ qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk,
CHECK_EQ(event_idx, "event_idx", true);
CHECK_EQ(copy_on_read, "copy_on_read", true);
CHECK_EQ(snapshot, "snapshot", true);
CHECK_EQ(startupPolicy, "startupPolicy", true);
/* startupPolicy is allowed to be updated. Therefore not checked here. */
CHECK_EQ(transient, "transient", true);
CHECK_EQ(info.bootIndex, "boot order", true);
CHECK_EQ(rawio, "rawio", true);

View File

@ -7904,6 +7904,7 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
{
virDomainDiskDefPtr disk = dev->data.disk;
virDomainDiskDefPtr orig_disk = NULL;
int startupPolicy;
int ret = -1;
if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
@ -7921,23 +7922,29 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
goto cleanup;
}
startupPolicy = orig_disk->startupPolicy;
switch ((virDomainDiskDevice) disk->device) {
case VIR_DOMAIN_DISK_DEVICE_CDROM:
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
if (!qemuDomainDiskChangeSupported(disk, orig_disk))
goto cleanup;
/* Add the new disk src into shared disk hash table */
if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
goto cleanup;
orig_disk->startupPolicy = dev->data.disk->startupPolicy;
if (qemuDomainChangeEjectableMedia(driver, conn, vm,
orig_disk, disk->src, force) < 0) {
ignore_value(qemuRemoveSharedDisk(driver, disk, vm->def->name));
goto cleanup;
if (qemuDomainDiskSourceDiffers(conn, disk, orig_disk)) {
/* Add the new disk src into shared disk hash table */
if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
goto cleanup;
if (qemuDomainChangeEjectableMedia(driver, conn, vm,
orig_disk, dev->data.disk->src, force) < 0) {
ignore_value(qemuRemoveSharedDisk(driver, dev->data.disk, vm->def->name));
goto rollback;
}
dev->data.disk->src = NULL;
}
disk->src = NULL;
break;
case VIR_DOMAIN_DISK_DEVICE_DISK:
@ -7956,6 +7963,10 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
ret = 0;
cleanup:
return ret;
rollback:
orig_disk->startupPolicy = startupPolicy;
goto cleanup;
}
static int