diff --git a/backends/tpm/tpm_passthrough.c b/backends/tpm/tpm_passthrough.c index b7c7074c2a..a9f35ab7d6 100644 --- a/backends/tpm/tpm_passthrough.c +++ b/backends/tpm/tpm_passthrough.c @@ -211,7 +211,7 @@ static size_t tpm_passthrough_get_buffer_size(TPMBackend *tb) static int tpm_passthrough_open_sysfs_cancel(TPMPassthruState *tpm_pt) { int fd = -1; - char *dev; + const char *dev; char path[PATH_MAX]; if (tpm_pt->options->cancel_path) { diff --git a/block/vmdk.c b/block/vmdk.c index 3b35b63cb5..89e89cd10e 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1089,7 +1089,7 @@ vmdk_open_vmdk4(BlockDriverState *bs, BdrvChild *file, int flags, static int vmdk_parse_description(const char *desc, const char *opt_name, char *buf, int buf_size) { - char *opt_pos, *opt_end; + const char *opt_pos, *opt_end; const char *end = desc + strlen(desc); opt_pos = strstr(desc, opt_name); diff --git a/block/vvfat.c b/block/vvfat.c index 814796d918..e334b9febb 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1826,7 +1826,7 @@ cluster_was_modified(BDRVVVFATState *s, uint32_t cluster_num) static const char* get_basename(const char* path) { - char* basename = strrchr(path, '/'); + const char *basename = strrchr(path, '/'); if (basename == NULL) return path; else diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index dd5fb5667c..5b2fc06e58 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -362,7 +362,7 @@ static const char *get_feature_xml(const char *p, const char **newp, * qXfer:features:read:ANNEX:OFFSET,LENGTH' * ^p ^newp */ - char *term = strchr(p, ':'); + const char *term = strchr(p, ':'); *newp = term + 1; len = term - p; diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c index 79359d911a..ca0fff5fa9 100644 --- a/hw/9pfs/xen-9p-backend.c +++ b/hw/9pfs/xen-9p-backend.c @@ -310,7 +310,7 @@ static void xen_9pfs_bh(void *opaque) again: wait = ring->co != NULL && qemu_coroutine_entered(ring->co); - /* paired with the smb_wmb barriers in xen_9pfs_init_in_iov_from_pdu */ + /* paired with the smp_wmb barriers in xen_9pfs_init_in_iov_from_pdu */ smp_rmb(); if (wait) { cpu_relax(); diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index f5d93eb400..ca813203d7 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -986,7 +986,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, virtio_has_feature_ex(vdev->guest_features_ex, VIRTIO_NET_F_CTRL_VLAN)) { bool vlan = virtio_has_feature_ex(features, VIRTIO_NET_F_CTRL_VLAN); - memset(n->vlans, vlan ? 0 : 0xff, sizeof(n->vlans)); + memset(n->vlans, vlan ? 0 : 0xff, MAX_VLAN >> 3); } if (virtio_has_feature_ex(features, VIRTIO_NET_F_STANDBY)) { @@ -3598,8 +3598,7 @@ static const VMStateDescription vmstate_virtio_net_device = { * buffer; hold onto your endiannesses; it's actually used as a bitmap * but based on the uint. */ - VMSTATE_BUFFER_UNSAFE(vlans, VirtIONet, 0, - sizeof(typeof_field(VirtIONet, vlans))), + VMSTATE_BUFFER_POINTER_UNSAFE(vlans, VirtIONet, 0, MAX_VLAN >> 3), VMSTATE_WITH_TMP(VirtIONet, struct VirtIONetMigTmp, vmstate_virtio_net_has_vnet), VMSTATE_UINT8(mac_table.multi_overflow, VirtIONet), @@ -4017,7 +4016,8 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) n->mac_table.macs = g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN); - memset(n->vlans, 0xff, sizeof(n->vlans)); + n->vlans = g_malloc0(MAX_VLAN >> 3); + memset(n->vlans, 0xff, MAX_VLAN >> 3); nc = qemu_get_queue(n->nic); nc->rxfilter_notify_enabled = 1; @@ -4066,6 +4066,7 @@ static void virtio_net_device_unrealize(DeviceState *dev) n->netclient_type = NULL; g_free(n->mac_table.macs); + g_free(n->vlans); if (n->failover) { qobject_unref(n->primary_opts); diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 266a11514a..e654ea468a 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1261,7 +1261,7 @@ int vhost_virtqueue_start(struct vhost_dev *dev, BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); VirtioBusState *vbus = VIRTIO_BUS(qbus); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus); - hwaddr s, l, a; + hwaddr l; int r; int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx); struct vhost_vring_file file = { @@ -1272,8 +1272,17 @@ int vhost_virtqueue_start(struct vhost_dev *dev, }; struct VirtQueue *vvq = virtio_get_queue(vdev, idx); - a = virtio_queue_get_desc_addr(vdev, idx); - if (a == 0) { + vq->desc_size = virtio_queue_get_desc_size(vdev, idx); + vq->desc_phys = virtio_queue_get_desc_addr(vdev, idx); + vq->desc = NULL; + vq->avail_size = virtio_queue_get_avail_size(vdev, idx); + vq->avail_phys = virtio_queue_get_avail_addr(vdev, idx); + vq->avail = NULL; + vq->used_size = virtio_queue_get_used_size(vdev, idx); + vq->used_phys = virtio_queue_get_used_addr(vdev, idx); + vq->used = NULL; + + if (vq->desc_phys == 0) { /* Queue might not be ready for start */ return 0; } @@ -1301,24 +1310,23 @@ int vhost_virtqueue_start(struct vhost_dev *dev, } } - vq->desc_size = s = l = virtio_queue_get_desc_size(vdev, idx); - vq->desc_phys = a; - vq->desc = vhost_memory_map(dev, a, &l, false); - if (!vq->desc || l != s) { + l = vq->desc_size; + vq->desc = vhost_memory_map(dev, vq->desc_phys, &l, false); + if (!vq->desc || l != vq->desc_size) { r = -ENOMEM; goto fail_alloc_desc; } - vq->avail_size = s = l = virtio_queue_get_avail_size(vdev, idx); - vq->avail_phys = a = virtio_queue_get_avail_addr(vdev, idx); - vq->avail = vhost_memory_map(dev, a, &l, false); - if (!vq->avail || l != s) { + + l = vq->avail_size; + vq->avail = vhost_memory_map(dev, vq->avail_phys, &l, false); + if (!vq->avail || l != vq->avail_size) { r = -ENOMEM; goto fail_alloc_avail; } - vq->used_size = s = l = virtio_queue_get_used_size(vdev, idx); - vq->used_phys = a = virtio_queue_get_used_addr(vdev, idx); - vq->used = vhost_memory_map(dev, a, &l, true); - if (!vq->used || l != s) { + + l = vq->used_size; + vq->used = vhost_memory_map(dev, vq->used_phys, &l, true); + if (!vq->used || l != vq->used_size) { r = -ENOMEM; goto fail_alloc_used; } diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 6bccb25ac2..b72e484500 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -751,7 +751,7 @@ int pci_iommu_register_iotlb_notifier(PCIDevice *dev, uint32_t pasid, /** * pci_iommu_unregister_iotlb_notifier: unregister a notifier that has been - * registerd with pci_iommu_register_iotlb_notifier. + * registered with pci_iommu_register_iotlb_notifier. * * Returns 0 on success, or a negative errno otherwise. * diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index f708355306..5b8ab7bda7 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -202,7 +202,7 @@ struct VirtIONet { uint8_t uni_overflow; uint8_t *macs; } mac_table; - uint32_t vlans[MAX_VLAN]; + uint32_t *vlans; virtio_net_conf net_conf; NICConf nic_conf; DeviceState *qdev; diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index df57e6550a..a87a5efa42 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -727,6 +727,15 @@ extern const VMStateInfo vmstate_info_qlist; .offset = offsetof(_state, _field), \ } +#define VMSTATE_BUFFER_POINTER_UNSAFE(_field, _state, _version, _size) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .size = (_size), \ + .info = &vmstate_info_buffer, \ + .flags = VMS_BUFFER | VMS_POINTER, \ + .offset = offsetof(_state, _field), \ +} + /* Allocate a temporary of type 'tmp_type', set tmp->parent to _state * and execute the vmsd on the temporary. Note that we're working with * the whole of _state here, not a field within it. diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index cf8d7cf7e6..3cb45a1467 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -141,6 +141,12 @@ QEMU_EXTERN_C int daemon(int, int); #undef ELF_DATA #undef ELF_ARCH +/* + * Avoid conflict with Solaris FSCALE definition from header, + * but we might as well do this unconditionally. + */ +#undef FSCALE + #ifdef CONFIG_IOVEC #include #endif diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 7c9fe61041..715ef021a9 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -1467,7 +1467,8 @@ retry: static int postcopy_temp_pages_setup(MigrationIncomingState *mis) { PostcopyTmpPage *tmp_page; - int err, i, channels; + int err; + unsigned i, channels; void *temp_page; if (migrate_postcopy_preempt()) { @@ -1479,7 +1480,7 @@ static int postcopy_temp_pages_setup(MigrationIncomingState *mis) } channels = mis->postcopy_channels; - mis->postcopy_tmp_pages = g_malloc0_n(sizeof(PostcopyTmpPage), channels); + mis->postcopy_tmp_pages = g_new0(PostcopyTmpPage, channels); for (i = 0; i < channels; i++) { tmp_page = &mis->postcopy_tmp_pages[i]; diff --git a/qga/commands-linux.c b/qga/commands-linux.c index 4a09ddc760..c639a60a94 100644 --- a/qga/commands-linux.c +++ b/qga/commands-linux.c @@ -403,7 +403,8 @@ static bool build_guest_fsinfo_for_pci_dev(char const *syspath, int i, offset, nhosts = 0, pcilen; GuestPCIAddress *pciaddr = disk->pci_controller; bool has_ata = false, has_host = false, has_tgt = false; - char *p, *driver = NULL; + const char *p; + char *driver = NULL; bool ret = false; p = strstr(syspath, "/devices/pci"); @@ -543,7 +544,7 @@ static bool build_guest_fsinfo_for_nonpci_virtio(char const *syspath, Error **errp) { unsigned int tgt[3]; - char *p; + const char *p; if (!strstr(syspath, "/virtio") || !strstr(syspath, "/block")) { g_debug("Unsupported virtio device '%s'", syspath); @@ -575,7 +576,7 @@ static bool build_guest_fsinfo_for_ccw_dev(char const *syspath, Error **errp) { unsigned int cssid, ssid, subchno, devno; - char *p; + const char *p; p = strstr(syspath, "/devices/css"); if (!p || sscanf(p + 12, "%*x/%x.%x.%x/%*x.%*x.%x/", diff --git a/scripts/modinfo-collect.py b/scripts/modinfo-collect.py index 6ebaea989d..db78b16c1f 100644 --- a/scripts/modinfo-collect.py +++ b/scripts/modinfo-collect.py @@ -41,7 +41,7 @@ def main(args): for obj in args: entry = compile_commands.get(obj, None) if not entry: - sys.stderr.print('modinfo: Could not find object file', obj) + sys.stderr.write(f'modinfo: Could not find object file {obj}') sys.exit(1) src = entry['file'] if not src.endswith('.c'): diff --git a/scripts/nsis.py b/scripts/nsis.py index 8f469634eb..33069f4a86 100644 --- a/scripts/nsis.py +++ b/scripts/nsis.py @@ -114,7 +114,7 @@ def main(): "-DSRCDIR=" + args.srcdir, "-DBINDIR=" + destdir + prefix, ] - if args.cpu == "x86_64": + if args.cpu == "aarch64" or args.cpu == "x86_64": makensis += ["-DW64"] makensis += ["-DDLLDIR=" + dlldir] diff --git a/ui/ui-hmp-cmds.c b/ui/ui-hmp-cmds.c index 980a8bbc51..6c93d452c9 100644 --- a/ui/ui-hmp-cmds.c +++ b/ui/ui-hmp-cmds.c @@ -418,7 +418,7 @@ err_out: void sendkey_completion(ReadLineState *rs, int nb_args, const char *str) { int i; - char *sep; + const char *sep; size_t len; if (nb_args != 2) { diff --git a/util/log.c b/util/log.c index 41f78ce86b..c44d66b5ce 100644 --- a/util/log.c +++ b/util/log.c @@ -203,7 +203,7 @@ static ValidFilenameTemplateResult valid_filename_template(const char *filename, bool per_thread, Error **errp) { if (filename) { - char *pidstr = strstr(filename, "%"); + const char *pidstr = strstr(filename, "%"); if (pidstr) { /* We only accept one %d, no other format strings */