static void virtio_gpu_resource_create_2d(VirtIOGPU *g,

                                          struct virtio_gpu_ctrl_command *cmd)

{

    pixman_format_code_t pformat;

    struct virtio_gpu_simple_resource *res;

    struct virtio_gpu_resource_create_2d c2d;



    VIRTIO_GPU_FILL_CMD(c2d);

    trace_virtio_gpu_cmd_res_create_2d(c2d.resource_id, c2d.format,

                                       c2d.width, c2d.height);



    if (c2d.resource_id == 0) {

        qemu_log_mask(LOG_GUEST_ERROR, "%s: resource id 0 is not allowed\n",

                      __func__);

        cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;

        return;

    }



    res = virtio_gpu_find_resource(g, c2d.resource_id);

    if (res) {

        qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already exists %d\n",

                      __func__, c2d.resource_id);

        cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;

        return;

    }



    res = g_new0(struct virtio_gpu_simple_resource, 1);



    res->width = c2d.width;

    res->height = c2d.height;

    res->format = c2d.format;

    res->resource_id = c2d.resource_id;



    pformat = get_pixman_format(c2d.format);

    if (!pformat) {

        qemu_log_mask(LOG_GUEST_ERROR,

                      "%s: host couldn't handle guest format %d\n",

                      __func__, c2d.format);

        g_free(res);

        cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;

        return;

    }

    res->image = pixman_image_create_bits(pformat,

                                          c2d.width,

                                          c2d.height,

                                          NULL, 0);



    if (!res->image) {

        qemu_log_mask(LOG_GUEST_ERROR,

                      "%s: resource creation failed %d %d %d\n",

                      __func__, c2d.resource_id, c2d.width, c2d.height);

        g_free(res);

        cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY;

        return;

    }



    QTAILQ_INSERT_HEAD(&g->reslist, res, next);

}

static void virtio_gpu_resource_create_2d(VirtIOGPU *g,

                                          struct virtio_gpu_ctrl_command *cmd)

{

    pixman_format_code_t pformat;

    struct virtio_gpu_simple_resource *res;

    struct virtio_gpu_resource_create_2d c2d;



    VIRTIO_GPU_FILL_CMD(c2d);

    trace_virtio_gpu_cmd_res_create_2d(c2d.resource_id, c2d.format,

                                       c2d.width, c2d.height);



    if (c2d.resource_id == 0) {

        qemu_log_mask(LOG_GUEST_ERROR, "%s: resource id 0 is not allowed\n",

                      __func__);

        cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;

        return;

    }



    res = virtio_gpu_find_resource(g, c2d.resource_id);

    if (res) {

        qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already exists %d\n",

                      __func__, c2d.resource_id);

        cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;

        return;

    }



    res = g_new0(struct virtio_gpu_simple_resource, 1);



    res->width = c2d.width;

    res->height = c2d.height;

    res->format = c2d.format;

    res->resource_id = c2d.resource_id;



    pformat = get_pixman_format(c2d.format);

    if (!pformat) {

        qemu_log_mask(LOG_GUEST_ERROR,

                      "%s: host couldn't handle guest format %d\n",

                      __func__, c2d.format);

        g_free(res);

        cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;

        return;

    }

    res->image = pixman_image_create_bits(pformat,

                                          c2d.width,

                                          c2d.height,

                                          NULL, 0);



    if (!res->image) {

        qemu_log_mask(LOG_GUEST_ERROR,

                      "%s: resource creation failed %d %d %d\n",

                      __func__, c2d.resource_id, c2d.width, c2d.height);

        g_free(res);

        cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY;

        return;

    }



    QTAILQ_INSERT_HEAD(&g->reslist, res, next);

}

    res->image = pixman_image_create_bits(pformat,                                           c2d.width,                                           c2d.height,                                           NULL, 0);
static void FUNC_0(VirtIOGPU *VAR_0,

                                          struct virtio_gpu_ctrl_command *VAR_1)

{

    pixman_format_code_t pformat;

    struct virtio_gpu_simple_resource *VAR_2;

    struct FUNC_0 VAR_3;



    VIRTIO_GPU_FILL_CMD(VAR_3);

    trace_virtio_gpu_cmd_res_create_2d(VAR_3.resource_id, VAR_3.format,

                                       VAR_3.width, VAR_3.height);



    if (VAR_3.resource_id == 0) {

        qemu_log_mask(LOG_GUEST_ERROR, "%s: resource id 0 is not allowed\n",

                      __func__);

        VAR_1->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;

        return;

    }



    VAR_2 = virtio_gpu_find_resource(VAR_0, VAR_3.resource_id);

    if (VAR_2) {

        qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already exists %d\n",

                      __func__, VAR_3.resource_id);

        VAR_1->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;

        return;

    }



    VAR_2 = g_new0(struct virtio_gpu_simple_resource, 1);



    VAR_2->width = VAR_3.width;

    VAR_2->height = VAR_3.height;

    VAR_2->format = VAR_3.format;

    VAR_2->resource_id = VAR_3.resource_id;



    pformat = get_pixman_format(VAR_3.format);

    if (!pformat) {

        qemu_log_mask(LOG_GUEST_ERROR,

                      "%s: host couldn't handle guest format %d\n",

                      __func__, VAR_3.format);

        g_free(VAR_2);

        VAR_1->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;

        return;

    }

    VAR_2->image = pixman_image_create_bits(pformat,

                                          VAR_3.width,

                                          VAR_3.height,

                                          NULL, 0);



    if (!VAR_2->image) {

        qemu_log_mask(LOG_GUEST_ERROR,

                      "%s: resource creation failed %d %d %d\n",

                      __func__, VAR_3.resource_id, VAR_3.width, VAR_3.height);

        g_free(VAR_2);

        VAR_1->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY;

        return;

    }



    QTAILQ_INSERT_HEAD(&VAR_0->reslist, VAR_2, next);

}

static void FUNC_0(VirtIOGPU *VAR_0,
struct virtio_gpu_ctrl_command *VAR_1)
{ pixman_format_code_t pformat; struct virtio_gpu_simple_resource *VAR_2; struct FUNC_0 VAR_3; VIRTIO_GPU_FILL_CMD(VAR_3); trace_virtio_gpu_cmd_res_create_2d(VAR_3.resource_id, VAR_3.format,
VAR_3.width, VAR_3.height); if (VAR_3.resource_id == 0) { qemu_log_mask(LOG_GUEST_ERROR, "%s: resource id 0 is not allowed\n",
__func__); VAR_1->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; return; } VAR_2 = virtio_gpu_find_resource(VAR_0, VAR_3.resource_id); if (VAR_2) { qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already exists %d\n",
__func__, VAR_3.resource_id); VAR_1->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; return; } VAR_2 = g_new0(struct virtio_gpu_simple_resource, 1); VAR_2->width = VAR_3.width; VAR_2->height = VAR_3.height; VAR_2->format = VAR_3.format; VAR_2->resource_id = VAR_3.resource_id; pformat = get_pixman_format(VAR_3.format); if (!pformat) { qemu_log_mask(LOG_GUEST_ERROR,
"%s: host couldn't handle guest format %d\n",
__func__, VAR_3.format); g_free(VAR_2); VAR_1->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; return; } VAR_2->image = pixman_image_create_bits(pformat,
VAR_3.width,
VAR_3.height,
NULL, 0); if (!VAR_2->image) { qemu_log_mask(LOG_GUEST_ERROR,
"%s: resource creation failed %d %d %d\n",
__func__, VAR_3.resource_id, VAR_3.width, VAR_3.height); g_free(VAR_2); VAR_1->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY; return; } QTAILQ_INSERT_HEAD(&VAR_0->reslist, VAR_2, next); }