Change the virDomainChrDef to use a pointer to 'source' and allocate that pointer during virDomainChrDefNew. This has tremendous "fallout" in the rest of the code which mainly has to change source.$field to source->$field. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/bhyve/bhyve_command.c | 8 ++--- src/bhyve/bhyve_driver.c | 2 +- src/bhyve/bhyve_parse_command.c | 20 +++++------ src/conf/domain_audit.c | 4 +-- src/conf/domain_conf.c | 50 +++++++++++++++++--------- src/conf/domain_conf.h | 2 +- src/libxl/libxl_conf.c | 42 +++++++++++----------- src/libxl/libxl_domain.c | 22 ++++++------ src/libxl/libxl_driver.c | 4 +-- src/lxc/lxc_driver.c | 4 +-- src/lxc/lxc_native.c | 2 +- src/lxc/lxc_process.c | 6 ++-- src/qemu/qemu_cgroup.c | 2 +- src/qemu/qemu_command.c | 28 +++++++-------- src/qemu/qemu_domain.c | 16 ++++----- src/qemu/qemu_driver.c | 8 ++--- src/qemu/qemu_hotplug.c | 6 ++-- src/qemu/qemu_parse_command.c | 4 +-- src/qemu/qemu_process.c | 28 +++++++-------- src/security/security_dac.c | 4 +-- src/security/security_selinux.c | 4 +-- src/security/virt-aa-helper.c | 70 ++++++++++++++++++------------------ src/uml/uml_conf.c | 14 ++++---- src/uml/uml_driver.c | 12 +++---- src/vbox/vbox_common.c | 46 ++++++++++++------------ src/vmx/vmx.c | 74 +++++++++++++++++++------------------- src/vz/vz_sdk.c | 78 ++++++++++++++++++++-------------------- src/xen/xen_driver.c | 4 +-- src/xenconfig/xen_sxpr.c | 76 +++++++++++++++++++-------------------- src/xenconfig/xen_xl.c | 14 ++++---- tests/securityselinuxlabeltest.c | 14 ++++---- 31 files changed, 343 insertions(+), 325 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 55ad950..022b03b 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -130,7 +130,7 @@ bhyveBuildConsoleArgStr(const virDomainDef *def, virCommandPtr cmd) chr = def->serials[0]; - if (chr->source.type != VIR_DOMAIN_CHR_TYPE_NMDM) { + if (chr->source->type != VIR_DOMAIN_CHR_TYPE_NMDM) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("only nmdm console types are supported")); return -1; @@ -146,7 +146,7 @@ bhyveBuildConsoleArgStr(const virDomainDef *def, virCommandPtr cmd) virCommandAddArgList(cmd, "-s", "1,lpc", NULL); virCommandAddArg(cmd, "-l"); virCommandAddArgFormat(cmd, "com%d,%s", - chr->target.port + 1, chr->source.data.file.path); + chr->target.port + 1, chr->source->data.file.path); return 0; } @@ -505,14 +505,14 @@ virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def, chr = def->serials[0]; - if (chr->source.type != VIR_DOMAIN_CHR_TYPE_NMDM) { + if (chr->source->type != VIR_DOMAIN_CHR_TYPE_NMDM) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("only nmdm console types are supported")); return NULL; } virCommandAddArg(cmd, "--cons-dev"); - virCommandAddArg(cmd, chr->source.data.file.path); + virCommandAddArg(cmd, chr->source->data.file.path); } /* VM name */ diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 04be78b..38fb9f0 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1080,7 +1080,7 @@ bhyveDomainOpenConsole(virDomainPtr dom, chr = vm->def->serials[0]; - if (virFDStreamOpenPTY(st, chr->source.data.nmdm.slave, + if (virFDStreamOpenPTY(st, chr->source->data.nmdm.slave, 0, 0, O_RDWR) < 0) goto cleanup; diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c index 1a7de3d..0ae7a83 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -290,9 +290,9 @@ bhyveParseBhyveLPCArg(virDomainDefPtr def, if (!(chr = virDomainChrDefNew(NULL))) goto error; - chr->source.type = VIR_DOMAIN_CHR_TYPE_NMDM; - chr->source.data.nmdm.master = NULL; - chr->source.data.nmdm.slave = NULL; + chr->source->type = VIR_DOMAIN_CHR_TYPE_NMDM; + chr->source->data.nmdm.master = NULL; + chr->source->data.nmdm.slave = NULL; chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; if (!STRPREFIX(param, "/dev/nmdm")) { @@ -302,12 +302,12 @@ bhyveParseBhyveLPCArg(virDomainDefPtr def, goto error; } - if (VIR_STRDUP(chr->source.data.nmdm.master, param) < 0) { + if (VIR_STRDUP(chr->source->data.nmdm.master, param) < 0) { virDomainChrDefFree(chr); goto error; } - if (VIR_STRDUP(chr->source.data.nmdm.slave, chr->source.data.file.path) + if (VIR_STRDUP(chr->source->data.nmdm.slave, chr->source->data.file.path) < 0) { virDomainChrDefFree(chr); goto error; @@ -315,19 +315,19 @@ bhyveParseBhyveLPCArg(virDomainDefPtr def, /* If the last character of the master is 'A', the slave will be 'B' * and vice versa */ - last = strlen(chr->source.data.nmdm.master) - 1; - switch (chr->source.data.file.path[last]) { + last = strlen(chr->source->data.nmdm.master) - 1; + switch (chr->source->data.file.path[last]) { case 'A': - chr->source.data.nmdm.slave[last] = 'B'; + chr->source->data.nmdm.slave[last] = 'B'; break; case 'B': - chr->source.data.nmdm.slave[last] = 'A'; + chr->source->data.nmdm.slave[last] = 'A'; break; default: virReportError(VIR_ERR_OPERATION_FAILED, _("Failed to set slave for %s: last letter not " "'A' or 'B'"), - NULLSTR(chr->source.data.nmdm.master)); + NULLSTR(chr->source->data.nmdm.master)); goto error; } diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index 2423f34..314dee7 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -172,10 +172,10 @@ virDomainAuditChardev(virDomainObjPtr vm, virDomainChrSourceDefPtr newsrc = NULL; if (oldDef) - oldsrc = &oldDef->source; + oldsrc = oldDef->source; if (newDef) - newsrc = &newDef->source; + newsrc = newDef->source; virDomainAuditGenericDev(vm, "chardev", virDomainAuditChardevPath(oldsrc), diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 89473db..2b89ea2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2116,7 +2116,7 @@ void virDomainChrDefFree(virDomainChrDefPtr def) break; } - virDomainChrSourceDefClear(&def->source); + virDomainChrSourceDefFree(def->source); virDomainDeviceInfoClear(&def->info); if (def->seclabels) { @@ -3865,8 +3865,8 @@ virDomainDefAddConsoleCompat(virDomainDefPtr def) def->serials[0]->target.port = 0; } else { /* if the console source doesn't match */ - if (!virDomainChrSourceDefIsEqual(&def->serials[0]->source, - &def->consoles[0]->source)) { + if (!virDomainChrSourceDefIsEqual(def->serials[0]->source, + def->consoles[0]->source)) { virDomainChrDefFree(def->consoles[0]); def->consoles[0] = NULL; } @@ -10316,6 +10316,19 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def, goto cleanup; } + +static virDomainChrSourceDefPtr +virDomainChrSourceDefNew(void) +{ + virDomainChrSourceDefPtr def = NULL; + + if (VIR_ALLOC(def) < 0) + return NULL; + + return def; +} + + /* Create a new character device definition and set * default port. */ @@ -10329,9 +10342,14 @@ virDomainChrDefNew(virDomainXMLOptionPtr xmlopt) def->target.port = -1; + if (!(def->source = virDomainChrSourceDefNew())) + VIR_FREE(def); + if (xmlopt && xmlopt->privateData.chardevNew && - !(def->privateData = xmlopt->privateData.chardevNew())) + !(def->privateData = xmlopt->privateData.chardevNew())) { + virDomainChrSourceDefFree(def->source); VIR_FREE(def); + } return def; } @@ -10398,8 +10416,8 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xmlopt, type = virXMLPropString(node, "type"); if (type == NULL) { - def->source.type = VIR_DOMAIN_CHR_TYPE_PTY; - } else if ((def->source.type = virDomainChrTypeFromString(type)) < 0) { + def->source->type = VIR_DOMAIN_CHR_TYPE_PTY; + } else if ((def->source->type = virDomainChrTypeFromString(type)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown type presented to host for character device: %s"), type); @@ -10430,18 +10448,18 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xmlopt, ((def->targetType = virDomainChrDefaultTargetType(def->deviceType)) < 0)) goto error; - if (virDomainChrSourceDefParseXML(&def->source, node->children, flags, def, + if (virDomainChrSourceDefParseXML(def->source, node->children, flags, def, ctxt, vmSeclabels, nvmSeclabels) < 0) goto error; - if (def->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) { + if (def->source->type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) { if (def->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("spicevmc device type only supports " "virtio")); goto error; } else { - def->source.data.spicevmc = VIR_DOMAIN_CHR_SPICEVMC_VDAGENT; + def->source->data.spicevmc = VIR_DOMAIN_CHR_SPICEVMC_VDAGENT; } } @@ -14457,7 +14475,7 @@ virDomainChrEquals(virDomainChrDefPtr src, return src == tgt; if (src->deviceType != tgt->deviceType || - !virDomainChrSourceDefIsEqual(&src->source, &tgt->source)) + !virDomainChrSourceDefIsEqual(src->source, tgt->source)) return false; switch ((virDomainChrDeviceType) src->deviceType) { @@ -18492,9 +18510,9 @@ virDomainChannelDefCheckABIStability(virDomainChrDefPtr src, NULLSTR(dst->target.name), NULLSTR(src->target.name)); return false; } - if (src->source.type != dst->source.type && - (src->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC || - dst->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) && + if (src->source->type != dst->source->type && + (src->source->type == VIR_DOMAIN_CHR_TYPE_SPICEVMC || + dst->source->type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) && !src->target.name) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Changing device type to/from spicevmc would" @@ -21523,10 +21541,10 @@ virDomainChrDefFormat(virBufferPtr buf, virBufferAdjustIndent(buf, 2); tty_compat = (def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && def->target.port == 0 && - def->source.type == VIR_DOMAIN_CHR_TYPE_PTY && + def->source->type == VIR_DOMAIN_CHR_TYPE_PTY && !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) && - def->source.data.file.path); - if (virDomainChrSourceDefFormat(buf, def, &def->source, tty_compat, flags) < 0) + def->source->data.file.path); + if (virDomainChrSourceDefFormat(buf, def, def->source, tty_compat, flags) < 0) return -1; /* Format <target> block */ diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 04f2e40..5247d34 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1132,7 +1132,7 @@ struct _virDomainChrDef { virDomainChrDeviceState state; - virDomainChrSourceDef source; + virDomainChrSourceDefPtr source; virDomainDeviceInfo info; diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 1befd11..dcf8e7e 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -208,8 +208,8 @@ libxlMakeDomCreateInfo(libxl_ctx *ctx, static int libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf) { - virDomainChrSourceDef srcdef = def->source; - const char *type = virDomainChrTypeToString(srcdef.type); + virDomainChrSourceDefPtr srcdef = def->source; + const char *type = virDomainChrTypeToString(srcdef->type); if (!type) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -217,7 +217,7 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf) return -1; } - switch (srcdef.type) { + switch (srcdef->type) { case VIR_DOMAIN_CHR_TYPE_NULL: case VIR_DOMAIN_CHR_TYPE_STDIO: case VIR_DOMAIN_CHR_TYPE_VC: @@ -228,19 +228,19 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf) case VIR_DOMAIN_CHR_TYPE_FILE: case VIR_DOMAIN_CHR_TYPE_PIPE: - if (virAsprintf(buf, "%s:%s", type, srcdef.data.file.path) < 0) + if (virAsprintf(buf, "%s:%s", type, srcdef->data.file.path) < 0) return -1; break; case VIR_DOMAIN_CHR_TYPE_DEV: - if (VIR_STRDUP(*buf, srcdef.data.file.path) < 0) + if (VIR_STRDUP(*buf, srcdef->data.file.path) < 0) return -1; break; case VIR_DOMAIN_CHR_TYPE_UDP: { - const char *connectHost = srcdef.data.udp.connectHost; - const char *bindHost = srcdef.data.udp.bindHost; - const char *bindService = srcdef.data.udp.bindService; + const char *connectHost = srcdef->data.udp.connectHost; + const char *bindHost = srcdef->data.udp.bindHost; + const char *bindService = srcdef->data.udp.bindService; if (connectHost == NULL) connectHost = ""; @@ -251,7 +251,7 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf) if (virAsprintf(buf, "udp:%s:%s@%s:%s", connectHost, - srcdef.data.udp.connectService, + srcdef->data.udp.connectService, bindHost, bindService) < 0) return -1; @@ -261,24 +261,24 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf) case VIR_DOMAIN_CHR_TYPE_TCP: { const char *prefix; - if (srcdef.data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET) + if (srcdef->data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET) prefix = "telnet"; else prefix = "tcp"; if (virAsprintf(buf, "%s:%s:%s%s", prefix, - srcdef.data.tcp.host, - srcdef.data.tcp.service, - srcdef.data.tcp.listen ? ",server,nowait" : "") < 0) + srcdef->data.tcp.host, + srcdef->data.tcp.service, + srcdef->data.tcp.listen ? ",server,nowait" : "") < 0) return -1; break; } case VIR_DOMAIN_CHR_TYPE_UNIX: if (virAsprintf(buf, "unix:%s%s", - srcdef.data.nix.path, - srcdef.data.nix.listen ? ",server,nowait" : "") < 0) + srcdef->data.nix.path, + srcdef->data.nix.listen ? ",server,nowait" : "") < 0) return -1; break; @@ -1509,15 +1509,15 @@ libxlPrepareChannel(virDomainChrDefPtr channel, const char *domainName) { if (channel->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN && - channel->source.type == VIR_DOMAIN_CHR_TYPE_UNIX && - !channel->source.data.nix.path) { - if (virAsprintf(&channel->source.data.nix.path, + channel->source->type == VIR_DOMAIN_CHR_TYPE_UNIX && + !channel->source->data.nix.path) { + if (virAsprintf(&channel->source->data.nix.path, "%s/%s-%s", channelDir, domainName, channel->target.name ? channel->target.name : "unknown.sock") < 0) return -1; - channel->source.data.nix.listen = true; + channel->source->data.nix.listen = true; } return 0; @@ -1535,14 +1535,14 @@ libxlMakeChannel(virDomainChrDefPtr l_channel, return -1; } - switch (l_channel->source.type) { + switch (l_channel->source->type) { case VIR_DOMAIN_CHR_TYPE_PTY: x_channel->connection = LIBXL_CHANNEL_CONNECTION_PTY; break; case VIR_DOMAIN_CHR_TYPE_UNIX: x_channel->connection = LIBXL_CHANNEL_CONNECTION_SOCKET; if (VIR_STRDUP(x_channel->u.socket.path, - l_channel->source.data.nix.path) < 0) + l_channel->source->data.nix.path) < 0) return -1; break; default: diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index bdd8ae7..5cde576 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -392,7 +392,7 @@ libxlDomainDefPostParse(virDomainDefPtr def, if (!(chrdef = virDomainChrDefNew(NULL))) return -1; - chrdef->source.type = VIR_DOMAIN_CHR_TYPE_PTY; + chrdef->source->type = VIR_DOMAIN_CHR_TYPE_PTY; chrdef->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; chrdef->target.port = 0; chrdef->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; @@ -987,7 +987,7 @@ libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev, void *for_callback) chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) chr = vm->def->serials[0]; - if (chr->source.type == VIR_DOMAIN_CHR_TYPE_PTY) { + if (chr->source->type == VIR_DOMAIN_CHR_TYPE_PTY) { libxl_console_type console_type; console_type = @@ -997,9 +997,9 @@ libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev, void *for_callback) chr->target.port, console_type, &console); if (!ret) { - VIR_FREE(chr->source.data.file.path); + VIR_FREE(chr->source->data.file.path); if (console && console[0] != '\0') { - ignore_value(VIR_STRDUP(chr->source.data.file.path, + ignore_value(VIR_STRDUP(chr->source->data.file.path, console)); } } @@ -1010,17 +1010,17 @@ libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev, void *for_callback) chr = vm->def->serials[i]; ignore_value(virAsprintf(&chr->info.alias, "serial%zd", i)); - if (chr->source.type == VIR_DOMAIN_CHR_TYPE_PTY) { - if (chr->source.data.file.path) + if (chr->source->type == VIR_DOMAIN_CHR_TYPE_PTY) { + if (chr->source->data.file.path) continue; ret = libxl_console_get_tty(ctx, ev->domid, chr->target.port, LIBXL_CONSOLE_TYPE_SERIAL, &console); if (!ret) { - VIR_FREE(chr->source.data.file.path); + VIR_FREE(chr->source->data.file.path); if (console && console[0] != '\0') { - ignore_value(VIR_STRDUP(chr->source.data.file.path, + ignore_value(VIR_STRDUP(chr->source->data.file.path, console)); } } @@ -1075,7 +1075,7 @@ libxlDomainCreateChannelPTY(virDomainDefPtr def, libxl_ctx *ctx) int ret; chr = def->channels[i]; - if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) + if (chr->source->type != VIR_DOMAIN_CHR_TYPE_PTY) continue; ret = libxl_device_channel_getinfo(ctx, def->id, &x_channels[i], @@ -1083,8 +1083,8 @@ libxlDomainCreateChannelPTY(virDomainDefPtr def, libxl_ctx *ctx) if (!ret && channelinfo.u.pty.path && channelinfo.u.pty.path != '\0') { - VIR_FREE(chr->source.data.file.path); - ignore_value(VIR_STRDUP(chr->source.data.file.path, + VIR_FREE(chr->source->data.file.path); + ignore_value(VIR_STRDUP(chr->source->data.file.path, channelinfo.u.pty.path)); } } diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index ce23235..b2f3b16 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -4724,7 +4724,7 @@ libxlDomainOpenConsole(virDomainPtr dom, goto cleanup; } - if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) { + if (chr->source->type != VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, _("character device %s is not using a PTY"), dev_name ? dev_name : NULLSTR(chr->info.alias)); @@ -4733,7 +4733,7 @@ libxlDomainOpenConsole(virDomainPtr dom, /* handle mutually exclusive access to console devices */ ret = virChrdevOpen(priv->devs, - &chr->source, + chr->source, st, (flags & VIR_DOMAIN_CONSOLE_FORCE) != 0); diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index ba4035a..466e67f 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3252,14 +3252,14 @@ lxcDomainOpenConsole(virDomainPtr dom, goto cleanup; } - if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) { + if (chr->source->type != VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, _("character device %s is not using a PTY"), dev_name ? dev_name : NULLSTR(chr->info.alias)); goto cleanup; } - if (virFDStreamOpenFile(st, chr->source.data.file.path, + if (virFDStreamOpenFile(st, chr->source->data.file.path, 0, 0, O_RDWR) < 0) goto cleanup; diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index b6d26b2..ce62df9 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -709,7 +709,7 @@ lxcCreateConsoles(virDomainDefPtr def, virConfPtr properties) console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; console->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC; console->target.port = i; - console->source.type = VIR_DOMAIN_CHR_TYPE_PTY; + console->source->type = VIR_DOMAIN_CHR_TYPE_PTY; def->consoles[i] = console; } diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 07da3d3..d8727c3 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1246,7 +1246,7 @@ int virLXCProcessStart(virConnectPtr conn, } for (i = 0; i < vm->def->nconsoles; i++) { - if (vm->def->consoles[i]->source.type != VIR_DOMAIN_CHR_TYPE_PTY) { + if (vm->def->consoles[i]->source->type != VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Only PTY console types are supported")); return -1; @@ -1362,8 +1362,8 @@ int virLXCProcessStart(virConnectPtr conn, goto cleanup; } - VIR_FREE(vm->def->consoles[i]->source.data.file.path); - vm->def->consoles[i]->source.data.file.path = ttyPath; + VIR_FREE(vm->def->consoles[i]->source->data.file.path); + vm->def->consoles[i]->source->data.file.path = ttyPath; VIR_FREE(vm->def->consoles[i]->info.alias); if (virAsprintf(&vm->def->consoles[i]->info.alias, "console%zu", i) < 0) diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 4bce601..4489c64 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -196,7 +196,7 @@ qemuSetupChardevCgroup(virDomainDefPtr def ATTRIBUTE_UNUSED, { virDomainObjPtr vm = opaque; - return qemuSetupChrSourceCgroup(vm, &dev->source); + return qemuSetupChrSourceCgroup(vm, dev->source); } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8282162..d8a2867 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5328,7 +5328,7 @@ qemuBuildVirtioSerialPortDevStr(const virDomainDef *def, break; case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: /* Legacy syntax '-device spicevmc' */ - if (dev->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC && + if (dev->source->type == VIR_DOMAIN_CHR_TYPE_SPICEVMC && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPICEVMC)) { virBufferAddLit(&buf, "spicevmc"); } else { @@ -5362,7 +5362,7 @@ qemuBuildVirtioSerialPortDevStr(const virDomainDef *def, } if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && - dev->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC && + dev->source->type == VIR_DOMAIN_CHR_TYPE_SPICEVMC && dev->target.name && STRNEQ(dev->target.name, "com.redhat.spice.0")) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -5372,12 +5372,12 @@ qemuBuildVirtioSerialPortDevStr(const virDomainDef *def, } if (!(dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && - dev->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC && + dev->source->type == VIR_DOMAIN_CHR_TYPE_SPICEVMC && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPICEVMC))) { virBufferAsprintf(&buf, ",chardev=char%s,id=%s", dev->info.alias, dev->info.alias); if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && - (dev->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC || + (dev->source->type == VIR_DOMAIN_CHR_TYPE_SPICEVMC || dev->target.name)) { virBufferAsprintf(&buf, ",name=%s", dev->target.name ? dev->target.name : "com.redhat.spice.0"); @@ -8541,13 +8541,13 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager, virDomainChrDefPtr serial = def->serials[i]; char *devstr; - if (serial->source.type == VIR_DOMAIN_CHR_TYPE_SPICEPORT && !havespice) + if (serial->source->type == VIR_DOMAIN_CHR_TYPE_SPICEPORT && !havespice) continue; /* Use -chardev with -device if they are available */ if (virQEMUCapsSupportsChardev(def, qemuCaps, serial)) { if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, - &serial->source, + serial->source, serial->info.alias, qemuCaps, true))) return -1; @@ -8559,7 +8559,7 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager, return -1; } else { virCommandAddArg(cmd, "-serial"); - if (!(devstr = qemuBuildChrArgStr(&serial->source, NULL))) + if (!(devstr = qemuBuildChrArgStr(serial->source, NULL))) return -1; virCommandAddArg(cmd, devstr); VIR_FREE(devstr); @@ -8586,7 +8586,7 @@ qemuBuildParallelsCommandLine(virLogManagerPtr logManager, /* Use -chardev with -device if they are available */ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV)) { if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, - ¶llel->source, + parallel->source, parallel->info.alias, qemuCaps, true))) return -1; @@ -8599,7 +8599,7 @@ qemuBuildParallelsCommandLine(virLogManagerPtr logManager, return -1; } else { virCommandAddArg(cmd, "-parallel"); - if (!(devstr = qemuBuildChrArgStr(¶llel->source, NULL))) + if (!(devstr = qemuBuildChrArgStr(parallel->source, NULL))) return -1; virCommandAddArg(cmd, devstr); VIR_FREE(devstr); @@ -8632,7 +8632,7 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager, } if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, - &channel->source, + channel->source, channel->info.alias, qemuCaps, true))) return -1; @@ -8648,14 +8648,14 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager, case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPICEVMC) && - channel->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) { + channel->source->type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) { /* spicevmc was originally introduced via a -device * with a backend internal to qemu; although we prefer * the newer -chardev interface. */ ; } else { if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, - &channel->source, + channel->source, channel->info.alias, qemuCaps, true))) return -1; @@ -8698,7 +8698,7 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager, } if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, - &console->source, + console->source, console->info.alias, qemuCaps, true))) return -1; @@ -8712,7 +8712,7 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager, case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO: if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, - &console->source, + console->source, console->info.alias, qemuCaps, true))) return -1; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4c118ff..88c50a3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2660,10 +2660,10 @@ qemuDomainChrDefDropDefaultPath(virDomainChrDefPtr chr, if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO && - chr->source.type == VIR_DOMAIN_CHR_TYPE_UNIX && - chr->source.data.nix.path && - STRPREFIX(chr->source.data.nix.path, cfg->channelTargetDir)) { - VIR_FREE(chr->source.data.nix.path); + chr->source->type == VIR_DOMAIN_CHR_TYPE_UNIX && + chr->source->data.nix.path && + STRPREFIX(chr->source->data.nix.path, cfg->channelTargetDir)) { + VIR_FREE(chr->source->data.nix.path); } virObjectUnref(cfg); @@ -6171,15 +6171,15 @@ qemuDomainPrepareChannel(virDomainChrDefPtr channel, const char *domainChannelTargetDir) { if (channel->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO && - channel->source.type == VIR_DOMAIN_CHR_TYPE_UNIX && - !channel->source.data.nix.path) { - if (virAsprintf(&channel->source.data.nix.path, + channel->source->type == VIR_DOMAIN_CHR_TYPE_UNIX && + !channel->source->data.nix.path) { + if (virAsprintf(&channel->source->data.nix.path, "%s/%s", domainChannelTargetDir, channel->target.name ? channel->target.name : "unknown.sock") < 0) return -1; - channel->source.data.nix.listen = true; + channel->source->data.nix.listen = true; } return 0; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8789c9d..93ea5e2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15888,7 +15888,7 @@ qemuDomainOpenConsole(virDomainPtr dom, goto cleanup; } - if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) { + if (chr->source->type != VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, _("character device %s is not using a PTY"), dev_name ? dev_name : NULLSTR(chr->info.alias)); @@ -15897,7 +15897,7 @@ qemuDomainOpenConsole(virDomainPtr dom, /* handle mutually exclusive access to console devices */ ret = virChrdevOpen(priv->devs, - &chr->source, + chr->source, st, (flags & VIR_DOMAIN_CONSOLE_FORCE) != 0); @@ -15962,7 +15962,7 @@ qemuDomainOpenChannel(virDomainPtr dom, goto cleanup; } - if (chr->source.type != VIR_DOMAIN_CHR_TYPE_UNIX) { + if (chr->source->type != VIR_DOMAIN_CHR_TYPE_UNIX) { virReportError(VIR_ERR_INTERNAL_ERROR, _("channel %s is not using a UNIX socket"), name ? name : NULLSTR(chr->info.alias)); @@ -15971,7 +15971,7 @@ qemuDomainOpenChannel(virDomainPtr dom, /* handle mutually exclusive access to channel devices */ ret = virChrdevOpen(priv->devs, - &chr->source, + chr->source, st, (flags & VIR_DOMAIN_CHANNEL_FORCE) != 0); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 2cb2267..bc83771 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1700,7 +1700,7 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, virErrorPtr orig_err; virDomainDefPtr vmdef = vm->def; char *devstr = NULL; - virDomainChrSourceDefPtr dev = &chr->source; + virDomainChrSourceDefPtr dev = chr->source; char *charAlias = NULL; bool chardevAttached = false; bool tlsobjAdded = false; @@ -1753,7 +1753,7 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, tlsobjAdded = true; } - if (qemuMonitorAttachCharDev(priv->mon, charAlias, &chr->source) < 0) + if (qemuMonitorAttachCharDev(priv->mon, charAlias, chr->source) < 0) goto exit_monitor; chardevAttached = true; @@ -4403,7 +4403,7 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver, if (!(charAlias = qemuAliasChardevFromDevAlias(tmpChr->info.alias))) goto cleanup; - if (tmpChr->source.type == VIR_DOMAIN_CHR_TYPE_TCP && + if (tmpChr->source->type == VIR_DOMAIN_CHR_TYPE_TCP && cfg->chardevTLS && !(objAlias = qemuAliasTLSObjFromChardevAlias(charAlias))) goto cleanup; diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index 331ab36..c3b27aa 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -2192,7 +2192,7 @@ qemuParseCommandLine(virCapsPtr caps, if (!(chr = virDomainChrDefNew(NULL))) goto error; - if (qemuParseCommandLineChr(&chr->source, val) < 0) { + if (qemuParseCommandLineChr(chr->source, val) < 0) { virDomainChrDefFree(chr); goto error; } @@ -2211,7 +2211,7 @@ qemuParseCommandLine(virCapsPtr caps, if (!(chr = virDomainChrDefNew(NULL))) goto error; - if (qemuParseCommandLineChr(&chr->source, val) < 0) { + if (qemuParseCommandLineChr(chr->source, val) < 0) { virDomainChrDefFree(chr); goto error; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d641f33..a1e2896 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -235,7 +235,7 @@ qemuConnectAgent(virQEMUDriverPtr driver, virDomainObjPtr vm) virObjectUnlock(vm); agent = qemuAgentOpen(vm, - &config->source, + config->source, &agentCallbacks); virObjectLock(vm); @@ -1836,7 +1836,7 @@ qemuProcessLookupPTYs(virDomainDefPtr def, virDomainChrDefPtr chr = devices[i]; bool chardevfmt = virQEMUCapsSupportsChardev(def, qemuCaps, chr); - if (chr->source.type == VIR_DOMAIN_CHR_TYPE_PTY) { + if (chr->source->type == VIR_DOMAIN_CHR_TYPE_PTY) { char id[32]; qemuMonitorChardevInfoPtr entry; @@ -1851,7 +1851,7 @@ qemuProcessLookupPTYs(virDomainDefPtr def, entry = virHashLookup(info, id); if (!entry || !entry->ptyPath) { - if (chr->source.data.file.path == NULL) { + if (chr->source->data.file.path == NULL) { /* neither the log output nor 'info chardev' had a * pty path for this chardev, report an error */ @@ -1866,8 +1866,8 @@ qemuProcessLookupPTYs(virDomainDefPtr def, } } - VIR_FREE(chr->source.data.file.path); - if (VIR_STRDUP(chr->source.data.file.path, entry->ptyPath) < 0) + VIR_FREE(chr->source->data.file.path); + if (VIR_STRDUP(chr->source->data.file.path, entry->ptyPath) < 0) return -1; } } @@ -1906,8 +1906,8 @@ qemuProcessFindCharDevicePTYsMonitor(virDomainObjPtr vm, chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) { /* yes, the first console is just an alias for serials[0] */ i = 1; - if (virDomainChrSourceDefCopy(&chr->source, - &((vm->def->serials[0])->source)) < 0) + if (virDomainChrSourceDefCopy(chr->source, + ((vm->def->serials[0])->source)) < 0) return -1; } } @@ -2500,14 +2500,14 @@ qemuProcessPrepareChardevDevice(virDomainDefPtr def ATTRIBUTE_UNUSED, void *opaque ATTRIBUTE_UNUSED) { int fd; - if (dev->source.type != VIR_DOMAIN_CHR_TYPE_FILE) + if (dev->source->type != VIR_DOMAIN_CHR_TYPE_FILE) return 0; - if ((fd = open(dev->source.data.file.path, + if ((fd = open(dev->source->data.file.path, O_CREAT | O_APPEND, S_IRUSR|S_IWUSR)) < 0) { virReportSystemError(errno, _("Unable to pre-create chardev file '%s'"), - dev->source.data.file.path); + dev->source->data.file.path); return -1; } @@ -2522,10 +2522,10 @@ qemuProcessCleanupChardevDevice(virDomainDefPtr def ATTRIBUTE_UNUSED, virDomainChrDefPtr dev, void *opaque ATTRIBUTE_UNUSED) { - if (dev->source.type == VIR_DOMAIN_CHR_TYPE_UNIX && - dev->source.data.nix.listen && - dev->source.data.nix.path) - unlink(dev->source.data.nix.path); + if (dev->source->type == VIR_DOMAIN_CHR_TYPE_UNIX && + dev->source->data.nix.listen && + dev->source->data.nix.path) + unlink(dev->source->data.nix.path); return 0; } diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 442ce70..fd74e8b 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -968,7 +968,7 @@ virSecurityDACRestoreChardevCallback(virDomainDefPtr def, { virSecurityManagerPtr mgr = opaque; - return virSecurityDACRestoreChardevLabel(mgr, def, dev, &dev->source); + return virSecurityDACRestoreChardevLabel(mgr, def, dev, dev->source); } @@ -1139,7 +1139,7 @@ virSecurityDACSetChardevCallback(virDomainDefPtr def, { virSecurityManagerPtr mgr = opaque; - return virSecurityDACSetChardevLabel(mgr, def, dev, &dev->source); + return virSecurityDACSetChardevLabel(mgr, def, dev, dev->source); } diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 4be946d..a98e0c0 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1934,7 +1934,7 @@ virSecuritySELinuxRestoreSecurityChardevCallback(virDomainDefPtr def, dev->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) return 0; - return virSecuritySELinuxRestoreChardevLabel(mgr, def, dev, &dev->source); + return virSecuritySELinuxRestoreChardevLabel(mgr, def, dev, dev->source); } @@ -2323,7 +2323,7 @@ virSecuritySELinuxSetSecurityChardevCallback(virDomainDefPtr def, dev->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) return 0; - return virSecuritySELinuxSetChardevLabel(mgr, def, dev, &dev->source); + return virSecuritySELinuxSetChardevLabel(mgr, def, dev, dev->source); } diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 28ee5ac..77eeaff 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -946,60 +946,60 @@ get_files(vahControl * ctl) for (i = 0; i < ctl->def->nserials; i++) if (ctl->def->serials[i] && - (ctl->def->serials[i]->source.type == VIR_DOMAIN_CHR_TYPE_PTY || - ctl->def->serials[i]->source.type == VIR_DOMAIN_CHR_TYPE_DEV || - ctl->def->serials[i]->source.type == VIR_DOMAIN_CHR_TYPE_FILE || - ctl->def->serials[i]->source.type == VIR_DOMAIN_CHR_TYPE_UNIX || - ctl->def->serials[i]->source.type == VIR_DOMAIN_CHR_TYPE_PIPE) && - ctl->def->serials[i]->source.data.file.path && - ctl->def->serials[i]->source.data.file.path[0] != '\0') + (ctl->def->serials[i]->source->type == VIR_DOMAIN_CHR_TYPE_PTY || + ctl->def->serials[i]->source->type == VIR_DOMAIN_CHR_TYPE_DEV || + ctl->def->serials[i]->source->type == VIR_DOMAIN_CHR_TYPE_FILE || + ctl->def->serials[i]->source->type == VIR_DOMAIN_CHR_TYPE_UNIX || + ctl->def->serials[i]->source->type == VIR_DOMAIN_CHR_TYPE_PIPE) && + ctl->def->serials[i]->source->data.file.path && + ctl->def->serials[i]->source->data.file.path[0] != '\0') if (vah_add_file_chardev(&buf, - ctl->def->serials[i]->source.data.file.path, + ctl->def->serials[i]->source->data.file.path, "rw", - ctl->def->serials[i]->source.type) != 0) + ctl->def->serials[i]->source->type) != 0) goto cleanup; for (i = 0; i < ctl->def->nconsoles; i++) if (ctl->def->consoles[i] && - (ctl->def->consoles[i]->source.type == VIR_DOMAIN_CHR_TYPE_PTY || - ctl->def->consoles[i]->source.type == VIR_DOMAIN_CHR_TYPE_DEV || - ctl->def->consoles[i]->source.type == VIR_DOMAIN_CHR_TYPE_FILE || - ctl->def->consoles[i]->source.type == VIR_DOMAIN_CHR_TYPE_UNIX || - ctl->def->consoles[i]->source.type == VIR_DOMAIN_CHR_TYPE_PIPE) && - ctl->def->consoles[i]->source.data.file.path && - ctl->def->consoles[i]->source.data.file.path[0] != '\0') + (ctl->def->consoles[i]->source->type == VIR_DOMAIN_CHR_TYPE_PTY || + ctl->def->consoles[i]->source->type == VIR_DOMAIN_CHR_TYPE_DEV || + ctl->def->consoles[i]->source->type == VIR_DOMAIN_CHR_TYPE_FILE || + ctl->def->consoles[i]->source->type == VIR_DOMAIN_CHR_TYPE_UNIX || + ctl->def->consoles[i]->source->type == VIR_DOMAIN_CHR_TYPE_PIPE) && + ctl->def->consoles[i]->source->data.file.path && + ctl->def->consoles[i]->source->data.file.path[0] != '\0') if (vah_add_file(&buf, - ctl->def->consoles[i]->source.data.file.path, "rw") != 0) + ctl->def->consoles[i]->source->data.file.path, "rw") != 0) goto cleanup; for (i = 0; i < ctl->def->nparallels; i++) if (ctl->def->parallels[i] && - (ctl->def->parallels[i]->source.type == VIR_DOMAIN_CHR_TYPE_PTY || - ctl->def->parallels[i]->source.type == VIR_DOMAIN_CHR_TYPE_DEV || - ctl->def->parallels[i]->source.type == VIR_DOMAIN_CHR_TYPE_FILE || - ctl->def->parallels[i]->source.type == VIR_DOMAIN_CHR_TYPE_UNIX || - ctl->def->parallels[i]->source.type == VIR_DOMAIN_CHR_TYPE_PIPE) && - ctl->def->parallels[i]->source.data.file.path && - ctl->def->parallels[i]->source.data.file.path[0] != '\0') + (ctl->def->parallels[i]->source->type == VIR_DOMAIN_CHR_TYPE_PTY || + ctl->def->parallels[i]->source->type == VIR_DOMAIN_CHR_TYPE_DEV || + ctl->def->parallels[i]->source->type == VIR_DOMAIN_CHR_TYPE_FILE || + ctl->def->parallels[i]->source->type == VIR_DOMAIN_CHR_TYPE_UNIX || + ctl->def->parallels[i]->source->type == VIR_DOMAIN_CHR_TYPE_PIPE) && + ctl->def->parallels[i]->source->data.file.path && + ctl->def->parallels[i]->source->data.file.path[0] != '\0') if (vah_add_file_chardev(&buf, - ctl->def->parallels[i]->source.data.file.path, + ctl->def->parallels[i]->source->data.file.path, "rw", - ctl->def->parallels[i]->source.type) != 0) + ctl->def->parallels[i]->source->type) != 0) goto cleanup; for (i = 0; i < ctl->def->nchannels; i++) if (ctl->def->channels[i] && - (ctl->def->channels[i]->source.type == VIR_DOMAIN_CHR_TYPE_PTY || - ctl->def->channels[i]->source.type == VIR_DOMAIN_CHR_TYPE_DEV || - ctl->def->channels[i]->source.type == VIR_DOMAIN_CHR_TYPE_FILE || - ctl->def->channels[i]->source.type == VIR_DOMAIN_CHR_TYPE_UNIX || - ctl->def->channels[i]->source.type == VIR_DOMAIN_CHR_TYPE_PIPE) && - ctl->def->channels[i]->source.data.file.path && - ctl->def->channels[i]->source.data.file.path[0] != '\0') + (ctl->def->channels[i]->source->type == VIR_DOMAIN_CHR_TYPE_PTY || + ctl->def->channels[i]->source->type == VIR_DOMAIN_CHR_TYPE_DEV || + ctl->def->channels[i]->source->type == VIR_DOMAIN_CHR_TYPE_FILE || + ctl->def->channels[i]->source->type == VIR_DOMAIN_CHR_TYPE_UNIX || + ctl->def->channels[i]->source->type == VIR_DOMAIN_CHR_TYPE_PIPE) && + ctl->def->channels[i]->source->data.file.path && + ctl->def->channels[i]->source->data.file.path[0] != '\0') if (vah_add_file_chardev(&buf, - ctl->def->channels[i]->source.data.file.path, + ctl->def->channels[i]->source->data.file.path, "rw", - ctl->def->channels[i]->source.type) != 0) + ctl->def->channels[i]->source->type) != 0) goto cleanup; if (ctl->def->os.kernel) diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index dc68203..6754d3c 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -290,7 +290,7 @@ umlBuildCommandLineChr(virDomainChrDefPtr def, { char *ret = NULL; - switch (def->source.type) { + switch (def->source->type) { case VIR_DOMAIN_CHR_TYPE_NULL: if (virAsprintf(&ret, "%s%d=null", dev, def->target.port) < 0) return NULL; @@ -303,7 +303,7 @@ umlBuildCommandLineChr(virDomainChrDefPtr def, case VIR_DOMAIN_CHR_TYPE_DEV: if (virAsprintf(&ret, "%s%d=tty:%s", dev, def->target.port, - def->source.data.file.path) < 0) + def->source->data.file.path) < 0) return NULL; break; @@ -313,14 +313,14 @@ umlBuildCommandLineChr(virDomainChrDefPtr def, break; case VIR_DOMAIN_CHR_TYPE_TCP: - if (def->source.data.tcp.listen != 1) { + if (def->source->data.tcp.listen != 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("only TCP listen is supported for chr device")); return NULL; } if (virAsprintf(&ret, "%s%d=port:%s", dev, def->target.port, - def->source.data.tcp.service) < 0) + def->source->data.tcp.service) < 0) return NULL; break; @@ -328,11 +328,11 @@ umlBuildCommandLineChr(virDomainChrDefPtr def, { int fd_out; - if ((fd_out = open(def->source.data.file.path, + if ((fd_out = open(def->source->data.file.path, O_WRONLY | O_APPEND | O_CREAT, 0660)) < 0) { virReportSystemError(errno, _("failed to open chardev file: %s"), - def->source.data.file.path); + def->source->data.file.path); return NULL; } if (virAsprintf(&ret, "%s%d=null,fd:%d", dev, def->target.port, fd_out) < 0) { @@ -352,7 +352,7 @@ umlBuildCommandLineChr(virDomainChrDefPtr def, case VIR_DOMAIN_CHR_TYPE_UNIX: default: virReportError(VIR_ERR_INTERNAL_ERROR, - _("unsupported chr device type %d"), def->source.type); + _("unsupported chr device type %d"), def->source->type); break; } diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 768ce52..4f4a69b 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -244,8 +244,8 @@ umlIdentifyOneChrPTY(struct uml_driver *driver, return -1; if (res && STRPREFIX(res, "pts:")) { - VIR_FREE(def->source.data.file.path); - if (VIR_STRDUP(def->source.data.file.path, res + 4) < 0) { + VIR_FREE(def->source->data.file.path); + if (VIR_STRDUP(def->source->data.file.path, res + 4) < 0) { VIR_FREE(res); VIR_FREE(cmd); return -1; @@ -274,13 +274,13 @@ umlIdentifyChrPTY(struct uml_driver *driver, size_t i; for (i = 0; i < dom->def->nconsoles; i++) - if (dom->def->consoles[i]->source.type == VIR_DOMAIN_CHR_TYPE_PTY) + if (dom->def->consoles[i]->source->type == VIR_DOMAIN_CHR_TYPE_PTY) if (umlIdentifyOneChrPTY(driver, dom, dom->def->consoles[i], "con") < 0) return -1; for (i = 0; i < dom->def->nserials; i++) - if (dom->def->serials[i]->source.type == VIR_DOMAIN_CHR_TYPE_PTY && + if (dom->def->serials[i]->source->type == VIR_DOMAIN_CHR_TYPE_PTY && umlIdentifyOneChrPTY(driver, dom, dom->def->serials[i], "ssl") < 0) return -1; @@ -2624,14 +2624,14 @@ umlDomainOpenConsole(virDomainPtr dom, goto cleanup; } - if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) { + if (chr->source->type != VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, _("character device %s is not using a PTY"), dev_name ? dev_name : NULLSTR(chr->info.alias)); goto cleanup; } - if (virFDStreamOpenFile(st, chr->source.data.file.path, + if (virFDStreamOpenFile(st, chr->source->data.file.path, 0, 0, O_RDWR) < 0) goto cleanup; diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index ab1a4c4..7848e39 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1430,7 +1430,7 @@ vboxAttachSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) ISerialPort *serialPort = NULL; PRUnichar *pathUtf16 = NULL; - VIR_DEBUG("SerialPort(%zu): Type: %d", i, def->serials[i]->source.type); + VIR_DEBUG("SerialPort(%zu): Type: %d", i, def->serials[i]->source->type); VIR_DEBUG("SerialPort(%zu): target.port: %d", i, def->serials[i]->target.port); @@ -1440,8 +1440,8 @@ vboxAttachSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) gVBoxAPI.UISerialPort.SetEnabled(serialPort, 1); - if (def->serials[i]->source.data.file.path) { - VBOX_UTF8_TO_UTF16(def->serials[i]->source.data.file.path, + if (def->serials[i]->source->data.file.path) { + VBOX_UTF8_TO_UTF16(def->serials[i]->source->data.file.path, &pathUtf16); gVBoxAPI.UISerialPort.SetPath(serialPort, pathUtf16); } @@ -1459,20 +1459,20 @@ vboxAttachSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) gVBoxAPI.UISerialPort.SetIRQ(serialPort, 4); gVBoxAPI.UISerialPort.SetIOBase(serialPort, 1016); VIR_DEBUG(" serialPort-%zu irq: %d, iobase 0x%x, path: %s", - i, 4, 1016, def->serials[i]->source.data.file.path); + i, 4, 1016, def->serials[i]->source->data.file.path); } else if (def->serials[i]->target.port == 1) { gVBoxAPI.UISerialPort.SetIRQ(serialPort, 3); gVBoxAPI.UISerialPort.SetIOBase(serialPort, 760); VIR_DEBUG(" serialPort-%zu irq: %d, iobase 0x%x, path: %s", - i, 3, 760, def->serials[i]->source.data.file.path); + i, 3, 760, def->serials[i]->source->data.file.path); } - if (def->serials[i]->source.type == VIR_DOMAIN_CHR_TYPE_DEV) { + if (def->serials[i]->source->type == VIR_DOMAIN_CHR_TYPE_DEV) { gVBoxAPI.UISerialPort.SetHostMode(serialPort, PortMode_HostDevice); - } else if (def->serials[i]->source.type == VIR_DOMAIN_CHR_TYPE_PIPE) { + } else if (def->serials[i]->source->type == VIR_DOMAIN_CHR_TYPE_PIPE) { gVBoxAPI.UISerialPort.SetHostMode(serialPort, PortMode_HostPipe); } else if (gVBoxAPI.APIVersion >= 2002051 && - def->serials[i]->source.type == VIR_DOMAIN_CHR_TYPE_FILE) { + def->serials[i]->source->type == VIR_DOMAIN_CHR_TYPE_FILE) { /* PortMode RawFile is used for vbox 3.0 or later */ gVBoxAPI.UISerialPort.SetHostMode(serialPort, PortMode_RawFile); } else { @@ -1505,7 +1505,7 @@ vboxAttachParallel(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) IParallelPort *parallelPort = NULL; PRUnichar *pathUtf16 = NULL; - VIR_DEBUG("ParallelPort(%zu): Type: %d", i, def->parallels[i]->source.type); + VIR_DEBUG("ParallelPort(%zu): Type: %d", i, def->parallels[i]->source->type); VIR_DEBUG("ParallelPort(%zu): target.port: %d", i, def->parallels[i]->target.port); @@ -1513,28 +1513,28 @@ vboxAttachParallel(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) if (!parallelPort) continue; - VBOX_UTF8_TO_UTF16(def->parallels[i]->source.data.file.path, &pathUtf16); + VBOX_UTF8_TO_UTF16(def->parallels[i]->source->data.file.path, &pathUtf16); /* For now hard code the parallel ports to * LPT1 (Base Addr: 0x378 (decimal: 888), IRQ: 7) * LPT2 (Base Addr: 0x278 (decimal: 632), IRQ: 5) * TODO: make this more flexible */ - if ((def->parallels[i]->source.type == VIR_DOMAIN_CHR_TYPE_DEV) || - (def->parallels[i]->source.type == VIR_DOMAIN_CHR_TYPE_PTY) || - (def->parallels[i]->source.type == VIR_DOMAIN_CHR_TYPE_FILE) || - (def->parallels[i]->source.type == VIR_DOMAIN_CHR_TYPE_PIPE)) { + if ((def->parallels[i]->source->type == VIR_DOMAIN_CHR_TYPE_DEV) || + (def->parallels[i]->source->type == VIR_DOMAIN_CHR_TYPE_PTY) || + (def->parallels[i]->source->type == VIR_DOMAIN_CHR_TYPE_FILE) || + (def->parallels[i]->source->type == VIR_DOMAIN_CHR_TYPE_PIPE)) { gVBoxAPI.UIParallelPort.SetPath(parallelPort, pathUtf16); if (i == 0) { gVBoxAPI.UIParallelPort.SetIRQ(parallelPort, 7); gVBoxAPI.UIParallelPort.SetIOBase(parallelPort, 888); VIR_DEBUG(" parallePort-%zu irq: %d, iobase 0x%x, path: %s", - i, 7, 888, def->parallels[i]->source.data.file.path); + i, 7, 888, def->parallels[i]->source->data.file.path); } else if (i == 1) { gVBoxAPI.UIParallelPort.SetIRQ(parallelPort, 5); gVBoxAPI.UIParallelPort.SetIOBase(parallelPort, 632); VIR_DEBUG(" parallePort-%zu irq: %d, iobase 0x%x, path: %s", - i, 5, 632, def->parallels[i]->source.data.file.path); + i, 5, 632, def->parallels[i]->source->data.file.path); } } @@ -3706,15 +3706,15 @@ vboxDumpSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PRU gVBoxAPI.UISerialPort.GetHostMode(serialPort, &hostMode); if (hostMode == PortMode_HostPipe) { - def->serials[serialPortIncCount]->source.type = VIR_DOMAIN_CHR_TYPE_PIPE; + def->serials[serialPortIncCount]->source->type = VIR_DOMAIN_CHR_TYPE_PIPE; } else if (hostMode == PortMode_HostDevice) { - def->serials[serialPortIncCount]->source.type = VIR_DOMAIN_CHR_TYPE_DEV; + def->serials[serialPortIncCount]->source->type = VIR_DOMAIN_CHR_TYPE_DEV; } else if (gVBoxAPI.APIVersion >= 2002051 && hostMode == PortMode_RawFile) { /* PortMode RawFile is used for vbox 3.0 or later */ - def->serials[serialPortIncCount]->source.type = VIR_DOMAIN_CHR_TYPE_FILE; + def->serials[serialPortIncCount]->source->type = VIR_DOMAIN_CHR_TYPE_FILE; } else { - def->serials[serialPortIncCount]->source.type = VIR_DOMAIN_CHR_TYPE_NULL; + def->serials[serialPortIncCount]->source->type = VIR_DOMAIN_CHR_TYPE_NULL; } def->serials[serialPortIncCount]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; @@ -3731,7 +3731,7 @@ vboxDumpSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PRU if (pathUtf16) { VBOX_UTF16_TO_UTF8(pathUtf16, &path); - ignore_value(VIR_STRDUP(def->serials[serialPortIncCount]->source.data.file.path, path)); + ignore_value(VIR_STRDUP(def->serials[serialPortIncCount]->source->data.file.path, path)); } serialPortIncCount++; @@ -3800,13 +3800,13 @@ vboxDumpParallel(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, P def->parallels[parallelPortIncCount]->target.port = 1; } - def->parallels[parallelPortIncCount]->source.type = VIR_DOMAIN_CHR_TYPE_FILE; + def->parallels[parallelPortIncCount]->source->type = VIR_DOMAIN_CHR_TYPE_FILE; def->parallels[parallelPortIncCount]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; gVBoxAPI.UIParallelPort.GetPath(parallelPort, &pathUtf16); VBOX_UTF16_TO_UTF8(pathUtf16, &path); - ignore_value(VIR_STRDUP(def->parallels[parallelPortIncCount]->source.data.file.path, path)); + ignore_value(VIR_STRDUP(def->parallels[parallelPortIncCount]->source->data.file.path, path)); parallelPortIncCount++; diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index f61c4d6..31af2e9 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2806,17 +2806,17 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port, */ if (!fileType || STRCASEEQ(fileType, "device")) { (*def)->target.port = port; - (*def)->source.type = VIR_DOMAIN_CHR_TYPE_DEV; - (*def)->source.data.file.path = fileName; + (*def)->source->type = VIR_DOMAIN_CHR_TYPE_DEV; + (*def)->source->data.file.path = fileName; fileName = NULL; } else if (STRCASEEQ(fileType, "file")) { (*def)->target.port = port; - (*def)->source.type = VIR_DOMAIN_CHR_TYPE_FILE; - (*def)->source.data.file.path = ctx->parseFileName(fileName, - ctx->opaque); + (*def)->source->type = VIR_DOMAIN_CHR_TYPE_FILE; + (*def)->source->data.file.path = ctx->parseFileName(fileName, + ctx->opaque); - if ((*def)->source.data.file.path == NULL) + if ((*def)->source->data.file.path == NULL) goto cleanup; } else if (STRCASEEQ(fileType, "pipe")) { /* @@ -2824,13 +2824,13 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port, * not representable in domain XML form */ (*def)->target.port = port; - (*def)->source.type = VIR_DOMAIN_CHR_TYPE_PIPE; - (*def)->source.data.file.path = fileName; + (*def)->source->type = VIR_DOMAIN_CHR_TYPE_PIPE; + (*def)->source->data.file.path = fileName; fileName = NULL; } else if (STRCASEEQ(fileType, "network")) { (*def)->target.port = port; - (*def)->source.type = VIR_DOMAIN_CHR_TYPE_TCP; + (*def)->source->type = VIR_DOMAIN_CHR_TYPE_TCP; if (!(parsedUri = virURIParse(fileName))) goto cleanup; @@ -2842,10 +2842,10 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port, goto cleanup; } - if (VIR_STRDUP((*def)->source.data.tcp.host, parsedUri->server) < 0) + if (VIR_STRDUP((*def)->source->data.tcp.host, parsedUri->server) < 0) goto cleanup; - if (virAsprintf(&(*def)->source.data.tcp.service, "%d", + if (virAsprintf(&(*def)->source->data.tcp.service, "%d", parsedUri->port) < 0) goto cleanup; @@ -2854,18 +2854,18 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port, STRCASEEQ(parsedUri->scheme, "tcp") || STRCASEEQ(parsedUri->scheme, "tcp4") || STRCASEEQ(parsedUri->scheme, "tcp6")) { - (*def)->source.data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW; + (*def)->source->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW; } else if (STRCASEEQ(parsedUri->scheme, "telnet")) { - (*def)->source.data.tcp.protocol + (*def)->source->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET; } else if (STRCASEEQ(parsedUri->scheme, "telnets")) { - (*def)->source.data.tcp.protocol + (*def)->source->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS; } else if (STRCASEEQ(parsedUri->scheme, "ssl") || STRCASEEQ(parsedUri->scheme, "tcp+ssl") || STRCASEEQ(parsedUri->scheme, "tcp4+ssl") || STRCASEEQ(parsedUri->scheme, "tcp6+ssl")) { - (*def)->source.data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS; + (*def)->source->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS; } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("VMX entry '%s' contains unsupported scheme '%s'"), @@ -2874,9 +2874,9 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port, } if (network_endPoint == NULL || STRCASEEQ(network_endPoint, "server")) { - (*def)->source.data.tcp.listen = true; + (*def)->source->data.tcp.listen = true; } else if (STRCASEEQ(network_endPoint, "client")) { - (*def)->source.data.tcp.listen = false; + (*def)->source->data.tcp.listen = false; } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("Expecting VMX entry '%s' to be 'server' or 'client' " @@ -2983,17 +2983,17 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port, /* Setup virDomainChrDef */ if (STRCASEEQ(fileType, "device")) { (*def)->target.port = port; - (*def)->source.type = VIR_DOMAIN_CHR_TYPE_DEV; - (*def)->source.data.file.path = fileName; + (*def)->source->type = VIR_DOMAIN_CHR_TYPE_DEV; + (*def)->source->data.file.path = fileName; fileName = NULL; } else if (STRCASEEQ(fileType, "file")) { (*def)->target.port = port; - (*def)->source.type = VIR_DOMAIN_CHR_TYPE_FILE; - (*def)->source.data.file.path = ctx->parseFileName(fileName, - ctx->opaque); + (*def)->source->type = VIR_DOMAIN_CHR_TYPE_FILE; + (*def)->source->data.file.path = ctx->parseFileName(fileName, + ctx->opaque); - if ((*def)->source.data.file.path == NULL) + if ((*def)->source->data.file.path == NULL) goto cleanup; } else { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3827,19 +3827,19 @@ virVMXFormatSerial(virVMXContext *ctx, virDomainChrDefPtr def, virBufferAsprintf(buffer, "serial%d.present = \"true\"\n", def->target.port); /* def:type -> vmx:fileType and def:data.file.path -> vmx:fileName */ - switch (def->source.type) { + switch (def->source->type) { case VIR_DOMAIN_CHR_TYPE_DEV: virBufferAsprintf(buffer, "serial%d.fileType = \"device\"\n", def->target.port); virBufferAsprintf(buffer, "serial%d.fileName = \"%s\"\n", - def->target.port, def->source.data.file.path); + def->target.port, def->source->data.file.path); break; case VIR_DOMAIN_CHR_TYPE_FILE: virBufferAsprintf(buffer, "serial%d.fileType = \"file\"\n", def->target.port); - fileName = ctx->formatFileName(def->source.data.file.path, ctx->opaque); + fileName = ctx->formatFileName(def->source->data.file.path, ctx->opaque); if (fileName == NULL) return -1; @@ -3860,11 +3860,11 @@ virVMXFormatSerial(virVMXContext *ctx, virDomainChrDefPtr def, virBufferAsprintf(buffer, "serial%d.tryNoRxLoss = \"false\"\n", def->target.port); virBufferAsprintf(buffer, "serial%d.fileName = \"%s\"\n", - def->target.port, def->source.data.file.path); + def->target.port, def->source->data.file.path); break; case VIR_DOMAIN_CHR_TYPE_TCP: - switch (def->source.data.tcp.protocol) { + switch (def->source->data.tcp.protocol) { case VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW: protocol = "tcp"; break; @@ -3885,24 +3885,24 @@ virVMXFormatSerial(virVMXContext *ctx, virDomainChrDefPtr def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported character device TCP protocol '%s'"), virDomainChrTcpProtocolTypeToString( - def->source.data.tcp.protocol)); + def->source->data.tcp.protocol)); return -1; } virBufferAsprintf(buffer, "serial%d.fileType = \"network\"\n", def->target.port); virBufferAsprintf(buffer, "serial%d.fileName = \"%s://%s:%s\"\n", - def->target.port, protocol, def->source.data.tcp.host, - def->source.data.tcp.service); + def->target.port, protocol, def->source->data.tcp.host, + def->source->data.tcp.service); virBufferAsprintf(buffer, "serial%d.network.endPoint = \"%s\"\n", def->target.port, - def->source.data.tcp.listen ? "server" : "client"); + def->source->data.tcp.listen ? "server" : "client"); break; default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported character device type '%s'"), - virDomainChrTypeToString(def->source.type)); + virDomainChrTypeToString(def->source->type)); return -1; } @@ -3933,19 +3933,19 @@ virVMXFormatParallel(virVMXContext *ctx, virDomainChrDefPtr def, def->target.port); /* def:type -> vmx:fileType and def:data.file.path -> vmx:fileName */ - switch (def->source.type) { + switch (def->source->type) { case VIR_DOMAIN_CHR_TYPE_DEV: virBufferAsprintf(buffer, "parallel%d.fileType = \"device\"\n", def->target.port); virBufferAsprintf(buffer, "parallel%d.fileName = \"%s\"\n", - def->target.port, def->source.data.file.path); + def->target.port, def->source->data.file.path); break; case VIR_DOMAIN_CHR_TYPE_FILE: virBufferAsprintf(buffer, "parallel%d.fileType = \"file\"\n", def->target.port); - fileName = ctx->formatFileName(def->source.data.file.path, ctx->opaque); + fileName = ctx->formatFileName(def->source->data.file.path, ctx->opaque); if (fileName == NULL) return -1; @@ -3959,7 +3959,7 @@ virVMXFormatParallel(virVMXContext *ctx, virDomainChrDefPtr def, default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported character device type '%s'"), - virDomainChrTypeToString(def->source.type)); + virDomainChrTypeToString(def->source->type)); return -1; } diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index f36064d..d10c2ac 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -1137,46 +1137,46 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomainChrDefPtr chr) switch (emulatedType) { case PDT_USE_OUTPUT_FILE: - chr->source.type = VIR_DOMAIN_CHR_TYPE_FILE; - chr->source.data.file.path = friendlyName; + chr->source->type = VIR_DOMAIN_CHR_TYPE_FILE; + chr->source->data.file.path = friendlyName; friendlyName = NULL; break; case PDT_USE_SERIAL_PORT_SOCKET_MODE: - chr->source.type = VIR_DOMAIN_CHR_TYPE_UNIX; - chr->source.data.nix.path = friendlyName; - chr->source.data.nix.listen = socket_mode == PSP_SERIAL_SOCKET_SERVER; + chr->source->type = VIR_DOMAIN_CHR_TYPE_UNIX; + chr->source->data.nix.path = friendlyName; + chr->source->data.nix.listen = socket_mode == PSP_SERIAL_SOCKET_SERVER; friendlyName = NULL; break; case PDT_USE_REAL_DEVICE: - chr->source.type = VIR_DOMAIN_CHR_TYPE_DEV; - chr->source.data.file.path = friendlyName; + chr->source->type = VIR_DOMAIN_CHR_TYPE_DEV; + chr->source->data.file.path = friendlyName; friendlyName = NULL; break; case PDT_USE_TCP: - chr->source.type = VIR_DOMAIN_CHR_TYPE_TCP; + chr->source->type = VIR_DOMAIN_CHR_TYPE_TCP; if (virAsprintf(&uristr, "tcp://%s", friendlyName) < 0) goto cleanup; if (!(uri = virURIParse(uristr))) goto cleanup; - if (VIR_STRDUP(chr->source.data.tcp.host, uri->server) < 0) + if (VIR_STRDUP(chr->source->data.tcp.host, uri->server) < 0) goto cleanup; - if (virAsprintf(&chr->source.data.tcp.service, "%d", uri->port) < 0) + if (virAsprintf(&chr->source->data.tcp.service, "%d", uri->port) < 0) goto cleanup; - chr->source.data.tcp.listen = socket_mode == PSP_SERIAL_SOCKET_SERVER; + chr->source->data.tcp.listen = socket_mode == PSP_SERIAL_SOCKET_SERVER; break; case PDT_USE_UDP: - chr->source.type = VIR_DOMAIN_CHR_TYPE_UDP; + chr->source->type = VIR_DOMAIN_CHR_TYPE_UDP; if (virAsprintf(&uristr, "udp://%s", friendlyName) < 0) goto cleanup; if (!(uri = virURIParse(uristr))) goto cleanup; - if (VIR_STRDUP(chr->source.data.udp.bindHost, uri->server) < 0) + if (VIR_STRDUP(chr->source->data.udp.bindHost, uri->server) < 0) goto cleanup; - if (virAsprintf(&chr->source.data.udp.bindService, "%d", uri->port) < 0) + if (virAsprintf(&chr->source->data.udp.bindService, "%d", uri->port) < 0) goto cleanup; - if (VIR_STRDUP(chr->source.data.udp.connectHost, uri->server) < 0) + if (VIR_STRDUP(chr->source->data.udp.connectHost, uri->server) < 0) goto cleanup; - if (virAsprintf(&chr->source.data.udp.connectService, "%d", uri->port) < 0) + if (virAsprintf(&chr->source->data.udp.connectService, "%d", uri->port) < 0) goto cleanup; break; default: @@ -2757,11 +2757,11 @@ static int prlsdkCheckSerialUnsupportedParams(virDomainChrDefPtr chr) return -1; } - if (chr->source.type != VIR_DOMAIN_CHR_TYPE_DEV && - chr->source.type != VIR_DOMAIN_CHR_TYPE_FILE && - chr->source.type != VIR_DOMAIN_CHR_TYPE_UNIX && - chr->source.type != VIR_DOMAIN_CHR_TYPE_TCP && - chr->source.type != VIR_DOMAIN_CHR_TYPE_UDP) { + if (chr->source->type != VIR_DOMAIN_CHR_TYPE_DEV && + chr->source->type != VIR_DOMAIN_CHR_TYPE_FILE && + chr->source->type != VIR_DOMAIN_CHR_TYPE_UNIX && + chr->source->type != VIR_DOMAIN_CHR_TYPE_TCP && + chr->source->type != VIR_DOMAIN_CHR_TYPE_UDP) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -2784,20 +2784,20 @@ static int prlsdkCheckSerialUnsupportedParams(virDomainChrDefPtr chr) return -1; } - if (chr->source.type == VIR_DOMAIN_CHR_TYPE_TCP && - chr->source.data.tcp.protocol != VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW) { + if (chr->source->type == VIR_DOMAIN_CHR_TYPE_TCP && + chr->source->data.tcp.protocol != VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Protocol '%s' is not supported for " "tcp character device."), - virDomainChrTcpProtocolTypeToString(chr->source.data.tcp.protocol)); + virDomainChrTcpProtocolTypeToString(chr->source->data.tcp.protocol)); return -1; } - if (chr->source.type == VIR_DOMAIN_CHR_TYPE_UDP && - (STRNEQ(chr->source.data.udp.bindHost, - chr->source.data.udp.connectHost) || - STRNEQ(chr->source.data.udp.bindService, - chr->source.data.udp.connectService))) { + if (chr->source->type == VIR_DOMAIN_CHR_TYPE_UDP && + (STRNEQ(chr->source->data.udp.bindHost, + chr->source->data.udp.connectHost) || + STRNEQ(chr->source->data.udp.bindService, + chr->source->data.udp.connectService))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Different bind and connect parameters for " "udp character device is not supported.")); @@ -3014,36 +3014,36 @@ static int prlsdkAddSerial(PRL_HANDLE sdkdom, virDomainChrDefPtr chr) pret = PrlVmCfg_CreateVmDev(sdkdom, PDE_SERIAL_PORT, &sdkchr); prlsdkCheckRetGoto(pret, cleanup); - switch (chr->source.type) { + switch (chr->source->type) { case VIR_DOMAIN_CHR_TYPE_DEV: emutype = PDT_USE_REAL_DEVICE; - path = chr->source.data.file.path; + path = chr->source->data.file.path; break; case VIR_DOMAIN_CHR_TYPE_FILE: emutype = PDT_USE_OUTPUT_FILE; - path = chr->source.data.file.path; + path = chr->source->data.file.path; break; case VIR_DOMAIN_CHR_TYPE_UNIX: emutype = PDT_USE_SERIAL_PORT_SOCKET_MODE; - path = chr->source.data.nix.path; - if (!chr->source.data.nix.listen) + path = chr->source->data.nix.path; + if (!chr->source->data.nix.listen) socket_mode = PSP_SERIAL_SOCKET_CLIENT; break; case VIR_DOMAIN_CHR_TYPE_TCP: emutype = PDT_USE_TCP; if (virAsprintf(&url, "%s:%s", - chr->source.data.tcp.host, - chr->source.data.tcp.service) < 0) + chr->source->data.tcp.host, + chr->source->data.tcp.service) < 0) goto cleanup; - if (!chr->source.data.tcp.listen) + if (!chr->source->data.tcp.listen) socket_mode = PSP_SERIAL_SOCKET_CLIENT; path = url; break; case VIR_DOMAIN_CHR_TYPE_UDP: emutype = PDT_USE_UDP; if (virAsprintf(&url, "%s:%s", - chr->source.data.udp.bindHost, - chr->source.data.udp.bindService) < 0) + chr->source->data.udp.bindHost, + chr->source->data.udp.bindService) < 0) goto cleanup; path = url; break; diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 165f37c..188c2d1 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -2542,14 +2542,14 @@ xenUnifiedDomainOpenConsole(virDomainPtr dom, goto cleanup; } - if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) { + if (chr->source->type != VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, _("character device %s is not using a PTY"), dev_name ? dev_name : NULLSTR(chr->info.alias)); goto cleanup; } - if (virFDStreamOpenFile(st, chr->source.data.file.path, + if (virFDStreamOpenFile(st, chr->source->data.file.path, 0, 0, O_RDWR) < 0) goto cleanup; diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index 990c4ef..baa68b1 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -196,8 +196,8 @@ xenParseSxprChar(const char *value, prefix = value; if (value[0] == '/') { - def->source.type = VIR_DOMAIN_CHR_TYPE_DEV; - if (VIR_STRDUP(def->source.data.file.path, value) < 0) + def->source->type = VIR_DOMAIN_CHR_TYPE_DEV; + if (VIR_STRDUP(def->source->data.file.path, value) < 0) goto error; } else { if ((tmp = strchr(value, ':')) != NULL) { @@ -206,10 +206,10 @@ xenParseSxprChar(const char *value, } if (STRPREFIX(prefix, "telnet")) { - def->source.type = VIR_DOMAIN_CHR_TYPE_TCP; - def->source.data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET; + def->source->type = VIR_DOMAIN_CHR_TYPE_TCP; + def->source->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET; } else { - if ((def->source.type = virDomainChrTypeFromString(prefix)) < 0) { + if ((def->source->type = virDomainChrTypeFromString(prefix)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown chr device type '%s'"), prefix); goto error; @@ -217,15 +217,15 @@ xenParseSxprChar(const char *value, } } - switch (def->source.type) { + switch (def->source->type) { case VIR_DOMAIN_CHR_TYPE_PTY: - if (VIR_STRDUP(def->source.data.file.path, tty) < 0) + if (VIR_STRDUP(def->source->data.file.path, tty) < 0) goto error; break; case VIR_DOMAIN_CHR_TYPE_FILE: case VIR_DOMAIN_CHR_TYPE_PIPE: - if (VIR_STRDUP(def->source.data.file.path, value) < 0) + if (VIR_STRDUP(def->source->data.file.path, value) < 0) goto error; break; @@ -241,17 +241,17 @@ xenParseSxprChar(const char *value, } if (offset != value && - VIR_STRNDUP(def->source.data.tcp.host, value, offset - value) < 0) + VIR_STRNDUP(def->source->data.tcp.host, value, offset - value) < 0) goto error; offset2 = strchr(offset, ','); offset++; - if (VIR_STRNDUP(def->source.data.tcp.service, offset, + if (VIR_STRNDUP(def->source->data.tcp.service, offset, offset2 ? offset2 - offset : -1) < 0) goto error; if (offset2 && strstr(offset2, ",server")) - def->source.data.tcp.listen = true; + def->source->data.tcp.listen = true; } break; @@ -267,12 +267,12 @@ xenParseSxprChar(const char *value, } if (offset != value && - VIR_STRNDUP(def->source.data.udp.connectHost, value, offset - value) < 0) + VIR_STRNDUP(def->source->data.udp.connectHost, value, offset - value) < 0) goto error; offset2 = strchr(offset, '@'); if (offset2 != NULL) { - if (VIR_STRNDUP(def->source.data.udp.connectService, + if (VIR_STRNDUP(def->source->data.udp.connectService, offset + 1, offset2 - offset - 1) < 0) goto error; @@ -284,14 +284,14 @@ xenParseSxprChar(const char *value, } if (offset3 > (offset2 + 1) && - VIR_STRNDUP(def->source.data.udp.bindHost, + VIR_STRNDUP(def->source->data.udp.bindHost, offset2 + 1, offset3 - offset2 - 1) < 0) goto error; - if (VIR_STRDUP(def->source.data.udp.bindService, offset3 + 1) < 0) + if (VIR_STRDUP(def->source->data.udp.bindService, offset3 + 1) < 0) goto error; } else { - if (VIR_STRDUP(def->source.data.udp.connectService, offset + 1) < 0) + if (VIR_STRDUP(def->source->data.udp.connectService, offset + 1) < 0) goto error; } } @@ -300,13 +300,13 @@ xenParseSxprChar(const char *value, case VIR_DOMAIN_CHR_TYPE_UNIX: { const char *offset = strchr(value, ','); - if (VIR_STRNDUP(def->source.data.nix.path, value, + if (VIR_STRNDUP(def->source->data.nix.path, value, offset ? offset - value : -1) < 0) goto error; if (offset != NULL && strstr(offset, ",server") != NULL) - def->source.data.nix.listen = true; + def->source->data.nix.listen = true; } break; } @@ -1630,7 +1630,7 @@ int xenFormatSxprChr(virDomainChrDefPtr def, virBufferPtr buf) { - const char *type = virDomainChrTypeToString(def->source.type); + const char *type = virDomainChrTypeToString(def->source->type); if (!type) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1638,7 +1638,7 @@ xenFormatSxprChr(virDomainChrDefPtr def, return -1; } - switch (def->source.type) { + switch (def->source->type) { case VIR_DOMAIN_CHR_TYPE_NULL: case VIR_DOMAIN_CHR_TYPE_STDIO: case VIR_DOMAIN_CHR_TYPE_VC: @@ -1649,42 +1649,42 @@ xenFormatSxprChr(virDomainChrDefPtr def, case VIR_DOMAIN_CHR_TYPE_FILE: case VIR_DOMAIN_CHR_TYPE_PIPE: virBufferAsprintf(buf, "%s:", type); - virBufferEscapeSexpr(buf, "%s", def->source.data.file.path); + virBufferEscapeSexpr(buf, "%s", def->source->data.file.path); break; case VIR_DOMAIN_CHR_TYPE_DEV: - virBufferEscapeSexpr(buf, "%s", def->source.data.file.path); + virBufferEscapeSexpr(buf, "%s", def->source->data.file.path); break; case VIR_DOMAIN_CHR_TYPE_TCP: virBufferAsprintf(buf, "%s:%s:%s%s", - (def->source.data.tcp.protocol + (def->source->data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW ? "tcp" : "telnet"), - (def->source.data.tcp.host ? - def->source.data.tcp.host : ""), - (def->source.data.tcp.service ? - def->source.data.tcp.service : ""), - (def->source.data.tcp.listen ? + (def->source->data.tcp.host ? + def->source->data.tcp.host : ""), + (def->source->data.tcp.service ? + def->source->data.tcp.service : ""), + (def->source->data.tcp.listen ? ",server,nowait" : "")); break; case VIR_DOMAIN_CHR_TYPE_UDP: virBufferAsprintf(buf, "%s:%s:%s@%s:%s", type, - (def->source.data.udp.connectHost ? - def->source.data.udp.connectHost : ""), - (def->source.data.udp.connectService ? - def->source.data.udp.connectService : ""), - (def->source.data.udp.bindHost ? - def->source.data.udp.bindHost : ""), - (def->source.data.udp.bindService ? - def->source.data.udp.bindService : "")); + (def->source->data.udp.connectHost ? + def->source->data.udp.connectHost : ""), + (def->source->data.udp.connectService ? + def->source->data.udp.connectService : ""), + (def->source->data.udp.bindHost ? + def->source->data.udp.bindHost : ""), + (def->source->data.udp.bindService ? + def->source->data.udp.bindService : "")); break; case VIR_DOMAIN_CHR_TYPE_UNIX: virBufferAsprintf(buf, "%s:", type); - virBufferEscapeSexpr(buf, "%s", def->source.data.nix.path); - if (def->source.data.nix.listen) + virBufferEscapeSexpr(buf, "%s", def->source->data.nix.path); + if (def->source->data.nix.listen) virBufferAddLit(buf, ",server,nowait"); break; diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index 742f1ef..04842f1 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -741,11 +741,11 @@ xenParseXLChannel(virConfPtr conf, virDomainDefPtr def) goto cleanup; if (STRPREFIX(type, "socket")) { - channel->source.type = VIR_DOMAIN_CHR_TYPE_UNIX; - channel->source.data.nix.path = path; - channel->source.data.nix.listen = 1; + channel->source->type = VIR_DOMAIN_CHR_TYPE_UNIX; + channel->source->data.nix.path = path; + channel->source->data.nix.listen = 1; } else if (STRPREFIX(type, "pty")) { - channel->source.type = VIR_DOMAIN_CHR_TYPE_PTY; + channel->source->type = VIR_DOMAIN_CHR_TYPE_PTY; VIR_FREE(path); } else { goto cleanup; @@ -1442,7 +1442,7 @@ static int xenFormatXLChannel(virConfValuePtr list, virDomainChrDefPtr channel) { virBuffer buf = VIR_BUFFER_INITIALIZER; - int sourceType = channel->source.type; + int sourceType = channel->source->type; virConfValuePtr val, tmp; /* connection */ @@ -1454,9 +1454,9 @@ xenFormatXLChannel(virConfValuePtr list, virDomainChrDefPtr channel) case VIR_DOMAIN_CHR_TYPE_UNIX: virBufferAddLit(&buf, "socket,"); /* path */ - if (channel->source.data.nix.path) + if (channel->source->data.nix.path) virBufferAsprintf(&buf, "path=%s,", - channel->source.data.nix.path); + channel->source->data.nix.path); break; default: goto cleanup; diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c index 1178acf..6d9c7ba 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -202,17 +202,17 @@ testSELinuxLoadDef(const char *testname) } for (i = 0; i < def->nserials; i++) { - if (def->serials[i]->source.type != VIR_DOMAIN_CHR_TYPE_FILE && - def->serials[i]->source.type != VIR_DOMAIN_CHR_TYPE_PIPE && - def->serials[i]->source.type != VIR_DOMAIN_CHR_TYPE_DEV && - def->serials[i]->source.type != VIR_DOMAIN_CHR_TYPE_UNIX) + if (def->serials[i]->source->type != VIR_DOMAIN_CHR_TYPE_FILE && + def->serials[i]->source->type != VIR_DOMAIN_CHR_TYPE_PIPE && + def->serials[i]->source->type != VIR_DOMAIN_CHR_TYPE_DEV && + def->serials[i]->source->type != VIR_DOMAIN_CHR_TYPE_UNIX) continue; - if (def->serials[i]->source.type == VIR_DOMAIN_CHR_TYPE_UNIX) { - if (testSELinuxMungePath(&def->serials[i]->source.data.nix.path) < 0) + if (def->serials[i]->source->type == VIR_DOMAIN_CHR_TYPE_UNIX) { + if (testSELinuxMungePath(&def->serials[i]->source->data.nix.path) < 0) goto cleanup; } else { - if (testSELinuxMungePath(&def->serials[i]->source.data.file.path) < 0) + if (testSELinuxMungePath(&def->serials[i]->source->data.file.path) < 0) goto cleanup; } } -- 2.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list