On Tue, Feb 16, 2021 at 18:10:31 +0000, Daniel Berrange wrote: > This allows the VNC client user to perform a shutdown, reboot and reset > of the VM from the host side. > > Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> > --- > src/qemu/qemu_command.c | 6 +++ > src/qemu/qemu_validate.c | 21 ++++++++++ > .../graphics-vnc-power.x86_64-latest.args | 40 +++++++++++++++++++ > tests/qemuxml2argvdata/graphics-vnc-power.xml | 36 +++++++++++++++++ > tests/qemuxml2argvtest.c | 1 + > 5 files changed, 104 insertions(+) > create mode 100644 tests/qemuxml2argvdata/graphics-vnc-power.x86_64-latest.args > create mode 100644 tests/qemuxml2argvdata/graphics-vnc-power.xml > > diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c > index d801018aa2..7597ffafd1 100644 > --- a/src/qemu/qemu_command.c > +++ b/src/qemu/qemu_command.c > @@ -7700,6 +7700,12 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, > /* TODO: Support ACLs later */ > } > > + if (graphics->data.vnc.powerControl != VIR_TRISTATE_BOOL_ABSENT) { > + virBufferAsprintf(&opt, ",power-control=%s", > + graphics->data.vnc.powerControl == VIR_TRISTATE_BOOL_YES ? > + "on" : "off"); > + } > + > virCommandAddArg(cmd, "-vnc"); > virCommandAddArgBuffer(cmd, &opt); > if (graphics->data.vnc.keymap) > diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c > index 2541ae856a..2f98209470 100644 > --- a/src/qemu/qemu_validate.c > +++ b/src/qemu/qemu_validate.c > @@ -3939,7 +3939,22 @@ qemuValidateDomainDeviceDefSPICEGraphics(const virDomainGraphicsDef *graphics, > return 0; > } > > +static int Two empty lines between functions please. > +qemuValidateDomainDeviceDefVNCGraphics(const virDomainGraphicsDef *graphics, > + virQEMUDriverPtr driver, > + virQEMUCapsPtr qemuCaps) > +{ > + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); clang says: ../../../libvirt/src/qemu/qemu_validate.c:3947:36: error: unused variable 'cfg' [-Werror,-Wunused-variable] g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); ^ 1 error generated. > + > + if (graphics->data.vnc.powerControl != VIR_TRISTATE_BOOL_ABSENT && > + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNC_POWER_CONTROL)) { > + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", > + _("VNC power control is not available")); > + return -1; > + } > > + return 0; > +} > static int Here too. > qemuValidateDomainDeviceDefGraphics(const virDomainGraphicsDef *graphics, > const virDomainDef *def, > @@ -4023,6 +4038,12 @@ qemuValidateDomainDeviceDefGraphics(const virDomainGraphicsDef *graphics, > break; > > case VIR_DOMAIN_GRAPHICS_TYPE_VNC: > + if (qemuValidateDomainDeviceDefVNCGraphics(graphics, driver, > + qemuCaps) < 0) > + return -1; > + > + break; > + > case VIR_DOMAIN_GRAPHICS_TYPE_RDP: > case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: > case VIR_DOMAIN_GRAPHICS_TYPE_LAST: