From: Michal Privoznik Date: Wed, 31 Aug 2016 09:09:58 +0000 (+0200) Subject: qemuDomainUpdateDeviceConfig: Allow full disk update X-Git-Tag: v2.3.0-rc1^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3193a594475f1565e03ddec22fd72af08e95adb2;p=thirdparty%2Flibvirt.git 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 --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7873a6814e..db99c414d4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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); - 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")); + _("target %s doesn't exist."), newDisk->dst); 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: