virtio-blk.c (0cd09c3a6cc2230ba38c462fc410b4acce59eb6f) | virtio-blk.c (ef546f1275f6563e8934dd5e338d29d9f9909ca6) |
---|---|
1/* 2 * Virtio Block Device 3 * 4 * Copyright IBM, Corp. 2007 5 * 6 * Authors: 7 * Anthony Liguori <aliguori@us.ibm.com> 8 * --- 719 unchanged lines hidden (view full) --- 728 } 729 730 return features; 731} 732 733static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status) 734{ 735 VirtIOBlock *s = VIRTIO_BLK(vdev); | 1/* 2 * Virtio Block Device 3 * 4 * Copyright IBM, Corp. 2007 5 * 6 * Authors: 7 * Anthony Liguori <aliguori@us.ibm.com> 8 * --- 719 unchanged lines hidden (view full) --- 728 } 729 730 return features; 731} 732 733static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status) 734{ 735 VirtIOBlock *s = VIRTIO_BLK(vdev); |
736 uint32_t features; | |
737 738 if (s->dataplane && !(status & (VIRTIO_CONFIG_S_DRIVER | 739 VIRTIO_CONFIG_S_DRIVER_OK))) { 740 virtio_blk_data_plane_stop(s->dataplane); 741 } 742 743 if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) { 744 return; 745 } 746 | 736 737 if (s->dataplane && !(status & (VIRTIO_CONFIG_S_DRIVER | 738 VIRTIO_CONFIG_S_DRIVER_OK))) { 739 virtio_blk_data_plane_stop(s->dataplane); 740 } 741 742 if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) { 743 return; 744 } 745 |
747 features = vdev->guest_features; 748 | |
749 /* A guest that supports VIRTIO_BLK_F_CONFIG_WCE must be able to send 750 * cache flushes. Thus, the "auto writethrough" behavior is never 751 * necessary for guests that support the VIRTIO_BLK_F_CONFIG_WCE feature. 752 * Leaving it enabled would break the following sequence: 753 * 754 * Guest started with "-drive cache=writethrough" 755 * Guest sets status to 0 756 * Guest sets DRIVER bit in status field 757 * Guest reads host features (WCE=0, CONFIG_WCE=1) 758 * Guest writes guest features (WCE=0, CONFIG_WCE=1) 759 * Guest writes 1 to the WCE configuration field (writeback mode) 760 * Guest sets DRIVER_OK bit in status field 761 * 762 * s->blk would erroneously be placed in writethrough mode. 763 */ | 746 /* A guest that supports VIRTIO_BLK_F_CONFIG_WCE must be able to send 747 * cache flushes. Thus, the "auto writethrough" behavior is never 748 * necessary for guests that support the VIRTIO_BLK_F_CONFIG_WCE feature. 749 * Leaving it enabled would break the following sequence: 750 * 751 * Guest started with "-drive cache=writethrough" 752 * Guest sets status to 0 753 * Guest sets DRIVER bit in status field 754 * Guest reads host features (WCE=0, CONFIG_WCE=1) 755 * Guest writes guest features (WCE=0, CONFIG_WCE=1) 756 * Guest writes 1 to the WCE configuration field (writeback mode) 757 * Guest sets DRIVER_OK bit in status field 758 * 759 * s->blk would erroneously be placed in writethrough mode. 760 */ |
764 if (!(features & (1 << VIRTIO_BLK_F_CONFIG_WCE))) { | 761 if (!virtio_has_feature(vdev, VIRTIO_BLK_F_CONFIG_WCE)) { |
765 aio_context_acquire(blk_get_aio_context(s->blk)); 766 blk_set_enable_write_cache(s->blk, | 762 aio_context_acquire(blk_get_aio_context(s->blk)); 763 blk_set_enable_write_cache(s->blk, |
767 !!(features & (1 << VIRTIO_BLK_F_WCE))); | 764 virtio_has_feature(vdev, VIRTIO_BLK_F_WCE)); |
768 aio_context_release(blk_get_aio_context(s->blk)); 769 } 770} 771 772static void virtio_blk_save(QEMUFile *f, void *opaque) 773{ 774 VirtIODevice *vdev = VIRTIO_DEVICE(opaque); 775 --- 215 unchanged lines hidden --- | 765 aio_context_release(blk_get_aio_context(s->blk)); 766 } 767} 768 769static void virtio_blk_save(QEMUFile *f, void *opaque) 770{ 771 VirtIODevice *vdev = VIRTIO_DEVICE(opaque); 772 --- 215 unchanged lines hidden --- |