mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
qemu: wire up support for VNC power control options
This allows the VNC client user to perform a shutdown, reboot and reset of the VM from the host side. Reviewed-by: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
bad5280a53
commit
fe82fdfb52
@ -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)
|
||||
|
@ -3930,6 +3930,21 @@ qemuValidateDomainDeviceDefSPICEGraphics(const virDomainGraphicsDef *graphics,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuValidateDomainDeviceDefVNCGraphics(const virDomainGraphicsDef *graphics,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
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
|
||||
qemuValidateDomainDeviceDefGraphics(const virDomainGraphicsDef *graphics,
|
||||
const virDomainDef *def,
|
||||
@ -4013,6 +4028,11 @@ qemuValidateDomainDeviceDefGraphics(const virDomainGraphicsDef *graphics,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
|
||||
if (qemuValidateDomainDeviceDefVNCGraphics(graphics, qemuCaps) < 0)
|
||||
return -1;
|
||||
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
|
||||
|
40
tests/qemuxml2argvdata/graphics-vnc-power.x86_64-latest.args
Normal file
40
tests/qemuxml2argvdata/graphics-vnc-power.x86_64-latest.args
Normal file
@ -0,0 +1,40 @@
|
||||
LC_ALL=C \
|
||||
PATH=/bin \
|
||||
HOME=/tmp/lib/domain--1-QEMUGuest1 \
|
||||
USER=test \
|
||||
LOGNAME=test \
|
||||
XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
|
||||
XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
|
||||
XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
|
||||
QEMU_AUDIO_DRV=none \
|
||||
/usr/bin/qemu-system-i386 \
|
||||
-name guest=QEMUGuest1,debug-threads=on \
|
||||
-S \
|
||||
-object secret,id=masterKey0,format=raw,\
|
||||
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
|
||||
-machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \
|
||||
-cpu qemu64 \
|
||||
-m 214 \
|
||||
-object memory-backend-ram,id=pc.ram,size=224395264 \
|
||||
-overcommit mem-lock=off \
|
||||
-smp 1,sockets=1,cores=1,threads=1 \
|
||||
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
|
||||
-no-user-config \
|
||||
-nodefaults \
|
||||
-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
|
||||
-mon chardev=charmonitor,id=monitor,mode=control \
|
||||
-rtc base=utc \
|
||||
-no-shutdown \
|
||||
-no-acpi \
|
||||
-boot strict=on \
|
||||
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
|
||||
-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1",\
|
||||
"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
|
||||
-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw",\
|
||||
"file":"libvirt-1-storage"}' \
|
||||
-device ide-hd,bus=ide.0,unit=0,drive=libvirt-1-format,id=ide0-0-0,bootindex=1 \
|
||||
-vnc '[::]:59630,power-control=on' \
|
||||
-device cirrus-vga,id=video0,bus=pci.0,addr=0x2 \
|
||||
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
||||
resourcecontrol=deny \
|
||||
-msg timestamp=on
|
36
tests/qemuxml2argvdata/graphics-vnc-power.xml
Normal file
36
tests/qemuxml2argvdata/graphics-vnc-power.xml
Normal file
@ -0,0 +1,36 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219100</memory>
|
||||
<currentMemory unit='KiB'>219100</currentMemory>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os>
|
||||
<type arch='i686' machine='pc'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-i386</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<driver name='qemu' type='raw'/>
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='usb' index='0'/>
|
||||
<controller type='ide' index='0'/>
|
||||
<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='::' powerControl='yes'>
|
||||
<listen type='address' address='::'/>
|
||||
</graphics>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1'/>
|
||||
</video>
|
||||
<memballoon model='none'/>
|
||||
</devices>
|
||||
</domain>
|
@ -1377,6 +1377,7 @@ mymain(void)
|
||||
QEMU_CAPS_DEVICE_CIRRUS_VGA);
|
||||
DO_TEST("graphics-vnc-policy", QEMU_CAPS_VNC,
|
||||
QEMU_CAPS_DEVICE_CIRRUS_VGA);
|
||||
DO_TEST_CAPS_LATEST("graphics-vnc-power");
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user