Patch Round-up for stable 2.5.1, freeze on 2016-03-25
Subsystems (2)
cover Patch Round-up for stable 2.5.1, freeze on 2016-03-25
Hi everyone,
The following new patches are queued for QEMU stable v2.5.1:
https://github.com/mdroth/qemu/commits/stable-2.5-staging
The release is planned for 2016-03-29:
http://wiki.qemu.org/Planning/2.5
Please respond here or CC [email protected] on any patches you think should be included in the release.
Testing/feedback is greatly appreciated.
Thanks!
----------------------------------------------------------------
Alberto Garcia (1):
quorum: Fix crash in quorum_aio_cb()
Christian Borntraeger (1):
block/raw-posix: avoid bogus fixup for cylinders on DASD disks
Dr. David Alan Gilbert (1):
cpus: use broadcast on qemu_pause_cond
Eric Blake (1):
qmp: Fix reference-counting of qnull on empty output visit
Gabriel L. Somlo (1):
fw_cfg: avoid calculating invalid current entry pointer
Gerd Hoffmann (2):
ehci: make idt processing more robust
ehci: update irq on reset
Greg Kurz (3):
target-ppc: kvm: fix floating point registers sync on little-endian hosts
virtio-9p: use accessor to get thread_pool
spapr: skip configuration section during migration of older machines
Halil Pasic (1):
s390x/css: fix control flags during csch
Jeff Cody (2):
block: set device_list.tqe_prev to NULL on BDS removal
block: qemu-iotests - add test for snapshot, commit, snapshot bug
Laszlo Ersek (2):
e1000: eliminate infinite loops on out-of-bounds transfer start
fw_cfg: unbreak migration compatibility for 2.4 and earlier machines
Laurent Vivier (1):
net: set endianness on all backend devices
Li Zhijian (2):
net/dump: fix nfds->filename leak
net/filter: fix nf->netdev_id leakMarc-André Lureau (2):
ivshmem: no need for opaque argument
ivshmem: remove redundant assignment, fix crash with msi=off
Marcel Apfelbaum (3):
hw/virtio: fix double use of a virtio flag hw/virtio: group virtio flags into an enum vl.c: Fix regression in machine error message
Max Reitz (2):
block: Add blk_dev_has_tray()
blockdev: Fix 'change' for slot devices
Michael S. Tsirkin (1):
vhost-user: don't merge regions with different fds
P J P (2):
net: vmxnet3: avoid memory leakage in activate_device
scsi: initialise info object with appropriate size
Peter Maydell (2):
configure: Fix shell syntax to placate OpenBSD's pdksh
target-arm: Make reserved ranges in ID_AA64* spaces RAZ, not UNDEF
Pierre Morel (1):
s390x/ioinst: set type and len for SEI response
Prasad J Pandit (2):
net: rocker: fix an incorrect array bounds check
net: ne2000: check ring buffer control registers
Stefano Stabellini (2):
xen/blkif: Avoid double access to src->nr_segments
xenfb: avoid reading twice the same fields from the shared page
block.c | 24 ++++--- block/block-backend.c | 10 ++- block/quorum.c | 12 ++-- block/raw-posix.c | 7 --- blockdev.c | 34 ++++++++-- configure | 6 +- cpus.c | 4 +- hw/9pfs/virtio-9p-coth.c | 2 +- hw/block/xen_blkif.h | 12 ++-- hw/display/xenfb.c | 10 +-- hw/misc/ivshmem.c | 7 +-- hw/net/e1000.c | 6 +- hw/net/ne2000.c | 4 ++ hw/net/rocker/rocker.c | 8 +-- hw/net/vhost_net.c | 23 ++++--- hw/net/vmxnet3.c | 24 ++++--- hw/nvram/fw_cfg.c | 26 +++++--- hw/ppc/spapr.c | 1 + hw/s390x/css.c | 2 +- hw/scsi/megasas.c | 2 +- hw/usb/hcd-ehci.c | 6 +- hw/virtio/vhost-user.c | 20 ++++++ hw/virtio/vhost.c | 7 +++ hw/virtio/virtio-pci.h | 17 ++--- include/block/block.h | 1 + include/block/block_int.h | 1 + include/hw/compat.h | 8 +++ include/hw/virtio/vhost-backend.h | 4 ++ net/dump.c | 8 +++ net/filter.c | 1 + qapi/block-core.json | 3 +- qapi/qmp-output-visitor.c | 41 +++++++++--- target-arm/cpu-qom.h | 1 + target-arm/helper.c | 128 +++++++++++++++++++++++++++++++++++--- target-ppc/kvm.c | 12 ++++ target-s390x/ioinst.c | 3 +- tests/qemu-iotests/144 | 114 +++++++++++++++++++++++++++++++++ tests/qemu-iotests/144.out | 24 +++++++ tests/qemu-iotests/group | 1 + tests/test-qmp-output-visitor.c | 2 + vl.c | 37 +++++++---- 41 files changed, 544 insertions(+), 119 deletions(-) create mode 100755 tests/qemu-iotests/144 create mode 100644 tests/qemu-iotests/144.out
PATCH 1/35 ehci: make idt processing more robust
From: Gerd Hoffmann <[email protected]>
Make ehci_process_itd return an error in case we didn't do any actual iso transfer because we've found no active transaction. That'll avoid ehci happily run in circles forever if the guest builds a loop out of idts.
This is CVE-2015-8558.
--- hw/usb/hcd-ehci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/usb/hcd-ehci.c +3 -2
@@ -1389,7 +1389,7 @@ static int ehci_process_itd(EHCIState *ehci, {USBDevice *dev;USBEndpoint *ep; -uint32_t i, len, pid, dir, devaddr, endp; +uint32_t i, len, pid, dir, devaddr, endp, xfers =0 ;uint32_t pg, off, ptr1, ptr2, max, mult; ehci->periodic_sched_active =PERIODIC_ACTIVE ;
@@ -1479,9 +1479,10 @@ static int ehci_process_itd(EHCIState *ehci,ehci_raise_irq (ehci,USBSTS_INT ); } itd->transact[i] &= ~ITD_XACT_ACTIVE ; + xfers++; } } -return 0 ; +return xfers ?0 :-1 ; }
Signature · 1 line
1.9.1
PATCH 2/35 net: vmxnet3: avoid memory leakage in activate_device
In reply to Michael RothFrom: P J P <[email protected]>
Vmxnet3 device emulator does not check if the device is active before activating it, also it did not free the transmit & receive buffers while deactivating the device, thus resulting in memory leakage on the host. This patch fixes both these issues to avoid host memory leakage.
--- hw/net/vmxnet3.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
hw/net/vmxnet3.c +16 -8
@@ -1194,8 +1194,13 @@ static void vmxnet3_reset_mac(VMXNET3State *s)static void vmxnet3_deactivate_device (VMXNET3State *s) { -VMW_CBPRN ("Deactivating vmxnet3..." ); - s->device_active = false; +if (s->device_active) { +VMW_CBPRN ("Deactivating vmxnet3..." ); +vmxnet_tx_pkt_reset (s->tx_pkt); +vmxnet_tx_pkt_uninit (s->tx_pkt); +vmxnet_rx_pkt_uninit (s->rx_pkt); + s->device_active = false; + } }static void vmxnet3_reset (VMXNET3State *s)
@@ -1204,7 +1209,6 @@ static void vmxnet3_reset(VMXNET3State *s)vmxnet3_deactivate_device (s);vmxnet3_reset_interrupt_states (s); -vmxnet_tx_pkt_reset (s->tx_pkt); s->drv_shmem =0 ; s->tx_sop = true; s->skip_current_tx_pkt = false;
@@ -1431,6 +1435,12 @@ static void vmxnet3_activate_device(VMXNET3State *s)return ; } +/* Verify if device is active */ +if (s->device_active) { +VMW_CFPRN ("Vmxnet3 device is active" ); +return ; + } +vmxnet3_adjust_by_guest_type (s);vmxnet3_update_features (s);vmxnet3_update_pm_state (s);
@@ -1627,7 +1637,7 @@ static void vmxnet3_handle_command(VMXNET3State *s, uint64_t cmd)break ;case VMXNET3_CMD_QUIESCE_DEV : -VMW_CBPRN ("Set: VMXNET3_CMD_QUIESCE_DEV - pause the device" ); +VMW_CBPRN ("Set: VMXNET3_CMD_QUIESCE_DEV - deactivate the device" );vmxnet3_deactivate_device (s);break ;
@@ -1741,7 +1751,7 @@ vmxnet3_io_bar1_write(void *opaque,* shared address only after we get the high part */ if (val ==0 ) { - s->device_active = false; +vmxnet3_deactivate_device (s); } s->temp_shared_guest_driver_memory = val; s->drv_shmem =0 ;
@@ -2021,9 +2031,7 @@ static bool vmxnet3_peer_has_vnet_hdr(VMXNET3State *s)static void vmxnet3_net_uninit (VMXNET3State *s) {g_free (s->mcast_list); -vmxnet_tx_pkt_reset (s->tx_pkt); -vmxnet_tx_pkt_uninit (s->tx_pkt); -vmxnet_rx_pkt_uninit (s->rx_pkt); +vmxnet3_deactivate_device (s);qemu_del_nic (s->nic); }
Signature · 1 line
1.9.1
PATCH 3/35 target-ppc: kvm: fix floating point registers sync on little-endian hosts
In reply to Michael RothFrom: Greg Kurz <[email protected]>
On VSX capable CPUs, the 32 FP registers are mapped to the high-bits of the 32 first VSX registers. So if you have:
VSR31 = (uint128) 0x0102030405060708090a0b0c0d0e0f00
then
FPR31 = (uint64) 0x0102030405060708
The kernel stores the VSX registers in the fp_state struct following the host endian element ordering.
On big-endian:
fp_state.fpr[31][0] = 0x0102030405060708
fp_state.fpr[31][1] = 0x090a0b0c0d0e0f00
On little-endian:
fp_state.fpr[31][0] = 0x090a0b0c0d0e0f00
fp_state.fpr[31][1] = 0x0102030405060708
The KVM_GET_ONE_REG and KVM_SET_ONE_REG ioctls preserve this ordering, but QEMU considers it as big-endian and always copies element [0] to the fpr[] array and element [1] to the vsr[] array. This does not work with little-endian hosts, and you will get:
(qemu) p $f310x90a0b0c0d0e0f00
instead of:
(qemu) p $f310x102030405060708
This patch fixes the element ordering for little-endian hosts.
--- target-ppc/kvm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
target-ppc/kvm.c +12 -0
@@ -650,8 +650,13 @@ static int kvm_put_fp(CPUState *cs)for (i =0 ; i <32 ; i++) {uint64_t vsr[2 ]; +#ifdef HOST_WORDS_BIGENDIAN vsr[0 ] =float64_val (env->fpr[i]); vsr[1 ] = env->vsr[i]; +#else + vsr[0 ] = env->vsr[i]; + vsr[1 ] =float64_val (env->fpr[i]); +#endif reg.addr = (uintptr_t ) &vsr; reg.id = vsx ?KVM_REG_PPC_VSR (i) :KVM_REG_PPC_FPR (i);
@@ -721,10 +726,17 @@ static int kvm_get_fp(CPUState *cs) vsx ? "VSR" : "FPR", i, strerror(errno));return ret; }else { +#ifdef HOST_WORDS_BIGENDIAN env->fpr[i] = vsr[0 ];if (vsx) { env->vsr[i] = vsr[1 ]; } +#else + env->fpr[i] = vsr[1 ]; +if (vsx) { + env->vsr[i] = vsr[0 ]; + } +#endif } } }
Signature · 1 line
1.9.1
PATCH 4/35 configure: Fix shell syntax to placate OpenBSD's pdksh
In reply to Michael RothFrom: Peter Maydell <[email protected]>
Unfortunately the OpenBSD pdksh does not like brackets inside the right part of a ${variable+word} parameter expansion:
$ echo "${a+($b)}"
ksh: ${a+($b)}": bad substitutionthough both bash and dash accept them. In any case this line was causing odd output in the case where nettle is not present:
nettle no ()
(because if nettle is not present then $nettle will be "no", not a null string or unset).
Rewrite it to just use an if.
This bug was originally introduced in becaeb726 and was present in the 2.4.0 release.
Message-id: [email protected]
--- configure | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
configure +5 -1
@@ -4758,7 +4758,11 @@ echo "GTK GL support $gtk_gl" echo "GNUTLS support $gnutls" echo "GNUTLS hash $gnutls_hash" echo "libgcrypt $gcrypt" -echo "nettle $nettle ${nettle+($nettle_version)}" +if test "$nettle" = "yes"; then + echo "nettle $nettle ($nettle_version)" +else + echo "nettle $nettle" +fi echo "libtasn1 $tasn1" echo "VTE support $vte" echo "curses support $curses"
Signature · 1 line
1.9.1
PATCH 5/35 xen/blkif: Avoid double access to src->nr_segments
In reply to Michael RothFrom: Stefano Stabellini <[email protected]>
src is stored in shared memory and src->nr_segments is dereferenced twice at the end of the function. If a compiler decides to compile this into two separate memory accesses then the size limitation could be bypassed.
Fix it by removing the double access to src->nr_segments.
This is part of XSA-155.
--- hw/block/xen_blkif.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
hw/block/xen_blkif.h +8 -4
@@ -85,8 +85,10 @@ static inline void blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_reque d->nr_sectors = s->nr_sectors;return ; } -if (n > src->nr_segments) - n = src->nr_segments; +/* prevent the compiler from optimizing the code and using src->nr_segments instead */ +barrier (); +if (n > dst->nr_segments) + n = dst->nr_segments;for (i =0 ; i < n; i++) dst->seg[i] = src->seg[i]; }
@@ -106,8 +108,10 @@ static inline void blkif_get_x86_64_req(blkif_request_t *dst, blkif_x86_64_reque d->nr_sectors = s->nr_sectors;return ; } -if (n > src->nr_segments) - n = src->nr_segments; +/* prevent the compiler from optimizing the code and using src->nr_segments instead */ +barrier (); +if (n > dst->nr_segments) + n = dst->nr_segments;for (i =0 ; i < n; i++) dst->seg[i] = src->seg[i]; }
Signature · 1 line
1.9.1
PATCH 6/35 xenfb: avoid reading twice the same fields from the shared page
In reply to Michael RothFrom: Stefano Stabellini <[email protected]>
Reading twice the same field could give the guest an attack of opportunity. In the case of event->type, gcc could compile the switch statement into a jump table, effectively ending up reading the type field multiple times.
This is part of XSA-155.
--- hw/display/xenfb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
hw/display/xenfb.c +6 -4
@@ -784,18 +784,20 @@ static void xenfb_invalidate(void *opaque)static void xenfb_handle_events (struct XenFB *xenfb) { -uint32_t prod, cons; +uint32_t prod, cons, out_cons;struct xenfb_page *page = xenfb->c.page; prod = page->out_prod; -if (prod == page->out_cons) + out_cons = page->out_cons; +if (prod == out_cons)return ;xen_rmb ();/* ensure we see ring contents up to prod */ -for (cons = page->out_cons; cons != prod; cons++) { +for (cons = out_cons; cons != prod; cons++) {union xenfb_out_event *event = &XENFB_OUT_RING_REF (page, cons); +uint8_t type = event->type;int x, y, w, h; -switch (event->type) { +switch (type) {case XENFB_TYPE_UPDATE :if (xenfb->up_count ==UP_QUEUE ) xenfb->up_fullscreen =1 ;
Signature · 1 line
1.9.1
PATCH 7/35 virtio-9p: use accessor to get thread_pool
In reply to Michael RothFrom: Greg Kurz <[email protected]>
The aio_context_new() function does not allocate a thread pool. This is deferred to the first call to the aio_get_thread_pool() accessor. It is hence forbidden to access the thread_pool field directly, as it may be NULL. The accessor *must* be used always.
--- hw/9pfs/virtio-9p-coth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/9pfs/virtio-9p-coth.c +1 -1
@@ -36,6 +36,6 @@ static int coroutine_enter_func(void *arg)void co_run_in_worker_bh (void *opaque) {Coroutine *co = opaque; -thread_pool_submit_aio (qemu_get_aio_context ()->thread_pool, +thread_pool_submit_aio (aio_get_thread_pool (qemu_get_aio_context ()), coroutine_enter_func, co, coroutine_enter_cb, co); }
Signature · 1 line
1.9.1
PATCH 8/35 scsi: initialise info object with appropriate size
In reply to Michael RothFrom: P J P <[email protected]>
While processing controller 'CTRL_GET_INFO' command, the routine 'megasas_ctrl_get_info' overflows the '&info' object size. Use its appropriate size to null initialise it.
Message-Id: <alpine.LFD.2.20.1512211501420.22471@wniryva>
--- hw/scsi/megasas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/megasas.c +1 -1
@@ -718,7 +718,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd)BusChild *kid;int num_pd_disks =0 ; -memset (&info,0x0 , cmd->iov_size); +memset (&info,0x0 , dcmd_size);if (cmd->iov_size < dcmd_size) {trace_megasas_dcmd_invalid_xfer_len (cmd->index, cmd->iov_size, dcmd_size);
Signature · 1 line
1.9.1
PATCH 9/35 ivshmem: no need for opaque argument
In reply to Michael RothFrom: Marc-André Lureau <[email protected]>
*context dependency for 47213eb
--- hw/misc/ivshmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/misc/ivshmem.c +2 -2
@@ -350,11 +350,11 @@ static void ivshmem_vector_poll(PCIDevice *dev, } } -static CharDriverState *create_eventfd_chr_device (void * opaque,EventNotifier *n, +static CharDriverState *create_eventfd_chr_device (IVShmemState *s, +EventNotifier *n,int vector) {/* create a event character device based on the passed eventfd */ -IVShmemState *s = opaque;PCIDevice *pdev =PCI_DEVICE (s);int eventfd =event_notifier_get_fd (n);CharDriverState *chr;
Signature · 1 line
1.9.1
PATCH 10/35 ivshmem: remove redundant assignment, fix crash with msi=off
In reply to Michael RothFrom: Marc-André Lureau <[email protected]>
Fix crash when msi=false introduced in 660c97ee (msi_vectors is NULL in this case)
--- hw/misc/ivshmem.c | 3 --- 1 file changed, 3 deletions(-)
hw/misc/ivshmem.c +0 -3
@@ -355,12 +355,9 @@ static CharDriverState* create_eventfd_chr_device(IVShmemState *s, int vector) {/* create a event character device based on the passed eventfd */ -PCIDevice *pdev =PCI_DEVICE (s);int eventfd =event_notifier_get_fd (n);CharDriverState *chr; - s->msi_vectors[vector].pdev = pdev; - chr =qemu_chr_open_eventfd (eventfd);if (chr ==NULL ) {
Signature · 1 line
1.9.1
PATCH 11/35 net: rocker: fix an incorrect array bounds check
In reply to Michael RothFrom: Prasad J Pandit <[email protected]>
While processing transmit(tx) descriptors in 'tx_consume' routine the switch emulator suffers from an off-by-one error, if a descriptor was to have more than allowed(ROCKER_TX_FRAGS_MAX=16) fragments. Fix an incorrect bounds check to avoid it.
--- hw/net/rocker/rocker.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/net/rocker/rocker.c +4 -4
@@ -232,6 +232,9 @@ static int tx_consume(Rocker *r, DescInfo *info) frag_addr =rocker_tlv_get_le64 (tlvs[ROCKER_TLV_TX_FRAG_ATTR_ADDR ]); frag_len =rocker_tlv_get_le16 (tlvs[ROCKER_TLV_TX_FRAG_ATTR_LEN ]); +if (iovcnt >=ROCKER_TX_FRAGS_MAX ) { + goto err_too_many_frags; + } iov[iovcnt].iov_len = frag_len; iov[iovcnt].iov_base =g_malloc (frag_len);if (!iov[iovcnt].iov_base) {
@@ -244,10 +247,7 @@ static int tx_consume(Rocker *r, DescInfo *info) err = -ROCKER_ENXIO ; goto err_bad_io; } - -if (++iovcnt >ROCKER_TX_FRAGS_MAX ) { - goto err_too_many_frags; - } + iovcnt++; }if (iovcnt) {
Signature · 1 line
1.9.1
PATCH 12/35 block: Add blk_dev_has_tray()
In reply to Michael RothFrom: Max Reitz <[email protected]>
Pull out the check whether a block device has a tray from blk_dev_is_tray_open() into its own function so both attributes (whether there is a tray vs. whether that tray is open) can be queried independently.
Message-id: [email protected]
--- block/block-backend.c | 10 +++++++++- include/block/block_int.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-)
block/block-backend.c +9 -1
@@ -458,6 +458,14 @@ bool blk_dev_has_removable_media(BlockBackend *blk) }/* +* Does @blk's attached device model have a tray? +*/ +bool blk_dev_has_tray (BlockBackend *blk) +{ +return blk->dev_ops && blk->dev_ops->is_tray_open; +} + +/* * Notify @blk's attached device model of a media eject request. * If @force is true, the medium is about to be yanked out forcefully. */
@@ -473,7 +481,7 @@ void blk_dev_eject_request(BlockBackend *blk, bool force)*/ bool blk_dev_is_tray_open (BlockBackend *blk) { -if (blk->dev_ops && blk->dev_ops->is_tray_open) { +if (blk_dev_has_tray (blk)) {return blk->dev_ops->is_tray_open (blk->dev_opaque); }return false;
include/block/block_int.h +1 -0
@@ -686,6 +686,7 @@ void blk_set_bs(BlockBackend *blk, BlockDriverState *bs);void blk_dev_change_media_cb (BlockBackend *blk,bool load);bool blk_dev_has_removable_media (BlockBackend *blk); +bool blk_dev_has_tray (BlockBackend *blk);void blk_dev_eject_request (BlockBackend *blk,bool force);bool blk_dev_is_tray_open (BlockBackend *blk);bool blk_dev_is_medium_locked (BlockBackend *blk);
Signature · 1 line
1.9.1
PATCH 13/35 blockdev: Fix 'change' for slot devices
In reply to Michael RothFrom: Max Reitz <[email protected]>
'change' and related operations did not work when used on guest devices featuring removable media but no actual tray, because blk_dev_is_tray_open() always returned false for them and the blockdev-{insert,remove}-medium commands required it to return true.
Fix this by making blockdev-{insert,remove}-medium work on tray-less devices. Also, blockdev-{open,close}-tray are now explicitly no-ops when invoked on such devices, and blk_dev_change_media_cb() is instead called by blockdev-{insert,remove}-medium (for tray-less devices only).
Message-id: [email protected]
--- blockdev.c | 31 +++++++++++++++++++++++++++++-- qapi/block-core.json | 3 +-- 2 files changed, 30 insertions(+), 4 deletions(-)
blockdev.c +29 -2
@@ -2306,6 +2306,11 @@ void qmp_blockdev_open_tray(const char *device, bool has_force, bool force,return ; } +if (!blk_dev_has_tray (blk)) { +/* Ignore this command on tray-less devices */ +return ; + } +if (blk_dev_is_tray_open (blk)) {return ; }
@@ -2336,6 +2341,11 @@ void qmp_blockdev_close_tray(const char *device, Error **errp)return ; } +if (!blk_dev_has_tray (blk)) { +/* Ignore this command on tray-less devices */ +return ; + } +if (!blk_dev_is_tray_open (blk)) {return ; }
@@ -2365,7 +2375,7 @@ void qmp_x_blockdev_remove_medium(const char *device, Error **errp)return ; } -if (has_device && !blk_dev_is_tray_open (blk)) { +if (has_device &&blk_dev_has_tray (blk) && !blk_dev_is_tray_open (blk)) {error_setg (errp,"Tray of device '%s' is not open" , device);return ; }
@@ -2390,6 +2400,14 @@ void qmp_x_blockdev_remove_medium(const char *device, Error **errp)blk_remove_bs (blk); +if (!blk_dev_has_tray (blk)) { +/* For tray-less devices, blockdev-open-tray is a no-op (or may not be +* called at all); therefore, the medium needs to be ejected here. +* Do it after blk_remove_bs() so blk_is_inserted(blk) returns the @load +* value passed here (i.e. false). */ +blk_dev_change_media_cb (blk, false); + } + out:aio_context_release (aio_context); }
@@ -2415,7 +2433,7 @@ static void qmp_blockdev_insert_anon_medium(const char *device,return ; } -if (has_device && !blk_dev_is_tray_open (blk)) { +if (has_device &&blk_dev_has_tray (blk) && !blk_dev_is_tray_open (blk)) {error_setg (errp,"Tray of device '%s' is not open" , device);return ; }
@@ -2428,6 +2446,15 @@ static void qmp_blockdev_insert_anon_medium(const char *device,blk_insert_bs (blk, bs);QTAILQ_INSERT_TAIL (&bdrv_states, bs, device_list); + +if (!blk_dev_has_tray (blk)) { +/* For tray-less devices, blockdev-close-tray is a no-op (or may not be +* called at all); therefore, the medium needs to be pushed into the +* slot here. +* Do it after blk_insert_bs() so blk_is_inserted(blk) returns the @load +* value passed here (i.e. true). */ +blk_dev_change_media_cb (blk, true); + } } void qmp_x_blockdev_insert_medium(const char *device, const char *node_name,
qapi/block-core.json +1 -2
@@ -2048,8 +2048,7 @@ # respond to the eject request # - if the BlockBackend denoted by @device does not have a guest device attached # to it -# - if the guest device does not have an actual tray and is empty, for instance -# for floppy disk drives +# - if the guest device does not have an actual tray # # @device: block device name #
Signature · 1 line
1.9.1
PATCH 14/35 net/dump: fix nfds->filename leak
In reply to Michael RothFrom: Li Zhijian <[email protected]>
--- net/dump.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/dump.c +8 -0
@@ -329,6 +329,13 @@ static void filter_dump_instance_init(Object *obj) file_dump_set_filename, NULL); } +static void filter_dump_instance_finalize (Object *obj) +{ +NetFilterDumpState *nfds =FILTER_DUMP (obj); + +g_free (nfds->filename); +} +static void filter_dump_class_init (ObjectClass *oc,void *data) {NetFilterClass *nfc =NETFILTER_CLASS (oc);
@@ -343,6 +350,7 @@ static const TypeInfo filter_dump_info = { .parent = TYPE_NETFILTER, .class_init = filter_dump_class_init, .instance_init = filter_dump_instance_init, + .instance_finalize = filter_dump_instance_finalize, .instance_size = sizeof(NetFilterDumpState), };
Signature · 1 line
1.9.1
PATCH 15/35 net/filter: fix nf->netdev_id leak
In reply to Michael RothFrom: Li Zhijian <[email protected]>
--- net/filter.c | 1 + 1 file changed, 1 insertion(+)
net/filter.c +1 -0
@@ -204,6 +204,7 @@ static void netfilter_finalize(Object *obj)if (nf->netdev && !QTAILQ_EMPTY (&nf->netdev->filters)) {QTAILQ_REMOVE (&nf->netdev->filters, nf, next); } +g_free (nf->netdev_id); }static void netfilter_class_init (ObjectClass *oc,void *data)
Signature · 1 line
1.9.1
PATCH 16/35 net: ne2000: check ring buffer control registers
In reply to Michael RothFrom: Prasad J Pandit <[email protected]>
Ne2000 NIC uses ring buffer of NE2000_MEM_SIZE(49152) bytes to process network packets. Registers PSTART & PSTOP define ring buffer size & location. Setting these registers to invalid values could lead to infinite loop or OOB r/w access issues. Add check to avoid it.
--- hw/net/ne2000.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/net/ne2000.c +4 -0
@@ -154,6 +154,10 @@ static int ne2000_buffer_full(NE2000State *s) {int avail, index, boundary; +if (s->stop <= s->start) { +return 1 ; + } + index = s->curpag <<8 ; boundary = s->boundary <<8 ;if (index < boundary)
Signature · 1 line
1.9.1
PATCH 17/35 net: set endianness on all backend devices
In reply to Michael RothFrom: Laurent Vivier <[email protected]>
commit 5be7d9f1b1452613b95c6ba70b8d7ad3d0797991
vhost-net: tell tap backend about the vnet endianness
makes vhost net to set the endianness of the device, but only for the first device.
In case of multiqueue, we have multiple devices... This patch sets the endianness for all the devices of the interface.
--- hw/net/vhost_net.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
hw/net/vhost_net.c +11 -12
@@ -300,21 +300,19 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,BusState *qbus =BUS (qdev_get_parent_bus (DEVICE (dev)));VirtioBusState *vbus =VIRTIO_BUS (qbus);VirtioBusClass *k =VIRTIO_BUS_GET_CLASS (vbus); -int r, e, i; +int r, e, i, j;if (!k->set_guest_notifiers) {error_report ("binding does not support guest notifiers" ); - r = -ENOSYS ; - goto err; +return -ENOSYS ; } - r =vhost_net_set_vnet_endian (dev, ncs[0 ].peer, true); -if (r <0 ) { - goto err; - } - -for (i =0 ; i < total_queues; i++) { -vhost_net_set_vq_index (get_vhost_net (ncs[i].peer), i *2 ); +for (j =0 ; j < total_queues; j++) { + r =vhost_net_set_vnet_endian (dev, ncs[j].peer, true); +if (r <0 ) { + goto err_endian; + } +vhost_net_set_vq_index (get_vhost_net (ncs[j].peer), j *2 ); } r = k->set_guest_notifiers (qbus->parent, total_queues *2 , true);
@@ -343,8 +341,9 @@ err_start:fflush (stderr); } err_endian: -vhost_net_set_vnet_endian (dev, ncs[0 ].peer, false); -err: +while (--j >=0 ) { +vhost_net_set_vnet_endian (dev, ncs[j].peer, false); + }return r; }
Signature · 1 line
1.9.1
PATCH 18/35 ehci: update irq on reset
In reply to Michael RothFrom: Gerd Hoffmann <[email protected]>
After clearing the status register we also have to update the irq line status. Otherwise a irq which happends to be pending at reset time causes a interrupt storm. And the guest can't stop as the status register doesn't indicate any pending interrupt.
Both NetBSD and FreeBSD hang on shutdown because of that.
Message-id: [email protected]
--- hw/usb/hcd-ehci.c | 1 + 1 file changed, 1 insertion(+)
hw/usb/hcd-ehci.c +1 -0
@@ -865,6 +865,7 @@ void ehci_reset(void *opaque) s->usbsts =USBSTS_HALT ; s->usbsts_pending =0 ; s->usbsts_frindex =0 ; +ehci_update_irq (s); s->astate =EST_INACTIVE ; s->pstate =EST_INACTIVE ;
Signature · 1 line
1.9.1
PATCH 19/35 block/raw-posix: avoid bogus fixup for cylinders on DASD disks
In reply to Michael RothFrom: Christian Borntraeger <[email protected]>
large volume DASD that have > 64k cylinders do claim to have 0xFFFE cylinders as special value in the old 16 bit field. We want to pass this "token" along to the guest, instead of calculating the real number. Otherwise qemu might fail with "cyls must be between 1 and 65535"
--- block/raw-posix.c | 7 ------- 1 file changed, 7 deletions(-)
block/raw-posix.c +0 -7
@@ -783,7 +783,6 @@ static int hdev_probe_geometry(BlockDriverState *bs, HDGeometry *geo) {BDRVRawState *s = bs->opaque;struct hd_geometry ioctl_geo = {0 }; -uint32_t blksize;/* If DASD, get its geometry */ if (check_for_dasd (s->fd) <0 ) {
@@ -803,12 +802,6 @@ static int hdev_probe_geometry(BlockDriverState *bs, HDGeometry *geo) } geo->heads = ioctl_geo.heads; geo->sectors = ioctl_geo.sectors; -if (!probe_physical_blocksize (s->fd, &blksize)) { -/* overwrite cyls: HDIO_GETGEO result is incorrect for big drives */ - geo->cylinders =bdrv_nb_sectors (bs) / (blksize /BDRV_SECTOR_SIZE ) - / (geo->heads * geo->sectors); -return 0 ; - } geo->cylinders = ioctl_geo.cylinders;return 0 ;
Signature · 1 line
1.9.1
PATCH 20/35 s390x/ioinst: set type and len for SEI response
In reply to Michael RothFrom: Pierre Morel <[email protected]>
If no event information is pending, the return code is set to 0x0005 and the length of the response is set to 8 bytes.
--- target-s390x/ioinst.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
target-s390x/ioinst.c +2 -1
@@ -616,7 +616,8 @@ static void ioinst_handle_chsc_sei(ChscReq *req, ChscResp *res) (*res_flags) &= ~0x80 ; } }else { - res->code =cpu_to_be16 (0x0004 ); + res->code =cpu_to_be16 (0x0005 ); + res->len =cpu_to_be16 (CHSC_MIN_RESP_LEN ); } }
Signature · 1 line
1.9.1
PATCH 21/35 s390x/css: fix control flags during csch
In reply to Michael RothFrom: Halil Pasic <[email protected]>
Quoted 1 line
From the beginning, css support contained an error in csch handling:
instead of setting the clear bit in the function control bits twice, we need to set the clear pending bit in the activity control bits. Let's fix this.
--- hw/s390x/css.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/s390x/css.c +1 -1
@@ -701,7 +701,7 @@ int css_do_csch(SubchDev *sch)/* Trigger the clear function. */ s->ctrl &= ~(SCSW_CTRL_MASK_FCTL |SCSW_CTRL_MASK_ACTL ); - s->ctrl |=SCSW_FCTL_CLEAR_FUNC |SCSW_FCTL_CLEAR_FUNC ; + s->ctrl |=SCSW_FCTL_CLEAR_FUNC |SCSW_ACTL_CLEAR_PEND ;do_subchannel_work (sch,NULL ); ret =0 ;
Signature · 1 line
1.9.1
PATCH 22/35 fw_cfg: avoid calculating invalid current entry pointer
In reply to Michael RothFrom: "Gabriel L. Somlo" <[email protected]>
When calculating a pointer to the currently selected fw_cfg item, the following is used:
FWCfgEntry *e = &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];
When s->cur_entry is FW_CFG_INVALID, we are calculating the address of a non-existent element in s->entries[arch][...], which is undefined.
This patch ensures the resulting entry pointer is set to NULL whenever s->cur_entry is FW_CFG_INVALID.
Message-id: [email protected]
--- hw/nvram/fw_cfg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/nvram/fw_cfg.c +4 -2
@@ -270,7 +270,8 @@ static int fw_cfg_select(FWCfgState *s, uint16_t key)static uint8_t fw_cfg_read (FWCfgState *s) {int arch = !!(s->cur_entry &FW_CFG_ARCH_LOCAL ); -FWCfgEntry *e = &s->entries[arch][s->cur_entry &FW_CFG_ENTRY_MASK ]; +FWCfgEntry *e = (s->cur_entry ==FW_CFG_INVALID ) ?NULL : + &s->entries[arch][s->cur_entry &FW_CFG_ENTRY_MASK ];uint8_t ret;if (s->cur_entry ==FW_CFG_INVALID || !e->data || s->cur_offset >= e->len)
@@ -338,7 +339,8 @@ static void fw_cfg_dma_transfer(FWCfgState *s) } arch = !!(s->cur_entry &FW_CFG_ARCH_LOCAL ); - e = &s->entries[arch][s->cur_entry &FW_CFG_ENTRY_MASK ]; + e = (s->cur_entry ==FW_CFG_INVALID ) ?NULL : + &s->entries[arch][s->cur_entry &FW_CFG_ENTRY_MASK ];if (dma.control &FW_CFG_DMA_CTL_READ ) { read =1 ;
Signature · 1 line
1.9.1
PATCH 23/35 cpus: use broadcast on qemu_pause_cond
In reply to Michael RothFrom: "Dr. David Alan Gilbert" <[email protected]>
Jiri saw a hang on pause_all_vcpus called from postcopy_start, where the cpus are all apparently stopped ('stopped' flag set) but pause_all_vcpus is still stuck on a cond_wait on qemu_paused_cond. We suspect this is happening if a qmp_stop is called at about the same time as the postcopy code calls that pause_all_vcpus; although they both should have the main lock held, Paolo spotted the cond_wait unlocks the global lock so perhaps they both could end up waiting at the same time?
Message-Id: <[email protected]>
--- cpus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
cpus.c +2 -2
@@ -986,7 +986,7 @@ static void qemu_wait_io_event_common(CPUState *cpu)if (cpu->stop) { cpu->stop = false; cpu->stopped = true; -qemu_cond_signal (&qemu_pause_cond); +qemu_cond_broadcast (&qemu_pause_cond); }flush_queued_work (cpu); cpu->thread_kicked = false;
@@ -1387,7 +1387,7 @@ void cpu_stop_current(void) current_cpu->stop = false; current_cpu->stopped = true;cpu_exit (current_cpu); -qemu_cond_signal (&qemu_pause_cond); +qemu_cond_broadcast (&qemu_pause_cond); } }
Signature · 1 line
1.9.1
PATCH 24/35 qmp: Fix reference-counting of qnull on empty output visit
In reply to Michael RothFrom: Eric Blake <[email protected]>
Commit 6c2f9a15 ensured that we would not return NULL when the caller used an output visitor but had nothing to visit. But in doing so, it added a FIXME about a reference count leak that could abort qemu in the (unlikely) case of SIZE_MAX such visits (more plausible on 32-bit). (Although that commit suggested we might fix it in time for 2.5, we ran out of time; fortunately, it is unlikely enough to bite that it was not worth worrying about during the 2.5 release.)
This fixes things by documenting the internal contracts, and explaining why the internal function can return NULL and only the public facing interface needs to worry about qnull(), thus avoiding over-referencing the qnull_ global object.
It does not, however, fix the stupidity of the stack mixing up two separate pieces of information; add a FIXME to explain that issue, which will be fixed shortly in a future patch.
Message-Id: <[email protected]>
--- qapi/qmp-output-visitor.c | 41 ++++++++++++++++++++++++++++++++++------- tests/test-qmp-output-visitor.c | 2 ++ 2 files changed, 36 insertions(+), 7 deletions(-)
qapi/qmp-output-visitor.c +34 -7
@@ -29,6 +29,15 @@ typedef QTAILQ_HEAD(QStack, QStackEntry) QStack;struct QmpOutputVisitor {Visitor visitor; +/* FIXME: we are abusing stack to hold two separate pieces of +* information: the current root object in slot 0, and the stack +* of N objects still being built in slots 1 through N (for N+1 +* slots in use). Worse, our behavior is inconsistent: +* qmp_output_add_obj() visiting two top-level scalars in a row +* discards the first in favor of the second, but visiting two +* top-level objects in a row tries to append the second object +* into the first (since the first object was placed in the stack +* in both slot 0 and 1, but only popped from slot 1). */ QStack stack; };
@@ -41,10 +50,12 @@ static QmpOutputVisitor *to_qov(Visitor *v)return container_of (v, QmpOutputVisitor, visitor); } +/* Push @value onto the stack of current QObjects being built */ static void qmp_output_push_obj (QmpOutputVisitor *qov,QObject *value) {QStackEntry *e =g_malloc0 (sizeof (*e)); +assert (value); e->value = value;if (qobject_type (e->value) ==QTYPE_QLIST ) { e->is_list_head = true;
@@ -52,44 +63,53 @@ static void qmp_output_push_obj(QmpOutputVisitor *qov, QObject *value)QTAILQ_INSERT_HEAD (&qov->stack, e, node); } +/* Pop a value off the stack of QObjects being built, and return it. */ static QObject *qmp_output_pop (QmpOutputVisitor *qov) {QStackEntry *e =QTAILQ_FIRST (&qov->stack);QObject *value; + +assert (e);QTAILQ_REMOVE (&qov->stack, e, node); value = e->value; +assert (value);g_free (e);return value; } +/* Grab the root QObject, if any */ static QObject *qmp_output_first (QmpOutputVisitor *qov) {QStackEntry *e =QTAILQ_LAST (&qov->stack, QStack); -/* -* FIXME Wrong, because qmp_output_get_qobject() will increment -* the refcnt *again*. We need to think through how visitors -* handle null. -*/ if (!e) { -return qnull (); +/* No root */ +return NULL ; } - +assert (e->value);return e->value; } +/* Peek at the top of the stack of QObjects being built. +* The stack must not be empty. */ static QObject *qmp_output_last (QmpOutputVisitor *qov) {QStackEntry *e =QTAILQ_FIRST (&qov->stack); + +assert (e && e->value);return e->value; } +/* Add @value to the current QObject being built. +* If the stack is visiting a dictionary or list, @value is now owned +* by that container. Otherwise, @value is now the root. */ static void qmp_output_add_obj (QmpOutputVisitor *qov,const char *name,QObject *value) {QObject *cur;if (QTAILQ_EMPTY (&qov->stack)) { +/* Stack was empty, track this object as root */ qmp_output_push_obj (qov, value);return ; }
@@ -98,13 +118,17 @@ static void qmp_output_add_obj(QmpOutputVisitor *qov, const char *name,switch (qobject_type (cur)) {case QTYPE_QDICT : +assert (name);qdict_put_obj (qobject_to_qdict (cur), name, value);break ;case QTYPE_QLIST :qlist_append_obj (qobject_to_qlist (cur), value);break ;default : +/* The previous root was a scalar, replace it with a new root */ +/* FIXME this is abusing the stack; see comment above */ qobject_decref (qmp_output_pop (qov)); +assert (QTAILQ_EMPTY (&qov->stack));qmp_output_push_obj (qov, value);break ; }
@@ -198,11 +222,14 @@ static void qmp_output_type_any(Visitor *v, QObject **obj, const char *name,qmp_output_add_obj (qov, name, *obj); } +/* Finish building, and return the root object. Will not be NULL. */ QObject *qmp_output_get_qobject (QmpOutputVisitor *qov) {QObject *obj =qmp_output_first (qov);if (obj) {qobject_incref (obj); + }else { + obj =qnull (); }return obj; }
tests/test-qmp-output-visitor.c +2 -0
@@ -461,6 +461,8 @@ static void test_visitor_out_empty(TestOutputVisitorData *data, arg =qmp_output_get_qobject (data->qov);g_assert (qobject_type (arg) ==QTYPE_QNULL ); +/* Check that qnull reference counting is sane */ +g_assert (arg->refcnt ==2 );qobject_decref (arg); }
Signature · 1 line
1.9.1
PATCH 25/35 block: set device_list.tqe_prev to NULL on BDS removal
In reply to Michael RothFrom: Jeff Cody <[email protected]>
This fixes a regression introduced with commit 3f09bfbc7. Multiple bugs arise in conjunction with live snapshots and mirroring operations (which include active layer commit).
After a live snapshot occurs, the active layer and the base layer both have a non-NULL tqe_prev field in the device_list, although the base node's tqe_prev field points to a NULL entry. This non-NULL tqe_prev field occurs after the bdrv_append() in the external snapshot calls change_parent_backing_link().
In change_parent_backing_link(), when the previous active layer is removed from device_list, the device_list.tqe_prev pointer is not set to NULL.
The operating scheme in the block layer is to indicate that a BDS belongs in the bdrv_states device_list iff the device_list.tqe_prev pointer is non-NULL.
This patch does two things:
1.) Introduces a new block layer helper bdrv_device_remove() to remove a
BDS from the device_list, and
2.) uses that new API, which also fixes the regression once used in
change_parent_backing_link().
Message-id: 0cd51e11c0666c04ddb7c05293fe94afeb551e89.1454376655.git.jcody@redhat.com
--- block.c | 24 ++++++++++++++---------- blockdev.c | 3 +-- include/block/block.h | 1 + 3 files changed, 16 insertions(+), 12 deletions(-)
block.c +14 -10
@@ -1976,21 +1976,25 @@ void bdrv_close_all(void) } } +/* Note that bs->device_list.tqe_prev is initially null, +* and gets set to non-null by QTAILQ_INSERT_TAIL(). Establish +* the useful invariant "bs in bdrv_states iff bs->tqe_prev" by +* resetting it to null on remove. */ +void bdrv_device_remove (BlockDriverState *bs) +{ +QTAILQ_REMOVE (&bdrv_states, bs, device_list); + bs->device_list.tqe_prev =NULL ; +} +/* make a BlockDriverState anonymous by removing from bdrv_state and * graph_bdrv_state list. Also, NULL terminate the device_name to prevent double remove */ void bdrv_make_anon (BlockDriverState *bs) { -/* -* Take care to remove bs from bdrv_states only when it's actually -* in it. Note that bs->device_list.tqe_prev is initially null, -* and gets set to non-null by QTAILQ_INSERT_TAIL(). Establish -* the useful invariant "bs in bdrv_states iff bs->tqe_prev" by -* resetting it to null on remove. -*/ +/* Take care to remove bs from bdrv_states only when it's actually +* in it. */ if (bs->device_list.tqe_prev) { -QTAILQ_REMOVE (&bdrv_states, bs, device_list); - bs->device_list.tqe_prev =NULL ; +bdrv_device_remove (bs); }if (bs->node_name[0 ] !='\0' ) {QTAILQ_REMOVE (&graph_bdrv_states, bs, node_list);
@@ -2031,7 +2035,7 @@ static void change_parent_backing_link(BlockDriverState *from,if (!to->device_list.tqe_prev) {QTAILQ_INSERT_BEFORE (from, to, device_list); } -QTAILQ_REMOVE (&bdrv_states, from, device_list); +bdrv_device_remove (from); } }
blockdev.c +1 -2
@@ -2394,8 +2394,7 @@ void qmp_x_blockdev_remove_medium(const char *device, Error **errp)/* This follows the convention established by bdrv_make_anon() */ if (bs->device_list.tqe_prev) { -QTAILQ_REMOVE (&bdrv_states, bs, device_list); - bs->device_list.tqe_prev =NULL ; +bdrv_device_remove (bs); }blk_remove_bs (blk);
include/block/block.h +1 -0
@@ -196,6 +196,7 @@ int bdrv_create(BlockDriver *drv, const char* filename,int bdrv_create_file (const char *filename,QemuOpts *opts,Error **errp);BlockDriverState *bdrv_new_root (void );BlockDriverState *bdrv_new (void ); +void bdrv_device_remove (BlockDriverState *bs);void bdrv_make_anon (BlockDriverState *bs);void bdrv_swap (BlockDriverState *bs_new,BlockDriverState *bs_old);void bdrv_append (BlockDriverState *bs_new,BlockDriverState *bs_top);
Signature · 1 line
1.9.1
PATCH 26/35 block: qemu-iotests - add test for snapshot, commit, snapshot bug
In reply to Michael RothFrom: Jeff Cody <[email protected]>
Message-id: 2dbc05efba2f683cb3aaf71aaa9b776ebf7ec57c.1454376655.git.jcody@redhat.com
(cherry picked from commit 8983b670f62ab5e5e8dd2690bf8304123651bfe5)
Conflicts:
tests/qemu-iotests/group
*removed context dependencies on newer test groups
--- tests/qemu-iotests/144 | 114 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/144.out | 24 ++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 139 insertions(+) create mode 100755 tests/qemu-iotests/144 create mode 100644 tests/qemu-iotests/144.out
tests/qemu-iotests/144 new file +114 -0
@@ -0,0 +1,114 @@ +#!/bin/bash +# Check live snapshot, followed by active commit, and another snapshot. +# +# This test is to catch the error case of BZ #1300209: +# https://bugzilla.redhat.com/show_bug.cgi?id=1300209 +# +# Copyright (C) 2016 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# creator [email protected] + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +status=1 # failure is the default! + +TMP_SNAP1=${TEST_DIR}/tmp.qcow2 +TMP_SNAP2=${TEST_DIR}/tmp2.qcow2 + +_cleanup() +{ + _cleanup_qemu + rm -f "${TEST_IMG}" "${TMP_SNAP1}" "${TMP_SNAP2}" +} + +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +size=512M + +_make_test_img $size + +echo +echo === Launching QEMU === +echo + +qemu_comm_method="qmp" +_launch_qemu -drive file="${TEST_IMG}",if=virtio +h=$QEMU_HANDLE + + +echo +echo === Performing Live Snapshot 1 === +echo + +_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return" + + +# First live snapshot, new overlay as active layer +_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot-sync', + 'arguments': { + 'device': 'virtio0', + 'snapshot-file':'${TMP_SNAP1}', + 'format': 'qcow2' + } + }" "return" + +echo +echo === Performing block-commit on active layer === +echo + +# Block commit on active layer, push the new overlay into base +_send_qemu_cmd $h "{ 'execute': 'block-commit', + 'arguments': { + 'device': 'virtio0' + } + }" "READY" + +_send_qemu_cmd $h "{ 'execute': 'block-job-complete', + 'arguments': { + 'device': 'virtio0' + } + }" "COMPLETED" + +echo +echo === Performing Live Snapshot 2 === +echo + +# New live snapshot, new overlays as active layer +_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot-sync', + 'arguments': { + 'device': 'virtio0', + 'snapshot-file':'${TMP_SNAP2}', + 'format': 'qcow2' + } + }" "return" + +# success, all done +echo "*** done" +rm -f $seq.full +status=0
tests/qemu-iotests/144.out new file +24 -0
@@ -0,0 +1,24 @@ +QA output created by 144 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=536870912 + +=== Launching QEMU === + + +=== Performing Live Snapshot 1 === + +{"return": {}} +Formatting 'TEST_DIR/tmp.qcow2', fmt=qcow2 size=536870912 backing_file=TEST_DIR/t.qcow2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 +{"return": {}} + +=== Performing block-commit on active layer === + +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "virtio0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "virtio0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} + +=== Performing Live Snapshot 2 === + +Formatting 'TEST_DIR/tmp2.qcow2', fmt=qcow2 size=536870912 backing_file=TEST_DIR/t.qcow2 backing_fmt=qcow2 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 +{"return": {}} +*** done
tests/qemu-iotests/group +1 -0
@@ -140,3 +140,4 @@ 137 rw auto 138 rw auto quick 139 rw auto quick +144 rw auto quick
Signature · 1 line
1.9.1
PATCH 27/35 e1000: eliminate infinite loops on out-of-bounds transfer start
In reply to Michael RothFrom: Laszlo Ersek <[email protected]>
The start_xmit() and e1000_receive_iov() functions implement DMA transfers iterating over a set of descriptors that the guest's e1000 driver prepares:
- the TDLEN and RDLEN registers store the total size of the descriptor area,
- while the TDH and RDH registers store the offset (in whole tx / rx descriptors) into the area where the transfer is supposed to start.
Each time a descriptor is processed, the TDH and RDH register is bumped (as appropriate for the transfer direction).
QEMU already contains logic to deal with bogus transfers submitted by the guest:
- Normally, the transmit case wants to increase TDH from its initial value to TDT. (TDT is allowed to be numerically smaller than the initial TDH value; wrapping at or above TDLEN bytes to zero is normal.) The failsafe that QEMU currently has here is a check against reaching the original TDH value again -- a complete wraparound, which should never happen.
- In the receive case RDH is increased from its initial value until "total_size" bytes have been received; preferably in a single step, or in "s->rxbuf_size" byte steps, if the latter is smaller. However, null RX descriptors are skipped without receiving data, while RDH is incremented just the same. QEMU tries to prevent an infinite loop (processing only null RX descriptors) by detecting whether RDH assumes its original value during the loop. (Again, wrapping from RDLEN to 0 is normal.)
What both directions miss is that the guest could program TDLEN and RDLEN so low, and the initial TDH and RDH so high, that these registers will immediately be truncated to zero, and then never reassume their initial values in the loop -- a full wraparound will never occur.
The condition that expresses this is:
xdh_start >= s->mac_reg[XDLEN] / sizeof(desc)
i.e., TDH or RDH start out after the last whole rx or tx descriptor that fits into the TDLEN or RDLEN sized area.
This condition could be checked before we enter the loops, but pci_dma_read() / pci_dma_write() knows how to fill in buffers safely for bogus DMA addresses, so we just extend the existing failsafes with the above condition.
This is CVE-2016-1981.
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Petr Matousek <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Prasad Pandit <[email protected]>
Cc: Michael Roth <[email protected]>
Cc: Jason Wang <[email protected]>
Cc: [email protected]
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1296044
--- hw/net/e1000.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/net/e1000.c +4 -2
@@ -908,7 +908,8 @@ start_xmit(E1000State *s)* bogus values to TDT/TDLEN. * there's nothing too intelligent we could do about this. */ -if (s->mac_reg[TDH ] == tdh_start) { +if (s->mac_reg[TDH ] == tdh_start || + tdh_start >= s->mac_reg[TDLEN ] /sizeof (desc)) {DBGOUT (TXERR ,"TDH wraparound @%x, TDT %x, TDLEN %x\n" , tdh_start, s->mac_reg[TDT ], s->mac_reg[TDLEN ]);break ;
@@ -1165,7 +1166,8 @@ e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt)if (++s->mac_reg[RDH ] *sizeof (desc) >= s->mac_reg[RDLEN ]) s->mac_reg[RDH ] =0 ;/* see comment in start_xmit; same here */ -if (s->mac_reg[RDH ] == rdh_start) { +if (s->mac_reg[RDH ] == rdh_start || + rdh_start >= s->mac_reg[RDLEN ] /sizeof (desc)) {DBGOUT (RXERR ,"RDH wraparound @%x, RDT %x, RDLEN %x\n" , rdh_start, s->mac_reg[RDT ], s->mac_reg[RDLEN ]);set_ics (s,0 ,E1000_ICS_RXO );
Signature · 1 line
1.9.1
PATCH 28/35 spapr: skip configuration section during migration of older machines
In reply to Michael RothFrom: Greg Kurz <[email protected]>
Since QEMU 2.4, we have a configuration section in the migration stream. This must be skipped for older machines, like it is already done for x86.
This patch fixes the migration of pseries-2.3 from/to QEMU 2.3, but it breaks migration of the same machine from/to QEMU 2.4/2.4.1/2.5. We do that anyway because QEMU 2.3 is likely to be more widely deployed than newer QEMU versions.
Conflicts:
hw/ppc/spapr.c
*remove dep on 5013c5474
--- hw/ppc/spapr.c | 1 + 1 file changed, 1 insertion(+)
hw/ppc/spapr.c +1 -0
@@ -2327,6 +2327,7 @@ static void spapr_compat_2_3(Object *obj) {savevm_skip_section_footers ();global_state_set_optional (); +savevm_skip_configuration (); }static void spapr_compat_2_2 (Object *obj)
Signature · 1 line
1.9.1
Re: [Qemu-devel] [Qemu-stable] [PATCH 28/35] spapr: skip configuration section during migration of older machines
Quoted 17 lines · On Mon, 21 Mar 2016 12:28:26 -0500 Michael Roth <[email protected]>…
From: Greg Kurz <[email protected]>
Since QEMU 2.4, we have a configuration section in the migration stream. This must be skipped for older machines, like it is already done for x86.
This patch fixes the migration of pseries-2.3 from/to QEMU 2.3, but it breaks migration of the same machine from/to QEMU 2.4/2.4.1/2.5. We do that anyway because QEMU 2.3 is likely to be more widely deployed than newer QEMU versions.
Fixes 61964c23e5ddd5a33f15699e45ce126f879e3e33Signed-off-by Greg Kurz <[email protected]>Reviewed-by Laurent Vivier <[email protected]>Reviewed-by Juan Quintela <[email protected]>Signed-off-by David Gibson <[email protected]>(cherry picked from commit 09b5e30da5b19f44768a5429f603caaede216757)
Quoted 7 lines
Conflicts:
hw/ppc/spapr.c*remove dep on
5013c5474Signed-off-by Michael Roth <[email protected]>---
This will break migration of pseries-2.3 from QEMU 2.5 to QEMU 2.5.1. Maybe this should be documented somewhere ?
Also, there's a companion patch to allow migration to succeed with manual intervention on the destination:
commit 902c053d834e3b802ec736f170edf226d4a841ff
Author: Greg Kurz <[email protected]> Date: Thu Feb 18 12:32:25 2016 +0100
migration: allow machine to enforce configuration section migration
Maybe worth to push to stable as well ?
Quoted 15 lines
hw/ppc/spapr.c | 1 + 1 file changed, 1 insertion(+)hw/ppc/spapr.c +1
-0@@ -2327,6 +2327,7 @@ static void spapr_compat_2_3(Object *obj) {savevm_skip_section_footers ();global_state_set_optional (); +savevm_skip_configuration (); }static void spapr_compat_2_2 (Object *obj)
Re: [Qemu-devel] [Qemu-stable] [PATCH 28/35] spapr: skip configuration section during migration of older machines
Quoting Greg Kurz (2016-03-22 02:49:35)
Quoted 34 lines
Quoted 17 lines · On Mon, 21 Mar 2016 12:28:26 -0500 Michael Roth <[email protected]>…
From: Greg Kurz <[email protected]>
Since QEMU 2.4, we have a configuration section in the migration stream. This must be skipped for older machines, like it is already done for x86.
This patch fixes the migration of pseries-2.3 from/to QEMU 2.3, but it breaks migration of the same machine from/to QEMU 2.4/2.4.1/2.5. We do that anyway because QEMU 2.3 is likely to be more widely deployed than newer QEMU versions.
Fixes 61964c23e5ddd5a33f15699e45ce126f879e3e33Signed-off-by Greg Kurz <[email protected]>Reviewed-by Laurent Vivier <[email protected]>Reviewed-by Juan Quintela <[email protected]>Signed-off-by David Gibson <[email protected]>(cherry picked from commit 09b5e30da5b19f44768a5429f603caaede216757)Quoted 7 lines
Conflicts:
hw/ppc/spapr.c*remove dep on
5013c5474Signed-off-by Michael Roth <[email protected]>---
This will break migration of pseries-2.3 from QEMU 2.5 to QEMU 2.5.1. Maybe this should be documented somewhere ?
Also, there's a companion patch to allow migration to succeed with manual intervention on the destination:
Quoted 7 lines
commit
902c053d834e3b802ec736f170edf226d4a841ffAuthor: Greg Kurz <[email protected]> Date: Thu Feb 18 12:32:25 2016 +0100migration: allow machine to enforce configuration section migration
Maybe worth to push to stable as well ?
Yah, makes sense. I'll include this patch and document compatibility changes in the release notes.
Is this wording correct?
"Fixes migration between QEMU 2.3 and QEMU 2.5.1 when running pseries-2.3 machine model. Note that for migration of same pseries-2.3 machine to/from QEMU versions 2.4.x and 2.5, the -machine enforce-config-section=on option now needs to be used."
Quoted 17 lines
Quoted 16 lines
hw/ppc/spapr.c | 1 + 1 file changed, 1 insertion(+)hw/ppc/spapr.c +1
-0@@ -2327,6 +2327,7 @@ static void spapr_compat_2_3(Object *obj) {savevm_skip_section_footers ();global_state_set_optional (); +savevm_skip_configuration (); }static void spapr_compat_2_2 (Object *obj)
Re: [Qemu-devel] [Qemu-stable] [PATCH 28/35] spapr: skip configuration section during migration of older machines
Quoted 46 lines · On Tue, 22 Mar 2016 17:35:18 -0500 Michael Roth <[email protected]>…
Quoting Greg Kurz (2016-03-22 02:49:35)
Quoted 34 lines
Quoted 17 lines · On Mon, 21 Mar 2016 12:28:26 -0500 Michael Roth <[email protected]>…
From: Greg Kurz <[email protected]>
Since QEMU 2.4, we have a configuration section in the migration stream. This must be skipped for older machines, like it is already done for x86.
This patch fixes the migration of pseries-2.3 from/to QEMU 2.3, but it breaks migration of the same machine from/to QEMU 2.4/2.4.1/2.5. We do that anyway because QEMU 2.3 is likely to be more widely deployed than newer QEMU versions.
Fixes 61964c23e5ddd5a33f15699e45ce126f879e3e33Signed-off-by Greg Kurz <[email protected]>Reviewed-by Laurent Vivier <[email protected]>Reviewed-by Juan Quintela <[email protected]>Signed-off-by David Gibson <[email protected]>(cherry picked from commit 09b5e30da5b19f44768a5429f603caaede216757)Quoted 7 lines
Conflicts:
hw/ppc/spapr.c*remove dep on
5013c5474Signed-off-by Michael Roth <[email protected]>---
This will break migration of pseries-2.3 from QEMU 2.5 to QEMU 2.5.1. Maybe this should be documented somewhere ?
Also, there's a companion patch to allow migration to succeed with manual intervention on the destination:
Quoted 7 lines
commit
902c053d834e3b802ec736f170edf226d4a841ffAuthor: Greg Kurz <[email protected]> Date: Thu Feb 18 12:32:25 2016 +0100migration: allow machine to enforce configuration section migration
Maybe worth to push to stable as well ?
Yah, makes sense. I'll include this patch and document compatibility changes in the release notes.
Quoted 8 lines
Is this wording correct?
"Fixes migration between QEMU 2.3 and QEMU 2.5.1 when running pseries-2.3 machine model. Note that for migration of same pseries-2.3 machine to/from QEMU versions 2.4.x and 2.5, the -machine enforce-config-section=on option now needs to be used."
Of course this is also the case for older pseries (< 2.3) but the wording is correct.
Thanks !
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
hw/ppc/spapr.c | 1 + 1 file changed, 1 insertion(+)hw/ppc/spapr.c +1
-0@@ -2327,6 +2327,7 @@ static void spapr_compat_2_3(Object *obj) {savevm_skip_section_footers ();global_state_set_optional (); +savevm_skip_configuration (); }static void spapr_compat_2_2 (Object *obj)
PATCH 29/35 hw/virtio: fix double use of a virtio flag
In reply to Michael RothFrom: Marcel Apfelbaum <[email protected]>
Commits 1811e64c and a6df8adf use the same virtio feature bit 4 for different features.
Fix it by using different bits.
--- hw/virtio/virtio-pci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio-pci.h +1 -1
@@ -72,7 +72,7 @@ typedef struct VirtioBusClass VirtioPCIBusClass;/* virtio version flags */ #define VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT 2#define VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT 3 -#define VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT 4 +#define VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT 6#define VIRTIO_PCI_FLAG_DISABLE_LEGACY (1 << VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT)#define VIRTIO_PCI_FLAG_DISABLE_MODERN (1 << VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT)#define VIRTIO_PCI_FLAG_DISABLE_PCIE (1 << VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT)
Signature · 1 line
1.9.1
PATCH 30/35 hw/virtio: group virtio flags into an enum
In reply to Michael RothFrom: Marcel Apfelbaum <[email protected]>
Minimizes the possibility to assign
the same bit to different features.
--- hw/virtio/virtio-pci.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
hw/virtio/virtio-pci.h +10 -7
@@ -59,30 +59,33 @@ typedef struct VirtioBusClass VirtioPCIBusClass;#define VIRTIO_PCI_BUS_CLASS (klass) \ OBJECT_CLASS_CHECK(VirtioPCIBusClass, klass, TYPE_VIRTIO_PCI_BUS) +enum { +VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION_BIT , +VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT , +VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT , +VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT , +VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT , +VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT , +VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT , +}; +/* Need to activate work-arounds for buggy guests at vmstate load. */ -#define VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION_BIT 0#define VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION \ (1 << VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION_BIT)/* Performance improves when virtqueue kick processing is decoupled from the * vcpu thread using ioeventfd for some devices. */ -#define VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT 1#define VIRTIO_PCI_FLAG_USE_IOEVENTFD (1 << VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT)/* virtio version flags */ -#define VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT 2 -#define VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT 3 -#define VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT 6#define VIRTIO_PCI_FLAG_DISABLE_LEGACY (1 << VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT)#define VIRTIO_PCI_FLAG_DISABLE_MODERN (1 << VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT)#define VIRTIO_PCI_FLAG_DISABLE_PCIE (1 << VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT)/* migrate extra state */ -#define VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT 4#define VIRTIO_PCI_FLAG_MIGRATE_EXTRA (1 << VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT)/* have pio notification for modern device ? */ -#define VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT 5#define VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY \ (1 << VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT)
Signature · 1 line
1.9.1
PATCH 31/35 fw_cfg: unbreak migration compatibility for 2.4 and earlier machines
In reply to Michael RothFrom: Laszlo Ersek <[email protected]>
When I reviewed Marc's fw_cfg DMA patches, I completely missed that the way we set dma_enabled would break migration.
Gerd explained the right way (see reference below): dma_enabled should be set to true by default, and only true->false transitions should be possible:
- when the user requests that with
-global fw_cfg_mem.dma_enabled=off
or
-global fw_cfg_io.dma_enabled=off
as appropriate for the platform,
- when HW_COMPAT_2_4 dictates it,
- when board code initializes fw_cfg without requesting DMA support.
Cc: Marc Marí <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Alexandre DERUMIER <[email protected]>
Cc: [email protected]
Ref: http://thread.gmane.org/gmane.comp.emulators.qemu/390272/focus=391042
Ref: https://bugs.launchpad.net/qemu/+bug/1536487
Message-id: [email protected]
Conflicts:
include/hw/compat.h
* remove cosmetic dep on c9c0afbb
--- hw/nvram/fw_cfg.c | 20 ++++++++++++-------- include/hw/compat.h | 8 ++++++++ 2 files changed, 20 insertions(+), 8 deletions(-)
hw/nvram/fw_cfg.c +12 -8
@@ -782,17 +782,19 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase,DeviceState *dev;FWCfgState *s;uint32_t version =FW_CFG_VERSION ; -bool dma_enabled = dma_iobase && dma_as; +bool dma_requested = dma_iobase && dma_as; dev =qdev_create (NULL ,TYPE_FW_CFG_IO );qdev_prop_set_uint32 (dev,"iobase" , iobase);qdev_prop_set_uint32 (dev,"dma_iobase" , dma_iobase); -qdev_prop_set_bit (dev,"dma_enabled" , dma_enabled); +if (!dma_requested) { +qdev_prop_set_bit (dev,"dma_enabled" , false); + }fw_cfg_init1 (dev); s =FW_CFG (dev); -if (dma_enabled) { +if (s->dma_enabled) {/* 64 bits for the address field */ s->dma_as = dma_as; s->dma_addr =0 ;
@@ -818,11 +820,13 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr,SysBusDevice *sbd;FWCfgState *s;uint32_t version =FW_CFG_VERSION ; -bool dma_enabled = dma_addr && dma_as; +bool dma_requested = dma_addr && dma_as; dev =qdev_create (NULL ,TYPE_FW_CFG_MEM );qdev_prop_set_uint32 (dev,"data_width" , data_width); -qdev_prop_set_bit (dev,"dma_enabled" , dma_enabled); +if (!dma_requested) { +qdev_prop_set_bit (dev,"dma_enabled" , false); + }fw_cfg_init1 (dev);
@@ -832,7 +836,7 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, s =FW_CFG (dev); -if (dma_enabled) { +if (s->dma_enabled) { s->dma_as = dma_as; s->dma_addr =0 ;sysbus_mmio_map (sbd,2 , dma_addr);
@@ -877,7 +881,7 @@ static Property fw_cfg_io_properties[] = {DEFINE_PROP_UINT32 ("iobase" , FWCfgIoState, iobase,-1 ),DEFINE_PROP_UINT32 ("dma_iobase" , FWCfgIoState, dma_iobase,-1 ),DEFINE_PROP_BOOL ("dma_enabled" , FWCfgIoState, parent_obj.dma_enabled, - false), + true), DEFINE_PROP_END_OF_LIST(), };
@@ -917,7 +921,7 @@ static const TypeInfo fw_cfg_io_info = {static Property fw_cfg_mem_properties[] = {DEFINE_PROP_UINT32 ("data_width" , FWCfgMemState, data_width,-1 ),DEFINE_PROP_BOOL ("dma_enabled" , FWCfgMemState, parent_obj.dma_enabled, - false), + true),DEFINE_PROP_END_OF_LIST (), };
include/hw/compat.h +8 -0
@@ -18,6 +18,14 @@ .driver = "virtio-pci",\ .property = "migrate-extra",\ .value = "off",\ + },{\ + .driver = "fw_cfg_mem",\ + .property = "dma_enabled",\ + .value = "off",\ + },{\ + .driver = "fw_cfg_io",\ + .property = "dma_enabled",\ + .value = "off",\ }, #define HW_COMPAT_2_3 \
Signature · 1 line
1.9.1
PATCH 32/35 vhost-user: don't merge regions with different fds
In reply to Michael RothFrom: "Michael S. Tsirkin" <[email protected]>
vhost currently merges regions with contiguious virtual and physical addresses. This breaks for vhost-user since that also needs fds to match.
Add a vhost_ops entry to compare the fds for vhost-user only.
--- hw/virtio/vhost-user.c | 20 ++++++++++++++++++++ hw/virtio/vhost.c | 7 +++++++ include/hw/virtio/vhost-backend.h | 4 ++++ 3 files changed, 31 insertions(+)
hw/virtio/vhost-user.c +20 -0
@@ -612,6 +612,25 @@ static int vhost_user_migration_done(struct vhost_dev *dev, char* mac_addr)return -1 ; } +static bool vhost_user_can_merge (struct vhost_dev *dev, +uint64_t start1,uint64_t size1, +uint64_t start2,uint64_t size2) +{ +ram_addr_t ram_addr; +int mfd, rfd; +MemoryRegion *mr; + + mr =qemu_ram_addr_from_host ((void *)(uintptr_t )start1, &ram_addr); +assert (mr); + mfd =qemu_get_ram_fd (ram_addr); + + mr =qemu_ram_addr_from_host ((void *)(uintptr_t )start2, &ram_addr); +assert (mr); + rfd =qemu_get_ram_fd (ram_addr); + +return mfd == rfd; +} +const VhostOps user_ops = { .backend_type =VHOST_BACKEND_TYPE_USER , .vhost_backend_init = vhost_user_init,
@@ -634,4 +653,5 @@ const VhostOps user_ops = { .vhost_set_vring_enable = vhost_user_set_vring_enable, .vhost_requires_shm_log = vhost_user_requires_shm_log, .vhost_migration_done = vhost_user_migration_done, + .vhost_backend_can_merge = vhost_user_can_merge, };
hw/virtio/vhost.c +7 -0
@@ -259,6 +259,13 @@ static void vhost_dev_assign_memory(struct vhost_dev *dev,continue ; } +if (dev->vhost_ops->vhost_backend_can_merge && + !dev->vhost_ops->vhost_backend_can_merge (dev, uaddr, size, + reg->userspace_addr, + reg->memory_size)) { +continue ; + } +if (merged) { --to;assert (to >=0 );
include/hw/virtio/vhost-backend.h +4 -0
@@ -70,6 +70,9 @@ typedef int (*vhost_set_vring_enable_op)(struct vhost_dev *dev,typedef bool (*vhost_requires_shm_log_op )(struct vhost_dev *dev);typedef int (*vhost_migration_done_op )(struct vhost_dev *dev,char *mac_addr); +typedef bool (*vhost_backend_can_merge_op )(struct vhost_dev *dev, +uint64_t start1,uint64_t size1, +uint64_t start2,uint64_t size2); typedef struct VhostOps { VhostBackendType backend_type;
@@ -97,6 +100,7 @@ typedef struct VhostOps {vhost_set_vring_enable_op vhost_set_vring_enable;vhost_requires_shm_log_op vhost_requires_shm_log;vhost_migration_done_op vhost_migration_done; +vhost_backend_can_merge_op vhost_backend_can_merge; } VhostOps;extern const VhostOps user_ops;
Signature · 1 line
1.9.1
PATCH 33/35 target-arm: Make reserved ranges in ID_AA64* spaces RAZ, not UNDEF
In reply to Michael RothFrom: Peter Maydell <[email protected]>
The v8 ARM ARM defines that unused spaces in the ID_AA64* system register ranges are Reserved and must RAZ, rather than being UNDEF. Implement this.
In particular, ARM v8.2 adds a new feature register ID_AA64MMFR2, and newer versions of the Linux kernel will attempt to read this, which causes them not to boot up on versions of QEMU missing this fix.
Since the encoding .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 6 is actually defined in ARMv8 (as ID_MMFR4), we give it an entry in the ARMCPU struct so CPUs can override it, though since none do this too will just RAZ.
Message-id: [email protected]
Conflicts:
target-arm/helper.c
* remove context dep on 4054bfa9
--- target-arm/cpu-qom.h | 1 + target-arm/helper.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 122 insertions(+), 7 deletions(-)
target-arm/cpu-qom.h +1 -0
@@ -150,6 +150,7 @@ typedef struct ARMCPU {uint32_t id_mmfr1;uint32_t id_mmfr2;uint32_t id_mmfr3; +uint32_t id_mmfr4;uint32_t id_isar0;uint32_t id_isar1;uint32_t id_isar2;
target-arm/helper.c +121 -7
176 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 34/35 quorum: Fix crash in quorum_aio_cb()
In reply to Michael RothFrom: Alberto Garcia <[email protected]>
quorum_aio_cb() emits the QUORUM_REPORT_BAD event if there's an I/O error in a Quorum child. However sacb->aiocb must be correctly initialized for this to happen. read_quorum_children() and read_fifo_child() are not doing this, which results in a QEMU crash.
Message-id: 8138570d071ba7e25db3736979234a1fd71dbd05.1457610443.git.berto@igalia.com
--- block/quorum.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
block/quorum.c +7 -5
@@ -646,8 +646,9 @@ static BlockAIOCB *read_quorum_children(QuorumAIOCB *acb) }for (i =0 ; i < s->num_children; i++) { -bdrv_aio_readv (s->children[i]->bs, acb->sector_num, &acb->qcrs[i].qiov, - acb->nb_sectors, quorum_aio_cb, &acb->qcrs[i]); + acb->qcrs[i].aiocb =bdrv_aio_readv (s->children[i]->bs, acb->sector_num, + &acb->qcrs[i].qiov, acb->nb_sectors, + quorum_aio_cb, &acb->qcrs[i]); }return &acb->common;
@@ -662,9 +663,10 @@ static BlockAIOCB *read_fifo_child(QuorumAIOCB *acb)qemu_iovec_init (&acb->qcrs[acb->child_iter].qiov, acb->qiov->niov);qemu_iovec_clone (&acb->qcrs[acb->child_iter].qiov, acb->qiov, acb->qcrs[acb->child_iter].buf); -bdrv_aio_readv (s->children[acb->child_iter]->bs, acb->sector_num, - &acb->qcrs[acb->child_iter].qiov, acb->nb_sectors, - quorum_aio_cb, &acb->qcrs[acb->child_iter]); + acb->qcrs[acb->child_iter].aiocb = +bdrv_aio_readv (s->children[acb->child_iter]->bs, acb->sector_num, + &acb->qcrs[acb->child_iter].qiov, acb->nb_sectors, + quorum_aio_cb, &acb->qcrs[acb->child_iter]);return &acb->common; }
Signature · 1 line
1.9.1
PATCH 35/35 vl.c: Fix regression in machine error message
In reply to Michael RothFrom: Marcel Apfelbaum <[email protected]>
Commit e1ce0c3cb (vl.c: fix regression when reading machine type from config file) fixed the error message when the machine type was supplied inside the config file. However now the option name is not displayed correctly if the error happens when the machine is specified at command line.
Running
./x86_64-softmmu/qemu-system-x86_64 -M q35-1.5 -redir tcp:8022::22
will result in the error message:
qemu-system-x86_64: -redir tcp:8022::22: unsupported machine type Use -machine help to list supported machines
Fixed it by restoring the error location and also extracted the code dealing with machine options into a separate function.
Message-Id: <[email protected]>
--- vl.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-)
vl.c +26 -11
@@ -2757,6 +2757,31 @@ static const QEMUOption *lookup_opt(int argc, char **argv,return popt; } +static void set_machine_options (MachineClass **machine_class) +{ +const char *optarg; +QemuOpts *opts; +Location loc; + +loc_push_none (&loc); + + opts =qemu_get_machine_opts (); +qemu_opts_loc_restore (opts); + + optarg =qemu_opt_get (opts,"type" ); +if (optarg) { + *machine_class =machine_parse (optarg); + } + +if (*machine_class ==NULL ) { +error_report ("No machine specified, and there is no default" ); +error_printf ("Use -machine help to list supported machines\n" ); +exit (1 ); + } + +loc_pop (&loc); +} +static int machine_set_property (void *opaque,const char *name,const char *value,Error **errp)
@@ -4025,17 +4050,7 @@ int main(int argc, char **argv, char **envp)replay_configure (icount_opts); - opts =qemu_get_machine_opts (); - optarg =qemu_opt_get (opts,"type" ); -if (optarg) { - machine_class =machine_parse (optarg); - } - -if (machine_class ==NULL ) { -error_report ("No machine specified, and there is no default" ); -error_printf ("Use -machine help to list supported machines\n" ); -exit (1 ); - } +set_machine_options (&machine_class);set_memory_options (&ram_slots, &maxram_size, machine_class);
Signature · 1 line
1.9.1
Quoted 6 lines · Michael Roth
Hi everyone,
The following new patches are queued for QEMU stable v2.5.1:
Quoted 9 lines
The release is planned for 2016-03-29:
http://wiki.qemu.org/Planning/2.5
Please respond here or CC [email protected] on any patches you think should be included in the release.
Testing/feedback is greatly appreciated.
Here's some patches we have in Fedora that aren't in your tree that IMO are stable candidates:
99b4cb7 ahci: Do not unmap NULL addresses
64ffbe0 hmp: fix sendkey out of bounds write (CVE-2015-8619) 4c1396c i386: avoid null pointer dereference 4ab0359 ide: ahci: reset ncq object to unused on error 362786f net: check packet payload length
aa7f996 net: ne2000: fix bounds check in ioport operations 49d925c usb: check page select value while processing iTD fe3c546 usb: check RNDIS buffer offsets & length 64c9bc1 usb: check RNDIS message length
80eecda usb: check USB configuration descriptor object d62d9dc vmdk: Create streamOptimized as version 3 3db1d98 vmdk: Fix converting to streamOptimized
vmdk patches are for https://bugzilla.redhat.com/show_bug.cgi?id=1299185
Rest are security issues
Thanks,
Cole
Quoting Cole Robinson (2016-03-21 14:32:14)
Quoted 33 lines · Michael Roth
Quoted 6 lines
Hi everyone,
The following new patches are queued for QEMU stable v2.5.1:
Quoted 9 lines
The release is planned for 2016-03-29:
http://wiki.qemu.org/Planning/2.5
Please respond here or CC [email protected] on any patches you think should be included in the release.
Testing/feedback is greatly appreciated.
Here's some patches we have in Fedora that aren't in your tree that IMO are stable candidates:
99b4cb7 ahci: Do not unmap NULL addresses
64ffbe0 hmp: fix sendkey out of bounds write (CVE-2015-8619) 4c1396c i386: avoid null pointer dereference 4ab0359 ide: ahci: reset ncq object to unused on error 362786f net: check packet payload length
aa7f996 net: ne2000: fix bounds check in ioport operations 49d925c usb: check page select value while processing iTD fe3c546 usb: check RNDIS buffer offsets & length 64c9bc1 usb: check RNDIS message length
80eecda usb: check USB configuration descriptor object d62d9dc vmdk: Create streamOptimized as version 3 3db1d98 vmdk: Fix converting to streamOptimized
Quoted 2 lines
vmdk patches are for https://bugzilla.redhat.com/show_bug.cgi?id=1299185
Rest are security issues
Thanks, definitely good to have. Have them all applied locally and will push after another round of testing.
Quoted 4 lines
Thanks,
Cole
Am 21.03.2016 um 18:27 schrieb Michael Roth:
Quoted 4 lines
Hi everyone,
The following new patches are queued for QEMU stable v2.5.1:
Quoted 8 lines
https://github.com/mdroth/qemu/commits/stable-2.5-staging
The release is planned for 2016-03-29:
http://wiki.qemu.org/Planning/2.5Please respond here or CC [email protected] on any patches you think should be included in the release.
Is this stable material?
4467c6c hyperv: cpu hotplug fix with HyperV enabled
Peter
Quoting Peter Lieven (2016-03-22 05:00:28)
Quoted 9 lines
Am 21.03.2016 um 18:27 schrieb Michael Roth:
Quoted 8 lines
Hi everyone,
The following new patches are queued for QEMU stable v2.5.1:
https://github.com/mdroth/qemu/commits/stable-2.5-staging
The release is planned for 2016-03-29:
Quoted 8 lines
Quoted 4 lines
http://wiki.qemu.org/Planning/2.5Please respond here or CC [email protected] on any patches you think should be included in the release.
Is this stable material?
4467c6c hyperv: cpu hotplug fix with HyperV enabled
Doesn't seem like it would cause any side-effects outside of the cpu hotplug case it's fixing, so makes sense to me.
Quoted 3 lines
Peter