static void vhost_log_put(struct vhost_dev *dev, bool sync)

{

    struct vhost_log *log = dev->log;



    if (!log) {

        return;

    }

    dev->log = NULL;

    dev->log_size = 0;



    --log->refcnt;

    if (log->refcnt == 0) {

        /* Sync only the range covered by the old log */

        if (dev->log_size && sync) {

            vhost_log_sync_range(dev, 0, dev->log_size * VHOST_LOG_CHUNK - 1);

        }



        if (vhost_log == log) {

            g_free(log->log);

            vhost_log = NULL;

        } else if (vhost_log_shm == log) {

            qemu_memfd_free(log->log, log->size * sizeof(*(log->log)),

                            log->fd);

            vhost_log_shm = NULL;

        }



        g_free(log);

    }

}

static void vhost_log_put(struct vhost_dev *dev, bool sync)

{

    struct vhost_log *log = dev->log;



    if (!log) {

        return;

    }

    dev->log = NULL;

    dev->log_size = 0;



    --log->refcnt;

    if (log->refcnt == 0) {

        

        if (dev->log_size && sync) {

            vhost_log_sync_range(dev, 0, dev->log_size * VHOST_LOG_CHUNK - 1);

        }



        if (vhost_log == log) {

            g_free(log->log);

            vhost_log = NULL;

        } else if (vhost_log_shm == log) {

            qemu_memfd_free(log->log, log->size * sizeof(*(log->log)),

                            log->fd);

            vhost_log_shm = NULL;

        }



        g_free(log);

    }

}

    dev->log = NULL;     dev->log_size = 0;
static void FUNC_0(struct vhost_dev *VAR_0, bool VAR_1)

{

    struct vhost_log *VAR_2 = VAR_0->VAR_2;



    if (!VAR_2) {

        return;

    }

    VAR_0->VAR_2 = NULL;

    VAR_0->log_size = 0;



    --VAR_2->refcnt;

    if (VAR_2->refcnt == 0) {

        

        if (VAR_0->log_size && VAR_1) {

            vhost_log_sync_range(VAR_0, 0, VAR_0->log_size * VHOST_LOG_CHUNK - 1);

        }



        if (vhost_log == VAR_2) {

            g_free(VAR_2->VAR_2);

            vhost_log = NULL;

        } else if (vhost_log_shm == VAR_2) {

            qemu_memfd_free(VAR_2->VAR_2, VAR_2->size * sizeof(*(VAR_2->VAR_2)),

                            VAR_2->fd);

            vhost_log_shm = NULL;

        }



        g_free(VAR_2);

    }

}

static void FUNC_0(struct vhost_dev *VAR_0, bool VAR_1)
{ struct vhost_log *VAR_2 = VAR_0->VAR_2; if (!VAR_2) { return; } VAR_0->VAR_2 = NULL; VAR_0->log_size = 0; --VAR_2->refcnt; if (VAR_2->refcnt == 0) { if (VAR_0->log_size && VAR_1) { vhost_log_sync_range(VAR_0, 0, VAR_0->log_size * VHOST_LOG_CHUNK - 1); } if (vhost_log == VAR_2) { g_free(VAR_2->VAR_2); vhost_log = NULL; } else if (vhost_log_shm == VAR_2) { qemu_memfd_free(VAR_2->VAR_2, VAR_2->size * sizeof(*(VAR_2->VAR_2)),
VAR_2->fd); vhost_log_shm = NULL; } g_free(VAR_2); } }