Merge remote-tracking branch 'stefanha/trivial-patches' into staging
# By Markus Armbruster (12) and others
# Via Stefan Hajnoczi
* stefanha/trivial-patches:
  qmp-commands.hx: s/tray-open/tray_open/ to match qapi schema
  tests: Fix {rtc, m48t59}-test build on illumos
  qemu-pixman.h: Avoid mutual inclusion loop with console.h
  qemu-ga: Fix unchecked strdup() by converting to g_strdup()
  qapi: Fix unchecked strdup() by converting to g_strdup()
  libcacard: Fix unchecked strdup() by converting to g_strdup()
  qemu-log: Plug trivial memory leak in cpu_set_log_filename()
  qemu-log: Fix unchecked strdup() by converting to g_strdup()
  virtfs-proxy-helper: Fix unchecked strdup() by conv. to g_strdup()
  spice: Fix unchecked strdup() by converting to g_strdup()
  readline: Fix unchecked strdup() by converting to g_strdup()
  hw/9pfs: Fix unchecked strdup() by converting to g_strdup()
  g_strdup(NULL) returns NULL; simplify
  g_malloc(0) and g_malloc0(0) return NULL; simplify
  xilinx_axidma: Fix debug mode compile messages
  cadence_gem: Debug mode compile fixes
  cadence_ttc: Debug mode compile fixes
  vnc: Clean up vncws_send_handshake_response()
			
			
This commit is contained in:
		
						commit
						b0df98f3a2
					
				@ -737,11 +737,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
 | 
				
			|||||||
     * l1_table_offset when it is the current s->l1_table_offset! Be careful
 | 
					     * l1_table_offset when it is the current s->l1_table_offset! Be careful
 | 
				
			||||||
     * when changing this! */
 | 
					     * when changing this! */
 | 
				
			||||||
    if (l1_table_offset != s->l1_table_offset) {
 | 
					    if (l1_table_offset != s->l1_table_offset) {
 | 
				
			||||||
        if (l1_size2 != 0) {
 | 
					 | 
				
			||||||
        l1_table = g_malloc0(align_offset(l1_size2, 512));
 | 
					        l1_table = g_malloc0(align_offset(l1_size2, 512));
 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            l1_table = NULL;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        l1_allocated = 1;
 | 
					        l1_allocated = 1;
 | 
				
			||||||
        if (bdrv_pread(bs->file, l1_table_offset,
 | 
					        if (bdrv_pread(bs->file, l1_table_offset,
 | 
				
			||||||
                       l1_table, l1_size2) != l1_size2)
 | 
					                       l1_table, l1_size2) != l1_size2)
 | 
				
			||||||
 | 
				
			|||||||
@ -443,9 +443,7 @@ static int vdi_open(BlockDriverState *bs, int flags)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    bmap_size = header.blocks_in_image * sizeof(uint32_t);
 | 
					    bmap_size = header.blocks_in_image * sizeof(uint32_t);
 | 
				
			||||||
    bmap_size = (bmap_size + SECTOR_SIZE - 1) / SECTOR_SIZE;
 | 
					    bmap_size = (bmap_size + SECTOR_SIZE - 1) / SECTOR_SIZE;
 | 
				
			||||||
    if (bmap_size > 0) {
 | 
					 | 
				
			||||||
    s->bmap = g_malloc(bmap_size * SECTOR_SIZE);
 | 
					    s->bmap = g_malloc(bmap_size * SECTOR_SIZE);
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    ret = bdrv_read(bs->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size);
 | 
					    ret = bdrv_read(bs->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size);
 | 
				
			||||||
    if (ret < 0) {
 | 
					    if (ret < 0) {
 | 
				
			||||||
        goto fail_free_bmap;
 | 
					        goto fail_free_bmap;
 | 
				
			||||||
 | 
				
			|||||||
@ -1039,7 +1039,7 @@ int main(int argc, char **argv)
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        switch (c) {
 | 
					        switch (c) {
 | 
				
			||||||
        case 'p':
 | 
					        case 'p':
 | 
				
			||||||
            rpath = strdup(optarg);
 | 
					            rpath = g_strdup(optarg);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case 'n':
 | 
					        case 'n':
 | 
				
			||||||
            is_daemon = false;
 | 
					            is_daemon = false;
 | 
				
			||||||
@ -1048,7 +1048,7 @@ int main(int argc, char **argv)
 | 
				
			|||||||
            sock = atoi(optarg);
 | 
					            sock = atoi(optarg);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case 's':
 | 
					        case 's':
 | 
				
			||||||
            sock_name = strdup(optarg);
 | 
					            sock_name = g_strdup(optarg);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case 'u':
 | 
					        case 'u':
 | 
				
			||||||
            own_u = atoi(optarg);
 | 
					            own_u = atoi(optarg);
 | 
				
			||||||
 | 
				
			|||||||
@ -85,11 +85,7 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    s->ctx.export_flags = fse->export_flags;
 | 
					    s->ctx.export_flags = fse->export_flags;
 | 
				
			||||||
    if (fse->path) {
 | 
					 | 
				
			||||||
    s->ctx.fs_root = g_strdup(fse->path);
 | 
					    s->ctx.fs_root = g_strdup(fse->path);
 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        s->ctx.fs_root = NULL;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    s->ctx.exops.get_st_gen = NULL;
 | 
					    s->ctx.exops.get_st_gen = NULL;
 | 
				
			||||||
    len = strlen(conf->tag);
 | 
					    len = strlen(conf->tag);
 | 
				
			||||||
    if (len > MAX_TAG_LEN - 1) {
 | 
					    if (len > MAX_TAG_LEN - 1) {
 | 
				
			||||||
@ -98,7 +94,7 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
 | 
				
			|||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    s->tag = strdup(conf->tag);
 | 
					    s->tag = g_strdup(conf->tag);
 | 
				
			||||||
    s->ctx.uid = -1;
 | 
					    s->ctx.uid = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    s->ops = fse->ops;
 | 
					    s->ops = fse->ops;
 | 
				
			||||||
 | 
				
			|||||||
@ -46,7 +46,7 @@ static const char *local_mapped_attr_path(FsContext *ctx,
 | 
				
			|||||||
                                          const char *path, char *buffer)
 | 
					                                          const char *path, char *buffer)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    char *dir_name;
 | 
					    char *dir_name;
 | 
				
			||||||
    char *tmp_path = strdup(path);
 | 
					    char *tmp_path = g_strdup(path);
 | 
				
			||||||
    char *base_name = basename(tmp_path);
 | 
					    char *base_name = basename(tmp_path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* NULL terminate the directory */
 | 
					    /* NULL terminate the directory */
 | 
				
			||||||
@ -55,7 +55,7 @@ static const char *local_mapped_attr_path(FsContext *ctx,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    snprintf(buffer, PATH_MAX, "%s/%s/%s/%s",
 | 
					    snprintf(buffer, PATH_MAX, "%s/%s/%s/%s",
 | 
				
			||||||
             ctx->fs_root, dir_name, VIRTFS_META_DIR, base_name);
 | 
					             ctx->fs_root, dir_name, VIRTFS_META_DIR, base_name);
 | 
				
			||||||
    free(tmp_path);
 | 
					    g_free(tmp_path);
 | 
				
			||||||
    return buffer;
 | 
					    return buffer;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -130,7 +130,7 @@ static int local_create_mapped_attr_dir(FsContext *ctx, const char *path)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    int err;
 | 
					    int err;
 | 
				
			||||||
    char attr_dir[PATH_MAX];
 | 
					    char attr_dir[PATH_MAX];
 | 
				
			||||||
    char *tmp_path = strdup(path);
 | 
					    char *tmp_path = g_strdup(path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    snprintf(attr_dir, PATH_MAX, "%s/%s/%s",
 | 
					    snprintf(attr_dir, PATH_MAX, "%s/%s/%s",
 | 
				
			||||||
             ctx->fs_root, dirname(tmp_path), VIRTFS_META_DIR);
 | 
					             ctx->fs_root, dirname(tmp_path), VIRTFS_META_DIR);
 | 
				
			||||||
@ -139,7 +139,7 @@ static int local_create_mapped_attr_dir(FsContext *ctx, const char *path)
 | 
				
			|||||||
    if (err < 0 && errno == EEXIST) {
 | 
					    if (err < 0 && errno == EEXIST) {
 | 
				
			||||||
        err = 0;
 | 
					        err = 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    free(tmp_path);
 | 
					    g_free(tmp_path);
 | 
				
			||||||
    return err;
 | 
					    return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -3101,11 +3101,7 @@ static void v9fs_xattrcreate(void *opaque)
 | 
				
			|||||||
    xattr_fidp->fs.xattr.flags = flags;
 | 
					    xattr_fidp->fs.xattr.flags = flags;
 | 
				
			||||||
    v9fs_string_init(&xattr_fidp->fs.xattr.name);
 | 
					    v9fs_string_init(&xattr_fidp->fs.xattr.name);
 | 
				
			||||||
    v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name);
 | 
					    v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name);
 | 
				
			||||||
    if (size) {
 | 
					 | 
				
			||||||
    xattr_fidp->fs.xattr.value = g_malloc(size);
 | 
					    xattr_fidp->fs.xattr.value = g_malloc(size);
 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        xattr_fidp->fs.xattr.value = NULL;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    err = offset;
 | 
					    err = offset;
 | 
				
			||||||
    put_fid(pdu, file_fidp);
 | 
					    put_fid(pdu, file_fidp);
 | 
				
			||||||
out_nofid:
 | 
					out_nofid:
 | 
				
			||||||
 | 
				
			|||||||
@ -18,10 +18,8 @@ void blkconf_serial(BlockConf *conf, char **serial)
 | 
				
			|||||||
    if (!*serial) {
 | 
					    if (!*serial) {
 | 
				
			||||||
        /* try to fall back to value set with legacy -drive serial=... */
 | 
					        /* try to fall back to value set with legacy -drive serial=... */
 | 
				
			||||||
        dinfo = drive_get_by_blockdev(conf->bs);
 | 
					        dinfo = drive_get_by_blockdev(conf->bs);
 | 
				
			||||||
        if (dinfo->serial) {
 | 
					 | 
				
			||||||
        *serial = g_strdup(dinfo->serial);
 | 
					        *serial = g_strdup(dinfo->serial);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int blkconf_geometry(BlockConf *conf, int *ptrans,
 | 
					int blkconf_geometry(BlockConf *conf, int *ptrans,
 | 
				
			||||||
 | 
				
			|||||||
@ -687,14 +687,15 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    packet_desc_addr = s->rx_desc_addr;
 | 
					    packet_desc_addr = s->rx_desc_addr;
 | 
				
			||||||
    while (1) {
 | 
					    while (1) {
 | 
				
			||||||
        DB_PRINT("read descriptor 0x%x\n", packet_desc_addr);
 | 
					        DB_PRINT("read descriptor 0x%x\n", (unsigned)packet_desc_addr);
 | 
				
			||||||
        /* read current descriptor */
 | 
					        /* read current descriptor */
 | 
				
			||||||
        cpu_physical_memory_read(packet_desc_addr,
 | 
					        cpu_physical_memory_read(packet_desc_addr,
 | 
				
			||||||
                                 (uint8_t *)&desc[0], sizeof(desc));
 | 
					                                 (uint8_t *)&desc[0], sizeof(desc));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /* Descriptor owned by software ? */
 | 
					        /* Descriptor owned by software ? */
 | 
				
			||||||
        if (rx_desc_get_ownership(desc) == 1) {
 | 
					        if (rx_desc_get_ownership(desc) == 1) {
 | 
				
			||||||
            DB_PRINT("descriptor 0x%x owned by sw.\n", packet_desc_addr);
 | 
					            DB_PRINT("descriptor 0x%x owned by sw.\n",
 | 
				
			||||||
 | 
					                     (unsigned)packet_desc_addr);
 | 
				
			||||||
            s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_NOBUF;
 | 
					            s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_NOBUF;
 | 
				
			||||||
            /* Handle interrupt consequences */
 | 
					            /* Handle interrupt consequences */
 | 
				
			||||||
            gem_update_int_status(s);
 | 
					            gem_update_int_status(s);
 | 
				
			||||||
@ -709,7 +710,7 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
 | 
				
			|||||||
         */
 | 
					         */
 | 
				
			||||||
        if (rx_desc_get_buffer(desc) == 0) {
 | 
					        if (rx_desc_get_buffer(desc) == 0) {
 | 
				
			||||||
            DB_PRINT("Invalid RX buffer (NULL) for descriptor 0x%x\n",
 | 
					            DB_PRINT("Invalid RX buffer (NULL) for descriptor 0x%x\n",
 | 
				
			||||||
                       packet_desc_addr);
 | 
					                     (unsigned)packet_desc_addr);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -749,7 +750,7 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
 | 
				
			|||||||
        s->rx_desc_addr += 8;
 | 
					        s->rx_desc_addr += 8;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DB_PRINT("set SOF, OWN on descriptor 0x%08x\n", packet_desc_addr);
 | 
					    DB_PRINT("set SOF, OWN on descriptor 0x%08x\n", (unsigned)packet_desc_addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Count it */
 | 
					    /* Count it */
 | 
				
			||||||
    gem_receive_updatestats(s, buf, size);
 | 
					    gem_receive_updatestats(s, buf, size);
 | 
				
			||||||
@ -861,7 +862,8 @@ static void gem_transmit(GemState *s)
 | 
				
			|||||||
         */
 | 
					         */
 | 
				
			||||||
        if ((tx_desc_get_buffer(desc) == 0) ||
 | 
					        if ((tx_desc_get_buffer(desc) == 0) ||
 | 
				
			||||||
            (tx_desc_get_length(desc) == 0)) {
 | 
					            (tx_desc_get_length(desc) == 0)) {
 | 
				
			||||||
            DB_PRINT("Invalid TX descriptor @ 0x%x\n", packet_desc_addr);
 | 
					            DB_PRINT("Invalid TX descriptor @ 0x%x\n",
 | 
				
			||||||
 | 
					                     (unsigned)packet_desc_addr);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1031,10 +1033,11 @@ static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size)
 | 
				
			|||||||
    offset >>= 2;
 | 
					    offset >>= 2;
 | 
				
			||||||
    retval = s->regs[offset];
 | 
					    retval = s->regs[offset];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DB_PRINT("offset: 0x%04x read: 0x%08x\n", offset*4, retval);
 | 
					    DB_PRINT("offset: 0x%04x read: 0x%08x\n", (unsigned)offset*4, retval);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch (offset) {
 | 
					    switch (offset) {
 | 
				
			||||||
    case GEM_ISR:
 | 
					    case GEM_ISR:
 | 
				
			||||||
 | 
					        DB_PRINT("lowering irq on ISR read\n");
 | 
				
			||||||
        qemu_set_irq(s->irq, 0);
 | 
					        qemu_set_irq(s->irq, 0);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    case GEM_PHYMNTNC:
 | 
					    case GEM_PHYMNTNC:
 | 
				
			||||||
@ -1073,7 +1076,7 @@ static void gem_write(void *opaque, hwaddr offset, uint64_t val,
 | 
				
			|||||||
    GemState *s = (GemState *)opaque;
 | 
					    GemState *s = (GemState *)opaque;
 | 
				
			||||||
    uint32_t readonly;
 | 
					    uint32_t readonly;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DB_PRINT("offset: 0x%04x write: 0x%08x ", offset, (unsigned)val);
 | 
					    DB_PRINT("offset: 0x%04x write: 0x%08x ", (unsigned)offset, (unsigned)val);
 | 
				
			||||||
    offset >>= 2;
 | 
					    offset >>= 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Squash bits which are read only in write value */
 | 
					    /* Squash bits which are read only in write value */
 | 
				
			||||||
 | 
				
			|||||||
@ -302,7 +302,7 @@ static uint64_t cadence_ttc_read(void *opaque, hwaddr offset,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    uint32_t ret = cadence_ttc_read_imp(opaque, offset);
 | 
					    uint32_t ret = cadence_ttc_read_imp(opaque, offset);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DB_PRINT("addr: %08x data: %08x\n", offset, ret);
 | 
					    DB_PRINT("addr: %08x data: %08x\n", (unsigned)offset, (unsigned)ret);
 | 
				
			||||||
    return ret;
 | 
					    return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -311,7 +311,7 @@ static void cadence_ttc_write(void *opaque, hwaddr offset,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    CadenceTimerState *s = cadence_timer_from_addr(opaque, offset);
 | 
					    CadenceTimerState *s = cadence_timer_from_addr(opaque, offset);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DB_PRINT("addr: %08x data %08x\n", offset, (unsigned)value);
 | 
					    DB_PRINT("addr: %08x data %08x\n", (unsigned)offset, (unsigned)value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    cadence_timer_sync(s);
 | 
					    cadence_timer_sync(s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -269,11 +269,8 @@ static inline void vhost_dev_log_resize(struct vhost_dev* dev, uint64_t size)
 | 
				
			|||||||
    vhost_log_chunk_t *log;
 | 
					    vhost_log_chunk_t *log;
 | 
				
			||||||
    uint64_t log_base;
 | 
					    uint64_t log_base;
 | 
				
			||||||
    int r, i;
 | 
					    int r, i;
 | 
				
			||||||
    if (size) {
 | 
					
 | 
				
			||||||
    log = g_malloc0(size * sizeof *log);
 | 
					    log = g_malloc0(size * sizeof *log);
 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        log = NULL;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    log_base = (uint64_t)(unsigned long)log;
 | 
					    log_base = (uint64_t)(unsigned long)log;
 | 
				
			||||||
    r = ioctl(dev->control, VHOST_SET_LOG_BASE, &log_base);
 | 
					    r = ioctl(dev->control, VHOST_SET_LOG_BASE, &log_base);
 | 
				
			||||||
    assert(r >= 0);
 | 
					    assert(r >= 0);
 | 
				
			||||||
 | 
				
			|||||||
@ -444,7 +444,7 @@ static void axidma_write(void *opaque, hwaddr addr,
 | 
				
			|||||||
            break;
 | 
					            break;
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
            D(qemu_log("%s: ch=%d addr=" TARGET_FMT_plx " v=%x\n",
 | 
					            D(qemu_log("%s: ch=%d addr=" TARGET_FMT_plx " v=%x\n",
 | 
				
			||||||
                  __func__, sid, addr * 4, value));
 | 
					                  __func__, sid, addr * 4, (unsigned)value));
 | 
				
			||||||
            s->regs[addr] = value;
 | 
					            s->regs[addr] = value;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -15,7 +15,7 @@
 | 
				
			|||||||
#pragma GCC diagnostic error "-Wredundant-decls"
 | 
					#pragma GCC diagnostic error "-Wredundant-decls"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "console.h"
 | 
					#include "qemu/typedefs.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * pixman image formats are defined to be native endian,
 | 
					 * pixman image formats are defined to be native endian,
 | 
				
			||||||
 | 
				
			|||||||
@ -21,6 +21,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "qemu/thread.h"
 | 
					#include "qemu/thread.h"
 | 
				
			||||||
#include "ui/qemu-pixman.h"
 | 
					#include "ui/qemu-pixman.h"
 | 
				
			||||||
 | 
					#include "ui/console.h"
 | 
				
			||||||
#include "sysemu/sysemu.h"
 | 
					#include "sysemu/sysemu.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define NUM_MEMSLOTS 8
 | 
					#define NUM_MEMSLOTS 8
 | 
				
			||||||
 | 
				
			|||||||
@ -454,7 +454,7 @@ vreader_emul_new(PK11SlotInfo *slot, VCardEmulType type, const char *params)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    new_reader_emul->slot = PK11_ReferenceSlot(slot);
 | 
					    new_reader_emul->slot = PK11_ReferenceSlot(slot);
 | 
				
			||||||
    new_reader_emul->default_type = type;
 | 
					    new_reader_emul->default_type = type;
 | 
				
			||||||
    new_reader_emul->type_params = strdup(params);
 | 
					    new_reader_emul->type_params = g_strdup(params);
 | 
				
			||||||
    new_reader_emul->present = PR_FALSE;
 | 
					    new_reader_emul->present = PR_FALSE;
 | 
				
			||||||
    new_reader_emul->series = 0;
 | 
					    new_reader_emul->series = 0;
 | 
				
			||||||
    new_reader_emul->saved_vcard = NULL;
 | 
					    new_reader_emul->saved_vcard = NULL;
 | 
				
			||||||
@ -997,7 +997,7 @@ vcard_emul_init(const VCardEmulOptions *options)
 | 
				
			|||||||
    /* We should control this with options. For now we mirror out any
 | 
					    /* We should control this with options. For now we mirror out any
 | 
				
			||||||
     * removable hardware slot */
 | 
					     * removable hardware slot */
 | 
				
			||||||
    default_card_type = options->hw_card_type;
 | 
					    default_card_type = options->hw_card_type;
 | 
				
			||||||
    default_type_params = strdup(options->hw_type_params);
 | 
					    default_type_params = g_strdup(options->hw_type_params);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SECMOD_GetReadLock(module_lock);
 | 
					    SECMOD_GetReadLock(module_lock);
 | 
				
			||||||
    for (mlp = module_list; mlp; mlp = mlp->next) {
 | 
					    for (mlp = module_list; mlp; mlp = mlp->next) {
 | 
				
			||||||
 | 
				
			|||||||
@ -49,7 +49,7 @@ vreader_new(const char *name, VReaderEmul *private,
 | 
				
			|||||||
    reader = (VReader *)g_malloc(sizeof(VReader));
 | 
					    reader = (VReader *)g_malloc(sizeof(VReader));
 | 
				
			||||||
    qemu_mutex_init(&reader->lock);
 | 
					    qemu_mutex_init(&reader->lock);
 | 
				
			||||||
    reader->reference_count = 1;
 | 
					    reader->reference_count = 1;
 | 
				
			||||||
    reader->name = name ? strdup(name) : NULL;
 | 
					    reader->name = g_strdup(name);
 | 
				
			||||||
    reader->card = NULL;
 | 
					    reader->card = NULL;
 | 
				
			||||||
    reader->id = (vreader_id_t)-1;
 | 
					    reader->id = (vreader_id_t)-1;
 | 
				
			||||||
    reader->reader_private = private;
 | 
					    reader->reader_private = private;
 | 
				
			||||||
 | 
				
			|||||||
@ -503,8 +503,8 @@ main(
 | 
				
			|||||||
        command_line_options = vcard_emul_options(emul_args);
 | 
					        command_line_options = vcard_emul_options(emul_args);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qemu_host = strdup(argv[argc - 2]);
 | 
					    qemu_host = g_strdup(argv[argc - 2]);
 | 
				
			||||||
    qemu_port = strdup(argv[argc - 1]);
 | 
					    qemu_port = g_strdup(argv[argc - 1]);
 | 
				
			||||||
    sock = connect_to_qemu(qemu_host, qemu_port);
 | 
					    sock = connect_to_qemu(qemu_host, qemu_port);
 | 
				
			||||||
    if (sock == -1) {
 | 
					    if (sock == -1) {
 | 
				
			||||||
        fprintf(stderr, "error opening socket, exiting.\n");
 | 
					        fprintf(stderr, "error opening socket, exiting.\n");
 | 
				
			||||||
 | 
				
			|||||||
@ -566,9 +566,7 @@ static int net_init_nic(const NetClientOptions *opts, const char *name,
 | 
				
			|||||||
        assert(peer);
 | 
					        assert(peer);
 | 
				
			||||||
        nd->netdev = peer;
 | 
					        nd->netdev = peer;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (name) {
 | 
					 | 
				
			||||||
    nd->name = g_strdup(name);
 | 
					    nd->name = g_strdup(name);
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (nic->has_model) {
 | 
					    if (nic->has_model) {
 | 
				
			||||||
        nd->model = g_strdup(nic->model);
 | 
					        nd->model = g_strdup(nic->model);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -92,7 +92,7 @@ char **qmp_get_command_list(void)
 | 
				
			|||||||
    list_head = list = g_malloc0(count * sizeof(char *));
 | 
					    list_head = list = g_malloc0(count * sizeof(char *));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QTAILQ_FOREACH(cmd, &qmp_commands, node) {
 | 
					    QTAILQ_FOREACH(cmd, &qmp_commands, node) {
 | 
				
			||||||
        *list = strdup(cmd->name);
 | 
					        *list = g_strdup(cmd->name);
 | 
				
			||||||
        list++;
 | 
					        list++;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										15
									
								
								qemu-log.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								qemu-log.c
									
									
									
									
									
								
							@ -21,10 +21,12 @@
 | 
				
			|||||||
#include "qemu/log.h"
 | 
					#include "qemu/log.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef WIN32
 | 
					#ifdef WIN32
 | 
				
			||||||
static const char *logfilename = "qemu.log";
 | 
					#define DEFAULT_LOGFILENAME "qemu.log"
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
static const char *logfilename = "/tmp/qemu.log";
 | 
					#define DEFAULT_LOGFILENAME "/tmp/qemu.log"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static char *logfilename;
 | 
				
			||||||
FILE *qemu_logfile;
 | 
					FILE *qemu_logfile;
 | 
				
			||||||
int qemu_loglevel;
 | 
					int qemu_loglevel;
 | 
				
			||||||
static int log_append = 0;
 | 
					static int log_append = 0;
 | 
				
			||||||
@ -54,11 +56,13 @@ void qemu_log_mask(int mask, const char *fmt, ...)
 | 
				
			|||||||
/* enable or disable low levels log */
 | 
					/* enable or disable low levels log */
 | 
				
			||||||
void qemu_set_log(int log_flags, bool use_own_buffers)
 | 
					void qemu_set_log(int log_flags, bool use_own_buffers)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    const char *fname = logfilename ?: DEFAULT_LOGFILENAME;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qemu_loglevel = log_flags;
 | 
					    qemu_loglevel = log_flags;
 | 
				
			||||||
    if (qemu_loglevel && !qemu_logfile) {
 | 
					    if (qemu_loglevel && !qemu_logfile) {
 | 
				
			||||||
        qemu_logfile = fopen(logfilename, log_append ? "a" : "w");
 | 
					        qemu_logfile = fopen(fname, log_append ? "a" : "w");
 | 
				
			||||||
        if (!qemu_logfile) {
 | 
					        if (!qemu_logfile) {
 | 
				
			||||||
            perror(logfilename);
 | 
					            perror(fname);
 | 
				
			||||||
            _exit(1);
 | 
					            _exit(1);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        /* must avoid mmap() usage of glibc by setting a buffer "by hand" */
 | 
					        /* must avoid mmap() usage of glibc by setting a buffer "by hand" */
 | 
				
			||||||
@ -84,7 +88,8 @@ void qemu_set_log(int log_flags, bool use_own_buffers)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void cpu_set_log_filename(const char *filename)
 | 
					void cpu_set_log_filename(const char *filename)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    logfilename = strdup(filename);
 | 
					    g_free(logfilename);
 | 
				
			||||||
 | 
					    logfilename = g_strdup(filename);
 | 
				
			||||||
    if (qemu_logfile) {
 | 
					    if (qemu_logfile) {
 | 
				
			||||||
        fclose(qemu_logfile);
 | 
					        fclose(qemu_logfile);
 | 
				
			||||||
        qemu_logfile = NULL;
 | 
					        qemu_logfile = NULL;
 | 
				
			||||||
 | 
				
			|||||||
@ -61,7 +61,7 @@ struct GuestAgentInfo *qmp_guest_info(Error **err)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    while (*cmd_list) {
 | 
					    while (*cmd_list) {
 | 
				
			||||||
        cmd_info = g_malloc0(sizeof(GuestAgentCommandInfo));
 | 
					        cmd_info = g_malloc0(sizeof(GuestAgentCommandInfo));
 | 
				
			||||||
        cmd_info->name = strdup(*cmd_list);
 | 
					        cmd_info->name = g_strdup(*cmd_list);
 | 
				
			||||||
        cmd_info->enabled = qmp_command_is_enabled(cmd_info->name);
 | 
					        cmd_info->enabled = qmp_command_is_enabled(cmd_info->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cmd_info_list = g_malloc0(sizeof(GuestAgentCommandInfoList));
 | 
					        cmd_info_list = g_malloc0(sizeof(GuestAgentCommandInfoList));
 | 
				
			||||||
 | 
				
			|||||||
@ -1659,7 +1659,7 @@ Each json-object contain the following:
 | 
				
			|||||||
         - Possible values: "unknown"
 | 
					         - Possible values: "unknown"
 | 
				
			||||||
- "removable": true if the device is removable, false otherwise (json-bool)
 | 
					- "removable": true if the device is removable, false otherwise (json-bool)
 | 
				
			||||||
- "locked": true if the device is locked, false otherwise (json-bool)
 | 
					- "locked": true if the device is locked, false otherwise (json-bool)
 | 
				
			||||||
- "tray-open": only present if removable, true if the device has a tray,
 | 
					- "tray_open": only present if removable, true if the device has a tray,
 | 
				
			||||||
               and it is open (json-bool)
 | 
					               and it is open (json-bool)
 | 
				
			||||||
- "inserted": only present if the device is inserted, it is a json-object
 | 
					- "inserted": only present if the device is inserted, it is a json-object
 | 
				
			||||||
   containing the following:
 | 
					   containing the following:
 | 
				
			||||||
 | 
				
			|||||||
@ -247,14 +247,14 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    if (idx == READLINE_MAX_CMDS) {
 | 
					    if (idx == READLINE_MAX_CMDS) {
 | 
				
			||||||
	/* Need to get one free slot */
 | 
						/* Need to get one free slot */
 | 
				
			||||||
	free(rs->history[0]);
 | 
					        g_free(rs->history[0]);
 | 
				
			||||||
	memmove(rs->history, &rs->history[1],
 | 
						memmove(rs->history, &rs->history[1],
 | 
				
			||||||
	        (READLINE_MAX_CMDS - 1) * sizeof(char *));
 | 
						        (READLINE_MAX_CMDS - 1) * sizeof(char *));
 | 
				
			||||||
	rs->history[READLINE_MAX_CMDS - 1] = NULL;
 | 
						rs->history[READLINE_MAX_CMDS - 1] = NULL;
 | 
				
			||||||
	idx = READLINE_MAX_CMDS - 1;
 | 
						idx = READLINE_MAX_CMDS - 1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (new_entry == NULL)
 | 
					    if (new_entry == NULL)
 | 
				
			||||||
	new_entry = strdup(cmdline);
 | 
					        new_entry = g_strdup(cmdline);
 | 
				
			||||||
    rs->history[idx] = new_entry;
 | 
					    rs->history[idx] = new_entry;
 | 
				
			||||||
    rs->hist_entry = -1;
 | 
					    rs->hist_entry = -1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -225,12 +225,8 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork,
 | 
				
			|||||||
        pstrcpy(slirp->client_hostname, sizeof(slirp->client_hostname),
 | 
					        pstrcpy(slirp->client_hostname, sizeof(slirp->client_hostname),
 | 
				
			||||||
                vhostname);
 | 
					                vhostname);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (tftp_path) {
 | 
					 | 
				
			||||||
    slirp->tftp_prefix = g_strdup(tftp_path);
 | 
					    slirp->tftp_prefix = g_strdup(tftp_path);
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (bootfile) {
 | 
					 | 
				
			||||||
    slirp->bootp_filename = g_strdup(bootfile);
 | 
					    slirp->bootp_filename = g_strdup(bootfile);
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    slirp->vdhcp_startaddr = vdhcp_start;
 | 
					    slirp->vdhcp_startaddr = vdhcp_start;
 | 
				
			||||||
    slirp->vnameserver_addr = vnameserver;
 | 
					    slirp->vnameserver_addr = vnameserver;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -142,7 +142,9 @@ static void cmos_get_date_time(struct tm *date)
 | 
				
			|||||||
    date->tm_mday = mday;
 | 
					    date->tm_mday = mday;
 | 
				
			||||||
    date->tm_mon = mon - 1;
 | 
					    date->tm_mon = mon - 1;
 | 
				
			||||||
    date->tm_year = base_year + year - 1900;
 | 
					    date->tm_year = base_year + year - 1900;
 | 
				
			||||||
 | 
					#ifndef __sun__
 | 
				
			||||||
    date->tm_gmtoff = 0;
 | 
					    date->tm_gmtoff = 0;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ts = mktime(date);
 | 
					    ts = mktime(date);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -115,7 +115,9 @@ static void cmos_get_date_time(struct tm *date)
 | 
				
			|||||||
    date->tm_mday = mday;
 | 
					    date->tm_mday = mday;
 | 
				
			||||||
    date->tm_mon = mon - 1;
 | 
					    date->tm_mon = mon - 1;
 | 
				
			||||||
    date->tm_year = base_year + year - 1900;
 | 
					    date->tm_year = base_year + year - 1900;
 | 
				
			||||||
 | 
					#ifndef __sun__
 | 
				
			||||||
    date->tm_gmtoff = 0;
 | 
					    date->tm_gmtoff = 0;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ts = mktime(date);
 | 
					    ts = mktime(date);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,8 @@
 | 
				
			|||||||
 * See the COPYING file in the top-level directory.
 | 
					 * See the COPYING file in the top-level directory.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "ui/qemu-pixman.h"
 | 
					#include "qemu-common.h"
 | 
				
			||||||
 | 
					#include "ui/console.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int qemu_pixman_get_type(int rshift, int gshift, int bshift)
 | 
					int qemu_pixman_get_type(int rshift, int gshift, int bshift)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
				
			|||||||
@ -848,8 +848,8 @@ static int qemu_spice_set_ticket(bool fail_if_conn, bool disconnect_if_conn)
 | 
				
			|||||||
int qemu_spice_set_passwd(const char *passwd,
 | 
					int qemu_spice_set_passwd(const char *passwd,
 | 
				
			||||||
                          bool fail_if_conn, bool disconnect_if_conn)
 | 
					                          bool fail_if_conn, bool disconnect_if_conn)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    free(auth_passwd);
 | 
					    g_free(auth_passwd);
 | 
				
			||||||
    auth_passwd = strdup(passwd);
 | 
					    auth_passwd = g_strdup(passwd);
 | 
				
			||||||
    return qemu_spice_set_ticket(fail_if_conn, disconnect_if_conn);
 | 
					    return qemu_spice_set_ticket(fail_if_conn, disconnect_if_conn);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										11
									
								
								ui/vnc-ws.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								ui/vnc-ws.c
									
									
									
									
									
								
							@ -120,10 +120,11 @@ static char *vncws_extract_handshake_entry(const char *handshake,
 | 
				
			|||||||
static void vncws_send_handshake_response(VncState *vs, const char* key)
 | 
					static void vncws_send_handshake_response(VncState *vs, const char* key)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    char combined_key[WS_CLIENT_KEY_LEN + WS_GUID_LEN + 1];
 | 
					    char combined_key[WS_CLIENT_KEY_LEN + WS_GUID_LEN + 1];
 | 
				
			||||||
    char hash[SHA1_DIGEST_LEN];
 | 
					    unsigned char hash[SHA1_DIGEST_LEN];
 | 
				
			||||||
    size_t hash_size = SHA1_DIGEST_LEN;
 | 
					    size_t hash_size = sizeof(hash);
 | 
				
			||||||
    char *accept = NULL, *response = NULL;
 | 
					    char *accept = NULL, *response = NULL;
 | 
				
			||||||
    gnutls_datum_t in;
 | 
					    gnutls_datum_t in;
 | 
				
			||||||
 | 
					    int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_strlcpy(combined_key, key, WS_CLIENT_KEY_LEN + 1);
 | 
					    g_strlcpy(combined_key, key, WS_CLIENT_KEY_LEN + 1);
 | 
				
			||||||
    g_strlcat(combined_key, WS_GUID, WS_CLIENT_KEY_LEN + WS_GUID_LEN + 1);
 | 
					    g_strlcat(combined_key, WS_GUID, WS_CLIENT_KEY_LEN + WS_GUID_LEN + 1);
 | 
				
			||||||
@ -131,9 +132,9 @@ static void vncws_send_handshake_response(VncState *vs, const char* key)
 | 
				
			|||||||
    /* hash and encode it */
 | 
					    /* hash and encode it */
 | 
				
			||||||
    in.data = (void *)combined_key;
 | 
					    in.data = (void *)combined_key;
 | 
				
			||||||
    in.size = WS_CLIENT_KEY_LEN + WS_GUID_LEN;
 | 
					    in.size = WS_CLIENT_KEY_LEN + WS_GUID_LEN;
 | 
				
			||||||
    if (gnutls_fingerprint(GNUTLS_DIG_SHA1, &in, hash, &hash_size)
 | 
					    ret = gnutls_fingerprint(GNUTLS_DIG_SHA1, &in, hash, &hash_size);
 | 
				
			||||||
            == GNUTLS_E_SUCCESS) {
 | 
					    if (ret == GNUTLS_E_SUCCESS && hash_size <= SHA1_DIGEST_LEN) {
 | 
				
			||||||
        accept = g_base64_encode((guchar *)hash, SHA1_DIGEST_LEN);
 | 
					        accept = g_base64_encode(hash, hash_size);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (accept == NULL) {
 | 
					    if (accept == NULL) {
 | 
				
			||||||
        VNC_DEBUG("Hashing Websocket combined key failed\n");
 | 
					        VNC_DEBUG("Hashing Websocket combined key failed\n");
 | 
				
			||||||
 | 
				
			|||||||
@ -643,9 +643,7 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value,
 | 
				
			|||||||
        QTAILQ_INSERT_TAIL(&opts->head, opt, next);
 | 
					        QTAILQ_INSERT_TAIL(&opts->head, opt, next);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    opt->desc = desc;
 | 
					    opt->desc = desc;
 | 
				
			||||||
    if (value) {
 | 
					 | 
				
			||||||
    opt->str = g_strdup(value);
 | 
					    opt->str = g_strdup(value);
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    qemu_opt_parse(opt, &local_err);
 | 
					    qemu_opt_parse(opt, &local_err);
 | 
				
			||||||
    if (error_is_set(&local_err)) {
 | 
					    if (error_is_set(&local_err)) {
 | 
				
			||||||
        error_propagate(errp, local_err);
 | 
					        error_propagate(errp, local_err);
 | 
				
			||||||
@ -792,9 +790,7 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    opts = g_malloc0(sizeof(*opts));
 | 
					    opts = g_malloc0(sizeof(*opts));
 | 
				
			||||||
    if (id) {
 | 
					 | 
				
			||||||
    opts->id = g_strdup(id);
 | 
					    opts->id = g_strdup(id);
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    opts->list = list;
 | 
					    opts->list = list;
 | 
				
			||||||
    loc_save(&opts->loc);
 | 
					    loc_save(&opts->loc);
 | 
				
			||||||
    QTAILQ_INIT(&opts->head);
 | 
					    QTAILQ_INIT(&opts->head);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user