mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
qemuDomainChangeGraphics: Check listen address change by listen type
Currently, we have a bug when updating a graphics device. A graphics device can
have a listen address set. This address is either defined by user (in which case
it's type is VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) or it can be inherited
from a network (in which case it's type is
VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK). However, in both cases we have a
listen address to process (e.g. during migration, as I've tried to fix in
7f15ebc7
).
Later, when a user tries to update the graphics device (e.g. set a password),
we check if listen addresses match the original as qemu doesn't know how to
change listen address yet. Hence, users are required to not change the listen
address. The implementation then just dumps listen addresses and compare them.
Previously, while dumping the listen addresses, NULL was returned for NETWORK.
After my patch, this is no longer true, and we get a listen address for olddev
even if it is a type of NETWORK. So we have a real string on one side, the NULL
from user's XML on the other side and hence we think user wants to change the
listen address and we refuse it.
Therefore, we must take the type of listen address into account as well.
This commit is contained in:
parent
c3358d14d9
commit
752596b5dd
@ -1960,10 +1960,9 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
|
|||||||
virDomainGraphicsDefPtr dev)
|
virDomainGraphicsDefPtr dev)
|
||||||
{
|
{
|
||||||
virDomainGraphicsDefPtr olddev = qemuDomainFindGraphics(vm, dev);
|
virDomainGraphicsDefPtr olddev = qemuDomainFindGraphics(vm, dev);
|
||||||
const char *oldListenAddr, *newListenAddr;
|
|
||||||
const char *oldListenNetwork, *newListenNetwork;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
size_t i;
|
||||||
|
|
||||||
if (!olddev) {
|
if (!olddev) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
@ -1971,10 +1970,49 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
oldListenAddr = virDomainGraphicsListenGetAddress(olddev, 0);
|
if (dev->nListens != olddev->nListens) {
|
||||||
newListenAddr = virDomainGraphicsListenGetAddress(dev, 0);
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
oldListenNetwork = virDomainGraphicsListenGetNetwork(olddev, 0);
|
_("cannot change the number of listen addresses"));
|
||||||
newListenNetwork = virDomainGraphicsListenGetNetwork(dev, 0);
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < dev->nListens; i++) {
|
||||||
|
virDomainGraphicsListenDefPtr listen = &dev->listens[i];
|
||||||
|
virDomainGraphicsListenDefPtr oldlisten = &olddev->listens[i];
|
||||||
|
|
||||||
|
if (listen->type != oldlisten->type) {
|
||||||
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
|
_("cannot change the type of listen address"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ((enum virDomainGraphicsListenType) listen->type) {
|
||||||
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
|
||||||
|
if (STRNEQ_NULLABLE(listen->address, oldlisten->address)) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
dev->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ?
|
||||||
|
_("cannot change listen address setting on vnc graphics") :
|
||||||
|
_("cannot change listen address setting on spice graphics"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK:
|
||||||
|
if (STRNEQ_NULLABLE(listen->network, oldlisten->network)) {
|
||||||
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
|
dev->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ?
|
||||||
|
_("cannot change listen network setting on vnc graphics") :
|
||||||
|
_("cannot change listen network setting on spice graphics"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE:
|
||||||
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
|
||||||
|
/* nada */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (dev->type) {
|
switch (dev->type) {
|
||||||
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
|
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
|
||||||
@ -1985,16 +2023,6 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
|
|||||||
_("cannot change port settings on vnc graphics"));
|
_("cannot change port settings on vnc graphics"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (STRNEQ_NULLABLE(oldListenAddr,newListenAddr)) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("cannot change listen address setting on vnc graphics"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (STRNEQ_NULLABLE(oldListenNetwork,newListenNetwork)) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("cannot change listen network setting on vnc graphics"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (STRNEQ_NULLABLE(olddev->data.vnc.keymap, dev->data.vnc.keymap)) {
|
if (STRNEQ_NULLABLE(olddev->data.vnc.keymap, dev->data.vnc.keymap)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("cannot change keymap setting on vnc graphics"));
|
_("cannot change keymap setting on vnc graphics"));
|
||||||
@ -2040,16 +2068,6 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
|
|||||||
_("cannot change port settings on spice graphics"));
|
_("cannot change port settings on spice graphics"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (STRNEQ_NULLABLE(oldListenAddr, newListenAddr)) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("cannot change listen address setting on spice graphics"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (STRNEQ_NULLABLE(oldListenNetwork, newListenNetwork)) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("cannot change listen network setting on spice graphics"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (STRNEQ_NULLABLE(olddev->data.spice.keymap,
|
if (STRNEQ_NULLABLE(olddev->data.spice.keymap,
|
||||||
dev->data.spice.keymap)) {
|
dev->data.spice.keymap)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
Loading…
Reference in New Issue
Block a user