https://bugzilla.redhat.com/show_bug.cgi?id=1585108 When updating a live device users might pass different alias than the one the device has. Currently, this is silently ignored which goes against our behaviour for other parts of the device where we explicitly allow only certain changes and error out loudly on anything else. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/conf/domain_conf.c | 13 ++++++++++++- src/conf/domain_conf.h | 3 ++- src/lxc/lxc_driver.c | 9 ++++++--- src/qemu/qemu_domain.c | 8 -------- src/qemu/qemu_driver.c | 24 ++++++++++++++++-------- src/qemu/qemu_hotplug.c | 5 ----- 6 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 93cfca351c..b8b53450fa 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28206,7 +28206,8 @@ int virDomainDefCompatibleDevice(virDomainDefPtr def, virDomainDeviceDefPtr dev, virDomainDeviceDefPtr oldDev, - virDomainDeviceAction action ATTRIBUTE_UNUSED) + virDomainDeviceAction action, + bool live) { virDomainCompatibleDeviceData data = { .newInfo = virDomainDeviceGetInfo(dev), @@ -28216,6 +28217,16 @@ virDomainDefCompatibleDevice(virDomainDefPtr def, if (oldDev) data.oldInfo = virDomainDeviceGetInfo(oldDev); + if (action == VIR_DOMAIN_DEVICE_ACTION_UPDATE && + live && + ((!!data.newInfo != !!data.oldInfo) || + (data.newInfo && data.oldInfo && + STRNEQ_NULLABLE(data.newInfo->alias, data.oldInfo->alias)))) { + virReportError(VIR_ERR_OPERATION_DENIED, "%s", + _("changing device alias is not allowed")); + return -1; + } + if (!virDomainDefHasUSB(def) && def->os.type != VIR_DOMAIN_OSTYPE_EXE && virDomainDeviceIsUSB(dev)) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f33405e097..71437dc485 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3107,7 +3107,8 @@ typedef enum { int virDomainDefCompatibleDevice(virDomainDefPtr def, virDomainDeviceDefPtr dev, virDomainDeviceDefPtr oldDev, - virDomainDeviceAction action); + virDomainDeviceAction action, + bool live); void virDomainRNGDefFree(virDomainRNGDefPtr def); diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 850b12726b..8c02f888f4 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3550,7 +3550,8 @@ lxcDomainUpdateDeviceConfig(virDomainDefPtr vmdef, oldDev.data.net = vmdef->nets[idx]; if (virDomainDefCompatibleDevice(vmdef, dev, &oldDev, - VIR_DOMAIN_DEVICE_ACTION_UPDATE) < 0) + VIR_DOMAIN_DEVICE_ACTION_UPDATE, + false) < 0) return -1; virDomainNetDefFree(vmdef->nets[idx]); @@ -4787,7 +4788,8 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom, goto endjob; if (virDomainDefCompatibleDevice(vmdef, dev, NULL, - VIR_DOMAIN_DEVICE_ACTION_ATTACH) < 0) + VIR_DOMAIN_DEVICE_ACTION_ATTACH, + false) < 0) goto endjob; if ((ret = lxcDomainAttachDeviceConfig(vmdef, dev)) < 0) @@ -4796,7 +4798,8 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom, if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (virDomainDefCompatibleDevice(vm->def, dev_copy, NULL, - VIR_DOMAIN_DEVICE_ACTION_ATTACH) < 0) + VIR_DOMAIN_DEVICE_ACTION_ATTACH, + true) < 0) goto endjob; if ((ret = lxcDomainAttachDeviceLive(dom->conn, driver, vm, dev_copy)) < 0) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6d203e1f2e..d750f3382a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8613,14 +8613,6 @@ qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk, return false; } - if (disk->info.alias && - STRNEQ_NULLABLE(disk->info.alias, orig_disk->info.alias)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, - _("cannot modify field '%s' of the disk"), - "alias"); - return false; - } - CHECK_EQ(info.bootIndex, "boot order", true); CHECK_EQ(rawio, "rawio", true); CHECK_EQ(sgio, "sgio", true); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8c0c681c4d..21c97feed8 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7886,7 +7886,8 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm, oldDev.data.disk = orig_disk; if (virDomainDefCompatibleDevice(vm->def, dev, &oldDev, - VIR_DOMAIN_DEVICE_ACTION_UPDATE) < 0) + VIR_DOMAIN_DEVICE_ACTION_UPDATE, + true) < 0) goto cleanup; if (!qemuDomainDiskChangeSupported(disk, orig_disk)) @@ -7945,7 +7946,8 @@ qemuDomainUpdateDeviceLive(virDomainObjPtr vm, if ((idx = qemuDomainFindGraphicsIndex(vm->def, dev->data.graphics)) >= 0) { oldDev.data.graphics = vm->def->graphics[idx]; if (virDomainDefCompatibleDevice(vm->def, dev, &oldDev, - VIR_DOMAIN_DEVICE_ACTION_UPDATE) < 0) + VIR_DOMAIN_DEVICE_ACTION_UPDATE, + true) < 0) return -1; } @@ -7956,7 +7958,8 @@ qemuDomainUpdateDeviceLive(virDomainObjPtr vm, if ((idx = virDomainNetFindIdx(vm->def, dev->data.net)) >= 0) { oldDev.data.net = vm->def->nets[idx]; if (virDomainDefCompatibleDevice(vm->def, dev, &oldDev, - VIR_DOMAIN_DEVICE_ACTION_UPDATE) < 0) + VIR_DOMAIN_DEVICE_ACTION_UPDATE, + true) < 0) return -1; } @@ -8410,7 +8413,8 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, oldDev.data.disk = vmdef->disks[pos]; if (virDomainDefCompatibleDevice(vmdef, dev, &oldDev, - VIR_DOMAIN_DEVICE_ACTION_UPDATE) < 0) + VIR_DOMAIN_DEVICE_ACTION_UPDATE, + false) < 0) return -1; virDomainDiskDefFree(vmdef->disks[pos]); @@ -8430,7 +8434,8 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, oldDev.data.graphics = vmdef->graphics[pos]; if (virDomainDefCompatibleDevice(vmdef, dev, &oldDev, - VIR_DOMAIN_DEVICE_ACTION_UPDATE) < 0) + VIR_DOMAIN_DEVICE_ACTION_UPDATE, + false) < 0) return -1; virDomainGraphicsDefFree(vmdef->graphics[pos]); @@ -8445,7 +8450,8 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, oldDev.data.net = vmdef->nets[pos]; if (virDomainDefCompatibleDevice(vmdef, dev, &oldDev, - VIR_DOMAIN_DEVICE_ACTION_UPDATE) < 0) + VIR_DOMAIN_DEVICE_ACTION_UPDATE, + false) < 0) return -1; virDomainNetDefFree(vmdef->nets[pos]); @@ -8537,7 +8543,8 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm, goto cleanup; if (virDomainDefCompatibleDevice(vmdef, dev, NULL, - VIR_DOMAIN_DEVICE_ACTION_ATTACH) < 0) + VIR_DOMAIN_DEVICE_ACTION_ATTACH, + false) < 0) goto cleanup; if ((ret = qemuDomainAttachDeviceConfig(vmdef, dev, caps, parse_flags, @@ -8547,7 +8554,8 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm, if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (virDomainDefCompatibleDevice(vm->def, dev_copy, NULL, - VIR_DOMAIN_DEVICE_ACTION_ATTACH) < 0) + VIR_DOMAIN_DEVICE_ACTION_ATTACH, + true) < 0) goto cleanup; if ((ret = qemuDomainAttachDeviceLive(vm, dev_copy, driver)) < 0) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 7a1bbc7c8c..a8991800b3 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3193,11 +3193,6 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, if (!newdev->info.alias && VIR_STRDUP(newdev->info.alias, olddev->info.alias) < 0) goto cleanup; - if (STRNEQ_NULLABLE(olddev->info.alias, newdev->info.alias)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot modify network device alias")); - goto cleanup; - } if (olddev->info.rombar != newdev->info.rombar) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot modify network device rom bar setting")); -- 2.16.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list