mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
Introduce virDomainChrSourceDefNew for virDomainChrDefPtr
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@redhat.com>
This commit is contained in:
parent
931864a3ea
commit
77a12987a4
@ -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 */
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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),
|
||||
|
@ -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,10 +10342,15 @@ virDomainChrDefNew(virDomainXMLOptionPtr xmlopt)
|
||||
|
||||
def->target.port = -1;
|
||||
|
||||
if (xmlopt && xmlopt->privateData.chardevNew &&
|
||||
!(def->privateData = xmlopt->privateData.chardevNew()))
|
||||
if (!(def->source = virDomainChrSourceDefNew()))
|
||||
VIR_FREE(def);
|
||||
|
||||
if (xmlopt && 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 */
|
||||
|
@ -1132,7 +1132,7 @@ struct _virDomainChrDef {
|
||||
|
||||
virDomainChrDeviceState state;
|
||||
|
||||
virDomainChrSourceDef source;
|
||||
virDomainChrSourceDefPtr source;
|
||||
|
||||
virDomainDeviceInfo info;
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -196,7 +196,7 @@ qemuSetupChardevCgroup(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
||||
{
|
||||
virDomainObjPtr vm = opaque;
|
||||
|
||||
return qemuSetupChrSourceCgroup(vm, &dev->source);
|
||||
return qemuSetupChrSourceCgroup(vm, dev->source);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5320,7 +5320,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 {
|
||||
@ -5354,7 +5354,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,
|
||||
@ -5364,12 +5364,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");
|
||||
@ -8533,13 +8533,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;
|
||||
@ -8551,7 +8551,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);
|
||||
@ -8578,7 +8578,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;
|
||||
@ -8591,7 +8591,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);
|
||||
@ -8624,7 +8624,7 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager,
|
||||
}
|
||||
|
||||
if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
|
||||
&channel->source,
|
||||
channel->source,
|
||||
channel->info.alias,
|
||||
qemuCaps, true)))
|
||||
return -1;
|
||||
@ -8640,14 +8640,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;
|
||||
@ -8690,7 +8690,7 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
|
||||
}
|
||||
|
||||
if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
|
||||
&console->source,
|
||||
console->source,
|
||||
console->info.alias,
|
||||
qemuCaps, true)))
|
||||
return -1;
|
||||
@ -8704,7 +8704,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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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++;
|
||||
|
||||
|
@ -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,
|
||||
(*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,
|
||||
(*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;
|
||||
}
|
||||
|
||||
|
@ -1148,46 +1148,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:
|
||||
@ -2768,11 +2768,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",
|
||||
@ -2795,20 +2795,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."));
|
||||
@ -3025,36 +3025,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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user