1. 16 6月, 2016 21 次提交
    • D
      block: drop support for using qcow[2] encryption with system emulators · 8c0dcbc4
      Daniel P. Berrange 提交于
      Back in the 2.3.0 release we declared qcow[2] encryption as
      deprecated, warning people that it would be removed in a future
      release.
      
        commit a1f688f4
        Author: Markus Armbruster <armbru@redhat.com>
        Date:   Fri Mar 13 21:09:40 2015 +0100
      
          block: Deprecate QCOW/QCOW2 encryption
      
      The code still exists today, but by a (happy?) accident we entirely
      broke the ability to use qcow[2] encryption in the system emulators
      in the 2.4.0 release due to
      
        commit 8336aafa
        Author: Daniel P. Berrange <berrange@redhat.com>
        Date:   Tue May 12 17:09:18 2015 +0100
      
          qcow2/qcow: protect against uninitialized encryption key
      
      This commit was designed to prevent future coding bugs which
      might cause QEMU to read/write data on an encrypted block
      device in plain text mode before a decryption key is set.
      
      It turns out this preventative measure was a little too good,
      because we already had a long standing bug where QEMU read
      encrypted data in plain text mode during system emulator
      startup, in order to guess disk geometry:
      
        Thread 10 (Thread 0x7fffd3fff700 (LWP 30373)):
        #0  0x00007fffe90b1a28 in raise () at /lib64/libc.so.6
        #1  0x00007fffe90b362a in abort () at /lib64/libc.so.6
        #2  0x00007fffe90aa227 in __assert_fail_base () at /lib64/libc.so.6
        #3  0x00007fffe90aa2d2 in  () at /lib64/libc.so.6
        #4  0x000055555587ae19 in qcow2_co_readv (bs=0x5555562accb0, sector_num=0, remaining_sectors=1, qiov=0x7fffffffd260) at block/qcow2.c:1229
        #5  0x000055555589b60d in bdrv_aligned_preadv (bs=bs@entry=0x5555562accb0, req=req@entry=0x7fffd3ffea50, offset=offset@entry=0, bytes=bytes@entry=512, align=align@entry=512, qiov=qiov@entry=0x7fffffffd260, flags=0) at block/io.c:908
        #6  0x000055555589b8bc in bdrv_co_do_preadv (bs=0x5555562accb0, offset=0, bytes=512, qiov=0x7fffffffd260, flags=<optimized out>) at block/io.c:999
        #7  0x000055555589c375 in bdrv_rw_co_entry (opaque=0x7fffffffd210) at block/io.c:544
        #8  0x000055555586933b in coroutine_thread (opaque=0x555557876310) at coroutine-gthread.c:134
        #9  0x00007ffff64e1835 in g_thread_proxy (data=0x5555562b5590) at gthread.c:778
        #10 0x00007ffff6bb760a in start_thread () at /lib64/libpthread.so.0
        #11 0x00007fffe917f59d in clone () at /lib64/libc.so.6
      
        Thread 1 (Thread 0x7ffff7ecab40 (LWP 30343)):
        #0  0x00007fffe91797a9 in syscall () at /lib64/libc.so.6
        #1  0x00007ffff64ff87f in g_cond_wait (cond=cond@entry=0x555555e085f0 <coroutine_cond>, mutex=mutex@entry=0x555555e08600 <coroutine_lock>) at gthread-posix.c:1397
        #2  0x00005555558692c3 in qemu_coroutine_switch (co=<optimized out>) at coroutine-gthread.c:117
        #3  0x00005555558692c3 in qemu_coroutine_switch (from_=0x5555562b5e30, to_=to_@entry=0x555557876310, action=action@entry=COROUTINE_ENTER) at coroutine-gthread.c:175
        #4  0x0000555555868a90 in qemu_coroutine_enter (co=0x555557876310, opaque=0x0) at qemu-coroutine.c:116
        #5  0x0000555555859b84 in thread_pool_completion_bh (opaque=0x7fffd40010e0) at thread-pool.c:187
        #6  0x0000555555859514 in aio_bh_poll (ctx=ctx@entry=0x5555562953b0) at async.c:85
        #7  0x0000555555864d10 in aio_dispatch (ctx=ctx@entry=0x5555562953b0) at aio-posix.c:135
        #8  0x0000555555864f75 in aio_poll (ctx=ctx@entry=0x5555562953b0, blocking=blocking@entry=true) at aio-posix.c:291
        #9  0x000055555589c40d in bdrv_prwv_co (bs=bs@entry=0x5555562accb0, offset=offset@entry=0, qiov=qiov@entry=0x7fffffffd260, is_write=is_write@entry=false, flags=flags@entry=(unknown: 0)) at block/io.c:591
        #10 0x000055555589c503 in bdrv_rw_co (bs=bs@entry=0x5555562accb0, sector_num=sector_num@entry=0, buf=buf@entry=0x7fffffffd2e0 "\321,", nb_sectors=nb_sectors@entry=21845, is_write=is_write@entry=false, flags=flags@entry=(unknown: 0)) at block/io.c:614
        #11 0x000055555589c562 in bdrv_read_unthrottled (nb_sectors=21845, buf=0x7fffffffd2e0 "\321,", sector_num=0, bs=0x5555562accb0) at block/io.c:622
        #12 0x000055555589c562 in bdrv_read_unthrottled (bs=0x5555562accb0, sector_num=sector_num@entry=0, buf=buf@entry=0x7fffffffd2e0 "\321,", nb_sectors=nb_sectors@entry=21845) at block/io.c:634
          nb_sectors@entry=1) at block/block-backend.c:504
        #14 0x0000555555752e9f in guess_disk_lchs (blk=blk@entry=0x5555562a5290, pcylinders=pcylinders@entry=0x7fffffffd52c, pheads=pheads@entry=0x7fffffffd530, psectors=psectors@entry=0x7fffffffd534) at hw/block/hd-geometry.c:68
        #15 0x0000555555752ff7 in hd_geometry_guess (blk=0x5555562a5290, pcyls=pcyls@entry=0x555557875d1c, pheads=pheads@entry=0x555557875d20, psecs=psecs@entry=0x555557875d24, ptrans=ptrans@entry=0x555557875d28) at hw/block/hd-geometry.c:133
        #16 0x0000555555752b87 in blkconf_geometry (conf=conf@entry=0x555557875d00, ptrans=ptrans@entry=0x555557875d28, cyls_max=cyls_max@entry=65536, heads_max=heads_max@entry=16, secs_max=secs_max@entry=255, errp=errp@entry=0x7fffffffd5e0) at hw/block/block.c:71
        #17 0x0000555555799bc4 in ide_dev_initfn (dev=0x555557875c80, kind=IDE_HD) at hw/ide/qdev.c:174
        #18 0x0000555555768394 in device_realize (dev=0x555557875c80, errp=0x7fffffffd640) at hw/core/qdev.c:247
        #19 0x0000555555769a81 in device_set_realized (obj=0x555557875c80, value=<optimized out>, errp=0x7fffffffd730) at hw/core/qdev.c:1058
        #20 0x00005555558240ce in property_set_bool (obj=0x555557875c80, v=<optimized out>, opaque=0x555557875de0, name=<optimized out>, errp=0x7fffffffd730)
              at qom/object.c:1514
        #21 0x0000555555826c87 in object_property_set_qobject (obj=obj@entry=0x555557875c80, value=value@entry=0x55555784bcb0, name=name@entry=0x55555591cb3d "realized", errp=errp@entry=0x7fffffffd730) at qom/qom-qobject.c:24
        #22 0x0000555555825760 in object_property_set_bool (obj=obj@entry=0x555557875c80, value=value@entry=true, name=name@entry=0x55555591cb3d "realized", errp=errp@entry=0x7fffffffd730) at qom/object.c:905
        #23 0x000055555576897b in qdev_init_nofail (dev=dev@entry=0x555557875c80) at hw/core/qdev.c:380
        #24 0x0000555555799ead in ide_create_drive (bus=bus@entry=0x555557629630, unit=unit@entry=0, drive=0x5555562b77e0) at hw/ide/qdev.c:122
        #25 0x000055555579a746 in pci_ide_create_devs (dev=dev@entry=0x555557628db0, hd_table=hd_table@entry=0x7fffffffd830) at hw/ide/pci.c:440
        #26 0x000055555579b165 in pci_piix3_ide_init (bus=<optimized out>, hd_table=0x7fffffffd830, devfn=<optimized out>) at hw/ide/piix.c:218
        #27 0x000055555568ca55 in pc_init1 (machine=0x5555562960a0, pci_enabled=1, kvmclock_enabled=<optimized out>) at /home/berrange/src/virt/qemu/hw/i386/pc_piix.c:256
        #28 0x0000555555603ab2 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4249
      
      So the safety net is correctly preventing QEMU reading cipher
      text as if it were plain text, during startup and aborting QEMU
      to avoid bad usage of this data.
      
      For added fun this bug only happens if the encrypted qcow2
      file happens to have data written to the first cluster,
      otherwise the cluster won't be allocated and so qcow2 would
      not try the decryption routines at all, just return all 0's.
      
      That no one even noticed, let alone reported, this bug that
      has shipped in 2.4.0, 2.5.0 and 2.6.0 shows that the number
      of actual users of encrypted qcow2 is approximately zero.
      
      So rather than fix the crash, and backport it to stable
      releases, just go ahead with what we have warned users about
      and disable any use of qcow2 encryption in the system
      emulators. qemu-img/qemu-io/qemu-nbd are still able to access
      qcow2 encrypted images for the sake of data conversion.
      
      In the future, qcow2 will gain support for the alternative
      luks format, but when this happens it'll be using the
      '-object secret' infrastructure for getting keys, which
      avoids this problematic scenario entirely.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      8c0dcbc4
    • E
      block: Assert that flags are in range · fa166538
      Eric Blake 提交于
      Add a new BDRV_REQ_MASK constant, and use it to make sure that
      caller flags are always valid.
      
      Tested with 'make check' and with qemu-iotests on both '-raw'
      and '-qcow2'; the only failure turned up was fixed in the
      previous commit.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      fa166538
    • E
      block: Avoid bogus flags during mirroring · 73698c30
      Eric Blake 提交于
      Commit e253f4b8 converted mirroring from sector-based bdrv_aio_*
      to byte-based blk_aio_*, but failed to account for the subtle
      difference in signatures (the former takes a semi-redundant length,
      the latter takes a flags parameter).  Since all of our flags are
      currently smaller in size than BDRV_SECTOR_SIZE, it has no ill
      effects until we either perform sub-sector mirroring, or we start
      asserting that no unexpected flags are set.  I found it while
      testing new asserts when qemu-iotests 132 started warning about an
      unknown flag 0x200000.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      73698c30
    • K
      qemu-img bench: Fix uninitialised writethrough mode · 604e8613
      Kevin Wolf 提交于
      If no -t option is specified, bool writethrough stayed uninitialised.
      Initialise it as false, which makes cache=writeback the default cache
      mode.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      604e8613
    • C
      m25p80: fix test on blk_pread() return value · 9e19036e
      Cédric Le Goater 提交于
      commit 243e6f69 ("m25p80: Switch to byte-based block access")
      replaced blk_read() calls with blk_pread() but return values are
      different.
      Signed-off-by: NCédric Le Goater <clg@kaod.org>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      9e19036e
    • V
      hmp: acquire aio_context in hmp_qemu_io · 479b5998
      Vladimir Sementsov-Ogievskiy 提交于
      Acquire aio context before run command, this is mandatory for unit tests.
      Signed-off-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Signed-off-by: NDenis V. Lunev <den@openvz.org>
      CC: Kevin Wolf <kwolf@redhat.com>
      CC: Paolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      479b5998
    • C
      blockdev: clarify error on attempt to open locked tray · 38a53d50
      Colin Lord 提交于
      When opening a device with a locked tray, gives an error explaining the
      device tray is locked and that the user should wait and try again. This
      is less confusing than the previous error, which simply stated that the
      tray was locked.
      Signed-off-by: NColin Lord <clord@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      38a53d50
    • K
      qcow2: Implement .bdrv_co_pwritev() · d46a0bb2
      Kevin Wolf 提交于
      This changes qcow2 to implement the byte-based .bdrv_co_pwritev
      interface rather than the sector-based old one.
      
      As preallocation uses the same allocation function as normal writes, and
      the interface of that function needs to be changed, it is converted in
      the same patch.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      d46a0bb2
    • K
      qcow2: Use bytes instead of sectors for QCowL2Meta · 85567393
      Kevin Wolf 提交于
      In preparation for implementing .bdrv_co_pwritev in qcow2.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      85567393
    • K
      qcow2: Make copy_sectors() byte based · aaa4d20b
      Kevin Wolf 提交于
      This will allow copy on write operations where the overwritten part of
      the cluster is not aligned to sector boundaries.
      
      Also rename the function because it has nothing to do with sectors any
      more.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      aaa4d20b
    • K
      qcow2: Implement .bdrv_co_preadv() · ecfe1863
      Kevin Wolf 提交于
      Reading from qcow2 images is now byte granularity.
      
      Most of the affected code in qcow2 actually gets simpler with this
      change. The only exception is encryption, which is fixed on 512 bytes
      blocks; in order to keep this working, bs->request_alignment is set for
      encrypted images.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      ecfe1863
    • K
      qcow2: Work with bytes in qcow2_get_cluster_offset() · b2f65d6b
      Kevin Wolf 提交于
      This patch changes the units that qcow2_get_cluster_offset() uses
      internally, without touching the interface just yet. This will be done
      in another patch.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      b2f65d6b
    • P
      Merge remote-tracking branch 'remotes/amit-migration/tags/migration-for-2.7-4' into staging · a66370b0
      Peter Maydell 提交于
      Migration:
      
      - Fixes for TLS series
      - Postcopy: Add stats, fix, test case
      
      # gpg: Signature made Thu 16 Jun 2016 05:40:09 BST
      # gpg:                using RSA key 0xEB0B4DFC657EF670
      # gpg: Good signature from "Amit Shah <amit@amitshah.net>"
      # gpg:                 aka "Amit Shah <amit@kernel.org>"
      # gpg:                 aka "Amit Shah <amitshah@gmx.net>"
      # Primary key fingerprint: 48CA 3722 5FE7 F4A8 B337  2735 1E9A 3B5F 8540 83B6
      #      Subkey fingerprint: CC63 D332 AB8F 4617 4529  6534 EB0B 4DFC 657E F670
      
      * remotes/amit-migration/tags/migration-for-2.7-4:
        migration: rename functions to starting migrations
        migration: fix typos in qapi-schema from latest migration additions
        Postcopy: Check for support when setting the capability
        tests: fix libqtest socket timeouts
        test: Postcopy
        Postcopy: Add stats on page requests
        Migration: Split out ram part of qmp_query_migrate
        Postcopy: Avoid 0 length discards
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      a66370b0
    • D
      migration: rename functions to starting migrations · 22724f49
      Daniel P. Berrange 提交于
      Apply the following renames for starting incoming migration:
      
       process_incoming_migration -> migration_fd_process_incoming
       migration_set_incoming_channel -> migration_channel_process_incoming
       migration_tls_set_incoming_channel -> migration_tls_channel_process_incoming
      
      and for starting outgoing migration:
      
       migration_set_outgoing_channel -> migration_channel_connect
       migration_tls_set_outgoing_channel -> migration_tls_channel_connect
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-id: 1464776234-9910-3-git-send-email-berrange@redhat.com
      Message-Id: <1464776234-9910-3-git-send-email-berrange@redhat.com>
      Signed-off-by: NAmit Shah <amit.shah@redhat.com>
      22724f49
    • D
      migration: fix typos in qapi-schema from latest migration additions · bdbba12b
      Daniel P. Berrange 提交于
      Recent migration QAPI enhancements had a few spelling mistakes
      and also incorrect version number in a few places.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-id: 1464776234-9910-2-git-send-email-berrange@redhat.com
      Message-Id: <1464776234-9910-2-git-send-email-berrange@redhat.com>
      Signed-off-by: NAmit Shah <amit.shah@redhat.com>
      bdbba12b
    • D
      Postcopy: Check for support when setting the capability · 096631bd
      Dr. David Alan Gilbert 提交于
      Knowing whether the destination host supports migration with
      postcopy can be tricky.
      The destination doesn't need the capability set, however
      if we set it then use the opportunity to do the test and
      tell the user/management layer early.
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Message-id: 1465816605-29488-7-git-send-email-dgilbert@redhat.com
      Message-Id: <1465816605-29488-7-git-send-email-dgilbert@redhat.com>
      Signed-off-by: NAmit Shah <amit.shah@redhat.com>
      096631bd
    • A
      tests: fix libqtest socket timeouts · f5d45791
      Andrea Arcangeli 提交于
      I kept getting timeouts and unix socket accept failures under high
      load, the patch fixes it.
      Signed-off-by: NAndrea Arcangeli <aarcange@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel@redhat.com>
      Message-id: 1465816605-29488-6-git-send-email-dgilbert@redhat.com
      Message-Id: <1465816605-29488-6-git-send-email-dgilbert@redhat.com>
      Signed-off-by: NAmit Shah <amit.shah@redhat.com>
      f5d45791
    • D
      test: Postcopy · ea0c6d62
      Dr. David Alan Gilbert 提交于
      This is a postcopy test (x86 only) that actually runs the guest
      and checks the memory contents.
      
      The test runs from an x86 boot block with the hex embedded in the test;
      the source for this is:
      
      ...........
      
      .code16
      .org 0x7c00
      	.file	"fill.s"
      	.text
      	.globl	start
      	.type	start, @function
      start:             # at 0x7c00 ?
              cli
              lgdt gdtdesc
              mov $1,%eax
              mov %eax,%cr0  # Protected mode enable
              data32 ljmp $8,$0x7c20
      
      .org 0x7c20
      .code32
              # A20 enable - not sure I actually need this
              inb $0x92,%al
              or  $2,%al
              outb %al, $0x92
      
              # set up DS for the whole of RAM (needed on KVM)
              mov $16,%eax
              mov %eax,%ds
      
              mov $65,%ax
              mov $0x3f8,%dx
              outb %al,%dx
      
              # bl keeps a counter so we limit the output speed
              mov $0, %bl
      mainloop:
              # Start from 1MB
              mov $(1024*1024),%eax
      innerloop:
              incb (%eax)
              add $4096,%eax
              cmp $(100*1024*1024),%eax
              jl innerloop
      
              inc %bl
              jnz mainloop
      
              mov $66,%ax
              mov $0x3f8,%dx
              outb %al,%dx
      
      	jmp mainloop
      
              # GDT magic from old (GPLv2)  Grub startup.S
              .p2align        2       /* force 4-byte alignment */
      gdt:
              .word   0, 0
              .byte   0, 0, 0, 0
      
              /* -- code segment --
               * base = 0x00000000, limit = 0xFFFFF (4 KiB Granularity), present
               * type = 32bit code execute/read, DPL = 0
               */
              .word   0xFFFF, 0
              .byte   0, 0x9A, 0xCF, 0
      
              /* -- data segment --
               * base = 0x00000000, limit 0xFFFFF (4 KiB Granularity), present
               * type = 32 bit data read/write, DPL = 0
               */
              .word   0xFFFF, 0
              .byte   0, 0x92, 0xCF, 0
      
      gdtdesc:
              .word   0x27                    /* limit */
              .long   gdt                     /* addr */
      
      /* I'm a bootable disk */
      .org 0x7dfe
              .byte 0x55
              .byte 0xAA
      
      ...........
      
      and that can be assembled by the following magic:
          as --32 -march=i486 fill.s -o fill.o
          objcopy -O binary fill.o fill.boot
          dd if=fill.boot of=bootsect bs=256 count=2 skip=124
          xxd -i bootsect
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel@redhat.com>
      Message-id: 1465816605-29488-5-git-send-email-dgilbert@redhat.com
      Message-Id: <1465816605-29488-5-git-send-email-dgilbert@redhat.com>
      Signed-off-by: NAmit Shah <amit.shah@redhat.com>
      ea0c6d62
    • D
      Postcopy: Add stats on page requests · d3bf5418
      Dr. David Alan Gilbert 提交于
      On the source, add a count of page requests received from the
      destination.
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NDenis V. Lunev <den@openvz.org>
      Message-id: 1465816605-29488-4-git-send-email-dgilbert@redhat.com
      Message-Id: <1465816605-29488-4-git-send-email-dgilbert@redhat.com>
      Signed-off-by: NAmit Shah <amit.shah@redhat.com>
      d3bf5418
    • D
      Migration: Split out ram part of qmp_query_migrate · a22463a5
      Dr. David Alan Gilbert 提交于
      The RAM section of qmp_query_migrate is reasonably complex
      and repeated 3 times.  Split it out into a helper.
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-id: 1465816605-29488-3-git-send-email-dgilbert@redhat.com
      Reviwed-by: NDenis V. Lunev <den@openvz.org>
      Message-Id: <1465816605-29488-3-git-send-email-dgilbert@redhat.com>
      Signed-off-by: NAmit Shah <amit.shah@redhat.com>
      a22463a5
    • D
      Postcopy: Avoid 0 length discards · d688c62d
      Dr. David Alan Gilbert 提交于
      The discard code in migration/ram.c would send request for
      zero length discards in the case where no discards were needed.
      It doesn't appear to have had any bad effect.
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: NDenis V. Lunev <den@openvz.org>
      Message-id: 1465816605-29488-2-git-send-email-dgilbert@redhat.com
      Message-Id: <1465816605-29488-2-git-send-email-dgilbert@redhat.com>
      Signed-off-by: NAmit Shah <amit.shah@redhat.com>
      d688c62d
  2. 15 6月, 2016 10 次提交
  3. 14 6月, 2016 9 次提交