Hello community,

here is the log from the commit of package vm-install for openSUSE:Factory 
checked in at 2014-01-07 13:59:49
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/vm-install (Old)
 and      /work/SRC/openSUSE:Factory/.vm-install.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "vm-install"

Changes:
--------
--- /work/SRC/openSUSE:Factory/vm-install/vm-install.changes    2013-11-04 
08:50:59.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.vm-install.new/vm-install.changes       
2014-01-07 13:59:50.000000000 +0100
@@ -1,0 +2,14 @@
+Thu Jan 02 16:55:13 MDT 2014 - carn...@suse.com
+
+- Add support for sles12 and sled12
+- Add support in the upgrade feature to use the virsh XML format in
+  addition to the legacy xend sxp format
+- Version 0.8.0
+
+-------------------------------------------------------------------
+Thu Jan 02 16:55:13 MDT 2014 - carn...@suse.com
+
+- Add debug switch to allow starting VM's with 'xl'
+- Version 0.7.9
+
+-------------------------------------------------------------------

Old:
----
  vm-install-0.7.8.tar.bz2

New:
----
  vm-install-0.8.0.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ vm-install.spec ++++++
--- /var/tmp/diff_new_pack.nI0AJo/_old  2014-01-07 13:59:51.000000000 +0100
+++ /var/tmp/diff_new_pack.nI0AJo/_new  2014-01-07 13:59:51.000000000 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package vm-install
 #
-# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -22,12 +22,12 @@
 BuildRequires:  update-desktop-files
 # For directory ownership:
 BuildRequires:  yast2
-Version:        0.7.8
+Version:        0.8.0
 Release:        0
 Summary:        Tool to Define a Virtual Machine and Install Its Operating 
System
 License:        GPL-2.0
 Group:          System/Emulators/PC
-Source0:        %{name}-0.7.8.tar.bz2
+Source0:        %{name}-0.8.0.tar.bz2
 Source1:        vm-install.conf
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 ExclusiveArch:  %ix86 x86_64 s390x

++++++ vm-install-0.7.8.tar.bz2 -> vm-install-0.8.0.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/Makefile 
new/vm-install-0.8.0/Makefile
--- old/vm-install-0.7.8/Makefile       2013-10-16 18:43:56.000000000 +0200
+++ new/vm-install-0.8.0/Makefile       2014-01-06 22:48:24.000000000 +0100
@@ -1,5 +1,5 @@
 PACKAGE = vm-install
-VER = 0.7.8
+VER = 0.8.0
 
 default:
        @echo "Run 'make install DESTDIR=$destdir' to install."
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/bin/vm-install 
new/vm-install-0.8.0/bin/vm-install
--- old/vm-install-0.7.8/bin/vm-install 2013-10-16 18:43:54.000000000 +0200
+++ new/vm-install-0.8.0/bin/vm-install 2014-01-03 14:59:13.000000000 +0100
@@ -202,6 +202,8 @@
                       help="print debugging information")
     parser.add_option('', '--preserve-on-error', action='store_true', 
dest='preserve_on_error',
                       help="On error, do not delete temporary, configuration 
and image files")
+    parser.add_option('', '--use-xl', action='store_true', dest='use_xl',
+                      help="Use the xl command to start the VM; this is for 
debugging only")
 
     # Manually copy option keys/values into optparse's values, rather
     # than relying on optparse.parser.add_option, so my options class
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/setup.py 
new/vm-install-0.8.0/setup.py
--- old/vm-install-0.7.8/setup.py       2013-10-16 18:43:56.000000000 +0200
+++ new/vm-install-0.8.0/setup.py       2014-01-06 22:48:16.000000000 +0100
@@ -1,7 +1,7 @@
 from distutils.core import setup
 
 setup(name='vminstall',
-      version='0.7.8',
+      version='0.8.0',
       description='Define a virtual machine and install its operating system',
       author='Charles Coffing',
       author_email='ccoff...@novell.com',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vmdisks/disks.py 
new/vm-install-0.8.0/src/vmdisks/disks.py
--- old/vm-install-0.7.8/src/vmdisks/disks.py   2013-10-16 18:43:53.000000000 
+0200
+++ new/vm-install-0.8.0/src/vmdisks/disks.py   2013-12-06 18:42:08.000000000 
+0100
@@ -87,6 +87,14 @@
         os.chmod(filename, 0600)
     else:
         os.chmod(filename, 0644)
+
+    log.debug("Setting nocow flag")
+    cmd = '/usr/bin/chattr +C %s' % filename
+    log.debug("Running: %s" % cmd)
+    ret = os.system(cmd)
+    if ret:
+        log.debug("Setting nocow flag to %s failed" % filename)
+
     if sparse:
         offset = bytes - 1
         os.lseek(fd, offset, 0)
@@ -109,6 +117,20 @@
     log.debug("Creating qcow file '%s', %d bytes." % (filename, bytes))
     mb = str(bytes / 1024 / 1024) + 'M'
     fmt = '-f' + type
+    fd = os.open(filename, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | 
os.O_LARGEFILE | os.O_DIRECT);
+    if os.geteuid() == 0:
+        os.chmod(filename, 0600)
+    else:
+        os.chmod(filename, 0644)
+
+    log.debug("Setting nocow flag")
+    cmd = '/usr/bin/chattr +C %s' % filename
+    log.debug("Running: %s" % cmd)
+    ret = os.system(cmd)
+    if ret:
+        log.debug("Setting nocow flag to %s failed" % filename)
+    os.close(fd)
+ 
     if os.path.exists('/usr/bin/qemu-img'):
         vminstall.util.run(['/usr/bin/qemu-img', 'create', fmt, filename, mb])
     elif os.path.exists('/usr/bin/qemu-img-xen'):
@@ -120,6 +142,20 @@
     if not os.path.exists('/usr/sbin/vhd-util'):
         raise DiskResourceError(DiskResourceError.E_CREATE_FAILED, 
details='vhd-util not found')
     try:
+        fd = os.open(filename, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | 
os.O_LARGEFILE | os.O_DIRECT);
+        if os.geteuid() == 0:
+            os.chmod(filename, 0600)
+        else:
+            os.chmod(filename, 0644)
+
+        log.debug("Setting nocow flag")
+        cmd = '/usr/bin/chattr +C %s' % filename
+        log.debug("Running: %s" % cmd)
+        ret = os.system(cmd)
+        if ret:
+            log.debug("Setting nocow flag to %s failed" % filename)
+        os.close(fd)
+
         vminstall.util.run(['/usr/sbin/vhd-util', "create", "-n", filename, 
mb])
     except:
         raise DiskResourceError(DiskResourceError.E_CREATE_FAILED, 
details="Create %s failed" % filename)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vminstall/ParaVirtGuest.py 
new/vm-install-0.8.0/src/vminstall/ParaVirtGuest.py
--- old/vm-install-0.7.8/src/vminstall/ParaVirtGuest.py 2013-10-16 
18:43:54.000000000 +0200
+++ new/vm-install-0.8.0/src/vminstall/ParaVirtGuest.py 2014-01-03 
17:11:05.000000000 +0100
@@ -237,7 +237,7 @@
                     else:
                         vpart = traildigits(partition['name'])
                     log.info("Found kernel on partition %s." % vpart)
-                    boot_kernel_check = 
['sles11','sled11','opensuse11','opensuse12','opensuse13']
+                    boot_kernel_check = ['sles12', 'sled12', 
'sles11','sled11','opensuse11','opensuse12','opensuse13']
                     if self.options.os_type in boot_kernel_check:
                         path = os.path.dirname(_kernel)
                         checkAndSetDefaultBootKernel(mountpoint + path)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vminstall/VMDefaults.py 
new/vm-install-0.8.0/src/vminstall/VMDefaults.py
--- old/vm-install-0.7.8/src/vminstall/VMDefaults.py    2013-10-21 
23:31:57.000000000 +0200
+++ new/vm-install-0.8.0/src/vminstall/VMDefaults.py    2014-01-03 
17:09:36.000000000 +0100
@@ -364,6 +364,42 @@
     def direct_kernel_boot(self):
         return True
 
+class SLED12Defaults(SUSEDefaults):
+    def name(self):
+        return msg.sled12
+    def min_memory(self):
+        return 256
+    def default_memory(self):
+        return 512
+    def _disk_size(self):
+        return 16
+    def supports_32nonpae(self):
+        return False
+    def apic(self):
+        # Turned on even for uni-processor
+        return True
+    def is_upgradeable(self):
+        return True
+    def virtio(self):
+        if caps.is_kvm() or caps.is_qemu():
+            return True
+        else:
+            return False
+    def nics(self):
+        if caps.is_kvm() or caps.is_qemu():
+            return [ KvmNic(model='virtio') ]
+        else:
+            return [ XenNic(model='para') ]
+    def sound(self):
+        if caps.is_xen():
+            return "sb16"
+        else:
+            return "ac97"
+    def supports_direct_kernel_boot(self):
+        return True
+    def direct_kernel_boot(self):
+        return True
+
 class SLES8Defaults(SUSEDefaults):
     def name(self):
         return msg.sles8
@@ -442,6 +478,36 @@
     def direct_kernel_boot(self):
         return True
 
+class SLES12Defaults(SUSEDefaults):
+    def name(self):
+        return msg.sles12
+    def default_memory(self):
+        return 512
+    def _disk_size(self):
+        return 8
+    def num_vcpus(self):
+        return caps.vcpu_processors(4)
+    def apic(self):
+        return True
+    def is_upgradeable(self):
+        return True
+    def supports_32nonpae(self):
+        return False
+    def virtio(self):
+        if caps.is_kvm() or caps.is_qemu():
+            return True
+        else:
+            return False
+    def nics(self):
+        if caps.is_kvm() or caps.is_qemu():
+            return [ KvmNic(model='virtio') ]
+        else:
+            return [ XenNic(model='para') ]
+    def supports_direct_kernel_boot(self):
+        return True
+    def direct_kernel_boot(self):
+        return True
+
 class UbuntuDefaults(LinuxDefaults):
     def group(self):
         return 'ubuntu'
@@ -826,8 +892,10 @@
     'rhel6'    : RHEL6Defaults(),
     'sled10'   : SLED10Defaults(),
     'sled11'   : SLED11Defaults(),
+    'sled12'   : SLED12Defaults(),
     'sles10'   : SLES10Defaults(),
     'sles11'   : SLES11Defaults(),
+    'sles12'   : SLES12Defaults(),
     'sles8'    : SLES8Defaults(),
     'sles9'    : SLES9Defaults(),
     'suse'     : SUSEDefaults(),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vminstall/VMSUSE.py 
new/vm-install-0.8.0/src/vminstall/VMSUSE.py
--- old/vm-install-0.7.8/src/vminstall/VMSUSE.py        2013-10-16 
18:43:54.000000000 +0200
+++ new/vm-install-0.8.0/src/vminstall/VMSUSE.py        2014-01-03 
17:13:45.000000000 +0100
@@ -359,7 +359,8 @@
                 if options.direct_kernel_boot:
                     virtio = False
                     if caps.is_kvm():
-                        if options.os_type == 'sles11' or options.os_type == 
'sled11' or \
+                        if options.os_type == 'sles12' or options.os_type == 
'sled12' or \
+                           options.os_type == 'sles11' or options.os_type == 
'sled11' or \
                            options.os_type == 'opensuse11' or options.os_type 
== 'opensuse12' or \
                            options.os_type == 'opensuse13':
                             virtio = True
@@ -421,7 +422,9 @@
             (fd, tmpdisk) = tempfile.mkstemp(prefix='autoyast.')
             virtio = False
             if guest.options.direct_kernel_boot and caps.is_kvm():
-                if guest.options.os_type == 'sles11' or \
+                if guest.options.os_type == 'sles12' or \
+                   guest.options.os_type == 'sled12' or \
+                   guest.options.os_type == 'sles11' or \
                    guest.options.os_type == 'sled11' or \
                    guest.options.os_type == 'opensuse11' or \
                    guest.options.os_type == 'opensuse12' or \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vminstall/caps.py 
new/vm-install-0.8.0/src/vminstall/caps.py
--- old/vm-install-0.7.8/src/vminstall/caps.py  2013-10-16 18:43:54.000000000 
+0200
+++ new/vm-install-0.8.0/src/vminstall/caps.py  2014-01-03 17:10:34.000000000 
+0100
@@ -222,4 +222,8 @@
                 return 'sles11'
             if line.startswith('SUSE Linux Enterprise Desktop 11'):
                 return 'sled11'
-    return 'sles11'
+            if line.startswith('SUSE Linux Enterprise Server 12'):
+                return 'sles12'
+            if line.startswith('SUSE Linux Enterprise Desktop 12'):
+                return 'sled12'
+    return 'sles12'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vminstall/console.py 
new/vm-install-0.8.0/src/vminstall/console.py
--- old/vm-install-0.7.8/src/vminstall/console.py       2013-10-16 
18:43:54.000000000 +0200
+++ new/vm-install-0.8.0/src/vminstall/console.py       2014-01-03 
00:53:32.000000000 +0100
@@ -152,8 +152,11 @@
             default_viewer = 'vncviewer'
         else:
             default_viewer = 'virt-viewer'
-        domid = self.get_domid_from_uuid(guest.uuid)
-        vncport = self.get_vnc_port_from_domid(domid, timeout=10.0)
+        if guest.options.use_xl:
+            vncport = 5900
+        else:
+            domid = self.get_domid_from_uuid(guest.uuid)
+            vncport = self.get_vnc_port_from_domid(domid, timeout=10.0)
         if vncport == None:
             log.info("Did not find VNC port, so not using VNC.")
             raise NotImplementedError
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vminstall/hypervisor.py 
new/vm-install-0.8.0/src/vminstall/hypervisor.py
--- old/vm-install-0.7.8/src/vminstall/hypervisor.py    2013-10-16 
18:43:54.000000000 +0200
+++ new/vm-install-0.8.0/src/vminstall/hypervisor.py    2014-01-03 
22:49:55.000000000 +0100
@@ -63,14 +63,8 @@
     # Method: domain_running
     
#---------------------------------------------------------------------------
     def domain_running(self, domid):
-        domain = self.domain(domid)
-        if not domain:
-            return False
-        for d in domain:
-            if type(d) == list and len(d) > 1 and d[0] == 'state':
-                # Any state means there is an instance...
-                return len(d[1]) > 1
-        return False
+        #TODO: any code that is stubb, should probably produce an exception
+        pass
 
 
     
#---------------------------------------------------------------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vminstall/job.py 
new/vm-install-0.8.0/src/vminstall/job.py
--- old/vm-install-0.7.8/src/vminstall/job.py   2013-10-16 18:43:54.000000000 
+0200
+++ new/vm-install-0.8.0/src/vminstall/job.py   2014-01-06 21:46:02.000000000 
+0100
@@ -405,6 +405,228 @@
                     pass
         return (xml_cf, xen_cf)
         
+    def _find_closing_brace(self, line, index, end):
+        closing_brace_found = 0
+        while index < end:
+            if line[index] == ")" or line[index] == ">":
+                closing_brace_found = 1
+                index = index + 1
+                break
+            index += 1
+        return (index, closing_brace_found)
+
+    def _partition_line(self, line, sep):
+        list = line.split(sep)
+        a = b = c = ""
+        idx = 0
+        b = sep
+        for s in list:
+            if idx == 0:
+                a = s 
+            else:
+                c = c + s
+            idx = idx + 1
+        return (a,b,c)
+
+    def _parse_sxp(self, f, lines):
+        kernel_found = 0
+        bootloader_found = 0
+        bootloader_args_found = 0
+        ramdisk_found = 0
+        args_found = 0
+        on_reboot_found = 0
+
+        for line in lines:
+            while True:
+                if not kernel_found:
+                    index = line.find("(kernel ")
+                    if index != -1:
+                        kernel_found = 1
+                        _line = line[0:index]
+                        new = "           (kernel " + self.guest.kernel + ")\n"
+                        if not ramdisk_found:
+                            new = new + "           (ramdisk " + 
self.guest.initrd + ")\n"
+                            ramdisk_found = 1
+                        _line = _line + new
+                        end = len(line)
+                        (index,found) = self._find_closing_brace(line, index, 
end)
+                        line = _line + line[index:end]
+                        continue
+                if not bootloader_found:
+                    index = line.find("(bootloader ")
+                    if index != -1:
+                        bootloader_found = 1
+                        end = len(line)
+                        (end,found) = self._find_closing_brace(line, index, 
end)
+                        sep = line[index:end]
+                        (a,b,c) = self._partition_line(line, sep)
+                        if c.strip(" \n") == "" and a.strip(" ") == "":
+                            c = ""
+                        if a.strip(" ") == "":
+                            a = ""
+                        line = a + c
+                        continue
+                if not bootloader_args_found:
+                    index = line.find("(bootloader_args ")
+                    if index != -1:
+                        bootloader_args_found = 1
+                        end = len(line)
+                        (end,found) = self._find_closing_brace(line, index, 
end)
+                        sep = line[index:end]
+                        (a,b,c) = self._partition_line(line, sep)
+                        if c.strip(" \n") == "" and a.strip(" ") == "":
+                            c = ""
+                        if a.strip(" ") == "":
+                            a = ""
+                        line = a + c
+                        continue
+                if not ramdisk_found:
+                    index = line.find("(ramdisk ")
+                    if index != -1:
+                        ramdisk_found = 1
+                        end = len(line)
+                        (end,found) = self._find_closing_brace(line, index, 
end)
+                        sep = line[index:end]
+                        (a,b,c) = self._partition_line(line, sep)
+                        if found:
+                            new = "           (ramdisk " + self.guest.initrd + 
")\n"
+                        else:
+                            new = "           (ramdisk " + self.guest.initrd + 
"\n"
+                        line = a + new + c
+                        continue
+                if not args_found:
+                    index = line.find("(args ")
+                    if index != -1:
+                        args_found = 1
+                        end = len(line)
+                        (end,found) = self._find_closing_brace(line, index, 
end)
+                        sep = line[index:end]
+                        (a,b,c) = self._partition_line(line, sep)
+                        args_line = "           (args \' install=" + 
self.guest.options.source
+                        if self.guest.options.extra_args:
+                            args_line = args_line + " " + 
self.guest.options.extra_args
+                        if found:
+                            new = args_line + "\')\n"
+                        else:
+                            new = args_line + "\'\n"
+                        line = a + new + c
+                        continue
+                if not on_reboot_found:
+                    index = line.find("(on_reboot ")
+                    if index != -1:
+                        on_reboot_found = 1
+                        end = len(line)
+                        (end,found) = self._find_closing_brace(line, index, 
end)
+                        sep = line[index:end]
+                        (a,b,c) = self._partition_line(line, sep)
+                        if found:
+                            new = "(on_reboot destroy)" 
+                        else:
+                            new = "(on_reboot destroy" 
+                        line = a + new + c
+                        continue
+                f.write(line)
+                break
+
+    def _parse_xml(self, f, lines):
+        kernel_found = 0
+        bootloader_found = 0
+        bootloader_args_found = 0
+        ramdisk_found = 0
+        args_found = 0
+        on_reboot_found = 0
+        for line in lines:
+            while True:
+                if not kernel_found:
+                    index = line.find("<kernel>")
+                    if index != -1:
+                        kernel_found = 1
+                        _line = line[0:index]
+                        new = "    <kernel>" + self.guest.kernel + 
"</kernel>\n"
+                        if not ramdisk_found:
+                            new = new + "    <initrd>" + self.guest.initrd + 
"</initrd>\n"
+                            ramdisk_found = 1
+                        _line = _line + new
+                        end = len(line)
+                        (index,found) = self._find_closing_brace(line, index, 
end)
+                        line = _line + line[index:end]
+                        continue
+                if not bootloader_found:
+                    index = line.find("<bootloader>")
+                    if index != -1:
+                        bootloader_found = 1
+                        end = len(line)
+                        (end,found) = self._find_closing_brace(line, index, 
end)
+                        sep = line[index:end]
+                        (a,b,c) = self._partition_line(line, sep)
+                        if c.strip(" \n") == "" and a.strip(" ") == "":
+                            c = ""
+                        if a.strip(" ") == "":
+                            a = ""
+                        line = a + c
+                        continue
+                if not bootloader_args_found:
+                    index = line.find("<bootloader_args>")
+                    if index != -1:
+                        bootloader_args_found = 1
+                        end = len(line)
+                        (end,found) = self._find_closing_brace(line, index, 
end)
+                        sep = line[index:end]
+                        (a,b,c) = self._partition_line(line, sep)
+                        if c.strip(" \n") == "" and a.strip(" ") == "":
+                            c = ""
+                        if a.strip(" ") == "":
+                            a = ""
+                        line = a + c
+                        continue
+                if not ramdisk_found:
+                    index = line.find("<initrd>")
+                    if index != -1:
+                        ramdisk_found = 1
+                        end = len(line)
+                        (end,found) = self._find_closing_brace(line, index, 
end)
+                        sep = line[index:end]
+                        (a,b,c) = self._partition_line(line, sep)
+                        if found:
+                            new = "    <initrd>" + self.guest.initrd + 
"</initrd>\n"
+                        else:
+                            new = "    <initrd>" + self.guest.initrd + 
"</initrd>\n"
+                        line = a + new + c
+                        continue
+                if not args_found:
+                    index = line.find("<cmdline>")
+                    if index != -1:
+                        args_found = 1
+                        end = len(line)
+                        (end,found) = self._find_closing_brace(line, index, 
end)
+                        sep = line[index:end]
+                        (a,b,c) = self._partition_line(line, sep)
+                        args_line = "    <cmdline>\' install=" + 
self.guest.options.source
+                        if self.guest.options.extra_args:
+                            args_line = args_line + " " + 
self.guest.options.extra_args
+                        if found:
+                            new = args_line + "\'</cmdline>\n"
+                        else:
+                            new = args_line + "\'</cmdline>\n"
+                        line = a + new + c
+                        continue
+                if not on_reboot_found:
+                    index = line.find("<on_reboot>")
+                    if index != -1:
+                        on_reboot_found = 1
+                        end = len(line)
+                        (end,found) = self._find_closing_brace(line, index, 
end)
+                        sep = line[index:end]
+                        (a,b,c) = self._partition_line(line, sep)
+                        if found:
+                            new = "<on_reboot>destroy</on_reboot>" 
+                        else:
+                            new = "<on_reboot>destroy</on_reboot>" 
+                        line = a + new + c
+                        continue
+                f.write(line)
+                break
+
     def _write_upgrade_conf(self):
         # Edit the existing guest configuration or sxp file to prepare for 
upgrade.
         # 1. Remove the lines that begin with (bootloader and (bootloader_args 
@@ -425,130 +647,14 @@
             log.debug('Error: Creating temporary configuration files for 
upgrading has failed')
             raise InstSrcError(err=InstSrcError.E_CONFIG)
         f = open(fname, "w+")
-        kernel_found = 0
-        bootloader_found = 0
-        bootloader_args_found = 0
-        ramdisk_found = 0
-        args_found = 0
-        on_reboot_found = 0
 
-        def find_closing_brace(_line, index, end):
-            closing_brace_found = 0
-            while index < end:
-                if line[index] == ")":
-                    closing_brace_found = 1
-                    index = index + 1
-                    break
-                index += 1
-            return (index, closing_brace_found)
-
-        def partition_line(line, sep):
-            list = line.split(sep)
-            a = b = c = ""
-            idx = 0
-            b = sep
-            for s in list:
-                if idx == 0:
-                    a = s 
-                else:
-                    c = c + s
-                idx = idx + 1
-            return (a,b,c)
-
-        for line in lines:
-            if self._options.upgrade_managed_vm:
-                # This is an sxp file format
-                while True:
-                    if not kernel_found:
-                        index = line.find("(kernel ")
-                        if index != -1:
-                            kernel_found = 1
-                            _line = line[0:index]
-                            new = "           (kernel " + self.guest.kernel + 
")\n"
-                            if not ramdisk_found:
-                                new = new + "           (ramdisk " + 
self.guest.initrd + ")\n"
-                                ramdisk_found = 1
-                            _line = _line + new
-                            end = len(line)
-                            (index,found) = find_closing_brace(line, index, 
end)
-                            line = _line + line[index:end]
-                            continue
-                    if not bootloader_found:
-                        index = line.find("(bootloader ")
-                        if index != -1:
-                            bootloader_found = 1
-                            end = len(line)
-                            (end,found) = find_closing_brace(line, index, end)
-                            sep = line[index:end]
-                            (a,b,c) = partition_line(line, sep)
-                            if c.strip(" \n") == "" and a.strip(" ") == "":
-                                c = ""
-                            if a.strip(" ") == "":
-                                a = ""
-                            line = a + c
-                            continue
-                    if not bootloader_args_found:
-                        index = line.find("(bootloader_args ")
-                        if index != -1:
-                            bootloader_args_found = 1
-                            end = len(line)
-                            (end,found) = find_closing_brace(line, index, end)
-                            sep = line[index:end]
-                            (a,b,c) = partition_line(line, sep)
-                            if c.strip(" \n") == "" and a.strip(" ") == "":
-                                c = ""
-                            if a.strip(" ") == "":
-                                a = ""
-                            line = a + c
-                            continue
-                    if not ramdisk_found:
-                        index = line.find("(ramdisk ")
-                        if index != -1:
-                            ramdisk_found = 1
-                            end = len(line)
-                            (end,found) = find_closing_brace(line, index, end)
-                            sep = line[index:end]
-                            (a,b,c) = partition_line(line, sep)
-                            if found:
-                                new = "           (ramdisk " + 
self.guest.initrd + ")\n"
-                            else:
-                                new = "           (ramdisk " + 
self.guest.initrd + "\n"
-                            line = a + new + c
-                            continue
-                    if not args_found:
-                        index = line.find("(args ")
-                        if index != -1:
-                            args_found = 1
-                            end = len(line)
-                            (end,found) = find_closing_brace(line, index, end)
-                            sep = line[index:end]
-                            (a,b,c) = partition_line(line, sep)
-                            args_line = "           (args \' install=" + 
self.guest.options.source
-                            if self.guest.options.extra_args:
-                                args_line = args_line + " " + 
self.guest.options.extra_args
-                            if found:
-                                new = args_line + "\')\n"
-                            else:
-                                new = args_line + "\'\n"
-                            line = a + new + c
-                            continue
-                    if not on_reboot_found:
-                        index = line.find("(on_reboot ")
-                        if index != -1:
-                            on_reboot_found = 1
-                            end = len(line)
-                            (end,found) = find_closing_brace(line, index, end)
-                            sep = line[index:end]
-                            (a,b,c) = partition_line(line, sep)
-                            if found:
-                                new = "(on_reboot destroy)" 
-                            else:
-                                new = "(on_reboot destroy" 
-                            line = a + new + c
-                            continue
-                    f.write(line)
-                    break
+        if self._options.upgrade_managed_vm:
+            if util.is_xend_running():
+                self._parse_sxp(f, lines)
             else:
+                self._parse_xml(f, lines)
+        else:
+            for line in lines:
                 # This is a legacy config file format
                 value = line[:-1].split('=', 1)[1]
                 value = value.strip('"')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vminstall/libvirt_hypervisor.py 
new/vm-install-0.8.0/src/vminstall/libvirt_hypervisor.py
--- old/vm-install-0.7.8/src/vminstall/libvirt_hypervisor.py    2013-10-16 
18:43:54.000000000 +0200
+++ new/vm-install-0.8.0/src/vminstall/libvirt_hypervisor.py    2014-01-03 
22:55:27.000000000 +0100
@@ -15,6 +15,7 @@
 
 from   hypervisor import Hypervisor
 from   exceptions import ParamError
+from   libvirt import VIR_DOMAIN_SHUTOFF
 from   log import log 
 import libvirt
 import caps
@@ -167,6 +168,18 @@
 
 
     
#---------------------------------------------------------------------------
+    # Method: domain_running
+    
#---------------------------------------------------------------------------
+    def domain_running(self, domid):
+        domain = self.domain(domid)
+        if not domain:
+            return False
+        state = domain.state()
+        if state[0] == VIR_DOMAIN_SHUTOFF:
+            return False
+        return True
+
+    
#---------------------------------------------------------------------------
     # Method: info
     
#---------------------------------------------------------------------------
     def info(self):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vminstall/msg.py 
new/vm-install-0.8.0/src/vminstall/msg.py
--- old/vm-install-0.7.8/src/vminstall/msg.py   2013-10-16 18:43:54.000000000 
+0200
+++ new/vm-install-0.8.0/src/vminstall/msg.py   2014-01-03 17:08:39.000000000 
+0100
@@ -140,8 +140,10 @@
 rhel6 = _("RedHat Enterprise Linux 6")
 sled10 = _("SUSE Linux Enterprise Desktop 10")
 sled11 = _("SUSE Linux Enterprise Desktop 11")
+sled12 = _("SUSE Linux Enterprise Desktop 12")
 sles10 = _("SUSE Linux Enterprise Server 10")
 sles11 = _("SUSE Linux Enterprise Server 11")
+sles12 = _("SUSE Linux Enterprise Server 12")
 sles8 = _("SUSE Linux Enterprise Server 8")
 sles9 = _("SUSE Linux Enterprise Server 9")
 solaris10 = _("Solaris 10")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vminstall/options.py 
new/vm-install-0.8.0/src/vminstall/options.py
--- old/vm-install-0.7.8/src/vminstall/options.py       2013-10-22 
21:55:51.000000000 +0200
+++ new/vm-install-0.8.0/src/vminstall/options.py       2014-01-06 
21:45:07.000000000 +0100
@@ -30,6 +30,7 @@
 import paths
 import advanced
 import sound
+import xml
 
 on_exit = ["destroy", "restart", "preserve", "rename-restart", 
"coredump-destroy", "coredump-restart"]
 
@@ -91,6 +92,7 @@
             'upgrade_config',   # config file or generated sxp file
             'passthrough',
             'host_devices',
+            'use_xl',
         )
         default_keys = default_keys + 
tuple(vminstall.advanced.get_advanced_args())
         dict.__init__(self, dict(map(lambda k: (k, None), default_keys)))
@@ -286,6 +288,9 @@
         elif item == 'host_devices':
             check_type(value, (list,))
             host_devices = value
+        elif item == 'use_xl':
+            check_type(value, (int, bool))
+            value = bool(value)
         elif item == 'connect':
             import libvirt_hypervisor
             import xen_hypervisor
@@ -608,7 +613,7 @@
     elif vminstall.globals.default_graphics_viewer and not 
defaults.graphics_viewer:
         options.graphics_viewer = defaults.graphics_viewer = 
vminstall.globals.default_graphics_viewer
     else:
-        if os.path.exists('/usr/bin/virt-viewer'):
+        if os.path.exists('/usr/bin/virt-viewer') and options.use_libvirt is 
True:
             defaults.graphics_viewer = 'virt-viewer'
         else:
             defaults.graphics_viewer = 'vnc'
@@ -747,6 +752,9 @@
     defaults.debug = options.debug
     defaults.ui = options.ui
     defaults.background = options.background
+    if options.use_xl:
+        defaults.graphics_viewer = 'vnc'
+    defaults.use_xl = options.use_xl
 
     if defaults.background:
         defaults.noautoconsole = True
@@ -839,9 +847,14 @@
     if not options.upgrade_managed_vm:
         vm_name = options.upgrade_config
     (fname, lines, bname) = util.read_config_file(vm_name, 
options.upgrade_managed_vm, 0)
+    log.debug('Returned from reading configuration file: %s' % fname)
     if fname is None:
         log.debug('Error reading configuration file for %s' % vm_name)
         raise InstSrcError(err=InstSrcError.E_CONFIG)
+    if not util.is_xend_running():
+        xml.merge(fname, options)
+        os.unlink(fname)
+        return
     os.unlink(fname)
     extra_args = options.extra_args
     options.disks = None
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vminstall/passthrough.py 
new/vm-install-0.8.0/src/vminstall/passthrough.py
--- old/vm-install-0.7.8/src/vminstall/passthrough.py   2013-10-16 
18:43:54.000000000 +0200
+++ new/vm-install-0.8.0/src/vminstall/passthrough.py   2013-12-09 
22:43:55.000000000 +0100
@@ -85,7 +85,7 @@
 
 # Create the list of USB devices
 def get_host_usb_devices():
-    lines = util.run(['/usr/sbin/lsusb'])
+    lines = util.run(['/usr/bin/lsusb'])
     i = 0
     usb_devices = []
     for line in lines.splitlines():
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vminstall/util.py 
new/vm-install-0.8.0/src/vminstall/util.py
--- old/vm-install-0.7.8/src/vminstall/util.py  2013-10-16 18:43:54.000000000 
+0200
+++ new/vm-install-0.8.0/src/vminstall/util.py  2014-01-03 22:56:06.000000000 
+0100
@@ -297,17 +297,20 @@
 
 def get_running_vms():
     managed_vms = []
+    use_virsh = False
     if is_xend_running():
         rfd = os.popen("/usr/sbin/xm list")
     else:
-        rfd = os.popen("/usr/sbin/xl list")
+        rfd = os.popen("/usr/bin/virsh list --all --name")
+        use_virsh = True
     data = rfd.read()
     status = rfd.close()
     lines = data.splitlines()[1:]
     # Remove 'Domain-0'
-    lines.pop(0)
+    if not use_virsh:
+        lines.pop(0)
     for line in lines:
-        if line[0] in (' ', '\t'):
+        if line is '' or line[0] in (' ', '\t'):
             continue
         words = line.split()
         managed_vms.append(words[0])
@@ -342,17 +345,17 @@
         return value
     return None
 
-def read_config_file(vm_name, generate_config_from_xm, backup):
+def read_config_file(vm_name, generate_managed_config, backup):
     # Caller must delete temporary files when done
-    log.debug('Reading configuration file, %s, sxp = %s' % 
(vm_name,generate_config_from_xm))
+    log.debug('Reading configuration file, %s, data = %s' % 
(vm_name,generate_managed_config))
     bname = None
-    if generate_config_from_xm:
+    if generate_managed_config:
         (fd, fname) = tempfile.mkstemp(prefix=vm_name + '.')
         if is_xend_running():
             os.system("/usr/sbin/xm list -l %s > %s" % (vm_name, fname))
         else:
             # FIXME: This does not output sxp format so calling code will fail 
parsing it
-            os.system("/usr/sbin/xl list -l %s > %s" % (vm_name, fname))
+            os.system("/usr/bin/virsh dumpxml %s > %s" % (vm_name, fname))
         if not os.path.exists(fname):
             return (None, None, None)
         if not os.stat(fname).st_size:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vminstall/xen_guest.py 
new/vm-install-0.8.0/src/vminstall/xen_guest.py
--- old/vm-install-0.7.8/src/vminstall/xen_guest.py     2013-10-16 
18:43:54.000000000 +0200
+++ new/vm-install-0.8.0/src/vminstall/xen_guest.py     2014-01-03 
22:55:47.000000000 +0100
@@ -187,7 +187,8 @@
                         ret += 'model=%s' % ( nic.model, )
                         needComma = 1
                     if not self.isInstall:
-                        if self.options.os_type == 'sles11' or 
self.options.os_type == 'sled11':
+                        if self.options.os_type == 'sles12' or 
self.options.os_type == 'sled12' or \
+                           self.options.os_type == 'sles11' or 
self.options.os_type == 'sled11':
                             ret += commas[needComma]
                             ret += 'type=netfront'
                             needComma = 1
@@ -423,7 +424,7 @@
         # but it may have a different (conflicting) UUID, so delete it.
         hypervisor.connection.delete(self.options.name)
         try:
-            if self.options.use_libvirt:
+            if self.options.use_libvirt and not self.options.use_xl:
                 domXML = indent(self.GetConfigXml())
                 try:
                     virDom = hypervisor.connection.getconn().defineXML(domXML)
@@ -457,7 +458,7 @@
             self.Stop()
             hypervisor.connection.delete(self.options.name)
             raise VmError(VmError.E_NO_START, details=e.args[0])
-        if not hypervisor.connection.wait_domain(self.options.name):
+        if not hypervisor.connection.wait_domain(self.options.name) and not 
self.options.use_xl:
             log.info("Domain failed to start")
             self.Stop()
             hypervisor.connection.delete(self.options.name)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vminstall/xen_hypervisor.py 
new/vm-install-0.8.0/src/vminstall/xen_hypervisor.py
--- old/vm-install-0.7.8/src/vminstall/xen_hypervisor.py        2013-10-16 
18:43:54.000000000 +0200
+++ new/vm-install-0.8.0/src/vminstall/xen_hypervisor.py        2014-01-03 
22:55:33.000000000 +0100
@@ -108,6 +108,19 @@
 
 
     
#---------------------------------------------------------------------------
+    # Method: domain_running
+    
#---------------------------------------------------------------------------
+    def domain_running(self, domid):
+        domain = self.domain(domid)
+        if not domain:
+            return False
+        for d in domain:
+            if type(d) == list and len(d) > 1 and d[0] == 'state':
+                # Any state means there is an instance...
+                return len(d[1]) > 1
+        return False
+
+    
#---------------------------------------------------------------------------
     # Method: info
     
#---------------------------------------------------------------------------
     def info(self):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/vm-install-0.7.8/src/vminstall/xml.py 
new/vm-install-0.8.0/src/vminstall/xml.py
--- old/vm-install-0.7.8/src/vminstall/xml.py   2013-10-16 18:43:54.000000000 
+0200
+++ new/vm-install-0.8.0/src/vminstall/xml.py   2014-01-06 21:45:32.000000000 
+0100
@@ -106,7 +106,7 @@
         set(options, 'on_poweroff', tryStr(dom, 'on_poweroff'))
         set(options, 'on_reboot', tryStr(dom, 'on_reboot'))
         set(options, 'keymap', tryStr(dom, 'keymap'))
-#        clock = tryElem(dom, 'clock')
+        #set(options, 'loader', tryStr(dom, 'bootloader'))
         os = tryElem(dom, 'os')
         if os:
             os_source = None
@@ -144,12 +144,12 @@
                         set(options, 'kernel', tryStr(os, 'kernel'))
                         set(options, 'initrd', tryStr(os, 'initrd'))
                     set(options, 'extra_args', tryStr(os, 'cmdline'))
-    #    if options.full_virt:
-    #        features = tryElem(dom, 'features')
-    #        if features:
-    #            options.apic = tryExists(features, 'apic')
-    #            options.acpi = tryExists(features, 'acpi')
-    #            options.pae = tryExists(features, 'pae')
+        if options.full_virt:
+            features = tryElem(dom, 'features')
+            if features:
+                options.apic = tryExists(features, 'apic')
+                options.acpi = tryExists(features, 'acpi')
+                options.pae = tryExists(features, 'pae')
         devices = tryElem(dom, 'devices')
         if devices:
             options.disks = get_disks(devices)

-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to