Blame SOURCES/virt-manager-virt-xml-Start-using-os-variant.patch

4d81f3
From ffa0e4e8e438319cb3c8856d1d7f48a8864afe2e Mon Sep 17 00:00:00 2001
4d81f3
Message-Id: <ffa0e4e8e438319cb3c8856d1d7f48a8864afe2e@dist-git>
4d81f3
From: Pavel Hrdina <phrdina@redhat.com>
4d81f3
Date: Tue, 13 Nov 2018 16:18:08 +0100
4d81f3
Subject: [PATCH] virt-xml: Start using --os-variant
4d81f3
4d81f3
From: Andrea Bolognani <abologna@redhat.com>
4d81f3
4d81f3
The option only works with --add-device for the time being,
4d81f3
so we prevent its use in all other cases.
4d81f3
4d81f3
It would be nice to have it work with --build-xml too, but
4d81f3
in that case the user would have to provide some extra
4d81f3
information that in the case of --add-device we can figure
4d81f3
out from the existing guest, and it's not entirely clear
4d81f3
whether that would even be that useful, so for now we're
4d81f3
not considering that case at all.
4d81f3
4d81f3
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
4d81f3
(cherry picked from commit d2d103a334e3beeb8e108137f50adee2e5c0e5fc)
4d81f3
4d81f3
https://bugzilla.redhat.com/show_bug.cgi?id=1649406
4d81f3
4d81f3
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
4d81f3
---
4d81f3
 .../virt-xml-kvm-add-disk-os-from-cmdline.xml      | 11 ++++++++++-
4d81f3
 .../virt-xml-kvm-add-network-os-from-cmdline.xml   | 11 ++++++++++-
4d81f3
 virt-xml                                           | 14 ++++++++++++++
4d81f3
 3 files changed, 34 insertions(+), 2 deletions(-)
4d81f3
4d81f3
diff --git a/tests/cli-test-xml/compare/virt-xml-kvm-add-disk-os-from-cmdline.xml b/tests/cli-test-xml/compare/virt-xml-kvm-add-disk-os-from-cmdline.xml
4d81f3
index e5e4bd62..cf872c1c 100644
4d81f3
--- a/tests/cli-test-xml/compare/virt-xml-kvm-add-disk-os-from-cmdline.xml
4d81f3
+++ b/tests/cli-test-xml/compare/virt-xml-kvm-add-disk-os-from-cmdline.xml
4d81f3
@@ -1,10 +1,19 @@
4d81f3
+   </description>
4d81f3
+   <metadata>
4d81f3
+     <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
4d81f3
+-      <libosinfo:os id="http://fedoraproject.org/fedora/unknown"/>
4d81f3
++      <libosinfo:os id="http://microsoft.com/win/me"/>
4d81f3
+     </libosinfo:libosinfo>
4d81f3
+   </metadata>
4d81f3
+   <memory unit="KiB">409600</memory>
4d81f3
+@@
4d81f3
      <panic model="s390"/>
4d81f3
      <panic model="pseries"/>
4d81f3
      <panic model="hyperv"/>
4d81f3
 +    <disk type="file" device="disk">
4d81f3
 +      <driver name="qemu" type="qcow2"/>
4d81f3
 +      <source file="/dev/default-pool/testvol1.img"/>
4d81f3
-+      <target dev="vdaf" bus="virtio"/>
4d81f3
++      <target dev="hdd" bus="ide"/>
4d81f3
 +    </disk>
4d81f3
    </devices>
4d81f3
    <seclabel type="dynamic" model="selinux" relabel="yes"/>
4d81f3
diff --git a/tests/cli-test-xml/compare/virt-xml-kvm-add-network-os-from-cmdline.xml b/tests/cli-test-xml/compare/virt-xml-kvm-add-network-os-from-cmdline.xml
4d81f3
index c834c936..8d278e7a 100644
4d81f3
--- a/tests/cli-test-xml/compare/virt-xml-kvm-add-network-os-from-cmdline.xml
4d81f3
+++ b/tests/cli-test-xml/compare/virt-xml-kvm-add-network-os-from-cmdline.xml
4d81f3
@@ -1,10 +1,19 @@
4d81f3
+   </description>
4d81f3
+   <metadata>
4d81f3
+     <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
4d81f3
+-      <libosinfo:os id="http://fedoraproject.org/fedora/unknown"/>
4d81f3
++      <libosinfo:os id="http://microsoft.com/win/me"/>
4d81f3
+     </libosinfo:libosinfo>
4d81f3
+   </metadata>
4d81f3
+   <memory unit="KiB">409600</memory>
4d81f3
+@@
4d81f3
      <panic model="s390"/>
4d81f3
      <panic model="pseries"/>
4d81f3
      <panic model="hyperv"/>
4d81f3
 +    <interface type="bridge">
4d81f3
 +      <source bridge="eth0"/>
4d81f3
 +      <mac address="00:11:22:33:44:55"/>
4d81f3
-+      <model type="virtio"/>
4d81f3
++      <model type="e1000"/>
4d81f3
 +    </interface>
4d81f3
    </devices>
4d81f3
    <seclabel type="dynamic" model="selinux" relabel="yes"/>
4d81f3
diff --git a/virt-xml b/virt-xml
4d81f3
index 65d9b55f..39abd297 100755
4d81f3
--- a/virt-xml
4d81f3
+++ b/virt-xml
4d81f3
@@ -56,6 +56,13 @@ def get_diff(origxml, newxml):
4d81f3
     return ret
4d81f3
 
4d81f3
 
4d81f3
+def set_distro_variant(options, guest):
4d81f3
+    if options.distro_variant is None:
4d81f3
+        return
4d81f3
+
4d81f3
+    guest.set_os_name(options.distro_variant)
4d81f3
+
4d81f3
+
4d81f3
 def get_domain_and_guest(conn, domstr):
4d81f3
     try:
4d81f3
         int(domstr)
4d81f3
@@ -175,6 +182,8 @@ def action_edit(guest, options, parserclass):
4d81f3
             fail(_("'--edit %s' doesn't make sense with --%s, "
4d81f3
                    "just use empty '--edit'") %
4d81f3
             (options.edit, parserclass.cli_arg_name))
4d81f3
+    if options.distro_variant is not None:
4d81f3
+        fail(_("--os-variant is not supported with --edit"))
4d81f3
 
4d81f3
     return cli.parse_option_strings(options, guest, inst, update=True)
4d81f3
 
4d81f3
@@ -182,6 +191,7 @@ def action_edit(guest, options, parserclass):
4d81f3
 def action_add_device(guest, options, parserclass):
4d81f3
     if not parserclass.prop_is_list(guest):
4d81f3
         fail(_("Cannot use --add-device with --%s") % parserclass.cli_arg_name)
4d81f3
+    set_distro_variant(options, guest)
4d81f3
     devs = cli.parse_option_strings(options, guest, None)
4d81f3
     devs = util.listify(devs)
4d81f3
     for dev in devs:
4d81f3
@@ -193,6 +203,8 @@ def action_remove_device(guest, options, parserclass):
4d81f3
     if not parserclass.prop_is_list(guest):
4d81f3
         fail(_("Cannot use --remove-device with --%s") %
4d81f3
              parserclass.cli_arg_name)
4d81f3
+    if options.distro_variant is not None:
4d81f3
+        fail(_("--os-variant is not supported with --remove-device"))
4d81f3
 
4d81f3
     devs = _find_objects_to_edit(guest, "remove-device",
4d81f3
         getattr(options, parserclass.cli_arg_name)[-1], parserclass)
4d81f3
@@ -207,6 +219,8 @@ def action_build_xml(conn, options, parserclass):
4d81f3
     if not parserclass.propname:
4d81f3
         fail(_("--build-xml not supported for --%s") %
4d81f3
              parserclass.cli_arg_name)
4d81f3
+    if options.distro_variant is not None:
4d81f3
+        fail(_("--os-variant is not supported with --build-xml"))
4d81f3
 
4d81f3
     guest = virtinst.Guest(conn)
4d81f3
     inst = parserclass.lookup_prop(guest)
4d81f3
-- 
4d81f3
2.19.2
4d81f3