Hello community,

here is the log from the commit of package xen for openSUSE:Factory checked in 
at 2018-01-16 09:26:26
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/xen (Old)
 and      /work/SRC/openSUSE:Factory/.xen.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "xen"

Tue Jan 16 09:26:26 2018 rev:240 rq:563452 version:4.10.0_10

Changes:
--------
--- /work/SRC/openSUSE:Factory/xen/xen.changes  2017-12-21 11:28:13.434825013 
+0100
+++ /work/SRC/openSUSE:Factory/.xen.new/xen.changes     2018-01-16 
09:26:32.530130432 +0100
@@ -1,0 +2,33 @@
+Wed Jan 10 11:12:07 UTC 2018 - [email protected]
+
+- bsc#1067317 - pass cache=writeback|unsafe|directsync to qemu,
+  depending on the libxl disk settings
+  libxl.add-option-to-disable-disk-cache-flushes-in-qdisk.patch
+
+-------------------------------------------------------------------
+Mon Jan  8 08:15:11 UTC 2018 - [email protected]
+
+- Remove libxl.LIBXL_DESTROY_TIMEOUT.debug.patch
+
+-------------------------------------------------------------------
+Fri Jan  5 13:45:40 MST 2018 - [email protected]
+
+- bsc#1067224 - xen-tools have hard dependency on Python 2
+  build-python3-conversion.patch
+  bin-python3-conversion.patch
+
+-------------------------------------------------------------------
+Wed Dec 20 09:57:09 MST 2017 - [email protected]
+
+- bsc#1070165 - xen crashes after aborted localhost migration
+  5a2ffc1f-x86-mm-drop-bogus-paging-mode-assertion.patch
+- bsc#1035442 - L3: libxl: error: libxl.c:1676:devices_destroy_cb:
+  libxl__devices_destroy failed
+  5a33a12f-domctl-improve-locking-during-domain-destruction.patch
+- Upstream patches from Jan (bsc#1027519)
+  5a21a77e-x86-pv-construct-d0v0s-GDT-properly.patch
+  5a2fda0d-x86-mb2-avoid-Xen-when-looking-for-module-crashkernel-pos.patch
+  5a313972-x86-microcode-add-support-for-AMD-Fam17.patch
+  5a32bd79-x86-vmx-dont-use-hvm_inject_hw_exception-in-.patch
+
+-------------------------------------------------------------------

Old:
----
  libxl.LIBXL_DESTROY_TIMEOUT.debug.patch

New:
----
  5a21a77e-x86-pv-construct-d0v0s-GDT-properly.patch
  5a2fda0d-x86-mb2-avoid-Xen-when-looking-for-module-crashkernel-pos.patch
  5a2ffc1f-x86-mm-drop-bogus-paging-mode-assertion.patch
  5a313972-x86-microcode-add-support-for-AMD-Fam17.patch
  5a32bd79-x86-vmx-dont-use-hvm_inject_hw_exception-in-.patch
  5a33a12f-domctl-improve-locking-during-domain-destruction.patch
  bin-python3-conversion.patch
  build-python3-conversion.patch

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

Other differences:
------------------
++++++ xen.spec ++++++
--- /var/tmp/diff_new_pack.pxkMaJ/_old  2018-01-16 09:26:34.998014970 +0100
+++ /var/tmp/diff_new_pack.pxkMaJ/_new  2018-01-16 09:26:35.006014596 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package xen
 #
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -111,7 +111,7 @@
 %endif
 BuildRequires:  acpica
 BuildRequires:  openssl-devel
-BuildRequires:  python-devel
+BuildRequires:  python3-devel
 BuildRequires:  systemd
 BuildRequires:  xz-devel
 %ifarch x86_64
@@ -131,7 +131,7 @@
 BuildRequires:  pesign-obs-integration
 %endif
 
-Version:        4.10.0_08
+Version:        4.10.0_10
 Release:        0
 Summary:        Xen Virtualization: Hypervisor (aka VMM aka Microkernel)
 License:        GPL-2.0
@@ -166,6 +166,12 @@
 # For xen-libs
 Source99:       baselibs.conf
 # Upstream patches
+Patch1:         5a21a77e-x86-pv-construct-d0v0s-GDT-properly.patch
+Patch2:         
5a2fda0d-x86-mb2-avoid-Xen-when-looking-for-module-crashkernel-pos.patch
+Patch3:         5a2ffc1f-x86-mm-drop-bogus-paging-mode-assertion.patch
+Patch4:         5a313972-x86-microcode-add-support-for-AMD-Fam17.patch
+Patch5:         5a32bd79-x86-vmx-dont-use-hvm_inject_hw_exception-in-.patch
+Patch6:         5a33a12f-domctl-improve-locking-during-domain-destruction.patch
 # Our platform specific patches
 Patch400:       xen-destdir.patch
 Patch401:       vif-bridge-no-iptables.patch
@@ -198,11 +204,12 @@
 Patch466:       libxl.set-migration-constraints-from-cmdline.patch
 Patch467:       xenstore-run-in-studomain.patch
 Patch468:       libxl.LIBXL_DESTROY_TIMEOUT.patch
-Patch469:       libxl.LIBXL_DESTROY_TIMEOUT.debug.patch
 # python3 conversion patches
-Patch500:       pygrub-python3-conversion.patch
-Patch501:       xenmon-python3-conversion.patch
-Patch502:       migration-python3-conversion.patch
+Patch500:       build-python3-conversion.patch
+Patch501:       pygrub-python3-conversion.patch
+Patch502:       xenmon-python3-conversion.patch
+Patch503:       migration-python3-conversion.patch
+Patch504:       bin-python3-conversion.patch
 # Hypervisor and PV driver Patches
 Patch601:       x86-ioapic-ack-default.patch
 Patch602:       x86-cpufreq-report.patch
@@ -215,7 +222,7 @@
 Patch99998:     tmp_build.patch
 Url:            http://www.cl.cam.ac.uk/Research/SRG/netos/xen/
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-%define pyver %(python -c "import sys; print sys.version[:3]")
+%define pyver %(python3 -c "import sys; print(sys.version[:3])")
 
 %description
 Xen is a virtual machine monitor for x86 that supports execution of
@@ -264,8 +271,8 @@
 Requires:       qemu-arm
 %endif
 Requires:       multipath-tools
-Requires:       python
-Requires:       python-curses
+Requires:       python3
+Requires:       python3-curses
 Requires:       qemu-seabios
 Requires:       xen-libs = %{version}
 # subpackage existed in 10.3
@@ -355,6 +362,12 @@
 %prep
 %setup -q -n %xen_build_dir -a 1 -a 5 -a 6 -a 57
 # Upstream patches
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
 # Our platform specific patches
 %patch400 -p1
 %patch401 -p1
@@ -387,11 +400,12 @@
 %patch466 -p1
 %patch467 -p1
 %patch468 -p1
-%patch469 -p1
 # python3 conversion patches
 %patch500 -p1
 %patch501 -p1
 %patch502 -p1
+%patch503 -p1
+%patch504 -p1
 # Hypervisor and PV driver Patches
 %patch601 -p1
 %patch602 -p1
@@ -469,6 +483,7 @@
 sed -i~ 's/ XENSTORETYPE=domain$/ XENSTORETYPE=daemon/' 
tools/hotplug/Linux/launch-xenstore.in
 configure_flags=--disable-stubdom
 %endif
+export PYTHON="/usr/bin/python3"
 configure_flags="${configure_flags} --disable-qemu-traditional"
 ./configure \
         --disable-xen \
@@ -750,6 +765,7 @@
        -name "openbios-*" -o \
        -name "petalogix*" -o \
        -name "ppc*" -o \
+       -name "*.pyc" -o \
        -name "s390*" -o \
        -name "slof*" -o \
        -name "spapr*" -o \
@@ -926,7 +942,7 @@
 %{_libdir}/python%{pyver}/site-packages/xen/__init__*
 %{_libdir}/python%{pyver}/site-packages/xen/lowlevel/*
 %{_libdir}/python%{pyver}/site-packages/xen/migration/*
-%{_libdir}/python%{pyver}/site-packages/fsimage.so
+%{_libdir}/python%{pyver}/site-packages/*.so
 %{_libdir}/python%{pyver}/site-packages/xnloader.py
 %dir %{_defaultdocdir}/xen
 %{_defaultdocdir}/xen/COPYING

++++++ 5a21a77e-x86-pv-construct-d0v0s-GDT-properly.patch ++++++
# Commit 08f27f4468eedbeccaac9fdda4ef732247efd74e
# Date 2017-12-01 19:03:26 +0000
# Author Andrew Cooper <[email protected]>
# Committer Andrew Cooper <[email protected]>
xen/pv: Construct d0v0's GDT properly

c/s cf6d39f8199 "x86/PV: properly populate descriptor tables" changed the GDT
to reference zero_page for intermediate frames between the guest and Xen
frames.

Because dom0_construct_pv() doesn't call arch_set_info_guest(), some bits of
initialisation are missed, including the pv_destroy_gdt() which initially
fills the references to zero_page.

In practice, this means there is a window between starting and the first call
to HYPERCALL_set_gdt() were lar/lsl/verr/verw suffer non-architectural
behaviour.

Signed-off-by: Andrew Cooper <[email protected]>
Reviewed-by: Jan Beulich <[email protected]>

--- a/xen/arch/x86/pv/dom0_build.c
+++ b/xen/arch/x86/pv/dom0_build.c
@@ -18,6 +18,7 @@
 #include <asm/bzimage.h>
 #include <asm/dom0_build.h>
 #include <asm/page.h>
+#include <asm/pv/mm.h>
 #include <asm/setup.h>
 
 /* Allow ring-3 access in long mode as guest cannot use ring 1 ... */
@@ -866,6 +867,13 @@ int __init dom0_construct_pv(struct doma
     regs->rsi = vstartinfo_start;
     regs->eflags = X86_EFLAGS_IF;
 
+    /*
+     * We don't call arch_set_info_guest(), so some initialisation needs doing
+     * by hand:
+     *  - Reset the GDT to reference zero_page
+     */
+    pv_destroy_gdt(v);
+
     if ( test_bit(XENFEAT_supervisor_mode_kernel, parms.f_required) )
         panic("Dom0 requires supervisor-mode execution");
 
++++++ 5a2fda0d-x86-mb2-avoid-Xen-when-looking-for-module-crashkernel-pos.patch 
++++++
# Commit 9589927e5bf9e123ec42b6e0b0809f153bd92732
# Date 2017-12-12 14:30:53 +0100
# Author Daniel Kiper <[email protected]>
# Committer Jan Beulich <[email protected]>
x86/mb2: avoid Xen image when looking for module/crashkernel position

Commit e22e1c4 (x86/EFI: avoid Xen image when looking for module/kexec
position) added relevant check for EFI case. However, since commit
f75a304 (x86: add multiboot2 protocol support for relocatable images)
Multiboot2 compatible bootloaders are able to relocate Xen image too.
So, we have to avoid also Xen image region in such cases.

Reported-by: Andrew Cooper <[email protected]>
Reported-by: Konrad Rzeszutek Wilk <[email protected]>
Signed-off-by: Daniel Kiper <[email protected]>
Reviewed-by: Jan Beulich <[email protected]>

--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -653,7 +653,7 @@ void __init noreturn __start_xen(unsigne
     module_t *mod = (module_t *)__va(mbi->mods_addr);
     unsigned long nr_pages, raw_max_page, modules_headroom, *module_map;
     int i, j, e820_warn = 0, bytes = 0;
-    bool acpi_boot_table_init_done = false;
+    bool acpi_boot_table_init_done = false, relocated = false;
     struct domain *dom0;
     struct ns16550_defaults ns16550 = {
         .data_bits = 8,
@@ -904,8 +904,10 @@ void __init noreturn __start_xen(unsigne
         mod[i].reserved = 0;
     }
 
-    if ( efi_enabled(EFI_LOADER) )
+    if ( xen_phys_start )
     {
+        relocated = true;
+
         /*
          * This needs to remain in sync with xen_in_range() and the
          * respective reserve_e820_ram() invocation below.
@@ -1098,8 +1100,7 @@ void __init noreturn __start_xen(unsigne
 
             /* Don't overlap with other modules (or Xen itself). */
             end = consider_modules(s, e, size, mod,
-                                   mbi->mods_count + efi_enabled(EFI_LOADER),
-                                   j);
+                                   mbi->mods_count + relocated, j);
 
             if ( highmem_start && end > highmem_start )
                 continue;
@@ -1126,7 +1127,7 @@ void __init noreturn __start_xen(unsigne
         {
             /* Don't overlap with modules (or Xen itself). */
             e = consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size), mod,
-                                 mbi->mods_count + efi_enabled(EFI_LOADER), 
-1);
+                                 mbi->mods_count + relocated, -1);
             if ( s >= e )
                 break;
             if ( e > kexec_crash_area_limit )
++++++ 5a2ffc1f-x86-mm-drop-bogus-paging-mode-assertion.patch ++++++
References: bsc#1070165

# Commit b95f7be32d668fa4b09300892ebe19636ecebe36
# Date 2017-12-12 16:56:15 +0100
# Author Jan Beulich <[email protected]>
# Committer Jan Beulich <[email protected]>
x86/mm: drop bogus paging mode assertion

Olaf has observed this assertion to trigger after an aborted migration
of a PV guest:

(XEN) Xen call trace:
(XEN)    [<ffff82d0802a85dc>] do_page_fault+0x39f/0x55c
(XEN)    [<ffff82d08036b7d8>] x86_64/entry.S#handle_exception_saved+0x66/0xa4
(XEN)    [<ffff82d0802a9274>] __copy_to_user_ll+0x22/0x30
(XEN)    [<ffff82d0802772d4>] update_runstate_area+0x19c/0x228
(XEN)    [<ffff82d080277371>] domain.c#_update_runstate_area+0x11/0x39
(XEN)    [<ffff82d080277596>] context_switch+0x1fd/0xf25
(XEN)    [<ffff82d0802395c5>] schedule.c#schedule+0x303/0x6a8
(XEN)    [<ffff82d08023d067>] softirq.c#__do_softirq+0x6c/0x95
(XEN)    [<ffff82d08023d0da>] do_softirq+0x13/0x15
(XEN)    [<ffff82d08036b2f1>] x86_64/entry.S#process_softirqs+0x21/0x30

Release builds work fine, which is a first indication that the assertion
isn't really needed.

What's worse though - there appears to be a timing window where the
guest runs in shadow mode, but not in log-dirty mode, and that is what
triggers the assertion (the same could, afaict, be achieved by test-
enabling shadow mode on a PV guest). This is because turing off log-
dirty mode is being performed in two steps: First the log-dirty bit gets
cleared (paging_log_dirty_disable() [having paused the domain] ->
sh_disable_log_dirty() -> shadow_one_bit_disable()), followed by
unpausing the domain and only then clearing shadow mode (via
shadow_test_disable(), which pauses the domain a second time).

Hence besides removing the ASSERT() here (or optionally replacing it by
explicit translate and refcounts mode checks, but this seems rather
pointless now that the three are tied together) I wonder whether either
shadow_one_bit_disable() should turn off shadow mode if no other bit
besides PG_SH_enable remains set (just like shadow_one_bit_enable()
enables it if not already set), or the domain pausing scope should be
extended so that both steps occur without the domain getting a chance to
run in between.

Reported-by: Olaf Hering <[email protected]>
Signed-off-by: Jan Beulich <[email protected]>
Reviewed-by: Tim Deegan <[email protected]>
Acked-by: Andrew Cooper <[email protected]>

--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -1338,12 +1338,8 @@ static int fixup_page_fault(unsigned lon
      */
     if ( paging_mode_enabled(d) && !paging_mode_external(d) )
     {
-        int ret;
+        int ret = paging_fault(addr, regs);
 
-        /* Logdirty mode is the only expected paging mode for PV guests. */
-        ASSERT(paging_mode_only_log_dirty(d));
-
-        ret = paging_fault(addr, regs);
         if ( ret == EXCRET_fault_fixed )
             trace_trap_two_addr(TRC_PV_PAGING_FIXUP, regs->rip, addr);
         return ret;
--- a/xen/include/asm-x86/paging.h
+++ b/xen/include/asm-x86/paging.h
@@ -69,9 +69,6 @@
 #define paging_mode_translate(_d) (!!((_d)->arch.paging.mode & PG_translate))
 #define paging_mode_external(_d)  (!!((_d)->arch.paging.mode & PG_external))
 
-#define paging_mode_only_log_dirty(_d)                  \
-    (((_d)->arch.paging.mode & PG_MASK) == PG_log_dirty)
-
 /* flags used for paging debug */
 #define PAGING_DEBUG_LOGDIRTY 0
 
++++++ 5a313972-x86-microcode-add-support-for-AMD-Fam17.patch ++++++
# Commit 61d458ba8c171809e8dd9abd19339c87f3f934ca
# Date 2017-12-13 14:30:10 +0000
# Author Tom Lendacky <[email protected]>
# Committer Andrew Cooper <[email protected]>
x86/microcode: Add support for fam17h microcode loading

The size for the Microcode Patch Block (MPB) for an AMD family 17h
processor is 3200 bytes.  Add a #define for fam17h so that it does
not default to 2048 bytes and fail a microcode load/update.

Signed-off-by: Tom Lendacky <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Borislav Petkov <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
[Linux commit f4e9b7af0cd58dd039a0fb2cd67d57cea4889abf]

Ported to Xen.

Signed-off-by: Andrew Cooper <[email protected]>
Acked-by: Jan Beulich <[email protected]>

--- a/xen/arch/x86/microcode_amd.c
+++ b/xen/arch/x86/microcode_amd.c
@@ -107,6 +107,7 @@ static bool_t verify_patch_size(uint32_t
 #define F14H_MPB_MAX_SIZE 1824
 #define F15H_MPB_MAX_SIZE 4096
 #define F16H_MPB_MAX_SIZE 3458
+#define F17H_MPB_MAX_SIZE 3200
 
     switch (boot_cpu_data.x86)
     {
@@ -119,6 +120,9 @@ static bool_t verify_patch_size(uint32_t
     case 0x16:
         max_size = F16H_MPB_MAX_SIZE;
         break;
+    case 0x17:
+        max_size = F17H_MPB_MAX_SIZE;
+        break;
     default:
         max_size = F1XH_MPB_MAX_SIZE;
         break;
++++++ 5a32bd79-x86-vmx-dont-use-hvm_inject_hw_exception-in-.patch ++++++
# Commit 896ee3980e72866b602e743396751384de301fb0
# Date 2017-12-14 18:05:45 +0000
# Author Andrew Cooper <[email protected]>
# Committer Andrew Cooper <[email protected]>
x86/vmx: Don't use hvm_inject_hw_exception() in long_mode_do_msr_write()

Since c/s 49de10f3c1718 "x86/hvm: Don't raise #GP behind the emulators back
for MSR accesses", returning X86EMUL_EXCEPTION has pushed the exception
generation to the top of the call tree.

Using hvm_inject_hw_exception() and returning X86EMUL_EXCEPTION causes a
double #GP injection, which combines to #DF.

Signed-off-by: Andrew Cooper <[email protected]>
Acked-by: Kevin Tian <[email protected]>
Reviewed-by: Jan Beulich <[email protected]>

--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -542,7 +542,7 @@ long_mode_do_msr_write(unsigned int msr,
     case MSR_GS_BASE:
     case MSR_SHADOW_GS_BASE:
         if ( !is_canonical_address(msr_content) )
-            goto uncanonical_address;
+            return HNDL_exception_raised;
 
         if ( msr == MSR_FS_BASE )
             __vmwrite(GUEST_FS_BASE, msr_content);
@@ -560,14 +560,14 @@ long_mode_do_msr_write(unsigned int msr,
 
     case MSR_LSTAR:
         if ( !is_canonical_address(msr_content) )
-            goto uncanonical_address;
+            return HNDL_exception_raised;
         v->arch.hvm_vmx.lstar = msr_content;
         wrmsrl(MSR_LSTAR, msr_content);
         break;
 
     case MSR_CSTAR:
         if ( !is_canonical_address(msr_content) )
-            goto uncanonical_address;
+            return HNDL_exception_raised;
         v->arch.hvm_vmx.cstar = msr_content;
         break;
 
@@ -581,11 +581,6 @@ long_mode_do_msr_write(unsigned int msr,
     }
 
     return HNDL_done;
-
- uncanonical_address:
-    HVM_DBG_LOG(DBG_LEVEL_MSR, "Not cano address of msr write %x", msr);
-    hvm_inject_hw_exception(TRAP_gp_fault, 0);
-    return HNDL_exception_raised;
 }
 
 /*
++++++ 5a33a12f-domctl-improve-locking-during-domain-destruction.patch ++++++
References: bsc#1035442

# Commit 228ab9992ffb1d8f9d2475f2581e68b2913acb88
# Date 2017-12-15 11:17:19 +0100
# Author Jan Beulich <[email protected]>
# Committer Jan Beulich <[email protected]>
domctl: improve locking during domain destruction

There is no need to hold the global domctl lock across domain_kill() -
the domain lock is fully sufficient here, and parallel cleanup after
multiple domains performs quite a bit better this way.

Signed-off-by: Jan Beulich <[email protected]>
Reviewed-by: Andrew Cooper <[email protected]>

--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -615,13 +615,21 @@ int domain_kill(struct domain *d)
     if ( d == current->domain )
         return -EINVAL;
 
-    /* Protected by domctl_lock. */
+    /* Protected by d->domain_lock. */
     switch ( d->is_dying )
     {
     case DOMDYING_alive:
+        domain_unlock(d);
         domain_pause(d);
+        domain_lock(d);
+        /*
+         * With the domain lock dropped, d->is_dying may have changed. Call
+         * ourselves recursively if so, which is safe as then we won't come
+         * back here.
+         */
+        if ( d->is_dying != DOMDYING_alive )
+            return domain_kill(d);
         d->is_dying = DOMDYING_dying;
-        spin_barrier(&d->domain_lock);
         evtchn_destroy(d);
         gnttab_release_mappings(d);
         tmem_destroy(d->tmem_client);
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -665,11 +665,14 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe
         break;
 
     case XEN_DOMCTL_destroydomain:
+        domctl_lock_release();
+        domain_lock(d);
         ret = domain_kill(d);
+        domain_unlock(d);
         if ( ret == -ERESTART )
             ret = hypercall_create_continuation(
                 __HYPERVISOR_domctl, "h", u_domctl);
-        break;
+        goto domctl_out_unlock_domonly;
 
     case XEN_DOMCTL_setnodeaffinity:
     {
++++++ bin-python3-conversion.patch ++++++
++++ 617 lines (skipped)

++++++ build-python3-conversion.patch ++++++
++++ 965 lines (skipped)

++++++ libxl.add-option-to-disable-disk-cache-flushes-in-qdisk.patch ++++++
--- /var/tmp/diff_new_pack.pxkMaJ/_old  2018-01-16 09:26:35.286001496 +0100
+++ /var/tmp/diff_new_pack.pxkMaJ/_new  2018-01-16 09:26:35.286001496 +0100
@@ -7,42 +7,215 @@
  tools/libxl/libxlu_disk_l.l |    1 +
  5 files changed, 18 insertions(+), 1 deletion(-)
 
-Index: xen-4.10.0-testing/tools/libxl/libxl_disk.c
+Index: xen-4.10.0-testing/docs/man/xl-disk-configuration.pod.5
 ===================================================================
---- xen-4.10.0-testing.orig/tools/libxl/libxl_disk.c
-+++ xen-4.10.0-testing/tools/libxl/libxl_disk.c
-@@ -406,6 +406,8 @@ static void device_disk_add(libxl__egc *
-         flexarray_append_pair(back, "discard-enable",
-                               libxl_defbool_val(disk->discard_enable) ?
-                               "1" : "0");
-+        if ((disk->readwrite & 
~LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MASK) == 
LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MAGIC)
-+            flexarray_append_pair(back, "suse-diskcache-disable-flush", "1");
+--- xen-4.10.0-testing.orig/docs/man/xl-disk-configuration.pod.5
++++ xen-4.10.0-testing/docs/man/xl-disk-configuration.pod.5
+@@ -344,6 +344,32 @@ can be used to disable "hole punching" f
+ were intentionally created non-sparse to avoid fragmentation of the
+ file.
+ 
++=item B<suse-diskcache-disable-flush>
++
++=over 4
++
++=item Description
++
++Request that the qemu block driver does not automatically flush written data 
to the backend storage.
++
++=item Supported values
++
++absent, present
++
++=item Mandatory
++
++No
++
++=item Default value
++
++absent
++
++=back
++
++This enables the '-disk cache=unsafe' mode inside qemu.
++In this mode writes to the underlying blockdevice are delayed.
++While using this option in production is dangerous, it improves performance 
during installation of a domU.
++
+ =back
+ 
  
-         flexarray_append(front, "backend-id");
-         flexarray_append(front, GCSPRINTF("%d", disk->backend_domid));
 Index: xen-4.10.0-testing/tools/libxl/libxl.h
 ===================================================================
 --- xen-4.10.0-testing.orig/tools/libxl/libxl.h
 +++ xen-4.10.0-testing/tools/libxl/libxl.h
-@@ -348,6 +348,18 @@
+@@ -348,6 +348,21 @@
  #define LIBXL_HAVE_BUILDINFO_BOOTLOADER_ARGS 1
  
  /*
 + * The libxl_device_disk has no way to indicate that cache=unsafe is
 + * supposed to be used. Provide this knob without breaking the ABI.
 + * This is done by overloading struct libxl_device_disk->readwrite:
-+ * readwrite == 0: disk is readonly, no discard
-+ * readwrite == 1: disk is readwrite, backend driver may enable discard
++ * readwrite == 0: disk is readonly, cache= does not matter
++ * readwrite == 1: disk is readwrite, backend driver may tweak cache=
 + * readwrite == MAGIC: disk is readwrite, backend driver should ignore
 + * flush requests from the frontend driver.
++ * Note: the macro with MAGIC is used by libvirt to decide if this patch is 
applied
 + */
 +#define LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MAGIC 0x00006000U
 +#define LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MASK  0xffff0fffU
++#define LIBXL_SUSE_IS_CACHE_UNSAFE(rw) (((rw) & 
~LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MASK) == 
LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MAGIC)
++#define LIBXL_SUSE_SET_CACHE_UNSAFE(rw) (((rw) & 
LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MASK) | 
LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MAGIC)
 +
 +/*
   * libxl ABI compatibility
   *
   * The only guarantee which libxl makes regarding ABI compatibility
+Index: xen-4.10.0-testing/tools/libxl/libxl_disk.c
+===================================================================
+--- xen-4.10.0-testing.orig/tools/libxl/libxl_disk.c
++++ xen-4.10.0-testing/tools/libxl/libxl_disk.c
+@@ -406,6 +406,8 @@ static void device_disk_add(libxl__egc *
+         flexarray_append_pair(back, "discard-enable",
+                               libxl_defbool_val(disk->discard_enable) ?
+                               "1" : "0");
++        if (LIBXL_SUSE_IS_CACHE_UNSAFE(disk->readwrite))
++            flexarray_append_pair(back, "suse-diskcache-disable-flush", "1");
+ 
+         flexarray_append(front, "backend-id");
+         flexarray_append(front, GCSPRINTF("%d", disk->backend_domid));
+Index: xen-4.10.0-testing/tools/libxl/libxl_dm.c
+===================================================================
+--- xen-4.10.0-testing.orig/tools/libxl/libxl_dm.c
++++ xen-4.10.0-testing/tools/libxl/libxl_dm.c
+@@ -805,6 +805,19 @@ enum {
+     LIBXL__COLO_SECONDARY,
+ };
+ 
++static const char *qemu_cache_mode(const libxl_device_disk *disk)
++{
++    static const char cache_directsync[] = "directsync";
++    static const char cache_writeback[] = "writeback";
++    static const char cache_unsafe[] = "unsafe";
++
++    if (LIBXL_SUSE_IS_CACHE_UNSAFE(disk->readwrite))
++        return cache_unsafe;
++    if (disk->direct_io_safe)
++        return cache_directsync;
++    return cache_writeback;
++}
++
+ static char *qemu_disk_scsi_drive_string(libxl__gc *gc, const char 
*target_path,
+                                          int unit, const char *format,
+                                          const libxl_device_disk *disk,
+@@ -818,8 +831,8 @@ static char *qemu_disk_scsi_drive_string
+     switch (colo_mode) {
+     case LIBXL__COLO_NONE:
+         drive = libxl__sprintf
+-            (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s,cache=writeback",
+-             target_path, unit, format);
++            (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s,cache=%s",
++             target_path, unit, format, qemu_cache_mode(disk));
+         break;
+     case LIBXL__COLO_PRIMARY:
+         /*
+@@ -832,13 +845,15 @@ static char *qemu_disk_scsi_drive_string
+          *  vote-threshold=1
+          */
+         drive = GCSPRINTF(
+-            "if=scsi,bus=0,unit=%d,cache=writeback,driver=quorum,"
++            "if=scsi,bus=0,unit=%d,cache=%s,driver=quorum,"
+             "id=%s,"
+             "children.0.file.filename=%s,"
+             "children.0.driver=%s,"
+             "read-pattern=fifo,"
+             "vote-threshold=1",
+-            unit, exportname, target_path, format);
++            unit,
++            qemu_cache_mode(disk),
++            exportname, target_path, format);
+         break;
+     case LIBXL__COLO_SECONDARY:
+         /*
+@@ -852,7 +867,7 @@ static char *qemu_disk_scsi_drive_string
+          *  file.backing.backing=exportname,
+          */
+         drive = GCSPRINTF(
+-            "if=scsi,id=top-colo,bus=0,unit=%d,cache=writeback,"
++            "if=scsi,id=top-colo,bus=0,unit=%d,cache=%s,"
+             "driver=replication,"
+             "mode=secondary,"
+             "top-id=top-colo,"
+@@ -861,7 +876,9 @@ static char *qemu_disk_scsi_drive_string
+             "file.backing.driver=qcow2,"
+             "file.backing.file.filename=%s,"
+             "file.backing.backing=%s",
+-            unit, active_disk, hidden_disk, exportname);
++            unit,
++            qemu_cache_mode(disk),
++            active_disk, hidden_disk, exportname);
+         break;
+     default:
+         abort();
+@@ -883,8 +900,8 @@ static char *qemu_disk_ide_drive_string(
+     switch (colo_mode) {
+     case LIBXL__COLO_NONE:
+         drive = GCSPRINTF
+-            ("file=%s,if=ide,index=%d,media=disk,format=%s,cache=writeback",
+-             target_path, unit, format);
++            ("file=%s,if=ide,index=%d,media=disk,format=%s,cache=%s",
++             target_path, unit, format, qemu_cache_mode(disk));
+         break;
+     case LIBXL__COLO_PRIMARY:
+         /*
+@@ -897,13 +914,15 @@ static char *qemu_disk_ide_drive_string(
+          *  vote-threshold=1
+          */
+         drive = GCSPRINTF(
+-            "if=ide,index=%d,media=disk,cache=writeback,driver=quorum,"
++            "if=ide,index=%d,media=disk,cache=%s,driver=quorum,"
+             "id=%s,"
+             "children.0.file.filename=%s,"
+             "children.0.driver=%s,"
+             "read-pattern=fifo,"
+             "vote-threshold=1",
+-             unit, exportname, target_path, format);
++             unit,
++             qemu_cache_mode(disk),
++             exportname, target_path, format);
+         break;
+     case LIBXL__COLO_SECONDARY:
+         /*
+@@ -917,7 +936,7 @@ static char *qemu_disk_ide_drive_string(
+          *  file.backing.backing=exportname,
+          */
+         drive = GCSPRINTF(
+-            "if=ide,index=%d,id=top-colo,media=disk,cache=writeback,"
++            "if=ide,index=%d,id=top-colo,media=disk,cache=%s,"
+             "driver=replication,"
+             "mode=secondary,"
+             "top-id=top-colo,"
+@@ -926,7 +945,9 @@ static char *qemu_disk_ide_drive_string(
+             "file.backing.driver=qcow2,"
+             "file.backing.file.filename=%s,"
+             "file.backing.backing=%s",
+-            unit, active_disk, hidden_disk, exportname);
++            unit,
++            qemu_cache_mode(disk),
++            active_disk, hidden_disk, exportname);
+         break;
+     default:
+          abort();
+@@ -1605,8 +1626,8 @@ static int libxl__build_device_model_arg
+                         return ERROR_INVAL;
+                     }
+                     flexarray_vappend(dm_args, "-drive",
+-                        
GCSPRINTF("file=%s,if=none,id=ahcidisk-%d,format=%s,cache=writeback",
+-                        target_path, disk, format),
++                        
GCSPRINTF("file=%s,if=none,id=ahcidisk-%d,format=%s,cache=%s",
++                        target_path, disk, format, 
qemu_cache_mode(&disks[i])),
+                         "-device", 
GCSPRINTF("ide-hd,bus=ahci0.%d,unit=0,drive=ahcidisk-%d",
+                         disk, disk), NULL);
+                     continue;
 Index: xen-4.10.0-testing/tools/libxl/libxlu_disk.c
 ===================================================================
 --- xen-4.10.0-testing.orig/tools/libxl/libxlu_disk.c
@@ -52,7 +225,7 @@
              disk->format = LIBXL_DISK_FORMAT_EMPTY;
      }
 +    if (disk->readwrite && dpc.suse_diskcache_disable_flush)
-+        disk->readwrite = (disk->readwrite & 
LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MASK) | 
LIBXL_HAVE_LIBXL_DEVICE_DISK_DISABLE_FLUSH_MAGIC;
++        disk->readwrite = LIBXL_SUSE_SET_CACHE_UNSAFE(disk->readwrite);
  
      if (!disk->vdev) {
          xlu__disk_err(&dpc,0, "no vdev specified");
@@ -81,40 +254,3 @@
  
   /* the target magic parameter, eats the rest of the string */
  
-Index: xen-4.10.0-testing/docs/man/xl-disk-configuration.pod.5
-===================================================================
---- xen-4.10.0-testing.orig/docs/man/xl-disk-configuration.pod.5
-+++ xen-4.10.0-testing/docs/man/xl-disk-configuration.pod.5
-@@ -344,6 +344,32 @@ can be used to disable "hole punching" f
- were intentionally created non-sparse to avoid fragmentation of the
- file.
- 
-+=item B<suse-diskcache-disable-flush>
-+
-+=over 4
-+
-+=item Description
-+
-+Request that the qemu block driver does not automatically flush written data 
to the backend storage.
-+
-+=item Supported values
-+
-+absent, present
-+
-+=item Mandatory
-+
-+No
-+
-+=item Default value
-+
-+absent
-+
-+=back
-+
-+This enables the '-disk cache=unsafe' mode inside qemu.
-+In this mode writes to the underlying blockdevice are delayed.
-+While using this option in production is dangerous, it improves performance 
during installation of a domU.
-+
- =back
- 
- 

++++++ migration-python3-conversion.patch ++++++
--- /var/tmp/diff_new_pack.pxkMaJ/_old  2018-01-16 09:26:35.329999438 +0100
+++ /var/tmp/diff_new_pack.pxkMaJ/_new  2018-01-16 09:26:35.333999251 +0100
@@ -1,7 +1,23 @@
+Index: xen-4.10.0-testing/tools/python/xen/migration/legacy.py
+===================================================================
+--- xen-4.10.0-testing.orig/tools/python/xen/migration/legacy.py
++++ xen-4.10.0-testing/tools/python/xen/migration/legacy.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python3
+ # -*- coding: utf-8 -*-
+ 
+ """
 Index: xen-4.10.0-testing/tools/python/xen/migration/libxc.py
 ===================================================================
 --- xen-4.10.0-testing.orig/tools/python/xen/migration/libxc.py
 +++ xen-4.10.0-testing/tools/python/xen/migration/libxc.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python3
+ # -*- coding: utf-8 -*-
+ 
+ """
 @@ -87,23 +87,23 @@ rec_type_to_str = {
  
  # page_data
@@ -16,10 +32,7 @@
 -PAGE_DATA_TYPE_LTABTYPE_MASK = (long(0x7) << PAGE_DATA_TYPE_SHIFT)
 -PAGE_DATA_TYPE_LTAB_MASK     = (long(0xf) << PAGE_DATA_TYPE_SHIFT)
 -PAGE_DATA_TYPE_LPINTAB       = (long(0x8) << PAGE_DATA_TYPE_SHIFT) # Pinned 
pagetable
-+PAGE_DATA_TYPE_LTABTYPE_MASK = (int(0x7) << PAGE_DATA_TYPE_SHIFT)
-+PAGE_DATA_TYPE_LTAB_MASK     = (int(0xf) << PAGE_DATA_TYPE_SHIFT)
-+PAGE_DATA_TYPE_LPINTAB       = (int(0x8) << PAGE_DATA_TYPE_SHIFT) # Pinned 
pagetable
- 
+-
 -PAGE_DATA_TYPE_NOTAB         = (long(0x0) << PAGE_DATA_TYPE_SHIFT) # Regular 
page
 -PAGE_DATA_TYPE_L1TAB         = (long(0x1) << PAGE_DATA_TYPE_SHIFT) # L1 
pagetable
 -PAGE_DATA_TYPE_L2TAB         = (long(0x2) << PAGE_DATA_TYPE_SHIFT) # L2 
pagetable
@@ -28,6 +41,10 @@
 -PAGE_DATA_TYPE_BROKEN        = (long(0xd) << PAGE_DATA_TYPE_SHIFT) # Broken
 -PAGE_DATA_TYPE_XALLOC        = (long(0xe) << PAGE_DATA_TYPE_SHIFT) # 
Allocate-only
 -PAGE_DATA_TYPE_XTAB          = (long(0xf) << PAGE_DATA_TYPE_SHIFT) # Invalid
++PAGE_DATA_TYPE_LTABTYPE_MASK = (int(0x7) << PAGE_DATA_TYPE_SHIFT)
++PAGE_DATA_TYPE_LTAB_MASK     = (int(0xf) << PAGE_DATA_TYPE_SHIFT)
++PAGE_DATA_TYPE_LPINTAB       = (int(0x8) << PAGE_DATA_TYPE_SHIFT) # Pinned 
pagetable
++
 +PAGE_DATA_TYPE_NOTAB         = (int(0x0) << PAGE_DATA_TYPE_SHIFT) # Regular 
page
 +PAGE_DATA_TYPE_L1TAB         = (int(0x1) << PAGE_DATA_TYPE_SHIFT) # L1 
pagetable
 +PAGE_DATA_TYPE_L2TAB         = (int(0x2) << PAGE_DATA_TYPE_SHIFT) # L2 
pagetable
@@ -39,10 +56,46 @@
  
  # x86_pv_info
  X86_PV_INFO_FORMAT        = "BBHI"
+Index: xen-4.10.0-testing/tools/python/xen/migration/libxl.py
+===================================================================
+--- xen-4.10.0-testing.orig/tools/python/xen/migration/libxl.py
++++ xen-4.10.0-testing/tools/python/xen/migration/libxl.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python3
+ # -*- coding: utf-8 -*-
+ 
+ """
+Index: xen-4.10.0-testing/tools/python/xen/migration/public.py
+===================================================================
+--- xen-4.10.0-testing.orig/tools/python/xen/migration/public.py
++++ xen-4.10.0-testing/tools/python/xen/migration/public.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python3
+ # -*- coding: utf-8 -*-
+ 
+ """
+Index: xen-4.10.0-testing/tools/python/xen/migration/tests.py
+===================================================================
+--- xen-4.10.0-testing.orig/tools/python/xen/migration/tests.py
++++ xen-4.10.0-testing/tools/python/xen/migration/tests.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python3
+ # -*- coding: utf-8 -*-
+ 
+ """
 Index: xen-4.10.0-testing/tools/python/xen/migration/verify.py
 ===================================================================
 --- xen-4.10.0-testing.orig/tools/python/xen/migration/verify.py
 +++ xen-4.10.0-testing/tools/python/xen/migration/verify.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python3
+ # -*- coding: utf-8 -*-
+ 
+ """
 @@ -7,11 +7,11 @@ Common verification infrastructure for v
  
  from struct import calcsize, unpack
@@ -57,3 +110,13 @@
      """Error with a record in the stream"""
      pass
  
+Index: xen-4.10.0-testing/tools/python/xen/migration/xl.py
+===================================================================
+--- xen-4.10.0-testing.orig/tools/python/xen/migration/xl.py
++++ xen-4.10.0-testing/tools/python/xen/migration/xl.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python3
+ # -*- coding: utf-8 -*-
+ 
+ """

++++++ pygrub-python3-conversion.patch ++++++
--- /var/tmp/diff_new_pack.pxkMaJ/_old  2018-01-16 09:26:35.365997753 +0100
+++ /var/tmp/diff_new_pack.pxkMaJ/_new  2018-01-16 09:26:35.369997567 +0100
@@ -4,18 +4,20 @@
 +++ xen-4.10.0-testing/tools/pygrub/src/pygrub
 @@ -1,4 +1,4 @@
 -#! /usr/bin/env python
-+#!/usr/bin/python
++#!/usr/bin/python3
  #
  # pygrub - simple python-based bootloader for Xen
  #
-@@ -12,6 +12,7 @@
- # along with this program; If not, see <http://www.gnu.org/licenses/>.
- #
+@@ -18,7 +18,8 @@ import logging
+ import platform
+ import xen.lowlevel.xc
+ 
+-import curses, _curses, curses.wrapper, curses.textpad, curses.ascii
++import curses, _curses, curses.textpad, curses.ascii
++from curses import wrapper
+ import getopt
  
-+from __future__ import print_function
- import os, sys, string, struct, tempfile, re, traceback, stat, errno
- import copy
- import logging
+ import fsimage
 @@ -51,7 +52,7 @@ def enable_cursor(ison):
      except _curses.error:
          pass
@@ -80,7 +82,16 @@
                  self.cf = parser()
                  self.cf.filename = f
                  break
-@@ -636,18 +634,18 @@ def run_grub(file, entry, fs, cfg_args):
+@@ -459,7 +457,7 @@ class Grub:
+         # limit read size to avoid pathological cases
+         buf = f.read(FS_READ_MAX)
+         del f
+-        self.cf.parse(buf)
++        self.cf.parse(buf.decode())
+ 
+     def image_index(self):
+         if isinstance(self.cf.default, int):
+@@ -636,21 +634,21 @@ def run_grub(file, entry, fs, cfg_args):
                  chosencfg["args"] = cfg_args
                  return chosencfg
          if g.__dict__.get('cf', None) is None:
@@ -104,7 +115,11 @@
 +            print("  initrd: %s" % img.initrd[1])
  
      if interactive and not list_entries:
-         curses.wrapper(run_main)
+-        curses.wrapper(run_main)
++        wrapper(run_main)
+     else:
+         sel = g.image_index()
+ 
 @@ -661,7 +659,7 @@ def run_grub(file, entry, fs, cfg_args):
             sel = idx
  
@@ -163,7 +178,7 @@
                  usage()
                  sys.exit(1)
          elif o in ("--entry",):
-@@ -877,13 +875,13 @@ if __name__ == "__main__":
+@@ -877,23 +875,23 @@ if __name__ == "__main__":
              debug = True
          elif o in ("--output-format",):
              if a not in ["sxp", "simple", "simple0"]:
@@ -179,7 +194,9 @@
                  sys.exit(1)
              output_directory = a
  
-@@ -892,8 +890,8 @@ if __name__ == "__main__":
+     if debug:
+-      logging.basicConfig(level=logging.DEBUG)
++        logging.basicConfig(level=logging.DEBUG)
  
  
      try:
@@ -204,6 +221,15 @@
          sys.exit(0)
  
      # if boot filesystem is set then pass to fsimage.open
+@@ -947,7 +945,7 @@ if __name__ == "__main__":
+             # IOErrors raised by fsimage.open
+             # RuntimeErrors raised by run_grub if no menu.lst present
+             if debug:
+-              traceback.print_exc()
++                traceback.print_exc()
+             fs = None
+             continue
+ 
 @@ -956,7 +954,7 @@ if __name__ == "__main__":
  
      # Did looping through partitions find us a kernel?
@@ -213,6 +239,13 @@
  
      bootcfg["kernel"] = copy_from_image(fs, chosencfg["kernel"], "kernel",
                                          output_directory, not_really)
+@@ -991,5 +989,5 @@ if __name__ == "__main__":
+         ostring = format_simple(bootcfg["kernel"], bootcfg["ramdisk"], args, 
"\0")
+ 
+     sys.stdout.flush()
+-    os.write(fd, ostring)
++    os.write(fd, ostring.encode('utf-8'))
+     
 Index: xen-4.10.0-testing/tools/pygrub/src/GrubConf.py
 ===================================================================
 --- xen-4.10.0-testing.orig/tools/pygrub/src/GrubConf.py
@@ -271,11 +304,13 @@
              if self.commands[com] is not None:
                  setattr(self, self.commands[com], arg.strip())
              else:
-@@ -233,7 +233,7 @@ class _GrubConfigFile(object):
+@@ -232,8 +232,8 @@ class _GrubConfigFile(object):
+         else:
              self._default = val
  
-         if self._default < 0:
+-        if self._default < 0:
 -            raise ValueError, "default must be positive number"
++        if int(self._default) < 0:
 +            raise ValueError("default must be positive number")
      default = property(_get_default, _set_default)
  
@@ -487,3 +522,134 @@
 -    print g.default
 +        print(i) #, i.title, i.root, i.kernel, i.args, i.initrd
 +    print(g.default)
+Index: xen-4.10.0-testing/tools/pygrub/src/fsimage/fsimage.c
+===================================================================
+--- xen-4.10.0-testing.orig/tools/pygrub/src/fsimage/fsimage.c
++++ xen-4.10.0-testing/tools/pygrub/src/fsimage/fsimage.c
+@@ -66,12 +66,12 @@ fsimage_file_read(fsimage_file_t *file,
+ 
+       bufsize = size ? size : 4096;
+ 
+-      if ((buffer = PyString_FromStringAndSize(NULL, bufsize)) == NULL)
++      if ((buffer = PyBytes_FromStringAndSize(NULL, bufsize)) == NULL)
+               return (NULL);
+  
+       while (1) {
+               int err;
+-              void *buf = PyString_AS_STRING(buffer) + bytesread;
++              void *buf = PyBytes_AS_STRING(buffer) + bytesread;
+ 
+               err = fsi_pread_file(file->file, buf, bufsize,
+                   bytesread + offset);
+@@ -91,12 +91,12 @@ fsimage_file_read(fsimage_file_t *file,
+                       if (bufsize == 0)
+                               break;
+               } else {
+-                      if (_PyString_Resize(&buffer, bytesread + bufsize) < 0)
++                      if (_PyBytes_Resize(&buffer, bytesread + bufsize) < 0)
+                               return (NULL);
+               }
+       }
+ 
+-      _PyString_Resize(&buffer, bytesread);
++      _PyBytes_Resize(&buffer, bytesread);
+       return (buffer);
+ }
+ 
+@@ -107,7 +107,7 @@ PyDoc_STRVAR(fsimage_file_read__doc__,
+    "file. If offset is specified as well, read from the given "
+    "offset.\n");
+ 
+-static struct PyMethodDef fsimage_file_methods[] = {
++static PyMethodDef fsimage_file_methods[] = {
+       { "read", (PyCFunction) fsimage_file_read,
+           METH_VARARGS|METH_KEYWORDS, fsimage_file_read__doc__ },
+       { NULL, NULL, 0, NULL } 
+@@ -116,7 +116,13 @@ static struct PyMethodDef fsimage_file_m
+ static PyObject *
+ fsimage_file_getattr(fsimage_file_t *file, char *name)
+ {
+-      return (Py_FindMethod(fsimage_file_methods, (PyObject *)file, name));
++      PyMethodDef *ml = fsimage_file_methods;
++      for (; ml->ml_name != NULL; ml++) {
++              if (name[0] == ml->ml_name[0] &&
++                      strcmp(name+1, ml->ml_name+1) == 0)
++                      return PyCFunction_New(ml, (PyObject *)file);
++      }
++      return (NULL);
+ }
+ 
+ static void
+@@ -130,8 +136,7 @@ fsimage_file_dealloc(fsimage_file_t *fil
+ 
+ static char fsimage_file_type__doc__[] = "Filesystem image file";
+ PyTypeObject fsimage_file_type = {
+-      PyObject_HEAD_INIT(&PyType_Type)
+-      0,                                      /* ob_size */
++      PyVarObject_HEAD_INIT(&PyType_Type, 0)
+       "fsimage.file",                         /* tp_name */
+       sizeof(fsimage_file_t),                 /* tp_size */
+       0,                                      /* tp_itemsize */
+@@ -207,7 +212,7 @@ PyDoc_STRVAR(fsimage_fs_file_exists__doc
+    "file_exists(fs, name) - lookup name in the given fs and return "
+    "True if it exists");
+ 
+-static struct PyMethodDef fsimage_fs_methods[] = {
++static PyMethodDef fsimage_fs_methods[] = {
+       { "open_file", (PyCFunction) fsimage_fs_open_file,
+         METH_VARARGS|METH_KEYWORDS, fsimage_fs_open_file__doc__ },
+       { "file_exists", (PyCFunction) fsimage_fs_file_exists,
+@@ -218,7 +223,13 @@ static struct PyMethodDef fsimage_fs_met
+ static PyObject *
+ fsimage_fs_getattr(fsimage_fs_t *fs, char *name)
+ {
+-      return (Py_FindMethod(fsimage_fs_methods, (PyObject *)fs, name));
++      PyMethodDef *ml = fsimage_fs_methods;
++      for (; ml->ml_name != NULL; ml++) {
++              if (name[0] == ml->ml_name[0] &&
++                      strcmp(name+1, ml->ml_name+1) == 0)
++                      return PyCFunction_New(ml, (PyObject *)fs);
++      }
++      return (NULL);
+ }
+ 
+ static void
+@@ -232,8 +243,7 @@ fsimage_fs_dealloc (fsimage_fs_t *fs)
+ PyDoc_STRVAR(fsimage_fs_type__doc__, "Filesystem image");
+ 
+ PyTypeObject fsimage_fs_type = {
+-      PyObject_HEAD_INIT(&PyType_Type)
+-      0,                                      /* ob_size */
++      PyVarObject_HEAD_INIT(&PyType_Type, 0)
+       "fsimage.fs",                           /* tp_name */
+       sizeof(fsimage_fs_t),                   /* tp_size */
+       0,                                      /* tp_itemsize */
+@@ -308,7 +318,7 @@ PyDoc_STRVAR(fsimage_getbootstring__doc_
+     "getbootstring(fs) - Return the boot string needed for this file system "
+     "or NULL if none is needed.\n");
+ 
+-static struct PyMethodDef fsimage_module_methods[] = {
++static PyMethodDef fsimage_module_methods[] = {
+       { "open", (PyCFunction)fsimage_open,
+           METH_VARARGS|METH_KEYWORDS, fsimage_open__doc__ },
+       { "getbootstring", (PyCFunction)fsimage_getbootstring,
+@@ -316,8 +326,17 @@ static struct PyMethodDef fsimage_module
+       { NULL, NULL, 0, NULL }
+ };
+ 
++static struct PyModuleDef fsimage_module =
++{
++    PyModuleDef_HEAD_INIT,
++    "fsimage",
++    "",
++    -1,
++    fsimage_module_methods
++};
++
+ PyMODINIT_FUNC
+-initfsimage(void)
++PyInit_fsimage(void)
+ {
+-      Py_InitModule("fsimage", fsimage_module_methods);
++      return PyModule_Create(&fsimage_module);
+ }

++++++ xen-4.10.0-testing-src.tar.bz2 ++++++
/work/SRC/openSUSE:Factory/xen/xen-4.10.0-testing-src.tar.bz2 
/work/SRC/openSUSE:Factory/.xen.new/xen-4.10.0-testing-src.tar.bz2 differ: char 
11, line 1

++++++ xen2libvirt.py ++++++
--- /var/tmp/diff_new_pack.pxkMaJ/_old  2018-01-16 09:26:35.549989145 +0100
+++ /var/tmp/diff_new_pack.pxkMaJ/_new  2018-01-16 09:26:35.553988958 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 #
 # Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
@@ -22,7 +22,7 @@
 # Read native Xen configuration format, convert to libvirt domXML, and
 # import (virsh define <xml>) into libvirt.
 
-from __future__ import print_function
+
 import sys
 import os
 import argparse

++++++ xenmon-python3-conversion.patch ++++++
--- /var/tmp/diff_new_pack.pxkMaJ/_old  2018-01-16 09:26:35.597986900 +0100
+++ /var/tmp/diff_new_pack.pxkMaJ/_new  2018-01-16 09:26:35.597986900 +0100
@@ -2,15 +2,13 @@
 ===================================================================
 --- xen-4.10.0-testing.orig/tools/xenmon/xenmon.py
 +++ xen-4.10.0-testing/tools/xenmon/xenmon.py
-@@ -23,6 +23,7 @@
- #   along with this program; If not, see <http://www.gnu.org/licenses/>.
- #####################################################################
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python3
  
-+from __future__ import print_function
- import mmap
- import struct
- import os
-@@ -248,8 +249,8 @@ def display(scr, row, col, str, attr=0):
+ #####################################################################
+ # xenmon is a front-end for xenbaked.
+@@ -248,8 +248,8 @@ def display(scr, row, col, str, attr=0):
          scr.keypad(0)
          _c.echo()
          _c.endwin()
@@ -21,7 +19,7 @@
          sys.exit(1)
  
  
-@@ -704,7 +705,7 @@ def main():
+@@ -704,7 +704,7 @@ def main():
          try:
              writelog()
          except:

++++++ xnloader.py ++++++
--- /var/tmp/diff_new_pack.pxkMaJ/_old  2018-01-16 09:26:35.633985216 +0100
+++ /var/tmp/diff_new_pack.pxkMaJ/_new  2018-01-16 09:26:35.633985216 +0100
@@ -13,7 +13,7 @@
 # Binary patching of xnloader.sys
 # For launching NetWare on Xen 4.2 and newer
 
-from __future__ import print_function
+
 import os, sys, base64
 
 CODE_OFFSET=0x49F5


Reply via email to