[Libguestfs] [PATCH 4/4] Support multiple display types through guestcaps

Mike Latimer
Thu, 31 Oct 2013 20:14:07 -0000

---
 lib/Sys/VirtConvert/Connection/LibVirtTarget.pm | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/Sys/VirtConvert/Connection/LibVirtTarget.pm
b/lib/Sys/VirtConvert/Connection/LibVirtTarget.pm
index 6a09800..911a7da 100644
--- a/lib/Sys/VirtConvert/Connection/LibVirtTarget.pm
+++ b/lib/Sys/VirtConvert/Connection/LibVirtTarget.pm
@@ -336,6 +336,16 @@ sub _meta_to_domxml
 {
     my ($meta, $config, $guestcaps) = @_;

+    my $video_model;
+    my $display_type;
+    if ($guestcaps->{display} eq 'cirrus') {
+      $video_model = "model type='cirrus' vram='9216'
heads='1'";
+      $display_type = "vnc";
+    } else {
+      $video_model = "model type='qxl' ram='65536'
heads='1'";
+      $display_type = "spice";
+    }
+
     my $dom = new XML::DOM::Parser->parse(<<DOM);
 <domain type='kvm'>
   <os>
@@ -349,7 +359,7 @@ sub _meta_to_domxml



-      <model type='qxl' ram='65536' heads='1'/>
+      <$video_model/>

     <console type='pty'/>
   </devices>
@@ -386,7 +396,7 @@ DOM
     }

     my $graphics = _append_elem($devices, 'graphics');
-    $graphics->setAttribute('type', 'spice');
+    $graphics->setAttribute('type', $display_type);
     $graphics->setAttribute('keymap', $display_keymap)
         if defined($display_keymap);
     $graphics->setAttribute('passwd', $display_password)
--
1.8.1.4