[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[et-mgmt-tools] [PATCH] Port utility functions to Solaris



# HG changeset patch
# User john levon sun com
# Date 1228365030 28800
# Node ID 9e299e5ee2b46b8c3b737d5394498a855f553bae
# Parent  d9898b68352ad1c2491a3c9697d4b34af6630fc7
Port utility functions to Solaris

Port various utils to Solaris, and remove some unused ones that don't
work.

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

diff --git a/virtinst/FullVirtGuest.py b/virtinst/FullVirtGuest.py
--- a/virtinst/FullVirtGuest.py
+++ b/virtinst/FullVirtGuest.py
@@ -38,7 +38,8 @@ class FullVirtGuest(Guest):
             installer = DistroManager.DistroInstaller(type = type, os_type = "hvm")
         Guest.__init__(self, type, connection, hypervisorURI, installer)
         self.disknode = "hd"
-        self.features = { "acpi": None, "pae": util.is_pae_capable(), "apic": None }
+        self.features = { "acpi": None, "pae":
+            util.is_pae_capable(connection), "apic": None }
         if arch is None:
             arch = platform.machine()
         self.arch = arch
diff --git a/virtinst/util.py b/virtinst/util.py
--- a/virtinst/util.py
+++ b/virtinst/util.py
@@ -27,6 +27,7 @@ import logging
 import logging
 import commands
 import stat
+import popen2
 from sys import stderr
 
 import libvirt
@@ -56,8 +57,29 @@ def default_route():
             continue
     return None
 
-# Legacy for compat only.
+def default_nic():
+    """Return the default NIC to use, if one is specified."""
+
+    dev = ''
+
+    if platform.system() != 'SunOS':
+        return dev
+
+    # XXX: fails without PRIV_XVM_CONTROL
+    proc = popen2.Popen3(["/usr/lib/xen/bin/xenstore-read",
+        "device-misc/vif/default-nic"], capturestderr=True)
+    proc.tochild.close()
+    proc.wait()
+    out = proc.fromchild.readlines()
+    if len(out) > 0:
+        dev = out[0].rstrip()
+
+    return dev
+
 def default_bridge():
+    if platform.system() == 'SunOS':
+        return default_nic()
+
     rt = default_route()
     if rt is None:
         defn = None
@@ -70,6 +92,9 @@ def default_bridge():
         return "xenbr%d"%(defn)
 
 def default_network(conn):
+    if platform.system() == 'SunOS':
+        return ["bridge", default_nic()]
+
     dev = default_route()
 
     if dev is not None and not is_uri_remote(conn.getURI()):
@@ -100,6 +125,9 @@ def default_connection():
     return None
 
 def get_cpu_flags():
+    if platform.system() == 'SunOS':
+        raise OSError("CPU flags not available")
+
     f = open("/proc/cpuinfo")
     lines = f.readlines()
     f.close()
@@ -113,31 +141,16 @@ def get_cpu_flags():
         return flst
     return []
 
-def is_pae_capable():
+def is_pae_capable(conn):
     """Determine if a machine is PAE capable or not."""
-    flags = get_cpu_flags()
-    if "pae" in flags:
-        return True
-    return False
-
-def is_hvm_capable():
-    """Determine if a machine is HVM capable or not."""
-
-    caps = ""
-    if os.path.exists("/sys/hypervisor/properties/capabilities"):
-        caps = open("/sys/hypervisor/properties/capabilities").read()
-    if caps.find("hvm") != -1:
-        return True
-    return False
-
-def is_kqemu_capable():
-    return os.path.exists("/dev/kqemu")
-
-def is_kvm_capable():
-    return os.path.exists("/dev/kvm")
+    if not conn:
+        conn = libvirt.open('')
+    return "pae" in conn.getCapabilities()
 
 def is_blktap_capable():
-    #return os.path.exists("/dev/xen/blktapctrl")
+    if platform.system() == 'SunOS':
+        return False
+
     f = open("/proc/modules")
     lines = f.readlines()
     f.close()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]