提交 aa3e07ca 编写于 作者: K Katerina Koukiou

qemu: qemuDomainChangeNet: validity checks should be done before XML autocompletion

This patch ensures that changes in attributes of interfaces will emit
errors except if they are missing from the XML.
Previously we were falsely reporting successful updates, because some
changed attributes got overwritten before the validity checks.

https://bugzilla.redhat.com/show_bug.cgi?id=1599513Signed-off-by: NKaterina Koukiou <kkoukiou@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 8741b943
...@@ -3598,16 +3598,19 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, ...@@ -3598,16 +3598,19 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
goto cleanup; goto cleanup;
} }
/* info: if newdev->info is empty, fill it in from olddev, /* info: Nothing is allowed to change. First fill the missing newdev->info
* otherwise verify that it matches - nothing is allowed to * from olddev and then check for changes.
* change. (There is no helper function to do this, so
* individually check the few feidls of virDomainDeviceInfo that
* are relevant in this case).
*/ */
if (!virDomainDeviceAddressIsValid(&newdev->info, /* if pci addr is missing or is invalid we overwrite it from olddev */
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) && if (newdev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
virDomainDeviceInfoCopy(&newdev->info, &olddev->info) < 0) { !virDomainDeviceAddressIsValid(&newdev->info,
goto cleanup; newdev->info.type)) {
newdev->info.type = olddev->info.type;
newdev->info.addr = olddev->info.addr;
}
if (olddev->info.type != newdev->info.type) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify network device address type"));
} }
if (!virPCIDeviceAddressEqual(&olddev->info.addr.pci, if (!virPCIDeviceAddressEqual(&olddev->info.addr.pci,
&newdev->info.addr.pci)) { &newdev->info.addr.pci)) {
...@@ -3622,21 +3625,33 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, ...@@ -3622,21 +3625,33 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
/* device alias is checked already in virDomainDefCompatibleDevice */ /* device alias is checked already in virDomainDefCompatibleDevice */
if (newdev->info.rombar == VIR_TRISTATE_BOOL_ABSENT)
newdev->info.rombar = olddev->info.rombar;
if (olddev->info.rombar != newdev->info.rombar) { if (olddev->info.rombar != newdev->info.rombar) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify network device rom bar setting")); _("cannot modify network device rom bar setting"));
goto cleanup; goto cleanup;
} }
if (!newdev->info.romfile &&
VIR_STRDUP(newdev->info.romfile, olddev->info.romfile) < 0)
goto cleanup;
if (STRNEQ_NULLABLE(olddev->info.romfile, newdev->info.romfile)) { if (STRNEQ_NULLABLE(olddev->info.romfile, newdev->info.romfile)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify network rom file")); _("cannot modify network rom file"));
goto cleanup; goto cleanup;
} }
if (newdev->info.bootIndex == 0)
newdev->info.bootIndex = olddev->info.bootIndex;
if (olddev->info.bootIndex != newdev->info.bootIndex) { if (olddev->info.bootIndex != newdev->info.bootIndex) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify network device boot index setting")); _("cannot modify network device boot index setting"));
goto cleanup; goto cleanup;
} }
if (newdev->info.romenabled == VIR_TRISTATE_BOOL_ABSENT)
newdev->info.romenabled = olddev->info.romenabled;
if (olddev->info.romenabled != newdev->info.romenabled) { if (olddev->info.romenabled != newdev->info.romenabled) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify network device rom enabled setting")); _("cannot modify network device rom enabled setting"));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册