diff --git a/.exrc b/.exrc new file mode 100644 index 0000000000000000000000000000000000000000..37755ede83a0d5b4fe22114f624a140d2bcaefff --- /dev/null +++ b/.exrc @@ -0,0 +1,7 @@ +"VIM settings to match QEMU coding style. They are activated by adding the +"following settings (without the " symbol) as last two lines in $HOME/.vimrc: +"set secure +"set exrc +set expandtab +set shiftwidth=4 +set smarttab diff --git a/hw/pci.c b/hw/pci.c index 4d959848079fce877899e27ffff25fec1c63b096..f855cf3f39fa4b4a695a10aae48bb4bc940b9547 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -439,7 +439,7 @@ const VMStateDescription vmstate_pci_device = { }; const VMStateDescription vmstate_pcie_device = { - .name = "PCIDevice", + .name = "PCIEDevice", .version_id = 2, .minimum_version_id = 1, .minimum_version_id_old = 1, diff --git a/hw/pcie.h b/hw/pcie.h index b8ab0c7b4f1547dd794f7bd4303b24eda30a1586..4889194ae6d84a837b71d867bc2a624c39f1e621 100644 --- a/hw/pcie.h +++ b/hw/pcie.h @@ -133,7 +133,6 @@ extern const VMStateDescription vmstate_pcie_device; #define VMSTATE_PCIE_DEVICE(_field, _state) { \ .name = (stringify(_field)), \ - .version_id = 2, \ .size = sizeof(PCIDevice), \ .vmsd = &vmstate_pcie_device, \ .flags = VMS_STRUCT, \ diff --git a/hw/pcie_aer.c b/hw/pcie_aer.c index 3b6981c7b767ffdcda3cb24e133b16dc4bf6d100..b04c164e22bee1e8cfa902a7ba44fb38032caeb3 100644 --- a/hw/pcie_aer.c +++ b/hw/pcie_aer.c @@ -738,6 +738,11 @@ void pcie_aer_root_init(PCIDevice *dev) PCI_ERR_ROOT_CMD_EN_MASK); pci_set_long(dev->w1cmask + pos + PCI_ERR_ROOT_STATUS, PCI_ERR_ROOT_STATUS_REPORT_MASK); + /* PCI_ERR_ROOT_IRQ is RO but devices change it using a + * device-specific method. + */ + pci_set_long(dev->cmask + pos + PCI_ERR_ROOT_STATUS, + ~PCI_ERR_ROOT_IRQ); } void pcie_aer_root_reset(PCIDevice *dev) diff --git a/hw/vhost.c b/hw/vhost.c index 0fd8da84e2b8ee80d589eda3f6fbf5371899f1db..d0ce5aad9b76f57a021fb3dc19b2e71917a3681f 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -747,14 +747,15 @@ static void vhost_eventfd_del(MemoryListener *listener, { } -int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force) +int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath, + bool force) { uint64_t features; int r; if (devfd >= 0) { hdev->control = devfd; } else { - hdev->control = open("/dev/vhost-net", O_RDWR); + hdev->control = open(devpath, O_RDWR); if (hdev->control < 0) { return -errno; } diff --git a/hw/vhost.h b/hw/vhost.h index 80e64df860b7bc37b0cd9029e6c1177eb1e1eb6a..0c47229f91b0cb14409e321cc5f3819d7e45bad9 100644 --- a/hw/vhost.h +++ b/hw/vhost.h @@ -44,7 +44,8 @@ struct vhost_dev { bool force; }; -int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force); +int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath, + bool force); void vhost_dev_cleanup(struct vhost_dev *hdev); bool vhost_dev_query(struct vhost_dev *hdev, VirtIODevice *vdev); int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev); diff --git a/hw/vhost_net.c b/hw/vhost_net.c index ecaa22dfb4e28b4cfcc4508e4a1b1ca451da8c93..df2c4a30a28190d07325f33d06c71a9723e6e6b6 100644 --- a/hw/vhost_net.c +++ b/hw/vhost_net.c @@ -109,7 +109,7 @@ struct vhost_net *vhost_net_init(NetClientState *backend, int devfd, (1 << VHOST_NET_F_VIRTIO_NET_HDR); net->backend = r; - r = vhost_dev_init(&net->dev, devfd, force); + r = vhost_dev_init(&net->dev, devfd, "/dev/vhost-net", force); if (r < 0) { goto fail; } diff --git a/monitor.c b/monitor.c index 9be0140598daa51e1fe06da08fdc6a7813d69e99..67064e2706b3aa35c5fd6d457a7688e2f34cc129 100644 --- a/monitor.c +++ b/monitor.c @@ -2407,6 +2407,24 @@ int monitor_fdset_dup_fd_remove(int dup_fd) return monitor_fdset_dup_fd_find_remove(dup_fd, true); } +int monitor_handle_fd_param(Monitor *mon, const char *fdname) +{ + int fd; + + if (!qemu_isdigit(fdname[0]) && mon) { + + fd = monitor_get_fd(mon, fdname); + if (fd == -1) { + error_report("No file descriptor named %s found", fdname); + return -1; + } + } else { + fd = qemu_parse_fd(fdname); + } + + return fd; +} + /* mon_cmds and info_cmds would be sorted at runtime */ static mon_cmd_t mon_cmds[] = { #include "hmp-commands.h" diff --git a/monitor.h b/monitor.h index 5fc2983b943abf85c23d01c32ad3a4c20e960177..64c15618441eeead72619504dc6561be4fb845ce 100644 --- a/monitor.h +++ b/monitor.h @@ -67,6 +67,7 @@ int monitor_read_block_device_key(Monitor *mon, const char *device, void *opaque); int monitor_get_fd(Monitor *mon, const char *fdname); +int monitor_handle_fd_param(Monitor *mon, const char *fdname); void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); diff --git a/net.c b/net.c index 60043ddec694ef914cd340d250163954d25976e4..e5d25d4b6d9251fb7b028f742e024dd740460816 100644 --- a/net.c +++ b/net.c @@ -522,24 +522,6 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models, return -1; } -int net_handle_fd_param(Monitor *mon, const char *param) -{ - int fd; - - if (!qemu_isdigit(param[0]) && mon) { - - fd = monitor_get_fd(mon, param); - if (fd == -1) { - error_report("No file descriptor named %s found", param); - return -1; - } - } else { - fd = qemu_parse_fd(param); - } - - return fd; -} - static int net_init_nic(const NetClientOptions *opts, const char *name, NetClientState *peer) { diff --git a/net.h b/net.h index 29750567ed9e44c5423ddaab25055a8b069528d4..04fda1d6c8f8559dac23e34824b8fc07d443a6b3 100644 --- a/net.h +++ b/net.h @@ -168,8 +168,6 @@ int qmp_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret); void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd); -int net_handle_fd_param(Monitor *mon, const char *param); - #define POLYNOMIAL 0x04c11db6 unsigned compute_mcast_idx(const uint8_t *ep); diff --git a/net/socket.c b/net/socket.c index c172c249be6afe40d75866dd679c8a9e0c9b3da7..7c602e4c3a8121cf84a9cd51bc3f3b14350ddd0e 100644 --- a/net/socket.c +++ b/net/socket.c @@ -629,7 +629,7 @@ int net_init_socket(const NetClientOptions *opts, const char *name, if (sock->has_fd) { int fd; - fd = net_handle_fd_param(cur_mon, sock->fd); + fd = monitor_handle_fd_param(cur_mon, sock->fd); if (fd == -1 || !net_socket_fd_init(peer, "socket", name, fd, 1)) { return -1; } diff --git a/net/tap.c b/net/tap.c index 197152579414bcf19f9ebbc00ddcc16da9338254..a88ae8f61ae83b3058f878a68fa9cab119932298 100644 --- a/net/tap.c +++ b/net/tap.c @@ -610,7 +610,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name, return -1; } - fd = net_handle_fd_param(cur_mon, tap->fd); + fd = monitor_handle_fd_param(cur_mon, tap->fd); if (fd == -1) { return -1; } @@ -686,7 +686,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name, int vhostfd; if (tap->has_vhostfd) { - vhostfd = net_handle_fd_param(cur_mon, tap->vhostfd); + vhostfd = monitor_handle_fd_param(cur_mon, tap->vhostfd); if (vhostfd == -1) { return -1; }