211690d47b
resolves: rhbz#2041886
79 lines
3.0 KiB
Diff
79 lines
3.0 KiB
Diff
From 4c3d0b8b3b4b99ac613b612f05e0810d64381999 Mon Sep 17 00:00:00 2001
|
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
Date: Wed, 19 Jan 2022 16:16:55 +0000
|
|
Subject: [PATCH] output: -o libvirt: Fix <graphics/> element port/autoport
|
|
|
|
According to https://libvirt.org/formatdomain.html only vnc and sdl
|
|
graphics types support port/autoport.
|
|
|
|
In addition, autoport='yes' is the non-deprecated replacement for
|
|
port='-1'. Since we don't need to support ancient libvirt, we don't
|
|
need to keep adding port='-1' in the autoport case. virt-xml-validate
|
|
rejects our XML if it has both attributes.
|
|
|
|
Thanks: Martin Kletzander
|
|
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
|
|
---
|
|
output/create_libvirt_xml.ml | 22 ++++++++++------------
|
|
tests/test-v2v-i-ova.xml | 2 +-
|
|
2 files changed, 11 insertions(+), 13 deletions(-)
|
|
|
|
diff --git a/output/create_libvirt_xml.ml b/output/create_libvirt_xml.ml
|
|
index 87bfab17..93ceb803 100644
|
|
--- a/output/create_libvirt_xml.ml
|
|
+++ b/output/create_libvirt_xml.ml
|
|
@@ -435,13 +435,18 @@ let create_libvirt_xml ?pool source inspect
|
|
|
|
let graphics =
|
|
match source.s_display with
|
|
- | None -> e "graphics" [ "type", "vnc" ] []
|
|
+ | None ->
|
|
+ e "graphics" [ "type", "vnc"; "autoport", "yes" ] []
|
|
| Some { s_display_type = Window } ->
|
|
e "graphics" [ "type", "sdl" ] []
|
|
- | Some { s_display_type = VNC } ->
|
|
- e "graphics" [ "type", "vnc" ] []
|
|
- | Some { s_display_type = Spice } ->
|
|
- e "graphics" [ "type", "spice" ] [] in
|
|
+ | Some { s_display_type = VNC; s_port = Some p } ->
|
|
+ e "graphics" [ "type", "vnc"; "port", string_of_int p ] []
|
|
+ | Some { s_display_type = VNC; s_port = None } ->
|
|
+ e "graphics" [ "type", "vnc"; "autoport", "yes" ] []
|
|
+ | Some { s_display_type = Spice; s_port = Some p } ->
|
|
+ e "graphics" [ "type", "spice"; "port", string_of_int p ] []
|
|
+ | Some { s_display_type = Spice; s_port = None } ->
|
|
+ e "graphics" [ "type", "spice"; "autoport", "yes" ] [] in
|
|
|
|
(match source.s_display with
|
|
| Some { s_keymap = Some km } -> append_attr ("keymap", km) graphics
|
|
@@ -469,13 +474,6 @@ let create_libvirt_xml ?pool source inspect
|
|
append_child sub graphics
|
|
)
|
|
| None -> ());
|
|
- (match source.s_display with
|
|
- | Some { s_port = Some p } ->
|
|
- append_attr ("autoport", "no") graphics;
|
|
- append_attr ("port", string_of_int p) graphics
|
|
- | Some { s_port = None } | None ->
|
|
- append_attr ("autoport", "yes") graphics;
|
|
- append_attr ("port", "-1") graphics);
|
|
List.push_back devices graphics;
|
|
|
|
let sound =
|
|
diff --git a/tests/test-v2v-i-ova.xml b/tests/test-v2v-i-ova.xml
|
|
index 2b6a8de0..e72c1db3 100644
|
|
--- a/tests/test-v2v-i-ova.xml
|
|
+++ b/tests/test-v2v-i-ova.xml
|
|
@@ -41,7 +41,7 @@
|
|
<video>
|
|
<model type='vga' vram='16384' heads='1'/>
|
|
</video>
|
|
- <graphics type='vnc' autoport='yes' port='-1'/>
|
|
+ <graphics type='vnc' autoport='yes'/>
|
|
<rng model='virtio-transitional'>
|
|
<backend model='random'>/dev/urandom</backend>
|
|
</rng>
|
|
--
|
|
2.31.1
|
|
|