1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 06:50:22 +03:00

qemuDomainUpdateDeviceConfig: Allow full disk update

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

So far, when it comes to 'virsh update-device --config' of disks
we are limiting ourselves for just the disk source update and
just for CDROMs and floppies. This makes no sense. Especially if
you look around and see that we already allow full update to
graphics and net devices. So let's just take whatever XML user
wants to have there and replace our internal definition with it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2016-08-31 11:09:58 +02:00
parent 7b3cf84bbb
commit 3193a59447

View File

@ -8090,35 +8090,23 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
unsigned int parse_flags,
virDomainXMLOptionPtr xmlopt)
{
virDomainDiskDefPtr orig, disk;
virDomainDiskDefPtr newDisk;
virDomainGraphicsDefPtr newGraphics;
virDomainNetDefPtr net;
int pos;
switch ((virDomainDeviceType) dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
disk = dev->data.disk;
if (!(orig = virDomainDiskByName(vmdef, disk->dst, false))) {
newDisk = dev->data.disk;
if ((pos = virDomainDiskIndexByName(vmdef, newDisk->dst, false)) < 0) {
virReportError(VIR_ERR_INVALID_ARG,
_("target %s doesn't exist."), disk->dst);
_("target %s doesn't exist."), newDisk->dst);
return -1;
}
if (!(orig->device == VIR_DOMAIN_DISK_DEVICE_CDROM) &&
!(orig->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("this disk doesn't support update"));
return -1;
}
/*
* Update 'orig'
* We allow updating src/type//driverType/cachemode/
*/
orig->cachemode = disk->cachemode;
orig->startupPolicy = disk->startupPolicy;
virStorageSourceFree(orig->src);
orig->src = disk->src;
disk->src = NULL;
virDomainDiskDefFree(vmdef->disks[pos]);
vmdef->disks[pos] = newDisk;
dev->data.disk = NULL;
break;
case VIR_DOMAIN_DEVICE_GRAPHICS: