Misc vhost-user fixes
cover Misc vhost-user fixes
Hi,
Here is a few fixes spotted by Coverity in the recently landed vhost-user-{input,gpu}.
Marc-André Lureau (5):
vhost-user-gpu: do not send scanout update if no GPU socket
vhost-user: check unix_listen() return value
vhost-user: improve error report
vhost-user-input: check ioctl(EVIOCGNAME) return value
vhost-user-gpu: initialize msghdr & iov at declaration
contrib/vhost-user-gpu/main.c | 29 ++++++++++++++--------------- contrib/vhost-user-input/main.c | 12 ++++++++++-- 2 files changed, 24 insertions(+), 17 deletions(-)
Signature · 1 line
2.22.0.rc2.384.g1a9a72ea1d
PATCH 1/5 vhost-user-gpu: do not send scanout update if no GPU socket
Should fix coverity CID 1401760.
--- contrib/vhost-user-gpu/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/vhost-user-gpu/main.c +1 -1
@@ -354,7 +354,7 @@ vg_disable_scanout(VuGpu *g, int scanout_id) scanout->width =0 ; scanout->height =0 ; - { +if (g->sock_fd >=0 ) {VhostUserGpuMsg msg = { .request =VHOST_USER_GPU_SCANOUT , .size =sizeof (VhostUserGpuScanout),
Signature · 1 line
2.22.0.rc2.384.g1a9a72ea1d
PATCH 2/5 vhost-user: check unix_listen() return value
In reply to Marc-André LureauThis check shouldn't be necessary, since &error_fatal is given as argument and will exit() on failure. However, this change should silence coverity CID 1401761 & 1401705.
--- contrib/vhost-user-gpu/main.c | 4 ++++ contrib/vhost-user-input/main.c | 4 ++++ 2 files changed, 8 insertions(+)
contrib/vhost-user-gpu/main.c +4 -0
@@ -1160,6 +1160,10 @@ main(int argc, char *argv[])if (opt_socket_path) {int lsock =unix_listen (opt_socket_path, &error_fatal); +if (lsock <0 ) { +g_printerr ("Failed to listen on %s.\n" , opt_socket_path); +exit (EXIT_FAILURE ); + } fd =accept (lsock,NULL ,NULL );close (lsock); }else {
contrib/vhost-user-input/main.c +4 -0
@@ -367,6 +367,10 @@ main(int argc, char *argv[])if (opt_socket_path) {int lsock =unix_listen (opt_socket_path, &error_fatal); +if (lsock <0 ) { +g_printerr ("Failed to listen on %s.\n" , opt_socket_path); +exit (EXIT_FAILURE ); + } fd =accept (lsock,NULL ,NULL );close (lsock); }else {
Signature · 1 line
2.22.0.rc2.384.g1a9a72ea1d
Re: [Qemu-devel] [PATCH 2/5] vhost-user: check unix_listen() return value
Quoted 42 lines · Marc-André Lureau
This check shouldn't be necessary, since
&error_fatalis given as argument and willexit()on failure. However, this change should silence coverity CID 1401761 & 1401705.Signed-off-by Marc-André Lureau <[email protected]>--- contrib/vhost-user-gpu/main.c | 4 ++++ contrib/vhost-user-input/main.c | 4 ++++ 2 files changed, 8 insertions(+)contrib/vhost-user-gpu/main.c +4
-0@@ -1160,6 +1160,10 @@ main(int argc, char *argv[])if (opt_socket_path) {int lsock =unix_listen (opt_socket_path, &error_fatal); +if (lsock <0 ) { +g_printerr ("Failed to listen on %s.\n" , opt_socket_path); +exit (EXIT_FAILURE ); + } fd =accept (lsock,NULL ,NULL );close (lsock); }else {contrib/vhost-user-input/main.c +4
-1@@ -367,6 +367,10 @@ main(int argc, char *argv[])if (opt_socket_path) {int lsock =unix_listen (opt_socket_path, &error_fatal); +if (lsock <0 ) { +g_printerr ("Failed to listen on %s.\n" , opt_socket_path); +exit (EXIT_FAILURE ); + } fd =accept (lsock,NULL ,NULL );close (lsock); }else { --
Quoted 2 lines
2.22.0.rc2.384.g1a9a72ea1d
Maybe better to just assert(lsock >= 0) ?
(I hadn't noticed the &error_fatal -- it means this new code is unreachable.)
thanks
-- PMM
Re: [Qemu-devel] [PULL 02/11] vhost-user: check unix_listen() return value
In reply to Marc-André LureauQuoted 20 lines · Michael S. Tsirkin
From: Marc-André Lureau <[email protected]>
This check shouldn't be necessary, since
&error_fatalis given as argument and willexit()on failure. However, this change should silence coverity CID 1401761 & 1401705.Signed-off-by Marc-André Lureau <[email protected]>Message-Id: <[email protected]>
Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>--- contrib/vhost-user-gpu/main.c | 4 ++++ contrib/vhost-user-input/main.c | 4 ++++ 2 files changed, 8 insertions(+)contrib/vhost-user-gpu/main.c +0
-0
contrib/vhost-user-gpu/main.c main(int argc, char *argv[]) · line 1166
Quoted 7 lines
contrib/vhost-user-gpu/main.c +4
-0@@ -1160,6 +1160,10 @@ main(int argc, char *argv[])if (opt_socket_path) {int lsock =unix_listen (opt_socket_path, &error_fatal); +if (lsock <0 ) { +g_printerr ("Failed to listen on %s.\n" , opt_socket_path); +exit (EXIT_FAILURE ); + }
4 lines to appease Coverity; wouldn't the following one-liner also do the trick?
int lsock = unix_listen(opt_socket_path, &error_fatal); assert (lsock >= 0);
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PULL 02/11] vhost-user: check unix_listen() return value
Hi
Quoted 33 lines · Eric Blake
Quoted 20 lines · Michael S. Tsirkin
From: Marc-André Lureau <[email protected]>
This check shouldn't be necessary, since
&error_fatalis given as argument and willexit()on failure. However, this change should silence coverity CID 1401761 & 1401705.Signed-off-by Marc-André Lureau <[email protected]>Message-Id: <[email protected]>
Reviewed-by Michael S. Tsirkin <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>--- contrib/vhost-user-gpu/main.c | 4 ++++ contrib/vhost-user-input/main.c | 4 ++++ 2 files changed, 8 insertions(+)contrib/vhost-user-gpu/main.c +0
-0contrib/vhost-user-gpu/main.c main(int argc, char *argv[]) · line 1166
Quoted 7 lines
contrib/vhost-user-gpu/main.c +4
-0@@ -1160,6 +1160,10 @@ main(int argc, char *argv[])if (opt_socket_path) {int lsock =unix_listen (opt_socket_path, &error_fatal); +if (lsock <0 ) { +g_printerr ("Failed to listen on %s.\n" , opt_socket_path); +exit (EXIT_FAILURE ); + }4 lines to appease Coverity; wouldn't the following one-liner also do the trick?
Quoted 2 lines
int lsock =
unix_listen(opt_socket_path, &error_fatal); assert (lsock >= 0);
Probably, I didn't think too much about it. However looking at it now, it would be worthwhile to report the error to the user in a friendlier way than what error_fatal do. So I guess a follow-up patch should introduce a local Error.
Quoted 6 lines
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
Signature · 1 line
Marc-André Lureau
PATCH 3/5 vhost-user: improve error report
In reply to Marc-André Lureaug_printerr() needs a trailing \n
--- contrib/vhost-user-gpu/main.c | 2 +- contrib/vhost-user-input/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
contrib/vhost-user-gpu/main.c +1 -1
@@ -1170,7 +1170,7 @@ main(int argc, char *argv[]) fd = opt_fdnum; }if (fd ==-1 ) { -g_printerr ("Invalid socket" ); +g_printerr ("Invalid vhost-user socket.\n" );exit (EXIT_FAILURE ); }
contrib/vhost-user-input/main.c +1 -1
@@ -377,7 +377,7 @@ main(int argc, char *argv[]) fd = opt_fdnum; }if (fd ==-1 ) { -g_printerr ("Invalid socket" ); +g_printerr ("Invalid vhost-user socket.\n" );exit (EXIT_FAILURE ); }vug_init (&vi.dev, fd, vi_panic, &vuiface);
Signature · 1 line
2.22.0.rc2.384.g1a9a72ea1d
PATCH 4/5 vhost-user-input: check ioctl(EVIOCGNAME) return value
In reply to Marc-André LureauThis should fix coverity CID 1401704.
--- contrib/vhost-user-input/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
contrib/vhost-user-input/main.c +5 -1
@@ -342,7 +342,11 @@ main(int argc, char *argv[]) vi.config =g_array_new (false, false,sizeof (virtio_input_config));memset (&id,0 ,sizeof (id)); -ioctl (vi.evdevfd,EVIOCGNAME (sizeof (id.u.string) -1 ), id.u.string); +if (ioctl (vi.evdevfd,EVIOCGNAME (sizeof (id.u.string) -1 ), + id.u.string) <0 ) { +g_printerr ("Failed to get evdev name: %s\n" ,g_strerror (errno)); +exit (EXIT_FAILURE ); + } id.select =VIRTIO_INPUT_CFG_ID_NAME ; id.size =strlen (id.u.string);g_array_append_val (vi.config, id);
Signature · 1 line
2.22.0.rc2.384.g1a9a72ea1d
Re: [Qemu-devel] [PATCH 4/5] vhost-user-input: check ioctl(EVIOCGNAME) return value
Quoted 13 lines · Marc-André Lureau
This should fix coverity CID 1401704.
Signed-off-by Marc-André Lureau <[email protected]>--- contrib/vhost-user-input/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)contrib/vhost-user-input/main.c +0
-0
contrib/vhost-user-input/main.c main(int argc, char *argv[]) · line 349
Quoted 9 lines
contrib/vhost-user-input/main.c +5
-1@@ -342,7 +342,11 @@ main(int argc, char *argv[]) vi.config =g_array_new (false, false,sizeof (virtio_input_config));memset (&id,0 ,sizeof (id)); -ioctl (vi.evdevfd,EVIOCGNAME (sizeof (id.u.string) -1 ), id.u.string); +if (ioctl (vi.evdevfd,EVIOCGNAME (sizeof (id.u.string) -1 ), + id.u.string) <0 ) { +g_printerr ("Failed to get evdev name: %s\n" ,g_strerror (errno)); +exit (EXIT_FAILURE ); + }
thanks
-- PMM
PATCH 5/5 vhost-user-gpu: initialize msghdr & iov at declaration
In reply to Marc-André LureauThis should fix uninitialized fields found by coverity CID 1401762.
--- contrib/vhost-user-gpu/main.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
contrib/vhost-user-gpu/main.c +8 -13
@@ -138,22 +138,20 @@ static int vg_sock_fd_write(int sock, const void *buf, ssize_t buflen, int fd) { ssize_t ret; -struct msghdr msg; -struct iovec iov; +struct iovec iov = { + .iov_base = (void *)buf, + .iov_len = buflen, + }; +struct msghdr msg = { + .msg_iov = &iov, + .msg_iovlen =1 , + };union {struct cmsghdr cmsghdr;char control[CMSG_SPACE (sizeof (int ))]; } cmsgu;struct cmsghdr *cmsg; - iov.iov_base = (void *)buf; - iov.iov_len = buflen; - - msg.msg_name =NULL ; - msg.msg_namelen =0 ; - msg.msg_iov = &iov; - msg.msg_iovlen =1 ; -if (fd !=-1 ) { msg.msg_control = cmsgu.control; msg.msg_controllen =sizeof (cmsgu.control);
@@ -164,9 +162,6 @@ vg_sock_fd_write(int sock, const void *buf, ssize_t buflen, int fd) cmsg->cmsg_type =SCM_RIGHTS ; *((int *)CMSG_DATA (cmsg)) = fd; - }else { - msg.msg_control =NULL ; - msg.msg_controllen =0 ; } do {
Signature · 1 line
2.22.0.rc2.384.g1a9a72ea1d
Re: [Qemu-devel] [PATCH 5/5] vhost-user-gpu: initialize msghdr & iov at declaration
Quoted 8 lines · Marc-André Lureau
This should fix uninitialized fields found by coverity CID 1401762.
Signed-off-by Marc-André Lureau <[email protected]>--- contrib/vhost-user-gpu/main.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
thanks
-- PMM
[Qemu-devel] [PULL 00/11] virtio, acpi: fixes, cleanups
The following changes since commit f3d0bec9f80e4ed7796fffa834ba0a53f2094f7f:
Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-06-14' into staging (2019-06-14 14:46:13 +0100)
are available in the Git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
for you to fetch changes up to 5f6b3561bf58395fd6c906d7064a1a5693a2e426:
tests/rebuild-expected-aml.sh: blow out difflist (2019-06-16 16:44:44 -0400)
----------------------------------------------------------------
virtio, acpi: fixes, cleanups
A bunch of minor fixes all over the place.
----------------------------------------------------------------
Gerd Hoffmann (1):
q35: fix mmconfig and PCI0._CRS
Li Hangjing (1):
vhost: fix vhost_log size overflow during migration
Marc-André Lureau (6):
vhost-user-gpu: do not send scanout update if no GPU socket
vhost-user: check unix_listen() return value
vhost-user: improve error report
vhost-user-input: check ioctl(EVIOCGNAME) return value
vhost-user-gpu: initialize msghdr & iov at declaration docs/vhost-user.json: some firmware.json copy leftovers
Michael S. Tsirkin (2):
q35: update DSDT tests/rebuild-expected-aml.sh: blow out difflist
Wei Yang (1):
hw/acpi: extract acpi_add_rom_blob()
docs/interop/vhost-user.json | 6 ++--- include/hw/acpi/utils.h | 9 +++++++ contrib/vhost-user-gpu/main.c | 29 +++++++++++------------ contrib/vhost-user-input/main.c | 12 ++++++++-- hw/acpi/utils.c | 35 ++++++++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 26 ++++++++------------- hw/i386/acpi-build.c | 40 +++++++++++++++++++------------- hw/pci-host/q35.c | 31 +++++++------------------ hw/virtio/vhost.c | 10 ++++++++ hw/acpi/Makefile.objs | 2 +- tests/data/acpi/q35/DSDT | Bin 7815 -> 7841 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7832 -> 7858 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8278 -> 8304 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9468 -> 9494 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7890 -> 7916 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9174 -> 9200 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8945 -> 8971 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7821 -> 7847 bytes tests/data/acpi/rebuild-expected-aml.sh | 3 +++ 19 files changed, 127 insertions(+), 76 deletions(-) create mode 100644 include/hw/acpi/utils.h create mode 100644 hw/acpi/utils.c
[Qemu-devel] [PULL 10/11] q35: update DSDT
update expected files and drop them from allowed diff list.
--- tests/bios-tables-test-allowed-diff.h | 8 -------- tests/data/acpi/q35/DSDT | Bin 7815 -> 7841 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7832 -> 7858 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8278 -> 8304 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9468 -> 9494 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7890 -> 7916 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9174 -> 9200 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8945 -> 8971 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7821 -> 7847 bytes 9 files changed, 8 deletions(-)
tests/bios-tables-test-allowed-diff.h +0 -8
@@ -1,9 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/DSDT" , -"tests/data/acpi/q35/DSDT.bridge" , -"tests/data/acpi/q35/DSDT.mmio64" , -"tests/data/acpi/q35/DSDT.ipmibt" , -"tests/data/acpi/q35/DSDT.cphp" , -"tests/data/acpi/q35/DSDT.memhp" , -"tests/data/acpi/q35/DSDT.numamem" , -"tests/data/acpi/q35/DSDT.dimmpxm",
tests/data/acpi/q35/DSDT binary +0 -0
tests/data/acpi/q35/DSDT.bridge binary +0 -0
tests/data/acpi/q35/DSDT.cphp binary +0 -0
tests/data/acpi/q35/DSDT.dimmpxm binary +0 -0
tests/data/acpi/q35/DSDT.ipmibt binary +0 -0
tests/data/acpi/q35/DSDT.memhp binary +0 -0
tests/data/acpi/q35/DSDT.mmio64 binary +0 -0
tests/data/acpi/q35/DSDT.numamem binary +0 -0
Signature · 1 line
MST
[Qemu-devel] [PULL 11/11] tests/rebuild-expected-aml.sh: blow out difflist
In reply to Michael S. TsirkinAs expected files have been updated, make sure we
do not forget to remove them from the allowed
diff list.
--- tests/data/acpi/rebuild-expected-aml.sh | 3 +++ 1 file changed, 3 insertions(+)
tests/data/acpi/rebuild-expected-aml.sh +3 -0
@@ -29,5 +29,8 @@ for qemu in $qemu_bins; do TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test done +eval `grep SRC_PATH= config-host.mak` + +echo '/* List of comma-separated changed AML files to ignore */' > ${SRC_PATH}/tests/bios-tables-test-allowed-diff.h echo "The files were rebuilt and can be added to git."
Signature · 1 line
MST
Peter Maydell
AppliedRe: [Qemu-devel] [PULL 00/11] virtio, acpi: fixes, cleanups
In reply to Michael S. TsirkinQuoted 11 lines · Michael S. Tsirkin
The following changes since commit
f3d0bec9f80e4ed7796fffa834ba0a53f2094f7f:Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2019-06-14' into staging (2019-06-14 14:46:13 +0100)
are available in the Git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_upstreamfor you to fetch changes up to
5f6b3561bf58395fd6c906d7064a1a5693a2e426:
Quoted 8 lines
tests/rebuild-expected-aml.sh: blow out difflist (2019-06-16 16:44:44 -0400)----------------------------------------------------------------
virtio, acpi: fixes, cleanupsA bunch of minor fixes all over the place.
Signed-off-by Michael S. Tsirkin <[email protected]>
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.
-- PMM