Patch Round-up for stable 2.6.2, freeze on 2016-08-26
Subsystems (2)
cover Patch Round-up for stable 2.6.2, freeze on 2016-08-26
Hi everyone,
The following new patches are queued for QEMU stable v2.6.2:
https://github.com/mdroth/qemu/commits/stable-2.6-staging
The release is planned for 2016-08-29:
http://wiki.qemu.org/Planning/2.6
Please respond here or CC [email protected] on any patches you think should be included in the release.
Testing/feedback is greatly appreciated.
Thanks!
PATCH 1/25 net: check fragment length during fragmentation
From: Prasad J Pandit <[email protected]>
Network transport abstraction layer supports packet fragmentation. While fragmenting a packet, it checks for more fragments from packet length and current fragment length. It is susceptible to an infinite loop, if the current fragment length is zero. Add check to avoid it.
--- hw/net/vmxnet_tx_pkt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/vmxnet_tx_pkt.c +1 -1
@@ -544,7 +544,7 @@ static bool vmxnet_tx_pkt_do_sw_fragmentation(struct VmxnetTxPkt *pkt, fragment_offset += fragment_len; - }while (more_frags); + }while (fragment_len && more_frags);return true; }
Signature · 1 line
1.9.1
PATCH 2/25 ui: fix refresh of VNC server surface
In reply to Michael RothFrom: "Daniel P. Berrange" <[email protected]>
In previous commit
commit c7628bff4138ce906a3620d12e0820c1cf6c140d
Author: Gerd Hoffmann <[email protected]>
Date: Fri Oct 30 12:10:09 2015 +0100
vnc: only alloc server surface with clients connected
the VNC server was changed so that the 'vd->server' pixman image was only allocated when a client is connected.
Since then if a client disconnects and then reconnects to the VNC server all they will see is a black screen until they do something that triggers a refresh. On a graphical desktop this is not often noticed since there's many things going on which cause a refresh. On a plain text console it is really obvious since nothing refreshes frequently.
The problem is that the VNC server didn't update the guest dirty bitmap, so still believes its server image is in sync with the guest contents.
To fix this we must explicitly mark the entire guest desktop as dirty after re-creating the server surface. Move this logic into vnc_update_server_surface() so it is guaranteed to be call in all code paths that re-create the surface instead of only in vnc_dpy_switch()
Message-id: [email protected]
--- ui/vnc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
ui/vnc.c +11 -9
@@ -687,6 +687,8 @@ void *vnc_server_fb_ptr(VncDisplay *vd, int x, int y)static void vnc_update_server_surface (VncDisplay *vd) { +int width, height; +qemu_pixman_image_unref (vd->server); vd->server =NULL ;
@@ -694,10 +696,15 @@ static void vnc_update_server_surface(VncDisplay *vd)return ; } + width =vnc_width (vd); + height =vnc_height (vd); vd->server =pixman_image_create_bits (VNC_SERVER_FB_FORMAT , -vnc_width (vd), -vnc_height (vd), + width, height,NULL ,0 ); + +memset (vd->guest.dirty,0x00 ,sizeof (vd->guest.dirty)); +vnc_set_area_dirty (vd->guest.dirty, vd,0 ,0 , + width, height); } static void vnc_dpy_switch(DisplayChangeListener *dcl,
@@ -705,7 +712,6 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl, {VncDisplay *vd =container_of (dcl, VncDisplay, dcl);VncState *vs; -int width, height;vnc_abort_display_jobs (vd); vd->ds = surface;
@@ -717,11 +723,6 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl,qemu_pixman_image_unref (vd->guest.fb); vd->guest.fb =pixman_image_ref (surface->image); vd->guest.format = surface->format; - width =vnc_width (vd); - height =vnc_height (vd); -memset (vd->guest.dirty,0x00 ,sizeof (vd->guest.dirty)); -vnc_set_area_dirty (vd->guest.dirty, vd,0 ,0 , - width, height); QTAILQ_FOREACH(vs, &vd->clients, next) {vnc_colordepth (vs);
@@ -731,7 +732,8 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl, }memset (vs->dirty,0x00 ,sizeof (vs->dirty));vnc_set_area_dirty (vs->dirty, vd,0 ,0 , - width, height); +vnc_width (vd), +vnc_height (vd)); } }
Signature · 1 line
1.9.1
PATCH 3/25 virtio: recalculate vq->inuse after migration
In reply to Michael RothFrom: Stefan Hajnoczi <[email protected]>
The vq->inuse field is not migrated. Many devices don't hold VirtQueueElements across migration so it doesn't matter that vq->inuse starts at 0 on the destination QEMU.
At least virtio-serial, virtio-blk, and virtio-balloon migrate while holding VirtQueueElements. For these devices we need to recalculate vq->inuse upon load so the value is correct.
--- hw/virtio/virtio.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
hw/virtio/virtio.c +15 -0
@@ -1624,6 +1624,21 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) } vdev->vq[i].used_idx =vring_used_idx (&vdev->vq[i]); vdev->vq[i].shadow_avail_idx =vring_avail_idx (&vdev->vq[i]); + +/* +* Some devices migrate VirtQueueElements that have been popped +* from the avail ring but not yet returned to the used ring. +*/ + vdev->vq[i].inuse = vdev->vq[i].last_avail_idx - + vdev->vq[i].used_idx; +if (vdev->vq[i].inuse > vdev->vq[i].vring.num) { +error_report ("VQ %d size 0x%x < last_avail_idx 0x%x - " +"used_idx 0x%x" , + i, vdev->vq[i].vring.num, + vdev->vq[i].last_avail_idx, + vdev->vq[i].used_idx); +return -1 ; + } } }
Signature · 1 line
1.9.1
PATCH 4/25 virtio: decrement vq->inuse in virtqueue_discard()
In reply to Michael RothFrom: Stefan Hajnoczi <[email protected]>
virtqueue_discard() moves vq->last_avail_idx back so the element can be popped again. It's necessary to decrement vq->inuse to avoid "leaking" the element count.
--- hw/virtio/virtio.c | 1 + 1 file changed, 1 insertion(+)
hw/virtio/virtio.c +1 -0
@@ -267,6 +267,7 @@ void virtqueue_discard(VirtQueue *vq, const VirtQueueElement *elem, unsigned int len) { vq->last_avail_idx--; + vq->inuse--;virtqueue_unmap_sg (vq, elem, len); }
Signature · 1 line
1.9.1
PATCH 5/25 iscsi: pass SCSI status back for SG_IO
In reply to Michael RothFrom: Vadim Rozenfeld <[email protected]>
--- block/iscsi.c | 1 + 1 file changed, 1 insertion(+)
block/iscsi.c +1 -0
@@ -768,6 +768,7 @@ iscsi_aio_ioctl_cb(struct iscsi_context *iscsi, int status, acb->ioh->driver_status =0 ; acb->ioh->host_status =0 ; acb->ioh->resid =0 ; + acb->ioh->status = status;#define SG_ERR_DRIVER_SENSE 0x08
Signature · 1 line
1.9.1
PATCH 6/25 net: vmxnet: check IP header length
In reply to Michael RothFrom: Li Qiang <[email protected]>
Vmxnet3 device emulator when parsing packet headers does not check for IP header length. It could lead to a OOB access when reading further packet data. Add check to avoid it.
--- hw/net/vmxnet_tx_pkt.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/net/vmxnet_tx_pkt.c +5 -0
@@ -178,6 +178,11 @@ static bool vmxnet_tx_pkt_parse_headers(struct VmxnetTxPkt *pkt) } l3_hdr->iov_len =IP_HDR_GET_LEN (l3_hdr->iov_base); +if (l3_hdr->iov_len <sizeof (struct ip_header )) + { + l3_hdr->iov_len =0 ; +return false; + } pkt->l4proto = ((struct ip_header *) l3_hdr->iov_base)->ip_p;/* copy optional IPv4 header data */
Signature · 1 line
1.9.1
PATCH 7/25 net: vmxnet: use g_new for pkt initialisation
In reply to Michael RothFrom: Li Qiang <[email protected]>
When vmxnet transport abstraction layer initialises pkt, the maximum fragmentation count is not checked. This could lead to an integer overflow causing a NULL pointer dereference. Replace g_malloc() with g_new() to catch the multiplication overflow.
--- hw/net/vmxnet_tx_pkt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
hw/net/vmxnet_tx_pkt.c +2 -3
@@ -60,10 +60,9 @@ void vmxnet_tx_pkt_init(struct VmxnetTxPkt **pkt, uint32_t max_frags, {struct VmxnetTxPkt *p =g_malloc0 (sizeof *p); - p->vec =g_malloc ((sizeof *p->vec) * - (max_frags +VMXNET_TX_PKT_PL_START_FRAG )); + p->vec = g_new(struct iovec, max_frags + VMXNET_TX_PKT_PL_START_FRAG); - p->raw =g_malloc ((sizeof *p->raw) * max_frags); + p->raw = g_new(struct iovec, max_frags); p->max_payload_frags = max_frags; p->max_raw_frags = max_frags;
Signature · 1 line
1.9.1
PATCH 8/25 9pfs: forbid illegal path names
In reply to Michael RothFrom: Greg Kurz <[email protected]>
Empty path components don't make sense for most commands and may cause undefined behavior, depending on the backend.
Also, the walk request described in the 9P spec [1] clearly shows that the client is supposed to send individual path components: the official linux client never sends portions of path containing the / character for example.
Moreover, the 9P spec [2] also states that a system can decide to restrict the set of supported characters used in path components, with an explicit mention "to remove slashes from name components".
This patch introduces a new name_is_illegal() helper that checks the names sent by the client are not empty and don't contain unwanted chars. Since 9pfs is only supported on linux hosts, only the / character is checked at the moment. When support for other hosts (AKA. win32) is added, other chars may need to be blacklisted as well.
If a client sends an illegal path component, the request will fail and ENOENT is returned to the client.
[1] http://man.cat-v.org/plan_9/5/walk
[2] http://man.cat-v.org/plan_9/5/intro
--- hw/9pfs/9p.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
hw/9pfs/9p.c +56 -0
@@ -1254,6 +1254,11 @@ static int v9fs_walk_marshal(V9fsPDU *pdu, uint16_t nwnames, V9fsQID *qids)return offset; } +static bool name_is_illegal (const char *name) +{ +return !*name ||strchr (name,'/' ) !=NULL ; +} +static void v9fs_walk (void *opaque) {int name_idx;
@@ -1287,6 +1292,10 @@ static void v9fs_walk(void *opaque)if (err <0 ) { goto out_nofid; } +if (name_is_illegal (wnames[i].data)) { + err = -ENOENT ; + goto out_nofid; + } offset += err; } }else if (nwnames >P9_MAXWELEM ) {
@@ -1481,6 +1490,11 @@ static void v9fs_lcreate(void *opaque) }trace_v9fs_lcreate (pdu->tag, pdu->id, dfid, flags, mode, gid); +if (name_is_illegal (name.data)) { + err = -ENOENT ; + goto out_nofid; + } + fidp =get_fid (pdu, dfid);if (fidp ==NULL ) { err = -ENOENT ;
@@ -2066,6 +2080,11 @@ static void v9fs_create(void *opaque) }trace_v9fs_create (pdu->tag, pdu->id, fid, name.data, perm, mode); +if (name_is_illegal (name.data)) { + err = -ENOENT ; + goto out_nofid; + } + fidp =get_fid (pdu, fid);if (fidp ==NULL ) { err = -EINVAL ;
@@ -2231,6 +2250,11 @@ static void v9fs_symlink(void *opaque) }trace_v9fs_symlink (pdu->tag, pdu->id, dfid, name.data, symname.data, gid); +if (name_is_illegal (name.data)) { + err = -ENOENT ; + goto out_nofid; + } + dfidp =get_fid (pdu, dfid);if (dfidp ==NULL ) { err = -EINVAL ;
@@ -2305,6 +2329,11 @@ static void v9fs_link(void *opaque) }trace_v9fs_link (pdu->tag, pdu->id, dfid, oldfid, name.data); +if (name_is_illegal (name.data)) { + err = -ENOENT ; + goto out_nofid; + } + dfidp =get_fid (pdu, dfid);if (dfidp ==NULL ) { err = -ENOENT ;
@@ -2387,6 +2416,12 @@ static void v9fs_unlinkat(void *opaque)if (err <0 ) { goto out_nofid; } + +if (name_is_illegal (name.data)) { + err = -ENOENT ; + goto out_nofid; + } + dfidp =get_fid (pdu, dfid);if (dfidp ==NULL ) { err = -EINVAL ;
@@ -2493,6 +2528,12 @@ static void v9fs_rename(void *opaque)if (err <0 ) { goto out_nofid; } + +if (name_is_illegal (name.data)) { + err = -ENOENT ; + goto out_nofid; + } + fidp =get_fid (pdu, fid);if (fidp ==NULL ) { err = -ENOENT ;
@@ -2605,6 +2646,11 @@ static void v9fs_renameat(void *opaque) goto out_err; } +if (name_is_illegal (old_name.data) ||name_is_illegal (new_name.data)) { + err = -ENOENT ; + goto out_err; + } +v9fs_path_write_lock (s); err =v9fs_complete_renameat (pdu, olddirfid, &old_name, newdirfid, &new_name);
@@ -2815,6 +2861,11 @@ static void v9fs_mknod(void *opaque) }trace_v9fs_mknod (pdu->tag, pdu->id, fid, mode, major, minor); +if (name_is_illegal (name.data)) { + err = -ENOENT ; + goto out_nofid; + } + fidp =get_fid (pdu, fid);if (fidp ==NULL ) { err = -ENOENT ;
@@ -2966,6 +3017,11 @@ static void v9fs_mkdir(void *opaque) }trace_v9fs_mkdir (pdu->tag, pdu->id, fid, name.data, mode, gid); +if (name_is_illegal (name.data)) { + err = -ENOENT ; + goto out_nofid; + } + fidp =get_fid (pdu, fid);if (fidp ==NULL ) { err = -ENOENT ;
Signature · 1 line
1.9.1
PATCH 9/25 9pfs: forbid . and .. in file names
In reply to Michael RothFrom: Greg Kurz <[email protected]>
According to the 9P spec http://man.cat-v.org/plan_9/5/open about the create request:
The names . and .. are special; it is illegal to create files with these names.
This patch causes the create and lcreate requests to fail with EINVAL if the file name is either "." or "..".
Even if it isn't explicitly written in the spec, this patch extends the checking to all requests that may cause a directory entry to be created:
- mknod
- rename
- renameat
- mkdir
- link
- symlink
The unlinkat request also gets patched for consistency (even if rmdir("foo/..") is expected to fail according to POSIX.1-2001).
The various error values come from the linux manual pages.
--- hw/9pfs/9p.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
hw/9pfs/9p.c +51 -0
@@ -1495,6 +1495,11 @@ static void v9fs_lcreate(void *opaque) goto out_nofid; } +if (!strcmp ("." , name.data) || !strcmp (".." , name.data)) { + err = -EEXIST ; + goto out_nofid; + } + fidp =get_fid (pdu, dfid);if (fidp ==NULL ) { err = -ENOENT ;
@@ -2085,6 +2090,11 @@ static void v9fs_create(void *opaque) goto out_nofid; } +if (!strcmp ("." , name.data) || !strcmp (".." , name.data)) { + err = -EEXIST ; + goto out_nofid; + } + fidp =get_fid (pdu, fid);if (fidp ==NULL ) { err = -EINVAL ;
@@ -2255,6 +2265,11 @@ static void v9fs_symlink(void *opaque) goto out_nofid; } +if (!strcmp ("." , name.data) || !strcmp (".." , name.data)) { + err = -EEXIST ; + goto out_nofid; + } + dfidp =get_fid (pdu, dfid);if (dfidp ==NULL ) { err = -EINVAL ;
@@ -2334,6 +2349,11 @@ static void v9fs_link(void *opaque) goto out_nofid; } +if (!strcmp ("." , name.data) || !strcmp (".." , name.data)) { + err = -EEXIST ; + goto out_nofid; + } + dfidp =get_fid (pdu, dfid);if (dfidp ==NULL ) { err = -ENOENT ;
@@ -2422,6 +2442,16 @@ static void v9fs_unlinkat(void *opaque) goto out_nofid; } +if (!strcmp ("." , name.data)) { + err = -EINVAL ; + goto out_nofid; + } + +if (!strcmp (".." , name.data)) { + err = -ENOTEMPTY ; + goto out_nofid; + } + dfidp =get_fid (pdu, dfid);if (dfidp ==NULL ) { err = -EINVAL ;
@@ -2534,6 +2564,11 @@ static void v9fs_rename(void *opaque) goto out_nofid; } +if (!strcmp ("." , name.data) || !strcmp (".." , name.data)) { + err = -EISDIR ; + goto out_nofid; + } + fidp =get_fid (pdu, fid);if (fidp ==NULL ) { err = -ENOENT ;
@@ -2651,6 +2686,12 @@ static void v9fs_renameat(void *opaque) goto out_err; } +if (!strcmp ("." , old_name.data) || !strcmp (".." , old_name.data) || + !strcmp ("." , new_name.data) || !strcmp (".." , new_name.data)) { + err = -EISDIR ; + goto out_err; + } +v9fs_path_write_lock (s); err =v9fs_complete_renameat (pdu, olddirfid, &old_name, newdirfid, &new_name);
@@ -2866,6 +2907,11 @@ static void v9fs_mknod(void *opaque) goto out_nofid; } +if (!strcmp ("." , name.data) || !strcmp (".." , name.data)) { + err = -EEXIST ; + goto out_nofid; + } + fidp =get_fid (pdu, fid);if (fidp ==NULL ) { err = -ENOENT ;
@@ -3022,6 +3068,11 @@ static void v9fs_mkdir(void *opaque) goto out_nofid; } +if (!strcmp ("." , name.data) || !strcmp (".." , name.data)) { + err = -EEXIST ; + goto out_nofid; + } + fidp =get_fid (pdu, fid);if (fidp ==NULL ) { err = -ENOENT ;
Signature · 1 line
1.9.1
PATCH 10/25 9pfs: handle walk of ".." in the root directory
In reply to Michael RothFrom: Greg Kurz <[email protected]>
The 9P spec at http://man.cat-v.org/plan_9/5/intro says:
All directories must support walks to the directory .. (dot-dot) meaning parent directory, although by convention directories contain no explicit entry for .. or . (dot). The parent of the root directory of a server's tree is itself.
This means that a client cannot walk further than the root directory exported by the server. In other words, if the client wants to walk "/.." or "/foo/../..", the server should answer like the request was to walk "/".
This patch just does that:
- we cache the QID of the root directory at attach time
- during the walk we compare the QID of each path component with the root QID to detect if we're in a "/.." situation
- if so, we skip the current component and go to the next one
--- hw/9pfs/9p.c | 40 +++++++++++++++++++++++++++++++--------- hw/9pfs/9p.h | 1 + 2 files changed, 32 insertions(+), 9 deletions(-)
hw/9pfs/9p.c +31 -9
@@ -1008,6 +1008,7 @@ static void v9fs_attach(void *opaque) goto out; } err += offset; +memcpy (&s->root_qid, &qid,sizeof (qid));trace_v9fs_attach_return (pdu->tag, pdu->id, qid.type, qid.version, qid.path);/*
@@ -1259,6 +1260,14 @@ static bool name_is_illegal(const char *name)return !*name ||strchr (name,'/' ) !=NULL ; } +static bool not_same_qid (const V9fsQID *qid1,const V9fsQID *qid2) +{ +return + qid1->type != qid2->type || + qid1->version != qid2->version || + qid1->path != qid2->path; +} +static void v9fs_walk (void *opaque) {int name_idx;
@@ -1274,6 +1283,7 @@ static void v9fs_walk(void *opaque)V9fsFidState *newfidp =NULL ;V9fsPDU *pdu = opaque;V9fsState *s = pdu->s; +V9fsQID qid; err =pdu_unmarshal (pdu, offset,"ddw" , &fid, &newfid, &nwnames);if (err <0 ) {
@@ -1307,6 +1317,12 @@ static void v9fs_walk(void *opaque) err = -ENOENT ; goto out_nofid; } + + err =fid_to_qid (pdu, fidp, &qid); +if (err <0 ) { + goto out; + } +v9fs_path_init (&dpath);v9fs_path_init (&path);/*
@@ -1316,16 +1332,22 @@ static void v9fs_walk(void *opaque)v9fs_path_copy (&dpath, &fidp->path);v9fs_path_copy (&path, &fidp->path);for (name_idx =0 ; name_idx < nwnames; name_idx++) { - err =v9fs_co_name_to_path (pdu, &dpath, wnames[name_idx].data, &path); -if (err <0 ) { - goto out; - } - err =v9fs_co_lstat (pdu, &path, &stbuf); -if (err <0 ) { - goto out; +if (not_same_qid (&pdu->s->root_qid, &qid) || +strcmp (".." , wnames[name_idx].data)) { + err =v9fs_co_name_to_path (pdu, &dpath, wnames[name_idx].data, + &path); +if (err <0 ) { + goto out; + } + + err =v9fs_co_lstat (pdu, &path, &stbuf); +if (err <0 ) { + goto out; + } +stat_to_qid (&stbuf, &qid); +v9fs_path_copy (&dpath, &path); } -stat_to_qid (&stbuf, &qids[name_idx]); -v9fs_path_copy (&dpath, &path); +memcpy (&qids[name_idx], &qid,sizeof (qid)); }if (fid == newfid) {BUG_ON (fidp->fid_type !=P9_FID_NONE );
hw/9pfs/9p.h +1 -0
@@ -219,6 +219,7 @@ typedef struct V9fsStateint32_t root_fid;Error *migration_blocker;V9fsConf fsconf; +V9fsQID root_qid; } V9fsState;/* 9p2000.L open flags */
Signature · 1 line
1.9.1
PATCH 11/25 virtio: zero vq->inuse in virtio_reset()
In reply to Michael RothFrom: Stefan Hajnoczi <[email protected]>
vq->inuse must be zeroed upon device reset like most other virtqueue fields.
In theory, virtio_reset() just needs assert(vq->inuse == 0) since devices must clean up in-flight requests during reset (requests cannot not be leaked!).
In practice, it is difficult to achieve vq->inuse == 0 across reset because balloon, blk, 9p, etc implement various different strategies for cleaning up requests. Most devices call g_free(elem) directly without telling virtio.c that the VirtQueueElement is cleaned up. Therefore vq->inuse is not decremented during reset.
This patch zeroes vq->inuse and trusts that devices are not leaking VirtQueueElements across reset.
I will send a follow-up series that refactors request life-cycle across all devices and converts vq->inuse = 0 into assert(vq->inuse == 0) but this more invasive approach is not appropriate for stable trees.
--- hw/virtio/virtio.c | 1 + 1 file changed, 1 insertion(+)
hw/virtio/virtio.c +1 -0
@@ -816,6 +816,7 @@ void virtio_reset(void *opaque) vdev->vq[i].signalled_used_valid = false; vdev->vq[i].notification = true; vdev->vq[i].vring.num = vdev->vq[i].vring.num_default; + vdev->vq[i].inuse =0 ; } }
Signature · 1 line
1.9.1
PATCH 12/25 virtio-balloon: discard virtqueue element on reset
In reply to Michael RothFrom: Ladi Prosek <[email protected]>
The one pending element is being freed but not discarded on device reset, which causes svq->inuse to creep up, eventually hitting the "Virtqueue size exceeded" error.
Properly discarding the element on device reset makes sure that its buffers are unmapped and the inuse counter stays balanced.
--- hw/virtio/virtio-balloon.c | 1 + 1 file changed, 1 insertion(+)
hw/virtio/virtio-balloon.c +1 -0
@@ -478,6 +478,7 @@ static void virtio_balloon_device_reset(VirtIODevice *vdev)VirtIOBalloon *s =VIRTIO_BALLOON (vdev);if (s->stats_vq_elem !=NULL ) { +virtqueue_discard (s->svq, s->stats_vq_elem,0 );g_free (s->stats_vq_elem); s->stats_vq_elem =NULL ; }
Signature · 1 line
1.9.1
PATCH 13/25 vnc: fix qemu crash because of SIGSEGV
In reply to Michael RothFrom: Gonglei <[email protected]>
The backtrace is:
0x00007f0b75cdf880 in pixman_image_get_stride () from /lib64/libpixman-1.so.00x00007f0b77bcb3cf in vnc_server_fb_stride (vd=0x7f0b7a1a2bb0) at ui/vnc.c:680vnc_dpy_copy (dcl=0x7f0b7a1a2c00, src_x=224, src_y=263, dst_x=319, dst_y=363, w=1, h=1) at ui/vnc.c:9150x00007f0b77bbcc35 in dpy_gfx_copy (con=0x7f0b7a146210, src_x=src_x@entry=224, src_y=src_y@entry=263, dst_x=dst_x@entry=319,
dst_y=dst_y@entry=363, w=1, h=1) at ui/console.c:15750x00007f0b77bbda4e in qemu_console_copy (con=<optimized out>, src_x=src_x@entry=224, src_y=src_y@entry=263, dst_x=dst_x@entry=319,
dst_y=dst_y@entry=363, w=<optimized out>, h=<optimized out>) at ui/console.c:21110x00007f0b77ac0980 in cirrus_do_copy (h=<optimized out>, w=<optimized out>, src=<optimized out>, dst=<optimized out>, s=0x7f0b7b086090) at hw/display/cirrus_vga.c:774 cirrus_bitblt_videotovideo_copy (s=0x7f0b7b086090) at hw/display/cirrus_vga.c:793cirrus_bitblt_videotovideo (s=0x7f0b7b086090) at hw/display/cirrus_vga.c:915cirrus_bitblt_start (s=0x7f0b7b086090) at hw/display/cirrus_vga.c:10560x00007f0b77965cfb in memory_region_write_accessor (mr=0x7f0b7b096e40, addr=320, value=<optimized out>, size=1, shift=<optimized out>,mask=<optimized out>, attrs=...) at /root/rpmbuild/BUILD/master/qemu/memory.c:525 0x00007f0b77963f59 in access_with_adjusted_size (addr=addr@entry=320, value=value@entry=0x7f0b69a268d8, size=size@entry=4,
access_size_min=<optimized out>, access_size_max=<optimized out>, access=access@entry=0x7f0b77965c80 <memory_region_write_accessor>,
mr=mr@entry=0x7f0b7b096e40, attrs=attrs@entry=...) at /root/rpmbuild/BUILD/master/qemu/memory.c:5910x00007f0b77968315 in memory_region_dispatch_write (mr=mr@entry=0x7f0b7b096e40, addr=addr@entry=320, data=18446744073709551362,
size=size@entry=4, attrs=attrs@entry=...) at /root/rpmbuild/BUILD/master/qemu/memory.c:12620x00007f0b779256a9 in address_space_write_continue (mr=0x7f0b7b096e40, l=4, addr1=320, len=4, buf=0x7f0b77713028 "\002\377\377\377",
attrs=..., addr=4273930560, as=0x7f0b7827d280 <address_space_memory>) at /root/rpmbuild/BUILD/master/qemu/exec.c:2544address_space_write (as=<optimized out>, addr=<optimized out>, attrs=..., buf=<optimized out>, len=<optimized out>) at /root/rpmbuild/BUILD/master/qemu/exec.c:2601 0x00007f0b77925c1d in address_space_rw (as=<optimized out>, addr=<optimized out>, attrs=..., attrs@entry=...,
buf=buf@entry=0x7f0b77713028 "\002\377\377\377", len=<optimized out>, is_write=<optimized out>) at /root/rpmbuild/BUILD/master/qemu/exec.c:27030x00007f0b77962f53 in kvm_cpu_exec (cpu=cpu@entry=0x7f0b79fcc2d0) at /root/rpmbuild/BUILD/master/qemu/kvm-all.c:19650x00007f0b77950cc6 in qemu_kvm_cpu_thread_fn (arg=0x7f0b79fcc2d0) at /root/rpmbuild/BUILD/master/qemu/cpus.c:10780x00007f0b744b3dc5 in start_thread (arg=0x7f0b69a27700) at pthread_create.c:3080x00007f0b70d3d66d in clone () from /lib64/libc.so.6
The code path while meeting segfault:
vnc_dpy_copy
vnc_update_client
vnc_disconnect_finish [while vnc_disconnect_start() is invoked because somethins wrong]
vnc_update_server_surface
vd->server = NULL;
vnc_server_fb_stride
pixman_image_get_stride(vd->server)
Let's add a non-NULL check before calling vnc_server_fb_stride() to avoid segmentation fault.
Message-id: [email protected]
--- ui/vnc.c | 4 ++++ 1 file changed, 4 insertions(+)
ui/vnc.c +4 -0
@@ -906,6 +906,10 @@ static void vnc_dpy_copy(DisplayChangeListener *dcl, } } +if (!vd->server) { +/* no client connected */ +return ; + }/* do bitblit op on the local surface too */ pitch =vnc_server_fb_stride (vd); src_row =vnc_server_fb_ptr (vd, src_x, src_y);
Signature · 1 line
1.9.1
PATCH 14/25 9pfs: fix potential segfault during walk
In reply to Michael RothFrom: Greg Kurz <[email protected]>
If the call to fid_to_qid() returns an error, we will call v9fs_path_free() on uninitialized paths.
It is a regression introduced by the following commit:
56f101ecce0e 9pfs: handle walk of ".." in the root directory
Let's fix this by initializing dpath and path before calling fid_to_qid().
[groug: updated the changelog to indicate this is regression and to provide
the offending commit SHA1]
--- hw/9pfs/9p.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/9pfs/9p.c +3 -2
@@ -1318,13 +1318,14 @@ static void v9fs_walk(void *opaque) goto out_nofid; } +v9fs_path_init (&dpath); +v9fs_path_init (&path); + err =fid_to_qid (pdu, fidp, &qid);if (err <0 ) { goto out; } -v9fs_path_init (&dpath); -v9fs_path_init (&path);/* * Both dpath and path initially poin to fidp. * Needed to handle request with nwnames == 0
Signature · 1 line
1.9.1
PATCH 15/25 scsi: mptsas: use g_new0 to allocate MPTSASRequest object
In reply to Michael RothFrom: Li Qiang <[email protected]>
When processing IO request in mptsas, it uses g_new to allocate a 'req' object. If an error occurs before 'req->sreq' is allocated, It could lead to an OOB write in mptsas_free_request function. Use g_new0 to avoid it.
Message-Id: <[email protected]>
--- hw/scsi/mptsas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/mptsas.c +1 -1
@@ -304,7 +304,7 @@ static int mptsas_process_scsi_io_request(MPTSASState *s, goto bad; } - req =g_new (MPTSASRequest,1 ); + req =g_new0 (MPTSASRequest,1 );QTAILQ_INSERT_TAIL (&s->pending, req, next); req->scsi_io = *scsi_io; req->dev = s;
Signature · 1 line
1.9.1
PATCH 16/25 scsi: pvscsi: limit process IO loop to ring size
In reply to Michael RothFrom: Prasad J Pandit <[email protected]>
Vmware Paravirtual SCSI emulator while processing IO requests could run into an infinite loop if 'pvscsi_ring_pop_req_descr' always returned positive value. Limit IO loop to the ring size.
Message-Id: <[email protected]>
--- hw/scsi/vmw_pvscsi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
hw/scsi/vmw_pvscsi.c +4 -1
@@ -252,8 +252,11 @@ static hwaddr pvscsi_ring_pop_req_descr(PVSCSIRingInfo *mgr) {uint32_t ready_ptr =RS_GET_FIELD (mgr, reqProdIdx); +uint32_t ring_size =PVSCSI_MAX_NUM_PAGES_REQ_RING + *PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE ; -if (ready_ptr != mgr->consumed_ptr) { +if (ready_ptr != mgr->consumed_ptr + && ready_ptr - mgr->consumed_ptr < ring_size) {uint32_t next_ready_ptr = mgr->consumed_ptr++ & mgr->txr_len_mask; uint32_t next_ready_page =
Signature · 1 line
1.9.1
PATCH 17/25 qemu-char: avoid segfault if user lacks of permisson of a given logfile
In reply to Michael RothFrom: Lin Ma <[email protected]>
Function qemu_chr_alloc returns NULL if it failed to open logfile by any reason, says no write permission. For backends tty, stdio and msmouse, They need to check this return value to avoid segfault in this case.
Message-Id: <[email protected]>
--- qemu-char.c | 6 ++++++ 1 file changed, 6 insertions(+)
qemu-char.c +6 -0
@@ -1217,6 +1217,9 @@ static CharDriverState *qemu_chr_open_stdio(const char *id,sigaction (SIGCONT , &act,NULL ); chr =qemu_chr_open_fd (0 ,1 , common, errp); +if (!chr) { +return NULL ; + } chr->chr_close = qemu_chr_close_stdio; chr->chr_set_echo = qemu_chr_set_echo_stdio;if (opts->has_signal) {
@@ -1673,6 +1676,9 @@ static CharDriverState *qemu_chr_open_tty_fd(int fd,tty_serial_init (fd,115200 ,'N' ,8 ,1 ); chr =qemu_chr_open_fd (fd, fd, backend, errp); +if (!chr) { +return NULL ; + } chr->chr_ioctl = tty_serial_ioctl; chr->chr_close = qemu_chr_close_tty;return chr;
Signature · 1 line
1.9.1
PATCH 18/25 scsi-disk: change disk serial length from 20 to 36
In reply to Michael RothFrom: Rony Weng <[email protected]>
Openstack Cinder assigns volume a 36 characters uuid as serial. QEMU will shrinks the uuid to 20 characters, which does not match the original uuid.
Note that there is no limit to the length of the serial number in the SCSI spec. 20 was copy-pasted from virtio-blk which in turn was copy-pasted from ATA; 36 is even more arbitrary. However, bumping it up too much might cause issues (e.g. 252 seems to make sense because then the maximum amount of returned data is 256; but who knows there's no off-by-one somewhere for such a nicely rounded number).
Message-Id: <[email protected]>
--- hw/scsi/scsi-disk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/scsi/scsi-disk.c +2 -2
@@ -602,8 +602,8 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) } l =strlen (s->serial); -if (l >20 ) { - l =20 ; +if (l >36 ) { + l =36 ; } DPRINTF("Inquiry EVPD[Serial number] "
Signature · 1 line
1.9.1
PATCH 19/25 vmw_pvscsi: check page count while initialising descriptor rings
In reply to Michael RothFrom: Prasad J Pandit <[email protected]>
Vmware Paravirtual SCSI emulation uses command descriptors to process SCSI commands. These descriptors come with their ring buffers. A guest could set the page count for these rings to an arbitrary value, leading to infinite loop or OOB access. Add check to avoid it.
Message-Id: <[email protected]>
--- hw/scsi/vmw_pvscsi.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
hw/scsi/vmw_pvscsi.c +9 -10
@@ -153,7 +153,7 @@ pvscsi_log2(uint32_t input)return log; } -static int +static void pvscsi_ring_init_data (PVSCSIRingInfo *m,PVSCSICmdDescSetupRings *ri) {int i;
@@ -161,10 +161,6 @@ pvscsi_ring_init_data(PVSCSIRingInfo *m, PVSCSICmdDescSetupRings *ri)uint32_t req_ring_size, cmp_ring_size; m->rs_pa = ri->ringsStatePPN <<VMW_PAGE_SHIFT ; -if ((ri->reqRingNumPages >PVSCSI_SETUP_RINGS_MAX_NUM_PAGES ) - || (ri->cmpRingNumPages >PVSCSI_SETUP_RINGS_MAX_NUM_PAGES )) { -return -1 ; - } req_ring_size = ri->reqRingNumPages *PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE ; cmp_ring_size = ri->cmpRingNumPages *PVSCSI_MAX_NUM_CMP_ENTRIES_PER_PAGE ; txr_len_log2 =pvscsi_log2 (req_ring_size -1 );
@@ -196,8 +192,6 @@ pvscsi_ring_init_data(PVSCSIRingInfo *m, PVSCSICmdDescSetupRings *ri)/* Flush ring state page changes */ smp_wmb (); - -return 0 ; } static int
@@ -750,7 +744,7 @@ pvscsi_dbg_dump_tx_rings_config(PVSCSICmdDescSetupRings *rc)trace_pvscsi_tx_rings_num_pages ("Confirm Ring" , rc->cmpRingNumPages);for (i =0 ; i < rc->cmpRingNumPages; i++) { -trace_pvscsi_tx_rings_ppn ("Confirm Ring" , rc->reqRingPPNs[i]); +trace_pvscsi_tx_rings_ppn ("Confirm Ring" , rc->cmpRingPPNs[i]); } }
@@ -783,11 +777,16 @@ pvscsi_on_cmd_setup_rings(PVSCSIState *s)trace_pvscsi_on_cmd_arrived ("PVSCSI_CMD_SETUP_RINGS" ); -pvscsi_dbg_dump_tx_rings_config (rc); -if (pvscsi_ring_init_data (&s->rings, rc) <0 ) { +if (!rc->reqRingNumPages + || rc->reqRingNumPages >PVSCSI_SETUP_RINGS_MAX_NUM_PAGES + || !rc->cmpRingNumPages + || rc->cmpRingNumPages >PVSCSI_SETUP_RINGS_MAX_NUM_PAGES ) {return PVSCSI_COMMAND_PROCESSING_FAILED ; } +pvscsi_dbg_dump_tx_rings_config (rc); +pvscsi_ring_init_data (&s->rings, rc); + s->rings_info_valid = TRUE;return PVSCSI_COMMAND_PROCESSING_SUCCEEDED ; }
Signature · 1 line
1.9.1
PATCH 20/25 scsi: mptconfig: fix an assert expression
In reply to Michael RothFrom: Prasad J Pandit <[email protected]>
When LSI SAS1068 Host Bus emulator builds configuration page headers, mptsas_config_pack() should assert that the size fits in a byte. However, the size is expressed in 32-bit units, so up to 1020 bytes fit. The assertion was only allowing replies up to 252 bytes, so fix it.
Message-Id: <[email protected]>
--- hw/scsi/mptconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/mptconfig.c +1 -1
@@ -158,7 +158,7 @@ static size_t mptsas_config_pack(uint8_t **data, const char *fmt, ...)va_end (ap);if (data) { -assert (ret <256 && (ret %4 ) ==0 ); +assert (ret /4 <256 && (ret %4 ) ==0 );stb_p (*data +1 , ret /4 ); }return ret;
Signature · 1 line
1.9.1
PATCH 21/25 scsi: mptconfig: fix misuse of MPTSAS_CONFIG_PACK
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
These issues cause respectively a QEMU crash and a leak of 2 bytes of stack. They were discovered by VictorV of 360 Marvel Team.
--- hw/scsi/mptconfig.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/scsi/mptconfig.c +2 -2
@@ -203,7 +203,7 @@ size_t mptsas_config_manufacturing_1(MPTSASState *s, uint8_t **data, int address {/* VPD - all zeros */ return MPTSAS_CONFIG_PACK (1 ,MPI_CONFIG_PAGETYPE_MANUFACTURING ,0x00 , -"s256" ); +"*s256" ); } static
@@ -328,7 +328,7 @@ size_t mptsas_config_ioc_0(MPTSASState *s, uint8_t **data, int address)return MPTSAS_CONFIG_PACK (0 ,MPI_CONFIG_PAGETYPE_IOC ,0x01 ,"*l*lwwb*b*b*blww" , pcic->vendor_id, pcic->device_id, pcic->revision, - pcic->subsystem_vendor_id, + pcic->class_id, pcic->subsystem_vendor_id, pcic->subsystem_id); }
Signature · 1 line
1.9.1
PATCH 22/25 crypto: ensure XTS is only used with ciphers with 16 byte blocks
In reply to Michael RothFrom: "Daniel P. Berrange" <[email protected]>
The XTS cipher mode needs to be used with a cipher which has a block size of 16 bytes. If a mis-matching block size is used, the code will either corrupt memory beyond the IV array, or not fully encrypt/decrypt the IV.
This fixes a memory corruption crash when attempting to use cast5-128 with xts, since the former has an 8 byte block size.
A test case is added to ensure the cipher creation fails with such an invalid combination.
--- crypto/cipher-gcrypt.c | 6 ++++++ crypto/cipher-nettle.c | 12 +++++++----- tests/test-crypto-cipher.c | 43 +++++++++++++++++++++++++++++++++++-------- 3 files changed, 48 insertions(+), 13 deletions(-)
crypto/cipher-gcrypt.c +6 -0
@@ -192,6 +192,12 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg, }if (cipher->mode ==QCRYPTO_CIPHER_MODE_XTS ) { +if (ctx->blocksize !=XTS_BLOCK_SIZE ) { +error_setg (errp, +"Cipher block size %zu must equal XTS block size %d" , + ctx->blocksize,XTS_BLOCK_SIZE ); + goto error; + } ctx->iv =g_new0 (uint8_t, ctx->blocksize); }
crypto/cipher-nettle.c +7 -5
@@ -361,6 +361,13 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg, goto error; } +if (mode ==QCRYPTO_CIPHER_MODE_XTS && + ctx->blocksize !=XTS_BLOCK_SIZE ) { +error_setg (errp,"Cipher block size %zu must equal XTS block size %d" , + ctx->blocksize,XTS_BLOCK_SIZE ); + goto error; + } + ctx->iv =g_new0 (uint8_t, ctx->blocksize); cipher->opaque = ctx;
@@ -456,11 +463,6 @@ int qcrypto_cipher_decrypt(QCryptoCipher *cipher,break ;case QCRYPTO_CIPHER_MODE_XTS : -if (ctx->blocksize !=XTS_BLOCK_SIZE ) { -error_setg (errp,"Block size must be %d not %zu" , -XTS_BLOCK_SIZE , ctx->blocksize); -return -1 ; - }xts_decrypt (ctx->ctx, ctx->ctx_tweak, ctx->alg_encrypt_wrapper, ctx->alg_decrypt_wrapper, ctx->iv, len, out, in);
tests/test-crypto-cipher.c +35 -8
70 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 23/25 iothread: Stop threads before main() quits
In reply to Michael RothFrom: Fam Zheng <[email protected]>
Right after main_loop ends, we release various things but keep iothread alive. The latter is not prepared to the sudden change of resources.
Specifically, after bdrv_close_all(), virtio-scsi dataplane get a surprise at the empty BlockBackend:
(gdb) bt
at /usr/src/debug/qemu-2.6.0/hw/scsi/virtio-scsi.c:543
at /usr/src/debug/qemu-2.6.0/hw/scsi/virtio-scsi.c:577It is because the d->conf.blk->root is set to NULL, then blk_get_aio_context() returns qemu_aio_context, whereas s->ctx is still pointing to the iothread:
hw/scsi/virtio-scsi.c:543:
if (s->dataplane_started) {
assert(blk_get_aio_context(d->conf.blk) == s->ctx);
}To fix this, let's stop iothreads before doing bdrv_close_all().
Message-id: [email protected]
--- include/sysemu/iothread.h | 1 + iothread.c | 24 ++++++++++++++++++++---- vl.c | 2 ++ 3 files changed, 23 insertions(+), 4 deletions(-)
include/sysemu/iothread.h +1 -0
@@ -35,5 +35,6 @@ typedef struct {char *iothread_get_id (IOThread *iothread);AioContext *iothread_get_aio_context (IOThread *iothread); +void iothread_stop_all (void );#endif /* IOTHREAD_H */
iothread.c +20 -4
@@ -54,16 +54,25 @@ static void *iothread_run(void *opaque)return NULL ; } -static void iothread_instance_finalize (Object *obj) +static int iothread_stop (Object *object,void *opaque) { -IOThread *iothread =IOTHREAD (obj); +IOThread *iothread; -if (!iothread->ctx) { -return ; + iothread = (IOThread *)object_dynamic_cast (object,TYPE_IOTHREAD ); +if (!iothread || !iothread->ctx) { +return 0 ; } iothread->stopping = true;aio_notify (iothread->ctx);qemu_thread_join (&iothread->thread); +return 0 ; +} + +static void iothread_instance_finalize (Object *obj) +{ +IOThread *iothread =IOTHREAD (obj); + +iothread_stop (obj,NULL );qemu_cond_destroy (&iothread->init_done_cond);qemu_mutex_destroy (&iothread->init_done_lock);aio_context_unref (iothread->ctx);
@@ -174,3 +183,10 @@ IOThreadInfoList *qmp_query_iothreads(Error **errp)object_child_foreach (container, query_one_iothread, &prev);return head; } + +void iothread_stop_all (void ) +{ +Object *container =object_get_objects_root (); + +object_child_foreach (container, iothread_stop,NULL ); +}
vl.c +2 -0
@@ -119,6 +119,7 @@ int main(int argc, char **argv)#include "crypto/init.h" #include "sysemu/replay.h" #include "qapi/qmp/qerror.h" +#include "sysemu/iothread.h" #define MAX_VIRTIO_CONSOLES 1#define MAX_SCLP_CONSOLES 1
@@ -4659,6 +4660,7 @@ int main(int argc, char **argv, char **envp)main_loop ();replay_disable_events (); +iothread_stop_all ();bdrv_close_all ();pause_all_vcpus ();
Signature · 1 line
1.9.1
PATCH 24/25 scsi-disk: Cleaning up around tray open state
In reply to Michael RothFrom: Fam Zheng <[email protected]>
Even if tray is not open, it can be empty (blk_is_inserted() == false). Handle both cases correctly by replacing the s->tray_open checks with blk_is_available(), which is an AND of the two.
Also simplify successive checks of them into blk_is_available(), in a couple cases.
Message-Id: <[email protected]>
--- hw/scsi/scsi-disk.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
hw/scsi/scsi-disk.c +8 -14
@@ -392,7 +392,7 @@ static void scsi_read_data(SCSIRequest *req)return ; } -if (s->tray_open) { +if (!blk_is_available (req->dev->conf.blk)) {scsi_read_complete (r, -ENOMEDIUM );return ; }
@@ -523,7 +523,7 @@ static void scsi_write_data(SCSIRequest *req)scsi_write_complete_noio (r,0 );return ; } -if (s->tray_open) { +if (!blk_is_available (req->dev->conf.blk)) {scsi_write_complete_noio (r, -ENOMEDIUM );return ; }
@@ -795,10 +795,7 @@ static inline bool media_is_dvd(SCSIDiskState *s)if (s->qdev.type !=TYPE_ROM ) {return false; } -if (!blk_is_inserted (s->qdev.conf.blk)) { -return false; - } -if (s->tray_open) { +if (!blk_is_available (s->qdev.conf.blk)) {return false; }blk_get_geometry (s->qdev.conf.blk, &nb_sectors);
@@ -811,10 +808,7 @@ static inline bool media_is_cd(SCSIDiskState *s)if (s->qdev.type !=TYPE_ROM ) {return false; } -if (!blk_is_inserted (s->qdev.conf.blk)) { -return false; - } -if (s->tray_open) { +if (!blk_is_available (s->qdev.conf.blk)) {return false; }blk_get_geometry (s->qdev.conf.blk, &nb_sectors);
@@ -878,7 +872,7 @@ static int scsi_read_dvd_structure(SCSIDiskState *s, SCSIDiskReq *r, }if (format !=0xff ) { -if (s->tray_open || !blk_is_inserted (s->qdev.conf.blk)) { +if (!blk_is_available (s->qdev.conf.blk)) {scsi_check_condition (r,SENSE_CODE (NO_MEDIUM ));return -1 ; }
@@ -1874,7 +1868,7 @@ static int32_t scsi_disk_emulate_command(SCSIRequest *req, uint8_t *buf)break ;default : -if (s->tray_open || !blk_is_inserted (s->qdev.conf.blk)) { +if (!blk_is_available (s->qdev.conf.blk)) {scsi_check_condition (r,SENSE_CODE (NO_MEDIUM ));return 0 ; }
@@ -1903,7 +1897,7 @@ static int32_t scsi_disk_emulate_command(SCSIRequest *req, uint8_t *buf)memset (outbuf,0 , r->buflen);switch (req->cmd.buf[0 ]) {case TEST_UNIT_READY : -assert (!s->tray_open &&blk_is_inserted (s->qdev.conf.blk)); +assert (blk_is_available (s->qdev.conf.blk));break ;case INQUIRY : buflen =scsi_disk_emulate_inquiry (req, outbuf);
@@ -2142,7 +2136,7 @@ static int32_t scsi_disk_dma_command(SCSIRequest *req, uint8_t *buf) command = buf[0 ]; -if (s->tray_open || !blk_is_inserted (s->qdev.conf.blk)) { +if (!blk_is_available (s->qdev.conf.blk)) {scsi_check_condition (r,SENSE_CODE (NO_MEDIUM ));return 0 ; }
Signature · 1 line
1.9.1
PATCH 25/25 virtio-scsi: Don't abort when media is ejected
In reply to Michael RothFrom: Fam Zheng <[email protected]>
With an ejected block backend, blk_get_aio_context() would return qemu_aio_context. In this case don't assert.
Message-Id: <[email protected]>
--- hw/scsi/virtio-scsi.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
hw/scsi/virtio-scsi.c +9 -6
@@ -236,6 +236,13 @@ static void virtio_scsi_cancel_notify(Notifier *notifier, void *data)g_free (n); } +static inline void virtio_scsi_ctx_check (VirtIOSCSI *s,SCSIDevice *d) +{ +if (s->dataplane_started && d &&blk_is_available (d->conf.blk)) { +assert (blk_get_aio_context (d->conf.blk) == s->ctx); + } +} +/* Return 0 if the request is ready to be completed and return to guest; * -EINPROGRESS if the request is submitted and will be completed later, in the * case of async cancellation. */
@@ -247,9 +254,7 @@ static int virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)int target;int ret =0 ; -if (s->dataplane_started && d) { -assert (blk_get_aio_context (d->conf.blk) == s->ctx); - } +virtio_scsi_ctx_check (s, d);/* Here VIRTIO_SCSI_S_OK means "FUNCTION COMPLETE". */ req->resp.tmf.response =VIRTIO_SCSI_S_OK ;
@@ -539,9 +544,7 @@ static bool virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, VirtIOSCSIReq *reqvirtio_scsi_complete_cmd_req (req);return false; } -if (s->dataplane_started) { -assert (blk_get_aio_context (d->conf.blk) == s->ctx); - } +virtio_scsi_ctx_check (s, d); req->sreq =scsi_req_new (d, req->req.cmd.tag,virtio_scsi_get_lun (req->req.cmd.lun), req->req.cmd.cdb, req);
Signature · 1 line
1.9.1
Quoted 3 lines · Michael Roth
Hi everyone,
The following new patches are queued for QEMU stable v2.6.2:
What happened to the usual shortlog?
The following patches still need maintainer pull requests (cc'd), but have been tested and/or reviewed and are candidates for inclusion in the release:
[PATCH v2] iscsi: Fix divide-by-zero regression on raw SG d
https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg01627.html
[PATCH 1/3] migrate: Fix cpu-throttle-increment regression
https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg01948.html
We also want:
Revert "megasas: remove useless check for cmd->frame" commit 421cc3e7
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoting Eric Blake (2016-09-20 12:41:32)
Quoted 6 lines · Michael Roth
Quoted 3 lines
Hi everyone,
The following new patches are queued for QEMU stable v2.6.2:
What happened to the usual shortlog?
Sorry, didn't realize it was missing until about 2 seconds after I fired it off to qemu-devel. I'll include it in a reply to top-level.
Quoted 7 lines
The following patches still need maintainer pull requests (cc'd), but have been tested and/or reviewed and are candidates for inclusion in the release:
[PATCH v2] iscsi: Fix divide-by-zero regression on raw SG d
https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg01627.html
If I'm reading it right this fixes a regression introduced by cf081fca + a5b8dd2c,
Quoted 3 lines
[PATCH 1/3] migrate: Fix cpu-throttle-increment regression
https://lists.gnu.org/archive/html/qemu-devel/2016-09/msg01948.html
this fixes a regression introduced by 69ef1f3,
Quoted 5 lines
We also want:
Revert "megasas: remove useless check for
cmd->frame" commit421cc3e7
and this fixes one from 8cc4678, but none of these went into 2.6.x, so I don't think they're applicable. I have them all flagged for 2.7.1 though. 2.7.1 will probably go out fairly soon, but I'll try to hold off on setting a date until these make their way to master.
Quoted 5 lines
Signature · 3 lines
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 10 lines · Michael Roth
Quoting Eric Blake (2016-09-20 12:41:32)
Quoted 6 lines · Michael Roth
Quoted 3 lines
Hi everyone,
The following new patches are queued for QEMU stable v2.6.2:
What happened to the usual shortlog?
Sorry, didn't realize it was missing until about 2 seconds after I fired it off to qemu-devel. I'll include it in a reply to top-level.
Thanks.
Quoted 6 lines
and this fixes one from 8cc4678, but none of these went into 2.6.x, so I don't think they're applicable. I have them all flagged for 2.7.1 though. 2.7.1 will probably go out fairly soon, but I'll try to hold off on setting a date until these make their way to master.
Whoops, you're completely right. I saw "stable release" and immediately thought it was the most recent stable, but now that you point it out, it is obvious that the patches I mentioned are 2.7 material, not 2.6, compared to master at 2.8.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoting Michael Roth (2016-09-20 12:05:16)
Quoted 8 lines
Hi everyone,
The following new patches are queued for QEMU stable v2.6.2:
https://github.com/mdroth/qemu/commits/stable-2.6-staging
The release is planned for 2016-08-29:
Quoted 10 lines
http://wiki.qemu.org/Planning/2.6
Please respond here or CC [email protected] on any patches you think should be included in the release.
Testing/feedback is greatly appreciated.
Thanks!
Forgot to include the shortlog, here it is below:
The following changes since commit fcf75ad007b760eb5299ef7d0dda462372b8739e:
Update version for 2.6.1 release (2016-08-17 10:24:53 -0500)
are available in the git repository at:
git://github.com/mdroth/qemu.git stable-2.6-staging
for you to fetch changes up to 6e184753b3c1ba10e4b552805cb00ec8c51560b0:
virtio-scsi: Don't abort when media is ejected (2016-09-20 11:39:39 -0500)
----------------------------------------------------------------
Daniel P. Berrange (2):
ui: fix refresh of VNC server surface
crypto: ensure XTS is only used with ciphers with 16 byte blocks
Fam Zheng (3):
iothread: Stop threads before main() quits
scsi-disk: Cleaning up around tray open state
virtio-scsi: Don't abort when media is ejected
Gonglei (1):
vnc: fix qemu crash because of SIGSEGV
Greg Kurz (4):
9pfs: forbid illegal path names
9pfs: forbid . and .. in file names 9pfs: handle walk of ".." in the root directory 9pfs: fix potential segfault during walk
Ladi Prosek (1):
virtio-balloon: discard virtqueue element on reset
Li Qiang (3):
net: vmxnet: check IP header length
net: vmxnet: use g_new for pkt initialisation
scsi: mptsas: use g_new0 to allocate MPTSASRequest object
Lin Ma (1):
qemu-char: avoid segfault if user lacks of permisson of a given logfile
Paolo Bonzini (1):
scsi: mptconfig: fix misuse of MPTSAS_CONFIG_PACK
Prasad J Pandit (4):
net: check fragment length during fragmentation
scsi: pvscsi: limit process IO loop to ring size
vmw_pvscsi: check page count while initialising descriptor rings
scsi: mptconfig: fix an assert expression
Rony Weng (1):
scsi-disk: change disk serial length from 20 to 36
Stefan Hajnoczi (3):
virtio: recalculate vq->inuse after migration
virtio: decrement vq->inuse in virtqueue_discard()
virtio: zero vq->inuse in virtio_reset()Vadim Rozenfeld (1):
iscsi: pass SCSI status back for SG_IO
block/iscsi.c | 1 + crypto/cipher-gcrypt.c | 6 ++ crypto/cipher-nettle.c | 12 ++-- hw/9pfs/9p.c | 148 ++++++++++++++++++++++++++++++++++++++++++--- hw/9pfs/9p.h | 1 + hw/net/vmxnet_tx_pkt.c | 12 ++-- hw/scsi/mptconfig.c | 6 +- hw/scsi/mptsas.c | 2 +- hw/scsi/scsi-disk.c | 26 +++----- hw/scsi/virtio-scsi.c | 15 +++-- hw/scsi/vmw_pvscsi.c | 24 ++++---- hw/virtio/virtio-balloon.c | 1 + hw/virtio/virtio.c | 17 ++++++ include/sysemu/iothread.h | 1 + iothread.c | 24 ++++++-- qemu-char.c | 6 ++ tests/test-crypto-cipher.c | 43 ++++++++++--- ui/vnc.c | 24 +++++--- vl.c | 2 + 19 files changed, 295 insertions(+), 76 deletions(-)
Quoted 8 lines · Michael Roth
Hi everyone,
The following new patches are queued for QEMU stable v2.6.2:
https://github.com/mdroth/qemu/commits/stable-2.6-staging
The release is planned for 2016-08-29:
Quoted 10 lines
http://wiki.qemu.org/Planning/2.6
Please respond here or CC [email protected] on any patches you think should be included in the release.
Testing/feedback is greatly appreciated.
Thanks!
I assume you mean 2016-09-29. I might have another AHCI patch or two to submit for consideration here.
Quoting John Snow (2016-09-22 13:53:04)
Quoted 16 lines · Michael Roth
Quoted 13 lines
Hi everyone,
The following new patches are queued for QEMU stable v2.6.2:
https://github.com/mdroth/qemu/commits/stable-2.6-staging
The release is planned for 2016-08-29:
http://wiki.qemu.org/Planning/2.6
Please respond here or CC [email protected] on any patches you think should be included in the release.
Quoted 8 lines
Quoted 5 lines
Testing/feedback is greatly appreciated.
Thanks!
I assume you mean 2016-09-29. I might have another AHCI patch or two to submit for consideration here.
Argh! Yes, 2016-09-26. I've updated the wiki dates.