[et-mgmt-tools] [PATCH 09 of 11] virt-convert: Add OS variant options

john.levon at sun.com john.levon at sun.com
Thu Jul 10 13:48:39 UTC 2008


# HG changeset patch
# User john.levon at sun.com
# Date 1215697571 25200
# Node ID 443b42b45ee6f799020a9418388440b93d9ab78c
# Parent  72eec78868efe7a872eab6c08502b3b84bf00a46
virt-convert: Add OS variant options

And use them to set ACPI, APIC, clock, and USB tablet.

Signed-off-by: John Levon <john.levon at sun.com>

diff --git a/man/en/virt-convert.1 b/man/en/virt-convert.1
--- a/man/en/virt-convert.1
+++ b/man/en/virt-convert.1
@@ -185,6 +185,151 @@
 .IP "\-q, \-\-quiet" 4
 .IX Item "-q, --quiet"
 Avoid verbose output.
+.IP "\-\-os\-type=OS_TYPE" 4
+.IX Item "--os-type=OS_TYPE"
+Optimize the guest configuration for a type of operating system. This will
+attempt to pick the most suitable \s-1ACPI\s0 & \s-1APIC\s0 settings, optimally supported
+mouse drivers and generally accommodate other operating system quirks. The
+valid operating system types are
+.RS 4
+.IP "linux" 4
+.IX Item "linux"
+Linux 2.x series
+.IP "windows" 4
+.IX Item "windows"
+Microsoft Windows 9x or later
+.IP "unix" 4
+.IX Item "unix"
+Traditional \s-1UNIX\s0 \s-1BSD\s0 or SysV derivatives
+.IP "other" 4
+.IX Item "other"
+Operating systems not in one of the 3 prior groups
+.RE
+.RS 4
+.RE
+.IP "\-\-os\-variant=OS_VARIANT" 4
+.IX Item "--os-variant=OS_VARIANT"
+Further optimize the guest configuration for a specific operating system
+variant. This parameter is optional. The valid variants are
+.RS 4
+.IP "linux" 4
+.IX Item "linux"
+.RS 4
+.PD 0
+.IP "rhel2.1" 4
+.IX Item "rhel2.1"
+.PD
+Red Hat Enterprise Linux 2.1
+.IP "rhel3" 4
+.IX Item "rhel3"
+Red Hat Enterprise Linux 3
+.IP "rhel4" 4
+.IX Item "rhel4"
+Red Hat Enterprise Linux 4
+.IP "rhel5" 4
+.IX Item "rhel5"
+Red Hat Enterprise Linux 5
+.IP "centos5" 4
+.IX Item "centos5"
+Cent \s-1OS\s0 5
+.IP "fedora5" 4
+.IX Item "fedora5"
+Fedora Core 5
+.IP "fedora6" 4
+.IX Item "fedora6"
+Fedora Core 6
+.IP "fedora7" 4
+.IX Item "fedora7"
+Fedora 7
+.IP "sles10" 4
+.IX Item "sles10"
+Suse Linux Enterprise Server 10.x
+.IP "debianEtch" 4
+.IX Item "debianEtch"
+Debian 4.0 (Etch)
+.IP "debianLenny" 4
+.IX Item "debianLenny"
+Debian Lenny
+.IP "generic26" 4
+.IX Item "generic26"
+Generic Linux 2.6.x kernel
+.IP "generic24" 4
+.IX Item "generic24"
+Generic Linux 2.4.x kernel
+.RE
+.RS 4
+.RE
+.IP "windows" 4
+.IX Item "windows"
+.RS 4
+.PD 0
+.IP "winxp" 4
+.IX Item "winxp"
+.PD
+Microsoft Windows \s-1XP\s0
+.IP "win2k" 4
+.IX Item "win2k"
+Microsoft Windows 2000
+.IP "win2k3" 4
+.IX Item "win2k3"
+Microsoft Windows 2003
+.IP "vista" 4
+.IX Item "vista"
+Microsoft Windows Vista
+.RE
+.RS 4
+.RE
+.IP "unix" 4
+.IX Item "unix"
+.RS 4
+.PD 0
+.IP "solaris9" 4
+.IX Item "solaris9"
+.PD
+Sun Solaris 9
+.IP "solaris10" 4
+.IX Item "solaris10"
+Sun Solaris 10
+.IP "freebsd6" 4
+.IX Item "freebsd6"
+Free \s-1BSD\s0 6.x
+.IP "openbsd4" 4
+.IX Item "openbsd4"
+Open \s-1BSD\s0 4.x
+.RE
+.RS 4
+.RE
+.IP "other" 4
+.IX Item "other"
+.RS 4
+.PD 0
+.IP "msdos" 4
+.IX Item "msdos"
+.PD
+Microsoft \s-1DOS\s0
+.IP "netware4" 4
+.IX Item "netware4"
+Novell Netware 4
+.IP "netware5" 4
+.IX Item "netware5"
+Novell Netware 5
+.IP "netware6" 4
+.IX Item "netware6"
+Novell Netware 6
+.RE
+.RS 4
+.RE
+.RE
+.RS 4
+.RE
+.IP "\-\-noapic" 4
+.IX Item "--noapic"
+Override the \s-1OS\s0 type / variant to disables the \s-1APIC\s0 setting for fully 
+virtualized guest.
+.IP "\-\-noacpi" 4
+.IX Item "--noacpi"
+Override the \s-1OS\s0 type / variant to disables the \s-1ACPI\s0 setting for fully 
+virtualized guest. 
 .SH "EXAMPLES"
 .IX Header "EXAMPLES"
 Convert a paravirt guest from \f(CW\*(C`image.vmx\*(C'\fR:
diff --git a/man/en/virt-convert.pod b/man/en/virt-convert.pod
--- a/man/en/virt-convert.pod
+++ b/man/en/virt-convert.pod
@@ -71,6 +71,176 @@
 
 Avoid verbose output.
 
+=item  --os-type=OS_TYPE
+
+Optimize the guest configuration for a type of operating system. This will
+attempt to pick the most suitable ACPI & APIC settings, optimally supported
+mouse drivers and generally accommodate other operating system quirks. The
+valid operating system types are
+
+=over 4
+
+=item linux
+
+Linux 2.x series
+
+=item windows
+
+Microsoft Windows 9x or later
+
+=item unix
+
+Traditional UNIX BSD or SysV derivatives
+
+=item other
+
+Operating systems not in one of the 3 prior groups
+
+=back
+
+=item --os-variant=OS_VARIANT
+
+Further optimize the guest configuration for a specific operating system
+variant. This parameter is optional. The valid variants are
+
+=over 4
+
+=item linux
+
+=over 4
+
+=item rhel2.1
+
+Red Hat Enterprise Linux 2.1
+
+=item rhel3
+
+Red Hat Enterprise Linux 3
+
+=item rhel4
+
+Red Hat Enterprise Linux 4
+
+=item rhel5
+
+Red Hat Enterprise Linux 5
+
+=item centos5
+
+Cent OS 5
+
+=item fedora5
+
+Fedora Core 5
+
+=item fedora6
+
+Fedora Core 6
+
+=item fedora7
+
+Fedora 7
+
+=item sles10
+
+Suse Linux Enterprise Server 10.x
+
+=item debianEtch
+
+Debian 4.0 (Etch)
+
+=item debianLenny
+
+Debian Lenny
+
+=item generic26
+
+Generic Linux 2.6.x kernel
+
+=item generic24
+
+Generic Linux 2.4.x kernel
+
+=back
+
+=item windows
+
+=over 4
+
+=item winxp
+
+Microsoft Windows XP
+
+=item win2k
+
+Microsoft Windows 2000
+
+=item win2k3
+
+Microsoft Windows 2003
+
+=item vista
+
+Microsoft Windows Vista
+
+=back
+
+=item unix
+
+=over 4
+
+=item solaris9
+
+Sun Solaris 9
+
+=item solaris10
+
+Sun Solaris 10
+
+=item freebsd6
+
+Free BSD 6.x
+
+=item openbsd4
+
+Open BSD 4.x
+
+=back
+
+=item other
+
+=over 4
+
+=item msdos
+
+Microsoft DOS
+
+=item netware4
+
+Novell Netware 4
+
+=item netware5
+
+Novell Netware 5
+
+=item netware6
+
+Novell Netware 6
+
+=back
+
+=back
+
+=item  --noapic
+
+Override the OS type / variant to disables the APIC setting for fully 
+virtualized guest.
+
+=item  --noacpi
+
+Override the OS type / variant to disables the ACPI setting for fully 
+virtualized guest. 
+
 =back
 
 =head1 EXAMPLES
diff --git a/virt-convert b/virt-convert
--- a/virt-convert
+++ b/virt-convert
@@ -59,6 +59,16 @@
                     help=("This guest should be a fully virtualized guest"))
     opts.add_option("-p", "--paravirt", action="store_true", dest="paravirt",
                     help=("This guest should be a paravirtualized guest"))
+    opts.add_option("", "--os-type", type="string", dest="os_type",
+                      action="callback", callback=cli.check_before_store,
+                      help=("The OS type for fully virtualized guests, e.g. 'linux', 'unix', 'windows'"))
+    opts.add_option("", "--os-variant", type="string", dest="os_variant",
+                      action="callback", callback=cli.check_before_store,
+                      help=("The OS variant for fully virtualized guests, e.g. 'fedora6', 'rhel5', 'solaris10', 'win2k', 'vista'"))
+    opts.add_option("", "--noapic", action="store_true", dest="noapic",
+        help=("Disables APIC for fully virtualized guest (overrides value in os-type/os-variant db)"), default=False)
+    opts.add_option("", "--noacpi", action="store_true", dest="noacpi",
+        help=("Disables ACPI for fully virtualized guest (overrides value in os-type/os-variant db)"), default=False)
 
     (options, args) = opts.parse_args()
     if len(args) < 1:
@@ -165,6 +175,10 @@
         vmdef.type = vmcfg.VM_TYPE_HVM
 
     vmdef.arch = options.arch
+    vmdef.os_type = options.os_type
+    vmdef.os_variant = options.os_variant
+    vmdef.noapic = options.noapic
+    vmdef.noacpi = options.noacpi
 
     clean = []
 
diff --git a/virtconv/parsers/virtimage.py b/virtconv/parsers/virtimage.py
--- a/virtconv/parsers/virtimage.py
+++ b/virtconv/parsers/virtimage.py
@@ -18,12 +18,13 @@
 # MA 02110-1301 USA.
 #
 
-from xml.sax.saxutils import escape
-from string import ascii_letters
 import virtconv.formats as formats
 import virtconv.vmcfg as vmcfg
 import virtconv.diskcfg as diskcfg
+import virtinst.FullVirtGuest as fv
 
+from xml.sax.saxutils import escape
+from string import ascii_letters
 import re
 
 pv_boot_template = """
@@ -31,6 +32,8 @@
    <guest>
     <arch>%(arch)s</arch>
     <features>
+     %(acpi)s
+     %(apic)s
      <pae/>
     </features>
    </guest>
@@ -74,6 +77,37 @@
  </storage>
 </image>
 """
+
+def export_os_params(vm):
+    """
+    Export OS-specific parameters.
+    """
+    ostype = None
+    osvariant = None
+
+    ostype = fv.OS_TYPES.get(vm.os_type)
+    if ostype:
+        osvariant = ostype.variants.get(vm.os_variant)
+
+    def get_os_val(key, default):
+        val = None
+        if osvariant:
+            val = osvariant.get(key)
+        if not val and ostype:
+            val = ostype.get(key)
+        if not val:
+            val = default
+        return val
+
+    acpi = ""
+    if vm.noacpi is False and get_os_val("acpi", True):
+        acpi = "<acpi />"
+
+    apic = ""
+    if vm.noapic is False and get_os_val("apic", False):
+        apic = "<apic />"
+
+    return acpi, apic
 
 def export_disks(vm):
     """
@@ -190,6 +224,8 @@
         if len(vm.netdevs):
             interface = "<interface />"
 
+        acpi, apic = export_os_params(vm)
+
         if vm.type == vmcfg.VM_TYPE_PV:
             boot_template = pv_boot_template
         else:
@@ -200,6 +236,8 @@
         boot_xml = boot_template % {
             "disks" : "".join(disks),
             "arch" : vm.arch,
+            "acpi" : acpi,
+            "apic" : apic,
         }
 
         out = image_template % {
diff --git a/virtconv/vmcfg.py b/virtconv/vmcfg.py
--- a/virtconv/vmcfg.py
+++ b/virtconv/vmcfg.py
@@ -55,6 +55,10 @@
         self.netdevs = {}
         self.type = VM_TYPE_HVM
         self.arch = "i686"
+        self.noacpi = None
+        self.noapic = None
+        self.os_type = None
+        self.os_variant = None
 
     def validate(self):
         """




More information about the et-mgmt-tools mailing list