[pve-devel] [PATCH 2/2] add spice support to qemu

Alexandre Derumier aderumier at odiso.com
Fri Jun 21 10:32:03 CEST 2013


add new option : spice: 1

this enable spice (currently without tls on socket), and force vga=qxl

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuServer.pm |   34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index d2b942f..25f163d 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -332,6 +332,12 @@ EODESC
 	type => 'boolean',
 	description => "Freeze CPU at startup (use 'c' monitor command to start execution).",
     },
+    spice => {
+	optional => 1,
+	type => 'boolean',
+	description => "Enable/disable Spice Console.",
+	default => 1,
+    },
     vga => {
 	optional => 1,
 	type => 'string',
@@ -2349,6 +2355,8 @@ sub config_to_command {
 	}
     }
 
+    $vga = 'qxl' if $conf->{spice};
+
     push @$cmd, '-vga', $vga if $vga; # for kvm 77 and later
 
     # time drift fix
@@ -2414,6 +2422,26 @@ sub config_to_command {
 	push @$devices, '-device', 'virtserialport,chardev=qga0,name=org.qemu.guest_agent.0';
     }
 
+    if($conf->{spice}){
+	    my $pciaddr = print_pci_addr("spice", $bridges);
+
+	    #tls support
+
+            my $x509 = "x509-key-file=/etc/pve/local/pve-ssl.key";
+            $x509 .= ",x509-cert-file=/etc/pve/local/pve-ssl.pem";
+            $x509 .= ",x509-cacert-file=/etc/pve/pve-root-ca.pem";
+
+	    #push @$cmd, '-spice',"port=60100,tls-port=60101,disable-ticketing,$x509,tls-ciphers=DES-CBC3-SHA";
+	    #push @$cmd, '-spice',"unix=$socket,$x509,tls-ciphers=DES-CBC3-SHA";
+
+	    my $socket = spice_socket($vmid);
+
+            push @$cmd, '-spice',"disable-ticketing,unix=$socket";
+            push @$cmd, '-device',"virtio-serial,id=spice$pciaddr";
+            push @$cmd, '-chardev',"spicevmc,id=vdagent,name=vdagent";
+            push @$cmd, '-device',"virtserialport,chardev=vdagent,name=com.redhat.spice.0";
+    }
+
     # enable balloon by default, unless explicitly disabled
     if (!defined($conf->{balloon}) || $conf->{balloon}) {
 	$pciaddr = print_pci_addr("balloon0", $bridges);
@@ -2537,6 +2565,11 @@ sub vnc_socket {
     return "${var_run_tmpdir}/$vmid.vnc";
 }
 
+sub spice_socket {
+    my ($vmid) = @_;
+    return "${var_run_tmpdir}/$vmid.spice";
+}
+
 sub qmp_socket {
     my ($vmid) = @_;
     return "${var_run_tmpdir}/$vmid.qmp";
@@ -3405,6 +3438,7 @@ sub print_pci_addr {
 	scsihw1 => { bus => 0, addr => 6 },
 	ahci0 => { bus => 0, addr => 7 },
 	qga0 => { bus => 0, addr => 8 },
+	spice => { bus => 0, addr => 9 },
 	virtio0 => { bus => 0, addr => 10 },
 	virtio1 => { bus => 0, addr => 11 },
 	virtio2 => { bus => 0, addr => 12 },
-- 
1.7.10.4




More information about the pve-devel mailing list