[pve-devel] [PATCH 1/3] add spice support

Alexandre Derumier aderumier at odiso.com
Wed Apr 10 13:08:09 CEST 2013


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

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 214c3be..7ab521a 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',
@@ -2286,6 +2292,8 @@ sub config_to_command {
 	}
     }
 
+    $vga = 'qxl' if $conf->{spice};
+
     push @$cmd, '-vga', $vga if $vga; # for kvm 77 and later
 
     # time drift fix
@@ -2346,6 +2354,21 @@ 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-cacert-file=/etc/pve/pve-root-ca.pem";
+            #$x509 .=",x509-key-file=/etc/pve/nodes/kvmtest1/pve-ssl.key";
+            #$x509 .= ",x509-cert-file=/etc/pve/nodes/kvmtest1/server-cert.pem";
+
+	    my $socket = spice_socket($vmid);
+            push @$cmd, '-spice',"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);
@@ -2469,6 +2492,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";
@@ -3363,6 +3391,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