~ubuntu-branches/ubuntu/trusty/qemu/trusty

« back to all changes in this revision

Viewing changes to tests/qemu-iotests/iotests.py

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2013-10-22 22:47:07 UTC
  • mfrom: (1.8.3) (10.1.42 sid)
  • Revision ID: package-import@ubuntu.com-20131022224707-1lya34fw3k3f24tv
Tags: 1.6.0+dfsg-2ubuntu1
* Merge 1.6.0~rc0+dfsg-2exp from debian experimental.  Remaining changes:
  - debian/control
    * update maintainer
    * remove libiscsi, usb-redir, vde, vnc-jpeg, and libssh2-1-dev
      from build-deps
    * enable rbd
    * add qemu-system and qemu-common B/R to qemu-keymaps
    * add D:udev, R:qemu, R:qemu-common and B:qemu-common to
      qemu-system-common
    * qemu-system-arm, qemu-system-ppc, qemu-system-sparc:
      - add qemu-kvm to Provides
      - add qemu-common, qemu-kvm, kvm to B/R
      - remove openbios-sparc from qemu-system-sparc D
      - drop openbios-ppc and openhackware Depends to Suggests (for now)
    * qemu-system-x86:
      - add qemu-common to Breaks/Replaces.
      - add cpu-checker to Recommends.
    * qemu-user: add B/R:qemu-kvm
    * qemu-kvm:
      - add armhf armel powerpc sparc to Architecture
      - C/R/P: qemu-kvm-spice
    * add qemu-common package
    * drop qemu-slof which is not packaged in ubuntu
  - add qemu-system-common.links for tap ifup/down scripts and OVMF link.
  - qemu-system-x86.links:
    * remove pxe rom links which are in kvm-ipxe
    * add symlink for kvm.1 manpage
  - debian/rules
    * add kvm-spice symlink to qemu-kvm
    * call dh_installmodules for qemu-system-x86
    * update dh_installinit to install upstart script
    * run dh_installman (Closes: #709241) (cherrypicked from 1.5.0+dfsg-2)
  - Add qemu-utils.links for kvm-* symlinks.
  - Add qemu-system-x86.qemu-kvm.upstart and .default
  - Add qemu-system-x86.modprobe to set nesting=1
  - Add qemu-system-common.preinst to add kvm group
  - qemu-system-common.postinst: remove bad group acl if there, then have
    udev relabel /dev/kvm.
  - New linaro patches from qemu-linaro rebasing branch
  - Dropped patches:
    * xen-simplify-xen_enabled.patch
    * sparc-linux-user-fix-missing-symbols-in-.rel-.rela.plt-sections.patch
    * main_loop-do-not-set-nonblocking-if-xen_enabled.patch
    * xen_machine_pv-do-not-create-a-dummy-CPU-in-machine-.patch
    * virtio-rng-fix-crash
  - Kept patches:
    * expose_vms_qemu64cpu.patch - updated
    * linaro arm patches from qemu-linaro rebasing branch
  - New patches:
    * fix-pci-add: change CONFIG variable in ifdef to make sure that
      pci_add is defined.
* Add linaro patches
* Add experimental mach-virt patches for arm virtualization.
* qemu-system-common.install: add debian/tmp/usr/lib to install the
  qemu-bridge-helper

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import unittest
24
24
import sys; sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'QMP'))
25
25
import qmp
 
26
import struct
26
27
 
27
28
__all__ = ['imgfmt', 'imgproto', 'test_dir' 'qemu_img', 'qemu_io',
28
29
           'VM', 'QMPTestCase', 'notrun', 'main']
51
52
    args = qemu_io_args + list(args)
52
53
    return subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0]
53
54
 
 
55
def compare_images(img1, img2):
 
56
    '''Return True if two image files are identical'''
 
57
    return qemu_img('compare', '-f', imgfmt,
 
58
                    '-F', imgfmt, img1, img2) == 0
 
59
 
 
60
def create_image(name, size):
 
61
    '''Create a fully-allocated raw image with sector markers'''
 
62
    file = open(name, 'w')
 
63
    i = 0
 
64
    while i < size:
 
65
        sector = struct.pack('>l504xl', i / 512, i / 512)
 
66
        file.write(sector)
 
67
        i = i + 512
 
68
    file.close()
 
69
 
54
70
class VM(object):
55
71
    '''A QEMU VM'''
56
72
 
79
95
        self._num_drives += 1
80
96
        return self
81
97
 
 
98
    def hmp_qemu_io(self, drive, cmd):
 
99
        '''Write to a given drive using an HMP command'''
 
100
        return self.qmp('human-monitor-command',
 
101
                        command_line='qemu-io %s "%s"' % (drive, cmd))
 
102
 
82
103
    def add_fd(self, fd, fdset, opaque, opts=''):
83
104
        '''Pass a file descriptor to the VM'''
84
105
        options = ['fd=%d' % fd,
170
191
        result = self.dictpath(d, path)
171
192
        self.assertEqual(result, value, 'values not equal "%s" and "%s"' % (str(result), str(value)))
172
193
 
 
194
    def assert_no_active_block_jobs(self):
 
195
        result = self.vm.qmp('query-block-jobs')
 
196
        self.assert_qmp(result, 'return', [])
 
197
 
 
198
    def cancel_and_wait(self, drive='drive0', force=False):
 
199
        '''Cancel a block job and wait for it to finish, returning the event'''
 
200
        result = self.vm.qmp('block-job-cancel', device=drive, force=force)
 
201
        self.assert_qmp(result, 'return', {})
 
202
 
 
203
        cancelled = False
 
204
        result = None
 
205
        while not cancelled:
 
206
            for event in self.vm.get_qmp_events(wait=True):
 
207
                if event['event'] == 'BLOCK_JOB_COMPLETED' or \
 
208
                   event['event'] == 'BLOCK_JOB_CANCELLED':
 
209
                    self.assert_qmp(event, 'data/device', drive)
 
210
                    result = event
 
211
                    cancelled = True
 
212
 
 
213
        self.assert_no_active_block_jobs()
 
214
        return result
 
215
 
 
216
    def wait_until_completed(self, drive='drive0'):
 
217
        '''Wait for a block job to finish, returning the event'''
 
218
        completed = False
 
219
        while not completed:
 
220
            for event in self.vm.get_qmp_events(wait=True):
 
221
                if event['event'] == 'BLOCK_JOB_COMPLETED':
 
222
                    self.assert_qmp(event, 'data/device', drive)
 
223
                    self.assert_qmp_absent(event, 'data/error')
 
224
                    self.assert_qmp(event, 'data/offset', self.image_len)
 
225
                    self.assert_qmp(event, 'data/len', self.image_len)
 
226
                    completed = True
 
227
 
 
228
        self.assert_no_active_block_jobs()
 
229
        return event
 
230
 
173
231
def notrun(reason):
174
232
    '''Skip this test suite'''
175
233
    # Each test in qemu-iotests has a number ("seq")