@@ -1640,7 +1640,68 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n,
1640
1640
file .index = hdev -> vhost_ops -> vhost_get_vq_index (hdev , n );
1641
1641
r = hdev -> vhost_ops -> vhost_set_vring_call (hdev , & file );
1642
1642
if (r < 0 ) {
1643
- VHOST_OPS_DEBUG (r , "vhost_set_vring_call failed" );
1643
+ error_report ("vhost_set_vring_call failed %d" , - r );
1644
+ }
1645
+ }
1646
+
1647
+ bool vhost_config_pending (struct vhost_dev * hdev )
1648
+ {
1649
+ assert (hdev -> vhost_ops );
1650
+ if ((hdev -> started == false) ||
1651
+ (hdev -> vhost_ops -> vhost_set_config_call == NULL )) {
1652
+ return false;
1653
+ }
1654
+
1655
+ EventNotifier * notifier =
1656
+ & hdev -> vqs [VHOST_QUEUE_NUM_CONFIG_INR ].masked_config_notifier ;
1657
+ return event_notifier_test_and_clear (notifier );
1658
+ }
1659
+
1660
+ void vhost_config_mask (struct vhost_dev * hdev , VirtIODevice * vdev , bool mask )
1661
+ {
1662
+ int fd ;
1663
+ int r ;
1664
+ EventNotifier * notifier =
1665
+ & hdev -> vqs [VHOST_QUEUE_NUM_CONFIG_INR ].masked_config_notifier ;
1666
+ EventNotifier * config_notifier = & vdev -> config_notifier ;
1667
+ assert (hdev -> vhost_ops );
1668
+
1669
+ if ((hdev -> started == false) ||
1670
+ (hdev -> vhost_ops -> vhost_set_config_call == NULL )) {
1671
+ return ;
1672
+ }
1673
+ if (mask ) {
1674
+ assert (vdev -> use_guest_notifier_mask );
1675
+ fd = event_notifier_get_fd (notifier );
1676
+ } else {
1677
+ fd = event_notifier_get_fd (config_notifier );
1678
+ }
1679
+ r = hdev -> vhost_ops -> vhost_set_config_call (hdev , fd );
1680
+ if (r < 0 ) {
1681
+ error_report ("vhost_set_config_call failed %d" , - r );
1682
+ }
1683
+ }
1684
+
1685
+ static void vhost_stop_config_intr (struct vhost_dev * dev )
1686
+ {
1687
+ int fd = -1 ;
1688
+ assert (dev -> vhost_ops );
1689
+ if (dev -> vhost_ops -> vhost_set_config_call ) {
1690
+ dev -> vhost_ops -> vhost_set_config_call (dev , fd );
1691
+ }
1692
+ }
1693
+
1694
+ static void vhost_start_config_intr (struct vhost_dev * dev )
1695
+ {
1696
+ int r ;
1697
+
1698
+ assert (dev -> vhost_ops );
1699
+ int fd = event_notifier_get_fd (& dev -> vdev -> config_notifier );
1700
+ if (dev -> vhost_ops -> vhost_set_config_call ) {
1701
+ r = dev -> vhost_ops -> vhost_set_config_call (dev , fd );
1702
+ if (!r ) {
1703
+ event_notifier_set (& dev -> vdev -> config_notifier );
1704
+ }
1644
1705
}
1645
1706
}
1646
1707
@@ -1880,6 +1941,16 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
1880
1941
}
1881
1942
}
1882
1943
1944
+ r = event_notifier_init (
1945
+ & hdev -> vqs [VHOST_QUEUE_NUM_CONFIG_INR ].masked_config_notifier , 0 );
1946
+ if (r < 0 ) {
1947
+ return r ;
1948
+ }
1949
+ event_notifier_test_and_clear (
1950
+ & hdev -> vqs [VHOST_QUEUE_NUM_CONFIG_INR ].masked_config_notifier );
1951
+ if (!vdev -> use_guest_notifier_mask ) {
1952
+ vhost_config_mask (hdev , vdev , true);
1953
+ }
1883
1954
if (hdev -> log_enabled ) {
1884
1955
uint64_t log_base ;
1885
1956
@@ -1918,6 +1989,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
1918
1989
vhost_device_iotlb_miss (hdev , vq -> used_phys , true);
1919
1990
}
1920
1991
}
1992
+ vhost_start_config_intr (hdev );
1921
1993
return 0 ;
1922
1994
fail_start :
1923
1995
if (vrings ) {
@@ -1947,6 +2019,9 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
1947
2019
1948
2020
/* should only be called after backend is connected */
1949
2021
assert (hdev -> vhost_ops );
2022
+ event_notifier_test_and_clear (
2023
+ & hdev -> vqs [VHOST_QUEUE_NUM_CONFIG_INR ].masked_config_notifier );
2024
+ event_notifier_test_and_clear (& vdev -> config_notifier );
1950
2025
1951
2026
trace_vhost_dev_stop (hdev , vdev -> name , vrings );
1952
2027
@@ -1969,6 +2044,7 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
1969
2044
}
1970
2045
memory_listener_unregister (& hdev -> iommu_listener );
1971
2046
}
2047
+ vhost_stop_config_intr (hdev );
1972
2048
vhost_log_put (hdev , true);
1973
2049
hdev -> started = false;
1974
2050
vdev -> vhost_started = false;
0 commit comments