Expose a new "encoding" QemuOpt option.
Add the corresponding QAPI type and properties.
This is going to be wired in the following commits.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
return NULL;
}
}
+ if (!cc->supports_encoding_opts) {
+ if (qemu_opt_get(opts, "encoding")) {
+ error_setg(errp, "chardev '%s' does not support encoding option",
+ qemu_opts_id(opts));
+ return NULL;
+ }
+ }
backend = g_new0(ChardevBackend, 1);
backend->type = CHARDEV_BACKEND_KIND_NULL;
},{
.name = "rows",
.type = QEMU_OPT_NUMBER,
+ },{
+ .name = "encoding",
+ .type = QEMU_OPT_STRING,
},{
.name = "mux",
.type = QEMU_OPT_BOOL,
bool internal; /* TODO: eventually use TYPE_USER_CREATABLE */
bool supports_yank;
bool supports_size_opts;
+ bool supports_encoding_opts;
/* parse command line options and populate QAPI @backend */
void (*chr_parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp);
'base': 'ChardevCommon',
'if': 'CONFIG_SPICE' }
+##
+# @ChardevVCEncoding:
+#
+# Character encoding expected from the guest on a virtual console.
+#
+# @cp437: CP437 (8-bit Extended ASCII / VGA). Every byte maps
+# directly to a glyph; suitable for DOS or other guests that
+# output raw CP437.
+#
+# @utf8: UTF-8. Multi-byte sequences are decoded and then mapped
+# back to CP437 glyphs for display; unmappable codepoints are
+# shown as '?'. Suitable for modern Linux guests.
+#
+# Since: 11.1
+##
+{ 'enum': 'ChardevVCEncoding',
+ 'data': [ 'cp437', 'utf8' ] }
+
##
# @ChardevDBus:
#
#
# @name: name of the channel (following docs/spice-port-fqdn.txt)
#
+# @encoding: character encoding the guest is expected to use
+# (since 11.1)
+#
# Since: 7.0
##
{ 'struct': 'ChardevDBus',
- 'data': { 'name': 'str' },
+ 'data': { 'name': 'str',
+ '*encoding': 'ChardevVCEncoding' },
'base': 'ChardevCommon',
'if': 'CONFIG_DBUS_DISPLAY' }
#
# @rows: console height, in chars
#
+# @encoding: character encoding the guest is expected to use
+# (since 11.1)
+#
# .. note:: The options are only effective when the VNC or SDL
# graphical display backend is active. They are ignored with the
# GTK, Spice, VNC and D-Bus display backends.
'data': { '*width': 'int',
'*height': 'int',
'*cols': 'int',
- '*rows': 'int' },
+ '*rows': 'int',
+ '*encoding': 'ChardevVCEncoding' },
'base': 'ChardevCommon' }
##
" [,logfile=PATH][,logappend=on|off]\n"
"-chardev msmouse,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
"-chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]\n"
- " [,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
+ " [,mux=on|off][,logfile=PATH][,logappend=on|off][,encoding=ENCODING]\n"
"-chardev ringbuf,id=id[,size=size][,logfile=PATH][,logappend=on|off]\n"
"-chardev file,id=id,path=path[,input-path=input-file][,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
"-chardev pipe,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
Several frontend devices is not supported. Stacking of multiplexers
and hub devices is not supported as well.
-``-chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]``
+``-chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]][,encoding=ENCODING]``
Connect to a QEMU text console. The implementation and supported feature
set depend on the selected display backend.
``cols`` and ``rows`` specify that the console be sized to fit a
text console with the given dimensions.
+ ``encoding`` specifies the character set expected from the guest:
+ ``utf8`` or ``cp437`` (8-bit Extended ASCII / VGA).
+
``-chardev ringbuf,id=id[,size=size]``
Create a ring buffer with fixed size ``size``. size must be a power
of two and defaults to ``64K``.
static void vc_chr_parse(QemuOpts *opts, ChardevBackend *backend, Error **errp)
{
int val;
+ const char *str;
ChardevVC *vc;
backend->type = CHARDEV_BACKEND_KIND_VC;
vc->has_rows = true;
vc->rows = val;
}
+
+ str = qemu_opt_get(opts, "encoding");
+ if (str) {
+ int cs = qapi_enum_parse(&ChardevVCEncoding_lookup, str, -1, errp);
+ if (cs < 0) {
+ return;
+ }
+ vc->has_encoding = true;
+ vc->encoding = cs;
+ }
}
static void char_vc_class_init(ObjectClass *oc, const void *data)
cc->chr_accept_input = vc_chr_accept_input;
cc->chr_set_echo = vc_chr_set_echo;
cc->supports_size_opts = true;
+ cc->supports_encoding_opts = true;
}
static const TypeInfo char_vc_type_info = {
DBusVCClass *klass = DBUS_VC_CLASS(object_class_by_name(TYPE_CHARDEV_VC));
const char *name = qemu_opt_get(opts, "name");
const char *id = qemu_opts_id(opts);
+ const char *str;
+ ChardevDBus *dbus;
if (name == NULL) {
if (g_str_has_prefix(id, "compat_monitor")) {
}
klass->parent_parse(opts, backend, errp);
+ dbus = backend->u.dbus.data;
+ str = qemu_opt_get(opts, "encoding");
+ if (str) {
+ int cs = qapi_enum_parse(&ChardevVCEncoding_lookup, str, -1, errp);
+ if (cs < 0) {
+ return;
+ }
+ dbus->has_encoding = true;
+ dbus->encoding = cs;
+ }
}
static void
klass->parent_parse = cc->chr_parse;
cc->chr_parse = dbus_vc_parse;
+ cc->supports_encoding_opts = true;
}
static const TypeInfo dbus_vc_type_info = {