void qmp_memchar_write(const char *device, const char *data,
                       bool has_format, enum DataFormat format,
                       Error **errp)
{
    CharDriverState *chr;
    const uint8_t *write_data;
    int ret;
    size_t write_count;
    chr = qemu_chr_find(device);
    if (!chr) {
        error_setg(errp, "Device '%s' not found", device);
        return;
    if (qemu_is_chr(chr, "memory")) {
        error_setg(errp,"%s is not memory char device", device);
        return;
    if (has_format && (format == DATA_FORMAT_BASE64)) {
        write_data = g_base64_decode(data, &write_count);
    } else {
        write_data = (uint8_t *)data;
        write_count = strlen(data);
    ret = cirmem_chr_write(chr, write_data, write_count);
    if (ret < 0) {
        error_setg(errp, "Failed to write to device %s", device);
        return;
void qmp_memchar_write(const char *device, const char *data,
                       bool has_format, enum DataFormat format,
                       Error **errp)
{
    CharDriverState *chr;
    const uint8_t *write_data;
    int ret;
    size_t write_count;
    chr = qemu_chr_find(device);
    if (!chr) {
        error_setg(errp, "Device '%s' not found", device);
        return;
    if (qemu_is_chr(chr, "memory")) {
        error_setg(errp,"%s is not memory char device", device);
        return;
    if (has_format && (format == DATA_FORMAT_BASE64)) {
        write_data = g_base64_decode(data, &write_count);
    } else {
        write_data = (uint8_t *)data;
        write_count = strlen(data);
    ret = cirmem_chr_write(chr, write_data, write_count);
    if (ret < 0) {
        error_setg(errp, "Failed to write to device %s", device);
        return;
void FUNC_0(const char *VAR_0, const char *VAR_1,
                       bool VAR_2, enum DataFormat VAR_3,
                       Error **VAR_4)
{
    CharDriverState *chr;
    const uint8_t *VAR_5;
    int VAR_6;
    size_t write_count;
    chr = qemu_chr_find(VAR_0);
    if (!chr) {
        error_setg(VAR_4, "Device '%s' not found", VAR_0);
        return;
    if (qemu_is_chr(chr, "memory")) {
        error_setg(VAR_4,"%s is not memory char VAR_0", VAR_0);
        return;
    if (VAR_2 && (VAR_3 == DATA_FORMAT_BASE64)) {
        VAR_5 = g_base64_decode(VAR_1, &write_count);
    } else {
        VAR_5 = (uint8_t *)VAR_1;
        write_count = strlen(VAR_1);
    VAR_6 = cirmem_chr_write(chr, VAR_5, write_count);
    if (VAR_6 < 0) {
        error_setg(VAR_4, "Failed to write to VAR_0 %s", VAR_0);
        return;
void FUNC_0(const char *VAR_0, const char *VAR_1,
bool VAR_2, enum DataFormat VAR_3,
Error **VAR_4)
{ CharDriverState *chr; const uint8_t *VAR_5; int VAR_6; size_t write_count; chr = qemu_chr_find(VAR_0); if (!chr) { error_setg(VAR_4, "Device '%s' not found", VAR_0); return; if (qemu_is_chr(chr, "memory")) { error_setg(VAR_4,"%s is not memory char VAR_0", VAR_0); return; if (VAR_2 && (VAR_3 == DATA_FORMAT_BASE64)) { VAR_5 = g_base64_decode(VAR_1, &write_count); } else { VAR_5 = (uint8_t *)VAR_1; write_count = strlen(VAR_1); VAR_6 = cirmem_chr_write(chr, VAR_5, write_count); if (VAR_6 < 0) { error_setg(VAR_4, "Failed to write to VAR_0 %s", VAR_0); return;