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(a)redhat.com>
---
src/qemu/qemu_command.c | 9 +++++++++
tests/qemuxml2argvdata/graphics-vnc-policy.args | 2 +-
tests/qemuxml2argvdata/graphics-vnc-policy.xml | 2 +-
tests/qemuxml2argvtest.c | 2 +-
4 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d801018aa2..266cf7332e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7700,6 +7700,15 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
/* TODO: Support ACLs later */
}
+ if (graphics->data.vnc.powerControl) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNC_POWER_CONTROL)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("VNC power control is not available"));
+ return -1;
+ }
+ virBufferAddLit(&opt, ",power-control=on");
+ }
+
virCommandAddArg(cmd, "-vnc");
virCommandAddArgBuffer(cmd, &opt);
if (graphics->data.vnc.keymap)
diff --git a/tests/qemuxml2argvdata/graphics-vnc-policy.args
b/tests/qemuxml2argvdata/graphics-vnc-policy.args
index 85b7d722e0..d3a8d66161 100644
--- a/tests/qemuxml2argvdata/graphics-vnc-policy.args
+++ b/tests/qemuxml2argvdata/graphics-vnc-policy.args
@@ -26,5 +26,5 @@ server=on,wait=off \
-usb \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
--vnc '[::]:59630,share=allow-exclusive' \
+-vnc '[::]:59630,share=allow-exclusive,power-control=on' \
-vga cirrus
diff --git a/tests/qemuxml2argvdata/graphics-vnc-policy.xml
b/tests/qemuxml2argvdata/graphics-vnc-policy.xml
index 344f019079..4bee773438 100644
--- a/tests/qemuxml2argvdata/graphics-vnc-policy.xml
+++ b/tests/qemuxml2argvdata/graphics-vnc-policy.xml
@@ -25,7 +25,7 @@
<controller type='pci' index='0' model='pci-root'/>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
- <graphics type='vnc' port='65530' autoport='no'
listen='::' sharePolicy='allow-exclusive'>
+ <graphics type='vnc' port='65530' autoport='no'
listen='::' sharePolicy='allow-exclusive' powerControl='yes'>
<listen type='address' address='::'/>
</graphics>
<video>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index db438c5466..b4df042fea 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1364,7 +1364,7 @@ mymain(void)
QEMU_CAPS_VNC,
QEMU_CAPS_DEVICE_CIRRUS_VGA);
DO_TEST("graphics-vnc-policy", QEMU_CAPS_VNC,
- QEMU_CAPS_DEVICE_CIRRUS_VGA);
+ QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_VNC_POWER_CONTROL);
DO_TEST("graphics-vnc-no-listen-attr", QEMU_CAPS_VNC,
QEMU_CAPS_DEVICE_CIRRUS_VGA);
DO_TEST("graphics-vnc-remove-generated-socket", QEMU_CAPS_VNC,
--
2.29.2