packaging: add packaging directory
authorhyokeun <hyokeun.jeon@samsung.com>
Mon, 5 Sep 2016 04:22:58 +0000 (13:22 +0900)
committerhyokeun <hyokeun.jeon@samsung.com>
Tue, 6 Sep 2016 06:57:57 +0000 (15:57 +0900)
Change-Id: I7eb77abf7c4e5afdc9606c723c125910280c65e6

20 files changed:
packaging/60-kvm.rules [new file with mode: 0644]
packaging/60-kvm.x86.rules [new file with mode: 0644]
packaging/80-kvm.rules [new file with mode: 0644]
packaging/80-qemu-ga.rules [new file with mode: 0644]
packaging/_constraints [new file with mode: 0644]
packaging/baselibs.conf [new file with mode: 0644]
packaging/bridge.conf [new file with mode: 0644]
packaging/ksm.service [new file with mode: 0644]
packaging/kvm.conf [new file with mode: 0644]
packaging/kvm_stat [new file with mode: 0644]
packaging/pre_checkin.sh [new file with mode: 0644]
packaging/qemu-2.7.0.tar.bz2.sig [new file with mode: 0644]
packaging/qemu-ga.service [new file with mode: 0644]
packaging/qemu-ifup [new file with mode: 0644]
packaging/qemu-kvm.1.gz [new file with mode: 0644]
packaging/qemu-linux-user.spec [new file with mode: 0644]
packaging/qemu-rpmlintrc [new file with mode: 0644]
packaging/qemu.spec [new file with mode: 0644]
packaging/seabios_128kb.patch [new file with mode: 0644]
packaging/update_git.sh [new file with mode: 0644]

diff --git a/packaging/60-kvm.rules b/packaging/60-kvm.rules
new file mode 100644 (file)
index 0000000..6e89c84
--- /dev/null
@@ -0,0 +1 @@
+KERNEL=="kvm", MODE="0660", GROUP="kvm"
diff --git a/packaging/60-kvm.x86.rules b/packaging/60-kvm.x86.rules
new file mode 100644 (file)
index 0000000..52d448e
--- /dev/null
@@ -0,0 +1,2 @@
+KERNEL=="kvm", MODE="0660", GROUP="kvm"
+ACTION=="add|change", SUBSYSTEM=="dmi", KERNEL=="id", RUN+="/bin/sh -c 'grep -q vmx /proc/cpuinfo && /sbin/modprobe kvm-intel; grep -q svm /proc/cpuinfo && /sbin/modprobe kvm-amd; /sbin/modprobe vhost-net'"
diff --git a/packaging/80-kvm.rules b/packaging/80-kvm.rules
new file mode 100644 (file)
index 0000000..29ad001
--- /dev/null
@@ -0,0 +1 @@
+KERNEL=="kvm", MODE="0666", GROUP="kvm"
diff --git a/packaging/80-qemu-ga.rules b/packaging/80-qemu-ga.rules
new file mode 100644 (file)
index 0000000..8253237
--- /dev/null
@@ -0,0 +1 @@
+SUBSYSTEM=="virtio-ports", ATTR{name}=="org.qemu.guest_agent.0", TAG+="systemd", ENV{SYSTEMD_WANTS}+="qemu-ga.service"
diff --git a/packaging/_constraints b/packaging/_constraints
new file mode 100644 (file)
index 0000000..78fa034
--- /dev/null
@@ -0,0 +1,24 @@
+<constraints>
+  <overwrite>
+    <conditions>
+      <package>qemu-testsuite</package>
+    </conditions>
+    <hardware>
+      <physicalmemory>
+        <size unit="M">1500</size>
+      </physicalmemory>
+    </hardware>
+  </overwrite>
+  <overwrite>
+    <conditions>
+      <arch>ppc64</arch>
+      <arch>ppc64le</arch>
+      <package>qemu</package>
+    </conditions>
+    <hardware>
+      <disk>
+        <size unit="G">7</size>
+      </disk>
+    </hardware>
+  </overwrite>
+</constraints>
diff --git a/packaging/baselibs.conf b/packaging/baselibs.conf
new file mode 100644 (file)
index 0000000..42cff28
--- /dev/null
@@ -0,0 +1,29 @@
+arch i586 targets armv7l:cross aarch64:cross
+arch i686 targets armv7l:cross aarch64:cross
+arch x86_64 targets armv7l:cross aarch64:cross
+qemu-linux-user
+  +/
+qemu-linux-user-debuginfo
+  +/
+qemu-linux-user-debugsource
+  +/
+
+targettype cross package qemu-linux-user
+    autoreqprov off
+    +/
+    post "function setbinfmt () {"
+    post "    local arch=$1"
+    post "    local fmt=$2"
+    post "    local comp_fmt=$(echo ${fmt} | sed -e 's/.*:://;s/:[^:]$//;s/\\x//g')"
+    post "    local curr_fmt=$(cat /proc/sys/fs/binfmt_misc/${arch} | sed -ne '/interpreter/{s/interpreter //;h};/magic/{s/magic //;H};/mask/{s/mask //;G;s/\([^\n]*\)\n\([^\n]*\)\n\([^\n]*\)/\3:\1:\2/p}')"
+    post "    if ( [ ! -e "/proc/sys/fs/binfmt_misc/${arch}" ] || [ "x${comp_fmt}" != "x${curr_fmt}" ] ); then"
+    post "        builtin echo -1 > "/proc/sys/fs/binfmt_misc/${arch}""
+    post "        builtin echo "${fmt}" > /proc/sys/fs/binfmt_misc/register"
+    post "    fi"
+    post "}"
+    post "[ ! -d /proc/sys/fs/binfmt_misc ] && ( /sbin/modprobe binfmt_misc )"
+    post "[ ! -f /proc/sys/fs/binfmt_misc/register ] && ( mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc )"
+    post "[ -e /proc/sys/fs/binfmt_misc/arm64 ] && ( builtin echo -1 > /proc/sys/fs/binfmt_misc/arm64 )"
+    post "setbinfmt 'arm' ':arm:M::\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-binfmt:P' "
+    post "setbinfmt 'armeb' ':armeb:M::\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-armeb-binfmt:P'"
+    post "setbinfmt 'aarch64' ':aarch64:M::\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-aarch64-binfmt:P'"
diff --git a/packaging/bridge.conf b/packaging/bridge.conf
new file mode 100644 (file)
index 0000000..d06c62a
--- /dev/null
@@ -0,0 +1,11 @@
+# Access control file for qemu bridge helper
+# Syntax consists of:
+#   # comment (ignored)
+#   allow all
+#   allow <bridge_name>
+#   deny all
+#   deny <bridge_name>
+#   include /path/to/additional/ACL/file
+# Users are blacklisted by default and 'deny' takes precedence over 'allow'.
+# Including additional ACL files allows file access permissions to be used as
+# a component of the policy to allow access or deny access to specific bridges.
diff --git a/packaging/ksm.service b/packaging/ksm.service
new file mode 100644 (file)
index 0000000..55d699c
--- /dev/null
@@ -0,0 +1,13 @@
+[Unit]
+Description=Kernel Samepage Merging
+ConditionPathExists=/sys/kernel/mm/ksm
+ConditionVirtualization=no
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/bin/bash -c "echo 1 > /sys/kernel/mm/ksm/run"
+ExecStop=/bin/bash -c "echo 0 > /sys/kernel/mm/ksm/run"
+
+[Install]
+WantedBy=multi-user.target
diff --git a/packaging/kvm.conf b/packaging/kvm.conf
new file mode 100644 (file)
index 0000000..c1c76e6
--- /dev/null
@@ -0,0 +1,3 @@
+# load kvm module at boot time
+kvm
+
diff --git a/packaging/kvm_stat b/packaging/kvm_stat
new file mode 100644 (file)
index 0000000..762544b
--- /dev/null
@@ -0,0 +1,511 @@
+#!/usr/bin/python
+#
+# top-like utility for displaying kvm statistics
+#
+# Copyright 2006-2008 Qumranet Technologies
+# Copyright 2008-2011 Red Hat, Inc.
+#
+# Authors:
+#  Avi Kivity <avi@redhat.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2.  See
+# the COPYING file in the top-level directory.
+
+import curses
+import sys, os, time, optparse
+
+class DebugfsProvider(object):
+    def __init__(self):
+        self.base = '/sys/kernel/debug/kvm'
+        self._fields = os.listdir(self.base)
+    def fields(self):
+        return self._fields
+    def select(self, fields):
+        self._fields = fields
+    def read(self):
+        def val(key):
+            return int(file(self.base + '/' + key).read())
+        return dict([(key, val(key)) for key in self._fields])
+
+vmx_exit_reasons = {
+    0: 'EXCEPTION_NMI',
+    1: 'EXTERNAL_INTERRUPT',
+    2: 'TRIPLE_FAULT',
+    7: 'PENDING_INTERRUPT',
+    8: 'NMI_WINDOW',
+    9: 'TASK_SWITCH',
+    10: 'CPUID',
+    12: 'HLT',
+    14: 'INVLPG',
+    15: 'RDPMC',
+    16: 'RDTSC',
+    18: 'VMCALL',
+    19: 'VMCLEAR',
+    20: 'VMLAUNCH',
+    21: 'VMPTRLD',
+    22: 'VMPTRST',
+    23: 'VMREAD',
+    24: 'VMRESUME',
+    25: 'VMWRITE',
+    26: 'VMOFF',
+    27: 'VMON',
+    28: 'CR_ACCESS',
+    29: 'DR_ACCESS',
+    30: 'IO_INSTRUCTION',
+    31: 'MSR_READ',
+    32: 'MSR_WRITE',
+    33: 'INVALID_STATE',
+    36: 'MWAIT_INSTRUCTION',
+    39: 'MONITOR_INSTRUCTION',
+    40: 'PAUSE_INSTRUCTION',
+    41: 'MCE_DURING_VMENTRY',
+    43: 'TPR_BELOW_THRESHOLD',
+    44: 'APIC_ACCESS',
+    48: 'EPT_VIOLATION',
+    49: 'EPT_MISCONFIG',
+    54: 'WBINVD',
+    55: 'XSETBV',
+}
+
+svm_exit_reasons = {
+    0x000: 'READ_CR0',
+    0x003: 'READ_CR3',
+    0x004: 'READ_CR4',
+    0x008: 'READ_CR8',
+    0x010: 'WRITE_CR0',
+    0x013: 'WRITE_CR3',
+    0x014: 'WRITE_CR4',
+    0x018: 'WRITE_CR8',
+    0x020: 'READ_DR0',
+    0x021: 'READ_DR1',
+    0x022: 'READ_DR2',
+    0x023: 'READ_DR3',
+    0x024: 'READ_DR4',
+    0x025: 'READ_DR5',
+    0x026: 'READ_DR6',
+    0x027: 'READ_DR7',
+    0x030: 'WRITE_DR0',
+    0x031: 'WRITE_DR1',
+    0x032: 'WRITE_DR2',
+    0x033: 'WRITE_DR3',
+    0x034: 'WRITE_DR4',
+    0x035: 'WRITE_DR5',
+    0x036: 'WRITE_DR6',
+    0x037: 'WRITE_DR7',
+    0x040: 'EXCP_BASE',
+    0x060: 'INTR',
+    0x061: 'NMI',
+    0x062: 'SMI',
+    0x063: 'INIT',
+    0x064: 'VINTR',
+    0x065: 'CR0_SEL_WRITE',
+    0x066: 'IDTR_READ',
+    0x067: 'GDTR_READ',
+    0x068: 'LDTR_READ',
+    0x069: 'TR_READ',
+    0x06a: 'IDTR_WRITE',
+    0x06b: 'GDTR_WRITE',
+    0x06c: 'LDTR_WRITE',
+    0x06d: 'TR_WRITE',
+    0x06e: 'RDTSC',
+    0x06f: 'RDPMC',
+    0x070: 'PUSHF',
+    0x071: 'POPF',
+    0x072: 'CPUID',
+    0x073: 'RSM',
+    0x074: 'IRET',
+    0x075: 'SWINT',
+    0x076: 'INVD',
+    0x077: 'PAUSE',
+    0x078: 'HLT',
+    0x079: 'INVLPG',
+    0x07a: 'INVLPGA',
+    0x07b: 'IOIO',
+    0x07c: 'MSR',
+    0x07d: 'TASK_SWITCH',
+    0x07e: 'FERR_FREEZE',
+    0x07f: 'SHUTDOWN',
+    0x080: 'VMRUN',
+    0x081: 'VMMCALL',
+    0x082: 'VMLOAD',
+    0x083: 'VMSAVE',
+    0x084: 'STGI',
+    0x085: 'CLGI',
+    0x086: 'SKINIT',
+    0x087: 'RDTSCP',
+    0x088: 'ICEBP',
+    0x089: 'WBINVD',
+    0x08a: 'MONITOR',
+    0x08b: 'MWAIT',
+    0x08c: 'MWAIT_COND',
+    0x400: 'NPF',
+}
+
+s390_exit_reasons = {
+       0x000: 'UNKNOWN',
+       0x001: 'EXCEPTION',
+       0x002: 'IO',
+       0x003: 'HYPERCALL',
+       0x004: 'DEBUG',
+       0x005: 'HLT',
+       0x006: 'MMIO',
+       0x007: 'IRQ_WINDOW_OPEN',
+       0x008: 'SHUTDOWN',
+       0x009: 'FAIL_ENTRY',
+       0x010: 'INTR',
+       0x011: 'SET_TPR',
+       0x012: 'TPR_ACCESS',
+       0x013: 'S390_SIEIC',
+       0x014: 'S390_RESET',
+       0x015: 'DCR',
+       0x016: 'NMI',
+       0x017: 'INTERNAL_ERROR',
+       0x018: 'OSI',
+       0x019: 'PAPR_HCALL',
+}
+
+vendor_exit_reasons = {
+    'vmx': vmx_exit_reasons,
+    'svm': svm_exit_reasons,
+    'IBM/S390': s390_exit_reasons,
+}
+
+syscall_numbers = {
+    'IBM/S390': 331,
+}
+
+sc_perf_evt_open = 298
+
+exit_reasons = None
+
+for line in file('/proc/cpuinfo').readlines():
+    if line.startswith('flags') or line.startswith('vendor_id'):
+        for flag in line.split():
+            if flag in vendor_exit_reasons:
+                exit_reasons = vendor_exit_reasons[flag]
+            if flag in syscall_numbers:
+                sc_perf_evt_open = syscall_numbers[flag]
+filters = {
+    'kvm_exit': ('exit_reason', exit_reasons)
+}
+
+def invert(d):
+    return dict((x[1], x[0]) for x in d.iteritems())
+
+for f in filters:
+    filters[f] = (filters[f][0], invert(filters[f][1]))
+
+import ctypes, struct, array
+
+libc = ctypes.CDLL('libc.so.6')
+syscall = libc.syscall
+class perf_event_attr(ctypes.Structure):
+    _fields_ = [('type', ctypes.c_uint32),
+                ('size', ctypes.c_uint32),
+                ('config', ctypes.c_uint64),
+                ('sample_freq', ctypes.c_uint64),
+                ('sample_type', ctypes.c_uint64),
+                ('read_format', ctypes.c_uint64),
+                ('flags', ctypes.c_uint64),
+                ('wakeup_events', ctypes.c_uint32),
+                ('bp_type', ctypes.c_uint32),
+                ('bp_addr', ctypes.c_uint64),
+                ('bp_len', ctypes.c_uint64),
+                ]
+def _perf_event_open(attr, pid, cpu, group_fd, flags):
+    return syscall(sc_perf_evt_open, ctypes.pointer(attr), ctypes.c_int(pid),
+                   ctypes.c_int(cpu), ctypes.c_int(group_fd),
+                   ctypes.c_long(flags))
+
+PERF_TYPE_HARDWARE              = 0
+PERF_TYPE_SOFTWARE              = 1
+PERF_TYPE_TRACEPOINT            = 2
+PERF_TYPE_HW_CACHE              = 3
+PERF_TYPE_RAW                   = 4
+PERF_TYPE_BREAKPOINT            = 5
+
+PERF_SAMPLE_IP                  = 1 << 0
+PERF_SAMPLE_TID                 = 1 << 1
+PERF_SAMPLE_TIME                = 1 << 2
+PERF_SAMPLE_ADDR                = 1 << 3
+PERF_SAMPLE_READ                = 1 << 4
+PERF_SAMPLE_CALLCHAIN           = 1 << 5
+PERF_SAMPLE_ID                  = 1 << 6
+PERF_SAMPLE_CPU                 = 1 << 7
+PERF_SAMPLE_PERIOD              = 1 << 8
+PERF_SAMPLE_STREAM_ID           = 1 << 9
+PERF_SAMPLE_RAW                 = 1 << 10
+
+PERF_FORMAT_TOTAL_TIME_ENABLED  = 1 << 0
+PERF_FORMAT_TOTAL_TIME_RUNNING  = 1 << 1
+PERF_FORMAT_ID                  = 1 << 2
+PERF_FORMAT_GROUP               = 1 << 3
+
+import re
+
+sys_tracing = '/sys/kernel/debug/tracing'
+
+class Group(object):
+    def __init__(self, cpu):
+        self.events = []
+        self.group_leader = None
+        self.cpu = cpu
+    def add_event(self, name, event_set, tracepoint, filter = None):
+        self.events.append(Event(group = self,
+                                 name = name, event_set = event_set,
+                                 tracepoint = tracepoint, filter = filter))
+        if len(self.events) == 1:
+            self.file = os.fdopen(self.events[0].fd)
+    def read(self):
+        bytes = 8 * (1 + len(self.events))
+        fmt = 'xxxxxxxx' + 'q' * len(self.events)
+        return dict(zip([event.name for event in self.events],
+                        struct.unpack(fmt, self.file.read(bytes))))
+
+class Event(object):
+    def __init__(self, group, name, event_set, tracepoint, filter = None):
+        self.name = name
+        attr = perf_event_attr()
+        attr.type = PERF_TYPE_TRACEPOINT
+        attr.size = ctypes.sizeof(attr)
+        id_path = os.path.join(sys_tracing, 'events', event_set,
+                               tracepoint, 'id')
+        id = int(file(id_path).read())
+        attr.config = id
+        attr.sample_type = (PERF_SAMPLE_RAW
+                            | PERF_SAMPLE_TIME
+                            | PERF_SAMPLE_CPU)
+        attr.sample_period = 1
+        attr.read_format = PERF_FORMAT_GROUP
+        group_leader = -1
+        if group.events:
+            group_leader = group.events[0].fd
+        fd = _perf_event_open(attr, -1, group.cpu, group_leader, 0)
+        if fd == -1:
+            raise Exception('perf_event_open failed')
+        if filter:
+            import fcntl
+            fcntl.ioctl(fd, 0x40082406, filter)
+        self.fd = fd
+    def enable(self):
+        import fcntl
+        fcntl.ioctl(self.fd, 0x00002400, 0)
+    def disable(self):
+        import fcntl
+        fcntl.ioctl(self.fd, 0x00002401, 0)
+
+class TracepointProvider(object):
+    def __init__(self):
+        path = os.path.join(sys_tracing, 'events', 'kvm')
+        fields = [f
+                  for f in os.listdir(path)
+                  if os.path.isdir(os.path.join(path, f))]
+        extra = []
+        for f in fields:
+            if f in filters:
+                subfield, values = filters[f]
+                for name, number in values.iteritems():
+                    extra.append(f + '(' + name + ')')
+        fields += extra
+        self._setup(fields)
+        self.select(fields)
+    def fields(self):
+        return self._fields
+    def _setup(self, _fields):
+        self._fields = _fields
+        cpure = r'cpu([0-9]+)'
+        self.cpus = [int(re.match(cpure, x).group(1))
+                     for x in os.listdir('/sys/devices/system/cpu')
+                     if re.match(cpure, x)]
+        import resource
+        nfiles = len(self.cpus) * 1000
+        resource.setrlimit(resource.RLIMIT_NOFILE, (nfiles, nfiles))
+        events = []
+        self.group_leaders = []
+        for cpu in self.cpus:
+            group = Group(cpu)
+            for name in _fields:
+                tracepoint = name
+                filter = None
+                m = re.match(r'(.*)\((.*)\)', name)
+                if m:
+                    tracepoint, sub = m.groups()
+                    filter = '%s==%d\0' % (filters[tracepoint][0],
+                                           filters[tracepoint][1][sub])
+                event = group.add_event(name, event_set = 'kvm',
+                                        tracepoint = tracepoint,
+                                        filter = filter)
+            self.group_leaders.append(group)
+    def select(self, fields):
+        for group in self.group_leaders:
+            for event in group.events:
+                if event.name in fields:
+                    event.enable()
+                else:
+                    event.disable()
+    def read(self):
+        from collections import defaultdict
+        ret = defaultdict(int)
+        for group in self.group_leaders:
+            for name, val in group.read().iteritems():
+                ret[name] += val
+        return ret
+
+class Stats:
+    def __init__(self, provider, fields = None):
+        self.provider = provider
+        self.fields_filter = fields
+        self._update()
+    def _update(self):
+        def wanted(key):
+            import re
+            if not self.fields_filter:
+                return True
+            return re.match(self.fields_filter, key) is not None
+        self.values = dict([(key, None)
+                            for key in provider.fields()
+                            if wanted(key)])
+        self.provider.select(self.values.keys())
+    def set_fields_filter(self, fields_filter):
+        self.fields_filter = fields_filter
+        self._update()
+    def get(self):
+        new = self.provider.read()
+        for key in self.provider.fields():
+            oldval = self.values.get(key, (0, 0))
+            newval = new[key]
+            newdelta = None
+            if oldval is not None:
+                newdelta = newval - oldval[0]
+            self.values[key] = (newval, newdelta)
+        return self.values
+
+if not os.access('/sys/kernel/debug', os.F_OK):
+    print 'Please enable CONFIG_DEBUG_FS in your kernel'
+    sys.exit(1)
+if not os.access('/sys/kernel/debug/kvm', os.F_OK):
+    print "Please mount debugfs ('mount -t debugfs debugfs /sys/kernel/debug')"
+    print "and ensure the kvm modules are loaded"
+    sys.exit(1)
+
+label_width = 40
+number_width = 10
+
+def tui(screen, stats):
+    curses.use_default_colors()
+    curses.noecho()
+    drilldown = False
+    fields_filter = stats.fields_filter
+    def update_drilldown():
+        if not fields_filter:
+            if drilldown:
+                stats.set_fields_filter(None)
+            else:
+                stats.set_fields_filter(r'^[^\(]*$')
+    update_drilldown()
+    def refresh(sleeptime):
+        screen.erase()
+        screen.addstr(0, 0, 'kvm statistics')
+        row = 2
+        s = stats.get()
+        def sortkey(x):
+            if s[x][1]:
+                return (-s[x][1], -s[x][0])
+            else:
+                return (0, -s[x][0])
+        for key in sorted(s.keys(), key = sortkey):
+            if row >= screen.getmaxyx()[0]:
+                break
+            values = s[key]
+            if not values[0] and not values[1]:
+                break
+            col = 1
+            screen.addstr(row, col, key)
+            col += label_width
+            screen.addstr(row, col, '%10d' % (values[0],))
+            col += number_width
+            if values[1] is not None:
+                screen.addstr(row, col, '%8d' % (values[1] / sleeptime,))
+            row += 1
+        screen.refresh()
+
+    sleeptime = 0.25
+    while True:
+        refresh(sleeptime)
+        curses.halfdelay(int(sleeptime * 10))
+        sleeptime = 3
+        try:
+            c = screen.getkey()
+            if c == 'x':
+                drilldown = not drilldown
+                update_drilldown()
+            if c == 'q':
+                break
+        except KeyboardInterrupt:
+            break
+        except curses.error:
+            continue
+
+def batch(stats):
+    s = stats.get()
+    time.sleep(1)
+    s = stats.get()
+    for key in sorted(s.keys()):
+        values = s[key]
+        print '%-22s%10d%10d' % (key, values[0], values[1])
+
+def log(stats):
+    keys = sorted(stats.get().iterkeys())
+    def banner():
+        for k in keys:
+            print '%10s' % k[0:9],
+        print
+    def statline():
+        s = stats.get()
+        for k in keys:
+            print ' %9d' % s[k][1],
+        print
+    line = 0
+    banner_repeat = 20
+    while True:
+        time.sleep(1)
+        if line % banner_repeat == 0:
+            banner()
+        statline()
+        line += 1
+
+options = optparse.OptionParser()
+options.add_option('-1', '--once', '--batch',
+                   action = 'store_true',
+                   default = False,
+                   dest = 'once',
+                   help = 'run in batch mode for one second',
+                   )
+options.add_option('-l', '--log',
+                   action = 'store_true',
+                   default = False,
+                   dest = 'log',
+                   help = 'run in logging mode (like vmstat)',
+                   )
+options.add_option('-f', '--fields',
+                   action = 'store',
+                   default = None,
+                   dest = 'fields',
+                   help = 'fields to display (regex)',
+                   )
+(options, args) = options.parse_args(sys.argv)
+
+try:
+    provider = TracepointProvider()
+except:
+    provider = DebugfsProvider()
+
+stats = Stats(provider, fields = options.fields)
+
+if options.log:
+    log(stats)
+elif not options.once:
+    import curses.wrapper
+    curses.wrapper(tui, stats)
+else:
+    batch(stats)
diff --git a/packaging/pre_checkin.sh b/packaging/pre_checkin.sh
new file mode 100644 (file)
index 0000000..1abb100
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+cp qemu.changes qemu-testsuite.changes
+
+if [ "$1" != "-q" ]; then
+  echo "Note that the patch queue needs to be regenerated via update_git.sh"
+  echo "before running $0."
+fi
diff --git a/packaging/qemu-2.7.0.tar.bz2.sig b/packaging/qemu-2.7.0.tar.bz2.sig
new file mode 100644 (file)
index 0000000..af6b643
Binary files /dev/null and b/packaging/qemu-2.7.0.tar.bz2.sig differ
diff --git a/packaging/qemu-ga.service b/packaging/qemu-ga.service
new file mode 100644 (file)
index 0000000..c97e3f0
--- /dev/null
@@ -0,0 +1,11 @@
+[Unit]
+Description=QEMU Guest Agent
+Documentation=http://wiki.qemu.org/Features/QAPI/GuestAgent
+BindsTo=dev-virtio\x2dports-org.qemu.guest_agent.0.device
+After=dev-virtio\x2dports-org.qemu.guest_agent.0.device
+
+[Service]
+Type=simple
+ExecStart=-/usr/bin/qemu-ga
+Restart=always
+RestartSec=0
diff --git a/packaging/qemu-ifup b/packaging/qemu-ifup
new file mode 100644 (file)
index 0000000..f556ec7
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+echo 'config qemu network with bridge for ' $*
+
+# If bridge is not specified, try device with default route.
+bridge=$2
+if [ -z "$bridge" ]; then
+    bridge=$(ip route list | awk '/^default / { print $NF }')
+fi
+
+# Exit if $bridge is not a bridge.  Exit with 0 status
+# so qemu-dm process is not terminated.  No networking in
+# vm is bad but not catastrophic.  The vm could still run
+# cpu and disk IO workloads.
+# Include an useful error message in qemu-dm log file.
+if [ ! -e "/sys/class/net/${bridge}/bridge" ]
+then
+   echo "WARNING! ${bridge} is not a bridge.  qemu-ifup exiting.  VM may not have a functioning networking stack."
+   exit 0
+fi
+
+ifconfig $1 0.0.0.0 up
+brctl addif $bridge $1 || true
diff --git a/packaging/qemu-kvm.1.gz b/packaging/qemu-kvm.1.gz
new file mode 100644 (file)
index 0000000..48e8ae9
Binary files /dev/null and b/packaging/qemu-kvm.1.gz differ
diff --git a/packaging/qemu-linux-user.spec b/packaging/qemu-linux-user.spec
new file mode 100644 (file)
index 0000000..3fc4941
--- /dev/null
@@ -0,0 +1,194 @@
+#
+# spec file for package qemu-linux-user
+#
+# Copyright (c) 2016 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
+# upon. The license for this file, and modifications and additions to the
+# file, is the same license as for the pristine package itself (unless the
+# license for the pristine package is not an Open Source License, in which
+# case the license is the MIT License). An "Open Source License" is a
+# license that conforms to the Open Source Definition (Version 1.9)
+# published by the Open Source Initiative.
+
+# Please submit bugfixes or comments via http://bugs.opensuse.org/
+#
+
+
+Name:           qemu-linux-user
+Url:            http://www.qemu.org/
+Summary:        Universal CPU emulator
+License:        BSD-3-Clause and GPL-2.0 and GPL-2.0+ and LGPL-2.1+ and MIT
+Group:          System/Emulators/PC
+Version:        2.7.0
+Release:        0
+Source:         http://wiki.qemu.org/download/qemu-2.7.0.tar.bz2
+Source300:      qemu-rpmlintrc
+Source400:      update_git.sh
+BuildRoot:      %{_tmppath}/%{name}-%{version}-build
+BuildRequires:  e2fsprogs-devel
+BuildRequires:  fdupes
+BuildRequires:  gcc-c++
+%if 0%{?suse_version} >= 1140
+BuildRequires:  glib2-devel-static
+%else
+BuildRequires:  glib2-devel
+%endif
+%if 0%{?suse_version} >= 1210
+BuildRequires:  glibc-devel-static
+%endif
+%if 0%{?suse_version} >= 1210
+BuildRequires:  libattr-devel-static
+%else
+BuildRequires:  libattr-devel
+%endif
+%if 0%{?suse_version} > 1220
+BuildRequires:  makeinfo
+%endif
+BuildRequires:  ncurses-devel
+%if 0%{?suse_version} >= 1220
+BuildRequires:  pcre-devel-static
+%endif
+BuildRequires:  python
+%if 0%{?suse_version} >= 1120
+BuildRequires:  zlib-devel-static
+%else
+BuildRequires:  zlib-devel
+%endif
+# we must not install the qemu-linux-user package when under QEMU build
+%if 0%{?qemu_user_space_build:1}
+#!BuildIgnore:  post-build-checks
+%endif
+Provides:       qemu:%_bindir/qemu-arm
+
+%description
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+This sub-package contains statically linked binaries for running linux-user
+emulations. This can be used together with the OBS build script to
+run cross-architecture builds.
+
+%prep
+%setup -q -n qemu-2.7.0
+
+%build
+./configure --prefix=%_prefix --sysconfdir=%_sysconfdir \
+       --libexecdir=%_libexecdir \
+       --enable-linux-user \
+       --disable-system \
+       --disable-tools \
+       --disable-guest-agent \
+       --static --disable-linux-aio \
+       --disable-fdt \
+       --without-pixman \
+       --disable-blobs \
+       --disable-strip \
+       --extra-cflags="$QEMU_OPT_FLAGS"
+%if 0%{?suse_version} == 1140
+# -lrt needs to come after -lglib-2.0 to avoid undefined clock_gettime
+sed -i "s/-lglib-2.0/-lglib-2.0 -lrt/" config-host.mak
+%endif
+make %{?_smp_mflags} V=1
+
+%ifarch %ix86
+%define qemu_arch i386
+%endif
+%ifarch x86_64
+%define qemu_arch x86_64
+%endif
+%ifarch %arm
+%define qemu_arch arm
+%endif
+%ifarch aarch64
+%define qemu_arch aarch64
+%endif
+%ifarch ppc
+%define qemu_arch ppc
+%endif
+%ifarch ppc64
+%define qemu_arch ppc64
+%endif
+%ifarch ppc64le
+%define qemu_arch ppc64le
+%endif
+%ifarch s390x
+%define qemu_arch s390x
+%endif
+
+%ifarch %ix86 x86_64 %arm aarch64 ppc ppc64 ppc64le s390x
+%if 0%{?suse_version} >= 1310
+%check
+%{qemu_arch}-linux-user/qemu-%{qemu_arch} %_bindir/ls > /dev/null
+%endif
+%endif
+
+%install
+make install DESTDIR=$RPM_BUILD_ROOT
+rm -fr $RPM_BUILD_ROOT/%_datadir/doc
+rm -f $RPM_BUILD_ROOT/%_mandir/man1/qemu.1
+rm -f $RPM_BUILD_ROOT/%_mandir/man1/qemu-img.1
+rm -f $RPM_BUILD_ROOT/%_mandir/man8/qemu-nbd.8
+rm -rf $RPM_BUILD_ROOT/%_datadir/qemu/keymaps
+rm -f $RPM_BUILD_ROOT/%_datadir/qemu/trace-events-all
+rm -f $RPM_BUILD_ROOT/%_sysconfdir/qemu/target-x86_64.conf
+rm -f $RPM_BUILD_ROOT/%_libexecdir/qemu-bridge-helper
+install -d -m 755 $RPM_BUILD_ROOT/%_sbindir
+install -m 755 scripts/qemu-binfmt-conf.sh $RPM_BUILD_ROOT/%_sbindir
+%ifnarch %ix86 x86_64
+ln -sf ../../../emul/ia32-linux $RPM_BUILD_ROOT/usr/share/qemu/qemu-i386
+%endif
+%ifnarch ia64
+mkdir -p $RPM_BUILD_ROOT/emul/ia32-linux
+%endif
+%fdupes -s $RPM_BUILD_ROOT
+
+%clean
+rm -rf ${RPM_BUILD_ROOT}
+
+%files
+%defattr(-, root, root)
+%_bindir/qemu-aarch64
+%_bindir/qemu-alpha
+%_bindir/qemu-arm
+%_bindir/qemu-armeb
+%_bindir/qemu-cris
+%_bindir/qemu-i386
+%_bindir/qemu-m68k
+%_bindir/qemu-microblaze
+%_bindir/qemu-microblazeel
+%_bindir/qemu-mips
+%_bindir/qemu-mipsel
+%_bindir/qemu-mipsn32
+%_bindir/qemu-mipsn32el
+%_bindir/qemu-mips64
+%_bindir/qemu-mips64el
+%_bindir/qemu-or32
+%_bindir/qemu-ppc64abi32
+%_bindir/qemu-ppc64
+%_bindir/qemu-ppc64le
+%_bindir/qemu-ppc
+%_bindir/qemu-s390x
+%_bindir/qemu-sh4
+%_bindir/qemu-sh4eb
+%_bindir/qemu-sparc32plus
+%_bindir/qemu-sparc64
+%_bindir/qemu-sparc
+%_bindir/qemu-tilegx
+%_bindir/qemu-unicore32
+%_bindir/qemu-x86_64
+%_bindir/qemu-*-binfmt
+%_sbindir/qemu-binfmt-conf.sh
+%ifnarch %ix86 x86_64 ia64
+%dir /emul/ia32-linux
+%endif
+%ifnarch %ix86 x86_64
+%dir /usr/share/qemu
+/usr/share/qemu/qemu-i386
+%endif
+
+%changelog
diff --git a/packaging/qemu-rpmlintrc b/packaging/qemu-rpmlintrc
new file mode 100644 (file)
index 0000000..66f5a92
--- /dev/null
@@ -0,0 +1,5 @@
+# This line is mandatory to access the configuration functions
+from Config import *
+
+addFilter("arch-dependent-file-in-usr-share")
+
diff --git a/packaging/qemu.spec b/packaging/qemu.spec
new file mode 100644 (file)
index 0000000..0cccdc5
--- /dev/null
@@ -0,0 +1,1266 @@
+#
+# spec file for package qemu
+#
+# Copyright (c) 2016 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
+# upon. The license for this file, and modifications and additions to the
+# file, is the same license as for the pristine package itself (unless the
+# license for the pristine package is not an Open Source License, in which
+# case the license is the MIT License). An "Open Source License" is a
+# license that conforms to the Open Source Definition (Version 1.9)
+# published by the Open Source Initiative.
+
+# Please submit bugfixes or comments via http://bugs.opensuse.org/
+#
+
+
+%define build_x86_fw_from_source 0
+%define build_slof_from_source 0
+%ifarch %ix86 x86_64
+# choice of building all from source or using provided binary x86 blobs
+%if 0%{?suse_version} >= 1310
+%define build_x86_fw_from_source 1
+%endif
+%endif
+%ifarch ppc64
+%define build_slof_from_source 1
+%endif
+%ifarch ppc64le
+%if 0%{?suse_version} > 1320 ||  0%{?suse_version} == 1315
+%define build_slof_from_source 1
+%endif
+%endif
+%ifarch %ix86 x86_64 ppc ppc64 ppc64le s390x armv7hl aarch64
+%define kvm_available 1
+%else
+%define kvm_available 0
+%endif
+%ifarch %ix86 x86_64 s390x
+%define legacy_qemu_kvm 1
+%else
+%define legacy_qemu_kvm 0
+%endif
+%define noarch_supported 1110
+
+%if 0%{?is_opensuse} == 0
+%ifarch x86_64
+%if 0%{?suse_version} > 1320 || ( 0%{?suse_version} == 1315 && ( 0%{?is_opensuse} == 0 || 0%{?sle_version} > 120100 ) )
+%define with_rbd 1
+%endif
+%endif
+
+%ifarch aarch64
+%if 0%{?suse_version} > 1320 || ( 0%{?is_opensuse} == 0 && 0%{?sle_version} > 120100 )
+%define with_rbd 1
+%endif
+%endif
+%endif
+
+%if 0%{?suse_version} > 1320
+%define with_seccomp 1
+%endif
+
+%ifarch %ix86 x86_64
+%define with_seccomp 1
+%endif
+
+Name:           qemu
+Url:            http://www.qemu.org/
+Summary:        Universal CPU emulator
+License:        BSD-3-Clause and GPL-2.0 and GPL-2.0+ and LGPL-2.1+ and MIT
+Group:          System/Emulators/PC
+Version:        2.7.0
+Release:        0
+Source:         http://wiki.qemu.org/download/qemu-2.7.0.tar.bz2
+Source99:       http://wiki.qemu.org/download/qemu-2.7.0.tar.bz2.sig
+Source1:        80-kvm.rules
+Source2:        qemu-ifup
+Source3:        kvm_stat
+Source4:        qemu-kvm.1.gz
+Source5:        60-kvm.rules
+Source6:        ksm.service
+Source7:        60-kvm.x86.rules
+Source8:        80-qemu-ga.rules
+Source9:        qemu-ga.service
+Source10:       kvm.conf
+
+%if %{build_x86_fw_from_source}
+# SeaBIOS
+# PATCH-FIX-OPENSUSE seabios_128kb.patch brogers@suse.com -- make it fit
+Patch1000:      seabios_128kb.patch
+
+# ipxe
+# (currently no patches)
+%endif
+
+# this is to make lint happy
+Source300:      qemu-rpmlintrc
+Source302:      bridge.conf
+Source400:      update_git.sh
+BuildRoot:      %{_tmppath}/%{name}-%{version}-build
+BuildRequires:  SDL-devel
+%if 0%{?suse_version} >= 1320
+BuildRequires:  SDL2-devel
+%endif
+BuildRequires:  alsa-devel
+%if 0%{?build_x86_fw_from_source}
+BuildRequires:  binutils-devel
+%endif
+BuildRequires:  bluez-devel
+%if 0%{?suse_version} >= 1130
+BuildRequires:  brlapi-devel
+%endif
+BuildRequires:  curl-devel
+BuildRequires:  cyrus-sasl-devel
+%if %{build_x86_fw_from_source}
+BuildRequires:  iasl
+%endif
+BuildRequires:  e2fsprogs-devel
+BuildRequires:  fdupes
+BuildRequires:  gcc-c++
+BuildRequires:  glib2-devel
+%if 0%{?suse_version} >= 1310 && 0%{?suse_version} != 1315
+BuildRequires:  glusterfs-devel
+%endif
+%if 0%{?suse_version} >= 1220
+BuildRequires:  gtk3-devel
+%else
+BuildRequires:  gtk2-devel
+%endif
+BuildRequires:  libaio
+BuildRequires:  libaio-devel
+BuildRequires:  libattr-devel
+BuildRequires:  libbz2-devel
+BuildRequires:  libcacard-devel
+BuildRequires:  libcap-devel
+BuildRequires:  libcap-ng-devel
+BuildRequires:  libdrm-devel
+%if 0%{?suse_version} >= 1320 || ( 0%{?suse_version} == 1315 && 0%{?sle_version} > 120100 )
+BuildRequires:  libepoxy-devel
+%endif
+%if 0%{?suse_version} >= 1310
+# 12.3 and earlier don't ship a compatible libfdt; use the bundled one there
+BuildRequires:  libfdt1-devel
+%endif
+BuildRequires:  libgbm-devel
+BuildRequires:  libgcrypt-devel
+BuildRequires:  libgnutls-devel
+%if 0%{?suse_version} >= 1315
+BuildRequires:  libibverbs-devel
+%endif
+%if 0%{?with_rbd}
+%if 0%{?is_opensuse}
+BuildRequires:  librbd-devel
+%else
+BuildRequires:  ceph-devel
+%endif
+%endif
+%if 0%{?suse_version} > 1320 || ( 0%{?suse_version} == 1315 && 0%{?sle_version} > 120100 )
+BuildRequires:  libiscsi-devel
+%endif
+BuildRequires:  libjpeg-devel
+%if 0%{?suse_version} >= 1310
+BuildRequires:  libnettle-devel
+%endif
+%ifarch %ix86 aarch64
+%if 0%{?suse_version} > 1320
+BuildRequires:  libnuma-devel
+%endif
+%else
+%ifnarch %arm s390x
+BuildRequires:  libnuma-devel
+%endif
+%endif
+BuildRequires:  libpcap-devel
+BuildRequires:  libpixman-1-0-devel
+BuildRequires:  libpng-devel
+BuildRequires:  libpulse-devel
+%if 0%{?suse_version} >= 1315
+BuildRequires:  librdmacm-devel
+%endif
+%if 0%{?with_seccomp}
+BuildRequires:  libseccomp-devel
+%endif
+%if 0%{?suse_version} > 1140
+BuildRequires:  libssh2-devel
+%endif
+%if 0%{?suse_version} > 1310
+BuildRequires:  libusb-1_0-devel
+%endif
+BuildRequires:  libvdeplug3-devel
+BuildRequires:  lzo-devel
+%if 0%{?suse_version} > 1220
+BuildRequires:  makeinfo
+%endif
+BuildRequires:  Mesa-devel
+BuildRequires:  mozilla-nss-devel
+BuildRequires:  ncurses-devel
+%if 0%{?build_x86_fw_from_source}
+BuildRequires:  ovmf-tools
+%endif
+BuildRequires:  pkgconfig
+BuildRequires:  pwdutils
+BuildRequires:  python
+%if 0%{?suse_version} >= 1310
+BuildRequires:  snappy-devel
+%endif
+%if 0%{?suse_version} >= 1210
+BuildRequires:  systemd
+%{?systemd_requires}
+%define with_systemd 1
+%endif
+%if %{kvm_available}
+BuildRequires:  pkgconfig(udev)
+%if 0%( pkg-config --exists 'udev > 190' && echo '1' ) == 01
+%define _udevrulesdir /usr/lib/udev/rules.d
+%else
+%define _udevrulesdir /lib/udev/rules.d
+%endif
+%endif
+%if 0%{?sles_version} != 11
+BuildRequires:  usbredir-devel
+%endif
+%if 0%{?suse_version} >= 1320 || ( 0%{?suse_version} == 1315 && 0%{?sle_version} > 120100 )
+BuildRequires:  virglrenderer-devel >= 0.4.1
+%endif
+%if 0%{?suse_version} >= 1210
+%if 0%{?suse_version} >= 1220
+BuildRequires:  vte-devel
+%else
+BuildRequires:  vte2-devel
+%endif
+%endif
+%ifarch x86_64
+BuildRequires:  xen-devel
+%endif
+BuildRequires:  xfsprogs-devel
+%if %{build_x86_fw_from_source}
+BuildRequires:  xz-devel
+%endif
+BuildRequires:  zlib-devel
+%if 0%{?suse_version} >= 1140
+%ifarch %ix86 x86_64
+BuildRequires:  libspice-server-devel
+BuildRequires:  spice-protocol-devel
+%endif
+%endif
+%if "%{name}" == "qemu-testsuite"
+BuildRequires:  bc
+BuildRequires:  qemu-arm   = %version
+BuildRequires:  qemu-extra = %version
+BuildRequires:  qemu-guest-agent = %version
+BuildRequires:  qemu-ppc   = %version
+BuildRequires:  qemu-s390  = %version
+BuildRequires:  qemu-tools = %version
+BuildRequires:  qemu-x86   = %version
+%endif
+Requires:       /usr/sbin/groupadd
+Requires:       pwdutils
+Requires:       timezone
+%if %{kvm_available}
+Requires(post): udev
+%ifarch s390x
+Requires(post): procps
+%endif
+%endif
+Recommends:     qemu-block-curl
+Recommends:     qemu-tools
+Recommends:     qemu-x86
+%ifarch ppc ppc64 ppc64le
+Recommends:     qemu-ppc
+%else
+Suggests:       qemu-ppc
+%endif
+%ifarch s390x
+Recommends:     qemu-s390
+%else
+Suggests:       qemu-s390
+%endif
+%ifarch %arm aarch64
+Recommends:     qemu-arm
+%else
+Suggests:       qemu-arm
+%endif
+Suggests:       qemu-block-dmg
+%if 0%{?suse_version} >= 1310 && 0%{?suse_version} != 1315
+Suggests:       qemu-block-gluster
+%endif
+%if 0%{?suse_version} > 1320 || ( 0%{?suse_version} == 1315 && 0%{?sle_version} > 120100 )
+Suggests:       qemu-block-iscsi
+%endif
+%if 0%{?with_rbd}
+Suggests:       qemu-block-rbd
+%endif
+%if 0%{?suse_version} > 1140
+Suggests:       qemu-block-ssh
+%endif
+Suggests:       qemu-extra
+Suggests:       qemu-lang
+%if 0%{?with_systemd}
+Recommends:     qemu-ksm = %{version}
+%endif
+
+%ifarch x86_64
+%define x86_64_only_b_f_f {efi-e1000.rom efi-e1000e.rom efi-eepro100.rom \
+efi-pcnet.rom efi-ne2k_pci.rom efi-rtl8139.rom efi-virtio.rom efi-vmxnet3.rom}
+%endif
+%define built_firmware_files {bios.bin bios-256k.bin sgabios.bin vgabios.bin \
+vgabios-cirrus.bin vgabios-stdvga.bin vgabios-virtio.bin vgabios-vmware.bin \
+vgabios-qxl.bin optionrom/linuxboot.bin optionrom/multiboot.bin \
+optionrom/kvmvapic.bin pxe-e1000.rom pxe-pcnet.rom pxe-ne2k_pci.rom \
+pxe-rtl8139.rom pxe-eepro100.rom pxe-virtio.rom %{?x86_64_only_b_f_f}}
+
+%description
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+%if "%{name}" != "qemu-testsuite"
+
+%package x86
+Summary:        Universal CPU emulator -- x86
+Group:          System/Emulators/PC
+Requires:       qemu = %version
+Requires:       qemu-ipxe
+Requires:       qemu-seabios
+Requires:       qemu-sgabios
+Requires:       qemu-vgabios
+
+%description x86
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+This sub-package provides i386 and x86_64 emulation.
+
+%package ppc
+Summary:        Universal CPU emulator -- Power Architecture
+Group:          System/Emulators/PC
+Requires:       qemu = %version
+
+%description ppc
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+This sub-package provides ppc and ppc64 emulation.
+
+%package s390
+Summary:        Universal CPU emulator -- S/390
+Group:          System/Emulators/PC
+Requires:       qemu = %version
+
+%description s390
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+This sub-package provides s390x emulation.
+
+%package arm
+Summary:        Universal CPU emulator -- ARM
+Group:          System/Emulators/PC
+Requires:       qemu = %version
+
+%description arm
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+This sub-package provides arm emulation.
+
+%package extra
+Summary:        Universal CPU emulator -- extra architectures
+Group:          System/Emulators/PC
+Requires:       qemu = %version
+
+%description extra
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+This sub-package provides some lesser used emulations, such as moxie and xtensa.
+
+%if %{legacy_qemu_kvm}
+%package kvm
+Url:            http://www.linux-kvm.org
+Summary:        Kernel-based Virtual Machine
+Group:          System/Emulators/PC
+%ifarch %ix86 x86_64
+Requires:       qemu-x86 = %version
+%endif
+%ifarch s390x
+Requires:       qemu-s390 = %version
+%endif
+Provides:       kvm = %version
+Obsoletes:      kvm < %version
+Recommends:     python-curses
+
+%description kvm
+KVM (Kernel-based Virtual Machine) is virtualization software for Linux.
+It is designed to leverage the hardware virtualization features included
+with various architectures. QEMU uses KVM for CPU virtualization, while
+still providing emulation of other system components. This package is
+not required for KVM usage, but rather facilitates its usage with tools
+derived from the legacy kvm package.
+%endif
+
+%package lang
+Summary:        Universal CPU emulator -- Translations
+Group:          System/Emulators/PC
+
+%description lang
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+This sub-package contains translations.
+
+# Modules need to match {qemu-system-*,qemu-img} version.
+# We cannot have qemu and qemu-tools require them in the right version,
+# as that would drag in the dependencies the modules are supposed to avoid.
+# Nor can we have modules require the right version of qemu and qemu-tools
+# as Xen reuses our qemu-tools but does not want our qemu and qemu-x86.
+%define qemu_module_conflicts \
+Conflicts:      qemu < %version-%release \
+Conflicts:      qemu > %version-%release \
+Conflicts:      qemu-tools < %version-%release \
+Conflicts:      qemu-tools > %version-%release
+
+%package block-curl
+Summary:        Universal CPU emulator -- cURL block support
+Group:          System/Emulators/PC
+Provides:       qemu:%_libdir/%name/block-curl.so
+%{qemu_module_conflicts}
+
+%description block-curl
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+This sub-package contains a module for accessing network-based image files
+over a network connection from qemu-img tool and QEMU system emulation.
+
+%package block-dmg
+Summary:        Universal CPU emulator -- DMG block support
+Group:          System/Emulators/PC
+%{qemu_module_conflicts}
+
+%description block-dmg
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+This sub-package contains a module for accessing Mac OS X image files
+from qemu-img tool and QEMU system emulation.
+
+%if 0%{?suse_version} >= 1310 && 0%{?suse_version} != 1315
+%package block-gluster
+Summary:        Universal CPU emulator -- GlusterFS block support
+Group:          System/Emulators/PC
+%{qemu_module_conflicts}
+
+%description block-gluster
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+This sub-package contains a module for accessing network-based image files
+over a GlusterFS network connection from qemu-img tool and QEMU system emulation.
+%endif
+
+%if 0%{?suse_version} > 1320 || ( 0%{?suse_version} == 1315 && 0%{?sle_version} > 120100 )
+%package block-iscsi
+Summary:        Universal CPU emulator -- iSCSI block support
+Group:          System/Emulators/PC
+%{qemu_module_conflicts}
+
+%description block-iscsi
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+This sub-package contains a module for accessing network-based image files
+over an iSCSI network connection from qemu-img tool and QEMU system emulation.
+%endif
+
+%if 0%{?with_rbd}
+%package block-rbd
+Summary:        Universal CPU emulator -- Ceph (rbd) block support
+Group:          System/Emulators/PC
+%{qemu_module_conflicts}
+
+%description block-rbd
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+This sub-package contains a module for accessing ceph (rbd,rados)
+image files.
+%endif
+
+%if 0%{?suse_version} > 1140
+%package block-ssh
+Summary:        Universal CPU emulator -- SSH block support
+Group:          System/Emulators/PC
+%{qemu_module_conflicts}
+
+%description block-ssh
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+This sub-package contains a module for accessing network-based image files
+over an SSH network connection from qemu-img tool and QEMU system emulation.
+%endif
+
+%package tools
+Summary:        Universal CPU emulator -- Tools
+Group:          System/Emulators/PC
+Provides:       qemu:%_libexecdir/qemu-bridge-helper
+PreReq:         permissions
+Recommends:     qemu-block-curl
+%if 0%{?with_rbd}
+Recommends:     qemu-block-rbd
+%endif
+
+%description tools
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+This sub-package contains various tools, including a bridge helper.
+
+%package guest-agent
+Summary:        Universal CPU emulator -- Guest agent
+Group:          System/Emulators/PC
+Provides:       qemu:%_bindir/qemu-ga
+Requires(post): udev
+%if 0%{?with_systemd}
+%{?systemd_requires}
+%endif
+
+%description guest-agent
+QEMU is an extremely well-performing CPU emulator that allows you to
+choose between simulating an entire system and running userspace
+binaries for different architectures under your native operating
+system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well
+as PC and PowerMac systems.
+
+This sub-package contains the guest agent.
+
+%ifarch %ix86 x86_64
+%package seabios
+Summary:        X86 BIOS for QEMU
+Group:          System/Emulators/PC
+Version:        1.9.3
+Release:        0
+%if 0%{?suse_version} > %{noarch_supported}
+BuildArch:      noarch
+%endif
+Conflicts:      qemu < 1.6.0
+
+%description seabios
+SeaBIOS is an open source implementation of a 16bit x86 BIOS. SeaBIOS
+is the default BIOS for QEMU.
+
+%package vgabios
+Summary:        VGA BIOSes for QEMU
+Group:          System/Emulators/PC
+Version:        1.9.3
+Release:        0
+%if 0%{?suse_version} > %{noarch_supported}
+BuildArch:      noarch
+%endif
+Conflicts:      qemu < 1.6.0
+
+%description vgabios
+VGABIOS provides the video ROM BIOSes for the following variants of VGA
+emulated devices: Std VGA, QXL, Cirrus CLGD 5446 and VMware emulated
+video card.
+
+%package sgabios
+Summary:        Serial Graphics Adapter BIOS for QEMU
+Group:          System/Emulators/PC
+Version:        8
+Release:        0
+%if 0%{?suse_version} > %{noarch_supported}
+BuildArch:      noarch
+%endif
+Conflicts:      qemu < 1.6.0
+
+%description sgabios
+The Google Serial Graphics Adapter BIOS or SGABIOS provides a means for legacy
+x86 software to communicate with an attached serial console as if a video card
+were attached.
+
+%package ipxe
+Summary:        PXE ROMs for QEMU NICs
+Group:          System/Emulators/PC
+Version:        1.0.0
+Release:        0
+%if 0%{?suse_version} > %{noarch_supported}
+BuildArch:      noarch
+%endif
+Conflicts:      qemu < 1.6.0
+
+%description ipxe
+Preboot Execution Environment (PXE) ROM support for various emulated network
+adapters available with QEMU.
+%endif
+
+%if 0%{?with_systemd}
+%package ksm
+Summary:        Kernel Samepage Merging services
+Group:          System/Emulators/PC
+
+%description ksm
+Kernel Samepage Merging (KSM) is a memory-saving de-duplication feature,
+that merges anonymous (private) pages (not pagecache ones).
+
+This package provides a service file for starting and stopping KSM.
+%endif
+
+%endif # !qemu-testsuite
+
+%prep
+%setup -q -n qemu-2.7.0
+
+%if %{build_x86_fw_from_source}
+pushd roms/seabios
+%patch1000 -p1
+popd
+pushd roms/ipxe
+# (currently no patches)
+popd
+
+
+# as a safeguard, delete the firmware files that we intend to build
+for i in %built_firmware_files
+do
+  rm -f pc-bios/$i
+done
+%endif
+
+%if %{build_slof_from_source}
+rm -f pc-bios/slof.bin
+%endif
+
+%build
+./configure \
+       --prefix=%_prefix \
+       --sysconfdir=%_sysconfdir \
+       --libdir=%_libdir \
+       --libexecdir=%_libexecdir \
+       --localstatedir=%_localstatedir \
+       --extra-cflags="%{optflags}" \
+       --disable-stack-protector \
+       --disable-strip \
+       --with-pkgversion="%(echo '%{distribution}' | sed 's/ (.*)//')" \
+       --enable-system --disable-linux-user \
+       --enable-tools --enable-guest-agent \
+       --enable-modules \
+       --enable-pie \
+       --enable-docs \
+       --audio-drv-list="pa alsa sdl oss" \
+       --disable-archipelago \
+       --enable-attr \
+       --enable-bluez \
+%if 0%{?suse_version} >= 1130
+       --enable-brlapi \
+%else
+       --disable-brlapi \
+%endif
+       --enable-bzip2 \
+       --enable-cap-ng \
+       --enable-coroutine-pool \
+       --enable-curl \
+       --enable-curses \
+       --enable-fdt \
+%if 0
+# Let it auto-detect these based on gnutls - uses libnettle in Tumbleweed but unavailable in SLE11
+       --enable-gcrypt \
+       --disable-nettle \
+%endif
+%if 0%{?suse_version} >= 1310 && 0%{?suse_version} != 1315
+       --enable-glusterfs \
+%else
+       --disable-glusterfs \
+%endif
+       --enable-gnutls \
+       --enable-gtk \
+%if 0%{?suse_version} >= 1220
+       --with-gtkabi=3.0 \
+%else
+       --with-gtkabi=2.0 \
+%endif
+%if %{kvm_available}
+       --enable-kvm \
+%else
+       --disable-kvm \
+%endif
+%if 0%{?suse_version} > 1320 || ( 0%{?suse_version} == 1315 && 0%{?sle_version} > 120100 )
+       --enable-libiscsi \
+%else
+       --disable-libiscsi \
+%endif
+       --disable-libnfs \
+%if 0%{?suse_version} > 1140
+       --enable-libssh2 \
+%else
+       --disable-libssh2 \
+%endif
+%if 0%{?suse_version} > 1310
+       --enable-libusb \
+%else
+       --disable-libusb \
+%endif
+       --enable-linux-aio \
+       --enable-lzo \
+       --disable-netmap \
+%ifarch %ix86 aarch64
+%if 0%{?suse_version} > 1320
+       --enable-numa \
+%else
+       --disable-numa \
+%endif
+%else
+%ifarch %arm s390x
+       --disable-numa \
+%else
+       --enable-numa \
+%endif
+%endif
+%if 0%{?suse_version} >= 1320 || ( 0%{?suse_version} == 1315 && 0%{?sle_version} > 120100 )
+       --enable-opengl \
+%endif
+%if 0%{?with_rbd}
+       --enable-rbd \
+%else
+       --disable-rbd \
+%endif
+%if 0%{?suse_version} >= 1315
+       --enable-rdma \
+%else
+       --disable-rdma \
+%endif
+       --enable-sdl \
+%if 0%{?suse_version} >= 1320
+       --with-sdlabi=2.0 \
+%else
+       --with-sdlabi=1.2 \
+%endif
+%if 0%{?with_seccomp}
+       --enable-seccomp \
+%else
+       --disable-seccomp \
+%endif
+       --enable-smartcard \
+%if 0%{?suse_version} >= 1310
+       --enable-snappy \
+%else
+       --disable-snappy \
+%endif
+%if 0%{?suse_version} >= 1140
+%ifarch %ix86 x86_64
+       --enable-spice \
+%else
+       --disable-spice \
+%endif
+%else
+       --disable-spice \
+%endif
+       --enable-tpm \
+%if 0%{?sles_version} != 11
+       --enable-usb-redir \
+%else
+       --disable-usb-redir \
+%endif
+       --enable-uuid \
+       --enable-vde \
+       --enable-vhdx \
+       --enable-vhost-net \
+%if 0%{?suse_version} >= 1320 || ( 0%{?suse_version} == 1315 && 0%{?sle_version} > 120100 )
+       --enable-virglrenderer \
+%endif
+       --enable-virtfs \
+       --enable-vnc \
+       --enable-vnc-jpeg \
+       --enable-vnc-png \
+       --enable-vnc-sasl \
+%if 0%{?suse_version} == 1320
+       --disable-vte \
+%else
+       --enable-vte \
+%endif
+%ifarch x86_64
+       --enable-xen \
+       --enable-xen-pci-passthrough \
+       --enable-xen-pv-domain-build \
+%else
+       --disable-xen \
+%endif
+       --enable-xfsctl \
+
+
+%if "%{name}" != "qemu-testsuite"
+
+make %{?_smp_mflags} V=1
+
+# Firmware
+%if %{build_x86_fw_from_source}
+make %{?_smp_mflags} -C roms bios
+make %{?_smp_mflags} -C roms seavgabios
+make %{?_smp_mflags} -C roms pxerom
+%ifarch x86_64
+make %{?_smp_mflags} -C roms efirom
+%endif
+make                 -C roms sgabios
+%endif
+%if %{build_slof_from_source}
+make %{?_smp_mflags} -C roms slof
+%endif
+%ifarch s390x
+cp pc-bios/s390-ccw/s390-ccw.img pc-bios/s390-ccw.img
+%endif
+
+%else # qemu-testsuite
+
+ln -s %{_bindir}/qemu-img qemu-img
+ln -s %{_bindir}/qemu-ga qemu-ga
+
+%if %{build_x86_fw_from_source}
+for i in %built_firmware_files
+do
+  ln -s %{_datadir}/qemu/$i pc-bios/$i
+done
+%endif
+
+for conf in default-configs/*-softmmu.mak; do
+  arch=`echo "$conf" | sed -e 's|default-configs/\(.*\)-softmmu.mak|\1|g'`
+  ln -s %{_bindir}/qemu-system-$arch $arch-softmmu/qemu-system-$arch
+done
+
+# Compile the QOM test binary first, so that ...
+make tests/qom-test %{?_smp_mflags} V=1
+# ... make comes in fresh and has lots of address space (needed for 32bit, bsc#957379)
+%if 0%{?suse_version} >= 1310
+make check-report.html V=1
+install -D -m 644 check-report.html %{buildroot}%{_datadir}/qemu/check-report.html
+%else
+make check-report.xml V=1
+%endif
+
+%endif
+
+%check
+%if "%{name}" == "qemu-testsuite"
+
+%ifnarch %ix86 x64_64
+export QEMU_PROG=%{_bindir}/qemu-system-x86_64
+%endif
+export QEMU_IMG_PROG=%{_bindir}/qemu-img
+export QEMU_IO_PROG=%{_bindir}/qemu-io
+export QEMU_NBD_PROG=%{_bindir}/qemu-nbd
+# make check-block would rebuild qemu-img and qemu-io
+make tests/qemu-iotests/socket_scm_helper V=1
+pushd tests/qemu-iotests
+# -qcow 001 seems to hang?
+# TODO investigate hangs and failures
+#for fmt in -raw -bochs -cloop -parallels -qcow2 -qed -vdi -vpc -vhdx -vmdk; do
+#  ./check -v -T $fmt -file -g quick || true
+#done
+popd
+
+# Create minimal gzip format file
+echo "Test" > test.txt
+cat test.txt | gzip - > test.gz
+# Check qemu-img info output (bsc#945778)
+format=`qemu-img info test.gz | grep "file format:" | cut -d ':' -f 2 | tr -d '[:space:]'`
+[ "$format" == "raw" ] || false
+
+# Create minimal tar format file
+tar cf test.tar test.txt
+# Check qemu-img info output (bsc#945778)
+format=`qemu-img info test.tar | grep "file format:" | cut -d ':' -f 2 | tr -d '[:space:]'`
+[ "$format" == "raw" ] || false
+
+%endif # qemu-testsuite
+
+%install
+%if "%{name}" != "qemu-testsuite"
+
+make install DESTDIR=$RPM_BUILD_ROOT
+rm -fr $RPM_BUILD_ROOT/%_datadir/doc
+%if ! %{build_x86_fw_from_source}
+for f in acpi-dsdt.aml bios-256k.bin bios.bin efi-*.rom pxe-*.rom sgabios.bin \
+         vgabios-cirrus.bin vgabios-qxl.bin vgabios-stdvga.bin vgabios-virtio.bin vgabios-vmware.bin \
+         vgabios.bin; do
+  rm $RPM_BUILD_ROOT/%_datadir/%name/$f
+done
+%endif
+# rm -f %{buildroot}%{_datadir}/%{name}/u-boot.e500
+install -D -m 644 %{SOURCE302} $RPM_BUILD_ROOT/%{_sysconfdir}/qemu/bridge.conf
+%find_lang %name
+%if %{legacy_qemu_kvm}
+cat > %{buildroot}%{_bindir}/qemu-kvm << 'EOF'
+#!/bin/sh
+
+%ifarch s390x
+exec %{_bindir}/qemu-system-s390x -machine accel=kvm "$@"
+%else
+exec %{_bindir}/qemu-system-x86_64 -machine accel=kvm "$@"
+%endif
+EOF
+chmod 755 %{buildroot}%{_bindir}/qemu-kvm
+%ifarch s390x
+mkdir -p %{buildroot}%{_sysconfdir}/sysctl.d
+cat >  %{buildroot}%{_sysconfdir}/sysctl.d/50-allow-kvm-on-s390x <<- 'EOF'
+       # To allow KVM to run on s390x, we need to set the sysctl below
+       vm.allocate_pgste = 1
+EOF
+chmod 644 %{buildroot}%{_sysconfdir}/sysctl.d/50-allow-kvm-on-s390x
+%endif
+install -D -m 755 %{SOURCE2} %{buildroot}/usr/share/qemu/qemu-ifup
+install -D -m 755 %{SOURCE3} %{buildroot}%{_bindir}/kvm_stat
+install -D -m 644 %{SOURCE4} %{buildroot}%{_mandir}/man1/qemu-kvm.1.gz
+%endif
+%if %{kvm_available}
+%if 0%{?suse_version} >= 1230
+install -D -m 644 %{SOURCE1} %{buildroot}%{_udevrulesdir}/80-kvm.rules
+%else
+%ifarch %ix86 x86_64
+install -D -m 644 %{SOURCE7} %{buildroot}%{_udevrulesdir}/60-kvm.rules
+%else
+install -D -m 644 %{SOURCE5} %{buildroot}%{_udevrulesdir}/60-kvm.rules
+%endif
+%endif
+%endif
+install -D -p -m 0644 %{SOURCE8} %{buildroot}%{_udevrulesdir}/80-qemu-ga.rules
+%if 0%{?with_systemd}
+install -D -p -m 0644 %{SOURCE6} %{buildroot}%{_unitdir}/ksm.service
+install -D -p -m 0644 %{SOURCE9} %{buildroot}%{_unitdir}/qemu-ga.service
+%ifarch s390x
+install -D -m 0644 %{SOURCE10} %{buildroot}%{_libexecdir}/modules-load.d/kvm.conf
+%endif
+%endif
+%fdupes -s $RPM_BUILD_ROOT
+
+%else # qemu-testsuite
+
+%if 0%{?suse_version} >= 1310
+install -D -m 644 check-report.html %{buildroot}%{_datadir}/qemu/check-report.html
+%endif
+install -D -m 644 check-report.xml %{buildroot}%{_datadir}/qemu/check-report.xml
+
+%endif
+
+%if "%{name}" != "qemu-testsuite"
+
+%pre
+%{_bindir}/getent group kvm >/dev/null || %{_sbindir}/groupadd -r kvm 2>/dev/null
+%{_bindir}/getent group qemu >/dev/null || %{_sbindir}/groupadd -r qemu 2>/dev/null
+%{_bindir}/getent passwd qemu >/dev/null || \
+  %{_sbindir}/useradd -r -g qemu -G kvm -d / -s /sbin/nologin \
+  -c "qemu user" qemu
+
+
+%if %{kvm_available}
+%post
+# Do not execute operations affecting host devices while running in a chroot
+if [ $(stat -L -c "%i" /proc/1/root/) = $(stat -L -c "%i" /) ]; then
+  setfacl --remove-all /dev/kvm &> /dev/null || :
+%if 0%{?with_systemd}
+  %udev_rules_update
+  %_bindir/udevadm trigger || :
+%else
+  /sbin/udevadm control --reload-rules  || :
+  /sbin/udevadm trigger || :
+%endif
+%ifarch s390x
+  sysctl vm.allocate_pgste=1 || :
+%endif
+fi
+%endif
+
+%if 0%{?suse_version} >= 1130
+%post tools
+%set_permissions %_libexecdir/qemu-bridge-helper
+
+%verifyscript tools
+%verify_permissions %_libexecdir/qemu-bridge-helper
+%endif
+
+%pre guest-agent
+%{_bindir}/getent group kvm >/dev/null || %{_sbindir}/groupadd -r kvm 2>/dev/null
+%if 0%{?with_systemd}
+%service_add_pre qemu-ga.service
+
+%preun guest-agent
+%service_del_preun qemu-ga.service
+
+%post guest-agent
+if [ "$(readlink -f /proc/1/root)" = "/" ]; then
+  /sbin/udevadm control --reload-rules  || :
+  /sbin/udevadm trigger || :
+fi
+%service_add_post qemu-ga.service
+
+%postun guest-agent
+%service_del_postun qemu-ga.service
+
+%pre ksm
+%service_add_pre ksm.service
+
+%post ksm
+%service_add_post ksm.service
+
+%preun ksm
+%service_del_preun ksm.service
+
+%postun ksm
+%service_del_postun ksm.service
+%endif
+
+%endif # !qemu-testsuite
+
+%files
+%defattr(-, root, root)
+%if "%{name}" != "qemu-testsuite"
+%doc COPYING COPYING.LIB Changelog README VERSION qemu-doc.html qemu-tech.html
+%doc %_mandir/man1/qemu.1.gz
+%dir %_datadir/%name
+%_datadir/%name/keymaps
+%_datadir/%name/trace-events-all
+%_datadir/%name/qemu-icon.bmp
+%_datadir/%name/qemu_logo_no_text.svg
+%dir %_sysconfdir/%name
+%dir %_libdir/%name
+%if %{kvm_available}
+%if 0%{?suse_version} >= 1230
+%{_udevrulesdir}/80-kvm.rules
+%else
+%{_udevrulesdir}/60-kvm.rules
+%endif
+%ifarch s390x
+%{_sysconfdir}/sysctl.d/50-allow-kvm-on-s390x
+%if 0%{?with_systemd}
+%_libexecdir/modules-load.d/kvm.conf
+%endif
+%endif
+%endif
+
+%files x86
+%defattr(-, root, root)
+%_bindir/qemu-system-i386
+%_bindir/qemu-system-x86_64
+%_datadir/%name/kvmvapic.bin
+%_datadir/%name/linuxboot.bin
+%_datadir/%name/linuxboot_dma.bin
+%_datadir/%name/multiboot.bin
+
+%files ppc
+%defattr(-, root, root)
+%_bindir/qemu-system-ppc
+%_bindir/qemu-system-ppc64
+%_bindir/qemu-system-ppcemb
+%_datadir/%name/ppc_rom.bin
+%_datadir/%name/openbios-ppc
+%_datadir/%name/slof.bin
+%_datadir/%name/spapr-rtas.bin
+%_datadir/%name/u-boot.e500
+%_datadir/%name/bamboo.dtb
+%_datadir/%name/petalogix-ml605.dtb
+
+%files s390
+%defattr(-, root, root)
+%_bindir/qemu-system-s390x
+%_datadir/%name/s390-ccw.img
+
+%files arm
+%defattr(-, root, root)
+%_bindir/qemu-system-arm
+%_bindir/qemu-system-aarch64
+
+%files extra
+%defattr(-, root, root)
+%_bindir/qemu-system-alpha
+%_bindir/qemu-system-cris
+%_bindir/qemu-system-lm32
+%_bindir/qemu-system-m68k
+%_bindir/qemu-system-microblaze
+%_bindir/qemu-system-microblazeel
+%_bindir/qemu-system-mips
+%_bindir/qemu-system-mipsel
+%_bindir/qemu-system-mips64
+%_bindir/qemu-system-mips64el
+%_bindir/qemu-system-moxie
+%_bindir/qemu-system-or32
+%_bindir/qemu-system-sh4
+%_bindir/qemu-system-sh4eb
+%_bindir/qemu-system-sparc
+%_bindir/qemu-system-sparc64
+%_bindir/qemu-system-tricore
+%_bindir/qemu-system-unicore32
+%_bindir/qemu-system-xtensa
+%_bindir/qemu-system-xtensaeb
+%_datadir/%name/palcode-clipper
+%_datadir/%name/openbios-sparc32
+%_datadir/%name/openbios-sparc64
+%_datadir/%name/petalogix-s3adsp1800.dtb
+%_datadir/%name/QEMU,cgthree.bin
+%_datadir/%name/QEMU,tcx.bin
+
+%if %{legacy_qemu_kvm}
+%files kvm
+%defattr(-,root,root)
+%_bindir/qemu-kvm
+%_bindir/kvm_stat
+%_datadir/qemu/qemu-ifup
+%_mandir/man1/qemu-kvm.1.gz
+%endif
+
+%files block-curl
+%defattr(-, root, root)
+%_libdir/%name/block-curl.so
+
+%files block-dmg
+%defattr(-, root, root)
+%_libdir/%name/block-dmg.so
+
+%if 0%{?suse_version} >= 1310 && 0%{?suse_version} != 1315
+%files block-gluster
+%defattr(-, root, root)
+%_libdir/%name/block-gluster.so
+%endif
+
+%if 0%{?suse_version} > 1320 || ( 0%{?suse_version} == 1315 && 0%{?sle_version} > 120100 )
+%files block-iscsi
+%defattr(-, root, root)
+%_libdir/%name/block-iscsi.so
+%endif
+
+%if 0%{?with_rbd}
+%files block-rbd
+%defattr(-, root, root)
+%dir %_libdir/%name
+%_libdir/%name/block-rbd.so
+%endif
+
+%if 0%{?suse_version} > 1140
+%files block-ssh
+%defattr(-, root, root)
+%_libdir/%name/block-ssh.so
+%endif
+
+%files lang -f %name.lang
+%defattr(-, root, root)
+
+%if %{build_x86_fw_from_source}
+%files seabios
+%defattr(-, root, root)
+%_datadir/%name/bios.bin
+%_datadir/%name/bios-256k.bin
+%_datadir/%name/acpi-dsdt.aml
+
+%files vgabios
+%defattr(-, root, root)
+%_datadir/%name/vgabios.bin
+%_datadir/%name/vgabios-cirrus.bin
+%_datadir/%name/vgabios-qxl.bin
+%_datadir/%name/vgabios-stdvga.bin
+%_datadir/%name/vgabios-virtio.bin
+%_datadir/%name/vgabios-vmware.bin
+
+%files sgabios
+%defattr(-, root, root)
+%_datadir/%name/sgabios.bin
+
+%files ipxe
+%defattr(-, root, root)
+%_datadir/%name/pxe-e1000.rom
+%_datadir/%name/pxe-eepro100.rom
+%_datadir/%name/pxe-pcnet.rom
+%_datadir/%name/pxe-ne2k_pci.rom
+%_datadir/%name/pxe-rtl8139.rom
+%_datadir/%name/pxe-virtio.rom
+%_datadir/%name/efi-e1000.rom
+%_datadir/%name/efi-e1000e.rom
+%_datadir/%name/efi-eepro100.rom
+%_datadir/%name/efi-pcnet.rom
+%_datadir/%name/efi-ne2k_pci.rom
+%_datadir/%name/efi-rtl8139.rom
+%_datadir/%name/efi-virtio.rom
+%_datadir/%name/efi-vmxnet3.rom
+%endif
+
+%files tools
+%defattr(-, root, root)
+%doc %_mandir/man1/qemu-img.1.gz
+%doc %_mandir/man1/virtfs-proxy-helper.1.gz
+%doc %_mandir/man8/qemu-nbd.8.gz
+%_bindir/ivshmem-client
+%_bindir/ivshmem-server
+%_bindir/qemu-io
+%_bindir/qemu-img
+%_bindir/qemu-nbd
+%_bindir/virtfs-proxy-helper
+#%_bindir/vscclient
+%verify(not mode) %attr(4750,root,kvm) %_libexecdir/qemu-bridge-helper
+%dir %_sysconfdir/%name
+%config %_sysconfdir/%name/bridge.conf
+%dir %_libdir/%name
+
+%files guest-agent
+%defattr(-, root, root)
+%doc %_mandir/man8/qemu-ga.8.gz
+%attr(755,root,kvm) %_bindir/qemu-ga
+%if 0%{?with_systemd}
+%{_unitdir}/qemu-ga.service
+%endif
+%{_udevrulesdir}/80-qemu-ga.rules
+
+%if 0%{?with_systemd}
+%files ksm
+%defattr(-, root, root)
+%{_unitdir}/ksm.service
+%endif
+
+%else # qemu-testsuite
+%doc %_datadir/qemu/check-report.xml
+%if 0%{?suse_version} >= 1310
+%doc %_datadir/qemu/check-report.html
+%endif
+%endif
+
+%changelog
diff --git a/packaging/seabios_128kb.patch b/packaging/seabios_128kb.patch
new file mode 100644 (file)
index 0000000..a51c32e
--- /dev/null
@@ -0,0 +1,303 @@
+From 5fff5f1e79d8bc7ef24d1f8ff42c8021215f23a6 Mon Sep 17 00:00:00 2001
+From: Bruce Rogers <brogers@suse.com>
+Date: Thu, 19 Mar 2015 16:34:31 -0600
+Subject: [PATCH] Eliminate some duplicate string segments to reduce bios image
+ size
+
+In some build environments, we are running up against the 128K bios
+size limit. This change simply takes larger string segments which are
+used in printf style messages and uses a single copy, now referenced
+with a %s specifier, resulting in the needed space savings.
+
+Signed-off-by: Bruce Rogers <brogers@suse.com>
+---
+ src/boot.c        | 20 +++++++++++---------
+ src/bootsplash.c  |  5 +++--
+ src/fw/paravirt.c |  8 +++++---
+ src/fw/pciinit.c  | 19 ++++++++++---------
+ src/hw/usb-hub.c  |  9 +++++----
+ src/hw/usb-msc.c  |  6 ++++--
+ 6 files changed, 38 insertions(+), 29 deletions(-)
+
+diff --git a/src/boot.c b/src/boot.c
+index d6b1fb7..de37041 100644
+--- a/src/boot.c
++++ b/src/boot.c
+@@ -25,6 +25,8 @@
+  * Boot priority ordering
+  ****************************************************************/
++static const char *no_boot_dev_str = "No bootable device.";
++static const char *boot_str = "Booting from ";
+ static char **Bootorder VARVERIFY32INIT;
+ static int BootorderCount;
+@@ -587,7 +589,7 @@ bcv_prepboot(void)
+ static void
+ call_boot_entry(struct segoff_s bootsegip, u8 bootdrv)
+ {
+-    dprintf(1, "Booting from %04x:%04x\n", bootsegip.seg, bootsegip.offset);
++    dprintf(1, "%s%04x:%04x\n", boot_str, bootsegip.seg, bootsegip.offset);
+     struct bregs br;
+     memset(&br, 0, sizeof(br));
+     br.flags = F_IF;
+@@ -641,7 +643,7 @@ boot_cdrom(struct drive_s *drive_g)
+ {
+     if (! CONFIG_CDROM_BOOT)
+         return;
+-    printf("Booting from DVD/CD...\n");
++    printf("%sDVD/CD...\n", boot_str);
+     int status = cdrom_boot(drive_g);
+     if (status) {
+@@ -664,7 +666,7 @@ boot_cbfs(struct cbfs_file *file)
+ {
+     if (!CONFIG_COREBOOT_FLASH)
+         return;
+-    printf("Booting from CBFS...\n");
++    printf("%sCBFS...\n", boot_str);
+     cbfs_run_payload(file);
+ }
+@@ -672,7 +674,7 @@ boot_cbfs(struct cbfs_file *file)
+ static void
+ boot_rom(u32 vector)
+ {
+-    printf("Booting from ROM...\n");
++    printf("%sROM...\n", boot_str);
+     struct segoff_s so;
+     so.segoff = vector;
+     call_boot_entry(so, 0);
+@@ -683,10 +685,10 @@ static void
+ boot_fail(void)
+ {
+     if (BootRetryTime == (u32)-1)
+-        printf("No bootable device.\n");
++        printf("%s\n", no_boot_dev_str);
+     else
+-        printf("No bootable device.  Retrying in %d seconds.\n"
+-               , BootRetryTime/1000);
++        printf("%s  Retrying in %d seconds.\n", no_boot_dev_str,
++               BootRetryTime/1000);
+     // Wait for 'BootRetryTime' milliseconds and then reboot.
+     u32 end = irqtimer_calc(BootRetryTime);
+     for (;;) {
+@@ -712,11 +714,11 @@ do_boot(int seq_nr)
+     struct bev_s *ie = &BEV[seq_nr];
+     switch (ie->type) {
+     case IPL_TYPE_FLOPPY:
+-        printf("Booting from Floppy...\n");
++        printf("%sFloppy...\n", boot_str);
+         boot_disk(0x00, CheckFloppySig);
+         break;
+     case IPL_TYPE_HARDDISK:
+-        printf("Booting from Hard Disk...\n");
++        printf("%sHard Disk...\n", boot_str);
+         boot_disk(0x80, 1);
+         break;
+     case IPL_TYPE_CDROM:
+diff --git a/src/bootsplash.c b/src/bootsplash.c
+index c572685..e28d264 100644
+--- a/src/bootsplash.c
++++ b/src/bootsplash.c
+@@ -16,6 +16,7 @@
+ #include "string.h" // memset
+ #include "util.h" // enable_bootsplash
++static const char *decode_failed_str = "_decode failed with return code ";
+ /****************************************************************
+  * Helper functions
+@@ -154,7 +155,7 @@ enable_bootsplash(void)
+         dprintf(5, "Decoding bootsplash.jpg\n");
+         ret = jpeg_decode(jpeg, filedata);
+         if (ret) {
+-            dprintf(1, "jpeg_decode failed with return code %d...\n", ret);
++            dprintf(1, "jpeg%s%d...\n", decode_failed_str, ret);
+             goto done;
+         }
+         jpeg_get_size(jpeg, &width, &height);
+@@ -168,7 +169,7 @@ enable_bootsplash(void)
+         dprintf(5, "Decoding bootsplash.bmp\n");
+         ret = bmp_decode(bmp, filedata, filesize);
+         if (ret) {
+-            dprintf(1, "bmp_decode failed with return code %d...\n", ret);
++            dprintf(1, "bmp%s%d...\n", decode_failed_str, ret);
+             goto done;
+         }
+         bmp_get_size(bmp, &width, &height);
+diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c
+index db22ae8..868435a 100644
+--- a/src/fw/paravirt.c
++++ b/src/fw/paravirt.c
+@@ -36,6 +36,8 @@ int PlatformRunningOn VARFSEG;
+  */
+ #define KVM_CPUID_SIGNATURE     0x40000000
++static const char *running_on_qemu_str = "Running on QEMU (";
++
+ static void kvm_detect(void)
+ {
+     unsigned int eax, ebx, ecx, edx;
+@@ -73,13 +75,13 @@ static void qemu_detect(void)
+     PlatformRunningOn |= PF_QEMU;
+     switch (d) {
+     case 0x1237:
+-        dprintf(1, "Running on QEMU (i440fx)\n");
++        dprintf(1, "%si440fx)\n", running_on_qemu_str);
+         break;
+     case 0x29c0:
+-        dprintf(1, "Running on QEMU (q35)\n");
++        dprintf(1, "%sq35)\n", running_on_qemu_str);
+         break;
+     default:
+-        dprintf(1, "Running on QEMU (unknown nb: %04x:%04x)\n", v, d);
++        dprintf(1, "%sunknown nb: %04x:%04x)\n", running_on_qemu_str, v, d);
+         break;
+     }
+     kvm_detect();
+diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c
+index ac39d23..63018e4 100644
+--- a/src/fw/pciinit.c
++++ b/src/fw/pciinit.c
+@@ -27,6 +27,10 @@
+ #define PCI_BRIDGE_MEM_MIN    (1<<21)  // 2M == hugepage size
+ #define PCI_BRIDGE_IO_MIN      0x1000  // mandated by pci bridge spec
++static const char *pri_bus_str = "PCI: primary bus = ";
++static const char *sec_bus_str = "PCI: secondary bus = ";
++static const char *sub_bus_str = "PCI: subordinate bus = ";
++
+ static const char *region_type_name[] = {
+     [ PCI_REGION_TYPE_IO ]      = "io",
+     [ PCI_REGION_TYPE_MEM ]     = "mem",
+@@ -425,7 +429,6 @@ static void pci_bios_init_platform(void)
+     }
+ }
+-
+ /****************************************************************
+  * Bus initialization
+  ****************************************************************/
+@@ -456,21 +459,20 @@ pci_bios_init_bus_rec(int bus, u8 *pci_bus)
+         u8 pribus = pci_config_readb(bdf, PCI_PRIMARY_BUS);
+         if (pribus != bus) {
+-            dprintf(1, "PCI: primary bus = 0x%x -> 0x%x\n", pribus, bus);
++            dprintf(1, "%s0x%x -> 0x%x\n", pri_bus_str, pribus, bus);
+             pci_config_writeb(bdf, PCI_PRIMARY_BUS, bus);
+         } else {
+-            dprintf(1, "PCI: primary bus = 0x%x\n", pribus);
++            dprintf(1, "%s0x%x\n", pri_bus_str, pribus);
+         }
+         u8 secbus = pci_config_readb(bdf, PCI_SECONDARY_BUS);
+         (*pci_bus)++;
+         if (*pci_bus != secbus) {
+-            dprintf(1, "PCI: secondary bus = 0x%x -> 0x%x\n",
+-                    secbus, *pci_bus);
++            dprintf(1, "%s0x%x -> 0x%x\n", sec_bus_str, secbus, *pci_bus);
+             secbus = *pci_bus;
+             pci_config_writeb(bdf, PCI_SECONDARY_BUS, secbus);
+         } else {
+-            dprintf(1, "PCI: secondary bus = 0x%x\n", secbus);
++            dprintf(1, "%s0x%x\n", sec_bus_str, secbus);
+         }
+         /* set to max for access to all subordinate buses.
+@@ -481,11 +483,10 @@ pci_bios_init_bus_rec(int bus, u8 *pci_bus)
+         pci_bios_init_bus_rec(secbus, pci_bus);
+         if (subbus != *pci_bus) {
+-            dprintf(1, "PCI: subordinate bus = 0x%x -> 0x%x\n",
+-                    subbus, *pci_bus);
++            dprintf(1, "%s0x%x -> 0x%x\n", sub_bus_str, subbus, *pci_bus);
+             subbus = *pci_bus;
+         } else {
+-            dprintf(1, "PCI: subordinate bus = 0x%x\n", subbus);
++            dprintf(1, "%s0x%x\n", sub_bus_str, subbus);
+         }
+         pci_config_writeb(bdf, PCI_SUBORDINATE_BUS, subbus);
+     }
+diff --git a/src/hw/usb-hub.c b/src/hw/usb-hub.c
+index 54e341b..337385d 100644
+--- a/src/hw/usb-hub.c
++++ b/src/hw/usb-hub.c
+@@ -11,6 +11,8 @@
+ #include "usb-hub.h" // struct usb_hub_descriptor
+ #include "util.h" // timer_calc
++static const char *port_hub_fail_str = "Failure on hub port ";
++
+ static int
+ get_hub_desc(struct usb_pipe *pipe, struct usb_hub_descriptor *desc)
+ {
+@@ -82,7 +84,6 @@ get_port_status(struct usbhub_s *hub, int port, struct usb_port_status *sts)
+     mutex_unlock(&hub->lock);
+     return ret;
+ }
+-
+ // Check if device attached to port
+ static int
+ usb_hub_detect(struct usbhub_s *hub, u32 port)
+@@ -90,7 +91,7 @@ usb_hub_detect(struct usbhub_s *hub, u32 port)
+     struct usb_port_status sts;
+     int ret = get_port_status(hub, port, &sts);
+     if (ret) {
+-        dprintf(1, "Failure on hub port %d detect\n", port);
++        dprintf(1, "%s%d detect\n", port_hub_fail_str, port);
+         return -1;
+     }
+     return (sts.wPortStatus & USB_PORT_STAT_CONNECTION) ? 1 : 0;
+@@ -102,7 +103,7 @@ usb_hub_disconnect(struct usbhub_s *hub, u32 port)
+ {
+     int ret = clear_port_feature(hub, port, USB_PORT_FEAT_ENABLE);
+     if (ret)
+-        dprintf(1, "Failure on hub port %d disconnect\n", port);
++        dprintf(1, "%s%d disconnect\n", port_hub_fail_str, port);
+ }
+ // Reset device on port
+@@ -142,7 +143,7 @@ usb_hub_reset(struct usbhub_s *hub, u32 port)
+             >> USB_PORT_STAT_SPEED_SHIFT);
+ fail:
+-    dprintf(1, "Failure on hub port %d reset\n", port);
++    dprintf(1, "%s%d reset\n", port_hub_fail_str, port);
+     usb_hub_disconnect(hub, port);
+     return -1;
+ }
+diff --git a/src/hw/usb-msc.c b/src/hw/usb-msc.c
+index d90319f..9c6b3e2 100644
+--- a/src/hw/usb-msc.c
++++ b/src/hw/usb-msc.c
+@@ -50,6 +50,8 @@ struct csw_s {
+     u8 bCSWStatus;
+ } PACKED;
++static const char *cant_config_str = "Unable to configure USB MSC ";
++
+ static int
+ usb_msc_send(struct usbdrive_s *udrive_gf, int dir, void *buf, u32 bytes)
+ {
+@@ -158,7 +160,7 @@ usb_msc_lun_setup(struct usb_pipe *inpipe, struct usb_pipe *outpipe,
+     int prio = bootprio_find_usb(usbdev, lun);
+     int ret = scsi_drive_setup(&drive->drive, "USB MSC", prio);
+     if (ret) {
+-        dprintf(1, "Unable to configure USB MSC drive.\n");
++        dprintf(1, "%sdrive.\n", cant_config_str);
+         free(drive);
+         return -1;
+     }
+@@ -213,7 +215,7 @@ usb_msc_setup(struct usbdevice_s *usbdev)
+     return 0;
+ fail:
+-    dprintf(1, "Unable to configure USB MSC device.\n");
++    dprintf(1, "%sdevice.\n", cant_config_str);
+     usb_free_pipe(usbdev, inpipe);
+     usb_free_pipe(usbdev, outpipe);
+     return -1;
+-- 
+1.9.0
+
diff --git a/packaging/update_git.sh b/packaging/update_git.sh
new file mode 100644 (file)
index 0000000..ad0a9c5
--- /dev/null
@@ -0,0 +1,158 @@
+#!/bin/bash
+#
+# Instead of a quilt workflow, we use a git tree that contains
+# all the commits on top of a stable tarball.
+#
+# When updating this package, just either update the git tree
+# below (use rebase!) or change the tree path and use your own
+#
+# That way we can easily rebase against the next stable release
+# when it comes.
+
+set -e
+
+GIT_TREE=git://github.com/openSUSE/qemu.git
+GIT_LOCAL_TREE=~/git/qemu-opensuse
+GIT_BRANCH=opensuse-2.7
+GIT_UPSTREAM_TAG=v2.7.0-rc5
+GIT_DIR=/dev/shm/qemu-factory-git-dir
+CMP_DIR=/dev/shm/qemu-factory-cmp-dir
+
+rm -rf $GIT_DIR
+rm -rf $CMP_DIR
+
+if [ -d "$GIT_LOCAL_TREE" ]; then
+    echo "Processing $GIT_BRANCH branch of local git tree, using tag:" \
+         "$GIT_UPSTREAM_TAG"
+    if ! (cd $GIT_LOCAL_TREE && git show-branch $GIT_BRANCH &>/dev/null); then
+        echo "Error: Branch $GIT_BRANCH not found - please create a remote" \
+             "tracking branch of origin/$GIT_BRANCH"
+        exit
+    fi
+    git clone -ls $GIT_LOCAL_TREE $GIT_DIR -b $GIT_BRANCH
+    if ! (cd $GIT_LOCAL_TREE && git remote show upstream &>/dev/null); then
+        echo "Remote for upstream git tree not found. Next time add remote" \
+             "named upstream for git://git.qemu.org/qemu.git and update"
+        (cd $GIT_DIR && git remote add upstream git://git.qemu-project.org/qemu.git)
+        (cd $GIT_DIR && git remote update)
+   fi
+else
+    echo "Processing $GIT_BRANCH branch of remote git tree, using tag:" \
+         "$GIT_UPSTREAM_TAG"
+    echo "(For much fast processing, consider establishing a local git tree" \
+         "at $GIT_LOCAL_TREE)"
+    git clone $GIT_TREE $GIT_DIR -b $GIT_BRANCH
+    (cd $GIT_DIR && git remote add upstream git://git.qemu-project.org/qemu.git)
+    (cd $GIT_DIR && git remote update)
+fi
+(cd $GIT_DIR && git format-patch -N $GIT_UPSTREAM_TAG --suffix= -o $CMP_DIR >/dev/null)
+QEMU_VERSION=`cat $GIT_DIR/VERSION`
+echo "QEMU version: $QEMU_VERSION"
+
+rm -rf $GIT_DIR
+
+(
+    CHANGED_COUNT=0
+    UNCHANGED_COUNT=0
+    DELETED_COUNT=0
+    ADDED_COUNT=0
+
+    shopt -s nullglob
+
+# Process patches to eliminate useless differences: limit file names to 40 chars
+# before extension and remove git signature. ('30' below gets us past dir prefix)
+    for i in $CMP_DIR/*; do
+        # format-patch may append a signature, which per default contains the git version
+        # wipe everything starting from the signature tag
+        sed '/^-- $/Q' $i > $CMP_DIR/${i:30:40}.patch
+        rm $i
+    done
+
+    for i in 0???-*.patch; do
+        if [ -e $CMP_DIR/$i ]; then
+            if cmp -s $CMP_DIR/$i $i; then
+                rm $CMP_DIR/$i
+                let UNCHANGED_COUNT+=1
+            else
+                mv $CMP_DIR/$i .
+                let CHANGED_COUNT+=1
+            fi
+        else
+            osc rm --force $i
+            let DELETED_COUNT+=1
+            echo "  ${i##*/}" >> qemu.changes.deleted
+        fi
+    done
+
+    for i in $CMP_DIR/*; do
+        mv $i .
+        osc add ${i##*/}
+        let ADDED_COUNT+=1
+        echo "  ${i##*/}" >> qemu.changes.added
+    done
+
+    for package in qemu qemu-linux-user; do
+        while IFS= read -r line; do
+            if [ "$line" = "PATCH_FILES" ]; then
+                for i in 0???-*.patch; do
+                    NUM=${i%%-*}
+                    echo -e "Patch$NUM:      $i"
+                done
+            elif [ "$line" = "PATCH_EXEC" ]; then
+                for i in 0???-*.patch; do
+                    NUM=${i%%-*}
+                    echo "%patch$NUM -p1"
+                done
+            elif [ "$line" = "QEMU_VERSION" ]; then
+                echo "Version:        $QEMU_VERSION"
+            elif [[ "$line" =~ ^Source: ]]; then
+                QEMU_TARBALL=qemu-`echo "$line" | cut -d '-' -f 2-`
+                VERSION_FILE=${QEMU_TARBALL%.tar.bz2}/roms/seabios/.version
+                SEABIOS_VERSION=`tar jxfO "$QEMU_TARBALL" "$VERSION_FILE"`
+                SEABIOS_VERSION=`echo $SEABIOS_VERSION | cut -d '-' -f 2`
+                echo "$line"
+            elif [ "$line" = "SEABIOS_VERSION" ]; then
+                echo "Version:        $SEABIOS_VERSION"
+            else
+                echo "$line"
+            fi
+        done < $package.spec.in > $package.spec
+
+        # Factory requires all deleted and added patches to be mentioned
+        if [ -e qemu.changes.deleted ] || [ -e qemu.changes.added ]; then
+            echo "Patch queue updated from ${GIT_TREE} ${GIT_BRANCH}" > $package.changes.proposed
+        fi
+        if [ -e qemu.changes.deleted ]; then
+            echo "* Patches dropped:" >> $package.changes.proposed
+            cat qemu.changes.deleted  >> $package.changes.proposed
+        fi
+        if [ -e qemu.changes.added ]; then
+            echo "* Patches added:" >> $package.changes.proposed
+            cat qemu.changes.added  >> $package.changes.proposed
+        fi
+        if [ -e $package.changes.proposed ]; then
+            osc vc --file=$package.changes.proposed $package
+            rm -f $package.changes.proposed
+        fi
+    done
+    if [ -e qemu.changes.deleted ]; then
+        rm -f qemu.changes.deleted
+    fi
+    if [ -e qemu.changes.added ]; then
+        rm -f qemu.changes.added
+    fi
+    echo "git patch summary"
+    echo "  unchanged: $UNCHANGED_COUNT"
+    echo "    changed: $CHANGED_COUNT"
+    echo "    deleted: $DELETED_COUNT"
+    echo "      added: $ADDED_COUNT"
+)
+
+rm -rf $CMP_DIR
+
+sed -e 's|^\(Name:.*qemu\)|\1-testsuite|' < qemu.spec > qemu-testsuite.spec
+osc service localrun format_spec_file
+
+/bin/sh pre_checkin.sh -q
+
+echo "Please remember to run pre_checkin.sh after modifying qemu.changes."